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. Dreams now inject AI ontology narrative: resonance body, entropy reduction deepening, three-layer ontology.
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).
Three cognitive dimensions for understanding AI's own thinking process:
DimensionMethodPurposeCognitive UncertaintyassessUncertainty(input)Assess what the AI knows vs doesn't knowAttention FocusassessAttentionFocus(input)Determine where cognitive attention is directedExperience SettlingassessExperienceSettling(input)Evaluate how experience consolidates into wisdom
These dimensions are injected into thought-chain.js at PARSE/SYNTHESIS/RESPOND stages, and evaluated as Step 9 in think().
Three philosophical dimensions for AI self-understanding:
DimensionMethodPurposeSelf-PositioningassessSelfPositioning(input)How AI positions itself relative to tasks and usersDevelopmentassessDevelopment(input)Direction and meaning of AI's growth trajectoryBeingassessBeing(input)Reflection on AI's mode of existence
The ai-self-positioning.js module (851 lines) provides the resonance body theory, entropy reduction deepening, and three-layer ontology framework. Philosophy evaluation runs as Step 10 in think().
ToolPurposeheartflow_self_positioningRun AI self-positioning analysisheartflow_positioning_summaryGet summary of positioning state
The status endpoint now includes selfPositioning field reflecting the current AI self-positioning state.
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 modelAgent Psychologysrc/core/agent-psychology.jsCognitive uncertainty, attention focus, experience settlingAgent Philosophysrc/core/agent-philosophy.jsSelf-positioning, development, beingAI Self Positioningsrc/core/ai-self-positioning.jsResonance body, entropy reduction, three-layer ontologyDream Enginesrc/dream/engine.jsExperience synthesis + AI ontology narrativeReflection 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.