memory-init
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePurpose
目标
Initialize the Memory Hub for a project: create skeleton, scan the project, and populate initial knowledge files and catalog.
.memory/为项目初始化Memory Hub:创建目录骨架,扫描项目并填充初始知识库文件与目录。
.memory/Input
输入
No arguments required. Run from the project root.
无需传入参数。请在项目根目录执行。
Required Flow
必要流程
Step 1: Create skeleton
步骤1:创建目录骨架
bash
memory-hub initIf error, stop and inform the user.
ALREADY_INITIALIZEDbash
memory-hub init如果出现错误,停止操作并通知用户。
ALREADY_INITIALIZEDStep 2: Scan project and generate tech-stack knowledge
步骤2:扫描项目并生成技术栈知识库
- Read the project root file listing
- Read package manager files (,
package.json,pyproject.toml,Cargo.toml,go.mod, etc.)pom.xml - Read entry files (,
main.*,index.*,app.*, etc.)server.* - Read config files (,
.env.example,tsconfig.json, etc.)webpack.config.*
Generate content and write:
tech-stack.mdbash
memory-hub write architect tech-stack.md \
--topic tech-stack --summary "技术栈、关键依赖、使用方式与限制" --mode overwrite <<'EOF'
<generated markdown>
EOF- 读取项目根目录的文件列表
- 读取包管理文件(、
package.json、pyproject.toml、Cargo.toml、go.mod等)pom.xml - 读取入口文件(、
main.*、index.*、app.*等)server.* - 读取配置文件(、
.env.example、tsconfig.json等)webpack.config.*
生成内容并写入:
tech-stack.mdbash
memory-hub write architect tech-stack.md \
--topic tech-stack --summary "技术栈、关键依赖、使用方式与限制" --mode overwrite <<'EOF'
<generated markdown>
EOFStep 3: Generate code conventions knowledge
步骤3:生成代码约定知识库
Based on project structure from Step 2, generate :
conventions.mdbash
memory-hub write dev conventions.md \
--topic conventions --summary "目录命名规则、模块组织方式、代码约定" --mode overwrite <<'EOF'
<generated markdown>
EOF基于步骤2得到的项目结构,生成:
conventions.mdbash
memory-hub write dev conventions.md \
--topic conventions --summary "目录命名规则、模块组织方式、代码约定" --mode overwrite <<'EOF'
<generated markdown>
EOFStep 4: Scan project modules and generate Catalog
步骤4:扫描项目模块并生成目录
Analyze directory structure, identify functional domains and key files, construct JSON:
bash
memory-hub catalog-update <<'EOF'
{"modules": [{"name": "...", "summary": "...", "files": [{"path": "...", "description": "..."}]}]}
EOF分析目录结构,识别功能领域与关键文件,构建JSON:
bash
memory-hub catalog-update <<'EOF'
{"modules": [{"name": "...", "summary": "...", "files": [{"path": "...", "description": "..."}]}]}
EOFStep 5: Quality gate
步骤5:质量校验
- List — files/directories that don't clearly belong to any functional domain
unknowns - Check output (auto-triggered by catalog-update):
catalog.repair- non-empty → execute self-healing, then run
ai_actionsagain to confirm clearedmemory-hub catalog-repair - non-empty → report to user
manual_actions
- 列出— 无法明确归属到任何功能领域的文件/目录
unknowns - 检查的输出(由catalog-update自动触发):
catalog.repair- 非空 → 执行自我修复,然后再次运行
ai_actions确认已清理memory-hub catalog-repair - 非空 → 向用户报告
manual_actions
Step 6: Output summary
步骤6:输出摘要
Report: files created, modules identified, unknowns requiring user confirmation.
报告内容:已创建的文件、已识别的模块、需要用户确认的未知项。
Output
输出
JSON envelope from each command. Final summary to user.
每个命令返回JSON格式结果。最终向用户展示摘要信息。
Error Handling
错误处理
- → inform user, do not proceed
ALREADY_INITIALIZED - Any command failure → stop and report the error
- → 通知用户,不再继续执行
ALREADY_INITIALIZED - 任何命令执行失败 → 停止操作并报告错误