mb-map-codebase
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
Chinesemb-map-codebase — Brownfield: Repo → Memory Bank
mb-map-codebase — Brownfield: Repo → Memory Bank
- What it does: scans an existing repository, merges evidence from scoped workers, and writes as-is Memory Bank docs.
- Use it when: code already exists and you need a reliable baseline before planning changes.
- Input: repository root plus an initialized .
.memory-bank/ - Output: product, architecture, testing, runbook, and contract docs that describe the current system without speculative backlog generation.
- 功能说明: 扫描现有代码仓库,合并来自指定范围工作器的佐证信息,写入现状Memory Bank文档。
- 适用场景: 已有代码存在,你需要在规划变更前获得可靠的基线信息时使用。
- 输入: 代码仓库根目录以及已初始化的目录。
.memory-bank/ - 输出: 描述当前系统的产品、架构、测试、运行手册、合约文档,不会生成推测性的待办事项。
Preconditions
前置条件
- You are in the repo root.
- skeleton exists (if not, run
.memory-bank/).mb-init
- 你当前处于代码仓库根目录。
- 已存在框架结构(如果没有,运行
.memory-bank/)。mb-init
Process
流程
1) Start a protocol + task folder
1) 新建协议与任务文件夹
Create:
.protocols/MAP-CODEBASE/plan.md.protocols/MAP-CODEBASE/progress.md- (mapping completeness + evidence)
.protocols/MAP-CODEBASE/verification.md .protocols/MAP-CODEBASE/handoff.md- (optional)
.protocols/MAP-CODEBASE/decision-log.md
Create:
.tasks/TASK-MB-MAP/
Plan MUST include MB-SYNC (link ).
.memory-bank/workflows/mb-sync.md创建以下文件:
.protocols/MAP-CODEBASE/plan.md.protocols/MAP-CODEBASE/progress.md- (映射完整度+佐证信息)
.protocols/MAP-CODEBASE/verification.md .protocols/MAP-CODEBASE/handoff.md- (可选)
.protocols/MAP-CODEBASE/decision-log.md
创建以下文件夹:
.tasks/TASK-MB-MAP/
方案必须包含MB-SYNC(链接)。
.memory-bank/workflows/mb-sync.md2) Spawn scanning subagents (parallel)
2) 生成扫描子Agent(并行执行)
Use as the base worker prompt.
./agents/shared-repo-scanner.mdRules:
- Max 5–7 parallel subagents.
- Non-overlapping scopes (to avoid conflicts).
- Smart calling: each worker validates that its globs match real files.
Suggested scopes:
- S-01 tooling/CI
- S-02 backend/services
- S-03 frontend/UI
- S-04 data layer
- S-05 tests/quality
Each subagent writes:
.tasks/TASK-MB-MAP/TASK-MB-MAP-S-0X-final-report-<code|docs>-01.md
使用作为基础工作器提示词。
./agents/shared-repo-scanner.md规则:
- 最多同时运行5–7个并行子Agent。
- 扫描范围不重叠(避免冲突)。
- 智能调用:每个工作器需验证其匹配的glob规则对应真实存在的文件。
建议扫描范围:
- S-01 工具链/CI
- S-02 后端/服务
- S-03 前端/UI
- S-04 数据层
- S-05 测试/质量
每个子Agent输出:
.tasks/TASK-MB-MAP/TASK-MB-MAP-S-0X-final-report-<code|docs>-01.md
3) Fan-in (mandatory)
3) 结果聚合(强制要求)
Before writing final docs:
- read all worker reports
- merge into a single outline
- resolve contradictions (or record them as “needs verification”)
- write a short fan-in note into with:
.protocols/MAP-CODEBASE/progress.md- which reports were used
- what conflicted and how resolved
- open questions
在写入最终文档前:
- 读取所有工作器的报告
- 合并为单个大纲
- 解决矛盾内容(或者将其标记为“待验证”)
- 在中写入简短的聚合说明,包含:
.protocols/MAP-CODEBASE/progress.md- 使用了哪些报告
- 存在哪些冲突以及解决方式
- 未解决的问题
4) Synthesize Memory Bank (as-is)
4) 合成现状Memory Bank
Using the fan-in view, create/update:
- product brief ()
.memory-bank/product.md - architecture overview ()
.memory-bank/architecture/ - runbooks ()
.memory-bank/runbooks/ - contracts ()
.memory-bank/contracts/ - testing strategy ()
.memory-bank/testing/index.md - index ()
.memory-bank/index.md
Use .
references/synthesis-checklist.mdPRD-less rule (non-negotiable): if there is no, you MUST NOT create or populate:prd.md
.memory-bank/epics/*.memory-bank/features/* with waves/tasks.memory-bank/tasks/backlog.mdEmpty skeleton files/folders are OK if they were created by bootstrap.Mapping is documentation of the current system, not planning.
In overview docs, explicitly separate:
- Facts (evidence: paths/commands/logs/tests)
- Inferences (hypotheses, explicitly marked)
基于聚合后的视图,创建/更新以下内容:
- 产品概要()
.memory-bank/product.md - 架构概览()
.memory-bank/architecture/ - 运行手册()
.memory-bank/runbooks/ - 接口合约()
.memory-bank/contracts/ - 测试策略()
.memory-bank/testing/index.md - 索引页()
.memory-bank/index.md
参考。
references/synthesis-checklist.md无PRD规则(不可协商):如果不存在****,你绝对不能创建或填充以下内容:prd.md
.memory-bank/epics/*.memory-bank/features/*- 包含迭代/任务的
.memory-bank/tasks/backlog.md如果是初始化脚本创建的空框架文件/文件夹是允许的。映射是对当前系统的文档记录,而非规划。
在概览文档中,明确区分:
- 事实(佐证:路径/命令/日志/测试)
- 推论(假设,明确标记)
5) Ask for PRD delta
5) 申请PRD增量信息
Once baseline MB exists:
- ask the user for a describing what to change/add.
prd.md - then run to plan the delta on top of baseline.
mb-from-prd
当基线Memory Bank创建完成后:
- 要求用户提供说明需要变更/新增的内容。
prd.md - 之后运行在基线之上规划增量变更。
mb-from-prd
6) Review gate
6) 评审关口
Run in fresh context.
mb-review在全新上下文环境中运行。
mb-review7) MB-SYNC
7) MB-SYNC
Follow and append a changelog entry.
.memory-bank/workflows/mb-sync.md遵循的要求,追加变更日志条目。
.memory-bank/workflows/mb-sync.mdDefinition of done
完成标准
- contains scoped reports.
.tasks/TASK-MB-MAP/ - describes the system “as-is” with evidence.
.memory-bank/ - Contradictions and open questions are recorded.
- User has been asked for PRD delta.
- 包含各范围的扫描报告。
.tasks/TASK-MB-MAP/ - 带佐证信息描述系统“现状”。
.memory-bank/ - 矛盾内容与未解决问题已记录。
- 已向用户申请PRD增量信息。