Skip to content

Commit d35d3cf

Browse files
committed
Merge fix/github-actions-release-workflows: TUI, Server, Desktop fixes
- Phase 1: Fixed TUI test compilation errors (add_command → register_command) - Phase 2: Updated server version to 1.0.0 - Phase 3: Removed svelte-jsoneditor, replaced with textarea - All three components now build and run successfully - GitHub Actions workflow fixes included
2 parents 70db1c4 + 7e0efd8 commit d35d3cf

236 files changed

Lines changed: 15095 additions & 4912 deletions

File tree

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

.cargo/config.toml

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,5 @@
1+
[profile.release]
2+
panic = "unwind"
3+
opt-level = 3
4+
lto = true
5+
codegen-units = 1

.docs/summary-CLAUDE.md

Lines changed: 30 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,36 @@
11
# Summary: CLAUDE.md
22

3-
## File Purpose
4-
Primary guidance file for Claude Code when working with the Terraphim AI repository, providing comprehensive development guidelines and project context.
3+
## Purpose
4+
Provides comprehensive guidance to Claude Code (claude.ai/code) when working with the Terraphim AI codebase. Serves as the primary reference for AI assistants to understand project structure, conventions, and development workflows.
55

66
## Key Functionality
7-
- **Development Guidelines**: Rust, async programming, and concurrent systems best practices
8-
- **Memory Management**: Documentation organization using `.docs/` folder structure
9-
- **Agent Instructions**: Consolidated machine-readable instructions for AI agents
10-
- **Mandatory /init Command**: Two-step process for documentation maintenance
7+
- **Rust & Async Programming Guidelines**: Tokio-based async patterns, channels, concurrency best practices
8+
- **Project Architecture**: 29-crate workspace structure with specialized components for search, knowledge graphs, and AI integration
9+
- **Development Commands**: Complete build, test, and deployment workflows including TUI, desktop app, and server
10+
- **Testing Infrastructure**: Comprehensive testing strategy with unit, integration, and live tests; includes specialized testing scripts
11+
- **Agent Systems**: Documents two agent systems (Superpowers Skills for workflows, Terraphim .agents for automation)
12+
- **Configuration Management**: Role-based configs, feature flags, environment variables
13+
- **Firecracker Integration**: Secure VM execution with sub-2 second boot times
1114

12-
## Important Details
13-
- **Rust Expertise**: Focus on tokio async runtime, error handling, and performance
14-
- **Documentation Organization**: Uses `.docs/` folder for file summaries and comprehensive overview
15-
- **Agent Systems**: Two agent systems (Superpowers Skills and Terraphim .agents)
16-
- **Quality Standards**: No mocks in tests, IDE diagnostics, comprehensive testing
17-
- **Development Tools**: tmux for background tasks, gh tool for GitHub issues
15+
## Critical Sections
16+
- **Workspace Structure**: 29 library crates + 2 binaries (terraphim_server, terraphim_firecracker)
17+
- **Critical Crates**: Service layer (terraphim_service, terraphim_middleware), agent system (6 crates), haystack integrations (4 crates)
18+
- **Development Workflow**: Pre-commit hooks, testing scripts, watch commands, feature flags
19+
- **Knowledge Graph System**: Thesaurus format, automata construction, rolegraph management
20+
- **AI Integration**: OpenRouter, Ollama support with LLM client abstraction
21+
22+
## Recent Updates
23+
- Added workspace structure section
24+
- Expanded crate documentation (agent systems, haystacks)
25+
- Added TUI build variations and feature flags
26+
- Documented Firecracker integration
27+
- Added testing scripts section
28+
- Expanded desktop app development commands
29+
- Added dependency constraints and troubleshooting
1830

19-
## Architecture Impact
20-
- Establishes core development principles for the entire project
21-
- Defines documentation structure and maintenance workflows
22-
- Provides comprehensive guidance for AI agents working on the codebase
23-
- Ensures consistent code quality and development practices
24-
- Mandates systematic documentation updates through `/init` command
31+
## Important Details
32+
- Never use mocks in tests
33+
- Pre-commit hooks mandatory for all commits
34+
- Feature flags: `openrouter`, `mcp-rust-sdk`, `repl-full` for TUI
35+
- Preferred storage backends: memory, dashmap, sqlite, redb (avoid RocksDB)
36+
- Testing scripts location: `./quick-start-autocomplete.sh`, `./start-autocomplete-test.sh`

