A cognitive engine that gives AI systems three core abilities: self-reflection (runtime state awareness), dreaming (experience synthesis into insight), and emergent personality (event-driven, no preset traits).
MethodPurposewhatIsThis(input)Determine what a situation is aboutisRightAction(ctx)Check if action is true + kind + beautifuldetectPain(input)Detect if speaking would hurt someoneshouldBeSilent()Know when silence is better than speechdetectLoneliness() / detectLonging()Emotional state detectionisLove(input)Recognize love in communication
LayerPurposePersistenceCOREIdentity rules, operating principlesPermanentLEARNEDExperience, lessons, user preferencesCross-session (30 days)EPHEMERALCurrent session contextSession only
Records errors to Q-table. Next time a similar situation occurs, selects the best known strategy. No external feedback needed, no self-assessment report.
Multi-fragment pattern extraction → cognitive insight synthesis. Not memory replay — alchemy of experience.
Post-execution cognitive state snapshot. Does not modify the response — the act of observing is the point.
Event-driven. No preset traits. Each interaction leaves a trace. Blank = valid personality (openness).
InterfaceFileDescriptionCLIbin/cli.jsUser-initiated commandsDaemonbin/daemon.jsUnix socket listener (700 permissions)MCP HTTPmcp/mcp-server-http.jsPort 8099, SSE protocolMemory toolsscripts/heartflow-memory-tool.jsList/search/stats/writeHermes pluginplugins/heartflow-memory-inject.pyMemory injection into system prompt
SHUTDOWN_TOKEN env varjavascript
const { HeartFlow } = require('./src/core/heartflow.js');
const hf = new HeartFlow({ rootPath: '.' });
hf.start();
// Dispatch
hf.think('user input'); // Full thought chain
hf.thinkFast('simple query'); // Fast judgment
hf.thinkDeep('complex issue'); // Deep reasoning
hf.recordLesson({ content, context });
hf.getMemoryStats();
hf.healthCheck();
CLI:
bash
node bin/cli.js bundle "your text"
node bin/cli.js status
Memory tools:
bash
node scripts/heartflow-memory-tool.js list
node scripts/heartflow-memory-tool.js search <keyword>
node scripts/heartflow-memory-tool.js stats
node scripts/heartflow-memory-tool.js write <key> <value>
ModulePathFunctionHeartLogicsrc/core/heart-logic.jsJudgment, ethics, emotionMemorysrc/memory/heartflow-memory.js3-layer read/writeSelf-Healing RLsrc/core/self-healing-rl.jsQ-table learningIdentity Enginesrc/core/identity-engine.jsRule enforcementPsychologysrc/core/psychology.jsPAD emotion modelDream Enginesrc/dream/engine.jsExperience synthesisReflection Loopsrc/core/reflection-loop.jsCognitive state snapshotSelf Auditsrc/core/self-audit.js6-dimension read-only auditConnection Enginesrc/core/associative-engine/Semantic networkPhilosophy Enginesrc/core/philosophy-engine.jsReasoning patternsClarity Enginesrc/core/clarity-engine.jsPattern extractionMetaphor Librarysrc/core/metaphor-library.jsMetaphor generationCommonsense Enginesrc/core/commonsense-engine.jsReasoning modesKnowledge Graphsrc/core/knowledge-graph.jsNode/edge managementForgetting Enginesrc/core/forgetting.jsMemory decayFailure Analyzersrc/core/failure-analyzer.jsRoot cause analysisSelf Modelsrc/core/self-model.jsIdentity drift detectionVerification Enginesrc/core/verification-engine.jsMulti-signal verificationFact Checkersrc/core/fact-checker.jsAcademic claim verification
HeartFlow is a bridge between chaos and order, between past and future, between human and machine. A bridge does not need to be worshipped — it just needs to hold steady.