weflow-cli 1.5.0
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/LICENSE +21 -0
- package/README.md +149 -0
- package/bin/weflow-cli-electron.cjs +59 -0
- package/bin/weflow-cli.ts +2311 -0
- package/cli.cjs +3 -0
- package/dist/bin/weflow-cli.d.ts +3 -0
- package/dist/bin/weflow-cli.d.ts.map +1 -0
- package/dist/bin/weflow-cli.js +2270 -0
- package/dist/bin/weflow-cli.js.map +1 -0
- package/dist/mcp-server/index.d.ts +3 -0
- package/dist/mcp-server/index.d.ts.map +1 -0
- package/dist/mcp-server/index.js +690 -0
- package/dist/mcp-server/index.js.map +1 -0
- package/dist/src/core/dbPathService.d.ts +40 -0
- package/dist/src/core/dbPathService.d.ts.map +1 -0
- package/dist/src/core/dbPathService.js +324 -0
- package/dist/src/core/dbPathService.js.map +1 -0
- package/dist/src/core/keyService.d.ts +59 -0
- package/dist/src/core/keyService.d.ts.map +1 -0
- package/dist/src/core/keyService.js +368 -0
- package/dist/src/core/keyService.js.map +1 -0
- package/dist/src/core/ntCore.d.ts +62 -0
- package/dist/src/core/ntCore.d.ts.map +1 -0
- package/dist/src/core/ntCore.js +191 -0
- package/dist/src/core/ntCore.js.map +1 -0
- package/dist/src/core/sqlcipherCore.d.ts +119 -0
- package/dist/src/core/sqlcipherCore.d.ts.map +1 -0
- package/dist/src/core/sqlcipherCore.js +693 -0
- package/dist/src/core/sqlcipherCore.js.map +1 -0
- package/dist/src/core/wcdbCore.d.ts +738 -0
- package/dist/src/core/wcdbCore.d.ts.map +1 -0
- package/dist/src/core/wcdbCore.js +4545 -0
- package/dist/src/core/wcdbCore.js.map +1 -0
- package/dist/src/core/wechatClient.d.ts +23 -0
- package/dist/src/core/wechatClient.d.ts.map +1 -0
- package/dist/src/core/wechatClient.js +166 -0
- package/dist/src/core/wechatClient.js.map +1 -0
- package/dist/src/services/chatService.d.ts +25 -0
- package/dist/src/services/chatService.d.ts.map +1 -0
- package/dist/src/services/chatService.js +291 -0
- package/dist/src/services/chatService.js.map +1 -0
- package/dist/src/services/configService.d.ts +43 -0
- package/dist/src/services/configService.d.ts.map +1 -0
- package/dist/src/services/configService.js +156 -0
- package/dist/src/services/configService.js.map +1 -0
- package/dist/src/services/exportService.d.ts +30 -0
- package/dist/src/services/exportService.d.ts.map +1 -0
- package/dist/src/services/exportService.js +273 -0
- package/dist/src/services/exportService.js.map +1 -0
- package/dist/src/services/wechat-formatter.d.ts +69 -0
- package/dist/src/services/wechat-formatter.d.ts.map +1 -0
- package/dist/src/services/wechat-formatter.js +248 -0
- package/dist/src/services/wechat-formatter.js.map +1 -0
- package/dist/src/services/wechatMessageService.d.ts +28 -0
- package/dist/src/services/wechatMessageService.d.ts.map +1 -0
- package/dist/src/services/wechatMessageService.js +341 -0
- package/dist/src/services/wechatMessageService.js.map +1 -0
- package/dist/src/services/wereadService.d.ts +206 -0
- package/dist/src/services/wereadService.d.ts.map +1 -0
- package/dist/src/services/wereadService.js +145 -0
- package/dist/src/services/wereadService.js.map +1 -0
- package/dist/src/services/whitelistService.d.ts +20 -0
- package/dist/src/services/whitelistService.d.ts.map +1 -0
- package/dist/src/services/whitelistService.js +60 -0
- package/dist/src/services/whitelistService.js.map +1 -0
- package/dist/src/types.d.ts +140 -0
- package/dist/src/types.d.ts.map +1 -0
- package/dist/src/types.js +2 -0
- package/dist/src/types.js.map +1 -0
- package/dist/src/utils/errors.d.ts +25 -0
- package/dist/src/utils/errors.d.ts.map +1 -0
- package/dist/src/utils/errors.js +43 -0
- package/dist/src/utils/errors.js.map +1 -0
- package/dist/src/utils/pathUtils.d.ts +5 -0
- package/dist/src/utils/pathUtils.d.ts.map +1 -0
- package/dist/src/utils/pathUtils.js +16 -0
- package/dist/src/utils/pathUtils.js.map +1 -0
- package/dist/src/utils/pythonRunner.d.ts +27 -0
- package/dist/src/utils/pythonRunner.d.ts.map +1 -0
- package/dist/src/utils/pythonRunner.js +62 -0
- package/dist/src/utils/pythonRunner.js.map +1 -0
- package/dist/src/utils/talkerUtils.d.ts +14 -0
- package/dist/src/utils/talkerUtils.d.ts.map +1 -0
- package/dist/src/utils/talkerUtils.js +73 -0
- package/dist/src/utils/talkerUtils.js.map +1 -0
- package/mcp-server/index.ts +757 -0
- package/package.json +72 -0
- package/resources/key/win32/x64/wx_key.dll +0 -0
- package/resources/wcdb/win32/x64/SDL2.dll +0 -0
- package/resources/wcdb/win32/x64/WCDB.dll +0 -0
- package/resources/wcdb/win32/x64/msvcp140.dll +0 -0
- package/resources/wcdb/win32/x64/msvcp140_1.dll +0 -0
- package/resources/wcdb/win32/x64/vcruntime140.dll +0 -0
- package/resources/wcdb/win32/x64/vcruntime140_1.dll +0 -0
- package/resources/wcdb/win32/x64/wcdb_api.dll +0 -0
- package/scripts/_batch_link_sources.py +73 -0
- package/scripts/_utils.py +531 -0
- package/scripts/annual_report.py +796 -0
- package/scripts/auto_tag.py +128 -0
- package/scripts/biz_daily.py +896 -0
- package/scripts/chat_report.py +397 -0
- package/scripts/chat_stats.py +702 -0
- package/scripts/classify_daily.py +411 -0
- package/scripts/compile_wiki.py +258 -0
- package/scripts/create_reading_notes.py +370 -0
- package/scripts/enrich_backlinks.py +163 -0
- package/scripts/export_chat_html.py +766 -0
- package/scripts/extract_3x_key.py +86 -0
- package/scripts/extract_todos.py +404 -0
- package/scripts/fav_server.py +392 -0
- package/scripts/fix_topics.py +111 -0
- package/scripts/generate_ai_report.py +367 -0
- package/scripts/generate_html.py +1372 -0
- package/scripts/generate_review.py +170 -0
- package/scripts/mcp_bridge.py +398 -0
- package/scripts/nt_decrypt.py +562 -0
- package/scripts/pipeline.py +145 -0
- package/scripts/promote_all.py +310 -0
- package/scripts/promote_ideas.py +297 -0
- package/scripts/rag_chat.py +191 -0
- package/scripts/scan_decrypt_4x.py +329 -0
- package/scripts/semantic_search.py +431 -0
- package/scripts/sync_fav.py +146 -0
- package/scripts/sync_weread.py +192 -0
- package/scripts/vault_rag.py +139 -0
- package/scripts/vault_search.py +141 -0
- package/src/core/dbPathService.ts +348 -0
- package/src/core/keyService.ts +409 -0
- package/src/core/ntCore.ts +224 -0
- package/src/core/sqlcipherCore.ts +764 -0
- package/src/core/wcdbCore.ts +4568 -0
- package/src/core/wechatClient.ts +204 -0
- package/src/lz4.d.ts +10 -0
- package/src/services/chatService.ts +296 -0
- package/src/services/configService.ts +197 -0
- package/src/services/exportService.ts +305 -0
- package/src/services/wechat-formatter.ts +348 -0
- package/src/services/wechatMessageService.ts +383 -0
- package/src/services/wereadService.ts +308 -0
- package/src/services/whitelistService.ts +72 -0
- package/src/types.ts +141 -0
- package/src/utils/errors.ts +42 -0
- package/src/utils/pathUtils.ts +16 -0
- package/src/utils/pythonRunner.ts +81 -0
- package/src/utils/talkerUtils.ts +84 -0
|
@@ -0,0 +1,128 @@
|
|
|
1
|
+
#!/usr/bin/env python3
|
|
2
|
+
"""
|
|
3
|
+
自动标签 — AI 为缺少标签的文章生成标签,支持 Dataview 聚合。
|
|
4
|
+
|
|
5
|
+
用法:
|
|
6
|
+
python scripts/auto_tag.py --date 2026-05-22
|
|
7
|
+
python scripts/auto_tag.py --date 2026-05-22 --api-key <key>
|
|
8
|
+
"""
|
|
9
|
+
|
|
10
|
+
import sys, os, json, time
|
|
11
|
+
from pathlib import Path
|
|
12
|
+
|
|
13
|
+
SCRIPTS_DIR = os.path.dirname(os.path.abspath(__file__))
|
|
14
|
+
PROJECT_ROOT = os.path.dirname(SCRIPTS_DIR)
|
|
15
|
+
DEFAULT_SOURCE = os.path.join(PROJECT_ROOT, 'output', 'biz-daily')
|
|
16
|
+
|
|
17
|
+
TOPIC_ORDER = ['AI', '学术', '新闻', '文学', '投资']
|
|
18
|
+
|
|
19
|
+
from _utils import call_deepseek, parse_frontmatter as _parse_fm
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
def parse_frontmatter(text: str):
|
|
23
|
+
"""解析 frontmatter,返回 (meta, body)。"""
|
|
24
|
+
if not text.startswith('---'):
|
|
25
|
+
return {}, text
|
|
26
|
+
end = text.find('---', 3)
|
|
27
|
+
if end == -1:
|
|
28
|
+
return {}, text
|
|
29
|
+
fm_text = text[3:end].strip()
|
|
30
|
+
body = text[end + 3:].strip()
|
|
31
|
+
meta = {}
|
|
32
|
+
for line in fm_text.split('\n'):
|
|
33
|
+
line = line.strip()
|
|
34
|
+
if ':' in line:
|
|
35
|
+
key, _, val = line.partition(':')
|
|
36
|
+
key = key.strip()
|
|
37
|
+
val = val.strip().strip('"').strip("'")
|
|
38
|
+
if val.startswith('[') and val.endswith(']'):
|
|
39
|
+
val = [v.strip().strip('"').strip("'") for v in val[1:-1].split(',') if v.strip()]
|
|
40
|
+
meta[key] = val
|
|
41
|
+
return meta, body
|
|
42
|
+
|
|
43
|
+
|
|
44
|
+
def generate_tags(title: str, body: str, api_key: str) -> list[str]:
|
|
45
|
+
"""用 AI 生成 3-5 个标签。"""
|
|
46
|
+
prompt = f"""为以下文章生成 3-5 个标签,用逗号分隔(英文)。
|
|
47
|
+
适合 Obsidian Dataview 查询,尽量使用通用概念词。
|
|
48
|
+
|
|
49
|
+
标题:{title}
|
|
50
|
+
正文摘要:{body[:500]}
|
|
51
|
+
|
|
52
|
+
只返回标签,不要其他内容。示例格式:machine-learning, remote-sensing, air-quality"""
|
|
53
|
+
try:
|
|
54
|
+
result = call_deepseek(prompt, api_key, max_tokens=60, temperature=0.3)
|
|
55
|
+
tags = [t.strip().lower().replace(' ', '-') for t in result.split(',')]
|
|
56
|
+
return [t for t in tags if t and len(t) < 30][:5]
|
|
57
|
+
except Exception as e:
|
|
58
|
+
print(f' [WARN] AI 标签生成失败: {e}')
|
|
59
|
+
return []
|
|
60
|
+
|
|
61
|
+
|
|
62
|
+
def write_frontmatter(filepath: Path, fm: dict, body: str):
|
|
63
|
+
"""写回带 frontmatter 的文件。"""
|
|
64
|
+
lines = ['---']
|
|
65
|
+
for k, v in fm.items():
|
|
66
|
+
if v is None or v == '' or v == []:
|
|
67
|
+
continue
|
|
68
|
+
if isinstance(v, list):
|
|
69
|
+
lines.append(f'{k}: [{", ".join(v)}]')
|
|
70
|
+
else:
|
|
71
|
+
lines.append(f'{k}: "{v}"')
|
|
72
|
+
lines.append('---')
|
|
73
|
+
lines.append('')
|
|
74
|
+
lines.append(body)
|
|
75
|
+
filepath.write_text('\n'.join(lines), encoding='utf-8')
|
|
76
|
+
|
|
77
|
+
|
|
78
|
+
def main():
|
|
79
|
+
sys.stdout.reconfigure(encoding='utf-8', errors='replace')
|
|
80
|
+
import argparse
|
|
81
|
+
parser = argparse.ArgumentParser(description='AI 自动标签 → 统一标签系统')
|
|
82
|
+
parser.add_argument('--date', required=True, help='日期 YYYY-MM-DD')
|
|
83
|
+
parser.add_argument('--source', default=DEFAULT_SOURCE, help='源目录')
|
|
84
|
+
parser.add_argument('--api-key', default='', help='DeepSeek API key')
|
|
85
|
+
parser.add_argument('--force', action='store_true', help='覆盖已有标签')
|
|
86
|
+
args = parser.parse_args()
|
|
87
|
+
|
|
88
|
+
api_key = args.api_key or os.environ.get('DEEPSEEK_API_KEY', '')
|
|
89
|
+
if not api_key:
|
|
90
|
+
print('[ERROR] 缺少 API Key(--api-key 或 DEEPSEEK_API_KEY 环境变量)')
|
|
91
|
+
sys.exit(1)
|
|
92
|
+
|
|
93
|
+
date_dir = os.path.join(args.source, args.date)
|
|
94
|
+
if not os.path.isdir(date_dir):
|
|
95
|
+
print(f'[ERROR] 目录不存在: {date_dir}')
|
|
96
|
+
sys.exit(1)
|
|
97
|
+
|
|
98
|
+
tagged = 0
|
|
99
|
+
skipped = 0
|
|
100
|
+
for topic in TOPIC_ORDER:
|
|
101
|
+
topic_dir = Path(date_dir) / topic
|
|
102
|
+
if not topic_dir.is_dir():
|
|
103
|
+
continue
|
|
104
|
+
for md_file in sorted(topic_dir.glob('*.md')):
|
|
105
|
+
try:
|
|
106
|
+
content = md_file.read_text(encoding='utf-8')
|
|
107
|
+
except Exception:
|
|
108
|
+
continue
|
|
109
|
+
fm, body = parse_frontmatter(content)
|
|
110
|
+
existing = fm.get('tags', [])
|
|
111
|
+
if existing and not args.force:
|
|
112
|
+
skipped += 1
|
|
113
|
+
continue
|
|
114
|
+
|
|
115
|
+
print(f' {topic}/ {md_file.name[:50]}')
|
|
116
|
+
new_tags = generate_tags(fm.get('title', md_file.stem), body, api_key)
|
|
117
|
+
if new_tags:
|
|
118
|
+
fm['tags'] = new_tags
|
|
119
|
+
write_frontmatter(md_file, fm, body)
|
|
120
|
+
tagged += 1
|
|
121
|
+
print(f' → {", ".join(new_tags)}')
|
|
122
|
+
time.sleep(0.5) # 避免限流
|
|
123
|
+
|
|
124
|
+
print(f'\n✓ 完成: {tagged} 篇新增标签, {skipped} 篇已有标签')
|
|
125
|
+
|
|
126
|
+
|
|
127
|
+
if __name__ == '__main__':
|
|
128
|
+
main()
|