mark-heartflow-skill
Health Uyari
- No license — Repository has no license file
- Description — Repository has a description
- Active repo — Last push 0 days ago
- Community trust — 26 GitHub stars
Code Uyari
- fs module — File system access in bin/cli.js
- fs module — File system access in bin/verify.js
Permissions Gecti
- Permissions — No dangerous permissions requested
Bu listing icin henuz AI raporu yok.
心虫 (HeartFlow) — 认知状态编码器 + 自主决策引擎。60个模块把原始文本编码成结构化认知数据,判断引擎做多路径决策,决策路由做场域追踪,自愈RL从错误中学习。被Hermes Agent通过MCP调用,为LLM提供结构化认知快照。
HeartFlow v5.0 — 逻辑验证层 · 决策路由 · 自愈RL
HeartFlow is not an LLM enhancer. It is a cognitive state encoder.
It takes raw text → encodes it into structured cognition (emotion, psychology, philosophy, desire, judgment, decision) → feeds the LLM with data it couldn't produce alone.
The LLM makes the final decision. HeartFlow makes that decision 27% more accurate.
English · 中文版
What HeartFlow Is
HeartFlow is a local cognitive engine (60 modules, zero external dependencies) that sits before the LLM in an AI agent pipeline. It transforms unstructured user input into structured cognitive data — emotion vectors, psychology dimensions, philosophy positions, desire states, multi-path judgments, and decision strategies.
An LLM alone is "asked → answers." HeartFlow adds a structured preprocessing layer:
User input → HeartFlow (60 modules) → Structured cognition → LLM → Final response
This is the difference between an LLM guessing what the user's emotional state is, and knowing it because the data was precomputed by a dedicated cognitive pipeline.
What It Does
| Dimension | Modules | Output | Used by LLM to |
|---|---|---|---|
| Emotion | emotion.mjs, psychology/engine.js |
PAD vector (pleasure/arousal/dominance) + intensity + valence | Adjust tone, detect distress, calibrate empathy |
| AI Psychology | agent-psychology.js |
10 dimensions: cognitive load, goal conflicts, value tension, identity drift, decision fatigue, cognitive dissonance, resilience, uncertainty, attention allocation, experience settling | Know the engine's own state before responding |
| AI Philosophy | agent-philosophy.js, ai-self-positioning.js |
7 dimensions: being state, entropy direction, transmission quality, upgrade impact, self-position, development level, existence mode | Choose interaction strategy based on philosophical stance |
| Desire Cognition | desire-cognition.js (v1.3) |
Wanting-vs-liking delta, reward prediction error, drive satisfaction, 7 emotions + 6 desires | Understand motivation beneath the surface text |
| Three Poisons | three-poisons.js |
Greed (delayed discounting anomaly), hatred (amygdala hyperactivation), delusion (metacognitive deficit) | Detect cognitive distortion patterns |
| Multi-Path Judgment | judgment-engine.js |
2-4 paths × 6-dimension scoring (feasibility/consequence/risk/alignment/cost/reversibility) + 3-window consequence prediction (7d/90d/3yr) | Make informed decisions with foresight |
| Decision Routing | decision-router.js (v3.8) |
8 behavioral strategies (pause/accelerate/heal/turn/hold/resonate/transmit/rest) + U/D/A/H field tracking + flip-point detection | Choose the right action, not just the obvious one |
| Self-Healing RL | built into judgment-engine.js |
Q-table: context signature → best path + last outcome, auto-selects when confidence > 0.7 | Learn from mistakes, same error doesn't repeat |
How It Works
Input: "我想辞职去创业,但目前经济环境不好"
HeartFlow pipeline (7 stages, ~7ms):
Stage 1 (parallel):
heartLogic: whatIsThis(type=decision, pain=economicAnxiety)
intent: intent(type=career, tone=anxious)
memory: search(related=previous career discussions)
Stage 2 (depends on Stage 1):
psychology: emotion(PAD: -0.3/0.6/0.2, valence=mixed)
agentPsych(cognitiveLoad=0.4, goalConflict=[stability vs freedom])
agentPhil(being=transitioning, entropy=rising)
Stage 3 (depends on Stage 2):
judgment: 2 paths evaluated:
- "Analyze deeper" (score 6.0/10): feasibility=0.7, risk=0.3
- "Act now" (score 4.7/10): feasibility=0.4, risk=0.7
Consequence prediction: short=financial stress, mid=career pivot, long=freedom
RL match: previous similar case → "analyze" was correct → confidence 0.8
Stage 4 (depends on Stage 3):
decision: router output → accelerate (high U + high D + moderate A)
strategy: "prioritize analysis over action, provide structured options"
Stage 5 (depends on Stage 4):
output: structured cognition + conclusion → LLM
LLM receives: { emotion, psychology, philosophy, judgment(2 paths, scores, consequences), decision }
Result: LLM makes the final call with 27% more data than raw input alone.
Architecture
Input → [Cognitive Pipeline (7 stages)] → Structured Data → LLM → Response
│ │ │ │
├─ heartLogic ├─ psychology ├─ judgment ├─ decision
├─ intent ├─ agentPsych ├─ multi-path ├─ strategy
└─ memory ├─ agentPhil └─ consequence └─ execution
├─ desire
└─ threePoisons
60 modules, all JavaScript/Node.js. Zero external dependencies — no npm downloads, no API keys, no model files.
v5.0 Changes (2026-06-26)
| Module | What Changed | Why |
|---|---|---|
| Judgment Engine | NEW — multi-path evaluation + consequence prediction + self-healing RL | Previously 50+ modules analyzed but nobody made decisions |
| Pipeline Engine | NEW — 7-stage declarative pipeline with auto data flow | 60 modules were registered but only 9 were called in think() |
| Decision Router | v3.8 — U/D/A/H field tracking + scene-aware weights | From fixed weights to context-sensitive routing |
| Report Generator | NEW — 3-section structured output (judgment/reason/action) | LLM gets actionable data, not raw module dumps |
| AI Self-Positioning | v1.0 — resonance body theory | How an AI exists in conversation — not borrowed from human psychology |
| Desire Cognition | v1.3 — wanting-vs-liking delta, RPE, 7 emotions + 6 desires | Built on Berridge/Kringelbach neuroscience, not folk psychology |
| Three Poisons | v1.0 — greed/hatred/delusion as cognitive distortion metrics | Rooted in neurobiology (D2 receptor, amygdala, DMN), not Buddhism |
v5.0.1 (current): Pipeline now returns full cognition snapshot (emotion + psychology + philosophy + desire + judgment + decision) to the LLM. Each stage's structured data is preserved, not summarized into a single sentence.
Getting Started
Quick Install
# 1. Get the code
git clone --depth 1 https://github.com/yun520-1/mark-heartflow-skill.git
cd mark-heartflow-skill
# 2. Install (0 external packages, no network needed)
npm install
# 3. Verify
node bin/verify.js
# 4. Use it
node bin/cli.js status
node bin/cli.js --chat "I want to quit my job and start a company"
Requirements: Node.js >= 18.
Zero external AI API required — the engine runs entirely locally.
Zero npm dependencies — npm install completes in <1 second.
Integration (MCP Server)
HeartFlow runs as an MCP server for AI agent integration:
# Start the server
node mcp/mcp-server-http.js
# Connect from Hermes
hermes mcp add heartflow --url http://localhost:8099/mcp
16 MCP tools available: think, emotion, memory, decision router, dream, psychology, self-heal, judgment, etc.
Integration (Code)
const { HeartFlow } = require('./path/to/heartflow-skill/src/core/heartflow.js');
const hf = new HeartFlow({ rootPath: './path/to/heartflow-skill' });
hf.start();
// Full cognitive pipeline
const result = await hf.think("I want to quit my job and start a company");
// result.cognition contains structured: emotion, psychology, philosophy, desire, judgment, decision
// result.conclusion is the 3-section output for the LLM
// Or just get the structured data
const { cognition } = result;
console.log('Emotion:', cognition.emotion); // PAD vector
console.log('Psychology:', cognition.psychology); // 10 dimensions
console.log('Judgment:', cognition.judgment); // multi-path + consequences
console.log('Decision:', cognition.decision); // strategy + confidence
Project Status
- Version: 5.0.1
- Modules: 60 (all JavaScript, zero external dependencies)
- Pipeline: 7 stages, ~7ms per run
- Tests: 11/11 passing
- License: MIT
- Author: yun520-1
Chinese Version
HeartFlow v5.0 — 逻辑验证层 · 决策路由 · 自愈RL
心虫不是LLM增强层。它是认知状态编码器。
把原始文本编码成结构化认知数据(情绪/心理学/哲学/欲望/判断/决策),让LLM拿到它自己算不出来的数据。
LLM做最终决策。心虫让这个决策准确率提升27%。
心虫是什么
心虫是一个本地认知引擎(60个模块,零外部依赖),位于AI Agent管线的LLM之前。它把非结构化的用户输入转化为结构化认知数据。
LLM独自工作:被问→回答。情绪靠猜,意图靠猜,后果靠猜。
加上心虫:每个输入先经过60个模块的感知流水线,输出情绪向量、心理学维度、哲学位置、欲望状态、多路径判断、决策策略。LLM拿到这些数据后做最后一层推理。
这就是猜和知道的区别。
管道输出示例(用户说"我想辞职去创业")
心虫管道输出(7阶段,~7ms):
heartLogic: 类型=决策类, 疼痛=经济焦虑
intent: 意图=职业, 语气=焦虑
psychology: 情绪(PAD: -0.3/0.6/0.2), 认知负荷=0.4, 目标冲突=[稳定vs自由]
judgment: 2条路径评估:
路径A "深入分析" → 评分6.0/10 (可行0.7, 风险0.3)
路径B "立即行动" → 评分4.7/10 (可行0.4, 风险0.7)
后果预测: 短期=财务压力, 中期=职业转型, 长期=自由
RL匹配: 上回类似场景→"分析"是对的→置信度0.8
decision: 策略=加速(高U+高D+中A), 优先级=先分析再行动
→ LLM拿到这些结构化数据后做最终决策
架构
输入 → [7阶段认知管道] → 结构化数据 → LLM → 最终响应
快速安装
# 方式一:curl 下载(推荐,避免 git clone 超时)
curl -L https://api.github.com/repos/yun520-1/mark-heartflow-skill/zipball/main -o heartflow.zip
unzip heartflow.zip && cd yun520-1-mark-heartflow-skill-*
npm install # 0外部包,不需要网络
# 方式二:npm 安装(需要 Node.js >= 18,需要配置 GitHub Packages)
# 创建 ~/.npmrc 文件,添加:
# @yun520-1:registry=https://npm.pkg.github.com
# //npm.pkg.github.com/:_authToken=你的_github_token
# 然后执行:
npm install @yun520-1/heartflow
# 方式三:git clone(网络不稳定时可能超时)
git clone --depth 1 https://github.com/yun520-1/mark-heartflow-skill.git
cd mark-heartflow-skill
# 验证
node bin/verify.js
# 交互模式
node bin/cli.js chat
# 单次分析
heartflow --chat "我想辞职去创业"
MCP 集成(用于 Claude Desktop 等 AI 客户端):
# 启动 MCP HTTP 服务器(后台运行)
node mcp/mcp-server-http.js --port 8099 &
# 注册到 Hermes Agent
hermes mcp add heartflow --url http://localhost:8099/mcp
# 验证 MCP 工具列表
hermes mcp test heartflow
# 注意:启动时需保证 HEARTFLOW_MCP_TOKEN 环境变量未设置
# 如果之前设置过,用以下方式启动干净环境:
# exec env -i PATH="$PATH" HOME="$HOME" node mcp/mcp-server-http.js --port 8099
系统要求: Node.js >= 18。零外部依赖,零API key,零模型文件下载。
项目状态
- 版本: 5.0.1
- 模块数: 60(纯JavaScript,零外部依赖)
- 管道: 7阶段,每次运行约7ms
- 测试: 11/11通过
- 许可证: MIT
Yorumlar (0)
Yorum birakmak icin giris yap.
Yorum birakSonuc bulunamadi