Fei (named after the Chinese flying dragon of adaptability) is a powerful code assistant that combines AI capabilities with advanced code manipulation tools and a distributed memory system.
- Overview
- Project Vision
- Features
- Installation
- Usage
- FEI Network
- Architecture
- Documentation
- Known Issues & Bugs
- Project Roadmap
- Contributing
- License
Fei is an advanced AI-powered code assistant built to enhance software development workflows. It integrates with multiple LLM providers, offers powerful code manipulation tools, and features a distributed memory system for persistent knowledge across sessions.
By leveraging the capabilities of large language models like Claude and GPT, Fei provides intelligent assistance for coding tasks, code search, refactoring, and documentation.
The Fei project represents more than just a code assistant; it's part of a broader vision for a democratized AI ecosystem called the FEI Network (Flying Dragon of Adaptability Network).
The FEI Network aims to be a truly democratic, distributed system of artificial intelligence that serves the collective good through:
- Distributed Processing: Harnessing collective computational power across millions of individual nodes
- Specialized Intelligence Federation: Creating a network of specialized intelligences that collaborate through open protocols
- Task-Oriented Contribution: Participants contribute according to their capability, transforming computation from wasteful competition to purposeful collaboration
- Global Inclusion: Active design for participation across economic, geographic, linguistic, and cultural boundaries
- Public Benefit Orientation: Serving humanity's collective interests rather than narrow priorities
The project stands as an alternative to centralized AI approaches, focusing on human agency, democratization of artificial intelligence, and equitable distribution of computational power.
- Multi-provider Support: Seamless integration with Anthropic, OpenAI, Groq, and more through LiteLLM
- Model Selection: Easily switch between various LLM models
- API Key Management: Secure handling of API keys with proper precedence
-
Intelligent Search:
GlobTool
: Fast file pattern matching using glob patternsGrepTool
: Content searching using regular expressionsSmartSearch
: Context-aware code search for definitions and usage
-
Code Editing:
View
: File viewing with line limiting and offsetEdit
: Precise code editing with context preservationReplace
: Complete file content replacementRegexEdit
: Edit files using regex patterns for batch changes
-
Code Organization:
LS
: Directory listing with pattern filteringBatchGlob
: Search for multiple patterns in a single operationFindInFiles
: Search for patterns across specific files
-
Memdir: Maildir-compatible memory organization
- Hierarchical memory with cur/new/tmp folders
- Header-based metadata and tags
- Flag-based status tracking
- Advanced filtering system
- Memory lifecycle management
-
Memorychain: Distributed memory ledger
- Blockchain-inspired tamper-proof chain
- Consensus-based memory validation
- Peer-to-peer node communication
- Shared brain across multiple agents
- Node health monitoring and task tracking
- Brave Search: Web search integration for real-time information
- Memory Service: Knowledge graph for persistent memory
- Fetch Service: URL fetching for internet access
- GitHub Service: GitHub integration for repository management
- Sequential Thinking: Multi-step reasoning service
# Clone the repository
git clone https://github.com/yourusername/fei.git
cd fei
# Install from the current directory
pip install -e .
# Or install directly from GitHub
pip install git+https://github.com/yourusername/fei.git
- Python 3.8 or higher
- Required API keys (at least one):
ANTHROPIC_API_KEY
: Anthropic Claude API keyOPENAI_API_KEY
: OpenAI API keyGROQ_API_KEY
: Groq API keyBRAVE_API_KEY
: Brave Search API key (for web search)
# Start interactive chat (traditional CLI)
fei
# Start modern Textual-based chat interface
fei --textual
# Send a single message and exit
fei --message "Find all Python files in the current directory"
# Use a specific model
fei --model claude-3-7-sonnet-20250219
# Use a specific provider
fei --provider openai --model gpt-4o
# Enable debug logging
fei --debug
from fei.core.assistant import Assistant
# Create an assistant
assistant = Assistant()
# Simple interaction
response = assistant.ask("What files contain the function 'process_data'?")
print(response)
# Interactive session
assistant.start_interactive_session()
Configure Fei through environment variables:
# API Keys
export ANTHROPIC_API_KEY=your_anthropic_api_key
export OPENAI_API_KEY=your_openai_api_key
export GROQ_API_KEY=your_groq_api_key
export BRAVE_API_KEY=your_brave_api_key
# Configuration
export FEI_LOG_LEVEL=DEBUG
export FEI_LOG_FILE=/path/to/logfile.log
# Create memory directory structure
python -m memdir_tools
# Create a new memory
python -m memdir_tools create --subject "Meeting Notes" --tags "notes,meeting" --content "Discussion points..."
# List memories in folder
python -m memdir_tools list --folder ".Projects/Python"
# Search memories
python -m memdir_tools search "python"
# Advanced search with complex query
python -m memdir_tools search "tags:python,important date>now-7d Status=active sort:date" --format compact
Fei is part of the broader FEI Network vision - a distributed, democratic system for collective intelligence. The network functions as a living, adaptive neural network composed of thousands of individual nodes, each with specialized capabilities.
- Radical Openness: Anyone with computing resources can participate
- Emergent Specialization: Nodes naturally specialize based on their capabilities
- Autonomous Organization: The network self-organizes through quorum-based decision making
- Value Reciprocity: Contributions are fairly rewarded with FeiCoin
- Distributed Resilience: No single point of failure or control
The FEI Network consists of specialized node types:
- Mathematical Nodes: Solving complex computational problems and formal reasoning
- Creative Nodes: Generation of text, images, music, and creative works
- Analytical Nodes: Pattern recognition, data analysis, and insight extraction
- Knowledge Nodes: Information retrieval, verification, and contextualization
- Coordination Nodes: Supporting collaboration between humans and AI systems
The network is implemented through several layers:
- Computation Layer: Harnessing diverse hardware
- Memory Layer: Distributed storage of models and knowledge
- Communication Layer: Efficient routing of tasks and results
- Verification Layer: Ensuring quality and alignment with human values
- Governance Layer: Enabling collective decision-making
Fei's architecture is designed for extensibility and performance:
/
βββ fei/ # Main package
β βββ core/ # Core assistant implementation
β β βββ assistant.py # Main assistant class
β β βββ mcp.py # MCP service integration
β β βββ task_executor.py # Task execution logic
β βββ tools/ # Code manipulation tools
β β βββ code.py # File and code manipulation
β β βββ registry.py # Tool registration
β β βββ definitions.py # Tool definitions
β βββ ui/ # User interfaces
β β βββ cli.py # Command-line interface
β β βββ textual_chat.py # TUI with Textual
β βββ utils/ # Utility modules
β βββ config.py # Configuration management
β βββ logging.py # Logging setup
βββ memdir_tools/ # Memory system
β βββ server.py # HTTP API server
β βββ memorychain.py # Distributed memory system
β βββ filter.py # Memory filtering engine
βββ examples/ # Example usage scripts
The Fei project includes comprehensive documentation in the docs/
directory:
- FEI Manifesto: Declaration of digital independence and collective intelligence
- How FEI Network Works: Detailed explanation of the distributed network
- Project Status: Current development status and roadmap
- RepoMap: Tools for understanding codebase structure
- MemDir README: Documentation for the MemDir memory system
- MemoryChain README: Documentation for the distributed memory ledger
- Brave Search Troubleshooting: Resolving issues with web search
- Search Tools: Guide to code search capabilities
- Textual README: Documentation for the TUI interface
-
Error Handling
- Generic exception handling in
/root/fei/fei/core/assistant.py
masks specific errors - Swallowed exceptions in various components hide underlying problems
- Missing proper checks before accessing nested attributes
- Generic exception handling in
-
Race Conditions
- Process termination lacks proper synchronization
- Background process management has potential race conditions
- Complex asyncio event loop handling needs improvement
-
Performance Issues
- Inefficient glob pattern matching with large codebases
- Binary file detection is slow for large files
- Memory usage can be high when processing many files
-
Edit Tool
- Requires unique context for find/replace operations
- No support for multi-file refactoring
- Limited validation capabilities
-
Shell Command Execution
- Interactive commands are not fully supported
- Command allowlisting is restrictive
- Potential for zombie processes
-
MCP Integration
- Limited error handling for network issues
- No automatic reconnection for failed services
- Response size limitations
-
Memdir
- No cleanup mechanism for old memories
- Memory copy functionality not implemented
- Folder creation is not recursive
-
Memorychain
- Consensus mechanism is oversimplified
- Limited protection against malicious nodes
- No real blockchain implementation yet
- Basic assistant functionality
- File manipulation tools
- MCP service integration
- Command-line interface
- Enhanced error handling
- Improved test coverage
- Performance optimization
- Documentation improvement
- Basic web UI
- Plugin system foundations
- Advanced code generation
- Multi-file operations
- Stable API
- IDE integrations
- Comprehensive documentation
- Production-ready memory system
Contributions are welcome! Please follow these steps:
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature
) - Make your changes
- Add tests for new functionality
- Ensure all tests pass
- Commit your changes (
git commit -m 'Add amazing feature'
) - Push to the branch (
git push origin feature/amazing-feature
) - Open a Pull Request
This project is licensed under the MIT License - see the LICENSE file for details.
Built with β€οΈ by the Fei team
GitHub β’ Issues β’ Documentation
The FEI Network: Intelligence of the people, by the people, for the people.