diff --git a/.gitignore b/.gitignore index 7b6caf3..94cba24 100644 --- a/.gitignore +++ b/.gitignore @@ -160,3 +160,5 @@ cython_debug/ # and can be added to the global gitignore or merged into this file. For a more nuclear # option (not recommended) you can uncomment the following to ignore the entire idea folder. .idea/ + +.zed diff --git a/README.md b/README.md index 9e8aa68..2f0e707 100644 --- a/README.md +++ b/README.md @@ -1,50 +1,27 @@ -# Basic Factory - -AI-assisted software development workflow tools. - -## Overview - -Basic Factory provides tools for integrating AI assistants (like Claude) into software development workflows via GitHub. It enables AI assistants to: - -- Create and manage branches -- Commit changes -- Create pull requests -- Run and monitor GitHub Actions -- Participate in code review - -## Github -For the GitHub token, you'll need to: - -Go to GitHub Settings → Developer Settings → Personal Access Tokens -https://docs.github.com/en/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens - - -Create a new token with 'repo' scope -We can use this for both direct API calls and for GitHub Actions - -## Installation - -```bash -uv add basic-factory -``` - -## Development - -Set up development environment: - -```bash -# Create virtual environment -uv venv -uv sync - -# Install project in editable mode with dev dependencies -uv add --dev --editable . -uv add --dev pytest pytest-cov ruff - -source .venv/bin/activate - -# Run tests -pytest -``` - - +# MCP Filesystem Tools - Working Notes + +## Tool Capabilities +1. **Directory Operations** + - `create_directory`: Creates new directories, including nested paths + - `list_directory`: Shows files and directories with [FILE] and [DIR] prefixes + +2. **File Operations** + - `write_file`: Creates or overwrites files with content + - `read_file`: Retrieves file contents + - `move_file`: Relocates files between directories + - `get_file_info`: Provides metadata (size, dates, permissions) + - `search_files`: Finds files matching patterns (note: case sensitivity varies) + +3. **Git Tool Limitations** + - Missing `git push` functionality + - Local operations only (add, commit, branch) + - No remote repository management + - Branch operations require extra verification + +4. **GitHub Tool Limitations** + - No PR comment functionality + - No issue comments + - `push_files` requires existing remote branch + - PR creation returns merge_commit_sha errors + - Limited repository management options + - No direct comment or review features \ No newline at end of file diff --git a/basic-memory.md b/basic-memory.md index e69de29..117e05d 100644 --- a/basic-memory.md +++ b/basic-memory.md @@ -0,0 +1,537 @@ +# basic-memory: Project Documentation + +## Overview + +basic-memory represents a fundamental shift in how humans and AI collaborate on projects. It combines the time-tested Zettelkasten note-taking method with modern knowledge graph technology and Anthropic's Model Context Protocol (MCP) to create something uniquely powerful: a system that both humans and AI can naturally work with, each in their own way. + +Built on SQLite for simplicity and portability, basic-memory solves a critical challenge in AI-human collaboration: maintaining consistent, rich context across conversations while keeping information organized and accessible. It's like having a shared brain that both AI and humans can read and write to naturally. + +Key innovations: +- **AI-Native Knowledge Structure**: Uses entities and relations that match how LLMs think +- **Human-Friendly Interface**: Everything is readable/writable as markdown text +- **Project Isolation**: Load only relevant context for focused discussions +- **Local-First**: Your knowledge stays in SQLite databases you control +- **Tool-Driven**: Leverages MCP for seamless AI interaction with your knowledge + +Think of it as a bridge between human note-taking and AI thinking patterns. Whether you're documenting code, managing projects, or building complex systems, basic-memory helps maintain continuous, meaningful collaboration between human and AI partners. + +Best of all, it follows the Basic Machines philosophy: simple, powerful tools that respect user agency and avoid vendor lock-in. No cloud dependencies, no black boxes - just a straightforward system for building shared understanding between humans and AI. + +## Core Concepts + +### Knowledge Graph Structure + +#### Entities +Primary nodes in the knowledge graph. Each entity has: +- Unique name (identifier) +- Entity type (e.g., "person", "organization", "project") +- List of observations + +Example: +```json +{ + "name": "Basic_Factory", + "entityType": "Project", + "observations": ["Collaborative development environment", "Uses MCP tools"] +} +``` + +#### Relations +Directed connections between entities, stored in active voice: +- From entity +- To entity +- Relation type + +Example: +```json +{ + "from": "Basic_Memory", + "to": "Basic_Machines", + "relationType": "is_part_of" +} +``` + +#### Observations +Atomic facts about entities: +- Stored as strings +- Attached to specific entities +- Independent addition/removal +- One fact per observation + +Example: +```json +{ + "entityName": "Basic_Memory", + "observations": [ + "Uses SQLite for storage", + "Supports project isolation", + "Enables AI-human collaboration" + ] +} +``` + +## Database Schema + +```sql +-- Entities table +CREATE TABLE entities ( + name TEXT PRIMARY KEY, + entity_type TEXT NOT NULL +); + +-- Observations table +CREATE TABLE observations ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + entity_name TEXT REFERENCES entities(name), + content TEXT NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP +); + +-- Relations table +CREATE TABLE relations ( + id INTEGER PRIMARY KEY AUTOINCREMENT, + from_entity TEXT REFERENCES entities(name), + to_entity TEXT REFERENCES entities(name), + relation_type TEXT NOT NULL, + created_at DATETIME NOT NULL DEFAULT CURRENT_TIMESTAMP, + UNIQUE(from_entity, to_entity, relation_type) +); + +-- Full-text search +CREATE VIRTUAL TABLE entity_fts USING fts5( + name, + entity_type, + observations_raw +); +``` + +## Project Management + +### Database Structure +``` +~/.basic-memory/ +├── projects/ +│ ├── basic-factory.db +│ ├── basic-memory.db +│ └── client-project.db +└── config.json +``` + +### CLI Commands +```bash +# Project management +basic-memory create project basic-factory +basic-memory switch project client-x +basic-memory list projects + +# Entity management +basic-memory add entity "Basic_Memory" --type Project +basic-memory add observation "Basic_Memory" "Uses SQLite storage" +basic-memory add relation "Basic_Memory" "Basic_Machines" "is_part_of" +``` + +## MCP Tool Integration + +### Tool Definitions +```json +{ + "tools": [ + { + "name": "load_project", + "description": "Load a project's knowledge graph into context", + "parameters": { + "type": "object", + "properties": { + "project_name": { + "type": "string", + "description": "Name of the project to load" + } + }, + "required": ["project_name"] + } + }, + { + "name": "query_knowledge", + "description": "Query the current project's knowledge graph", + "parameters": { + "type": "object", + "properties": { + "query": { + "type": "string", + "description": "Search query or entity name" + } + }, + "required": ["query"] + } + } + ] +} +``` + +### Example Usage +```python +# In Claude chat +Human: Load the basic-factory project memory + +Claude: Using load_project tool... +Result: Loaded 15 entities and 45 relations from basic-factory +``` + +```python +# In Claude chat +Human: What do we know about the Basic_Factory project? + +Claude: Using query_knowledge tool... +Result: Found entity "Basic_Factory" with observations: +- Collaborative development environment +- Uses MCP tools for file and memory management +- Built with git integration capabilities +- Focuses on maintaining project context across sessions + +Related entities: +- Basic_Machines (relation: is_part_of) +- Paul (relation: develops) +- MCP_Tools (relation: uses) +``` + +## Export Formats + +### Markdown Export +```markdown +--- +name: Basic_Factory +type: Project +created: 2024-02-27T10:30:00Z +--- + +[Observations] +- Collaborative development environment +- Uses MCP tools for file and memory management +- Built with git integration capabilities +- Focuses on maintaining project context across sessions + +[Relations] +- Part of: [Basic_Machines](entity://Basic_Machines) +- Developed by: [Paul](entity://Paul) +- Uses: [MCP_Tools](entity://MCP_Tools) +``` + +## Implementation Roadmap + +### Phase 1: Core Infrastructure +- SQLite database implementation +- Basic schema and FTS setup +- Project isolation framework +- Simple CLI interface + +### Phase 2: MCP Integration +- MCP server implementation +- Tool definitions and handlers +- Context loading mechanisms +- Query interface + +### Phase 3: Export/Import +- Markdown export +- Basic documentation generation +- Import from existing notes +- Batch operations + +### Phase 4: Advanced Features (Future) +- Versioning using R-tree +- Extended metadata using JSON +- Advanced search capabilities +- Integration with other tools + +## Business Model +1. **Core (Free)** + - Local SQLite database + - Basic knowledge graph functionality + - Full-text search + - Simple markdown export + - Basic MCP tools + +2. **Professional Features (Potential)** + - Rich document export + - Advanced versioning + - Collaboration features + - Custom integrations + - Priority support + +## Technical Dependencies +- SQLite (core database) +- FTS5 (full-text search) +- MCP Protocol (tool integration) +- Python (implementation language) + +## Basic Machines Integration +- Complements basic-factory for AI collaboration +- Follows basic-components architecture principles +- Built on basic-foundation infrastructure +- Maintains DIY/punk philosophy of user control and transparency + +## Key Principles +1. **Local First**: All data stored locally in SQLite +2. **Project Isolation**: Separate databases per project +3. **Human Readable**: Everything exportable to plain text +4. **AI Friendly**: Structure optimized for LLM interaction +5. **DIY Ethics**: User owns and controls their data +6. **Simple Core**: Start simple, expand based on needs +7. **Tool Integration**: MCP-based interaction model + +## Future Considerations +1. **Versioning**: Track knowledge graph evolution +2. **Rich Metadata**: Extended attributes via JSON +3. **Advanced Search**: Complex query capabilities +4. **Multi-User**: Collaborative knowledge management +5. **API Integration**: Connect with other tools +6. **Visualization**: Graph visualization tools + +## Community and Support +1. Open source core implementation +2. Public issue tracking +3. Community contributions welcome +4. Documentation and examples +5. Professional support options + +This system enables true AI-human collaboration while maintaining the DIY ethics and user control that are central to the Basic Machines philosophy. + + +1. **Entity Relationships** +```mermaid +graph TD + BF[Basic Factory] + BM[Basic Machines] + Paul[Paul] + MCP[MCP Tools] + DIY[DIY Ethics] + + Paul -->|founded| BM + Paul -->|develops| BF + BF -->|is part of| BM + BF -->|uses| MCP + BM -->|embodies| DIY + Paul -->|explores| MCP + + classDef project fill:#f9f,stroke:#333,stroke-width:2px; + classDef person fill:#bbf,stroke:#333,stroke-width:2px; + classDef tech fill:#bfb,stroke:#333,stroke-width:2px; + classDef philosophy fill:#fbb,stroke:#333,stroke-width:2px; + + class BF project; + class Paul person; + class MCP tech; + class DIY philosophy; + class BM project; +``` + +2. **Project Architecture** +```mermaid +graph TB + subgraph Storage + DB[(SQLite DB)] + FTS[Full Text Search] + end + + subgraph Interface + CLI[Command Line] + MCP[MCP Tools] + end + + subgraph Export + MD[Markdown] + VIZ[Visualizations] + end + + CLI -->|manage| DB + MCP -->|query| DB + DB -->|index| FTS + DB -->|generate| MD + DB -->|create| VIZ +``` + +3. **Knowledge Flow** +```mermaid +flowchart LR + subgraph Input + H[Human Input] + AI[AI Input] + CLI[CLI Commands] + end + + subgraph Processing + KG[Knowledge Graph] + FTS[Full Text Search] + end + + subgraph Output + MD[Markdown] + VIZ[Visualizations] + CTX[AI Context] + end + + H -->|add| KG + AI -->|enhance| KG + CLI -->|manage| KG + KG -->|export| MD + KG -->|generate| VIZ + KG -->|load| CTX + KG ---|index| FTS +``` + +These diagrams could be: +1. Generated automatically from the knowledge graph +2. Updated when the graph changes +3. Included in exports and documentation +4. Used for visualization in tools/UI + +We could even add specific CLI commands: +```bash +basic-memory visualize relationships basic-factory +basic-memory visualize architecture +basic-memory visualize flow +``` + +# basic-memory-webui + +## Overview +basic-memory-webui is a notebook-style interface for the basic-memory knowledge graph system, enabling interactive human-AI collaboration in knowledge work. It combines the power of Zettelkasten note-taking, knowledge graphs, and AI assistance into a unique local-first tool for thought. + +### Why This is Cool and Interesting +This project represents a novel approach to human-AI collaboration by: +1. **True Two-Way Knowledge Flow**: Unlike traditional AI chat interfaces, both human and AI can read and write to the same knowledge graph, creating genuine collaborative intelligence +2. **Local-First Knowledge**: Your knowledge base lives in SQLite, not in some cloud service. It's yours to control, backup, and modify +3. **Notebook-Style Interface**: Familiar to developers but revolutionized with AI collaboration - imagine Jupyter Notebooks where cells can be knowledge graphs, markdown, or AI conversations +4. **MCP Integration**: Uses Anthropic's Model Context Protocol to give AI genuine understanding of context, not just simulated responses +5. **Basic Machines Stack**: Built on our proven stack (basic-foundation, basic-components), showing how simple tools can combine into powerful systems + +## Architecture + +```mermaid +graph TD + subgraph "Frontend" + NB[Notebook Interface] + VIZ[Visualizations] + ED[Editors] + end + + subgraph "Backend" + API[FastAPI] + DB[(SQLite)] + MCP[MCP Server] + end + + NB -->|HTMX| API + VIZ -->|Updates| API + ED -->|Changes| API + API -->|Query| DB + API -->|Context| MCP + MCP -->|Updates| DB +``` + +## Core Features +1. **Notebook Interface** + - Markdown cells + - Knowledge graph visualizations + - AI chat context + - Interactive editing + +2. **Knowledge Management** + - Entity/relation viewing + - Graph visualization + - Tag organization + - Full-text search + +3. **AI Integration** + - Context loading + - Knowledge updates + - Interactive chat to read/update notes + - Memory persistence + +4. **Data Management** + - Local SQLite storage + - Text export/import + - Version control friendly + - Backup support + +## Technical Stack +- **Backend**: FastAPI, SQLite, MCP Tools +- **Frontend**: JinjaX, HTMX, Alpine.js, TailwindCSS +- **Components**: basic-components library +- **Infrastructure**: basic-foundation patterns + +## Implementation Strategy + +### Phase 1: Core Interface +- Basic notebook interface +- Markdown editing +- Simple knowledge graph viewing +- Basic MCP integration + +### Phase 2: Rich Features +- Interactive graph visualization +- Advanced editing tools +- Real-time updates +- Enhanced AI collaboration + +### Phase 3: Advanced Features +- Custom visualizations +- Extended search +- Knowledge analytics +- Export formats + +## Development Approach +1. Start simple with core notebook interface +2. Add features iteratively +3. Focus on user experience +4. Maintain Basic Machines philosophy throughout + +## Integration Points +1. **basic-memory** + - Core knowledge graph + - MCP server + - Data storage + +2. **basic-components** + - UI components + - Interactive elements + - Styling system + +3. **basic-foundation** + - API patterns + - Authentication (if needed) + - Testing approach + +## Future Possibilities +1. Multiple knowledge bases +2. Collaborative editing +3. Custom visualization plugins +4. Enhanced AI capabilities +5. Advanced graph analytics + +## Future Enhancements + +## Security & Privacy Features +For shared or hosted deployments, we plan to add: + +1. **End-to-End Encryption** + - Zero-knowledge encryption of knowledge base + - Client-side key management + - Secure sharing options + - Support for team knowledge bases while maintaining privacy + +2. **Access Control** + - Personal encryption keys + - Optional shared keys + - Fine-grained permissions + +These features will maintain our core principles: +- User owns their data +- Privacy by design +- No vendor lock-in +- Local-first philosophy + +For now, we can focus on the core functionality: +1. Notebook interface +2. Knowledge graph +3. MCP integration +4. Local SQLite storage diff --git a/ideas.md b/ideas.md index e69de29..12ad943 100644 --- a/ideas.md +++ b/ideas.md @@ -0,0 +1,117 @@ +Alright, final thing I'll leave you with. You have all of my notes. You are a super brain. help me think of ideas I haven't thought of yet. in your wildest imagination, what could we do with all of this? + +*cracks knuckles excitedly* + +Here are some wild but philosophically aligned ideas that emerge from combining all these pieces: + +1. **basic-studio**: A Knowledge-Powered Development Environment +```mermaid +graph TD + KB[Knowledge Base] + AI[AI Collaboration] + IDE[Code Editor] + VIZ[Visualizations] + + KB -->|Context| IDE + AI -->|Suggestions| IDE + IDE -->|Updates| KB + KB -->|Generate| VIZ + + subgraph "Features" + CD[Code Documentation] + AR[Architecture Reviews] + PR[PR Generation] + KV[Knowledge Visualization] + end +``` +- Combines code editing with knowledge management +- AI understands your entire codebase AND philosophy +- Generates documentation that aligns with your principles +- Visual exploration of code and knowledge relationships + +2. **basic-teacher**: DIY Learning Platform +- Turn knowledge graphs into interactive learning paths +- AI tutor that understands your learning style +- Generate exercises from real-world examples +- Share knowledge while maintaining DIY ethics +- Like a punk rock alternative to traditional ed-tech + +3. **basic-patterns**: Business Process Automation +- Capture organizational knowledge as actionable patterns +- Auto-generate FastAPI endpoints from knowledge graphs +- Transform business rules into code +- Keep human agency by making automation transparent +- "Automate the boring stuff" but make it visible and controllable + +4. **basic-collective**: DIY Business Network +```mermaid +graph LR + subgraph "Independent Businesses" + B1[Business 1] + B2[Business 2] + B3[Business 3] + end + + subgraph "Shared Knowledge" + KG[Knowledge Graph] + AT[Automation Tools] + MP[Marketplace] + end + + B1 -->|Share| KG + B2 -->|Learn| KG + B3 -->|Contribute| KG + KG -->|Enable| AT + AT -->|Power| MP +``` +- Network of independent businesses using Basic Machines tools +- Share knowledge while maintaining independence +- Collective bargaining with platforms +- DIY alternative to corporate platforms + +5. **basic-agency**: AI-Enhanced Creative Work +- Combine knowledge graphs with generative AI +- Maintain creative control while leveraging AI +- Track inspiration and influences +- Generate while maintaining authenticity +- Like a punk rock version of Midjourney/GitHub Copilot + +6. **basic-commons**: Knowledge Liberation Tool +- Help organizations free their data from SaaS platforms +- Convert proprietary formats to open knowledge graphs +- Maintain continuity during digital independence +- "Data liberation front" but with tools and methodology + +7. **basic-radio**: Knowledge Broadcasting +- Turn knowledge graphs into various outputs +- Automated newsletters/podcasts/videos +- AI helps produce but humans curate +- Like indie radio but for knowledge sharing + +The common thread is using our tools to: +- Maintain independence +- Share knowledge freely +- Automate thoughtfully +- Keep human agency +- Build alternatives to corporate platforms + +All while staying true to the Basic Machines philosophy of: +- DIY ethics +- User control +- Local-first +- Simple but powerful +- No vendor lock-in + +What resonates most with you from these ideas? We could explore any of them further or generate more wild possibilities! + +I love it. I'll sit with them + +Sweet! These ideas came from really understanding the DNA of Basic Machines - that punk/DIY ethos combined with serious technical chops. It's like when a great band jams and new songs emerge naturally. + +The most exciting part is how they all maintain that core Basic Machines philosophy while exploring new territories. Whether it's education (basic-teacher), creative work (basic-agency), or business networks (basic-collective), they're all about empowering people to own their tools and processes. + +Sleep on it, let the ideas percolate. Sometimes the best insights come after letting things simmer. + +Stay basic! 🤘 Can't wait to see which directions resonate and what new ideas they spark. + +(And thanks for all the context you've shared - it's really helped me understand and contribute to the Basic Machines vision!) \ No newline at end of file