Autonomous research agent with web search, source analysis, and report synthesis. Built on Pi agent core. Available as CLI, programmatic API, and MCP server. Features: - 4 built-in tools: web_search, read_url, save_note, synthesize_report - CLI with TUI and print modes - Programmatic API via ResearchAgent class - MCP server with 3 tools: research, quick_search, read_url - Skills system for custom research behavior - Automatic .env file loading for API keys - Configurable max turns, output formats (markdown/JSON/bullet) - Automatic report saving to research-output/
4.8 KiB
Contributing to Pi Research Agent
Thank you for your interest in contributing to Pi Research Agent! This document provides guidelines and instructions for contributing.
Code of Conduct
By participating in this project, you agree to maintain a respectful and inclusive environment for everyone.
How to Contribute
Reporting Bugs
If you find a bug, please open an issue on GitHub with:
- A clear, descriptive title
- Steps to reproduce the bug
- Expected vs actual behavior
- Your environment (Node.js version, OS, etc.)
- Relevant logs or error messages
Suggesting Features
Feature requests are welcome! Please open an issue with:
- A clear description of the feature
- Use cases and motivation
- Any implementation ideas you have
Submitting Pull Requests
-
Fork the repository and create a new branch from
main:git checkout -b feature/your-feature-name -
Install dependencies:
npm install -
Make your changes following the code style guidelines below
-
Add tests for new functionality
-
Run the build and tests:
npm run build npm test -
Commit your changes with a clear message:
git commit -m "Add: brief description of your changes" -
Push to your fork and submit a pull request
-
Wait for review - maintainers will review your PR and may request changes
Development Setup
Prerequisites
- Node.js >= 22.19.0
- npm or pnpm
- Git
Project Structure
packages/research-agent/
├── src/
│ ├── agent.ts # Main ResearchAgent class
│ ├── cli.ts # CLI entry point
│ ├── mcp-cli.ts # MCP server entry point
│ ├── mcp-server.ts # MCP server implementation
│ ├── system-prompt.ts # System prompt templates
│ ├── config.ts # Configuration constants
│ ├── types.ts # TypeScript type definitions
│ ├── tools/ # Built-in research tools
│ ├── utils/ # Utility functions
│ ├── skills/ # Skills system
│ └── modes/ # Output modes (TUI, print)
├── examples/ # Usage examples
├── package.json
└── tsconfig.build.json
Code Style
- Use TypeScript with strict mode
- Follow the existing code conventions
- Use 4-space indentation (matches the rest of the monorepo)
- Use single quotes for strings
- Add JSDoc comments for public APIs
- Avoid
anytypes when possible - Use
importstatements (notrequire)
Testing
- Write unit tests for new functions
- Write integration tests for new features
- Ensure all tests pass before submitting a PR
- Aim for good test coverage
Commit Messages
Use clear, descriptive commit messages:
Add: new feature descriptionFix: bug descriptionUpdate: change descriptionRefactor: code improvement descriptionDocs: documentation update
Adding New Tools
To add a new research tool:
-
Create a new file in
src/tools/:// src/tools/my-tool.ts import type { AgentTool } from "@earendil-works/pi-agent-core"; import { Type, type Static } from "typebox"; const mySchema = Type.Object({ param: Type.String({ description: "Parameter description" }), }); export type MyInput = Static<typeof mySchema>; export function createMyTool(): AgentTool<typeof mySchema, MyDetails> { return { name: "my_tool", label: "My Tool", description: "Tool description", parameters: mySchema, execute: async (toolCallId, params: MyInput) => { // Implementation return { content: [{ type: "text" as const, text: "result" }], details: {}, }; }, }; } -
Register the tool in
src/tools/index.ts -
Add tests for the tool
-
Update documentation
Adding MCP Tools
To add a new MCP tool:
-
Add the tool definition in
src/mcp-server.ts:server.registerTool( "my_tool", { description: "Tool description", inputSchema: { param: z.string().describe("Parameter description"), }, }, async (params: any) => { // Implementation return { content: [{ type: "text" as const, text: "result" }], }; }, ); -
Add tests
-
Update MCP_SERVER.md documentation
Release Process
- Update version in
package.jsonfollowing semver - Update
CHANGELOG.mdwith changes - Create a git tag:
git tag v0.1.0 - Push tag:
git push origin v0.1.0 - GitHub Actions will publish to npm automatically
Questions?
If you have questions, feel free to:
- Open an issue on GitHub
- Join our community chat
- Email the maintainers
Thank you for contributing! 🎉