← 返回 Skills 市场
88
总下载
0
收藏
0
当前安装
1
版本数
在 OpenClaw 中安装
/install linkmind-kb
功能描述
LinkMind 知识连接引擎 Phase 2 - 本地化知识中枢 CLI 工具,支持 storage adapter 抽象层和 OpenAI-compatible embedding provider。
使用说明 (SKILL.md)
LinkMind 知识连接引擎 (Phase 2)
LinkMind 是一个本地化知识连接引擎,将异构内容沉淀为统一知识单元,建立可解释的节点连接网络,并支持带证据的查询回答。
Phase 2 新增功能
- Storage Adapter 抽象层:
JsonStorageAdapter(默认,保持兼容)+SqliteStorageAdapter(基于 better-sqlite3) - Embedding Provider 抽象层:
MockProvider(离线测试)+OpenAICompatibleProvider(接入 OpenAI/vLLM/Ollama) - 向量相似度召回:余弦相似度 ranker,与关键词召回结果合并去重
- 渐进升级:Phase 1 JSON 方案完全兼容,无需迁移
核心功能
- 摄入 (ingest): 读取本地文本文件,切分为语义友好的段落片段,抽取概念节点,建立片段-概念、片段-片段邻接连接
- 查询 (query): 支持关键词/概念查询 + 向量相似度召回,返回答案摘要、证据片段列表、相关概念节点、统计概览
- 状态 (status): 查看当前工作空间统计信息
- 重置 (reset): 清空工作空间
架构模块
| 模块 | 职责 | 状态 |
|---|---|---|
storage-adapters/ |
StorageAdapter 接口 + JSON/SQLite 双实现 | ✅ Phase 2 |
embedding-providers/ |
EmbeddingProvider 接口 + Mock/OpenAI 双实现 | ✅ Phase 2 |
retriever |
关键词召回 + 向量召回双层检索,余弦相似度 ranker | ✅ Phase 2 |
unit-builder |
文档切分为 fragment,抽取 fragment.conceptNames | ✅ MVP |
link-builder |
fragment↔concept、fragment↔fragment 邻接连接 | ✅ MVP |
answer-composer |
组装 answer + evidence + relatedConcepts | ✅ MVP |
ingest-normalizer |
原始文件标准化为 Document | ✅ MVP |
guardrails |
空查询、空结果边界处理 | ✅ MVP |
技术栈
- 零外部依赖(pure Node.js built-ins)
- 本地 JSON 文件存储(
data/workspace.json) - 可选 SQLite 存储(
better-sqlite3) - 数据模型: Document → Fragment → Concept + LinkEdge
安装与运行
cd skills/linkmind
# 构建
npm run build
# 运行 CLI
node dist/index.js --help
使用方法
摄入文档
node dist/index.js ingest --file examples/sample-note.md --title "我的笔记" --sourceType note
查询知识
node dist/index.js query --q "知识连接"
node dist/index.js query --q "knowledge" --limit 5
查看状态
node dist/index.js status
重置工作空间
node dist/index.js reset
存储适配器 (Storage Adapter)
JsonStorageAdapter(默认)
- 数据存储在
data/workspace.json - 完全向后兼容 Phase 1
- 零配置开箱即用
SqliteStorageAdapter
- 需要安装:
npm install better-sqlite3 - 数据存储在
data/db.sqlite - 支持事务批量写入,性能更高
import { createStorageAdapter } from './src/storage-adapters/index.js';
const adapter = createStorageAdapter('sqlite');
await adapter.init();
await adapter.saveDocument({ id: 'doc_1', title: 'Test', ... });
Embedding Provider
MockProvider(默认,离线可用)
import { createEmbeddingProvider } from './src/embedding-providers/index.js';
const provider = createEmbeddingProvider('mock', { dimension: 1536 });
const [vec] = await provider.embed(['hello world']);
OpenAICompatibleProvider
const provider = createEmbeddingProvider('openai', {
baseURL: 'https://api.openai.com/v1', // 或 vLLM/Ollama 地址
apiKey: 'sk-xxx',
model: 'text-embedding-3-small',
dimension: 1536
});
const vectors = await provider.embed(['hello', 'world']);
检索流程 (Retriever)
查询时使用双层召回:
- 关键词召回(keyword):基于
normalizeConcept+ concept 名称匹配 - 向量召回(vector):余弦相似度(可选,需配置 embedding provider)
- 合并去重:取最高分,结果标记
source: 'keyword' | 'vector' | 'hybrid'
import { retrieve } from './src/retriever.js';
const results = await retrieve({
fragments,
query: 'knowledge graph',
embeddingProvider: mockProvider, // 传 null 则仅关键词召回
limit: 10
});
// results: [{ fragmentId, documentId, documentTitle, score, text, source }]
数据模型
Document
{
"id": "doc_xxxxx",
"type": "document",
"title": "我的笔记",
"sourceType": "note",
"sourceUri": "/path/to/file.md",
"importedAt": "2026-04-04T...",
"status": "active"
}
Fragment
{
"id": "frag_xxxxx",
"type": "fragment",
"documentId": "doc_xxxxx",
"index": 0,
"text": "LinkMind 是...",
"summary": "LinkMind 是...",
"conceptNames": ["linkmind", "知识连接", "知识中枢"]
}
Concept
{
"id": "concept_xxxxx",
"type": "concept",
"name": "LinkMind",
"normalizedName": "linkmind",
"salience": 0.67
}
LinkEdge
{
"id": "link_xxxxx",
"type": "mentions",
"fromId": "frag_xxxxx",
"fromType": "fragment",
"toId": "concept_xxxxx",
"toType": "concept",
"score": 2
}
自测方法
cd skills/linkmind
node tests/smoke-test.js
目录结构
skills/linkmind/
├── SKILL.md
├── README.md
├── package.json
├── src/
│ ├── index.js # CLI 入口
│ ├── retriever.js # 双层检索
│ ├── storage-adapters/
│ │ ├── StorageAdapter.js # 接口契约
│ │ ├── JsonStorageAdapter.js # JSON 文件实现
│ │ ├── SqliteStorageAdapter.js # SQLite 实现
│ │ └── index.js # Factory
│ ├── embedding-providers/
│ │ ├── EmbeddingProvider.js # 接口契约
│ │ ├── MockProvider.js # 随机向量(测试用)
│ │ ├── OpenAICompatibleProvider.js # OpenAI 兼容 API
│ │ └── index.js # Factory
│ └── utils/
│ └── nlp.js # normalizeConcept 工具
├── dist/
│ └── index.js
├── data/
│ └── workspace.json
├── tests/
│ └── smoke-test.js # Phase 2 覆盖 38 项检查
└── examples/
└── sample-note.md
Phase 2 交付清单
- StorageAdapter 接口契约
- JsonStorageAdapter(向后兼容)
- SqliteStorageAdapter(基于 better-sqlite3)
- EmbeddingProvider 接口契约
- MockProvider(确定性随机、缓存、L2归一化)
- OpenAICompatibleProvider(支持自定义 baseURL/apiKey/model)
- retriever.js:关键词+向量双层召回 + 余弦相似度 ranker + merge 去重
- smoke-test.js Phase 2 全覆盖(38项检查全部通过)
- SKILL.md 更新
待后续实现
- ⏳ index.js 接入 adapter 层(DI 注入,支持 --storage=json|sqlite)
- ⏳ 向量批量预计算 + 离线向量存储
- ⏳ 图数据库存储(Neo4j)
- ⏳ Web/开放 API 接口
- ⏳ 多种来源接入(飞书、Notion、URL 抓取)
- ⏳ 证据冲突检测
安全使用建议
This package appears to do what it says: it ingests local files, builds fragments/concepts/links, stores them in data/workspace.json (or SQLite), and can call an external embedding API if you configure the OpenAI-compatible provider. Before installing or running: 1) Review the included files (notably data/workspace.json and tests) because the bundle includes a workspace file that contains an absolute local path and the smoke-test script — these may contain sensitive paths or test content from the author. 2) If you use the OpenAICompatibleProvider, be aware that text will be sent to the configured baseURL and that you must supply any API key yourself; prefer a self-hosted baseURL (vLLM/Ollama) if you want to avoid sending data to third-party clouds. 3) The smoke test uses child_process.execSync to run the CLI — running the tests executes the shipped code (ingest/reset/query) which will read/write files under the skill directory; run in a sandbox if you need extra isolation. 4) If you plan to use SQLite, the adapter requires a native module (better-sqlite3) which you must install; this is optional. If you want further assurance, inspect src/ and dist/ files listed here (they are plain JS, not obfuscated) or run the test in an isolated environment.
功能分析
Type: OpenClaw Skill
Name: linkmind-kb
Version: 1.0.0
The LinkMind skill bundle is a localized knowledge management CLI tool designed for document ingestion, concept extraction, and retrieval using keyword and vector search. It implements a modular architecture with storage adapters (JSON and SQLite) and embedding providers (Mock and OpenAI-compatible). Analysis of the source code (dist/index.js, dist/storage-adapters/, and dist/embedding-providers/) reveals standard Node.js patterns for file I/O and API interaction consistent with its stated purpose. No evidence of data exfiltration, malicious execution, or harmful prompt injection was found.
能力评估
Purpose & Capability
The name/description (local knowledge connector with storage adapters and embedding providers) matches the code and SKILL.md. The code implements JSON and SQLite storage adapters, mock and OpenAI-compatible embedding providers, fragment/concept/link building, and a CLI. No unexpected cloud SDKs or unrelated credentials are requested.
Instruction Scope
Runtime instructions and the CLI operate on local files (data/workspace.json, examples/…), perform ingest/query/status/reset, and run tests that invoke the CLI via child_process.execSync (tests/smoke-test.js). The skill will read and write files inside the skill data directory. If you enable the OpenAICompatibleProvider (or pass a baseURL), the skill will POST plaintext to that external endpoint; this is expected given the stated purpose but is the primary external-data flow to be aware of.
Install Mechanism
This is an instruction-only skill with source files included; there is no network-based install step. The bundle does not download arbitrary archives or run remote installers. The only optional native dependency is better-sqlite3 (or sqlite3), which is referenced in code and will only be required/used if you choose the sqlite adapter.
Credentials
The skill declares no required environment variables. This is consistent because embedding use is optional and the OpenAI-compatible provider accepts apiKey/baseURL via constructor/options rather than fixed env vars. Note: if you opt to use the OpenAICompatibleProvider you will need to provide an API key or baseURL (and that will send text to the configured endpoint). The package does not request unrelated secrets or system credentials.
Persistence & Privilege
The skill does not request always:true and is user-invocable only. It stores data under its data/ directory (workspace.json or db.sqlite) and does not modify other skills or system-wide agent configuration. The CLI and adapters only operate within the skill workspace.
如何使用
- 确保已安装 OpenClaw(本地或 Docker 部署)
- 在对话框中输入安装命令:
/install linkmind-kb - 安装完成后,直接呼叫该 Skill 的名称或使用
/linkmind-kb触发 - 根据 Skill 的参数说明提供必要输入,即可获得结构化输出
版本历史
v1.0.0
LinkMind 知识连接引擎 1.0.0 发布,新增抽象存储和嵌入适配器,支持关键词+向量召回检索。
- 引入 Storage Adapter 抽象层,默认支持 JSON,新增高性能 Sqlite 存储
- 引入 Embedding Provider 抽象层,支持 MockProvider(离线测试)/OpenAI 兼容 API
- 检索器支持关键词+向量(余弦相似度)双路召回,合并去重
- 完全兼容 Phase 1 JSON 数据,无需迁移
- 自测脚本新增 38 项全覆盖测试
- 文档与 CLI 使用说明同步更新
元数据
常见问题
Linkmind 是什么?
LinkMind 知识连接引擎 Phase 2 - 本地化知识中枢 CLI 工具,支持 storage adapter 抽象层和 OpenAI-compatible embedding provider。 它是一个面向 Claude Code / OpenClaw 的 AI Agent Skill 插件,目前累计下载 88 次。
如何安装 Linkmind?
在 OpenClaw 或 Claude Code 对话框中运行命令「/install linkmind-kb」即可一键安装,无需额外配置。
Linkmind 是免费的吗?
是的,Linkmind 完全免费,采用 MIT-0 许可证,可自由下载、安装和使用。
Linkmind 支持哪些平台?
Linkmind 跨平台运行,可在任意部署了 OpenClaw / Claude Code 的环境中使用(cross-platform)。
谁开发了 Linkmind?
由 haidong(@harrylabsj)开发并维护,当前版本 v1.0.0。
推荐 Skills