arcrun — AI workflow execution engine (clean history)
Self-hosted 開源:WASM 零件 + recipe + cypher-executor,跑在你自己的 Cloudflare。 此為重建的乾淨歷史起點(移除曾誤 commit 的 GCP SA 金鑰,舊歷史保留在 richblack/arcrun 與本地 backup 分支)。含: - acr init --self-hosted installer(建 KV/R2 + codeload 拉預編譯 wasm + wrangler deploy + seed recipe) - recipe push 把關(資料外流提醒 + 打通檢查) - 19 個正當零件預編譯 wasm(claude_api/km_writer/kbdb_upsert_block 排除:違反 DECISIONS §1) - CLI / cypher-executor / registry / 完整 SDD Co-Authored-By: Claude Opus 4.8 <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,77 @@
|
||||
'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 }) {
|
||||
// 兩階段預處理:1. strip Logseq metadata;2. [[entity]] 轉成 markdown link
|
||||
const cleaned = useMemo(() => expandWikilinks(stripLogseqMeta(text)), [text]);
|
||||
return (
|
||||
<div className="mira-md">
|
||||
<ReactMarkdown
|
||||
remarkPlugins={[remarkGfm]}
|
||||
components={{
|
||||
a: ({ href, children, ...rest }) => {
|
||||
const isWikiLink = typeof href === 'string' && href.startsWith('/mira/wiki/');
|
||||
return (
|
||||
<a
|
||||
href={href}
|
||||
{...(isWikiLink ? {} : { 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');
|
||||
}
|
||||
|
||||
// 把 [[entity]] 轉成 markdown link 指向 /mira/wiki/wiki-{entity}
|
||||
// 對應 mira-app design.md §3.6.2 + tasks.md backlog #12
|
||||
export function expandWikilinks(text: string): string {
|
||||
return text.replace(/\[\[([^\[\]\n]+?)\]\]/g, (_, entity: string) => {
|
||||
const e = entity.trim();
|
||||
if (!e) return '[[]]';
|
||||
const url = `/mira/wiki/${encodeURIComponent('wiki-' + e)}`;
|
||||
return `[${e}](${url})`;
|
||||
});
|
||||
}
|
||||
Reference in New Issue
Block a user