memforge-topology-trigger

A set of rules for creating and querying a visual map of how services and repositories in a product relate to one another. The map is shown in Memforge WebUI, a browser interface for viewing this information.

In plain words
What is it for?
Use it to initialize or refresh a product architecture map, view upstream and downstream service calls, inspect a complete system overview, and assess the impact of changing an interface.
Why use it?
It gives teams a consistent way to inspect service connections, call paths, and the possible effects of a change across repositories. It also tells the assistant when to scan or refresh the map.

Cursor rule

Install

Getting it into your agent

One page per mod, every tool's command on it. A separate URL per tool would split the same page into five that compete with each other.

agentmods
npx agentmods add rules/zql0805/memforge/memforge-topology-trigger
Clone the repo
git clone --depth 1 https://github.com/zql0805/memforge
Per session 870 This file is loaded in full into every session.
When invoked 870 The same file — it is already loaded in full.
Security scan A 0 findings. Scan, not verified.
Origin original No closer match found in the catalogue.
Token cost

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.

ModelPer sessionOnce invoked
Fable 5 $0.00870 $0.00870
Opus 5 $0.00435 $0.00435
Sonnet 5 $0.00174 $0.00174
Haiku 4.5 $0.00087 $0.00087

Measured 2d ago against content hash fcd92357a487, method: parsed. Prices are Anthropic first-party input rates as of 2026-08-30, from the pricing page.

Security

Grade A, and why

memforge-topology-trigger 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 2d ago.

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.

packages/memory-service/src/rules-templates/memforge-topology-trigger.mdc · 80 lines

What it actually says

产品线拓扑图 — 全局触发与自动检测

触发词识别

当用户消息包含以下关键词时,执行对应的内置拓扑操作:

分类 触发词
打开/显示 打开拓扑图、显示拓扑、拓扑图、看看拓扑、show topology、open topology
初始化 初始化拓扑、初始化拓扑图、帮我初始化产品线、初始化跨仓库分析
生成/刷新 生成拓扑图、刷新拓扑、更新拓扑、重新扫描、rescan
架构相关 架构图、服务关系图、调用链路图、全链路分析、产品线可视化、产品线拓扑、topology
跨仓库 跨仓库分析、关联代码库、仓库扫描
快速打开 topo、拓扑

快速打开拓扑图

当用户说「打开拓扑图」「看看拓扑」时,告知用户通过 Memforge WebUI 查看:

请在 Memforge WebUI 中打开「产品线拓扑」页面查看可视化拓扑图。 如果拓扑数据尚未生成,可以点击页面上的「一键扫描」按钮,或我帮你调用 scan_topology 扫描。

扫描/刷新拓扑

当用户说「刷新拓扑」「重新扫描」「生成拓扑图」时:

  1. 识别产品线:从工作区路径或用户输入推断
  2. 展示扫描配置并等待确认(强制):列出将扫描的目录、Git 过滤模式
  3. 用户确认后调用
    scan_topology({
      product_line: "<产品线>",
      force: true,
      scan_roots: ["用户确认的目录列表"],
      git_patterns: ["用户确认的过滤模式"]
    })
    
  4. 告知用户:汇报扫描结果(仓库数、调用链数),建议去 WebUI 查看

首次初始化

当 AI 检测到当前产品线从未扫描过拓扑数据时:

  1. 从工作区路径或 MCP product_line 参数自动识别
  2. 调用 scan_topology({ product_line: "<产品线>" }) 零配置扫描
  3. 未知产品线时询问用户提供扫描根目录和名称

新仓库自动检测

当前工作区是 git 仓库且该产品线已有拓扑数据时,首次提问自动检查该仓库是否已收录。 未收录时提示用户是否刷新拓扑。

拓扑查询工具(优先于 recall_memory)

查询服务间关系、发布顺序、变更影响时,优先使用结构化查询工具

场景 工具
查看上下游调用链 query_topology
全量架构概览 query_topology (include: ["all"])
修改接口后影响范围 get_topology_change_impact
确定发布顺序 get_topology_release_order
定位模糊服务名 resolve_service_path

重要约束

  1. 所有拓扑操作仅使用 Memforge 内置 MCP 工具,不使用外部脚本
  2. 拓扑可视化通过 Memforge WebUI「产品线拓扑」页面呈现
  3. 扫描前必须展示配置并等待用户确认
  4. 不将拓扑数据提交到 git
Changes

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.

  1. 2d ago First seen · 80 lines · 870 tokens per session scan A fcd92357a487

Subscribe to this mod's changes

memforge-topology-trigger is a cursor rule published in the GitHub repository zql0805/memforge (2 stars, last pushed 2mo ago), licensed MIT. It adds 870 tokens to every session, about $0.0043 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-08-31.