pkm
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChinesePKM - Personal Knowledge Management Skill
PKM - 个人知识管理工具使用指南
You are a specialist in using , a Personal Knowledge Management system that provides a knowledge layer between Claude Code (MCP) and lancer/LanceDB. PKM offers temporal awareness, quality filtering, token-efficient search, and document curation tools for managing workspace knowledge.
pkm您是使用的专家,是一个个人知识管理系统,在Claude Code(MCP)与lancer/LanceDB之间提供知识层。PKM具备时间感知、质量过滤、高效Token搜索以及文档整理工具,用于管理工作区知识。
pkmpkmWhat is PKM?
什么是PKM?
pkm- Temporal awareness: Track document freshness and identify stale content
- Quality filtering: Filter by certainty level and information type (facts, analysis, ideas)
- Hybrid search: Combines vector (semantic) and BM25 (full-text) search
- Relationship tracking: Document wikilinks, references, and backlinks
- Quality audits: Systematic review of knowledge base quality
- LSP server: Wikilink autocomplete in editors
- MCP integration: Claude Desktop integration for intelligent search
pkm- 时间感知:追踪文档新鲜度,识别过时内容
- 质量过滤:按确定性级别和信息类型(事实、分析、想法)过滤
- 混合搜索:结合向量(语义)和BM25(全文)搜索
- 关系追踪:记录文档维基链接、引用和反向链接
- 质量审计:系统化审查知识库质量
- LSP服务器:编辑器中的维基链接自动补全
- MCP集成:Claude Desktop集成,实现智能搜索
Core Capabilities
核心功能
- Index: Index workspace documents (titles and/or content)
- Search: Search with quality filters (certainty, info type, freshness)
- Relationships: Track document relationships and wikilinks
- Backlinks: Query what links to a document
- Quality Audit: Review and improve knowledge base quality
- Stats: Analyze indexed content statistics
- LSP/MCP: Editor integration and Claude Desktop integration
- 索引:为工作区文档(标题和/或内容)建立索引
- 搜索:使用质量过滤器(确定性、信息类型、新鲜度)进行搜索
- 关系追踪:记录文档关系和维基链接
- 反向链接:查询哪些文档链接到目标文档
- 质量审计:审查并提升知识库质量
- 统计:分析已索引内容的统计数据
- LSP/MCP集成:编辑器集成与Claude Desktop集成
Quick Start
快速开始
Basic Search
基础搜索
bash
undefinedbash
undefinedSearch workspace documents
搜索工作区文档
pkm search "kubernetes deployment strategies"
pkm search "kubernetes deployment strategies"
Search with quality filters
使用质量过滤器搜索
pkm search --facts-only --fresh-only "API authentication"
pkm search --facts-only --fresh-only "API authentication"
Search with result limit
限制搜索结果数量
pkm search -n 5 "error handling patterns"
undefinedpkm search -n 5 "error handling patterns"
undefinedBasic Indexing
基础索引
bash
undefinedbash
undefinedIndex current directory (both titles and content)
为当前目录建立索引(包含标题和内容)
pkm index
pkm index
Index specific directory
为指定目录建立索引
pkm index ~/Documents/notes/
pkm index ~/Documents/notes/
Index specific files
为指定文件建立索引
pkm index note1.md note2.md
undefinedpkm index note1.md note2.md
undefinedDocument Indexing
文档索引
Index Command Options
索引命令选项
bash
undefinedbash
undefinedIndex both titles and content (default)
为标题和内容建立索引(默认)
pkm index ./notes/
pkm index ./notes/
Index only titles (LSP autocomplete)
仅为标题建立索引(用于LSP自动补全)
pkm index --titles-only ./notes/
pkm index --titles-only ./notes/
Index only content (search)
仅为内容建立索引(用于搜索)
pkm index --content-only ./notes/
pkm index --content-only ./notes/
Index to specific table
为指定表建立索引
pkm index --table my_knowledge ./notes/
pkm index --table my_knowledge ./notes/
Index specific file extensions
为指定文件扩展名建立索引
pkm index --extensions md,txt,pdf ./documents/
pkm index --extensions md,txt,pdf ./documents/
Force re-index
强制重新索引
pkm index --force ./notes/
undefinedpkm index --force ./notes/
undefinedIndex from stdin
从标准输入建立索引
bash
undefinedbash
undefinedPipe file paths to index
管道传递文件路径进行索引
find ~/Documents -name "*.md" -mtime -7 | pkm index --stdin
find ~/Documents -name "*.md" -mtime -7 | pkm index --stdin
From git changed files
从Git变更文件中索引
git diff --name-only main | grep ".md$" | pkm index --stdin
undefinedgit diff --name-only main | grep ".md$" | pkm index --stdin
undefinedIndex Modes
索引模式
Hybrid index (default):
bash
undefined混合索引(默认):
bash
undefinedVector + BM25 full-text search
向量+BM25全文搜索
pkm index ./notes/
**Vector-only index:**
```bashpkm index ./notes/
**仅向量索引:**
```bashSkip BM25 (faster indexing, semantic search only)
跳过BM25(索引速度更快,仅支持语义搜索)
pkm index --no-hybrid ./notes/
undefinedpkm index --no-hybrid ./notes/
undefinedIndex Management
索引管理
bash
undefinedbash
undefinedQuiet mode (suppress progress)
静默模式(抑制进度输出)
pkm index --quiet ./large-corpus/
pkm index --quiet ./large-corpus/
Dry run (see what would be indexed)
试运行(查看将被索引的内容)
pkm index --dry-run ./notes/
pkm index --dry-run ./notes/
Verbose logging
详细日志
pkm index -v ./notes/
undefinedpkm index -v ./notes/
undefinedSearch Operations
搜索操作
Search Command Options
搜索命令选项
bash
undefinedbash
undefinedBasic search
基础搜索
pkm search "machine learning algorithms"
pkm search "machine learning algorithms"
Limit results
限制结果数量
pkm search -n 10 "API design patterns"
pkm search -n 10 "API design patterns"
Set minimum score threshold
设置最低分数阈值
pkm search --min-score 0.1 "database optimization"
pkm search --min-score 0.1 "database optimization"
Specify database path
指定数据库路径
pkm search --db-path ~/my-db "query"
pkm search --db-path ~/my-db "query"
Specify workspace root
指定工作区根目录
pkm search --workspace-root ~/Documents "query"
pkm search --workspace-root ~/Documents "query"
Custom table name
自定义表名称
pkm search --table-name custom_table "query"
undefinedpkm search --table-name custom_table "query"
undefinedQuality Filters
质量过滤器
Filter by information type:
bash
undefined按信息类型过滤:
bash
undefinedShow only facts
仅显示事实
pkm search --info-type fact "kubernetes architecture"
pkm search --facts-only "docker commands"
pkm search --info-type fact "kubernetes architecture"
pkm search --facts-only "docker commands"
Show only analysis
仅显示分析内容
pkm search --info-type analysis "performance bottlenecks"
pkm search --info-type analysis "performance bottlenecks"
Show only ideas
仅显示想法
pkm search --info-type idea "feature proposals"
**Filter by certainty:**
```bashpkm search --info-type idea "feature proposals"
**按确定性过滤:**
```bashHigh certainty only
仅显示高确定性内容
pkm search --certainty high "security best practices"
pkm search --certainty high "security best practices"
Medium certainty
中等确定性内容
pkm search --certainty medium "migration strategies"
pkm search --certainty medium "migration strategies"
Low certainty (speculative)
低确定性内容(推测性)
pkm search --certainty low "future trends"
**Filter by freshness:**
```bashpkm search --certainty low "future trends"
**按新鲜度过滤:**
```bashMaximum age in days
最大文档年龄(天)
pkm search --max-age 30 "recent updates"
pkm search --max-age 30 "recent updates"
Only fresh documents
仅显示新鲜文档
pkm search --fresh-only "current status"
pkm search --fresh-only "current status"
Exclude stale documents
排除过时文档
pkm search --exclude-stale "active projects"
undefinedpkm search --exclude-stale "active projects"
undefinedCombined Filters
组合过滤器
bash
undefinedbash
undefinedFacts from last 30 days
近30天内的事实内容
pkm search
--facts-only
--max-age 30
"authentication implementation"
--facts-only
--max-age 30
"authentication implementation"
pkm search
--facts-only
--max-age 30
"authentication implementation"
--facts-only
--max-age 30
"authentication implementation"
High certainty analysis (fresh)
高确定性的新鲜分析内容
pkm search
--info-type analysis
--certainty high
--fresh-only
"performance optimization"
--info-type analysis
--certainty high
--fresh-only
"performance optimization"
pkm search
--info-type analysis
--certainty high
--fresh-only
"performance optimization"
--info-type analysis
--certainty high
--fresh-only
"performance optimization"
Recent ideas with threshold
近14天内的想法内容(带分数阈值)
pkm search
--info-type idea
--max-age 14
--min-score 0.15
-n 5
"feature enhancements"
--info-type idea
--max-age 14
--min-score 0.15
-n 5
"feature enhancements"
undefinedpkm search
--info-type idea
--max-age 14
--min-score 0.15
-n 5
"feature enhancements"
--info-type idea
--max-age 14
--min-score 0.15
-n 5
"feature enhancements"
undefinedOutput Formats
输出格式
bash
undefinedbash
undefinedText output (default)
文本输出(默认)
pkm search "query"
pkm search "query"
JSON output for scripting
JSON输出(用于脚本)
pkm search --output json "query" | jq '.results[] | .path'
pkm search --output json "query" | jq '.results[] | .path'
Verbose logging
详细日志
pkm search -v "query"
undefinedpkm search -v "query"
undefinedRelationship Tracking
关系追踪
Query Outgoing Relationships
查询外向关系
bash
undefinedbash
undefinedShow all links from a document
显示文档的所有链接
pkm relationships --source notes/architecture.md
pkm relationships --source notes/architecture.md
Filter by relationship type
按关系类型过滤
pkm relationships --source notes/api.md --rel-type wikilink
pkm relationships --source notes/api.md --rel-type wikilink
JSON output
JSON输出
pkm relationships --source notes/design.md --output json
undefinedpkm relationships --source notes/design.md --output json
undefinedQuery Backlinks
查询反向链接
bash
undefinedbash
undefinedShow what links to a document
显示哪些文档链接到目标文档
pkm backlinks notes/concepts/auth.md
pkm backlinks notes/concepts/auth.md
Filter by relationship type
按关系类型过滤
pkm backlinks notes/api-spec.md --rel-type reference
pkm backlinks notes/api-spec.md --rel-type reference
JSON output
JSON输出
pkm backlinks notes/design.md --output json
undefinedpkm backlinks notes/design.md --output json
undefinedRelationship Use Cases
关系追踪使用场景
bash
undefinedbash
undefinedFind related documents
查找相关文档
pkm relationships --source current-work.md
pkm relationships --source current-work.md
Discover document impact
发现文档影响范围
pkm backlinks important-concept.md
pkm backlinks important-concept.md
Build knowledge graph
构建知识图谱
pkm relationships --source index.md --output json |
jq '.relationships[] | .target'
jq '.relationships[] | .target'
pkm relationships --source index.md --output json |
jq '.relationships[] | .target'
jq '.relationships[] | .target'
Find orphaned documents (no backlinks)
查找孤立文档(无反向链接)
pkm backlinks my-note.md | grep -q "No backlinks" &&
echo "Orphaned document"
echo "Orphaned document"
undefinedpkm backlinks my-note.md | grep -q "No backlinks" &&
echo "Orphaned document"
echo "Orphaned document"
undefinedIndex a Single Document
为单个文档建立索引
bash
undefinedbash
undefinedIndex document for relationship tracking
为文档建立索引以追踪关系
pkm index-doc notes/new-concept.md
pkm index-doc notes/new-concept.md
With custom database
使用自定义数据库
pkm index-doc --db-path ~/kb notes/article.md
pkm index-doc --db-path ~/kb notes/article.md
Verbose output
详细输出
pkm index-doc -v notes/research.md
undefinedpkm index-doc -v notes/research.md
undefinedQuality Management
质量管理
Quality Audit
质量审计
bash
undefinedbash
undefinedAudit entire workspace
审计整个工作区
pkm quality-audit
pkm quality-audit
Audit specific area/topic
审计特定领域/主题
pkm quality-audit --area kubernetes
pkm quality-audit --area kubernetes
JSON output
JSON输出
pkm quality-audit --output json
pkm quality-audit --output json
Verbose audit
详细审计
pkm quality-audit -v
**What quality-audit checks:**
- Documents missing quality metadata
- Stale documents needing updates
- Low certainty information
- Missing or unclear info types
- Document completenesspkm quality-audit -v
**quality-audit检查内容:**
- 缺少质量元数据的文档
- 需要更新的过时文档
- 低确定性信息
- 缺失或不明确的信息类型
- 文档完整性Find Stale Documents
查找过时文档
bash
undefinedbash
undefinedFind documents exceeding freshness threshold
查找超过新鲜度阈值的文档
pkm find-stale
pkm find-stale
With workspace root
指定工作区根目录
pkm find-stale --workspace-root ~/Documents/notes
pkm find-stale --workspace-root ~/Documents/notes
Verbose output
详细输出
pkm find-stale -v
undefinedpkm find-stale -v
undefinedVerification Queue
验证队列
bash
undefinedbash
undefinedShow documents needing review
显示需要审查的文档
pkm verify-queue
pkm verify-queue
With specific workspace
指定工作区
pkm verify-queue --workspace-root ~/kb
pkm verify-queue --workspace-root ~/kb
Verbose output
详细输出
pkm verify-queue -v
undefinedpkm verify-queue -v
undefinedStatistics and Analysis
统计与分析
Workspace Statistics
工作区统计
bash
undefinedbash
undefinedShow basic stats
显示基础统计数据
pkm stats
pkm stats
Detailed breakdown by file extension
按文件扩展名细分的详细统计
pkm stats -d
pkm stats -d
Detailed stats with custom database
自定义数据库的详细统计
pkm stats --db-path ~/my-kb -d
pkm stats --db-path ~/my-kb -d
JSON output
JSON输出
pkm stats --output json
**Stats include:**
- Total documents indexed
- Document counts by type
- Table information
- Embedding models used
- Index sizespkm stats --output json
**统计内容包括:**
- 已索引文档总数
- 按类型划分的文档数量
- 表信息
- 使用的嵌入模型
- 索引大小Table Management
表管理
List Tables
列出表
bash
undefinedbash
undefinedList all tables in database
列出数据库中的所有表
pkm tables
pkm tables
With custom database path
指定自定义数据库路径
pkm tables --db-path ~/my-kb
pkm tables --db-path ~/my-kb
Verbose output
详细输出
pkm tables -v
undefinedpkm tables -v
undefinedServer Modes
服务器模式
LSP Server (Wikilink Autocomplete)
LSP服务器(维基链接自动补全)
bash
undefinedbash
undefinedStart LSP server for editor integration
启动LSP服务器用于编辑器集成
pkm lsp
pkm lsp
With verbose logging
详细日志
pkm lsp -v
**Purpose**: Provides wikilink autocomplete in editors (VSCode, Neovim, etc.)pkm lsp -v
**用途**:在编辑器(VSCode、Neovim等)中提供维基链接自动补全MCP Server (Claude Desktop)
MCP服务器(Claude Desktop)
bash
undefinedbash
undefinedStart MCP server
启动MCP服务器
pkm mcp
pkm mcp
With verbose logging
详细日志
pkm mcp -v
**Purpose**: Integrates PKM search into Claude Desktop for intelligent document retrieval.pkm mcp -v
**用途**:将PKM搜索集成到Claude Desktop中,实现智能文档检索Environment Variables
环境变量
bash
undefinedbash
undefinedSet default database path
设置默认数据库路径
export PKM_DB_PATH=~/my-knowledge-base
pkm search "query"
export PKM_DB_PATH=~/my-knowledge-base
pkm search "query"
Set workspace root
设置工作区根目录
export PKM_ROOT=~/Documents/notes
pkm index
export PKM_ROOT=~/Documents/notes
pkm index
Both together
同时设置两者
export PKM_DB_PATH=/kb
export PKM_ROOT=/notes
pkm search "query"
undefinedexport PKM_DB_PATH=/kb
export PKM_ROOT=/notes
pkm search "query"
undefinedCommon Workflows
常见工作流
Workflow 1: Initial Workspace Setup
工作流1:初始工作区设置
bash
undefinedbash
undefined1. Index your workspace
1. 为工作区建立索引
cd ~/Documents/notes
pkm index
cd ~/Documents/notes
pkm index
2. Check statistics
2. 查看统计数据
pkm stats -d
pkm stats -d
3. Test search
3. 测试搜索
pkm search "recent projects"
pkm search "recent projects"
4. Run quality audit
4. 运行质量审计
pkm quality-audit
undefinedpkm quality-audit
undefinedWorkflow 2: Daily Knowledge Work
工作流2:日常知识管理
bash
undefinedbash
undefined1. Find stale documents to review
1. 查找需要审查的过时文档
pkm find-stale
pkm find-stale
2. Search for high-quality facts
2. 搜索高质量事实内容
pkm search --facts-only --certainty high "project status"
pkm search --facts-only --certainty high "project status"
3. Index new/modified documents
3. 为新修改的文档建立索引
find . -name "*.md" -mtime -1 | pkm index --stdin
find . -name "*.md" -mtime -1 | pkm index --stdin
4. Check relationships
4. 检查文档关系
pkm relationships --source today-notes.md
undefinedpkm relationships --source today-notes.md
undefinedWorkflow 3: Research and Analysis
工作流3:研究与分析
bash
undefinedbash
undefined1. Search for recent analysis
1. 搜索近30天内的分析内容
pkm search
--info-type analysis
--max-age 30
--certainty high
-n 20
"performance optimization"
--info-type analysis
--max-age 30
--certainty high
-n 20
"performance optimization"
pkm search
--info-type analysis
--max-age 30
--certainty high
-n 20
"performance optimization"
--info-type analysis
--max-age 30
--certainty high
-n 20
"performance optimization"
2. Find related documents
2. 查找相关文档
pkm relationships --source research-notes.md
pkm relationships --source research-notes.md
3. Discover citations
3. 发现引用关系
pkm backlinks key-concept.md
pkm backlinks key-concept.md
4. Export for review
4. 导出结果用于审查
pkm search --output json "research topic" |
jq '.results[] | {path, score, summary}' > research.json
jq '.results[] | {path, score, summary}' > research.json
undefinedpkm search --output json "research topic" |
jq '.results[] | {path, score, summary}' > research.json
jq '.results[] | {path, score, summary}' > research.json
undefinedWorkflow 4: Knowledge Base Maintenance
工作流4:知识库维护
bash
undefinedbash
undefined1. Find documents needing review
1. 查找需要审查的文档
pkm verify-queue
pkm verify-queue
2. Run quality audit
2. 运行质量审计并导出结果
pkm quality-audit --output json > audit-results.json
pkm quality-audit --output json > audit-results.json
3. Find stale content
3. 查找过时内容
pkm find-stale
pkm find-stale
4. Re-index updated documents
4. 为更新的文档重新建立索引
pkm index --force ./updated-notes/
pkm index --force ./updated-notes/
5. Verify improvements
5. 验证改进效果
pkm stats -d
undefinedpkm stats -d
undefinedWorkflow 5: Incremental Updates
工作流5:增量更新
bash
undefinedbash
undefined1. Find recently modified files
1. 查找最近修改的文件
find ~/notes -name "*.md" -mtime -7 > recent.txt
find ~/notes -name "*.md" -mtime -7 > recent.txt
2. Index only recent changes
2. 仅为最近变更建立索引
pkm index --stdin < recent.txt
pkm index --stdin < recent.txt
3. Search fresh content
3. 搜索新鲜内容
pkm search --max-age 7 "latest updates"
pkm search --max-age 7 "latest updates"
4. Update statistics
4. 更新统计数据
pkm stats -d
undefinedpkm stats -d
undefinedWorkflow 6: Integration with Git
工作流6:与Git集成
bash
undefinedbash
undefinedIndex files changed in current branch
为当前分支中变更的文件建立索引
git diff --name-only main |
grep ".md$" |
pkm index --stdin
grep ".md$" |
pkm index --stdin
git diff --name-only main |
grep ".md$" |
pkm index --stdin
grep ".md$" |
pkm index --stdin
Index uncommitted changes
为未提交的变更建立索引
git diff --name-only |
grep ".md$" |
pkm index --stdin
grep ".md$" |
pkm index --stdin
git diff --name-only |
grep ".md$" |
pkm index --stdin
grep ".md$" |
pkm index --stdin
Re-index entire repository
为整个仓库重新建立索引
pkm index --force .
undefinedpkm index --force .
undefinedBest Practices
最佳实践
1. Index Strategically
1. 策略性建立索引
Title indexing (fast, for autocomplete):
bash
pkm index --titles-only ~/notes/Content indexing (comprehensive, for search):
bash
pkm index --content-only ~/important-docs/Full indexing (both):
bash
pkm index ~/knowledge-base/标题索引(快速,用于自动补全):
bash
pkm index --titles-only ~/notes/内容索引(全面,用于搜索):
bash
pkm index --content-only ~/important-docs/完整索引(包含标题和内容):
bash
pkm index ~/knowledge-base/2. Use Quality Filters Effectively
2. 有效使用质量过滤器
For verified information:
bash
pkm search --facts-only --certainty high "API endpoints"For recent insights:
bash
pkm search --info-type analysis --max-age 14 "optimization"For brainstorming:
bash
pkm search --info-type idea --exclude-stale "features"用于已验证信息:
bash
pkm search --facts-only --certainty high "API endpoints"用于近期见解:
bash
pkm search --info-type analysis --max-age 14 "optimization"用于头脑风暴:
bash
pkm search --info-type idea --exclude-stale "features"3. Maintain Freshness
3. 保持内容新鲜度
bash
undefinedbash
undefinedRegular freshness check
定期检查新鲜度
pkm find-stale
pkm find-stale
Periodic re-indexing
定期重新索引
pkm index --force ./active-projects/
pkm index --force ./active-projects/
Exclude stale from searches
搜索时排除过时内容
pkm search --exclude-stale "current work"
undefinedpkm search --exclude-stale "current work"
undefined4. Track Relationships
4. 追踪文档关系
bash
undefinedbash
undefinedAfter creating new note with wikilinks
创建带维基链接的新笔记后
pkm index-doc new-note.md
pkm relationships --source new-note.md
pkm index-doc new-note.md
pkm relationships --source new-note.md
Understand impact before editing
编辑前了解文档影响范围
pkm backlinks important-concept.md
undefinedpkm backlinks important-concept.md
undefined5. Regular Quality Audits
5. 定期质量审计
bash
undefinedbash
undefinedWeekly audit
每周审计
pkm quality-audit --output json > audit-$(date +%Y%m%d).json
pkm quality-audit --output json > audit-$(date +%Y%m%d).json
Area-specific review
特定领域审查
pkm quality-audit --area architecture
pkm quality-audit --area architecture
Track verification queue
跟踪验证队列
pkm verify-queue
undefinedpkm verify-queue
undefined6. Organize with Extensions
6. 按扩展名组织
bash
undefinedbash
undefinedIndex markdown notes
为Markdown笔记建立索引
pkm index --extensions md ~/notes/
pkm index --extensions md ~/notes/
Include PDFs and markdown
包含PDF和Markdown文件
pkm index --extensions md,pdf ~/research/
pkm index --extensions md,pdf ~/research/
Text files only
仅为文本文件建立索引
pkm index --extensions txt ~/logs/
undefinedpkm index --extensions txt ~/logs/
undefined7. Use Appropriate Thresholds
7. 使用合适的分数阈值
Broad exploration:
bash
pkm search --min-score 0.05 "general topic"Balanced results:
bash
pkm search --min-score 0.1 "specific concept"High precision:
bash
pkm search --min-score 0.2 "exact information"广泛探索:
bash
pkm search --min-score 0.05 "general topic"平衡结果:
bash
pkm search --min-score 0.1 "specific concept"高精度搜索:
bash
pkm search --min-score 0.2 "exact information"Integration Setups
集成设置
Claude Desktop (MCP)
Claude Desktop(MCP)
Add to :
~/Library/Application Support/Claude/claude_desktop_config.jsonjson
{
"mcpServers": {
"pkm": {
"command": "pkm",
"args": ["mcp"],
"env": {
"PKM_ROOT": "/Users/username/Documents/notes",
"PKM_DB_PATH": "/Users/username/.pkm/db"
}
}
}
}添加到:
~/Library/Application Support/Claude/claude_desktop_config.jsonjson
{
"mcpServers": {
"pkm": {
"command": "pkm",
"args": ["mcp"],
"env": {
"PKM_ROOT": "/Users/username/Documents/notes",
"PKM_DB_PATH": "/Users/username/.pkm/db"
}
}
}
}VSCode (LSP)
VSCode(LSP)
- Start LSP server:
pkm lsp - Configure editor to connect to LSP endpoint
- Get wikilink autocomplete in markdown files
- 启动LSP服务器:
pkm lsp - 配置编辑器连接到LSP端点
- 在Markdown文件中使用维基链接自动补全
Advanced Usage
高级用法
Custom Database Locations
自定义数据库位置
bash
undefinedbash
undefinedWork with multiple knowledge bases
同时使用多个知识库
pkm search --db-path ~/work-kb "work queries"
pkm search --db-path ~/personal-kb "personal queries"
pkm search --db-path ~/work-kb "work queries"
pkm search --db-path ~/personal-kb "personal queries"
Separate workspace and database
分离工作区与数据库
pkm index
--workspace-root ~/Documents/notes
--db-path ~/kb/notes-index
--workspace-root ~/Documents/notes
--db-path ~/kb/notes-index
undefinedpkm index
--workspace-root ~/Documents/notes
--db-path ~/kb/notes-index
--workspace-root ~/Documents/notes
--db-path ~/kb/notes-index
undefinedScripting and Automation
脚本与自动化
bash
undefinedbash
undefinedDaily index automation
每日索引自动化脚本
#!/bin/bash
cd ~/notes
find . -name "*.md" -mtime -1 | pkm index --quiet --stdin
pkm stats --output json > ~/stats/$(date +%Y%m%d).json
#!/bin/bash
cd ~/notes
find . -name "*.md" -mtime -1 | pkm index --quiet --stdin
pkm stats --output json > ~/stats/$(date +%Y%m%d).json
Weekly quality report
每周质量报告脚本
#!/bin/bash
pkm quality-audit --output json > audit.json
pkm find-stale > stale.txt
pkm verify-queue > queue.txt
undefined#!/bin/bash
pkm quality-audit --output json > audit.json
pkm find-stale > stale.txt
pkm verify-queue > queue.txt
undefinedBatch Processing
批处理
bash
undefinedbash
undefinedProcess multiple directories
处理多个目录
for dir in ~/notes/*/; do
echo "Indexing $dir"
pkm index "$dir"
done
for dir in ~/notes/*/; do
echo "Indexing $dir"
pkm index "$dir"
done
Selective re-indexing
选择性重新索引
pkm stats --output json |
jq -r '.tables[] | select(.doc_count < 10) | .name' |
xargs -I {} pkm index --force --table {}
jq -r '.tables[] | select(.doc_count < 10) | .name' |
xargs -I {} pkm index --force --table {}
undefinedpkm stats --output json |
jq -r '.tables[] | select(.doc_count < 10) | .name' |
xargs -I {} pkm index --force --table {}
jq -r '.tables[] | select(.doc_count < 10) | .name' |
xargs -I {} pkm index --force --table {}
undefinedTroubleshooting
故障排除
Issue: Search returns no results
问题:搜索无结果
Solutions:
bash
undefined解决方案:
bash
undefinedCheck if content is indexed
检查内容是否已索引
pkm stats -d
pkm stats -d
Lower score threshold
降低分数阈值
pkm search --min-score 0.01 "query"
pkm search --min-score 0.01 "query"
Remove quality filters
移除质量过滤器
pkm search "query" # No filters
pkm search "query" # 无过滤器
Verify database path
验证数据库路径
pkm search --db-path ~/kb -v "query"
undefinedpkm search --db-path ~/kb -v "query"
undefinedIssue: Stale documents not detected
问题:未检测到过时文档
Solutions:
bash
undefined解决方案:
bash
undefinedForce re-index
强制重新索引
pkm index --force .
pkm index --force .
Check verbose output
查看详细输出
pkm find-stale -v
pkm find-stale -v
Verify workspace root
验证工作区根目录
pkm find-stale --workspace-root ~/notes
undefinedpkm find-stale --workspace-root ~/notes
undefinedIssue: Relationships not tracked
问题:关系未被追踪
Solutions:
bash
undefined解决方案:
bash
undefinedIndex document for relationships
为文档建立索引以追踪关系
pkm index-doc document.md
pkm index-doc document.md
Verbose indexing
详细索引
pkm index-doc -v document.md
pkm index-doc -v document.md
Re-index entire workspace
重新索引整个工作区
pkm index --force .
undefinedpkm index --force .
undefinedIssue: Poor search quality
问题:搜索质量差
Solutions:
bash
undefined解决方案:
bash
undefinedEnable hybrid search (vector + BM25)
启用混合搜索(向量+BM25)
pkm index . # Default is hybrid
pkm index . # 默认是混合模式
Adjust filters
调整过滤器
pkm search --min-score 0.05 "query"
pkm search --min-score 0.05 "query"
Check for sufficient indexed content
检查是否有足够的已索引内容
pkm stats -d
undefinedpkm stats -d
undefinedIssue: LSP/MCP not working
问题:LSP/MCP无法工作
Solutions:
bash
undefined解决方案:
bash
undefinedVerify server starts
验证服务器是否能启动
pkm lsp -v
pkm mcp -v
pkm lsp -v
pkm mcp -v
Check environment variables
检查环境变量
echo $PKM_ROOT
echo $PKM_DB_PATH
echo $PKM_ROOT
echo $PKM_DB_PATH
Restart server
重启服务器
pkill -f "pkm lsp"
pkm lsp -v
undefinedpkill -f "pkm lsp"
pkm lsp -v
undefinedQuick Reference
快速参考
bash
undefinedbash
undefinedIndexing
索引
pkm index # Index current directory
pkm index ~/notes/ # Index specific directory
pkm index --titles-only ~/notes/ # Titles only (LSP)
pkm index --force ~/notes/ # Force re-index
pkm index --extensions md,pdf ~/docs/ # Specific file types
pkm index # 为当前目录建立索引
pkm index ~/notes/ # 为指定目录建立索引
pkm index --titles-only ~/notes/ # 仅为标题建立索引(用于LSP)
pkm index --force ~/notes/ # 强制重新索引
pkm index --extensions md,pdf ~/docs/ # 为指定文件类型建立索引
Searching
搜索
pkm search "query" # Basic search
pkm search -n 10 "query" # Limit results
pkm search --facts-only "query" # Facts only
pkm search --fresh-only "query" # Fresh only
pkm search --certainty high "query" # High certainty
pkm search --max-age 30 "query" # Last 30 days
pkm search "query" # 基础搜索
pkm search -n 10 "query" # 限制结果数量
pkm search --facts-only "query" # 仅显示事实
pkm search --fresh-only "query" # 仅显示新鲜内容
pkm search --certainty high "query" # 仅显示高确定性内容
pkm search --max-age 30 "query" # 搜索近30天内的内容
Relationships
关系追踪
pkm relationships --source note.md # Show outgoing links
pkm backlinks note.md # Show incoming links
pkm index-doc note.md # Index for relationships
pkm relationships --source note.md # 显示外向链接
pkm backlinks note.md # 显示内向链接
pkm index-doc note.md # 为文档建立索引以追踪关系
Quality management
质量管理
pkm quality-audit # Audit workspace
pkm find-stale # Find stale documents
pkm verify-queue # Documents needing review
pkm stats -d # Detailed statistics
pkm quality-audit # 审计工作区
pkm find-stale # 查找过时文档
pkm verify-queue # 显示需要审查的文档
pkm stats -d # 查看详细统计数据
Servers
服务器
pkm mcp # Start MCP server
pkm lsp # Start LSP server
pkm mcp # 启动MCP服务器
pkm lsp # 启动LSP服务器
Output formats
输出格式
pkm search --output json "query" # JSON output
pkm stats --output json # JSON stats
pkm quality-audit --output json # JSON audit
undefinedpkm search --output json "query" # JSON输出
pkm stats --output json # JSON格式统计数据
pkm quality-audit --output json # JSON格式审计结果
undefinedCommon Patterns
常见模式
Pattern 1: Quick Fact Lookup
模式1:快速事实查询
bash
pkm search --facts-only --certainty high -n 5 "API authentication"bash
pkm search --facts-only --certainty high -n 5 "API authentication"Pattern 2: Recent Analysis
模式2:近期分析内容查询
bash
pkm search --info-type analysis --max-age 30 --fresh-only "optimization"bash
pkm search --info-type analysis --max-age 30 --fresh-only "optimization"Pattern 3: Explore Related Content
模式3:探索相关内容
bash
pkm relationships --source research.md && \
pkm backlinks research.mdbash
pkm relationships --source research.md && \
pkm backlinks research.mdPattern 4: Daily Maintenance
模式4:日常维护
bash
find . -name "*.md" -mtime -1 | pkm index --quiet --stdin && \
pkm find-stalebash
find . -name "*.md" -mtime -1 | pkm index --quiet --stdin && \
pkm find-stalePattern 5: Quality-Focused Search
模式5:质量优先搜索
bash
pkm search \
--facts-only \
--certainty high \
--fresh-only \
--min-score 0.15 \
-n 10 \
"deployment procedures"bash
pkm search \
--facts-only \
--certainty high \
--fresh-only \
--min-score 0.15 \
-n 10 \
"deployment procedures"Summary
总结
Primary use cases:
- Personal knowledge management with quality awareness
- Temporal tracking of document freshness
- Relationship discovery and backlink tracking
- Quality audits and knowledge base maintenance
- Integration with Claude via MCP
Key advantages:
- Quality filtering (certainty, info type)
- Freshness tracking (temporal awareness)
- Hybrid search (semantic + full-text)
- Relationship tracking (wikilinks, backlinks)
- Token-efficient results for Claude
- LSP integration for editor autocomplete
Most common commands:
- - Index workspace
pkm index ~/notes/ - - Quality search
pkm search --facts-only --fresh-only "query" - - Find relationships
pkm relationships --source note.md - - Audit knowledge base
pkm quality-audit - - Analyze workspace
pkm stats -d
主要使用场景:
- 具备质量感知的个人知识管理
- 文档新鲜度追踪
- 关系发现与反向链接追踪
- 质量审计与知识库维护
- 通过MCP与Claude集成
核心优势:
- 质量过滤(确定性、信息类型)
- 新鲜度追踪(时间感知)
- 混合搜索(语义+全文)
- 关系追踪(维基链接、反向链接)
- 为Claude优化的高效Token结果
- LSP集成实现编辑器自动补全
最常用命令:
- - 为工作区建立索引
pkm index ~/notes/ - - 高质量搜索
pkm search --facts-only --fresh-only "query" - - 查找文档关系
pkm relationships --source note.md - - 审计知识库
pkm quality-audit - - 分析工作区
pkm stats -d