/SKILL.md
思源笔记查询工具,如果用户的请求涉及查找、检索、浏览他们的笔记内容,就应该使用这个技能,例如:查询我的xxx
npx skillsauth add 2234839/siyuan-notes-skill siyuan-notesInstall this skill globally with one command. Works with Claude Code, Cursor, and Windsurf.
4 of 9 scanners reported clean
Some scanners were skipped, did not run, or reported a non-clean status. Review each row below.
默认查询 markdown 字段(源码),而不是 content(纯文本)
原因:
markdown 包含完整的格式标记(如 [x]、[ ]、#、* 等)[x] = 完成,[ ] = 未完成)示例:
-- ✅ 推荐:查询 markdown 字段
SELECT id, markdown, updated FROM blocks WHERE markdown LIKE '%[x]%'
-- ❌ 不推荐:只查询 content 字段(会丢失格式信息)
SELECT id, content, updated FROM blocks WHERE content LIKE '%完成%'
# 全文搜索(推荐,支持中文分词,返回格式化字符串)
node -e "const s = require('./index.js'); (async () => { console.log(await s.searchNotes('关键词', 20)); })();"
# 按类型搜索(只搜索标题)
node -e "const s = require('./index.js'); (async () => { console.log(await s.searchNotes('关键词', 10, 'h')); })();"
# 翻页(第2页)
node -e "const s = require('./index.js'); (async () => { console.log(await s.searchNotes('关键词', 20, null, 2)); })();"
返回格式:
📄 [文档ID] /路径 > [类型 块ID] 内容📄 [文档ID] /路径
1. [类型 块ID] 内容
2. [类型 块ID] 内容
...[x]、[ ]、# 等)# 获取指定块的内容(返回 kramdown 源码,文档块包含反向链接)
node -e "const s = require('./index.js'); (async () => { console.log(await s.getBlockByID('块ID')); })();"
# 获取资源文件(图片、附件等)的本地完整路径
node -e "const s = require('./index.js'); (async () => {
const path = await s.getLocalAssetPath('块ID', 'assets/image-xxx.webp');
console.log(path);
})();"
返回示例:
./.tmp/assets/image-20251223152400-195ojeh.webp
使用场景:
# 提取指定块中所有的资源文件路径
node -e "const s = require('./index.js'); (async () => {
const assets = await s.extractAssetsFromBlock('块ID');
console.log(assets);
})();"
返回格式:
[
{
"path": "assets/image-20251223151651-8wilav6.webp",
"type": "image"
}
]
# SQL查询(返回精简后的原始数据数组,包含 markdown 字段)
node -e "const s = require('./index.js'); (async () => { console.log(await s.executeSiyuanQuery('SELECT id, markdown, updated FROM blocks WHERE markdown LIKE \\\"%关键词%\\\" LIMIT 10')); })();"
h-标题 p-段落 d-文档 l-列表 c-代码 t-表格 b-引用
使用绝对路径引用 index.js,避免路径问题
# 查询最近的工作待办(按更新时间倒序,包含 markdown 格式)
node -e "const s = require('./index.js'); (async () => {
const results = await s.executeSiyuanQuery(\"SELECT id, markdown, updated FROM blocks WHERE markdown LIKE '%#工作/todo#%' ORDER BY updated DESC LIMIT 30\");
results.forEach((r, i) => {
const date = r.updated.slice(0, 8);
const md = r.markdown.substring(0, 100);
console.log(\`\${i+1}. [\${date}] \${md}\`);
});
})();"
# 查询最近完成的任务([x] 标记)
node -e "const s = require('./index.js'); (async () => {
const results = await s.executeSiyuanQuery(\"SELECT id, markdown, updated FROM blocks WHERE markdown LIKE '%[x]%' ORDER BY updated DESC LIMIT 20\");
results.forEach((r, i) => {
const date = r.updated.slice(0, 8);
console.log(\`\${i+1}. [\${date}] \${r.markdown.substring(0, 80)}\`);
});
})();"
# 查询最近未完成的任务([ ] 标记)
node -e "const s = require('./index.js'); (async () => {
const results = await s.executeSiyuanQuery(\"SELECT id, markdown, updated FROM blocks WHERE markdown LIKE '%[ ]%' ORDER BY updated DESC LIMIT 20\");
results.forEach((r, i) => {
const date = r.updated.slice(0, 8);
console.log(\`\${i+1}. [\${date}] \${r.markdown.substring(0, 80)}\`);
});
})();"
持续尝试,直到解决用户问题:
| 用户查询 | 可尝试的关键词 |
|---------|--------------|
| 图片压缩 | 压缩、优化、减小、webp、图片处理 |
| 工作总结 | 总结、周报、月报、汇报、复盘 |
| bug修复 | bug、修复、问题、issue、调试 |
| 学习笔记 | 学习、笔记、记录、整理、心得 |
| 已完成任务 | [x]、完成、done |
id: 块ID | type: 块类型(d/h/p/l/c/t/b) | subtype: 子类型content: 纯文本 | markdown: Markdown文本(推荐)| hpath: 人类可读路径created/updated: 创建/更新时间 (YYYYMMDDHHmmss)root_id: 所属文档ID | parent_id: 父块ID | box: 笔记本ID-- ✅ 推荐:查询 markdown 字段
SELECT id, markdown, updated FROM blocks WHERE markdown LIKE '%关键词%'
-- 查询已完成的任务
SELECT id, markdown, updated FROM blocks WHERE markdown LIKE '%[x]%'
-- 查询未完成的任务
SELECT id, markdown, updated FROM blocks WHERE markdown LIKE '%[ ]%'
-- 查询最近7天
SELECT id, markdown, updated FROM blocks WHERE updated > strftime('%Y%m%d%H%M%S', datetime('now', '-7 day'))
-- 查询反向链接
SELECT id, markdown FROM blocks WHERE id IN (SELECT block_id FROM refs WHERE def_block_id='块ID')
配置文件: skills/siyuan/.env
更可视化,推荐使用!
# 排除的笔记路径(多个用逗号分隔,包含子笔记)
# 示例:排除敏感笔记及其所有子笔记
SIYUAN_EXCLUDE_PATHS=/私密笔记,/个人日记
特点:
/私密笔记 比 ID 更易读)/私密笔记/子笔记1、/私密笔记/子笔记2 等)如何查找路径:
# 搜索特定关键词,查看返回的路径
node -e "const s = require('./index.js'); (async () => { console.log(await s.searchNotes('关键词', 10)); })();"
# 排除的笔记本ID(多个用逗号分隔)
# 示例:排除敏感笔记本
SIYUAN_EXCLUDE_BOXES=20210816161940-xxxxxxx
如何获取笔记本 ID:
# 查询所有笔记本
node -e "const s = require('./index.js'); (async () => {
const results = await s.executeSiyuanQuery(\"SELECT DISTINCT box FROM blocks LIMIT 20\");
console.log(results);
})();"
本工具在 API 层面实现了内容过滤,确保敏感内容不会被查询到:
SQL 查询:
-- 原始查询
SELECT * FROM blocks WHERE content LIKE '%关键词%'
-- 自动修改为(排除笔记本)
SELECT * FROM blocks WHERE box NOT IN ('笔记本ID') AND content LIKE '%关键词%'
-- 自动修改为(排除路径)
SELECT * FROM blocks WHERE hpath NOT LIKE '/排除路径%' AND content LIKE '%关键词%'
全文搜索:
使用场景:
tools
Use when work should span one or more detached tasks but still behave like one job with a single owner context. TaskFlow is the durable flow substrate under authoring layers like Lobster, ACPX, plugins, or plain code. Keep conditional logic in the caller; use TaskFlow for flow identity, child-task linkage, waiting state, revision-checked mutations, and user-facing emergence.
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
# Lobster Lobster executes multi-step workflows with approval checkpoints. Use it when: - User wants a repeatable automation (triage, monitor, sync) - Actions need human approval before executing (send, post, delete) - Multiple tool calls should run as one deterministic operation ## When to use Lobster | User intent | Use Lobster? | | ------------------------------------------------------ | --------------------------
tools
A CLI tool for making authenticated requests to the X (Twitter) API. Use this skill when you need to post tweets, reply, quote, search, read posts, manage followers, send DMs, upload media, or interact with any X API v2 endpoint.