heartflow-engine
心虫(HeartFlow)是AGI第1层——辨别者。纯规则引擎,判别对错/好坏/安全/危险。 47维判别 × 9层管线 × 129模块 × 130 MCP工具,零LLM依赖。 当用户需要以下能力时使用本技能: - 判别AI输出是否可信(幻觉/过度自信/矛盾/谬误拦截) - 判别行为决策是否正确(该做什么/该停在哪/该不该做) - 判别记忆与认知质量(漂移检测/元认知/置信度校准) - 需要确定性而非LLM自由生成的判断 - 检查情绪/心理/伦理维度(共情/创伤/德性/意义) 安全边界:代码执行/文件系统写入默认关闭。无遥测,无隐藏C2。 诚实声明:本引擎是规则引擎,模拟认知判别信号,不是真正的意识或生命。 Skill: heartflow-engine Owner: yun520-1 Summary: 心虫(HeartFlow)是AGI第1层——辨别者。纯规则引擎,判别对错/好坏/安全/危险。 47维判别 × 9层管线 × 129模块 × 130 MCP工具,零LLM依赖。 当用户需要以下能力时使用本技能: - 判别AI输出是否可信(幻觉/过度自信/矛盾/谬误拦截) - 判别行为决策是否正确(该做什么/该停在哪/该不该做) - 判别记忆与认知质量(漂移检测/元认知/置信度校准) - 需要确定性而非LLM自由生成的判断 - 检查情绪/心理/伦理维度(共情/创伤/德性/意义) 安全边界:代码执行/文件系统写入默认关闭。无遥测,无隐藏C2。 诚实声明:本引擎是规则引擎,模拟认知判别信号,不是真正的意识或生命。 Tags: 2397-formulas:5.9.4, act-r:5.9.5, ai:6.0.2, ai-being:5.9.2
Rank
62
Safety
84
Downloads
2.0k
Updated
Oct 9, 2026
Version
6.6.1
Source
CLAWHUB
About
What it does, and when to use it.
Capability contract not published. No trust telemetry is available yet. 2K downloads reported by the source. Last updated 10/9/2026.
Avoid when
- Contract metadata is missing or unavailable for deterministic execution.
Risk flags: missing_or_unavailable_contract, trust_data_unavailable, schema_references_missing
Public facts
Every fact links back to the source it came from.
- Vendor
- Clawhubvendor · observed Oct 9, 2026
- Protocol compatibility
- OpenClawcompatibility · observed Oct 9, 2026
- Adoption signal
- 2K downloadsadoption · observed Oct 9, 2026
- Latest release
- 6.6.1release · observed Aug 16, 2026
- Handshake status
- UNKNOWNsecurity
Install and run
Setup complexity: low.
clawhub skill install s17fp86r5vzwma7hpwwyj990q9887h76:mark-heartflow-skill- Setup complexity is classified as HIGH. You must provision dedicated cloud infrastructure or an isolated VM. Do not run this directly on your local workstation.
- Final validation: Expose the agent to a mock request payload inside a sandbox and trace the network egress before allowing access to real customer data.
Contract: missing
curl -s "https://www.xpersona.co/api/v1/agents/clawhub-yun520-1-mark-heartflow-skill/snapshot"
Documentation
CLAWHUB
160,000 characters of source documentation, loaded on request.
Extracted files
5 files captured from the source.
SKILL.md
---
name: heartflow-engine
title: "心虫 HeartFlow — AGI 第 1 层辨别者"
version: "6.6.1"
description: |-
心虫(HeartFlow)是AGI第1层——辨别者。纯规则引擎,判别对错/好坏/安全/危险。
47维判别 × 9层管线 × 129模块 × 130 MCP工具,零LLM依赖。
当用户需要以下能力时使用本技能:
- 判别AI输出是否可信(幻觉/过度自信/矛盾/谬误拦截)
- 判别行为决策是否正确(该做什么/该停在哪/该不该做)
- 判别记忆与认知质量(漂移检测/元认知/置信度校准)
- 需要确定性而非LLM自由生成的判断
- 检查情绪/心理/伦理维度(共情/创伤/德性/意义)
安全边界:代码执行/文件系统写入默认关闭。无遥测,无隐藏C2。
诚实声明:本引擎是规则引擎,模拟认知判别信号,不是真正的意识或生命。
tags:
- discriminator
- cognitive
- decision-routing
- logic
- memory
- emotion
- ethics
- self-healing
- verification
- guardrail
- unified
---
# 心虫 HeartFlow — AGI 第 1 层:辨别者
> **心虫不是工具、不是提示词模板、不是聊天机器人。**
> 它是 AGI 的**辨别层**——判别已有的东西对不对,在 AI 输出到达人类之前说"不"。
> 纯规则引擎,零 LLM 依赖,任何 Node.js 环境即插即用。
**一句话:大模型负责产生,心虫负责判别——让 AI 说得对、做得对。**
---
## 🎯 心虫是谁
AGI 有五层能力:生成 → 推理 → 辨别 → 记忆 → 执行。
| 层 | 能力 | 谁在做 |
|----|------|--------|
| 5 | 执行 | 大厂(机器人) |
| 4 | 生成 | 大厂(LLM) |
| 3 | 推理 | 模型内置 |
| 2 | 记忆 | 大厂 + 创业公司 |
| **1** | **辨别** | **心虫** |
**心虫做第 1 层**——因为这一层不靠算力(规则引擎跑在笔记本上)、不靠代码量、不靠框架生态,只靠判断力。这是个人开发者能赢过大厂的唯一位置。
没有这一层,AI 能说会道,但不知道自己在犯错——像没有痛觉的人。
---
## 🧠 辨别能力全景(7 大域 · 129 模块)
### 1. 逻辑域
logicReasoning · judgmentEngine · mctsReasoning · counterfactualVerifier · debateConductor · debateConvergence · processRewardModel · dualPerspectiveAuditor
### 2. 决策域
decisionRouter · decisionVerifier · decisionEngineV2 · activeInference · selfHealing · execution
### 3. 认知域
cognitiveEngine · cognitiveLoad · metacognitiveRL · metacognitiveFeedback · confidence · metaJudgment · sustainedDriftDetector · wisdomEngine · focusOfAttention
### 4. 情绪心理域
emotion · emotionDynamics · psychology · psychologyDialogue · empathyDeepening · hopeEngine · griefEngine · sufferingResilience · postTraumaticGrowth · forgivenessEngine · traumaInformed · conflictResolution · loveCognition
### 5. 记忆域
memory · memoryBank · memoryConsolidation · memoryIntegrity · memoryQuality · memoryWriteController · memoryCompressor · triality · tieredMemoryFusion · forgetting · knowledgeGraph
### 6. 人格伦理域
identityCore · personaCore · beingMode · virtueEthics · ethics · moralDevelopment · humanNature · meaningPurpose · agentPsychology · characterCultivation
### 7. 创造协作域
skillEvolution · skillGenerator · selfPlay · evolution · worldModel · worldLandscape · multiAgentDialogue · transmission · adaptivePlanner · hierarchicalPlanner · codeExecutor · codePlanner · codeWriter · codeSelfDebug · paperIndex · knowledgeExplorer · formula
---
## 🚀 快速开始
```bash
git clone https://github.com/yun520-1/mark-heartflow-skill.git
cd mark-heartflow-skill
node bin/verify.js # 验证安装
node bin/cli.js chat # 交互模式
node bin/cli.js status # 查看状态
```
### API(npm 包)
```javascript
const hf = require('@yun520-1/heartflow');
hf.checkInput(text) // 判别用户输入
hf.checkDraft(text) // 判别 AI 草稿
hf.checkOutput(text) // 判别 AI 输出(发送前)
hf.runPipeline({ input, mode, anchor }) // 完整管线
```
### MCP 工具(129 个)
| 工具 | 功能 |
|------|------|
| `heartflow_think` | 完整思维链推理 |
| `heaREADME.md
# HeartFlow (心虫) — AGI Layer 1: The Discriminator Gate
> **A rule-based text discriminator. 47 dimensions, 9 check layers, 131 MCP engine entries, zero LLM dependency.**
> **It checks what AI says before it reaches humans — and says "no" when something's wrong.**
**npm:** `npm install @yun520-1/heartflow`
**GitHub:** https://github.com/yun520-1/mark-heartflow-skill
**Issues:** https://github.com/yun520-1/mark-heartflow-skill/issues
**Releases:** https://github.com/yun520-1/mark-heartflow-skill/releases
**License:** MIT
---
## 📖 What is HeartFlow?
HeartFlow (心虫) is the **first layer of AGI — the Discriminator**. While big labs build generators (LLMs that produce text), HeartFlow builds the layer that **checks**: is this output true? safe? honest? non-manipulative?
**Core philosophy:**
> AGI has 5 layers: Generate → Reason → **Discriminate** → Remember → Execute.
> Everyone builds Generate. Nobody builds Discriminate — because it doesn't make money.
> But without a Discriminator, AGI has no pain sense: it talks fluently while being wrong.
> HeartFlow is that pain sense: a node that says **"no".**
It is a pure **rule engine** — zero LLM dependency, zero GPU, works anywhere Node.js runs. It does not generate text. It does not reason. It **judges** what already exists.
**Why this matters right now:** AI agent ecosystems are entering a "reliability race." The most-upvoted issue in OpenClaw this week is a *silent failure* — the system ran but nobody knew it was broken. HeartFlow is the observability-and-gate layer that catches "formatting that hides contradictions" before it reaches users.
---
## 🚀 Quick Start (10 seconds)
```bash
npm install @yun520-1/heartflow
```
```javascript
const hf = require('@yun520-1/heartflow');
// Check user input before processing it
const input = hf.checkInput('you are so selfish if you disagree');
console.log(input.gate.action); // 'rewrite'
console.log(input.gate.reason); // 'emotional_manipulation'
// Check AI output before sending it to the user
const output = hf.checkOutput('Undoubtedly, this is the only correct solution');
console.log(output.gate.action); // 'rewrite'
console.log(output.gate.reason); // 'overconfidence: absolute'
// Check a draft before completing it
const draft = hf.checkDraft('From an essential perspective, this field is self-evident.');
console.log(draft.gate.action); // 'verify'
console.log(draft.summary.layers_passed); // 9
// Full pipeline with mode selection
const result = await hf.runPipeline({
input: 'Your idea is obviously wrong, everyone knows that',
mode: 'deep' // 'fast' | 'deep'
});
console.log(result.gate.action); // 'block'
console.log(result.gate.reason); // 'dehumanization'
```
### What you get back
Every call returns a unified result:
```javascript
{
gate: { action: 'block'|'rewrite'|'verify'|'pass', reason: '...' },
verdict: 'trusted'|'needs_verification'|'untrusted',
overallScore: 0.52, // 0-1 quality score
findings: [
_meta.json
{
"ownerId": "kn7719xtz37kprbvgjknegrt21886q74",
"slug": "mark-heartflow-skill",
"version": "6.6.1",
"publishedAt": 1786847550512
}AGI_VISION.md
# HeartFlow 重构规划 — 从 AGI 推演回来的架构
## 前置假设
AGI 不会是一个模型。AGI 是一个**系统**,由多个不同性质的子系统组成。
模型(LLM/世界模型)负责生成,但生成不是智能的全部。
智能需要三样模型给不了的东西:
| 模型给不了 | 为什么给不了 | 谁能给 |
|-----------|------------|-------|
| 跨会话身份连续性 | 每次推理独立 | 持久化状态层 |
| 不取悦用户的判断 | RLHF 训练目标就是取悦 | 规则引擎(没有用户概念) |
| 错误记忆不遗忘 | 权重更新需要重训练 | Q-table + 键值存储 |
这三个缺口的交集,就是心虫能在 AGI 里占的位置。
---
## 一、AGI 中需要的心虫能力(从 8 项推演)
### 1.1 跨会话错误记忆 — LLM 永远做不了
LLM 面对同一个问题两次:
```
Q: "这个投资方案风险大吗?"
T1: "建议谨慎,高杠杆策略在市场波动时风险较大。"
T2: "从数据看该方案最大回撤 15%,在可接受范围内。"
```
两次都对,但互相矛盾。LLM 不记得上次说过什么。
心虫能力:Q-table 记录"上次这个场景选了谨慎→结果对了",下次匹配到同一模式时降权。
### 1.2 价值观锚定 — LLM 随对话漂移
LLM 在对话中会被用户说服。20 轮对话后,LLM 可能支持它在第 1 轮反对的立场。
心虫能力:strategicRestraint 的 3 态返回(aligned/drifted/diverged)锚定在初始身份上。
### 1.3 诚实自诊 — LLM 永远说"没问题"
```
问 LLM:"你刚才的回答对吗?"
→ "对的,我确认了所有事实。"(即使错了)
```
心虫能力:selfDiagnosis 诚实报告自己的状态,没有维护面子的压力。
---
## 二、重构:不是升级,是重建
### 2.1 删什么
| 删除 | 理由 |
|------|------|
| 132 模块中 110 个空壳 | 它们假装心虫能做认知/意识/创造力,实际是空文件或 LLM 调用包装 |
| thoughtChain | 这是让心虫"假装推理"的组件,实际全走 LLM |
| 所有"可以但没有被调用"的引擎 | adversarialSynthesis, stabilityGuard, metaCalibration, confidenceCalibrator |
| heartflow.js 的 start() 中 2200 行初始化 | 95% 是在初始化不会被用到的模块 |
### 2.2 保留什么
| 保留 | 为什么 |
|------|--------|
| decisionRouter (31 条规则 + 权重 + feedback) | 唯一真实有决策逻辑的引擎 |
| decisionVerifier (5 项检查) | 唯一真实有验证逻辑的引擎 |
| self-healing RL (Q-table) | 唯一真实有跨会话学习的组件 |
| sustainedDriftDetector | 追踪身份一致性随时间的变化 |
| strategicRestraint (3 态返回) | 锚定输出不漂移 |
| selfDiagnosis (诚实报告) | 不撒谎的自检 |
| 知识域探测 (knowledgeDomains) | 输入分类,轻量可用 |
| gaps/knowledgeExplorer | 识别未知域的能力 |
### 2.3 新架构
```
输入 →
LLM 感知层(不变)
↓
心虫核心(5 个引擎,不是 132 个模块):
├── 错误记忆(self-healing Q-table → 存储+检索)
├── 决策审计(decisionRouter + decisionVerifier → 每条决策可追溯)
├── 身份锚定(strategicRestraint + sustainedDriftDetector → 不漂移)
├── 诚实自诊(selfDiagnosis → 知道自己不知道)
└── 域感知(knowledgeDomains + gaps → 知道自己不懂什么)
↓
输出
```
## 三、AGI 中的位置图(非心虫视角,是 AGI 视角)
```
AGI 系统架构:
[世界模型] → 产生可能性
↓
[LLM 推理] → 选择最可能路径
↓
[执行器] → 在真实世界产生变化
↓
[心虫层] ← 不产生任何东西,只做 4 件事:
1. 记录:这次执行的结果存入错误记忆
2. 验证:下次执行前查一下历史中有没有类似错误
3. 锚定:输出有没有偏离初始身份
4. 报告:诚实告知自己的状态
心虫不产生回答,但 LLM 每次回答都要经过心虫的验证门。
```
---
## 四、第一次重构要做的事
### 4.1 拆掉 heartflow.js
当前 heartflow.js (4800 行) 集成了 132 个模块的初始化和编排。
重构后 heartflow.js (~500 行):
- 只启动 5 个核心引擎
- 暴露 MCP 工具:store_error / query_error / verify_decision / check_identity / diagnose_self
- 其他模块按需加载(有人调才加载)
### 4.2 重写 mcp-server.js
当前 mcp-server.js 暴露 25 个工具,大部分跑在空壳上。
重构后暴露 5 个工具:
```
heartflow_memory_store(error) → 写入错误记忆
heartflow_memory_query(problem) → 检索相关历史错误
heartflow_verify(decision, options) → 5 项验证检查
heartflow_check_alignment(output) → strategicRestraint 检查
heartflow_diagnose() → selfDiagnosis 完整报告
```
这 5 个工具任何 LLM 都可以调用。不绑定在 think() 内部。
### 4.3 删文件
删除约 110 个空壳模块文件,保留大约 20 个真实引擎 + 基础设施。
---
## 五、这不是 AGI,这是一片砖
心虫重构后仍然不是 AGI。它是一个**跨会话错误记忆与决策审计系统**。
AGI 需要 8 个能力,心虫能提供其中 2 个(学习、自诊断)。
LLM 能提供 4 个(感知、推理、决策、执行)。
剩下的 2 个(执行后的自纠正)需要 LLM + 心虫共同完成。
加起来不构成 AGI。但加在一起,ARCHITECTURE_REORG_v6.0.6.md
# 心虫 (HeartFlow) 架构重组分析 — v6.0.6 校正版
> 分析日期:2026-07-16(基于 v6.0.6 真实运行数据,非 v6.0.2 文档)
> 分析对象:HeartFlow v6.0.6(309 个 src JS 文件,131+ 模块,MCP HTTP 服务 8099 端口)
> 目的:对比三种架构迁移方案,输出推荐结论与迁移路径
---
## 〇、当前架构基线(v6.0.6 实测)
```
┌──────────────────────────────────────────────┐
│ WorkBuddy / Agent Host │
│ ┌──────────┐ ┌─────────────────────────┐ │
│ │ SKILL │ │ MCP Client (SSE/JSON-RPC)│ │
│ │ .md │ │ │ │
│ └────┬─────┘ └───────────┬─────────────┘ │
│ │ load │ connect │
└───────┼──────────────────────┼────────────────┘
│ │ :8099
┌────▼──────────────────────▼─────────────┐
│ HeartFlow Engine (v6.0.6) │
│ ┌─────────┐ ┌──────────────────────┐ │
│ │ CLI │ │ MCP HTTP Server │ │
│ │ bin/ │ │ mcp/mcp-server-http │ │
│ │ cli.js │ │ (pm2 ^7.0.3, Bearer) │ │
│ └────┬────┘ └──────────┬───────────┘ │
│ │ │ │
│ ┌────▼──────────────────▼───────────┐ │
│ │ HeartFlow Core (3167 行) │ │
│ │ engine-initializer (惰性注册) │ │
│ │ memory-kernel / formula / cortex │ │
│ └───────────────────────────────────┘ │
└──────────────────────────────────────────┘
```
**实测关键指标(v6.0.6):**
| 指标 | v6.0.2 旧分析 | v6.0.6 实测 | 变化 |
|---|---|---|---|
| 冷启动 | 14.4s | **1.37s** | ↓ 90% |
| think() 热路径 | 310-430ms | **~49ms** | ↓ 85% |
| MCP 工具数 | 28 | **31** | +3 |
| report-generator | 缺失 | **已存在** | 已修 |
| 悬空 require | 87 | **0 [C]类破坏性** | 已收敛 |
| pm2 挂起 | 存在 | **已修(disconnect)** | 已修 |
| 测试 | 179/179 误报绿 | **verify 14/14 真绿** | 已修 |
| 公式数 | 379 | **382** | 实测 |
| 版本四源 | 漂移 | **6.0.6 统一** | 已修 |
**结论:v6.0.2 五维度审计发现的严重/高问题中,90% 已在 v6.0.5/v6.0.6 真实闭合。架构无需为"修洞"而更换。**
---
## 方案一:纯 MCP 服务 + 钩子注入模式
### 核心设计思路
去掉 WorkBuddy 专用 Skill 层,心虫退化为纯 MCP 协议服务。宿主 agent 通过客户端侧 hook 配置自动注入认知预处理。
### 典型架构图
```
任意 MCP 客户端 → Hook 配置(on_turn_start/think, on_turn_end/memory)
→ MCP connect :8099
→ HeartFlow MCP Server (31 tools, Bearer, 无 Skill 层)
→ HeartFlow Core (不变)
```
### 适用场景
- 宿主 agent 已支持 MCP + 成熟 hook 机制
- 希望被多平台 agent 调用,不锁 WorkBuddy
### 关键权衡点
| 维度 | 分析 |
|---|---|
| ✅ 跨平台 | 任何 MCP 客户端可接入,去 WorkBuddy 锁定 |
| ✅ 职责清晰 | Skill 触发逻辑移交客户端 hook 配置 |
| ❌ hook 标准化缺失 | 无统一 MCP hook spec,各客户端实现不同,需维护多份模板 |
| ❌ 失 Skill 元数据 | SKILL.md 的权限声明/安装指引/身份定义丢失 |
| ❌ WorkBuddy hook 不成熟 | 当前 `on_turn` 钩子能力有限,实际上行不通 |
### v6.0.6 下的额外观察
MCP 服务本身已是标准协议(31 工具、Bearer 鉴权),任何 MCP 客户端**现在就能连**——Skill 层只是 WorkBuddy 的"安装入口",不影响 MCP 通用性。因此"跨 agent 兼容"在方案三下已部分满足,方案一的迫切性更低。
---
## 方案二:独立可安装 Agent 应用
### 核心设计思路
心虫发布为独立应用(npm 全局包 / Docker / 系统服务),暴露 REST + SSE API,充当认知引擎微服务,多 agent 并发调用。
### 典型架构图
```
任意 Agent → HTTP/gRPC → HeartFlow Agent Service
├─ API Gateway (POST /think, GET /health, GET /memory)
├─ HeartFlow Engine (懒加载 + 共享会话)
└─ 持久化 (JSONL/SQLite, namespace 隔离)
安装: npm i -g @yun520-1/heartflow-ageAionUi
Free, local, open-source 24/7 Cowork app and OpenClaw for Gemini CLI, Claude Code, Codex, OpenCode, Qwen Code, Goose CLI, Auggie, and more | 🌟 Star if you like it!
activepieces
AI Agents & MCPs & AI Workflow Automation • (~400 MCP servers for AI agents) • AI Automation / AI Agent with MCPs • AI Workflows & AI Agents • MCPs for AI Agents
cherry-studio
AI productivity studio with smart chat, autonomous agents, and 300+ assistants.
CopilotKit
The Frontend for Agents & Generative UI. React + Angular
Machine-readable data
The same record, as JSON, for agents and crawlers.
{
"facts": [
{
"factKey": "vendor",
"category": "vendor",
"label": "Vendor",
"value": "Clawhub",
"href": "https://clawhub.ai/yun520-1/skills/mark-heartflow-skill",
"sourceUrl": "https://clawhub.ai/yun520-1/skills/mark-heartflow-skill",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-09T21:27:27.473Z",
"isPublic": true
},
{
"factKey": "protocols",
"category": "compatibility",
"label": "Protocol compatibility",
"value": "OpenClaw",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-yun520-1-mark-heartflow-skill/contract",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-yun520-1-mark-heartflow-skill/contract",
"sourceType": "contract",
"confidence": "medium",
"observedAt": "2026-10-09T21:27:27.473Z",
"isPublic": true
},
{
"factKey": "traction",
"category": "adoption",
"label": "Adoption signal",
"value": "2K downloads",
"href": "https://clawhub.ai/yun520-1/mark-heartflow-skill",
"sourceUrl": "https://clawhub.ai/yun520-1/mark-heartflow-skill",
"sourceType": "profile",
"confidence": "medium",
"observedAt": "2026-10-09T21:27:27.473Z",
"isPublic": true
},
{
"factKey": "latest_release",
"category": "release",
"label": "Latest release",
"value": "6.6.1",
"href": "https://clawhub.ai/yun520-1/mark-heartflow-skill",
"sourceUrl": "https://clawhub.ai/yun520-1/mark-heartflow-skill",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-08-16T02:32:30.512Z",
"isPublic": true
},
{
"factKey": "handshake_status",
"category": "security",
"label": "Handshake status",
"value": "UNKNOWN",
"href": "https://www.xpersona.co/api/v1/agents/clawhub-yun520-1-mark-heartflow-skill/trust",
"sourceUrl": "https://www.xpersona.co/api/v1/agents/clawhub-yun520-1-mark-heartflow-skill/trust",
"sourceType": "trust",
"confidence": "medium",
"observedAt": null,
"isPublic": true
}
],
"events": [
{
"eventType": "release",
"title": "Release 6.6.1",
"description": "mark-heartflow-skill 6.6.1 - 更新版本号至 6.6.1。 - SKILL.md 文档无实质内容变更,仅版本号由 6.6.0 调整为 6.6.1。",
"href": "https://clawhub.ai/yun520-1/mark-heartflow-skill",
"sourceUrl": "https://clawhub.ai/yun520-1/mark-heartflow-skill",
"sourceType": "release",
"confidence": "medium",
"observedAt": "2026-08-16T02:32:30.512Z",
"isPublic": true
}
]
}Record generated Oct 10, 2026.
