Duyetbot Agent

Getting Started

Installation, configuration, and setup guide. Clone, install, run dev server, CLI chat, tests, and GitHub Bot.

Related: Use Cases | Architecture | API Reference | Deployment

Complete guide to installing, configuring, and running duyetbot-agent.


Prerequisites

  • Node.js 20+
  • pnpm 9+
  • GitHub account (for OAuth and GitHub Bot)
  • Anthropic API key (or Claude-compatible: Z.AI, OpenRouter)

Installation

1. Clone Repository

git clone https://github.com/duyet/duyetbot-agent.git
cd duyetbot-agent

2. Install Dependencies

pnpm install

3. Build All Packages

pnpm run build

4. Run Tests

pnpm test

All 443 tests should pass.


Configuration

Environment Variables

Create a .env file in the root directory:

# LLM Provider (required)
ANTHROPIC_API_KEY=sk-ant-...
ANTHROPIC_BASE_URL=https://api.anthropic.com  # or Z.AI URL
 
# Alternative providers (optional)
OPENROUTER_API_KEY=sk-or-...
 
# GitHub Bot (for webhook integration)
BOT_USERNAME=duyetbot
GITHUB_TOKEN=ghp_xxx
WEBHOOK_SECRET=your_webhook_secret
 
# Fly.io (for Supervisor to provision Workers)
FLY_API_TOKEN=xxx
FLY_ORG=personal
 
# MCP Memory Server (optional)
MCP_SERVER_URL=https://memory.duyetbot.workers.dev
MCP_AUTH_TOKEN=xxx
 
# Server Configuration
PORT=3001
NODE_ENV=development

GitHub OAuth Setup

  1. Go to GitHub Developer Settings
  2. Create a new OAuth App
  3. Set callback URL: http://localhost:3001/auth/github/callback
  4. Copy Client ID and Client Secret to .env

LLM Provider Configuration

The system supports Claude-compatible providers:

ProviderFormatExample
Anthropicclaude:<model>claude:claude-sonnet-4-20250514
Z.AIvia base URLSet ANTHROPIC_BASE_URL=https://api.z.ai/api/anthropic
OpenRouteropenrouter:<model>openrouter:anthropic/claude-3.5-sonnet

Model shortcuts: haiku, sonnet, opus


Development

Start Development Server

pnpm run dev

This starts all packages in watch mode.

Run Specific Package

# CLI only
pnpm run dev --filter @duyetbot/cli
 
# GitHub Bot only
pnpm run dev --filter @duyetbot/github-bot

Code Quality

# Lint all code
pnpm run lint
 
# Fix lint issues
pnpm run lint:fix
 
# Type check
pnpm run type-check
 
# Format code
pnpm run format
 
# Run all checks
pnpm run check

Testing

# All tests
pnpm test
 
# Watch mode
pnpm run test:watch
 
# Specific package
pnpm test --filter @duyetbot/core
 
# Coverage report
pnpm run test:coverage

Project Structure

duyetbot-agent/
├── apps/
│   ├── github-bot/        # GitHub App webhook handler
│   ├── telegram-bot/      # Telegram bot
│   └── memory-mcp/        # MCP memory server (Cloudflare Workers)
├── packages/
│   ├── cli/               # Command-line interface
│   ├── core/              # Agent core logic
│   ├── providers/         # LLM provider adapters
│   ├── tools/             # Tool implementations
│   └── types/             # Shared TypeScript types
├── docs/                  # Documentation
├── PLAN.md                # Development roadmap
└── CLAUDE.md              # Claude Code instructions

CLI Usage

Interactive Chat

pnpm run cli chat

One-shot Questions

pnpm run cli ask "How do I implement rate limiting?"

With Specific Model

pnpm run cli chat --model sonnet
pnpm run cli chat --model haiku

Session Management

# List sessions
pnpm run cli sessions list
 
# Continue session
pnpm run cli chat --session <session-id>

GitHub Bot Usage

Local Development

  1. Use smee.io for webhook forwarding:
npx smee -u https://smee.io/YOUR_CHANNEL -p 3001 -P /webhook
  1. Start the bot:
pnpm run dev --filter @duyetbot/github-bot
  1. Configure GitHub App webhook URL to your smee.io URL

Testing Locally

  1. Create a test issue in your repository
  2. Comment: @duyetbot hello
  3. Bot should respond within seconds

Git Hooks

The project includes automatic quality checks before git push:

  • Runs linting and auto-fixes
  • Runs TypeScript type checking
  • Runs all tests
  • Prevents push if checks fail

Hooks are automatically installed via pnpm install. To bypass:

git push --no-verify

Troubleshooting

Build Failures

# Clean and rebuild
pnpm run clean
pnpm install
pnpm run build

Test Failures

# Run specific test file
pnpm test -- --filter @duyetbot/core src/__tests__/session.test.ts

TypeScript Errors

# Check types across all packages
pnpm run type-check

Dependency Issues

# Clear node_modules and reinstall
rm -rf node_modules packages/*/node_modules apps/*/node_modules
pnpm install

Next Steps