Files
market/skills/tech-diagram/references/templates.md
Yige f4dfe8e32f feat: add tech-diagram skill (Mermaid 技术图生成) (#18)
## 概述 / Summary

新增市场技能 **tech-diagram**:把自然语言描述转成品牌一致的技术图(架构图/流程图/时序图/状态机/ER/类图/思维导图),在
DesireCore 对话内复用现有 Mermaid 渲染管线即时渲染为 SVG。

Adds a market skill **tech-diagram** that turns natural-language
descriptions into brand-consistent technical diagrams, rendered inline
as SVG by the existing Mermaid pipeline in the DesireCore chat.

灵感来源 / Inspired by
[fireworks-tech-graph](https://github.com/yizhiyanhua-ai/fireworks-tech-graph)
的三个设计思路:语义词汇表即数据、风格系统化、领域 Pattern 内置——并落到 DesireCore 自己的 3+2 设计令牌与领域模型上。

## 改动 / Changes

- `skills/tech-diagram/SKILL.md` + `SKILL.zh-CN.md`:双语技能正文(强制风格规则 +
语义词汇表 + 输出约定)
- `skills/tech-diagram/references/semantic-vocabulary.md`:概念→Mermaid
形状→3+2 classDef 完整映射
- `skills/tech-diagram/references/templates.md`:4 个 DesireCore
领域模板(Agent 架构 / Delegate 6 模式 / 三层记忆 / 关系图谱)+ 时序图示例
- `builtin-skills.json`:加入 `tech-diagram`
- `manifest.json`:`version` 1.2.1→1.2.2,`stats.totalSkills`
21→22,`lastUpdated`

## 设计要点 / Design

- **风格一致性**:每张图以 `%%{init}%%` 注入品牌主题(覆盖对话全局暗色),用 5 个 `classDef` 绑定
DesireCore 3+2 配色(green/blue/purple + warning orange / error red)。
- **语义优于视觉**:Agent→六边形、系统/记忆→圆角/圆柱、决策→菱形;箭头编码主数据流/记忆写入/异步/层级/上报。
- **领域内置**:直接对照 `delegate.ts` / `conversation-memory.ts` /
`relations/projector.ts` 给出可套用模板。

## 验证 / Verification

-  `scripts/i18n/validate-i18n.py`:无 i18n 问题
-  用 app 同版本 **mermaid 11.15.0**(securityLevel: loose)解析 `templates.md`
全部 5 个图块,全部通过
2026-05-30 23:56:27 +08:00

4.3 KiB
Raw Blame History

Built-in Templates (内置模板)

Ready-to-use, brand-styled Mermaid for DesireCore's own architecture patterns. Adapt the labels to the user's subject; keep the header and classDefs intact. All four are verified to render.

Note: file paths like lib/... and app/... cited below refer to the DesireCore application codebase where this skill runs at runtime — they do not exist in this market repository.

1. Agent architecture (Agent 架构图)

Mirrors the delegate / skills / memory layout (lib/agent-service/builtin-tools/delegate.ts).

%%{init: {'theme':'base','themeVariables':{'primaryColor':'#F0F5FF','primaryBorderColor':'#007AFF','primaryTextColor':'#1d1d1f','lineColor':'#6e6e73','fontFamily':'-apple-system,SF Pro Text,Noto Sans SC,sans-serif'}}}%%
flowchart TD
    classDef agent  fill:#F6F3FF,stroke:#AF52DE,color:#1d1d1f
    classDef system fill:#F0F5FF,stroke:#007AFF,color:#1d1d1f
    classDef biz    fill:#F0FDF4,stroke:#34C759,color:#1d1d1f

    U(["User"]):::biz
    Core("DesireCore Core"):::system
    A1{{"Legal Agent"}}:::agent
    A2{{"Data Agent"}}:::agent
    Skills["Skills / MCP Tools"]:::biz
    Mem[("Conversation Memory")]:::system

    U --> Core
    Core --> A1
    Core --> A2
    A1 --> Skills
    A2 --> Skills
    A1 -.-> Mem
    A2 -.-> Mem

2. Delegate 6 modes (Delegate 六种模式)

The unified delegate tool and its six execution modes.

%%{init: {'theme':'base','themeVariables':{'primaryColor':'#F0F5FF','primaryBorderColor':'#007AFF','primaryTextColor':'#1d1d1f','lineColor':'#6e6e73','fontFamily':'-apple-system,SF Pro Text,Noto Sans SC,sans-serif'}}}%%
flowchart LR
    classDef system fill:#F0F5FF,stroke:#007AFF,color:#1d1d1f
    classDef biz    fill:#F0FDF4,stroke:#34C759,color:#1d1d1f

    D("Delegate Tool"):::system
    D --> S["sync: block & await"]:::biz
    D --> AS["async: fire & report back"]:::biz
    D --> W["worker: ephemeral SubAgent"]:::biz
    D --> F["fan-out: parallel / sequential"]:::biz
    D --> H["handoff: hand session to user"]:::biz
    D --> V["via-messaging: fallback wait"]:::biz

3. Three-tier conversation memory (三层对话记忆)

active → recent (L0/L1) → archive (L2); writes are dotted (lib/schemas/agent-service/conversation-memory.ts).

%%{init: {'theme':'base','themeVariables':{'primaryColor':'#F0F5FF','primaryBorderColor':'#007AFF','primaryTextColor':'#1d1d1f','lineColor':'#6e6e73','fontFamily':'-apple-system,SF Pro Text,Noto Sans SC,sans-serif'}}}%%
flowchart LR
    classDef system fill:#F0F5FF,stroke:#007AFF,color:#1d1d1f
    classDef warn   fill:#FFFBF0,stroke:#FF9500,color:#1d1d1f

    New(["New Message"]):::warn
    Active[("active: ongoing matters")]:::system
    Recent[("recent: L0 / L1 summaries")]:::system
    Archive[("archive: L2 full log")]:::system

    New --> Active
    Active -.->|compact| Recent
    Recent -.->|archive after 180d| Archive

4. Relation graph (关系图谱6 种边)

The six edge types projected by lib/agent-service/relations/projector.ts, each drawn with a distinct edge style. Edge weight decays over time (30-day half-life).

%%{init: {'theme':'base','themeVariables':{'primaryColor':'#F0F5FF','primaryBorderColor':'#007AFF','primaryTextColor':'#1d1d1f','lineColor':'#6e6e73','fontFamily':'-apple-system,SF Pro Text,Noto Sans SC,sans-serif'}}}%%
flowchart TD
    classDef agent fill:#F6F3FF,stroke:#AF52DE,color:#1d1d1f
    classDef biz   fill:#F0FDF4,stroke:#34C759,color:#1d1d1f

    A1{{"Agent A"}}:::agent
    A2{{"Agent B"}}:::agent
    A3{{"Agent C"}}:::agent
    U(["User"]):::biz

    A1 -->|delegate| A2
    A1 -.->|mention| A3
    A2 ===|co_task| A3
    A2 --o|hierarchy| A1
    A3 -->|seek_help| A1
    A1 --x|escalation| U

Other diagram types

For sequence / state / ER / class diagrams, keep the same %%{init}%% header for a consistent light theme. Example sequence diagram:

%%{init: {'theme':'base','themeVariables':{'primaryColor':'#F0F5FF','primaryBorderColor':'#007AFF','primaryTextColor':'#1d1d1f','lineColor':'#6e6e73','fontFamily':'-apple-system,SF Pro Text,Noto Sans SC,sans-serif'}}}%%
sequenceDiagram
    actor U as User
    participant C as DesireCore Core
    participant A as Sub-Agent
    participant M as Memory
    U->>C: request
    C->>A: delegate (sync)
    A->>M: write fact
    A-->>C: result
    C-->>U: reply