Borrowing it
Nothing to install: this file belongs to fuzhengwei/WaLiAPI. Take a copy, put it at the same path in your own repository, and replace the rules that are about this project with yours.
curl -O https://raw.githubusercontent.com/fuzhengwei/WaLiAPI/main/AGENTS.mdgit clone --depth 1 https://github.com/fuzhengwei/WaLiAPIWrote this? Show the measurements
A badge with what this costs and how it scanned, read live from this page, so it follows the numbers instead of freezing them. Markdown for a README, HTML for a documentation site or a project page.
[](https://agentmods.dev/instructions/fuzhengwei/waliapi/agents-md)<a href="https://agentmods.dev/instructions/fuzhengwei/waliapi/agents-md"><img src="https://agentmods.dev/badge/instructions/fuzhengwei/waliapi/agents-md/github.svg" alt="Measured on agentmods" height="20"></a>Or the 80×15 button, for a site that already has a row of RSS and ATOM ones. Only the verdict fits; the numbers stay here.
<a href="https://agentmods.dev/instructions/fuzhengwei/waliapi/agents-md"><img src="https://agentmods.dev/badge/instructions/fuzhengwei/waliapi/agents-md.svg" alt="Reviewed on agentmods" width="80" height="20"></a>What it costs to keep this loaded
Counted locally with the o200k_base tokenizer, which is exact for GPT models; Claude uses its own tokenizer and its counts differ. Treat this as one consistent yardstick across the catalogue rather than a bill. Prices are per million input tokens.
| Model | Per session | Once invoked |
|---|---|---|
| Fable 5.1 | $0.03665 | $0.03665 |
| Opus 5 | $0.01833 | $0.01833 |
| Sonnet 5 | $0.00733 | $0.00733 |
| Haiku 4.5 | $0.00366 | $0.00366 |
Grade A, and why
WaLiAPI AGENTS.md scanned grade A with 0 findings against 26 rules in 11 categories — prompt injection, anti-refusal, data exfiltration, privilege escalation, supply chain, agent snooping, system-prompt leakage, SSRF and excessive agency — measured today.
A static scan of the body, not an audit. Every finding is printed with the line that produced it so you can judge whether it matters here. A mod is markdown that instructs an agent; that is exactly why what it instructs is worth reading.
Nothing flagged
None of the 26 patterns this scan looks for appear in this file: no shell pipes, no recursive deletes, no credential paths, no hidden text, no instruction-override or anti-refusal phrasing, no agent-config snooping. That is not a guarantee, it is the absence of the things that are checkable.
How it starts
The opening of the file, as written. The whole thing — 174 lines — stays where its author put it; the contents beside it link to each section on GitHub.
AGENTS.md
本文件面向 AI 编码代理,介绍 WaLiAPI 项目的架构、构建方式与开发约定。阅读本文件即可上手开发,无需先读其他文档。
项目概览
WaLiAPI 是一款本地运行的 LLM API 网关(当前版本 0.2.9,MIT 协议)。核心能力:
- 多协议网关:下游可用 OpenAI Chat Completions、OpenAI Responses、Anthropic Messages 三种协议接入,出口统一转换后转发到上游供应商(OpenAI / Claude / DeepSeek / Gemini / 智谱 / 通义 / Moonshot / 豆包 / Ollama / 自定义)。
- 渠道调度:优先级 + 权重负载均衡、多 API Key 负载、模型映射、自动故障切换。
- 安全审计:风险扫描引擎(敏感信息、路径、Unicode 隐写等 25+ 内置规则),策略支持只审计 / 警告 / 脱敏 / 阻断。
- 知识库 RAG:文档解析(tree-sitter 代码符号感知)→ 智能分块 → 向量化(复用渠道 Embedding)→ HNSW 向量索引 + SQLite FTS5 混合检索 → RAG 问答。
- Wiki 知识引擎:Markdown + frontmatter 页面管理、
[[wikilinks]]知识图谱、摄入管道。 - MCP Server:
/mcp端点(Streamable HTTP + SSE),对外暴露 29 个工具(知识库 13 + Wiki 16)。
同一套 Rust 代码库编译出两种产物:
- 桌面端(默认 feature
desktop-ui):Tauri 2 窗口应用,macOS / Windows / Linux。 - Headless 服务端(
waliapi-web二进制,--no-default-features --features embed-web):无窗口纯 HTTP 服务,用于 Docker / systemd 部署,内嵌 Web 管理面板。
技术栈
| 层 | 技术 |
|---|---|
| 前端 | React 19 + TypeScript ~5.8 + Vite 7 + Tailwind CSS 4 + React Router 7(无独立状态/服务端数据库,组件内 useState/useEffect + 自封装 runtime 层) |
| 后端 | Rust (edition 2021) + Tauri 2 + Axum 0.8 + sqlx 0.8 (SQLite) + reqwest 0.12 + tokio |
| 知识库 | tree-sitter(7 种语言)+ HNSW + FTS5 + bincode + pdf-extract |
| 包管理 | pnpm(workspace,含 web/ 子包)+ cargo |
| 打包 | Tauri bundler(.dmg / .msi / .deb / .AppImage)、Docker 多阶段构建 |
仓库结构(实际目录)
├── src/ # 前端主源码(桌面端直接用,Web 面板复用)
│ ├── pages/ # 9 个页面:Dashboard / Channels / AuthChannels / ApiKeys / Logs
│ │ # / KnowledgeBase / Usage / Settings / AppConfig
│ ├── components/ # ChannelForm、MappingSection、auth/、channel-form/、layout/ 等
│ ├── hooks/ # useModelMappings 等
│ ├── lib/ # api.ts、runtime.ts(统一命令传输层,见下)、constants.ts
│ └── types/ # TypeScript 类型定义
├── web/ # Web 管理面板构建(pnpm 子包 waliapi-web)
│ └── src/lib/ # tauri-shim.ts 等:把 @tauri-apps/* API 替换为 HTTP 实现
│ # web/vite.config.ts 用 @app alias 复用 ../src 全部页面组件
├── src-tauri/ # Rust 后端
│ ├── src/
│ │ ├── main.rs # 桌面端入口(default-run = "waliapi")
│ │ ├── bin/waliapi-web.rs # headless 服务端入口
│ │ ├── lib.rs # 库入口:AppState、系统托盘、服务启动
│ │ ├── web_server.rs # headless 启动逻辑(数据目录解析、host/port)
│ │ ├── server/ # Axum HTTP 服务:router.rs、handlers.rs、admin*.rs(管理面)、
│ │ │ # event_bridge.rs(桌面 Webview / Web SSE 统一事件出口)
│ │ ├── core/ # 核心调度:proxy.rs、dispatcher.rs、route_plan.rs、
│ │ │ # plan_executor.rs、attempt.rs、stream_supervisor.rs、
│ │ │ # channel_identity.rs、feature_flags.rs、protocol_boundary.rs
│ │ ├── endpoint_executor/ # 端点执行器(请求驱动、SSE 处理、Token 用量估算)
│ │ ├── auth_provider/ # Auth 账号(Codex / Kimi OAuth 登录、Token 刷新、模型发现)
│ │ ├── protocol/ # 协议转换层:codec/(chat / messages / responses_codec /
│ │ │ # directions 双向转换)、sse_bridge.rs(字节级 SSE 重组,CJK 安全)
│ │ ├── adaptor/ # 上游渠道适配器:openai / claude / deepseek / gemini / custom
│ │ ├── security/ # 安全审计:scanner.rs、rules.rs、redact.rs
│ │ ├── services/ # 服务层:mod.rs 定义 Service trait + ServiceRegistry,
│ │ │ # knowledge/(RAG 全链路,含 ocr/ 扫描版 PDF VLM 识别)、wiki/、mcp/、channel_test.rs
│ │ ├── commands/ # Tauri Commands(channel / api_key / auth / log / settings / ...)
│ │ ├── db/ # Database 初始化、models.rs、repository.rs
│ │ ├── channel_presets.rs # 渠道预设注册表
│ │ └── settings_store.rs # 设置存储抽象(桌面 tauri-plugin-store / headless JSON 文件)
│ ├── migrations/ # SQL 迁移 001–027,启动时经 sqlx::migrate! 自动执行,迁移前自动备份 DB
│ ├── resources/pdfium/ # pdfium 动态库打包目录(VLM OCR 用,库文件不入库,见该目录 README)
│ └── tests/ # 集成测试(见「测试」一节)
├── deploy/ # caddy/Caddyfile.example、systemd/(unit + env 示例)
├── scripts/ # fetch-pdfium.sh(打包前下载 OCR 渲染依赖 pdfium 动态库)、Gitcode release 同步脚本
├── docs/ # 设计文档(渠道协议重构、KB 升级、Wiki 架构等)
└── .github/workflows/ # 6 个发布 workflow(见「发布与部署」)
What this file has done since we first saw it
Hashed on every crawl. A supply-chain change to an agent config is a question of when, not whether, so the history is kept rather than the latest state alone.
- today Changed · +33 tokens per session 1ec2034ffd05
- 5d ago First seen · 174 lines · 3,632 tokens per session scan A 8570457b88fb
WaLiAPI AGENTS.md is an instructions file published in the GitHub repository fuzhengwei/WaLiAPI (122 stars, last pushed yesterday), licensed MIT. It adds 3,665 tokens to every session, about $0.0183 per session on Opus 5. A static security scan graded it A with 0 findings. No closer match exists in the catalogue, so it is treated as the original; first seen 2026-09-03.
Other instructions, from other repositories
vibe-coding-prompt-template backend.instructions.md
Instructions for KhazP/vibe-coding-prompt-template: Read AGENTS.md, agentdocs/techstack.md, and agentdocs/codepatterns.md.
next.js AGENTS.md
AGENTS.md instructions for vercel/next.js, covering next.js development guide, codebase structure, monorepo overview, core package: packages/next and other important packages.
codex AGENTS.md
AGENTS.md instructions for openai/codex, covering rust/codex-rs, the codex-core crate, code review rules, crate api surface and model visible context.
vscode buildNext.instructions.md
Working notes and architecture documentation for the new esbuild-based build system in build/next. Use when making changes to the new build pipeline (transpile/bundle commands, NLS plugin, source-map handling, resource copying, or self-hosting watch tasks).
vscode oss-third-party-notices.instructions.md
Instructions for microsoft/vscode, covering vs code oss third-party-notices pipeline, architecture, pipeline flow in ci, applying the notice (cutover) and fallback chain (never fail the build).
langchain AGENTS.md
AGENTS.md instructions for langchain-ai/langchain, covering global development guidelines for the langchain monorepo, corridor security analysis, project architecture and context, monorepo structure and development tools & commands.