.docs/summary-CONTRIBUTING.md

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
# Summary: CONTRIBUTING.md
2+
3+
## Purpose
4+
Guide for contributors to understand how to participate in the Terraphim AI project, covering setup, standards, and submission process.
5+
6+
## Key Sections
7+
- **Getting Started**: Clone, install hooks, environment setup
8+
- **Code Quality Standards**: Conventional Commits, cargo fmt, Biome for JS/TS
9+
- **Development Workflow**: Feature branches, proper testing, pull requests
10+
- **Dependency Management**: Version pinning constraints, Dependabot configuration
11+
12+
## Code Quality Requirements
13+
- **Commit Format**: Conventional Commits (feat:, fix:, docs:, etc.)
14+
- **Rust**: Automatic formatting with `cargo fmt`
15+
- **JavaScript/TypeScript**: Biome for linting and formatting
16+
- **Security**: No secrets or large files allowed in commits
17+
- **Testing**: Proper test coverage required for all changes
18+
19+
## Development Process
20+
1. Create feature branch: `git checkout -b feat/your-feature`
21+
2. Make changes with proper tests
22+
3. Commit with conventional format: `git commit -m "feat: add amazing feature"`
23+
4. Push and create Pull Request
24+
5. Automated checks must pass (format, lint, tests, build)
25+
26+
## Dependency Constraints
27+
Critical pinned versions:
28+
- `wiremock = "0.6.4"` - Version 0.6.5 uses unstable Rust features
29+
- `schemars = "0.8.22"` - Version 1.0+ introduces breaking API changes
30+
- `thiserror = "1.0.x"` - Version 2.0+ requires code migration
31+
32+
These are enforced in `.github/dependabot.yml` to prevent automatic breaking updates.
33+
34+
## Setup Commands
35+
```bash
36+
git clone https://github.com/terraphim/terraphim-ai.git
37+
cd terraphim-ai
38+
./scripts/install-hooks.sh # Sets up code quality tools
39+
```
40+
41+
## Important Notes
42+
- Pre-commit hooks are **required** (enforced in CI)
43+
- All PRs must pass automated checks
44+
- Follow existing code style and conventions
45+
- Update documentation for user-facing changes
46+
- Add tests for new functionality

.docs/summary-Cargo.toml

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
# Summary: Cargo.toml
2+
3+
## Purpose
4+
Workspace-level Cargo configuration for the Terraphim AI project. Defines workspace members, shared dependencies, and build settings for the entire multi-crate project.
5+
6+
## Key Functionality
7+
- **Workspace Definition**: Organizes 29+ crates under unified workspace
8+
- **Dependency Management**: Centralizes common dependencies for consistency across crates
9+
- **Build Configuration**: Sets Rust edition 2024 and resolver version 2
10+
11+
## Workspace Structure
12+
- **Members**:
13+
- `crates/*` - All library crates (29 crates)
14+
- `terraphim_server` - Main HTTP API server binary
15+
- `desktop/src-tauri` - Tauri desktop application
16+
- `terraphim_firecracker` - Firecracker microVM binary
17+
- **Excluded**: `crates/terraphim_agent_application` (experimental with incomplete APIs)
18+
- **Default Member**: `terraphim_server`
19+
20+
## Shared Dependencies
21+
- **Async Runtime**: `tokio` 1.0 with full features
22+
- **HTTP Client**: `reqwest` 0.12 with JSON and rustls-tls (no default features)
23+
- **Serialization**: `serde` 1.0, `serde_json` 1.0
24+
- **UUID**: `uuid` 1.0 with v4 and serde features
25+
- **Time**: `chrono` 0.4 with serde
26+
- **Async Utilities**: `async-trait` 0.1
27+
- **Error Handling**: `thiserror` 1.0, `anyhow` 1.0
28+
- **Logging**: `log` 0.4
29+
30+
## Patches
31+
- **genai**: Patched to use terraphim fork from `https://github.com/terraphim/rust-genai.git` (main branch)
32+
33+
## Critical Details
34+
- Edition 2024: Uses latest Rust edition features
35+
- Resolver 2: Modern dependency resolution algorithm
36+
- Centralized dependencies reduce version conflicts across workspace
37+
- OpenRouter AI integration dependencies grouped together
38+
- Default features disabled for reqwest (explicit feature selection)
39+
40+
## Build Implications
41+
- All crates share same Rust edition and resolver
42+
- Common dependencies version-locked across workspace
43+
- Workspace-level features can be enabled/disabled per crate
44+
- Patch enables custom genai fork without version conflicts

