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>
This commit is contained in:
@@ -0,0 +1,63 @@
|
||||
'use client';
|
||||
|
||||
// Mira 共用 Markdown 渲染器(河道 + Wiki 共用)
|
||||
// SDD: polaris/mira/.agents/specs/mira-app/design.md §3.5.7
|
||||
|
||||
import { useMemo } from 'react';
|
||||
import ReactMarkdown from 'react-markdown';
|
||||
import remarkGfm from 'remark-gfm';
|
||||
|
||||
export function MarkdownView({ text }: { text: string }) {
|
||||
const cleaned = useMemo(() => stripLogseqMeta(text), [text]);
|
||||
return (
|
||||
<div className="mira-md">
|
||||
<ReactMarkdown
|
||||
remarkPlugins={[remarkGfm]}
|
||||
components={{
|
||||
a: ({ href, children, ...rest }) => (
|
||||
<a
|
||||
href={href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="wiki-link"
|
||||
{...rest}
|
||||
>
|
||||
{children}
|
||||
</a>
|
||||
),
|
||||
// 圖片不直接 inline 顯示(避免大圖打亂 feed),改成連結
|
||||
img: ({ src, alt }) => {
|
||||
const href = typeof src === 'string' ? src : '';
|
||||
return href ? (
|
||||
<a
|
||||
href={href}
|
||||
target="_blank"
|
||||
rel="noopener noreferrer"
|
||||
className="wiki-link"
|
||||
style={{ fontStyle: 'italic' }}
|
||||
>
|
||||
🖼 {alt || 'image'}
|
||||
</a>
|
||||
) : null;
|
||||
},
|
||||
}}
|
||||
>
|
||||
{cleaned}
|
||||
</ReactMarkdown>
|
||||
</div>
|
||||
);
|
||||
}
|
||||
|
||||
// Strip Logseq 專屬語法
|
||||
// - 屬性行:`xxx:: yyy`、`collapsed:: true`、`id:: ...`、`logseq.order-list-type:: ...`
|
||||
// - block ref:`((uuid))` 暫時保留為純文字
|
||||
export function stripLogseqMeta(text: string): string {
|
||||
return text
|
||||
.split('\n')
|
||||
.filter((line) => {
|
||||
const trimmed = line.trimStart();
|
||||
if (/^[a-zA-Z][a-zA-Z0-9_.-]*::\s/.test(trimmed)) return false;
|
||||
return true;
|
||||
})
|
||||
.join('\n');
|
||||
}
|
||||
File diff suppressed because it is too large
Load Diff
@@ -0,0 +1,87 @@
|
||||
'use client';
|
||||
|
||||
// Mira 子應用 layout
|
||||
// SDD: polaris/mira/.agents/specs/mira-app/design.md §5.5
|
||||
// 規範:白名單 user 進得去;非白名單 user 看到「即將開放」頁
|
||||
// middleware 已做未登入跳 /login?redirect=/mira 檢查(不在這裡重做)
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import SiteNav from '../components/SiteNav';
|
||||
import { MATRIX_APPS } from '../components/apps';
|
||||
|
||||
const API_BASE = process.env.NEXT_PUBLIC_API_BASE ?? 'https://cypher.arcrun.dev';
|
||||
|
||||
type Me = { email: string; display_name: string; api_key: string };
|
||||
|
||||
const MIRA = MATRIX_APPS.find(a => a.id === 'mira');
|
||||
const ALLOWED = new Set(MIRA?.allowlist_emails ?? []);
|
||||
|
||||
export default function MiraLayout({ children }: { children: React.ReactNode }) {
|
||||
const [me, setMe] = useState<Me | null | undefined>(undefined);
|
||||
|
||||
useEffect(() => {
|
||||
fetch(`${API_BASE}/me`, { credentials: 'include' })
|
||||
.then(r => r.ok ? r.json() as Promise<Me> : null)
|
||||
.then(u => setMe(u))
|
||||
.catch(() => setMe(null));
|
||||
}, []);
|
||||
|
||||
if (me === undefined) {
|
||||
return (
|
||||
<>
|
||||
<SiteNav currentPath="/mira" />
|
||||
<div className="flex-1 flex items-center justify-center text-[#666]">載入中…</div>
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
if (me === null) {
|
||||
// 理論上 middleware 已擋住,但保險
|
||||
if (typeof window !== 'undefined') {
|
||||
window.location.href = '/login?redirect=/mira';
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
||||
if (!ALLOWED.has(me.email)) {
|
||||
return (
|
||||
<>
|
||||
<SiteNav currentPath="/mira" />
|
||||
<BetaBlocked email={me.email} />
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
return (
|
||||
<>
|
||||
<SiteNav currentPath="/mira" />
|
||||
{children}
|
||||
</>
|
||||
);
|
||||
}
|
||||
|
||||
function BetaBlocked({ email }: { email: string }) {
|
||||
return (
|
||||
<main className="flex-1 flex items-center justify-center px-6">
|
||||
<div className="max-w-md text-center space-y-4">
|
||||
<div className="text-6xl mb-2">🌊</div>
|
||||
<h1 className="text-3xl font-bold text-white">Mira 仍封測中</h1>
|
||||
<p className="text-[#888] leading-relaxed">
|
||||
Mira 是 arcrun 的個人化 KM 河道,目前僅開放給少數測試用戶。
|
||||
</p>
|
||||
<p className="text-sm text-[#555]">
|
||||
你登入的帳號是 <span className="font-mono text-[#888]">{email}</span>,
|
||||
不在白名單內。準備好對外開放時會公告。
|
||||
</p>
|
||||
<div className="pt-4">
|
||||
<a
|
||||
href="/dashboard"
|
||||
className="inline-block bg-indigo-600 hover:bg-indigo-500 text-white px-5 py-2 rounded-md text-sm font-medium transition-colors"
|
||||
>
|
||||
回 Dashboard
|
||||
</a>
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,757 @@
|
||||
/* Mira — 社群貼文式 KM 河道
|
||||
* 視覺參考:Facebook / X / LinkedIn
|
||||
* Scope 在 .mira-app 容器內,避免汙染 landing 的 Tailwind 樣式
|
||||
*/
|
||||
|
||||
.mira-app {
|
||||
/* Surfaces */
|
||||
--mira-bg-0: #0e0e0d;
|
||||
--mira-bg-1: #1a1a18;
|
||||
--mira-bg-2: #252320;
|
||||
--mira-bg-3: #302d28;
|
||||
|
||||
--mira-line: #2e2c27;
|
||||
--mira-line-soft: #1f1d1a;
|
||||
|
||||
/* Text — 高對比 */
|
||||
--mira-text-1: #f0eee8;
|
||||
--mira-text-2: #c9c4b8;
|
||||
--mira-text-3: #9c968a;
|
||||
--mira-text-4: #6c685e;
|
||||
|
||||
--mira-accent: oklch(0.78 0.13 75);
|
||||
--mira-accent-soft: oklch(0.78 0.13 75 / 0.16);
|
||||
--mira-accent-line: oklch(0.78 0.13 75 / 0.4);
|
||||
|
||||
--mira-conflict: oklch(0.72 0.14 30);
|
||||
--mira-conflict-soft: oklch(0.72 0.14 30 / 0.13);
|
||||
|
||||
--mira-src-logseq: oklch(0.75 0.08 250);
|
||||
--mira-src-mobile: oklch(0.78 0.07 160);
|
||||
--mira-src-tg: oklch(0.78 0.08 220);
|
||||
--mira-src-rss: oklch(0.78 0.08 30);
|
||||
--mira-src-ai: oklch(0.82 0.10 95);
|
||||
|
||||
--mira-radius-sm: 6px;
|
||||
--mira-radius: 10px;
|
||||
--mira-radius-lg: 14px;
|
||||
|
||||
--mira-font-zh: "Noto Sans TC", "PingFang TC", "Microsoft JhengHei", system-ui, sans-serif;
|
||||
--mira-font-en: "Inter Tight", "Helvetica Neue", Helvetica, Arial, sans-serif;
|
||||
--mira-font-mono: "JetBrains Mono", "SF Mono", Menlo, monospace;
|
||||
|
||||
background: var(--mira-bg-0);
|
||||
color: var(--mira-text-1);
|
||||
font-family: var(--mira-font-zh);
|
||||
/* 不啟用 palt:保留中文標點全寬,避免標點看起來只有半寬 */
|
||||
-webkit-font-smoothing: antialiased;
|
||||
text-rendering: optimizeLegibility;
|
||||
letter-spacing: 0.01em;
|
||||
line-height: 1.65;
|
||||
min-height: calc(100vh - 73px);
|
||||
}
|
||||
|
||||
.mira-app .mira-num,
|
||||
.mira-app .mira-en {
|
||||
font-family: var(--mira-font-en);
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
.mira-app .mira-content {
|
||||
max-width: 920px;
|
||||
margin: 0 auto;
|
||||
padding: 24px 16px 80px;
|
||||
}
|
||||
|
||||
@media (max-width: 640px) {
|
||||
.mira-app .mira-content {
|
||||
padding: 12px 0 60px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── card 卡片 ── */
|
||||
.mira-app .mira-card {
|
||||
background: var(--mira-bg-1);
|
||||
border: 1px solid var(--mira-line);
|
||||
border-radius: var(--mira-radius);
|
||||
margin-bottom: 12px;
|
||||
/* 不要 overflow: hidden — 會 clip ⋮ menu dropdown */
|
||||
position: relative;
|
||||
}
|
||||
@media (max-width: 640px) {
|
||||
.mira-app .mira-card {
|
||||
border-radius: 0;
|
||||
border-left: none;
|
||||
border-right: none;
|
||||
margin-bottom: 8px;
|
||||
}
|
||||
}
|
||||
|
||||
/* ── composer 寫貼文 ── */
|
||||
.mira-app .mira-composer-card {
|
||||
padding: 14px 16px;
|
||||
}
|
||||
.mira-app .mira-composer-row {
|
||||
display: flex;
|
||||
gap: 12px;
|
||||
align-items: flex-start;
|
||||
}
|
||||
.mira-app .mira-composer-textarea {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
outline: none;
|
||||
resize: none;
|
||||
font-family: inherit;
|
||||
font-size: 16px;
|
||||
line-height: 1.65;
|
||||
color: var(--mira-text-1);
|
||||
padding: 8px 0;
|
||||
}
|
||||
.mira-app .mira-composer-textarea::placeholder {
|
||||
color: var(--mira-text-3);
|
||||
}
|
||||
.mira-app .mira-composer-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 10px;
|
||||
padding-top: 10px;
|
||||
margin-top: 8px;
|
||||
border-top: 1px solid var(--mira-line-soft);
|
||||
margin-left: 52px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* ── avatar ── */
|
||||
.mira-app .mira-avatar {
|
||||
border-radius: 50%;
|
||||
flex-shrink: 0;
|
||||
background: var(--mira-bg-2);
|
||||
object-fit: cover;
|
||||
}
|
||||
.mira-app .mira-avatar-fallback {
|
||||
display: grid;
|
||||
place-items: center;
|
||||
background: linear-gradient(135deg, var(--mira-bg-2), var(--mira-bg-3));
|
||||
color: var(--mira-text-1);
|
||||
font-weight: 600;
|
||||
font-family: var(--mira-font-en);
|
||||
}
|
||||
|
||||
/* ── post 貼文 ── */
|
||||
.mira-app .mira-post {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.mira-app .mira-post-header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 12px;
|
||||
padding: 14px 16px 10px;
|
||||
}
|
||||
.mira-app .mira-post-author {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
}
|
||||
.mira-app .mira-post-name {
|
||||
font-size: 14.5px;
|
||||
font-weight: 600;
|
||||
color: var(--mira-text-1);
|
||||
line-height: 1.3;
|
||||
}
|
||||
.mira-app .mira-post-time {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
font-size: 12px;
|
||||
color: var(--mira-text-3);
|
||||
font-family: var(--mira-font-en);
|
||||
margin-top: 2px;
|
||||
}
|
||||
|
||||
/* ── post body 內文 ── */
|
||||
.mira-app .mira-post-body {
|
||||
padding: 0 16px 12px;
|
||||
}
|
||||
.mira-app .mira-post-content {
|
||||
font-size: 15px;
|
||||
line-height: 1.7;
|
||||
color: var(--mira-text-1);
|
||||
word-break: break-word;
|
||||
white-space: normal;
|
||||
}
|
||||
.mira-app .mira-post-content-full {
|
||||
/* 展開模式:顯示每個 sub-block 為獨立行,可編輯 */
|
||||
font-size: 14.5px;
|
||||
}
|
||||
|
||||
/* react-markdown render 樣式 */
|
||||
.mira-app .mira-md > *:first-child { margin-top: 0; }
|
||||
.mira-app .mira-md > *:last-child { margin-bottom: 0; }
|
||||
|
||||
.mira-app .mira-md p {
|
||||
margin: 0 0 8px;
|
||||
line-height: 1.7;
|
||||
}
|
||||
|
||||
.mira-app .mira-md h1,
|
||||
.mira-app .mira-md h2,
|
||||
.mira-app .mira-md h3,
|
||||
.mira-app .mira-md h4,
|
||||
.mira-app .mira-md h5,
|
||||
.mira-app .mira-md h6 {
|
||||
margin: 14px 0 6px;
|
||||
font-weight: 700;
|
||||
color: var(--mira-text-1);
|
||||
line-height: 1.3;
|
||||
}
|
||||
.mira-app .mira-md h1 { font-size: 1.5em; }
|
||||
.mira-app .mira-md h2 { font-size: 1.3em; }
|
||||
.mira-app .mira-md h3 { font-size: 1.15em; font-weight: 600; }
|
||||
.mira-app .mira-md h4,
|
||||
.mira-app .mira-md h5,
|
||||
.mira-app .mira-md h6 { font-size: 1em; font-weight: 600; }
|
||||
|
||||
.mira-app .mira-md ul,
|
||||
.mira-app .mira-md ol {
|
||||
margin: 4px 0 8px;
|
||||
padding-left: 22px;
|
||||
}
|
||||
.mira-app .mira-md ul {
|
||||
list-style: disc;
|
||||
}
|
||||
.mira-app .mira-md ul ul {
|
||||
list-style: circle;
|
||||
}
|
||||
.mira-app .mira-md ul ul ul {
|
||||
list-style: square;
|
||||
}
|
||||
.mira-app .mira-md ol {
|
||||
list-style: decimal;
|
||||
}
|
||||
.mira-app .mira-md ul ul,
|
||||
.mira-app .mira-md ul ol,
|
||||
.mira-app .mira-md ol ul,
|
||||
.mira-app .mira-md ol ol {
|
||||
margin: 4px 0;
|
||||
}
|
||||
.mira-app .mira-md li {
|
||||
margin: 2px 0;
|
||||
line-height: 1.7;
|
||||
}
|
||||
/* GFM task list 的 li 不顯示 bullet(checkbox 取代)*/
|
||||
.mira-app .mira-md li:has(> input[type="checkbox"]) {
|
||||
list-style: none;
|
||||
margin-left: -22px;
|
||||
}
|
||||
.mira-app .mira-md li > p {
|
||||
margin: 0;
|
||||
}
|
||||
|
||||
.mira-app .mira-md blockquote {
|
||||
margin: 8px 0;
|
||||
padding: 4px 12px;
|
||||
border-left: 3px solid var(--mira-line);
|
||||
color: var(--mira-text-2);
|
||||
background: var(--mira-bg-2);
|
||||
border-radius: 0 4px 4px 0;
|
||||
}
|
||||
.mira-app .mira-md blockquote p:last-child { margin-bottom: 0; }
|
||||
|
||||
.mira-app .mira-md hr {
|
||||
border: none;
|
||||
border-top: 1px solid var(--mira-line);
|
||||
margin: 16px 0;
|
||||
}
|
||||
|
||||
.mira-app .mira-md code {
|
||||
font-family: var(--mira-font-mono);
|
||||
font-size: 0.9em;
|
||||
background: var(--mira-bg-2);
|
||||
padding: 1px 5px;
|
||||
border-radius: 4px;
|
||||
border: 1px solid var(--mira-line-soft);
|
||||
}
|
||||
.mira-app .mira-md pre {
|
||||
margin: 8px 0;
|
||||
padding: 12px;
|
||||
background: var(--mira-bg-2);
|
||||
border: 1px solid var(--mira-line-soft);
|
||||
border-radius: 6px;
|
||||
overflow-x: auto;
|
||||
}
|
||||
.mira-app .mira-md pre code {
|
||||
background: transparent;
|
||||
border: none;
|
||||
padding: 0;
|
||||
font-size: 0.85em;
|
||||
line-height: 1.6;
|
||||
}
|
||||
|
||||
.mira-app .mira-md table {
|
||||
border-collapse: collapse;
|
||||
margin: 8px 0;
|
||||
width: 100%;
|
||||
font-size: 0.95em;
|
||||
}
|
||||
.mira-app .mira-md th,
|
||||
.mira-app .mira-md td {
|
||||
border: 1px solid var(--mira-line);
|
||||
padding: 6px 10px;
|
||||
text-align: left;
|
||||
}
|
||||
.mira-app .mira-md th {
|
||||
background: var(--mira-bg-2);
|
||||
color: var(--mira-text-1);
|
||||
font-weight: 600;
|
||||
}
|
||||
.mira-app .mira-md tr:nth-child(even) {
|
||||
background: rgba(255, 255, 255, 0.02);
|
||||
}
|
||||
|
||||
.mira-app .mira-md strong { color: var(--mira-text-1); font-weight: 700; }
|
||||
.mira-app .mira-md em { font-style: italic; }
|
||||
.mira-app .mira-md del { color: var(--mira-text-3); }
|
||||
|
||||
/* GFM task list */
|
||||
.mira-app .mira-md input[type="checkbox"] {
|
||||
margin-right: 6px;
|
||||
vertical-align: middle;
|
||||
}
|
||||
|
||||
/* ── show more ── */
|
||||
.mira-app .mira-show-more {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--mira-accent);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
padding: 4px 0;
|
||||
margin-top: 4px;
|
||||
font-family: inherit;
|
||||
}
|
||||
.mira-app .mira-show-more:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
|
||||
/* ── footer 互動列 ── */
|
||||
.mira-app .mira-post-footer {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
border-top: 1px solid var(--mira-line-soft);
|
||||
padding: 4px 8px;
|
||||
margin: 0 8px;
|
||||
}
|
||||
.mira-app .mira-action-btn {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--mira-text-2);
|
||||
font-size: 13.5px;
|
||||
font-family: inherit;
|
||||
padding: 8px 14px;
|
||||
cursor: pointer;
|
||||
border-radius: 6px;
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 6px;
|
||||
transition: background 0.12s, color 0.12s;
|
||||
}
|
||||
.mira-app .mira-action-btn:hover,
|
||||
.mira-app .mira-action-btn:active {
|
||||
background: var(--mira-bg-2);
|
||||
color: var(--mira-text-1);
|
||||
}
|
||||
.mira-app .mira-action-count {
|
||||
font-size: 12px;
|
||||
color: var(--mira-text-3);
|
||||
font-family: var(--mira-font-en);
|
||||
}
|
||||
|
||||
/* ── replies 對整篇的留言 ── */
|
||||
.mira-app .mira-post-replies {
|
||||
background: var(--mira-bg-0);
|
||||
padding: 8px 16px;
|
||||
border-top: 1px solid var(--mira-line-soft);
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 6px;
|
||||
}
|
||||
.mira-app .mira-show-replies {
|
||||
background: transparent;
|
||||
border: none;
|
||||
color: var(--mira-text-2);
|
||||
font-size: 13px;
|
||||
cursor: pointer;
|
||||
padding: 6px 4px;
|
||||
text-align: left;
|
||||
font-family: inherit;
|
||||
font-weight: 500;
|
||||
}
|
||||
.mira-app .mira-show-replies:hover {
|
||||
text-decoration: underline;
|
||||
}
|
||||
.mira-app .mira-reply-composer {
|
||||
display: flex;
|
||||
gap: 10px;
|
||||
padding: 10px 16px;
|
||||
border-top: 1px solid var(--mira-line-soft);
|
||||
background: var(--mira-bg-0);
|
||||
align-items: flex-start;
|
||||
}
|
||||
|
||||
/* ── reply line ── */
|
||||
.mira-app .mira-reply-line {
|
||||
margin-bottom: 6px;
|
||||
padding: 8px 10px;
|
||||
background: var(--mira-bg-1);
|
||||
border-radius: 16px;
|
||||
display: flex;
|
||||
align-items: flex-start;
|
||||
gap: 8px;
|
||||
position: relative;
|
||||
}
|
||||
.mira-app .mira-reply-line.is-ai {
|
||||
background: var(--mira-accent-soft);
|
||||
}
|
||||
/* reply line 內的 ⋮ 永遠顯示(取代 hover only)*/
|
||||
.mira-app .mira-reply-line .mira-menu-wrap {
|
||||
opacity: 1;
|
||||
}
|
||||
.mira-app .mira-reply-icon {
|
||||
font-size: 13px;
|
||||
color: var(--mira-text-2);
|
||||
flex-shrink: 0;
|
||||
margin-top: 2px;
|
||||
}
|
||||
.mira-app .mira-reply-line.is-ai .mira-reply-icon {
|
||||
color: var(--mira-accent);
|
||||
}
|
||||
.mira-app .mira-reply-content {
|
||||
font-size: 13.5px;
|
||||
line-height: 1.6;
|
||||
color: var(--mira-text-1);
|
||||
word-break: break-word;
|
||||
white-space: normal;
|
||||
}
|
||||
.mira-app .mira-reply-nested {
|
||||
margin-left: 20px;
|
||||
margin-top: 4px;
|
||||
padding-left: 8px;
|
||||
border-left: 2px solid var(--mira-line-soft);
|
||||
}
|
||||
|
||||
/* ── source tag ── */
|
||||
.mira-app .src-tag {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
gap: 5px;
|
||||
padding: 1px 7px;
|
||||
border-radius: 999px;
|
||||
font-size: 11px;
|
||||
font-family: var(--mira-font-en);
|
||||
letter-spacing: 0.04em;
|
||||
background: var(--mira-bg-2);
|
||||
color: var(--mira-text-2);
|
||||
border: 1px solid var(--mira-line);
|
||||
}
|
||||
.mira-app .src-dot {
|
||||
width: 5px;
|
||||
height: 5px;
|
||||
border-radius: 50%;
|
||||
background: var(--mira-text-3);
|
||||
}
|
||||
.mira-app .src-tag.logseq .src-dot { background: var(--mira-src-logseq); }
|
||||
.mira-app .src-tag.mobile .src-dot { background: var(--mira-src-mobile); }
|
||||
.mira-app .src-tag.tg .src-dot { background: var(--mira-src-tg); }
|
||||
.mira-app .src-tag.rss .src-dot { background: var(--mira-src-rss); }
|
||||
.mira-app .src-tag.ai .src-dot { background: var(--mira-src-ai); }
|
||||
|
||||
/* ── wiki link ── */
|
||||
.mira-app .wiki-link {
|
||||
color: var(--mira-accent);
|
||||
cursor: pointer;
|
||||
text-decoration: none;
|
||||
border-bottom: 1px dashed var(--mira-accent-line);
|
||||
padding-bottom: 1px;
|
||||
}
|
||||
.mira-app .wiki-link:hover {
|
||||
background: var(--mira-accent-soft);
|
||||
}
|
||||
|
||||
/* ── empty state ── */
|
||||
.mira-app .empty-state {
|
||||
text-align: center;
|
||||
padding: 80px 20px;
|
||||
color: var(--mira-text-2);
|
||||
font-size: 13px;
|
||||
}
|
||||
|
||||
/* ── icon button ── */
|
||||
.mira-app .mira-icon-btn {
|
||||
width: 32px;
|
||||
height: 32px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 50%;
|
||||
cursor: pointer;
|
||||
color: var(--mira-text-2);
|
||||
background: transparent;
|
||||
border: none;
|
||||
font-size: 14px;
|
||||
line-height: 1;
|
||||
padding: 0;
|
||||
transition: background 0.12s, color 0.12s;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
.mira-app .mira-icon-btn:hover,
|
||||
.mira-app .mira-icon-btn:active {
|
||||
background: var(--mira-bg-2);
|
||||
color: var(--mira-text-1);
|
||||
}
|
||||
.mira-app .mira-icon-btn-vertical {
|
||||
font-size: 20px;
|
||||
font-weight: 700;
|
||||
letter-spacing: 0;
|
||||
}
|
||||
|
||||
/* ── ⋮ menu (dropdown) ── */
|
||||
.mira-app .mira-menu-wrap {
|
||||
position: relative;
|
||||
}
|
||||
.mira-app .mira-menu {
|
||||
position: absolute;
|
||||
right: 0;
|
||||
top: calc(100% + 4px);
|
||||
min-width: 160px;
|
||||
background: var(--mira-bg-1);
|
||||
border: 1px solid var(--mira-line);
|
||||
border-radius: 8px;
|
||||
box-shadow: 0 8px 24px rgba(0, 0, 0, 0.5);
|
||||
padding: 4px;
|
||||
z-index: 10;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
gap: 1px;
|
||||
}
|
||||
.mira-app .mira-menu-item {
|
||||
background: transparent;
|
||||
border: none;
|
||||
text-align: left;
|
||||
padding: 10px 14px;
|
||||
border-radius: 5px;
|
||||
color: var(--mira-text-1);
|
||||
font-size: 14px;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
transition: background 0.12s;
|
||||
}
|
||||
.mira-app .mira-menu-item:hover,
|
||||
.mira-app .mira-menu-item:active {
|
||||
background: var(--mira-bg-2);
|
||||
}
|
||||
.mira-app .mira-menu-item.danger {
|
||||
color: var(--mira-conflict);
|
||||
}
|
||||
.mira-app .mira-menu-item.danger:hover {
|
||||
background: var(--mira-conflict-soft);
|
||||
}
|
||||
|
||||
/* ── block-line(FullContent 模式)── */
|
||||
.mira-app .mira-block-line {
|
||||
position: relative;
|
||||
}
|
||||
.mira-app .mira-block-line .mira-menu-wrap {
|
||||
opacity: 0;
|
||||
transition: opacity 0.12s;
|
||||
}
|
||||
.mira-app .mira-block-line:hover .mira-menu-wrap {
|
||||
opacity: 1;
|
||||
}
|
||||
@media (hover: none) {
|
||||
/* 觸控裝置一律顯示 ⋮ */
|
||||
.mira-app .mira-block-line .mira-menu-wrap {
|
||||
opacity: 1;
|
||||
}
|
||||
}
|
||||
.mira-app .mira-menu-wrap:has(.mira-menu) { opacity: 1 !important; }
|
||||
|
||||
/* ── edit textarea ── */
|
||||
.mira-app .mira-edit-textarea {
|
||||
width: 100%;
|
||||
background: var(--mira-bg-0);
|
||||
border: 1px solid var(--mira-accent-line);
|
||||
border-radius: 8px;
|
||||
padding: 10px 12px;
|
||||
font-family: inherit;
|
||||
font-size: 14px;
|
||||
line-height: 1.7;
|
||||
color: var(--mira-text-1);
|
||||
resize: vertical;
|
||||
outline: none;
|
||||
}
|
||||
.mira-app .mira-edit-textarea:focus {
|
||||
border-color: var(--mira-accent);
|
||||
}
|
||||
.mira-app .mira-edit-textarea::placeholder {
|
||||
color: var(--mira-text-3);
|
||||
}
|
||||
.mira-app .mira-edit-actions {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 8px;
|
||||
margin-top: 6px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
|
||||
/* ── markdown toolbar ── */
|
||||
.mira-app .mira-md-toolbar {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
gap: 4px;
|
||||
padding: 6px 8px;
|
||||
background: var(--mira-bg-2);
|
||||
border: 1px solid var(--mira-line);
|
||||
border-bottom: none;
|
||||
border-top-left-radius: 8px;
|
||||
border-top-right-radius: 8px;
|
||||
flex-wrap: wrap;
|
||||
}
|
||||
/* compact 模式:給 PostComposer 的 actions 列 inline 用 */
|
||||
.mira-app .mira-md-toolbar.compact {
|
||||
padding: 0;
|
||||
background: transparent;
|
||||
border: none;
|
||||
gap: 2px;
|
||||
}
|
||||
.mira-app .mira-md-btn {
|
||||
background: transparent;
|
||||
border: none;
|
||||
width: 28px;
|
||||
height: 28px;
|
||||
display: grid;
|
||||
place-items: center;
|
||||
border-radius: 5px;
|
||||
color: var(--mira-text-2);
|
||||
cursor: pointer;
|
||||
font-size: 13px;
|
||||
font-family: inherit;
|
||||
transition: background 0.12s, color 0.12s;
|
||||
padding: 0;
|
||||
line-height: 1;
|
||||
}
|
||||
.mira-app .mira-md-btn:hover,
|
||||
.mira-app .mira-md-btn:active {
|
||||
background: var(--mira-bg-3);
|
||||
color: var(--mira-text-1);
|
||||
}
|
||||
.mira-app .mira-md-btn em {
|
||||
font-style: italic;
|
||||
font-family: serif;
|
||||
}
|
||||
.mira-app .mira-md-hint {
|
||||
margin-left: auto;
|
||||
font-size: 11px;
|
||||
color: var(--mira-text-3);
|
||||
font-family: var(--mira-font-en);
|
||||
}
|
||||
/* toolbar 之後的 textarea 接續成一塊 */
|
||||
.mira-app .mira-md-toolbar + .mira-edit-textarea {
|
||||
border-top-left-radius: 0;
|
||||
border-top-right-radius: 0;
|
||||
border-top: none;
|
||||
}
|
||||
|
||||
/* ── kbd 提示 ── */
|
||||
.mira-app .mira-kbd {
|
||||
font-size: 11px;
|
||||
color: var(--mira-text-3);
|
||||
font-family: var(--mira-font-en);
|
||||
}
|
||||
|
||||
/* ── messages ── */
|
||||
.mira-app .mira-msg-error {
|
||||
font-size: 12px;
|
||||
color: var(--mira-conflict);
|
||||
}
|
||||
.mira-app .mira-error {
|
||||
padding: 16px;
|
||||
color: var(--mira-conflict);
|
||||
font-size: 14px;
|
||||
}
|
||||
|
||||
/* ── buttons ── */
|
||||
.mira-app .mira-btn-primary {
|
||||
background: var(--mira-accent);
|
||||
border: none;
|
||||
color: var(--mira-bg-0);
|
||||
font-size: 13px;
|
||||
padding: 8px 18px;
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
font-weight: 600;
|
||||
font-family: inherit;
|
||||
transition: opacity 0.12s, background 0.12s;
|
||||
}
|
||||
.mira-app .mira-btn-primary:hover {
|
||||
opacity: 0.9;
|
||||
}
|
||||
.mira-app .mira-btn-primary:disabled,
|
||||
.mira-app .mira-btn-primary.disabled {
|
||||
background: var(--mira-bg-3);
|
||||
color: var(--mira-text-3);
|
||||
cursor: not-allowed;
|
||||
opacity: 1;
|
||||
}
|
||||
|
||||
.mira-app .mira-btn-ghost {
|
||||
background: transparent;
|
||||
border: 1px solid var(--mira-line);
|
||||
color: var(--mira-text-2);
|
||||
font-size: 12px;
|
||||
padding: 6px 14px;
|
||||
border-radius: 999px;
|
||||
cursor: pointer;
|
||||
font-family: inherit;
|
||||
}
|
||||
.mira-app .mira-btn-ghost:hover {
|
||||
background: var(--mira-bg-2);
|
||||
color: var(--mira-text-1);
|
||||
}
|
||||
|
||||
/* ── Mira 思考中(AI reply pending)── */
|
||||
.mira-app .mira-thinking {
|
||||
opacity: 0.7;
|
||||
}
|
||||
.mira-app .mira-thinking-dots::after {
|
||||
content: '⋯';
|
||||
display: inline-block;
|
||||
animation: mira-think-dots 1.4s infinite;
|
||||
}
|
||||
@keyframes mira-think-dots {
|
||||
0%, 100% { opacity: 0.3; }
|
||||
50% { opacity: 1; }
|
||||
}
|
||||
|
||||
/* ── skeleton loader ── */
|
||||
.mira-app .mira-skel {
|
||||
height: 60px;
|
||||
background: linear-gradient(
|
||||
90deg,
|
||||
var(--mira-bg-1) 0%,
|
||||
var(--mira-bg-2) 50%,
|
||||
var(--mira-bg-1) 100%
|
||||
);
|
||||
background-size: 200% 100%;
|
||||
animation: mira-skel-shimmer 1.4s ease-in-out infinite;
|
||||
border-radius: 6px;
|
||||
}
|
||||
@keyframes mira-skel-shimmer {
|
||||
0% { background-position: 200% 0; }
|
||||
100% { background-position: -200% 0; }
|
||||
}
|
||||
|
||||
/* ── rel time ── */
|
||||
.mira-app .mira-rel-time {
|
||||
cursor: default;
|
||||
}
|
||||
@@ -0,0 +1,122 @@
|
||||
'use client';
|
||||
|
||||
// Mira 首頁(Profile / KM Hub)
|
||||
// SDD: polaris/mira/.agents/specs/mira-app/design.md §5.2
|
||||
// 這頁是 leo 的 KM 首頁,列出所有同層子頁的入口
|
||||
// 河道 / Wiki 是同層子頁,不是父子關係
|
||||
|
||||
import Link from 'next/link';
|
||||
import './mira.css';
|
||||
|
||||
type Entry = {
|
||||
href: string;
|
||||
emoji: string;
|
||||
title: string;
|
||||
desc: string;
|
||||
status?: 'live' | 'wip' | 'planned';
|
||||
};
|
||||
|
||||
const ENTRIES: Entry[] = [
|
||||
{
|
||||
href: '/mira/feed',
|
||||
emoji: '🌊',
|
||||
title: '河道',
|
||||
desc: '時間軸式貼文流,所有 source 進來的內容都在這',
|
||||
status: 'live',
|
||||
},
|
||||
{
|
||||
href: '/mira/wiki',
|
||||
emoji: '📚',
|
||||
title: 'Wiki',
|
||||
desc: 'leo 的個人觀點累積(Karpathy LLM Wiki 風格)',
|
||||
status: 'live',
|
||||
},
|
||||
{
|
||||
href: '/mira/plan',
|
||||
emoji: '📋',
|
||||
title: '計劃',
|
||||
desc: 'Task 列表 + 狀態切換 + workflow 觸發',
|
||||
status: 'planned',
|
||||
},
|
||||
{
|
||||
href: '/mira/dissent',
|
||||
emoji: '⚔️',
|
||||
title: '異見牆',
|
||||
desc: 'Triplet 列表(含 ai-idea / 矛盾標記)',
|
||||
status: 'planned',
|
||||
},
|
||||
];
|
||||
|
||||
export default function MiraHubPage() {
|
||||
return (
|
||||
<main className="mira-app">
|
||||
<div className="mira-content">
|
||||
<header style={{ padding: '32px 0 24px' }}>
|
||||
<h1 style={{ fontSize: 32, fontWeight: 700, color: '#fff', margin: 0 }}>
|
||||
🦔 Mira
|
||||
</h1>
|
||||
<p style={{ color: '#888', fontSize: 15, marginTop: 6 }}>
|
||||
leo 的個人 KM 系統
|
||||
</p>
|
||||
</header>
|
||||
|
||||
<div style={{ display: 'grid', gap: 12, paddingBottom: 40 }}>
|
||||
{ENTRIES.map((e) => (
|
||||
<EntryCard key={e.href} entry={e} />
|
||||
))}
|
||||
</div>
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function EntryCard({ entry }: { entry: Entry }) {
|
||||
const isClickable = entry.status === 'live';
|
||||
const card = (
|
||||
<div
|
||||
style={{
|
||||
padding: '18px 20px',
|
||||
background: '#1a1a1a',
|
||||
border: '1px solid #2a2a2a',
|
||||
borderRadius: 8,
|
||||
opacity: isClickable ? 1 : 0.5,
|
||||
cursor: isClickable ? 'pointer' : 'not-allowed',
|
||||
transition: 'border-color 0.15s',
|
||||
}}
|
||||
onMouseEnter={(e) => {
|
||||
if (isClickable) e.currentTarget.style.borderColor = '#444';
|
||||
}}
|
||||
onMouseLeave={(e) => {
|
||||
if (isClickable) e.currentTarget.style.borderColor = '#2a2a2a';
|
||||
}}
|
||||
>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 6 }}>
|
||||
<span style={{ fontSize: 24 }}>{entry.emoji}</span>
|
||||
<span style={{ fontSize: 18, fontWeight: 600, color: '#fff' }}>
|
||||
{entry.title}
|
||||
</span>
|
||||
{entry.status === 'planned' && (
|
||||
<span
|
||||
style={{
|
||||
fontSize: 11,
|
||||
padding: '2px 8px',
|
||||
background: '#2a2a3a',
|
||||
color: '#aab',
|
||||
borderRadius: 3,
|
||||
}}
|
||||
>
|
||||
未實作
|
||||
</span>
|
||||
)}
|
||||
</div>
|
||||
<div style={{ color: '#888', fontSize: 14, marginLeft: 36 }}>{entry.desc}</div>
|
||||
</div>
|
||||
);
|
||||
return isClickable ? (
|
||||
<Link href={entry.href} style={{ textDecoration: 'none' }}>
|
||||
{card}
|
||||
</Link>
|
||||
) : (
|
||||
card
|
||||
);
|
||||
}
|
||||
@@ -0,0 +1,165 @@
|
||||
'use client';
|
||||
|
||||
export const runtime = 'edge';
|
||||
|
||||
// Mira Wiki 單篇頁
|
||||
// SDD: polaris/mira/.agents/specs/mira-app/design.md §5.2 + §3.5.7
|
||||
// 對應 task: 7C.2
|
||||
// 路由:/mira/wiki/[pageName]
|
||||
// 顯示單一 wiki block + 它的 children(wiki-paragraph)
|
||||
|
||||
import { useEffect, useState, use } from 'react';
|
||||
import Link from 'next/link';
|
||||
import { MarkdownView } from '../../_shared/markdown';
|
||||
import '../../mira.css';
|
||||
|
||||
const KBDB_BASE = 'https://kbdb.finally.click';
|
||||
const API_BASE = process.env.NEXT_PUBLIC_API_BASE ?? 'https://cypher.arcrun.dev';
|
||||
|
||||
type Block = {
|
||||
id: string;
|
||||
page_name: string;
|
||||
content: string;
|
||||
type: string;
|
||||
parent_id: string | null;
|
||||
tags_json: string | null;
|
||||
created_at: number;
|
||||
updated_at: number;
|
||||
};
|
||||
|
||||
export default function WikiPagePage({
|
||||
params,
|
||||
}: {
|
||||
params: Promise<{ pageName: string }>;
|
||||
}) {
|
||||
const { pageName } = use(params);
|
||||
const decodedName = decodeURIComponent(pageName);
|
||||
const [block, setBlock] = useState<Block | null>(null);
|
||||
const [siblings, setSiblings] = useState<Block[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
async function load() {
|
||||
try {
|
||||
const meRes = await fetch(`${API_BASE}/me`, { credentials: 'include' });
|
||||
if (!meRes.ok) throw new Error('未登入');
|
||||
const me = (await meRes.json()) as { api_key: string };
|
||||
const headers = { Authorization: `Bearer ${me.api_key}` };
|
||||
|
||||
const res = await fetch(
|
||||
`${KBDB_BASE}/blocks?page_name=${encodeURIComponent(decodedName)}&limit=1`,
|
||||
{ headers },
|
||||
);
|
||||
if (!res.ok) throw new Error(`KBDB ${res.status}`);
|
||||
const data = await res.json();
|
||||
const found: Block | undefined = data.blocks?.[0];
|
||||
if (cancelled) return;
|
||||
if (!found) {
|
||||
setError(`找不到 wiki page:${decodedName}`);
|
||||
return;
|
||||
}
|
||||
setBlock(found);
|
||||
|
||||
// 若這是個 child block,撈 parent 下其他 siblings 給導航用
|
||||
if (found.parent_id) {
|
||||
// KBDB 沒 children endpoint,用 page_name 找不到 siblings;先略過
|
||||
setSiblings([]);
|
||||
}
|
||||
} catch (e: any) {
|
||||
if (!cancelled) setError(e?.message ?? 'load failed');
|
||||
} finally {
|
||||
if (!cancelled) setLoading(false);
|
||||
}
|
||||
}
|
||||
load();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, [decodedName]);
|
||||
|
||||
const tags = parseTags(block?.tags_json);
|
||||
const subtype = tags
|
||||
.find((t) => t.startsWith('subtype:'))
|
||||
?.replace('subtype:', '');
|
||||
|
||||
return (
|
||||
<main className="mira-app">
|
||||
<div className="mira-content">
|
||||
<header style={{ padding: '24px 0 16px', borderBottom: '1px solid #2a2a2a' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 4 }}>
|
||||
<Link
|
||||
href="/mira/wiki"
|
||||
style={{ color: '#888', fontSize: 14, textDecoration: 'none' }}
|
||||
>
|
||||
← Wiki 索引
|
||||
</Link>
|
||||
</div>
|
||||
<h1 style={{ fontSize: 24, fontWeight: 700, color: '#fff', margin: 0 }}>
|
||||
{decodedName}
|
||||
</h1>
|
||||
{subtype && (
|
||||
<div style={{ marginTop: 6 }}>
|
||||
<span
|
||||
style={{
|
||||
display: 'inline-block',
|
||||
padding: '2px 8px',
|
||||
fontSize: 11,
|
||||
background: '#2a2a3a',
|
||||
color: '#aab',
|
||||
borderRadius: 3,
|
||||
}}
|
||||
>
|
||||
subtype: {subtype}
|
||||
</span>
|
||||
</div>
|
||||
)}
|
||||
</header>
|
||||
|
||||
{loading && <div style={{ padding: 24, color: '#666' }}>載入中⋯</div>}
|
||||
{error && (
|
||||
<div style={{ padding: 24, color: '#e66' }}>{error}</div>
|
||||
)}
|
||||
|
||||
{block && !loading && !error && (
|
||||
<>
|
||||
<article style={{ padding: '20px 0' }}>
|
||||
<MarkdownView text={block.content} />
|
||||
</article>
|
||||
|
||||
{/* 7C.3 contribution log placeholder(此頁是 schema/index/log infra 而非 wiki-page,先不顯示) */}
|
||||
|
||||
<footer
|
||||
style={{
|
||||
padding: '20px 0',
|
||||
borderTop: '1px solid #1f1f1f',
|
||||
color: '#555',
|
||||
fontSize: 12,
|
||||
}}
|
||||
>
|
||||
<div>id: <span style={{ fontFamily: 'monospace' }}>{block.id}</span></div>
|
||||
<div>type: {block.type}</div>
|
||||
{block.parent_id && (
|
||||
<div>
|
||||
parent: <span style={{ fontFamily: 'monospace' }}>{block.parent_id}</span>
|
||||
</div>
|
||||
)}
|
||||
{tags.length > 0 && <div>tags: {tags.join(', ')}</div>}
|
||||
<div>updated: {new Date(block.updated_at * 1000).toLocaleString('zh-TW')}</div>
|
||||
</footer>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function parseTags(tags_json: string | null | undefined): string[] {
|
||||
if (!tags_json) return [];
|
||||
try {
|
||||
return JSON.parse(tags_json) as string[];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,269 @@
|
||||
'use client';
|
||||
|
||||
// Mira Wiki 索引頁
|
||||
// SDD: polaris/mira/.agents/specs/mira-app/design.md §5.2 + §3.5.10
|
||||
// 對應 task: 7C.1
|
||||
// 階段 7-A 已建:mira-wiki-schema、mira-wiki-index(+4 children)、mira-wiki-log(+1 child)
|
||||
// 此頁列出這些 infra block 與既有 wiki-page,方便 leo 在瀏覽器確認 schema 寫得對不對
|
||||
|
||||
import { useEffect, useState } from 'react';
|
||||
import Link from 'next/link';
|
||||
import '../mira.css';
|
||||
|
||||
const KBDB_BASE = 'https://kbdb.finally.click';
|
||||
const API_BASE = process.env.NEXT_PUBLIC_API_BASE ?? 'https://cypher.arcrun.dev';
|
||||
|
||||
type Block = {
|
||||
id: string;
|
||||
page_name: string;
|
||||
content: string;
|
||||
type: string;
|
||||
parent_id: string | null;
|
||||
tags_json: string | null;
|
||||
created_at: number;
|
||||
};
|
||||
|
||||
export default function WikiIndexPage() {
|
||||
const [schema, setSchema] = useState<Block | null>(null);
|
||||
const [indexChildren, setIndexChildren] = useState<Block[]>([]);
|
||||
const [logEntries, setLogEntries] = useState<Block[]>([]);
|
||||
const [otherWikiPages, setOtherWikiPages] = useState<Block[]>([]);
|
||||
const [loading, setLoading] = useState(true);
|
||||
const [error, setError] = useState<string | null>(null);
|
||||
|
||||
useEffect(() => {
|
||||
let cancelled = false;
|
||||
async function load() {
|
||||
try {
|
||||
// 先拿 ak_ partner key(同 page.tsx pattern)
|
||||
const meRes = await fetch(`${API_BASE}/me`, { credentials: 'include' });
|
||||
if (!meRes.ok) throw new Error('未登入');
|
||||
const me = (await meRes.json()) as { api_key: string };
|
||||
const headers = { Authorization: `Bearer ${me.api_key}` };
|
||||
|
||||
// 用 tag=mira-wiki 一次撈所有相關 blocks(KBDB list endpoint 2026-05-07 加了 tag filter)
|
||||
const res = await fetch(
|
||||
`${KBDB_BASE}/blocks?tag=mira-wiki&limit=200`,
|
||||
{ headers },
|
||||
);
|
||||
if (!res.ok) throw new Error(`KBDB ${res.status}`);
|
||||
const data = await res.json();
|
||||
if (cancelled) return;
|
||||
const blocks: Block[] = data.blocks ?? [];
|
||||
|
||||
const tagsOf = (b: Block): string[] => {
|
||||
if (!b.tags_json) return [];
|
||||
try {
|
||||
return JSON.parse(b.tags_json) as string[];
|
||||
} catch {
|
||||
return [];
|
||||
}
|
||||
};
|
||||
const hasSubtype = (b: Block, st: string) =>
|
||||
tagsOf(b).includes(`subtype:${st}`);
|
||||
const hasAnyInfraSubtype = (b: Block) =>
|
||||
['schema', 'index', 'index-child', 'log', 'log-child'].some((st) => hasSubtype(b, st));
|
||||
const hasMetaTag = (b: Block) =>
|
||||
tagsOf(b).some((t) => t === 'data-source-config' || t === 'source-skill');
|
||||
|
||||
setSchema(blocks.find((b) => hasSubtype(b, 'schema')) ?? null);
|
||||
setIndexChildren(
|
||||
blocks
|
||||
.filter((b) => hasSubtype(b, 'index-child'))
|
||||
.sort((a, b) => a.page_name.localeCompare(b.page_name)),
|
||||
);
|
||||
setLogEntries(
|
||||
blocks
|
||||
.filter((b) => hasSubtype(b, 'log-child'))
|
||||
.sort((a, b) => b.page_name.localeCompare(a.page_name)),
|
||||
);
|
||||
// 真正的 wiki-page paragraphs(排除 infra 跟 meta 配置)
|
||||
setOtherWikiPages(
|
||||
blocks
|
||||
.filter((b) => !hasAnyInfraSubtype(b) && !hasMetaTag(b))
|
||||
.sort((a, b) => (b.created_at ?? 0) - (a.created_at ?? 0)),
|
||||
);
|
||||
} catch (e: any) {
|
||||
if (!cancelled) setError(e?.message ?? 'load failed');
|
||||
} finally {
|
||||
if (!cancelled) setLoading(false);
|
||||
}
|
||||
}
|
||||
load();
|
||||
return () => {
|
||||
cancelled = true;
|
||||
};
|
||||
}, []);
|
||||
|
||||
return (
|
||||
<main className="mira-app">
|
||||
<div className="mira-content">
|
||||
<header style={{ padding: '24px 0 16px', borderBottom: '1px solid #2a2a2a' }}>
|
||||
<div style={{ display: 'flex', alignItems: 'center', gap: 12, marginBottom: 4 }}>
|
||||
<Link
|
||||
href="/mira"
|
||||
style={{ color: '#888', fontSize: 14, textDecoration: 'none' }}
|
||||
>
|
||||
← Mira 首頁
|
||||
</Link>
|
||||
</div>
|
||||
<h1 style={{ fontSize: 28, fontWeight: 700, color: '#fff', margin: 0 }}>
|
||||
📚 Mira Wiki
|
||||
</h1>
|
||||
<p style={{ color: '#888', fontSize: 14, marginTop: 4 }}>
|
||||
leo 的個人觀點累積(Karpathy LLM Wiki 風格)
|
||||
</p>
|
||||
</header>
|
||||
|
||||
{loading && <div style={{ padding: 24, color: '#666' }}>載入中⋯</div>}
|
||||
{error && (
|
||||
<div style={{ padding: 24, color: '#e66' }}>讀取失敗:{error}</div>
|
||||
)}
|
||||
|
||||
{!loading && !error && (
|
||||
<>
|
||||
<Section title="📋 Schema(合成規則)">
|
||||
{schema ? (
|
||||
<WikiCardLink page_name={schema.page_name} title="mira-wiki-schema" excerpt="ingest 規則手冊:cypher binding、17 predicates、entity normalize⋯" />
|
||||
) : (
|
||||
<Empty>尚未建立 schema</Empty>
|
||||
)}
|
||||
</Section>
|
||||
|
||||
<Section title="🗂 Index(4 個分類)">
|
||||
{indexChildren.length > 0 ? (
|
||||
<div style={{ display: 'grid', gap: 8 }}>
|
||||
{indexChildren.map((b) => {
|
||||
const tags = b.tags_json ? (JSON.parse(b.tags_json) as string[]) : [];
|
||||
const key = tags.find((t) => t.startsWith('index-key:'))?.replace('index-key:', '') ?? '?';
|
||||
return (
|
||||
<WikiCardLink
|
||||
key={b.id}
|
||||
page_name={b.page_name}
|
||||
title={`${iconForKey(key)} ${key}`}
|
||||
excerpt={firstLineOf(b.content)}
|
||||
/>
|
||||
);
|
||||
})}
|
||||
</div>
|
||||
) : (
|
||||
<Empty>index children 尚未建立</Empty>
|
||||
)}
|
||||
</Section>
|
||||
|
||||
<Section title="📜 Log(每月一筆)">
|
||||
{logEntries.length > 0 ? (
|
||||
<div style={{ display: 'grid', gap: 8 }}>
|
||||
{logEntries.map((b) => (
|
||||
<WikiCardLink
|
||||
key={b.id}
|
||||
page_name={b.page_name}
|
||||
title={b.page_name}
|
||||
excerpt={firstLineOf(b.content)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<Empty>尚未有 log</Empty>
|
||||
)}
|
||||
</Section>
|
||||
|
||||
<Section title={`📖 Wiki Pages(${otherWikiPages.length})`}>
|
||||
{otherWikiPages.length > 0 ? (
|
||||
<div style={{ display: 'grid', gap: 8 }}>
|
||||
{otherWikiPages.map((p) => (
|
||||
<WikiCardLink
|
||||
key={p.id}
|
||||
page_name={p.page_name}
|
||||
title={p.page_name}
|
||||
excerpt={firstLineOf(p.content)}
|
||||
/>
|
||||
))}
|
||||
</div>
|
||||
) : (
|
||||
<Empty>尚未有 wiki page(待 7-B ai-canon-wiki workflow 跑出第一張)</Empty>
|
||||
)}
|
||||
</Section>
|
||||
</>
|
||||
)}
|
||||
</div>
|
||||
</main>
|
||||
);
|
||||
}
|
||||
|
||||
function Section({ title, children }: { title: string; children: React.ReactNode }) {
|
||||
return (
|
||||
<section style={{ padding: '20px 0', borderBottom: '1px solid #1f1f1f' }}>
|
||||
<h2 style={{ fontSize: 16, fontWeight: 600, color: '#ddd', marginBottom: 12 }}>
|
||||
{title}
|
||||
</h2>
|
||||
{children}
|
||||
</section>
|
||||
);
|
||||
}
|
||||
|
||||
function Empty({ children }: { children: React.ReactNode }) {
|
||||
return (
|
||||
<div style={{ color: '#555', fontStyle: 'italic', fontSize: 13 }}>{children}</div>
|
||||
);
|
||||
}
|
||||
|
||||
function WikiCardLink({
|
||||
page_name,
|
||||
title,
|
||||
excerpt,
|
||||
}: {
|
||||
page_name: string;
|
||||
title: string;
|
||||
excerpt: string;
|
||||
}) {
|
||||
return (
|
||||
<Link
|
||||
href={`/mira/wiki/${encodeURIComponent(page_name)}`}
|
||||
style={{
|
||||
display: 'block',
|
||||
padding: '12px 14px',
|
||||
background: '#1a1a1a',
|
||||
border: '1px solid #2a2a2a',
|
||||
borderRadius: 6,
|
||||
textDecoration: 'none',
|
||||
color: 'inherit',
|
||||
}}
|
||||
>
|
||||
<div style={{ color: '#ddd', fontWeight: 500, marginBottom: 4 }}>{title}</div>
|
||||
{excerpt && (
|
||||
<div
|
||||
style={{
|
||||
color: '#888',
|
||||
fontSize: 13,
|
||||
overflow: 'hidden',
|
||||
textOverflow: 'ellipsis',
|
||||
whiteSpace: 'nowrap',
|
||||
}}
|
||||
>
|
||||
{excerpt}
|
||||
</div>
|
||||
)}
|
||||
</Link>
|
||||
);
|
||||
}
|
||||
|
||||
function iconForKey(key: string): string {
|
||||
return (
|
||||
{
|
||||
entities: '🧩',
|
||||
topics: '📂',
|
||||
sources: '🔗',
|
||||
stale: '⚠️',
|
||||
}[key] ?? '•'
|
||||
);
|
||||
}
|
||||
|
||||
function firstLineOf(content: string): string {
|
||||
if (!content) return '';
|
||||
const firstNonHeader = content
|
||||
.split('\n')
|
||||
.map((l) => l.trim())
|
||||
.find((l) => l && !l.startsWith('#') && !l.startsWith('>'));
|
||||
return firstNonHeader ?? '';
|
||||
}
|
||||
Reference in New Issue
Block a user