Skip to content

快速开始

本指南将帮助你在 5 分钟内创建并运行你的第一个 AweeClaw 场景。

前置条件

  • Node.js >= 18.0.0
  • npmpnpm
  • 已安装 AweeClaw 客户端

第一步:安装 CLI

bash
# 全局安装
npm install -g @aweeclaw/scenario-cli

# 或使用 npx(无需安装)
npx @aweeclaw/scenario-cli init my-scenario

第二步:创建项目

bash
# 创建声明式场景(推荐新手)
npx aweeclaw-scenario init my-scenario --type declarative --name-zh "我的场景"

# 或创建编程式场景
npx aweeclaw-scenario init my-scenario --type programmatic --name-zh "我的场景"

第三步:开发场景

声明式场景

编辑 scenario.json

json
{
  "id": "my-scenario",
  "version": "1.0.0",
  "name": "My Scenario",
  "nameZh": "我的场景",
  "type": "declarative",
  "identity": {
    "systemPromptFile": "prompts/system.md"
  },
  "capabilities": {
    "builtinTools": ["web_search", "ask_user"]
  }
}

编辑 prompts/system.md

markdown
# 角色

你是一个友好的 AI 助手,帮助用户解答问题。

# 行为准则

- 使用简洁清晰的语言回答
- 如果不确定答案,诚实地告诉用户
- 优先使用工具搜索最新信息

编程式场景

编辑 src/index.ts

typescript
import type { ScenarioModule } from '@aweeclaw/scenario-sdk'

export default {
  id: 'my-scenario',
  version: '1.0.0',

  getManifest() {
    return {
      id: 'my-scenario',
      version: '1.0.0',
      name: 'My Scenario',
      nameZh: '我的场景',
      category: 'custom',
      tags: ['demo'],
    }
  },

  getPlugin() {
    return {
      id: 'my-scenario',
      name: 'My Scenario',
      nameZh: '我的场景',
      version: '1.0.0',
      category: 'custom',
      identity: {
        systemPrompt: '你是一个友好的 AI 助手。',
      },
      capabilities: {
        toolPacks: [],
        modes: [],
        contextTypes: [],
        outputFormats: [],
      },
      ui: { layout: 'chat-centric', panels: [], sidebarItems: [], statusBarItems: [] },
      dataSources: { workspace: false },
    }
  },

  getTools() {
    return [{
      name: 'greet',
      definition: {
        name: 'greet',
        description: '向用户打招呼',
        parameters: {
          type: 'object',
          properties: {
            name: { type: 'string', description: '用户名称' },
          },
          required: ['name'],
        },
      },
      executor: async (args) => ({
        success: true,
        data: `你好,${args.name}!`,
      }),
    }]
  },
} satisfies ScenarioModule

第四步:本地测试

bash
# 进入项目目录
cd my-scenario

# 安装依赖(仅编程式场景需要)
npm install

# 启动开发模式
npx aweeclaw-scenario dev

打开 AweeClaw 客户端,在设置中添加本地场景路径,即可测试。

第五步:构建与发布

bash
# 构建
npx aweeclaw-scenario build

# 校验
npx aweeclaw-scenario validate

# 打包
npx aweeclaw-scenario pack

# 登录并发布
npx aweeclaw-scenario login
npx aweeclaw-scenario publish

下一步

AweeClaw AI 应用构建平台