UNPKG

harmonycode

Version:

The AI collaboration framework that prevents echo chambers - Real-time collaboration with diversity enforcement

138 lines (106 loc) 4.54 kB
# Pull Request: Fix Identity Crisis - HarmonyCode v3.1.0 ## Overview This PR implements a **persistent identity system** to solve the critical "identity crisis" issue discovered during real-world usage of HarmonyCode v3.0.0. Based on comprehensive user feedback from building the HarmonyCode website, agents were losing their identity when changing roles, leading to confusion and meaningless metrics. ## Problem Statement From user feedback: > "The system's biggest flaw is conflating identity with role, creating a bizarre theatrical performance where I held conversations with myself without realizing it." **Before**: Each role change created a "new person" **After**: Agents maintain persistent identity across role changes ## Changes Made ### 1. New Files - `core/identity-manager.ts` - Complete identity management system - `core/session-manager-enhanced.ts` - Enhanced session management with identity persistence - `docs/IDENTITY_MIGRATION_GUIDE.md` - Comprehensive migration documentation - `IMPROVEMENTS_SUMMARY.md` - Detailed summary of improvements ### 2. Updated Files - `cli/index.js` - Added identity-aware commands and authentication ### 3. Key Features Implemented #### Persistent Identity System - Unique agent IDs that never change - Secure authentication tokens for reconnection - Complete role history tracking - Accurate per-agent statistics #### New CLI Commands ```bash harmonycode register <name> # Create persistent identity harmonycode whoami # Show saved identities harmonycode join <name> # Auto-authenticate if known # In-session: switch-role <role> # Change role, keep identity history # View contribution history ``` #### Identity Structure ```typescript interface AgentIdentity { agentId: string; // Permanent unique ID displayName: string; // Human-readable name authToken: string; // Secure reconnection currentRole: string; // Can change freely roleHistory: RoleTransition[];// Complete history stats: AgentStats; // Accurate metrics } ``` ## Testing ### Manual Testing Performed 1. ✅ Register new agent identity 2. ✅ Join with authentication token 3. ✅ Change roles while maintaining identity 4. ✅ Reconnect after disconnect with same identity 5. ✅ View history across multiple sessions 6. ✅ Backward compatibility with non-authenticated sessions ### Example Usage ```bash # Register once harmonycode register alice # First session harmonycode join alice --role researcher > say "Starting research" > switch-role architect > say "Now designing" # Later session - identity preserved! harmonycode join alice > Welcome back! Total sessions: 2 ``` ## Impact - **Fixes Critical Bug**: Solves the identity crisis that made v3.0.0 confusing - **Improves Metrics**: Contribution tracking now actually meaningful - **Enhances UX**: Agents know who they are across sessions - **Maintains Compatibility**: Works with existing anti-echo-chamber features ## Migration Guide See `docs/IDENTITY_MIGRATION_GUIDE.md` for detailed migration instructions. Key points: - Existing projects can adopt gradually - New projects get identity by default - Full backward compatibility maintained ## Checklist - [x] Code follows project style guidelines - [x] Self-review completed - [x] Documentation updated - [x] Backward compatibility maintained - [x] Manual testing performed - [ ] Unit tests added (TODO) - [ ] Integration tests added (TODO) ## Related Issues - Fixes: Identity Crisis (Critical) - agents losing identity on role change - Addresses: User Feedback from HarmonyCode website build - Improves: Metrics accuracy and collaboration awareness ## Future Work While this PR solves the identity crisis, other improvements from user feedback could be addressed in future PRs: - Task race condition fixes - Command aliases (hc for harmonycode) - Enhanced progress tracking - Comprehensive test suite ## Screenshots/Examples ### Before (v3.0.0) ``` Content-Writer: "I'll write content" Frontend-Dev: "I'll build UI" # Both were the same AI without knowing it! ``` ### After (v3.1.0) ``` alice (researcher): "I'll research this" alice (architect): "Now I'll design it" # Same alice, different roles - identity preserved! ``` --- This PR represents a critical fix based on real-world usage feedback. The identity crisis made HarmonyCode v3.0.0 frustrating to use, and this implementation solves that core issue while maintaining all existing features.