Based on the existing code repository, recursively analyze,as meticulously as possible,understand its project structure, code structure, and code content, and help users generate complete DeepWiki-style project documentation.
Detection Logic
Automatically detect the run mode, determining in the following order:
-
Check Git Submodules
- Check whether the
.gitmodulesfile exists - If so, execute
git submodule update --init --recursive --depth 1
- Check whether the
-
New Project Planning Mode
- Trigger condition: the project is empty (no source code files)
- Trigger keywords: "new project", "start from scratch", "plan project"
- See new-project-plan.md
-
Sync/Refresh Mode
- Trigger condition:
{{workspace}}/.monkeycode/docs/ARCHITECTURE.md - Trigger keywords: "sync documentation", "update documentation", "refresh wiki"
- See sync-code-docs.md
- Trigger condition:
-
Full Generation Mode(default)
- Trigger condition: code already exists but no documentation structure exists
- Trigger keywords: "generate documentation", "create documentation", "build wiki"
- See existing-code-docs.md
Workflow
1. 检测运行模式
├── 检查 .gitmodules → 拉取 submodules
├── 项目为空? → 新项目规划模式
├── 存在 ARCHITECTURE.md? → 同步模式
└── 否则 → 完整生成模式
2. 执行对应工作流
├── 新项目规划:交互式问答收集需求 → 生成文档
├── 完整生成:分析仓库 → 创建文档结构 → 填充内容
└── 同步/刷新:检测变更 → 增量更新
3. 提交文档
├── git commit
├── git push
└── 向用户确认并收集反馈
Output Structure
Generated documentation structure:
{{workspace}}/.monkeycode/docs/
├── INDEX.md # 文档索引
├── ARCHITECTURE.md # 系统架构文档
├── INTERFACES.md # 接口文档
├── DEVELOPER_GUIDE.md # 开发者指南
├── 专有概念/ # 核心概念页面
│ ├── [Concept1].md
│ └── [Concept2].md
└── 模块/ # 模块 README
├── [Module1].md
└── [Module2].md
Constraints
Source code is read-only:
- Any file in the repository can be analyzed
- Nevermodify source code files
- Onlycreate/update documentation files (Markdown)
- Default documentation location:
{{workspace}}/.monkeycode/docs/(follow existing conventions if any)
No fabrication:
- Documentation must be strictly based on actual code, configuration, and tests
- Never fabricate features, APIs, or behaviors that do not exist in the code
- When uncertain, say "unable to determine" instead of guessing
No leaking secrets:
- Never include API keys, passwords, tokens, or credentials in documentation
- Use placeholders such as
<API_KEY>
Templates
Documentation template reference templates.md
Notes
- Unless executing the "New Project Planning" workflow, complete the task without interacting with the user
- If there are multiple subprojects under the workspace directory (similar to submodules), output all documentation to
{{workspace}}/.monkeycode/docs/instead of the subproject directories - After completion, confirm with the user whether they are satisfied, and iterate and improve based on feedback