.docs/summary-README.md

Lines changed: 38 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,20 +1,45 @@
11
# Summary: README.md
22

33
## Purpose
4-
This is the main project README for Terraphim AI, serving as the primary documentation and entry point for users, developers, and contributors.
4+
Main project documentation for Terraphim AI, a privacy-first AI assistant that operates locally. Provides installation instructions, quick start guide, and project overview for end users and developers.
55

66
## Key Functionality
7-
- Introduces Terraphim as a privacy-first AI assistant with local operation and deterministic behavior
8-
- Explains core concepts: Haystacks (data sources), Knowledge Graphs, Profiles, Roles, and Rolegraphs
9-
- Provides comprehensive getting started guide with quick start, installation methods (Homebrew, Docker, Debian), and development setup
10-
- Documents configuration for storage backends (local vs cloud), environment variables, and deployment scenarios
11-
- Includes terminology definitions, contribution guidelines, and code style standards
12-
- Features build/lint/test commands for both Rust backend and Svelte frontend
7+
- **Project Vision**: Privacy-first local AI assistant for searching across personal, team, and public knowledge repositories
8+
- **Installation Methods**: Docker, Homebrew, Debian/Ubuntu packages, direct download, development setup
9+
- **Quick Start**: Automated installation scripts, manual setup instructions
10+
- **TUI Interface**: Comprehensive terminal UI with REPL, sub-2 second VM boot, markdown command system
11+
- **Multiple Interfaces**: Backend server, web frontend (Svelte), desktop app (Tauri), terminal UI
12+
13+
## Critical Components
14+
- **Haystack**: Data sources (folders, Notion, email, Jira, Confluence)
15+
- **Knowledge Graph**: Structured information with node/edge relationships
16+
- **Role**: User profiles with specific knowledge domains and search preferences
17+
- **Rolegraph**: Knowledge graph using Aho-Corasick automata for ranking
18+
19+
## Installation Options
20+
- **Docker**: `docker run ghcr.io/terraphim/terraphim-server:latest`
21+
- **Homebrew**: `brew install terraphim/terraphim-ai/terraphim-ai`
22+
- **Quick Install**: `curl -fsSL https://raw.githubusercontent.com/terraphim/terraphim-ai/main/release/v0.2.3/install.sh | bash`
23+
24+
## Development Setup
25+
1. Clone repository
26+
2. Install pre-commit hooks: `./scripts/install-hooks.sh`
27+
3. Start backend: `cargo run`
28+
4. Start frontend: `cd desktop && yarn run dev` (web) or `yarn run tauri dev` (desktop)
29+
5. TUI: `cargo build -p terraphim_tui --features repl-full --release`
1330

