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:
2026-05-07 16:52:01 +08:00
parent e8fca33f80
commit 519423cb0d
127 changed files with 23909 additions and 264 deletions
+3 -15
View File
@@ -2,6 +2,7 @@
import { useEffect, useRef } from 'react';
import Link from 'next/link';
import SiteNav from '../components/SiteNav';
const API_BASE = process.env.NEXT_PUBLIC_API_BASE ?? 'https://cypher.arcrun.dev';
@@ -25,7 +26,7 @@ export default function ApiDocsPage() {
const SwaggerUIBundle = (window as unknown as { SwaggerUIBundle: (opts: unknown) => void }).SwaggerUIBundle;
if (!SwaggerUIBundle || !containerRef.current) return;
SwaggerUIBundle({
url: `${API_BASE}/docs`,
url: `${API_BASE}/openapi.json`,
dom_id: '#swagger-ui',
presets: [(window as unknown as { SwaggerUIBundle: { presets: { apis: unknown } } }).SwaggerUIBundle.presets.apis],
layout: 'BaseLayout',
@@ -51,20 +52,7 @@ export default function ApiDocsPage() {
return (
<div className="min-h-screen bg-[#0a0a0a] text-[#ededed]">
{/* Nav */}
<nav className="flex items-center justify-between px-6 py-4 border-b border-[#1a1a1a]">
<Link href="/" className="text-white font-bold text-lg tracking-tight hover:opacity-80 transition-opacity">
arcrun
</Link>
<div className="flex items-center gap-4 text-sm">
<Link href="/integrations" className="text-[#666] hover:text-white transition-colors">Integrations</Link>
<Link href="/dashboard" className="text-[#666] hover:text-white transition-colors">Dashboard</Link>
<Link href="/login"
className="bg-indigo-600 hover:bg-indigo-500 text-white px-4 py-1.5 rounded-md text-sm font-medium transition-colors">
Get API Key
</Link>
</div>
</nav>
<SiteNav currentPath="/api-docs" />
{/* Header */}
<div className="max-w-5xl mx-auto px-6 py-8">
+90
View File
@@ -0,0 +1,90 @@
'use client';
// 九宮格 App Launcher(受 Google Apps menu 啟發)
// 規範:matrix/identity/.agents/specs/identity/design.md §2.5
// 非白名單 user 看到 mira 等受限 app 顯示為灰色 + tooltip「即將開放」
import { useEffect, useRef, useState } from 'react';
import { MATRIX_APPS, isAppAccessible, type AppEntry } from './apps';
export default function AppLauncher({ userEmail }: { userEmail: string | null }) {
const [open, setOpen] = useState(false);
const ref = useRef<HTMLDivElement>(null);
useEffect(() => {
if (!open) return;
const onClickOutside = (e: MouseEvent) => {
if (ref.current && !ref.current.contains(e.target as Node)) setOpen(false);
};
document.addEventListener('mousedown', onClickOutside);
return () => document.removeEventListener('mousedown', onClickOutside);
}, [open]);
return (
<div className="relative" ref={ref}>
<button
type="button"
onClick={() => setOpen(o => !o)}
aria-label="切換應用"
className="flex items-center justify-center w-9 h-9 rounded-md text-[#888] hover:text-white hover:bg-[#1a1a1a] transition-colors"
>
{/* 九宮格 icon */}
<svg width="18" height="18" viewBox="0 0 18 18" fill="currentColor">
<circle cx="3" cy="3" r="1.5" /><circle cx="9" cy="3" r="1.5" /><circle cx="15" cy="3" r="1.5" />
<circle cx="3" cy="9" r="1.5" /><circle cx="9" cy="9" r="1.5" /><circle cx="15" cy="9" r="1.5" />
<circle cx="3" cy="15" r="1.5" /><circle cx="9" cy="15" r="1.5" /><circle cx="15" cy="15" r="1.5" />
</svg>
</button>
{open && (
<div
className="absolute right-0 mt-2 w-72 bg-[#0f0f0f] border border-[#222] rounded-lg shadow-xl p-2 z-50"
role="menu"
>
<div className="grid grid-cols-3 gap-1">
{MATRIX_APPS.map(app => (
<AppTile key={app.id} app={app} userEmail={userEmail} onClose={() => setOpen(false)} />
))}
</div>
</div>
)}
</div>
);
}
function AppTile({
app,
userEmail,
onClose,
}: {
app: AppEntry;
userEmail: string | null;
onClose: () => void;
}) {
const accessible = isAppAccessible(app, userEmail);
const tooltip = !accessible ? (app.locked_tooltip ?? '即將開放') : (app.description ?? '');
if (!accessible) {
return (
<div
title={tooltip}
className="flex flex-col items-center justify-center gap-1 p-3 rounded-md cursor-not-allowed opacity-40"
>
<span className="text-2xl grayscale">{app.icon ?? '📦'}</span>
<span className="text-xs text-[#666] text-center">{app.name}</span>
</div>
);
}
return (
<a
href={app.url}
onClick={onClose}
title={tooltip}
className="flex flex-col items-center justify-center gap-1 p-3 rounded-md hover:bg-[#1a1a1a] transition-colors text-[#ccc] hover:text-white"
>
<span className="text-2xl">{app.icon ?? '📦'}</span>
<span className="text-xs text-center">{app.name}</span>
</a>
);
}
+82
View File
@@ -0,0 +1,82 @@
'use client';
import { useEffect, useState } from 'react';
import Link from 'next/link';
import AppLauncher from './AppLauncher';
const API_BASE = process.env.NEXT_PUBLIC_API_BASE ?? 'https://cypher.arcrun.dev';
type NavUser = {
display_name: string;
email: string;
avatar_url?: string;
};
export default function SiteNav({ currentPath }: { currentPath?: string }) {
const [user, setUser] = useState<NavUser | null | undefined>(undefined);
useEffect(() => {
fetch(`${API_BASE}/me`, { credentials: 'include' })
.then(r => r.ok ? r.json() as Promise<NavUser> : null)
.then(u => setUser(u))
.catch(() => setUser(null));
}, []);
const logout = async () => {
await fetch(`${API_BASE}/auth/logout`, { method: 'POST', credentials: 'include' });
window.location.href = '/';
};
const linkCls = (path: string) =>
`transition-colors text-sm ${currentPath === path ? 'text-white' : 'text-[#666] hover:text-white'}`;
return (
<nav className="flex items-center justify-between px-6 py-4 border-b border-[#1a1a1a]">
<Link href="/" className="text-white font-bold text-lg tracking-tight hover:opacity-80 transition-opacity">
arcrun
</Link>
<div className="flex items-center gap-4 text-sm">
<Link href="/integrations" className={linkCls('/integrations')}>Integrations</Link>
<Link href="/api-docs" className={linkCls('/api-docs')}>API</Link>
<a
href="https://github.com/richblack/arcrun"
target="_blank"
rel="noopener noreferrer"
className="text-[#666] hover:text-white transition-colors"
>
GitHub
</a>
{user === undefined ? (
// Loading — placeholder to prevent layout shift
<div className="w-20 h-7" />
) : user ? (
<>
<AppLauncher userEmail={user.email} />
<Link href="/dashboard" className="flex items-center gap-2 hover:opacity-80 transition-opacity">
{user.avatar_url && (
// eslint-disable-next-line @next/next/no-img-element
<img src={user.avatar_url} alt="" width={26} height={26} className="rounded-full" />
)}
<span className="text-[#aaa]">{user.display_name}</span>
</Link>
<button
onClick={logout}
className="text-[#555] hover:text-[#888] transition-colors cursor-pointer"
>
</button>
</>
) : (
<Link
href="/login"
className="bg-indigo-600 hover:bg-indigo-500 text-white px-4 py-1.5 rounded-md font-medium transition-colors"
>
Get API Key
</Link>
)}
</div>
</nav>
);
}
+54
View File
@@ -0,0 +1,54 @@
// Matrix App Launcher 九宮格清單
// 來源:matrix/identity/.agents/specs/identity/apps.jsonv0 過渡複製,未來 v1 抽進 @matrix/identity-ui
// 規範:matrix/identity/.agents/specs/identity/design.md §2.5
export type AppEntry = {
id: string;
name: string;
url: string;
icon?: string;
description?: string;
access?: 'public' | 'allowlist';
allowlist_emails?: string[];
locked_tooltip?: string;
};
export const MATRIX_APPS: AppEntry[] = [
{
id: 'arcrun',
name: 'Arcrun',
url: 'https://arcrun.dev',
icon: '🔄',
description: '工作流引擎與零件平台',
},
{
id: 'dashboard',
name: 'Dashboard',
url: 'https://arcrun.dev/dashboard',
icon: '🔑',
description: 'API Key 管理',
},
{
id: 'integrations',
name: 'Integrations',
url: 'https://arcrun.dev/integrations',
icon: '🧩',
description: '服務目錄',
},
{
id: 'mira',
name: 'Mira',
url: 'https://arcrun.dev/mira',
icon: '🌊',
description: '個人化 KM 河道',
access: 'allowlist',
allowlist_emails: ['leo21c@gmail.com'],
locked_tooltip: '即將開放',
},
];
export function isAppAccessible(app: AppEntry, userEmail: string | null): boolean {
if (app.access !== 'allowlist') return true;
if (!userEmail) return false;
return (app.allowlist_emails ?? []).includes(userEmail);
}
+2 -21
View File
@@ -2,6 +2,7 @@
import { useEffect, useState, useCallback } from 'react';
import Link from 'next/link';
import SiteNav from '../components/SiteNav';
const API_BASE = process.env.NEXT_PUBLIC_API_BASE ?? 'https://cypher.arcrun.dev';
@@ -89,11 +90,6 @@ export default function DashboardPage() {
}
};
const logout = async () => {
await fetch(`${API_BASE}/auth/logout`, { method: 'POST', credentials: 'include' });
window.location.href = '/';
};
if (loading) {
return (
<div className="min-h-screen bg-[#0a0a0a] flex items-center justify-center">
@@ -115,22 +111,7 @@ export default function DashboardPage() {
return (
<div className="min-h-screen bg-[#0a0a0a] text-[#ededed]">
{/* Nav */}
<nav className="flex items-center justify-between px-6 py-4 border-b border-[#1a1a1a]">
<Link href="/" className="text-white font-bold text-lg tracking-tight hover:opacity-80 transition-opacity">
arcrun
</Link>
<div className="flex items-center gap-4">
{user.avatar_url && (
// eslint-disable-next-line @next/next/no-img-element
<img src={user.avatar_url} alt="" width={28} height={28} className="rounded-full" />
)}
<span className="text-[#666] text-sm">{user.email}</span>
<button onClick={logout} className="text-[#555] hover:text-[#888] text-sm transition-colors cursor-pointer">
</button>
</div>
</nav>
<SiteNav currentPath="/dashboard" />
<main className="max-w-2xl mx-auto px-6 py-12">
<h1 className="text-2xl font-bold text-white mb-1">{user.display_name}</h1>
+2 -13
View File
@@ -1,6 +1,7 @@
export const runtime = 'edge';
import Link from 'next/link';
import SiteNav from '../components/SiteNav';
type Recipe = {
id: string;
@@ -64,19 +65,7 @@ async function IntegrationsContent({
return (
<div className="min-h-screen bg-[#0a0a0a] text-[#ededed]">
{/* Nav */}
<nav className="flex items-center justify-between px-6 py-4 border-b border-[#1a1a1a]">
<Link href="/" className="text-white font-bold text-lg tracking-tight hover:opacity-80 transition-opacity">
arcrun
</Link>
<div className="flex items-center gap-4 text-sm">
<Link href="/api-docs" className="text-[#666] hover:text-white transition-colors">API</Link>
<Link href="/login"
className="bg-indigo-600 hover:bg-indigo-500 text-white px-4 py-1.5 rounded-md text-sm font-medium transition-colors">
Get API Key
</Link>
</div>
</nav>
<SiteNav currentPath="/integrations" />
<div className="max-w-5xl mx-auto px-6 py-12">
{/* Header */}
+63
View File
@@ -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
+87
View File
@@ -0,0 +1,87 @@
'use client';
// Mira 子應用 layout
// SDD: polaris/mira/.agents/specs/mira-app/design.md §5.5
// 規範:白名單 user 進得去;非白名單 user 看到「即將開放」頁
// middleware 已做未登入跳 /loginredirect=/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>
);
}
+757
View File
@@ -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 不顯示 bulletcheckbox 取代)*/
.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-lineFullContent 模式)── */
.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;
}
+122
View File
@@ -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
);
}
+165
View File
@@ -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 + 它的 childrenwiki-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 [];
}
}
+269
View File
@@ -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 一次撈所有相關 blocksKBDB 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="🗂 Index4 個分類)">
{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 ?? '';
}
+14 -19
View File
@@ -1,7 +1,8 @@
'use client';
import { useState } from 'react';
import { useState, useEffect } from 'react';
import Link from 'next/link';
import SiteNav from './components/SiteNav';
const API_BASE = process.env.NEXT_PUBLIC_API_BASE ?? 'https://cypher.arcrun.dev';
@@ -55,23 +56,17 @@ Content-Type: application/json
export default function HomePage() {
const [activeTab, setActiveTab] = useState<'python' | 'javascript' | 'http'>('python');
const [isLoggedIn, setIsLoggedIn] = useState(false);
useEffect(() => {
fetch(`${API_BASE}/me`, { credentials: 'include' })
.then(r => { if (r.ok) setIsLoggedIn(true); })
.catch(() => {});
}, []);
return (
<div className="flex flex-col min-h-screen bg-[#0a0a0a] text-[#ededed]">
{/* Nav */}
<nav className="flex items-center justify-between px-6 py-4 border-b border-[#1a1a1a]">
<span className="text-white font-bold text-lg tracking-tight">arcrun</span>
<div className="flex items-center gap-4 text-sm">
<Link href="/integrations" className="text-[#666] hover:text-white transition-colors">Integrations</Link>
<Link href="/api-docs" className="text-[#666] hover:text-white transition-colors">API</Link>
<a href="https://github.com/richblack/arcrun" target="_blank" rel="noopener noreferrer"
className="text-[#666] hover:text-white transition-colors">GitHub</a>
<Link href="/login"
className="bg-indigo-600 hover:bg-indigo-500 text-white px-4 py-1.5 rounded-md text-sm font-medium transition-colors">
Get API Key
</Link>
</div>
</nav>
<SiteNav currentPath="/" />
{/* Hero */}
<section className="flex flex-col items-center text-center px-6 pt-24 pb-16">
@@ -92,9 +87,9 @@ export default function HomePage() {
</p>
<div className="flex gap-3 flex-wrap justify-center">
<Link href="/login"
<Link href={isLoggedIn ? '/dashboard' : '/login'}
className="bg-indigo-600 hover:bg-indigo-500 text-white px-6 py-3 rounded-lg font-medium transition-colors">
Get API Key Free
{isLoggedIn ? 'Go to Dashboard' : 'Get API Key — Free'}
</Link>
<a href="https://github.com/richblack/arcrun" target="_blank" rel="noopener noreferrer"
className="border border-[#333] hover:border-[#555] text-[#aaa] hover:text-white px-6 py-3 rounded-lg font-medium transition-colors">
@@ -183,9 +178,9 @@ drive = auth.bind(
<section className="border-t border-[#1a1a1a] py-16 text-center px-6">
<h2 className="text-3xl font-bold text-white mb-3"></h2>
<p className="text-[#555] mb-8"> API Key</p>
<Link href="/login"
<Link href={isLoggedIn ? '/dashboard' : '/login'}
className="bg-indigo-600 hover:bg-indigo-500 text-white px-8 py-3 rounded-lg font-medium transition-colors">
API Key
{isLoggedIn ? 'Go to Dashboard' : '免費取得 API Key'}
</Link>
</section>
+3 -3
View File
@@ -4,8 +4,8 @@ import type { NextRequest } from 'next/server';
export function middleware(request: NextRequest) {
const { pathname } = request.nextUrl;
// Only protect /dashboard
if (pathname.startsWith('/dashboard')) {
// Protect /dashboard and /mira (login required; mira 額外白名單檢查在 layout)
if (pathname.startsWith('/dashboard') || pathname.startsWith('/mira')) {
const session = request.cookies.get('arcrun_session');
if (!session?.value) {
const loginUrl = new URL('/login', request.url);
@@ -18,5 +18,5 @@ export function middleware(request: NextRequest) {
}
export const config = {
matcher: ['/dashboard/:path*'],
matcher: ['/dashboard', '/dashboard/:path*', '/mira', '/mira/:path*'],
};
+1498
View File
File diff suppressed because it is too large Load Diff
+2
View File
@@ -14,6 +14,8 @@
"next": "^15.5.15",
"react": "^19.2.5",
"react-dom": "^19.2.5",
"react-markdown": "^10.1.0",
"remark-gfm": "^4.0.1",
"wrangler": "^4.83.0"
},
"devDependencies": {