weflow-cli 1.5.0 → 1.6.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/ARCHITECTURE.md +105 -0
- package/CHANGELOG.md +121 -0
- package/CONTRIBUTING.md +45 -0
- package/LICENSE +21 -21
- package/OPERATIONS.md +272 -0
- package/README.en.md +281 -0
- package/README.md +334 -149
- package/SECURITY.md +47 -0
- package/bin/weflow-cli.ts +4050 -581
- package/dist/bin/weflow-cli.js +4310 -588
- package/dist/bin/weflow-cli.js.map +1 -1
- package/dist/mcp-server/index.js +178 -236
- package/dist/mcp-server/index.js.map +1 -1
- package/dist/src/core/dbPathService.d.ts +15 -1
- package/dist/src/core/dbPathService.d.ts.map +1 -1
- package/dist/src/core/dbPathService.js +177 -19
- package/dist/src/core/dbPathService.js.map +1 -1
- package/dist/src/core/keyService.d.ts +8 -0
- package/dist/src/core/keyService.d.ts.map +1 -1
- package/dist/src/core/keyService.js +127 -22
- package/dist/src/core/keyService.js.map +1 -1
- package/dist/src/core/ntCore.d.ts +59 -1
- package/dist/src/core/ntCore.d.ts.map +1 -1
- package/dist/src/core/ntCore.js +201 -65
- package/dist/src/core/ntCore.js.map +1 -1
- package/dist/src/core/sqlcipherCore.d.ts.map +1 -1
- package/dist/src/core/sqlcipherCore.js +18 -1
- package/dist/src/core/sqlcipherCore.js.map +1 -1
- package/dist/src/core/wcdbCore.d.ts.map +1 -1
- package/dist/src/core/wcdbCore.js +3 -6
- package/dist/src/core/wcdbCore.js.map +1 -1
- package/dist/src/services/assistantDaemon.d.ts +19 -0
- package/dist/src/services/assistantDaemon.d.ts.map +1 -0
- package/dist/src/services/assistantDaemon.js +117 -0
- package/dist/src/services/assistantDaemon.js.map +1 -0
- package/dist/src/services/assistantMemory.d.ts +36 -0
- package/dist/src/services/assistantMemory.d.ts.map +1 -0
- package/dist/src/services/assistantMemory.js +182 -0
- package/dist/src/services/assistantMemory.js.map +1 -0
- package/dist/src/services/assistantPrivacy.d.ts +25 -0
- package/dist/src/services/assistantPrivacy.d.ts.map +1 -0
- package/dist/src/services/assistantPrivacy.js +77 -0
- package/dist/src/services/assistantPrivacy.js.map +1 -0
- package/dist/src/services/assistantRouting.d.ts +18 -0
- package/dist/src/services/assistantRouting.d.ts.map +1 -0
- package/dist/src/services/assistantRouting.js +68 -0
- package/dist/src/services/assistantRouting.js.map +1 -0
- package/dist/src/services/assistantService.d.ts +37 -0
- package/dist/src/services/assistantService.d.ts.map +1 -0
- package/dist/src/services/assistantService.js +284 -0
- package/dist/src/services/assistantService.js.map +1 -0
- package/dist/src/services/assistantTools.d.ts +24 -0
- package/dist/src/services/assistantTools.d.ts.map +1 -0
- package/dist/src/services/assistantTools.js +582 -0
- package/dist/src/services/assistantTools.js.map +1 -0
- package/dist/src/services/chatService.d.ts +44 -0
- package/dist/src/services/chatService.d.ts.map +1 -1
- package/dist/src/services/chatService.js +105 -4
- package/dist/src/services/chatService.js.map +1 -1
- package/dist/src/services/configService.d.ts +55 -0
- package/dist/src/services/configService.d.ts.map +1 -1
- package/dist/src/services/configService.js +147 -6
- package/dist/src/services/configService.js.map +1 -1
- package/dist/src/services/evidenceService.d.ts +30 -0
- package/dist/src/services/evidenceService.d.ts.map +1 -0
- package/dist/src/services/evidenceService.js +98 -0
- package/dist/src/services/evidenceService.js.map +1 -0
- package/dist/src/services/exportService.d.ts +13 -20
- package/dist/src/services/exportService.d.ts.map +1 -1
- package/dist/src/services/exportService.js +113 -47
- package/dist/src/services/exportService.js.map +1 -1
- package/dist/src/services/initKeyService.d.ts +19 -0
- package/dist/src/services/initKeyService.d.ts.map +1 -0
- package/dist/src/services/initKeyService.js +80 -0
- package/dist/src/services/initKeyService.js.map +1 -0
- package/dist/src/services/messageContract.d.ts +23 -0
- package/dist/src/services/messageContract.d.ts.map +1 -0
- package/dist/src/services/messageContract.js +49 -0
- package/dist/src/services/messageContract.js.map +1 -0
- package/dist/src/services/messageQuery.d.ts +7 -0
- package/dist/src/services/messageQuery.d.ts.map +1 -0
- package/dist/src/services/messageQuery.js +30 -0
- package/dist/src/services/messageQuery.js.map +1 -0
- package/dist/src/services/wechat-formatter.js +14 -14
- package/dist/src/services/wechatMessageService.d.ts.map +1 -1
- package/dist/src/services/wechatMessageService.js +31 -3
- package/dist/src/services/wechatMessageService.js.map +1 -1
- package/dist/src/services/whitelistService.d.ts +52 -4
- package/dist/src/services/whitelistService.d.ts.map +1 -1
- package/dist/src/services/whitelistService.js +183 -17
- package/dist/src/services/whitelistService.js.map +1 -1
- package/dist/src/types.d.ts +20 -0
- package/dist/src/types.d.ts.map +1 -1
- package/dist/src/utils/dateRange.d.ts +15 -0
- package/dist/src/utils/dateRange.d.ts.map +1 -0
- package/dist/src/utils/dateRange.js +48 -0
- package/dist/src/utils/dateRange.js.map +1 -0
- package/dist/src/utils/mcpSecurity.d.ts +5 -0
- package/dist/src/utils/mcpSecurity.d.ts.map +1 -0
- package/dist/src/utils/mcpSecurity.js +39 -0
- package/dist/src/utils/mcpSecurity.js.map +1 -0
- package/dist/src/utils/packageRoot.d.ts +2 -0
- package/dist/src/utils/packageRoot.d.ts.map +1 -0
- package/dist/src/utils/packageRoot.js +16 -0
- package/dist/src/utils/packageRoot.js.map +1 -0
- package/dist/src/utils/python.d.ts +2 -0
- package/dist/src/utils/python.d.ts.map +1 -0
- package/dist/src/utils/python.js +72 -0
- package/dist/src/utils/python.js.map +1 -0
- package/dist/src/utils/pythonProcessEnv.d.ts +3 -0
- package/dist/src/utils/pythonProcessEnv.d.ts.map +1 -0
- package/dist/src/utils/pythonProcessEnv.js +46 -0
- package/dist/src/utils/pythonProcessEnv.js.map +1 -0
- package/dist/src/utils/talkerUtils.d.ts +4 -1
- package/dist/src/utils/talkerUtils.d.ts.map +1 -1
- package/dist/src/utils/talkerUtils.js +9 -9
- package/dist/src/utils/talkerUtils.js.map +1 -1
- package/dist/src/utils/wechatEmoji.d.ts +5 -0
- package/dist/src/utils/wechatEmoji.d.ts.map +1 -0
- package/dist/src/utils/wechatEmoji.js +35 -0
- package/dist/src/utils/wechatEmoji.js.map +1 -0
- package/docs/AI_INTERFACE.md +189 -0
- package/docs/BRANCHES.md +87 -0
- package/docs/DATA_CONTRACT.md +74 -0
- package/docs/DECISIONS.md +270 -0
- package/docs/DEEPSEEK_V4_FLASH/346/226/275/345/267/245/346/226/207/346/241/243.md +234 -0
- package/docs/EVIDENCE_GUIDE.md +96 -0
- package/docs/MCP.md +95 -0
- package/docs/PARTNERS.md +41 -0
- package/docs/PROJECT_STATE.md +96 -0
- package/docs/RELEASING.md +124 -0
- package/docs/ROADMAP.md +191 -0
- package/docs/SETUP.md +103 -0
- package/docs/images/weflow-architecture-gpt-image-2.png +0 -0
- package/docs/images/weflow-architecture.png +0 -0
- package/docs/images/weflow-architecture.svg +65 -0
- package/mcp-server/index.ts +169 -269
- package/package.json +81 -72
- package/requirements-3x.txt +4 -0
- package/requirements-voice.txt +15 -0
- package/requirements.txt +9 -0
- package/resources/js/marked.min.js +69 -0
- package/resources/wechat-emoji/666.png +0 -0
- package/resources/wechat-emoji/Awesome.png +0 -0
- package/resources/wechat-emoji/Concerned.png +0 -0
- package/resources/wechat-emoji/Cry.png +0 -0
- package/resources/wechat-emoji/Emm.png +0 -0
- package/resources/wechat-emoji/Facepalm.png +0 -0
- package/resources/wechat-emoji/Grin.png +0 -0
- package/resources/wechat-emoji/OK.png +0 -0
- package/resources/wechat-emoji/Respect.png +0 -0
- package/resources/wechat-emoji/Sick.png +0 -0
- package/resources/wechat-emoji/Sleep.png +0 -0
- package/resources/wechat-emoji/Smile.png +0 -0
- package/resources/wechat-emoji//344/272/262/344/272/262.png +0 -0
- package/resources/wechat-emoji//344/276/277/344/276/277.png +0 -0
- package/resources/wechat-emoji//345/201/267/347/254/221.png +0 -0
- package/resources/wechat-emoji//345/202/262/346/205/242.png +0 -0
- package/resources/wechat-emoji//345/206/215/350/247/201.png +0 -0
- package/resources/wechat-emoji//345/207/213/350/260/242.png +0 -0
- package/resources/wechat-emoji//345/212/240/346/262/271.png +0 -0
- package/resources/wechat-emoji//345/213/276/345/274/225.png +0 -0
- package/resources/wechat-emoji//345/217/221/345/221/206.png +0 -0
- package/resources/wechat-emoji//345/217/221/346/200/222.png +0 -0
- package/resources/wechat-emoji//345/217/221/346/212/226.png +0 -0
- package/resources/wechat-emoji//345/217/257/346/200/234.png +0 -0
- package/resources/wechat-emoji//345/217/263/345/223/274/345/223/274.png +0 -0
- package/resources/wechat-emoji//345/217/271/346/260/224.png +0 -0
- package/resources/wechat-emoji//345/220/203/347/223/234.png +0 -0
- package/resources/wechat-emoji//345/220/210/345/215/201.png +0 -0
- package/resources/wechat-emoji//345/220/220.png +0 -0
- package/resources/wechat-emoji//345/221/262/347/211/231.png +0 -0
- package/resources/wechat-emoji//345/222/222/351/252/202.png +0 -0
- package/resources/wechat-emoji//345/222/226/345/225/241.png +0 -0
- package/resources/wechat-emoji//345/223/207.png +0 -0
- package/resources/wechat-emoji//345/225/244/351/205/222.png +0 -0
- package/resources/wechat-emoji//345/230/230.png +0 -0
- package/resources/wechat-emoji//345/230/264/345/224/207.png +0 -0
- package/resources/wechat-emoji//345/230/277/345/223/210.png +0 -0
- package/resources/wechat-emoji//345/233/247.png +0 -0
- package/resources/wechat-emoji//345/233/260.png +0 -0
- package/resources/wechat-emoji//345/235/217/347/254/221.png +0 -0
- package/resources/wechat-emoji//345/244/247/345/223/255.png +0 -0
- package/resources/wechat-emoji//345/244/251/345/225/212.png +0 -0
- package/resources/wechat-emoji//345/244/252/351/230/263.png +0 -0
- package/resources/wechat-emoji//345/244/261/346/234/233.png +0 -0
- package/resources/wechat-emoji//345/245/270/347/254/221.png +0 -0
- package/resources/wechat-emoji//345/245/275/347/232/204.png +0 -0
- package/resources/wechat-emoji//345/247/224/345/261/210.png +0 -0
- package/resources/wechat-emoji//345/256/263/347/276/236.png +0 -0
- package/resources/wechat-emoji//345/260/264/345/260/254.png +0 -0
- package/resources/wechat-emoji//345/272/206/347/245/235.png +0 -0
- package/resources/wechat-emoji//345/274/261.png +0 -0
- package/resources/wechat-emoji//345/274/272.png +0 -0
- package/resources/wechat-emoji//345/276/227/346/204/217.png +0 -0
- package/resources/wechat-emoji//345/276/256/347/254/221.png +0 -0
- package/resources/wechat-emoji//345/277/203/347/242/216.png +0 -0
- package/resources/wechat-emoji//345/277/253/345/223/255/344/272/206.png +0 -0
- package/resources/wechat-emoji//346/201/220/346/203/247.png +0 -0
- package/resources/wechat-emoji//346/202/240/351/227/262.png +0 -0
- package/resources/wechat-emoji//346/203/212/346/201/220.png +0 -0
- package/resources/wechat-emoji//346/203/212/350/256/266.png +0 -0
- package/resources/wechat-emoji//346/204/211/345/277/253.png +0 -0
- package/resources/wechat-emoji//346/206/250/347/254/221.png +0 -0
- package/resources/wechat-emoji//346/211/223/350/204/270.png +0 -0
- package/resources/wechat-emoji//346/212/223/347/213/202.png +0 -0
- package/resources/wechat-emoji//346/212/240/351/274/273.png +0 -0
- package/resources/wechat-emoji//346/212/261/346/213/263.png +0 -0
- package/resources/wechat-emoji//346/213/245/346/212/261.png +0 -0
- package/resources/wechat-emoji//346/213/263/345/244/264.png +0 -0
- package/resources/wechat-emoji//346/215/202/350/204/270.png +0 -0
- package/resources/wechat-emoji//346/217/241/346/211/213.png +0 -0
- package/resources/wechat-emoji//346/222/207/345/230/264.png +0 -0
- package/resources/wechat-emoji//346/223/246/346/261/227.png +0 -0
- package/resources/wechat-emoji//346/225/262/346/211/223.png +0 -0
- package/resources/wechat-emoji//346/227/240/350/257/255.png +0 -0
- package/resources/wechat-emoji//346/227/272/346/237/264.png +0 -0
- package/resources/wechat-emoji//346/231/225.png +0 -0
- package/resources/wechat-emoji//346/234/210/344/272/256.png +0 -0
- package/resources/wechat-emoji//346/234/272/346/231/272.png +0 -0
- package/resources/wechat-emoji//346/261/227.png +0 -0
- package/resources/wechat-emoji//346/265/201/346/263/252.png +0 -0
- package/resources/wechat-emoji//347/202/270/345/274/271.png +0 -0
- package/resources/wechat-emoji//347/203/237/350/212/261.png +0 -0
- package/resources/wechat-emoji//347/210/206/347/253/271.png +0 -0
- package/resources/wechat-emoji//347/210/261/345/277/203.png +0 -0
- package/resources/wechat-emoji//347/214/252/345/244/264.png +0 -0
- package/resources/wechat-emoji//347/216/253/347/221/260.png +0 -0
- package/resources/wechat-emoji//347/224/237/347/227/205.png +0 -0
- package/resources/wechat-emoji//347/226/221/351/227/256.png +0 -0
- package/resources/wechat-emoji//347/231/274.png +0 -0
- package/resources/wechat-emoji//347/231/275/347/234/274.png +0 -0
- package/resources/wechat-emoji//347/232/261/347/234/211.png +0 -0
- package/resources/wechat-emoji//347/235/241.png +0 -0
- package/resources/wechat-emoji//347/240/264/346/266/225/344/270/272/347/254/221.png +0 -0
- package/resources/wechat-emoji//347/244/274/347/211/251.png +0 -0
- package/resources/wechat-emoji//347/244/276/344/274/232/347/244/276/344/274/232.png +0 -0
- package/resources/wechat-emoji//347/246/217.png +0 -0
- package/resources/wechat-emoji//347/254/221/350/204/270.png +0 -0
- package/resources/wechat-emoji//347/272/242/345/214/205.png +0 -0
- package/resources/wechat-emoji//347/277/273/347/231/275/347/234/274.png +0 -0
- package/resources/wechat-emoji//350/200/266.png +0 -0
- package/resources/wechat-emoji//350/203/234/345/210/251.png +0 -0
- package/resources/wechat-emoji//350/204/270/347/272/242.png +0 -0
- package/resources/wechat-emoji//350/211/262.png +0 -0
- package/resources/wechat-emoji//350/213/246/346/266/251.png +0 -0
- package/resources/wechat-emoji//350/217/234/345/210/200.png +0 -0
- package/resources/wechat-emoji//350/233/213/347/263/225.png +0 -0
- package/resources/wechat-emoji//350/241/260.png +0 -0
- package/resources/wechat-emoji//350/243/202/345/274/200.png +0 -0
- package/resources/wechat-emoji//350/256/251/346/210/221/347/234/213/347/234/213.png +0 -0
- package/resources/wechat-emoji//350/260/203/347/232/256.png +0 -0
- package/resources/wechat-emoji//350/267/263/350/267/263.png +0 -0
- package/resources/wechat-emoji//350/275/254/345/234/210.png +0 -0
- package/resources/wechat-emoji//351/204/231/350/247/206.png +0 -0
- package/resources/wechat-emoji//351/227/255/345/230/264.png +0 -0
- package/resources/wechat-emoji//351/230/264/351/231/251.png +0 -0
- package/resources/wechat-emoji//351/232/276/350/277/207.png +0 -0
- package/resources/wechat-emoji//351/252/267/351/253/205.png +0 -0
- package/resources/wechat-emoji//351/274/223/346/216/214.png +0 -0
- package/scripts/_batch_link_sources.py +73 -73
- package/scripts/_utils.py +29 -0
- package/scripts/annual_report.py +796 -796
- package/scripts/auto_tag.py +128 -128
- package/scripts/biz_daily.py +210 -53
- package/scripts/chat_report.py +10 -0
- package/scripts/chat_stats.py +702 -702
- package/scripts/classify_daily.py +17 -11
- package/scripts/create_reading_notes.py +370 -370
- package/scripts/daily_stats.py +132 -0
- package/scripts/enrich_backlinks.py +163 -163
- package/scripts/export_chat_html.py +1704 -107
- package/scripts/extract_todos.py +445 -404
- package/scripts/fav_server.py +119 -12
- package/scripts/fix_topics.py +111 -111
- package/scripts/generate_ai_report.py +1 -1
- package/scripts/generate_html.py +597 -277
- package/scripts/inspection_records.py +354 -0
- package/scripts/mcp_bridge.py +398 -398
- package/scripts/nt_decrypt.py +702 -48
- package/scripts/pipeline.py +27 -19
- package/scripts/promote_all.py +312 -310
- package/scripts/promote_ideas.py +299 -297
- package/scripts/rag_chat.py +194 -191
- package/scripts/semantic_search.py +435 -431
- package/scripts/sync_fav.py +201 -146
- package/scripts/sync_weread.py +192 -192
- package/scripts/vault_rag.py +140 -139
- package/scripts/vault_search.py +141 -141
- package/scripts/wechat_emoji.py +132 -0
- package/scripts/wechat_emoticon.py +433 -0
- package/scripts/wechat_image.py +258 -0
- package/scripts/wechat_voice.py +327 -0
- package/src/core/dbPathService.ts +163 -18
- package/src/core/keyService.ts +137 -25
- package/src/core/ntCore.ts +215 -62
- package/src/core/sqlcipherCore.ts +17 -1
- package/src/core/wcdbCore.ts +3 -7
- package/src/services/assistantDaemon.ts +111 -0
- package/src/services/assistantMemory.ts +193 -0
- package/src/services/assistantPrivacy.ts +87 -0
- package/src/services/assistantRouting.ts +92 -0
- package/src/services/assistantService.ts +295 -0
- package/src/services/assistantTools.ts +549 -0
- package/src/services/chatService.ts +133 -4
- package/src/services/configService.ts +194 -6
- package/src/services/evidenceService.ts +129 -0
- package/src/services/exportService.ts +113 -48
- package/src/services/initKeyService.ts +83 -0
- package/src/services/messageContract.ts +77 -0
- package/src/services/messageQuery.ts +38 -0
- package/src/services/wechat-formatter.ts +348 -348
- package/src/services/wechatMessageService.ts +25 -3
- package/src/services/wereadService.ts +308 -308
- package/src/services/whitelistService.ts +209 -22
- package/src/types.ts +20 -0
- package/src/utils/dateRange.ts +58 -0
- package/src/utils/mcpSecurity.ts +39 -0
- package/src/utils/packageRoot.ts +14 -0
- package/src/utils/python.ts +73 -0
- package/src/utils/pythonProcessEnv.ts +45 -0
- package/src/utils/talkerUtils.ts +14 -2
- package/dist/src/utils/errors.d.ts +0 -25
- package/dist/src/utils/errors.d.ts.map +0 -1
- package/dist/src/utils/errors.js +0 -43
- package/dist/src/utils/errors.js.map +0 -1
- package/dist/src/utils/pythonRunner.d.ts +0 -27
- package/dist/src/utils/pythonRunner.d.ts.map +0 -1
- package/dist/src/utils/pythonRunner.js +0 -62
- package/dist/src/utils/pythonRunner.js.map +0 -1
- package/src/utils/errors.ts +0 -42
- package/src/utils/pythonRunner.ts +0 -81
package/scripts/promote_ideas.py
CHANGED
|
@@ -1,297 +1,299 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""
|
|
3
|
-
知识升级管道 — 002_Literature → 003_Ideas → 004_Permanent → 008_MOC
|
|
4
|
-
|
|
5
|
-
用法:
|
|
6
|
-
python scripts/promote_ideas.py
|
|
7
|
-
python scripts/promote_ideas.py --api-key <key>
|
|
8
|
-
"""
|
|
9
|
-
|
|
10
|
-
import sys, os, re, json
|
|
11
|
-
from pathlib import Path
|
|
12
|
-
from collections import Counter, defaultdict
|
|
13
|
-
from datetime import datetime
|
|
14
|
-
|
|
15
|
-
SCRIPTS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
16
|
-
PROJECT_ROOT = os.path.dirname(SCRIPTS_DIR)
|
|
17
|
-
DEFAULT_VAULT = os.path.join(PROJECT_ROOT, 'output', 'wechat-vault')
|
|
18
|
-
|
|
19
|
-
sys.path.insert(0, SCRIPTS_DIR)
|
|
20
|
-
from _utils import call_deepseek
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
def collect_metadata(vault_path: str) -> list[dict]:
|
|
24
|
-
"""收集所有 002_Literature 笔记的元数据。"""
|
|
25
|
-
lit_dir = Path(vault_path) / '002_Literature' / 'WeChat'
|
|
26
|
-
articles = []
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
v =
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
|
|
62
|
-
'
|
|
63
|
-
'
|
|
64
|
-
'
|
|
65
|
-
'
|
|
66
|
-
'
|
|
67
|
-
'
|
|
68
|
-
|
|
69
|
-
|
|
70
|
-
|
|
71
|
-
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
-
|
|
112
|
-
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
{
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
190
|
-
|
|
191
|
-
|
|
192
|
-
|
|
193
|
-
|
|
194
|
-
|
|
195
|
-
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
|
|
199
|
-
|
|
200
|
-
|
|
201
|
-
|
|
202
|
-
|
|
203
|
-
|
|
204
|
-
|
|
205
|
-
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
|
|
209
|
-
|
|
210
|
-
|
|
211
|
-
|
|
212
|
-
|
|
213
|
-
|
|
214
|
-
|
|
215
|
-
|
|
216
|
-
content += f'-
|
|
217
|
-
|
|
218
|
-
|
|
219
|
-
|
|
220
|
-
|
|
221
|
-
|
|
222
|
-
|
|
223
|
-
|
|
224
|
-
|
|
225
|
-
|
|
226
|
-
|
|
227
|
-
|
|
228
|
-
|
|
229
|
-
|
|
230
|
-
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
235
|
-
|
|
236
|
-
|
|
237
|
-
|
|
238
|
-
|
|
239
|
-
|
|
240
|
-
|
|
241
|
-
|
|
242
|
-
|
|
243
|
-
|
|
244
|
-
|
|
245
|
-
|
|
246
|
-
|
|
247
|
-
|
|
248
|
-
|
|
249
|
-
|
|
250
|
-
|
|
251
|
-
|
|
252
|
-
|
|
253
|
-
|
|
254
|
-
|
|
255
|
-
|
|
256
|
-
|
|
257
|
-
|
|
258
|
-
|
|
259
|
-
parser
|
|
260
|
-
parser.add_argument('--
|
|
261
|
-
|
|
262
|
-
|
|
263
|
-
|
|
264
|
-
|
|
265
|
-
|
|
266
|
-
|
|
267
|
-
print(
|
|
268
|
-
|
|
269
|
-
|
|
270
|
-
|
|
271
|
-
|
|
272
|
-
|
|
273
|
-
|
|
274
|
-
|
|
275
|
-
|
|
276
|
-
|
|
277
|
-
|
|
278
|
-
|
|
279
|
-
|
|
280
|
-
|
|
281
|
-
|
|
282
|
-
|
|
283
|
-
|
|
284
|
-
print(
|
|
285
|
-
|
|
286
|
-
idea_count
|
|
287
|
-
|
|
288
|
-
|
|
289
|
-
|
|
290
|
-
|
|
291
|
-
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
295
|
-
|
|
296
|
-
|
|
297
|
-
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
知识升级管道 — 002_Literature → 003_Ideas → 004_Permanent → 008_MOC
|
|
4
|
+
|
|
5
|
+
用法:
|
|
6
|
+
python scripts/promote_ideas.py
|
|
7
|
+
python scripts/promote_ideas.py --api-key <key>
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import sys, os, re, json
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
from collections import Counter, defaultdict
|
|
13
|
+
from datetime import datetime
|
|
14
|
+
|
|
15
|
+
SCRIPTS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
16
|
+
PROJECT_ROOT = os.path.dirname(SCRIPTS_DIR)
|
|
17
|
+
DEFAULT_VAULT = os.path.join(PROJECT_ROOT, 'output', 'wechat-vault')
|
|
18
|
+
|
|
19
|
+
sys.path.insert(0, SCRIPTS_DIR)
|
|
20
|
+
from _utils import call_deepseek
|
|
21
|
+
|
|
22
|
+
|
|
23
|
+
def collect_metadata(vault_path: str) -> list[dict]:
|
|
24
|
+
"""收集所有 002_Literature 笔记的元数据。"""
|
|
25
|
+
lit_dir = Path(vault_path) / '002_Literature' / 'WeChat'
|
|
26
|
+
articles = []
|
|
27
|
+
if not lit_dir.is_dir():
|
|
28
|
+
return articles
|
|
29
|
+
for date_dir in sorted(lit_dir.iterdir()):
|
|
30
|
+
if not date_dir.is_dir():
|
|
31
|
+
continue
|
|
32
|
+
for note_file in date_dir.glob('*.md'):
|
|
33
|
+
try:
|
|
34
|
+
content = note_file.read_text(encoding='utf-8')
|
|
35
|
+
except Exception:
|
|
36
|
+
continue
|
|
37
|
+
# 提取 frontmatter
|
|
38
|
+
fm = {}
|
|
39
|
+
if content.startswith('---'):
|
|
40
|
+
end = content.find('---', 3)
|
|
41
|
+
if end != -1:
|
|
42
|
+
for line in content[3:end].split('\n'):
|
|
43
|
+
if ':' in line:
|
|
44
|
+
k, _, v = line.partition(':')
|
|
45
|
+
k = k.strip()
|
|
46
|
+
v = v.strip().strip('"').strip("'")
|
|
47
|
+
fm[k] = v
|
|
48
|
+
|
|
49
|
+
# 提取概念
|
|
50
|
+
concept_match = re.findall(r'## 关联网络.*?##', content, re.DOTALL)
|
|
51
|
+
concepts = []
|
|
52
|
+
if concept_match:
|
|
53
|
+
concepts = re.findall(r'\[\[([^\]]+)\]\]', concept_match[0])
|
|
54
|
+
|
|
55
|
+
# 提取标签
|
|
56
|
+
tags = []
|
|
57
|
+
tag_match = re.search(r'tags:\s*\[(.+?)\]', content)
|
|
58
|
+
if tag_match:
|
|
59
|
+
tags = [t.strip() for t in tag_match.group(1).split(',')]
|
|
60
|
+
|
|
61
|
+
articles.append({
|
|
62
|
+
'title': fm.get('title', note_file.stem),
|
|
63
|
+
'source': fm.get('source', ''),
|
|
64
|
+
'date': date_dir.name,
|
|
65
|
+
'topic': fm.get('topic', ''),
|
|
66
|
+
'hasTopic': fm.get('hasTopic', ''),
|
|
67
|
+
'concepts': concepts,
|
|
68
|
+
'tags': tags,
|
|
69
|
+
'path': note_file,
|
|
70
|
+
})
|
|
71
|
+
return articles
|
|
72
|
+
|
|
73
|
+
|
|
74
|
+
def generate_ideas(articles: list[dict], api_key: str, vault_path: str) -> int:
|
|
75
|
+
"""AI 分析文章,提取跨领域研究想法 → 003_Ideas。"""
|
|
76
|
+
# 按主题分组,提取代表性样本
|
|
77
|
+
by_topic = defaultdict(list)
|
|
78
|
+
for a in articles:
|
|
79
|
+
topic = a['hasTopic'].replace('[[', '').replace(']]', '') or a.get('topic', '其他')
|
|
80
|
+
by_topic[topic].append(a)
|
|
81
|
+
|
|
82
|
+
ideas_dir = Path(vault_path) / '003_Ideas'
|
|
83
|
+
ideas_dir.mkdir(parents=True, exist_ok=True)
|
|
84
|
+
created = 0
|
|
85
|
+
|
|
86
|
+
for topic, arts in by_topic.items():
|
|
87
|
+
if len(arts) < 5:
|
|
88
|
+
continue
|
|
89
|
+
# 取代表性文章(高概念数的)
|
|
90
|
+
samples = sorted(arts, key=lambda a: len(a.get('concepts', [])), reverse=True)[:10]
|
|
91
|
+
titles = '\n'.join(f'- {a["title"][:60]} (来源: {a["source"]})' for a in samples[:8])
|
|
92
|
+
|
|
93
|
+
# 收集热门概念
|
|
94
|
+
all_concepts = []
|
|
95
|
+
for a in arts:
|
|
96
|
+
all_concepts.extend(a.get('concepts', []))
|
|
97
|
+
top_concepts = [c for c, _ in Counter(all_concepts).most_common(8) if len(c) > 2]
|
|
98
|
+
|
|
99
|
+
concepts_str = ', '.join(top_concepts[:8]) if top_concepts else '无'
|
|
100
|
+
|
|
101
|
+
prompt = f'''你是一个研究助理。分析以下 {topic} 主题的文章列表,从中提炼 1-2 个研究想法。
|
|
102
|
+
|
|
103
|
+
文章列表(共 {len(arts)} 篇,样本 {len(samples)} 篇):
|
|
104
|
+
{titles}
|
|
105
|
+
|
|
106
|
+
热门概念:{concepts_str}
|
|
107
|
+
|
|
108
|
+
请为每个想法生成以下格式(200字内/想法):
|
|
109
|
+
|
|
110
|
+
## 想法1: [标题]
|
|
111
|
+
- **背景**: 一句话描述
|
|
112
|
+
- **核心思路**: 2-3句
|
|
113
|
+
- **相关文章**: 从样本列表中引用2-3篇
|
|
114
|
+
- **可行性**: 高/中/低
|
|
115
|
+
|
|
116
|
+
只返回想法,不要其他内容。'''
|
|
117
|
+
|
|
118
|
+
try:
|
|
119
|
+
result = call_deepseek(prompt, api_key, max_tokens=500)
|
|
120
|
+
except Exception as e:
|
|
121
|
+
print(f' [WARN] {topic} AI 失败: {e}')
|
|
122
|
+
continue
|
|
123
|
+
|
|
124
|
+
idea_name = f'idea-{topic}-研究想法.md'
|
|
125
|
+
idea_path = ideas_dir / idea_name
|
|
126
|
+
if idea_path.exists():
|
|
127
|
+
continue
|
|
128
|
+
|
|
129
|
+
idea_content = f'''---
|
|
130
|
+
title: "{topic} 研究想法"
|
|
131
|
+
created: {datetime.now().strftime('%Y-%m-%d')}
|
|
132
|
+
type: idea
|
|
133
|
+
hasTopic: [[{topic}]]
|
|
134
|
+
tags: [idea, {topic.lower()}, research]
|
|
135
|
+
inspired_by: [{len(arts)} articles]
|
|
136
|
+
---
|
|
137
|
+
|
|
138
|
+
# {topic} 研究想法
|
|
139
|
+
|
|
140
|
+
> 基于 {len(arts)} 篇 {topic} 文章自动提炼
|
|
141
|
+
|
|
142
|
+
{result}
|
|
143
|
+
|
|
144
|
+
---
|
|
145
|
+
|
|
146
|
+
## 相关文章
|
|
147
|
+
|
|
148
|
+
'''
|
|
149
|
+
for a in arts[:15]:
|
|
150
|
+
idea_content += f'- [[{a["date"]}/{a["path"].name}|{a["title"][:50]}]]\n'
|
|
151
|
+
|
|
152
|
+
idea_content += f'''
|
|
153
|
+
|
|
154
|
+
## 热门概念
|
|
155
|
+
|
|
156
|
+
'''
|
|
157
|
+
for c in top_concepts[:10]:
|
|
158
|
+
idea_content += f'- [[{c}]]\n'
|
|
159
|
+
|
|
160
|
+
idea_path.write_text(idea_content, encoding='utf-8')
|
|
161
|
+
created += 1
|
|
162
|
+
print(f' [{topic}] → {idea_name}')
|
|
163
|
+
|
|
164
|
+
return created
|
|
165
|
+
|
|
166
|
+
|
|
167
|
+
def generate_moc(articles: list[dict], vault_path: str) -> int:
|
|
168
|
+
"""为每个主题生成 Map of Content → 008_MOC。"""
|
|
169
|
+
by_topic = defaultdict(list)
|
|
170
|
+
for a in articles:
|
|
171
|
+
topic = a['hasTopic'].replace('[[', '').replace(']]', '') or a.get('topic', '其他')
|
|
172
|
+
by_topic[topic].append(a)
|
|
173
|
+
|
|
174
|
+
moc_dir = Path(vault_path) / '008_MOC'
|
|
175
|
+
moc_dir.mkdir(parents=True, exist_ok=True)
|
|
176
|
+
created = 0
|
|
177
|
+
|
|
178
|
+
for topic, arts in by_topic.items():
|
|
179
|
+
if len(arts) < 5:
|
|
180
|
+
continue
|
|
181
|
+
|
|
182
|
+
# 按日期分组
|
|
183
|
+
by_date = defaultdict(list)
|
|
184
|
+
for a in arts:
|
|
185
|
+
by_date[a['date']].append(a)
|
|
186
|
+
|
|
187
|
+
# 收集所有概念
|
|
188
|
+
all_concepts = []
|
|
189
|
+
for a in arts:
|
|
190
|
+
all_concepts.extend(a.get('concepts', []))
|
|
191
|
+
top_concepts = Counter(all_concepts).most_common(15)
|
|
192
|
+
|
|
193
|
+
moc_path = moc_dir / f'MOC-{topic}.md'
|
|
194
|
+
content = f'''---
|
|
195
|
+
title: "{topic} — 主题导航"
|
|
196
|
+
created: {datetime.now().strftime('%Y-%m-%d')}
|
|
197
|
+
type: moc
|
|
198
|
+
hasTopic: [[{topic}]]
|
|
199
|
+
tags: [moc, {topic.lower()}]
|
|
200
|
+
article_count: {len(arts)}
|
|
201
|
+
---
|
|
202
|
+
|
|
203
|
+
# {topic} — 主题导航地图
|
|
204
|
+
|
|
205
|
+
> {len(arts)} 篇文章 · 覆盖 {len(by_date)} 天
|
|
206
|
+
|
|
207
|
+
---
|
|
208
|
+
|
|
209
|
+
## 📅 按日期
|
|
210
|
+
|
|
211
|
+
'''
|
|
212
|
+
for date_str in sorted(by_date.keys(), reverse=True):
|
|
213
|
+
day_arts = by_date[date_str]
|
|
214
|
+
content += f'\n### {date_str} ({len(day_arts)} 篇)\n'
|
|
215
|
+
for a in day_arts[:8]:
|
|
216
|
+
content += f'- [[{a["date"]}/{a["path"].name}|{a["title"][:60]}]] — {a["source"]}\n'
|
|
217
|
+
if len(day_arts) > 8:
|
|
218
|
+
content += f'- ... 等 {len(day_arts)} 篇\n'
|
|
219
|
+
|
|
220
|
+
content += f'''
|
|
221
|
+
|
|
222
|
+
## 🔥 热门概念
|
|
223
|
+
|
|
224
|
+
'''
|
|
225
|
+
for c, count in top_concepts:
|
|
226
|
+
content += f'- [[{c}]] ({count} 次)\n'
|
|
227
|
+
|
|
228
|
+
content += f'''
|
|
229
|
+
|
|
230
|
+
## 🔗 相关 MOC
|
|
231
|
+
|
|
232
|
+
'''
|
|
233
|
+
for other in by_topic.keys():
|
|
234
|
+
if other != topic:
|
|
235
|
+
content += f'- [[MOC-{other}]]\n'
|
|
236
|
+
|
|
237
|
+
content += f'''
|
|
238
|
+
|
|
239
|
+
## 📊 统计
|
|
240
|
+
|
|
241
|
+
```dataview
|
|
242
|
+
TABLE date, source, rating
|
|
243
|
+
FROM "002_Literature"
|
|
244
|
+
WHERE contains(hasTopic, "{topic}")
|
|
245
|
+
SORT date DESC
|
|
246
|
+
```
|
|
247
|
+
'''
|
|
248
|
+
|
|
249
|
+
moc_path.write_text(content, encoding='utf-8')
|
|
250
|
+
created += 1
|
|
251
|
+
print(f' [{topic}] → MOC-{topic}.md ({len(arts)} articles)')
|
|
252
|
+
|
|
253
|
+
return created
|
|
254
|
+
|
|
255
|
+
|
|
256
|
+
def main():
|
|
257
|
+
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
|
258
|
+
import argparse
|
|
259
|
+
parser = argparse.ArgumentParser(description='知识升级管道')
|
|
260
|
+
parser.add_argument('--vault', default=DEFAULT_VAULT, help='Vault 路径')
|
|
261
|
+
parser.add_argument('--api-key', default='', help='DeepSeek API key')
|
|
262
|
+
parser.add_argument('--skip-ai', action='store_true', help='跳过 AI 部分(仅生成 MOC)')
|
|
263
|
+
args = parser.parse_args()
|
|
264
|
+
|
|
265
|
+
api_key = args.api_key or os.environ.get('DEEPSEEK_API_KEY', '')
|
|
266
|
+
|
|
267
|
+
print('📊 收集文章元数据...')
|
|
268
|
+
articles = collect_metadata(args.vault)
|
|
269
|
+
print(f' 共 {len(articles)} 篇文章')
|
|
270
|
+
|
|
271
|
+
# 统计
|
|
272
|
+
by_topic = defaultdict(int)
|
|
273
|
+
for a in articles:
|
|
274
|
+
topic = a['hasTopic'].replace('[[', '').replace(']]', '') or a.get('topic', '其他')
|
|
275
|
+
by_topic[topic] += 1
|
|
276
|
+
print(f' 主题分布: {dict(by_topic)}')
|
|
277
|
+
|
|
278
|
+
# Step 1: MOC(不需要 AI)
|
|
279
|
+
print('\n🗺️ 生成 008_MOC 主题导航...')
|
|
280
|
+
moc_count = generate_moc(articles, args.vault)
|
|
281
|
+
|
|
282
|
+
# Step 2: Ideas(需要 AI)
|
|
283
|
+
if not args.skip_ai and api_key:
|
|
284
|
+
print('\n💡 生成 003_Ideas 研究想法...')
|
|
285
|
+
idea_count = generate_ideas(articles, api_key, args.vault)
|
|
286
|
+
print(f'\n✓ 完成: {moc_count} MOC + {idea_count} Ideas')
|
|
287
|
+
else:
|
|
288
|
+
idea_count = 0
|
|
289
|
+
print(f'\n✓ 完成: {moc_count} MOC (跳过 AI)')
|
|
290
|
+
|
|
291
|
+
if not api_key and not args.skip_ai:
|
|
292
|
+
print(' 提示: 使用 --api-key 或设置 DEEPSEEK_API_KEY 以启用 AI 想法生成')
|
|
293
|
+
|
|
294
|
+
total = moc_count + idea_count
|
|
295
|
+
print(f' 共生成 {total} 个文件')
|
|
296
|
+
|
|
297
|
+
|
|
298
|
+
if __name__ == '__main__':
|
|
299
|
+
main()
|