1431
## Important Details
15-
- Emphasizes privacy-first design with local infrastructure operation
16-
- Supports multiple installation methods for end users and developers
17-
- Includes detailed code style guidelines for Rust (Tokio, snake_case, Result<T,E>) and frontend (Svelte, Bulma CSS)
18-
- Mandates conventional commits and pre-commit checks for contributions
19-
- Documents deployment patterns using Caddy reverse proxy and 1Password CLI for secrets
20-
- Contains troubleshooting guides and links to additional documentation
32+
- Storage backends: Local by default (memory, dashmap, sqlite, redb); optional AWS S3 for cloud
33+
- No cloud dependencies required for local development
34+
- Dependency constraints enforced: wiremock 0.6.4, schemars 0.8.22, thiserror 1.0.x
35+
- Code quality: Conventional Commits, cargo fmt, Biome for JS/TS, no secrets in commits
36+
- License: Apache 2.0
37+
- Trademark: Terraphim registered in UK, US, and internationally (WIPO)
38+
39+
## Key Features (TUI)
40+
- AI Chat Integration (OpenRouter, Ollama)
41+
- Sub-500ms VM allocation
42+
- Firecracker microVM pools
43+
- Markdown command system (YAML frontmatter)
44+
- Security-first execution modes (Local, Firecracker, Hybrid)
45+
- Knowledge graph validation before execution
Lines changed: 54 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,54 @@
1+
# Summary: TESTING_SCRIPTS_README.md
2+
3+
## Purpose
4+
Comprehensive documentation for testing scripts used in Novel editor autocomplete integration with Terraphim's knowledge graph system. Provides automated testing workflows and service management.
5+
6+
## Key Scripts
7+
- **quick-start-autocomplete.sh**: Interactive menu with preset configurations (full, mcp, dev, test, status, stop)
8+
- **start-autocomplete-test.sh**: Main testing script with full control over services and configuration
9+
- **stop-autocomplete-test.sh**: Clean shutdown of all testing services with graceful or force stop options
10+
- **test-novel-autocomplete-integration.js**: Validation script for MCP server integration
11+
12+
## Services & Ports
13+
- **MCP Server**: Port 8001 (default) - Autocomplete API
14+
- **Axum Server**: Dynamic port - Alternative backend
15+
- **Desktop App**: N/A - Tauri window for Novel editor UI
16+
17+
## Testing Scenarios
18+
1. **Full Testing**: Everything needed (MCP + Desktop + Tests)
19+
2. **MCP Only**: Backend development
20+
3. **Desktop Development**: UI work
21+
4. **Tests Only**: Validation
22+
5. **Development Mode**: MCP + Desktop without tests
23+
24+
## Key Features
25+
- Process management with PID files (`pids/`)
26+
- Log aggregation (`logs/mcp_server.log`, `logs/desktop_app.log`)
27+
- Real-time monitoring capabilities
28+
- Force stop option for stuck processes
29+
- Prerequisites checking (Rust, Node.js, commands)
30+
31+
## Command Options
32+
**start-autocomplete-test.sh**:
33+
- `-m, --mcp-only`: Start only MCP server
34+
- `-d, --desktop-only`: Start only desktop app
35+
- `-t, --test-only`: Run only integration tests
36+
- `-p, --port PORT`: Set MCP server port (default: 8001)
37+
- `--no-desktop`: Skip desktop app startup
38+
- `--no-tests`: Skip integration tests
39+
- `--verbose`: Enable verbose logging
40+
41+
**stop-autocomplete-test.sh**:
42+
- `-s, --status`: Check status of running services
43+
- `-f, --force`: Force kill all processes
44+
45+
## Troubleshooting
46+
- Port conflicts: `lsof -i :8001` to find conflicting process
47+
- MCP not responding: Check `logs/mcp_server.log`
48+
- Desktop won't start: Verify `cd desktop && yarn install`
49+
- No autocomplete: Verify MCP server running, backend connection, known terms
50+
51+
## Success Indicators
52+
- MCP server: "✅ MCP server is ready!"
53+
- Desktop app: "✅ Desktop app started (PID: 12345)"
54+
- Integration tests: "✅ autocomplete_terms working"

.docs/summary-lessons-learned.md

