MetaCraft/docs/GETTING_STARTED.md

118 lines
3.2 KiB
Markdown
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

# 快速开始
本指南将帮助你快速上手 MetaCraft包括安装、运行第一个 prompt以及参与自举开发。
## 安装
### 1. 克隆仓库
```bash
git clone https://github.com/your-username/metacraft.git
cd metacraft
```
### 2. 安装依赖
```bash
npm install
```
### 3. 安装 Claude Code CLI
确保已安装 Claude Code CLI 并配置好 API 密钥。请参考 [Claude Code 官方文档](https://claude.com/claude-code)。
验证安装:
```bash
claude --version
```
## 运行第一个 Prompt
### 步骤
1. **查看示例 prompt**:打开 `prompts/example.md`,这是一个简单的任务:创建欢迎脚本。
2. **执行 prompt**
```bash
npm run prompt -- prompts/example.md
```
或者直接使用 Node.js
```bash
node scripts/run-prompt.js prompts/example.md
```
3. **与 AI 交互**:脚本会调用 Claude CodeAI 将生成 `welcome.js` 文件。按照提示操作。
4. **验证结果**:检查生成的 `welcome.js` 文件,并运行它:
```bash
node welcome.js
```
## 自举开发流程
MetaCraft 的核心是自举bootstrapping——使用工具自身来开发工具。
### 1. 查看待办任务
```bash
cat meta/todo.md
```
或者运行自举循环查看:
```bash
npm start
```
### 2. 选择一个任务
例如“实现prompt引擎”。找到或创建对应的 prompt 文件(`prompts/implement-prompt-engine.md`)。
### 3. 编写 Prompt
Prompt 应清晰描述任务目标、上下文、输出要求。参考已有示例。
### 4. 执行自举循环
```bash
npm start
```
选择任务编号,工具将自动执行对应 prompt并调用 AI 生成代码。
### 5. 验证与提交
- 运行测试(待实现)。
- 确保构建通过。
- 提交更改到 Git。
### 6. 更新任务状态
自举循环会询问是否标记任务为完成。确认后,`meta/todo.md` 中对应任务将被勾选。
## 项目结构速查
```
metacraft/
├── prompts/ # 任务prompt库
│ └── example.md # 示例prompt
├── scripts/ # 核心脚本
│ ├── run-prompt.js # 执行prompt
│ └── bootstrap.js # 自举循环
├── docs/ # 文档
│ ├── ARCHITECTURE.md
│ └── GETTING_STARTED.md
├── meta/ # 元数据
│ └── todo.md # 待办任务
├── config/ # 配置(暂无)
├── templates/ # 模板(暂无)
└── package.json
```
## 常见问题
### Claude Code 命令未找到
确保已正确安装 Claude Code CLI并且 `claude` 命令在 PATH 中。
### 执行 prompt 时卡住
可能是 Claude Code 需要交互式输入。尝试手动运行:
```bash
claude --file prompts/example.md
```
### 如何添加新任务?
1.`meta/todo.md` 中添加一行 `- [ ] 任务描述`
2.`prompts/` 中创建对应的 prompt 文件(可选)。如果不存在,自举循环会提示创建。
### 如何修改脚本行为?
直接编辑 `scripts/` 下的文件。修改后,可以运行 `npm test` 验证(测试待实现)。
## 下一步
- 阅读 [ARCHITECTURE.md](ARCHITECTURE.md) 了解设计细节。
- 尝试修改 `prompts/example.md` 并观察效果。
- 参与开发:选择一个待办任务,编写 prompt 并提交 Pull Request。