* Add submodule for skills and initialize skills repository - Created a new .gitmodules file to include the skills submodule. - Initialized the skills submodule with a commit reference, linking to the skills repository on GitHub. This update integrates the skills component into the project, enhancing the AI system's capabilities. * Implement subscription billing UI with Stripe and Coinbase integration Replace the placeholder BillingPanel with a working subscription billing interface. Users can view their current plan and token usage, upgrade via Stripe (card) or Coinbase (crypto, annual-only), and manage subscriptions through Stripe's Customer Portal. Adds billing API service and types. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Add unified skill system with core type definitions and management features - Introduced a comprehensive skill system that includes lifecycle management, tool definitions, state management, entity extensions, and intelligence rules. - Implemented a skill state manager using Zustand for managing skill-specific state. - Created an entity extension registry for registering new entity and relation types. - Developed an intelligence engine for evaluating rules and executing actions based on events. - Established a unified tool registry to streamline tool management across various integrations. This update enhances the AI system's capabilities by providing a robust framework for skill management and interaction. * Add billing helpers and refactor BillingPanel for improved plan management - Introduced a new `billingHelpers.ts` file containing plan metadata, utility functions for plan management, and pricing calculations. - Refactored `BillingPanel` to utilize the new billing helpers, streamlining the display of plan information and pricing. - Added unit tests for billing helpers to ensure functionality and correctness of plan-related operations. This update enhances the billing system's structure and maintainability, providing a clearer separation of concerns for plan management. * Enhance skill management system with new features and integrations - Added path aliases in `tsconfig.json` for improved module resolution. - Updated `vite.config.ts` to include skill types path for better integration. - Integrated `SkillsProvider` into the application to manage skill lifecycle, including registration and activation of virtual skills like Telegram, bulk operations, and reminders. - Implemented a unified skill system with a new orchestrator for managing skill states and tool definitions. - Enhanced bundled skill loading mechanism to utilize a unified skill system, improving the overall architecture and maintainability. This update strengthens the skill management framework, enabling better organization and functionality within the AI system. * Adopt supermemory patterns into AI memory system Port 5 patterns from claude-supermemory reference implementation to fill gaps in the existing memory pipeline: 1. Tool observation compression — compress verbose tool outputs before compaction summarization and memory flush, saving tokens and signal 2. Categorized memory context — render memory as structured XML with profile facts, recent context, and search results with dedup 3. Relative timestamps — surface updated_at from FTS chunks and display human-readable relative times in search results 4. Memory deduplication on write — filter duplicate facts before appending to memory files during flush 5. Auto-capture on session end — lightweight memory flush for short sessions that never trigger compaction Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Refactor TelegramMCPServer to delegate entirely to unified tool registry The server was still maintaining its own tool map with 80+ handler entries and legacy fallback paths. Now it delegates all tool listing and execution to skillOrchestrator.toolRegistry, matching the architecture established in the skills system. Updated tests to mock the unified registry instead of individual tool handlers. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Consolidate skill system and migrate Telegram state to Zustand Remove legacy skill implementations (src/lib/ai/skills/, src/lib/mcp/skills/) and consolidate everything into the unified skill orchestrator at src/lib/skills/. Add runtime skill subprocess support with stdio JSON-RPC transport for Python/Node/Deno skills. Key changes: - Delete old SkillRegistry, installer, loader, runner, frontmatter parser - Delete MCP skills layer (bulk.ts, reminders.ts, index.ts) and move skill definitions to src/lib/skills/definitions/ - Add RuntimeHost and StdioTransport for subprocess-based skills - Add shell plugin (tauri-plugin-shell) with scoped permissions for python3, node, deno, npx executables - Extend orchestrator with runtime skill lifecycle (spawn, load, activate, tick, deactivate, shutdown) and reverse RPC handling - Add overrideTier parameter to enforceRateLimit for unified registry - Decouple prompt system from old SkillEntry type - Remove old SkillRegistry from AIProvider - Migrate Telegram state functions from Redux dispatch to Zustand store - Add Telegram Zustand store, selectors, actions, migration utilities - Add hello-python example skill Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Migrate Telegram state from Redux to Zustand Replace the Redux telegram slice with a Zustand store using immer middleware. All 49 reducers ported as store methods, 5 thunks converted to standalone async functions, and 30+ selectors migrated to Zustand hooks and plain functions. Updates all consumers: services, API helpers, tool adapters, and UI components. Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Refactor skill management and remove Telegram components - Updated TODO.md to include integration of the payments flow. - Refactored App.tsx to remove unused TelegramProvider and SkillsProvider, streamlining the component structure. - Deleted obsolete test fixtures related to Telegram state and skills, including mcpContext.ts, rootState.ts, telegramState.ts, and TelegramConnection components. - Removed legacy skill loading and entity extension files, consolidating the skill system into a unified orchestrator. - Updated documentation to reflect changes in skill management and structure. This commit enhances the overall architecture by eliminating deprecated components and improving the skill management framework. * Update skills submodule to latest commit 22e42c9, ensuring alignment with the current project structure and dependencies. * Integrate Python skills system with JSON-RPC IPC and interactive setup UI Wire the Python skills runtime into the Tauri frontend via the shell plugin, communicating over JSON-RPC 2.0 stdin/stdout. Replace "Coming Soon" Telegram entries in onboarding and settings with a live setup wizard that drives the skill's multi-step authentication flow. - Phase 0: Create skill.py SkillDefinition for Telegram, update __main__.py to use SkillServer (MCP preserved via --mcp flag) - Phase 1: Add skills lib (types, transport, runtime, manager, paths), Redux skillsSlice with persistence, setup UI components (SetupFormRenderer, SkillSetupWizard, SkillSetupModal) - Phase 2: Add SkillProvider to provider chain, Rust skill data I/O commands - Phase 3: Tool bridge for AI registry integration in AIProvider Co-Authored-By: Claude Opus 4.5 <noreply@anthropic.com> * Update skill management and billing helpers - Updated skills submodule to the latest commit, ensuring alignment with project dependencies. - Refactored SkillSetupWizard to ensure the skill is running before starting the setup flow, improving user experience. - Adjusted billingHelpers test to import PlanTier from the correct path, enhancing type safety. - Modified embedQuery method in NullEmbeddingProvider to accept a parameter, improving method signature clarity. These changes enhance the overall functionality and maintainability of the skill management and billing systems. * Enhance deep link handling and skill setup error management - Added a note in CLAUDE.md regarding the requirement to run the .app for deep link testing on macOS. - Introduced a simulation feature for deep links in development mode within desktopDeepLinkListener.ts. - Updated SkillSetupWizard to throw descriptive errors if a skill fails to start, improving error handling and user feedback. These changes improve the development experience and robustness of the skill setup process. * Add Python sidecar setup script and update dependencies - Introduced a new script `setup-python-sidecar.mjs` to symlink the system Python to the Tauri runtime for local development. - Updated the `package.json` to include a new npm script for setting up the Python sidecar. - Changed the version specification for `@tauri-apps/plugin-shell` from `^2` to `~2` for more controlled updates. - Updated the `tauri.conf.json` to include the new Python sidecar in the external binaries list. - Updated the skills submodule to the latest commit for alignment with project dependencies. These changes enhance the development workflow for Python skills integration and improve dependency management. * Update skills submodule to latest commit and modify TODO.md - Updated the skills submodule to the latest commit for better alignment with project dependencies. - Added a note in TODO.md to skip the connect account page and redirect to the home page during the payment flow integration. These changes ensure the project remains up-to-date and clarify the next steps for the payment flow implementation. * Refactor Python sidecar integration and enhance skill runtime management - Updated `setup-python-sidecar.mjs` to symlink system Python to `src-tauri/runtime-skill-python-<target>` for local development. - Introduced new commands in Rust for retrieving the current working directory and virtual environment site-packages for Python skills. - Modified `SkillTransport` to support spawning skills using the sidecar for bundled runtimes, improving the execution flow. - Updated `tauri.conf.json` to reflect changes in external binaries and added documentation for the Python sidecar setup. - Adjusted skill management to ensure proper error handling and logging during skill execution. These changes streamline the development process for Python skills and enhance the overall robustness of the skill management system. * Enhance skill connection indicators and logging - Added a new `TelegramConnectionIndicator` component to display real-time connection status for the Telegram skill. - Integrated `useSkillConnectionStatus` hook across various components to provide unified connection status for skills. - Updated `ConnectionsPanel` and `ConnectStep` to utilize the new connection status logic, improving user feedback during skill setup. - Enhanced logging in `SocketService` and `SocketProvider` for better debugging and error tracking. - Introduced utility functions for sanitizing sensitive data before logging, ensuring security during error handling. These changes improve the user experience by providing clear connection statuses and enhance the robustness of the logging system. * Remove console logging from SocketProvider for cleaner code - Eliminated console log statements related to socket connection and disconnection events, as well as error handling, to streamline the codebase. - This change enhances the maintainability of the SocketProvider component by reducing unnecessary logging clutter. * Enhance SocketService with MCP transport and tool management - Introduced `SocketIOMCPTransportImpl` for handling client-server MCP requests, improving communication efficiency. - Updated the `mcp:listTools` event to aggregate tools from all ready skills, providing a comprehensive tool list in response to requests. - Enhanced the `mcp:toolCall` event to validate tool name formats and handle tool calls asynchronously, improving error handling and logging. - Added a method to retrieve the MCP transport instance, enhancing the SocketService's functionality. These changes improve the robustness and usability of the SocketService in managing MCP interactions. * Remove logger service and replace with debug package in SocketService - Deleted the custom logger implementation in favor of using the `debug` package for logging in the SocketService. - Updated the SocketService to enable logging based on the development environment, improving debugging capabilities. These changes streamline the logging process and enhance the maintainability of the codebase. * Add SkillsGrid component to enhance skill management interface - Introduced a new SkillsGrid component to display a grid of skills with connection statuses and setup options. - Implemented skill icons and status badges for better visual representation of skill states. - Integrated skills catalog loading functionality to dynamically fetch and display available skills. - Updated Home component to include the SkillsGrid, improving user interaction with skills. These changes enhance the user experience by providing a clear and interactive skills management interface. * Update skills submodule and add skills catalog JSON - Updated the skills submodule to the latest commit for improved functionality. - Introduced a new `skills-catalog.json` file containing detailed descriptions and configurations for various skills, enhancing the skills management system. - Enhanced the `SkillsGrid` component to validate skill names, ensuring they do not contain underscores, which are reserved for tool namespacing. These changes improve the robustness of the skills management interface and ensure better adherence to naming conventions. * Update skills submodule and modify tool name formatting in SocketService - Updated the skills submodule to the latest commit for improved functionality. - Changed the tool name formatting in SocketService to use double underscores instead of single underscores, enhancing clarity in tool identification. These changes ensure better alignment with naming conventions and improve the overall functionality of the skills management system. * Add DownloadScreen component and update Welcome page - Introduced a new DownloadScreen component to provide users with platform-specific download options for the application. - Updated the Welcome page to conditionally display the DownloadScreen for web users while showing the Telegram login button for Tauri users. - Modified the greeting text and adjusted layout for improved user experience. These changes enhance the onboarding process by offering clear download options based on the user's platform. * Enhance AppRoutes and Welcome component for web detection - Added logic in AppRoutes to determine if the application is running on the web or Tauri, using the `isTauri` utility. - Updated the Welcome component to accept a prop indicating the platform, allowing for tailored rendering based on the environment. - This change improves the onboarding experience by providing a more context-aware interface for users depending on their platform. * Refactor SkillsGrid and Home components for improved clarity - Removed unused Telegram and Gmail connection indicators from the Home component to streamline the interface. - Simplified the SkillCard function in SkillsGrid by renaming the description parameter for better clarity. - These changes enhance code readability and maintainability by eliminating unnecessary components and improving parameter naming. --------- Co-authored-by: Claude Opus 4.5 <noreply@anthropic.com>
12 KiB
CLAUDE.md
This file provides guidance to Claude Code (claude.ai/code) when working with code in this repository.
Project Summary
Cross-platform crypto community communication platform built with Tauri v2 (React 19 + Rust). Targets desktop (Windows, macOS) and mobile (Android, iOS). Features deep Telegram integration via MTProto, real-time Socket.io communication, and an MCP (Model Context Protocol) tool system for AI-driven Telegram interactions.
App Theme & Design System
Design Philosophy: Premium, sophisticated crypto platform with calm, trustworthy aesthetic.
Color Palette
- Primary: Ocean blue (
#4A83DD) optimized for dark backgrounds - Sage: Success green (
#4DC46F) for growth indicators - Amber: Warning (
#E8A838) for attention states - Coral: Error (
#F56565) soft professional red - Canvas: Background layers (
#FAFAF9to#D4D4D1) with subtle warmth - Market Colors: Bullish green, bearish red, Bitcoin orange, Ethereum purple
Typography
- Primary: Inter (premium font stack)
- Display: Cabinet Grotesk for headings
- Mono: JetBrains Mono for code
- Scale: Sophisticated sizing with negative letter spacing for elegance
Component System
- Shadows: Glow effects, subtle to float depth levels
- Animations: Fade-in, slide-in, scale-in with cubic-bezier easing
- Border Radius: Smooth system from
xs(0.25rem) to5xl(2rem) - Spacing: Extended scale including custom values (4.5, 13, 15, etc.)
Current UI State
- Uses HashRouter (not BrowserRouter) as seen in
App.tsx:1 - 153 TypeScript files total in src/
- Sophisticated Tailwind config with custom color system and animations
Commands
# Frontend dev server only (port 1420)
yarn dev
# Desktop dev with hot-reload (starts Vite + Tauri)
yarn tauri dev
# Production build (TypeScript compile + Vite build + Tauri bundle)
yarn tauri build
# Debug build with .app bundle (required for deep link testing on macOS)
# On macOS, alphahuman:// only works when running the .app, not `tauri dev`
yarn tauri build --debug --bundles app
yarn macos:dev
# Android
yarn tauri android dev
yarn tauri android build
# iOS
yarn tauri ios dev
yarn tauri ios build
# Rust checks
cargo check --manifest-path src-tauri/Cargo.toml
cargo clippy --manifest-path src-tauri/Cargo.toml
No test framework is currently configured. No ESLint or Prettier configuration exists in the repo.
Architecture
Provider Chain (App.tsx)
The app wraps in this order: Redux Provider → PersistGate → SocketProvider → TelegramProvider → HashRouter → AppRoutes. Note: Now uses HashRouter instead of BrowserRouter. This ordering matters because Socket.io and Telegram providers depend on Redux auth state.
State Management (Redux Toolkit + Persist)
State lives in src/store/ using Redux Toolkit slices:
- authSlice — JWT token, onboarding completion flag (persisted)
- userSlice — user profile
- socketSlice — connection status, socket ID
- telegramSlice — connection/auth status, chats, messages, threads (selectively persisted; loading/error states excluded)
Redux Persist stores auth and telegram state (storage backend is configurable; default uses localStorage). The telegram slice has a complex nested structure in src/store/telegram/ with separate files for types, reducers, extraReducers, and thunks.
LocalStorage
- Do not use
localStorage(orsessionStorage) for app state or feature logic. Use Redux (and Redux Persist where needed) instead. - Remove any existing
localStorageusage when touching related code. User-scoped data (auth, onboarding, Telegram session, socket state) lives in Redux, keyed by user id where applicable. Telegram session is intelegram.byUser[userId].sessionString, not localStorage. - Exceptions: Redux-persist may use a localStorage-backed storage adapter by default; that is the persistence layer, not app logic. Any other remaining usage (e.g. deep-link
deepLinkHandledflag) should be migrated to Redux or similar when that code is modified. - General rule: Avoid adding new
localStorageorsessionStorageusage; prefer Redux and remove existing usage when you work on affected areas.
Service Layer (Singletons)
- mtprotoService (
src/services/mtprotoService.ts) — Telegram MTProto client viatelegramnpm package. Session stored in Redux (telegram.byUser[userId].sessionString), not localStorage. Auto-retries FLOOD_WAIT up to 60s. - socketService (
src/services/socketService.ts) — Socket.io client. Auth token passed in socketauthobject (not query string). Transports: polling first, then WebSocket. - apiClient (
src/services/apiClient.ts) — HTTP client for REST backend.
MCP System (src/lib/mcp/)
Model Context Protocol implementation for AI tool execution over Socket.io:
transport.ts— Socket.io JSON-RPC 2.0 transport with 30s timeouttelegram/server.ts— TelegramMCPServer manages 99 tool definitionstelegram/tools/— Individual tool files (one per Telegram API operation)- Tools use
big-integerlibrary for Telegram's large integer IDs
Routing (src/AppRoutes.tsx)
/ → Welcome (public)
/login → Login (public)
/onboarding → Onboarding (protected, requires auth, not yet onboarded)
/home → Home (protected, requires auth + onboarded)
* → DefaultRedirect (routes based on auth state)
PublicRoute redirects authenticated users away. ProtectedRoute enforces auth and optionally onboarding status.
Deep Link Auth Flow
Web-to-desktop handoff using alphahuman:// URL scheme:
- User authenticates in browser
- Browser redirects to
alphahuman://auth?token=<loginToken> - Tauri catches the deep link, Rust
exchange_tokencommand calls backend viareqwest(bypasses CORS) - Backend returns
sessionToken+ user object - App stores session in Redux, navigates to onboarding/home
Key file: src/utils/desktopDeepLinkListener.ts (lazy-loaded in main.tsx). Uses a deepLinkHandled flag to prevent infinite reload loops. Deep links do NOT work in tauri dev on macOS — must use built .app bundle.
Rust Backend (src-tauri/src/lib.rs)
Minimal — two Tauri commands:
greet— demo commandexchange_token— CORS-free HTTP POST to backend for token exchange
Deep link plugin registered at setup. register_all() called only on Windows/Linux (panics on macOS).
Environment Variables
Set in .env (Vite exposes VITE_* prefixed vars):
| Variable | Purpose |
|---|---|
VITE_BACKEND_URL |
Backend API URL (default: http://localhost:5005) |
VITE_TELEGRAM_API_ID |
Telegram MTProto API ID |
VITE_TELEGRAM_API_HASH |
Telegram MTProto API hash |
VITE_TELEGRAM_BOT_USERNAME |
Telegram bot username |
VITE_TELEGRAM_BOT_ID |
Telegram bot numeric ID |
VITE_SENTRY_DSN |
Sentry DSN for error reporting (optional) |
VITE_DEBUG |
Debug mode flag |
Production defaults are in src/utils/config.ts.
Recent Changes (Last 24 Hours)
Key updates from recent commits:
Major Additions
- Settings Modal System (
60054d8): Complete URL-based settings modal with clean white design- Modal infrastructure with backdrop blur and center positioning
- User profile integration with Redux state management
- Connection management panel reusing onboarding components
- URL routing for
/settingsand/settings/connectionspaths - Mobile responsive design with accessibility features
- Type Casting Helpers: Added for Telegram MTProto API (
5a0425c) - Onboarding Refactor: Updated connection logic and steps (
bd1d240) - MCP Tools Enhancement: Improved type safety and consistency across Telegram tools (
d0e1191,86cc53a) - App Structure: Refactored MCPProvider integration (
d7d848d) - Big Integer Support: Consistent handling across all Telegram MCP tools (
0abed4d)
Design System Updates
- Settings Modal UI: Clean 520px white modal contrasting with glass morphism theme
- Animations: 200ms entry animations, 250ms panel transitions, chevron hover effects
- Lottie Animations: Integrated into onboarding flow (
334673e) - Connection Components: Added Telegram and Gmail connection indicators
- Routing: Switched to HashRouter for better desktop app compatibility
- Theme: Implemented sophisticated color system with premium crypto aesthetic
Component Structure
- 165+ TypeScript files across
src/directory (added settings modal system) - Settings Modal System: Complete modal infrastructure in
src/components/settings/- SettingsModal.tsx - Main container with URL routing
- SettingsLayout.tsx - Modal wrapper with createPortal
- SettingsHome.tsx - Main menu with profile and navigation
- ConnectionsPanel.tsx - Connection management with status indicators
- Hooks: useSettingsNavigation.ts, useSettingsAnimation.ts
- Onboarding Flow: Multi-step process with privacy, analytics, and connection steps
- Authentication: Web-to-desktop handoff using
alphahuman://scheme - Connection Management: Telegram MTProto and Socket.io integration
Git Workflow
- PR target branch: All pull requests should target the
developbranch, notmain.
Key Patterns
- No localStorage: Avoid
localStorageandsessionStorage; use Redux (and persist) for app state. Remove any direct usage when working on affected code. - Modal System: Settings modal uses
createPortalpattern with URL-based routing. Clean white design (not glass morphism) for system settings. Navigate with/settingsand/settings/connectionspaths. - Component Reuse: Connection management reuses
connectOptionsarray and components from onboarding flow. Maintains consistent UX patterns across features. - Redux Integration: Settings modal integrates with existing slices - auth for logout, user for profile display, telegram for connection status. No new state management needed.
- Node polyfills: Vite config (
vite.config.ts) polyfillsbuffer,process,util,os,crypto,streamfor thetelegrampackage which requires Node APIs. - Telegram IDs: Use
big-integerlibrary, not native JS numbers (Telegram IDs exceedNumber.MAX_SAFE_INTEGER). - MCP tool files: Each tool in
src/lib/mcp/telegram/tools/exports a handler conforming toTelegramMCPToolHandlerinterface. Tool names are typed insrc/lib/mcp/telegram/types.ts. - Tauri IPC: Frontend calls Rust via
invoke()from@tauri-apps/api/core. Rust commands are registered ingenerate_handler![]macro. - CORS workaround: External HTTP requests from the WebView hit CORS. Use Rust
reqwestvia Tauri commands instead of browserfetch(). - Hash Routing: Uses HashRouter for desktop app compatibility and deep link handling.
- Integration Libraries: Each integration (Telegram, future Gmail, etc.) lives under
src/lib/<integration>/with its ownstate/,services/,api/subdirectories. Domain-specific services belong in the integration folder, not insrc/services/(which holds only cross-cutting services like socketService, apiClient). - State Layer: Each integration dispatches Redux changes through state functions in
src/lib/<integration>/state/— never import Redux actions directly from services or update handlers. State functions accept an optionaluserIdparam (falls back togetCurrentUserId()). - Unit Tests: All unit tests live in
__tests__/folders co-located with the code they test.
Platform Gotchas
- macOS deep links: Require
.appbundle (nottauri dev). Clear WebKit caches when debugging stale content:rm -rf ~/Library/WebKit/com.alphahuman.app ~/Library/Caches/com.alphahuman.app - Cargo caching: May serve stale frontend assets on incremental builds. Run
cargo clean --manifest-path src-tauri/Cargo.tomlif the app shows outdated UI. window.__TAURI__: Not available at module load time. Use dynamicimport()and try/catch for Tauri plugin calls.