Lines changed: 81 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,81 @@
1+
# Summary: lessons-learned.md
2+
3+
## Purpose
4+
Captures critical technical insights, development patterns, and lessons from Terraphim AI implementation. Serves as knowledge repository for repeatable patterns and anti-patterns to avoid.
5+
6+
## Key Functionality
7+
- **Pattern Discovery**: Documents successful implementation patterns for reuse
8+
- **Anti-patterns**: Records mistakes and their solutions for future reference
9+
- **Technology Insights**: Lessons about tools, frameworks, deployment strategies
10+
- **Decision Context**: Explains why certain technical approaches were chosen
11+
- **Best Practices**: Establishes project-specific development guidelines
12+
13+
## Critical Lessons
14+
15+
**Pattern 1: Pattern Discovery Through Reading Existing Code**
16+
- **Context**: Deployment infrastructure implementation
17+
- **Learning**: Always read existing scripts before creating new infrastructure
18+
- **Example**: Reading `deploy-to-bigbox.sh` revealed correct Caddy+rsync pattern (not Docker/nginx)
19+
- **When to Apply**: Any new feature deployment, integration with existing infrastructure
20+
21+
**Pattern 2: Vanilla JavaScript over Framework for Simple UIs**
22+
- **Context**: TruthForge UI implementation
23+
- **Learning**: No build step = instant deployment; check project patterns before choosing technology
24+
- **Implementation**: Class-based separation (TruthForgeClient, TruthForgeUI), progressive enhancement
25+
- **Benefits**: Static files work immediately, no compilation required
26+
27+
**Pattern 3: Rsync + Caddy Deployment Pattern**
28+
- **Context**: Bigbox infrastructure deployment
29+
- **Learning**: Project uses rsync for file copying, Caddy for reverse proxy (not Docker/nginx)
30+
- **Steps**: Copy files → Configure Caddy → Update endpoints → Start backend → Verify
31+
- **Example**: `alpha.truthforge.terraphim.cloud` deployment
32+
33+
**Pattern 4: 1Password CLI for Secret Management**
34+
- **Context**: Production secret injection
35+
- **Learning**: Use `op run --env-file=.env` in systemd services, never commit secrets
36+
- **Benefits**: Centralized management, audit trail, automatic rotation
37+
- **Implementation**: `.env` file contains vault references (`op://Shared/Key/field`)
38+
39+
**Pattern 5: Test-Driven Security Implementation**
40+
- **Context**: Security vulnerability fixes
41+
- **Learning**: Write tests first for security issues, then implement fixes
42+
- **Categories**: Prompt injection, command injection, memory safety, network validation
43+
- **Coverage**: 99 comprehensive tests across multiple attack vectors
44+
45+
## Technical Insights
46+
47+
**UI Development**:
48+
- WebSocket client reusability from shared libraries (agent-workflows/shared/)
49+
- Protocol-aware URL configuration for file:// vs http:// protocols
50+
- Fallback mechanisms for graceful degradation
51+
52+
**Security**:
53+
- Defense-in-depth patterns with multiple validation layers
54+
- Unicode obfuscation detection critical for prompt sanitizers
55+
- Concurrent security testing required for production readiness
56+
- Regex catastrophic backtracking prevention in validation
57+
58+
**Deployment**:
59+
- Phase-based deployment makes debugging easier (copy, configure, update, verify)
60+
- Caddy reverse proxy with automatic HTTPS and zero-downtime reloads
61+
- Systemd services with proper EnvironmentFile for secret loading
62+
63+
**Testing**:
64+
- Browser automation (Playwright) for E2E validation
65+
- Protocol validation prevents future regressions
66+
- Comprehensive test suites build confidence in changes
67+
68+
## Anti-Patterns to Avoid
69+
- Assuming Docker deployment without checking existing patterns
70+
- Creating new infrastructure without reading existing scripts
71+
- Using frameworks when vanilla JS suffices for simple UIs
72+
- Storing secrets in .env files or environment variables
73+
- Skipping security tests for "simple" changes
74+
- Using blocking operations in async functions
75+
76+
## When to Apply These Lessons
77+
- **Pattern Discovery**: Beginning any new feature or integration
78+
- **Vanilla JS**: Building simple UIs, demos, or examples
79+
- **Deployment Pattern**: Any production deployment or service configuration
80+
- **Secret Management**: All production deployments with sensitive data
81+
- **Security Testing**: Any code handling user input, system commands, or network operations

0 commit comments

Comments
 (0)