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.
Files changed (145) hide show
  1. package/LICENSE +21 -0
  2. package/README.md +149 -0
  3. package/bin/weflow-cli-electron.cjs +59 -0
  4. package/bin/weflow-cli.ts +2311 -0
  5. package/cli.cjs +3 -0
  6. package/dist/bin/weflow-cli.d.ts +3 -0
  7. package/dist/bin/weflow-cli.d.ts.map +1 -0
  8. package/dist/bin/weflow-cli.js +2270 -0
  9. package/dist/bin/weflow-cli.js.map +1 -0
  10. package/dist/mcp-server/index.d.ts +3 -0
  11. package/dist/mcp-server/index.d.ts.map +1 -0
  12. package/dist/mcp-server/index.js +690 -0
  13. package/dist/mcp-server/index.js.map +1 -0
  14. package/dist/src/core/dbPathService.d.ts +40 -0
  15. package/dist/src/core/dbPathService.d.ts.map +1 -0
  16. package/dist/src/core/dbPathService.js +324 -0
  17. package/dist/src/core/dbPathService.js.map +1 -0
  18. package/dist/src/core/keyService.d.ts +59 -0
  19. package/dist/src/core/keyService.d.ts.map +1 -0
  20. package/dist/src/core/keyService.js +368 -0
  21. package/dist/src/core/keyService.js.map +1 -0
  22. package/dist/src/core/ntCore.d.ts +62 -0
  23. package/dist/src/core/ntCore.d.ts.map +1 -0
  24. package/dist/src/core/ntCore.js +191 -0
  25. package/dist/src/core/ntCore.js.map +1 -0
  26. package/dist/src/core/sqlcipherCore.d.ts +119 -0
  27. package/dist/src/core/sqlcipherCore.d.ts.map +1 -0
  28. package/dist/src/core/sqlcipherCore.js +693 -0
  29. package/dist/src/core/sqlcipherCore.js.map +1 -0
  30. package/dist/src/core/wcdbCore.d.ts +738 -0
  31. package/dist/src/core/wcdbCore.d.ts.map +1 -0
  32. package/dist/src/core/wcdbCore.js +4545 -0
  33. package/dist/src/core/wcdbCore.js.map +1 -0
  34. package/dist/src/core/wechatClient.d.ts +23 -0
  35. package/dist/src/core/wechatClient.d.ts.map +1 -0
  36. package/dist/src/core/wechatClient.js +166 -0
  37. package/dist/src/core/wechatClient.js.map +1 -0
  38. package/dist/src/services/chatService.d.ts +25 -0
  39. package/dist/src/services/chatService.d.ts.map +1 -0
  40. package/dist/src/services/chatService.js +291 -0
  41. package/dist/src/services/chatService.js.map +1 -0
  42. package/dist/src/services/configService.d.ts +43 -0
  43. package/dist/src/services/configService.d.ts.map +1 -0
  44. package/dist/src/services/configService.js +156 -0
  45. package/dist/src/services/configService.js.map +1 -0
  46. package/dist/src/services/exportService.d.ts +30 -0
  47. package/dist/src/services/exportService.d.ts.map +1 -0
  48. package/dist/src/services/exportService.js +273 -0
  49. package/dist/src/services/exportService.js.map +1 -0
  50. package/dist/src/services/wechat-formatter.d.ts +69 -0
  51. package/dist/src/services/wechat-formatter.d.ts.map +1 -0
  52. package/dist/src/services/wechat-formatter.js +248 -0
  53. package/dist/src/services/wechat-formatter.js.map +1 -0
  54. package/dist/src/services/wechatMessageService.d.ts +28 -0
  55. package/dist/src/services/wechatMessageService.d.ts.map +1 -0
  56. package/dist/src/services/wechatMessageService.js +341 -0
  57. package/dist/src/services/wechatMessageService.js.map +1 -0
  58. package/dist/src/services/wereadService.d.ts +206 -0
  59. package/dist/src/services/wereadService.d.ts.map +1 -0
  60. package/dist/src/services/wereadService.js +145 -0
  61. package/dist/src/services/wereadService.js.map +1 -0
  62. package/dist/src/services/whitelistService.d.ts +20 -0
  63. package/dist/src/services/whitelistService.d.ts.map +1 -0
  64. package/dist/src/services/whitelistService.js +60 -0
  65. package/dist/src/services/whitelistService.js.map +1 -0
  66. package/dist/src/types.d.ts +140 -0
  67. package/dist/src/types.d.ts.map +1 -0
  68. package/dist/src/types.js +2 -0
  69. package/dist/src/types.js.map +1 -0
  70. package/dist/src/utils/errors.d.ts +25 -0
  71. package/dist/src/utils/errors.d.ts.map +1 -0
  72. package/dist/src/utils/errors.js +43 -0
  73. package/dist/src/utils/errors.js.map +1 -0
  74. package/dist/src/utils/pathUtils.d.ts +5 -0
  75. package/dist/src/utils/pathUtils.d.ts.map +1 -0
  76. package/dist/src/utils/pathUtils.js +16 -0
  77. package/dist/src/utils/pathUtils.js.map +1 -0
  78. package/dist/src/utils/pythonRunner.d.ts +27 -0
  79. package/dist/src/utils/pythonRunner.d.ts.map +1 -0
  80. package/dist/src/utils/pythonRunner.js +62 -0
  81. package/dist/src/utils/pythonRunner.js.map +1 -0
  82. package/dist/src/utils/talkerUtils.d.ts +14 -0
  83. package/dist/src/utils/talkerUtils.d.ts.map +1 -0
  84. package/dist/src/utils/talkerUtils.js +73 -0
  85. package/dist/src/utils/talkerUtils.js.map +1 -0
  86. package/mcp-server/index.ts +757 -0
  87. package/package.json +72 -0
  88. package/resources/key/win32/x64/wx_key.dll +0 -0
  89. package/resources/wcdb/win32/x64/SDL2.dll +0 -0
  90. package/resources/wcdb/win32/x64/WCDB.dll +0 -0
  91. package/resources/wcdb/win32/x64/msvcp140.dll +0 -0
  92. package/resources/wcdb/win32/x64/msvcp140_1.dll +0 -0
  93. package/resources/wcdb/win32/x64/vcruntime140.dll +0 -0
  94. package/resources/wcdb/win32/x64/vcruntime140_1.dll +0 -0
  95. package/resources/wcdb/win32/x64/wcdb_api.dll +0 -0
  96. package/scripts/_batch_link_sources.py +73 -0
  97. package/scripts/_utils.py +531 -0
  98. package/scripts/annual_report.py +796 -0
  99. package/scripts/auto_tag.py +128 -0
  100. package/scripts/biz_daily.py +896 -0
  101. package/scripts/chat_report.py +397 -0
  102. package/scripts/chat_stats.py +702 -0
  103. package/scripts/classify_daily.py +411 -0
  104. package/scripts/compile_wiki.py +258 -0
  105. package/scripts/create_reading_notes.py +370 -0
  106. package/scripts/enrich_backlinks.py +163 -0
  107. package/scripts/export_chat_html.py +766 -0
  108. package/scripts/extract_3x_key.py +86 -0
  109. package/scripts/extract_todos.py +404 -0
  110. package/scripts/fav_server.py +392 -0
  111. package/scripts/fix_topics.py +111 -0
  112. package/scripts/generate_ai_report.py +367 -0
  113. package/scripts/generate_html.py +1372 -0
  114. package/scripts/generate_review.py +170 -0
  115. package/scripts/mcp_bridge.py +398 -0
  116. package/scripts/nt_decrypt.py +562 -0
  117. package/scripts/pipeline.py +145 -0
  118. package/scripts/promote_all.py +310 -0
  119. package/scripts/promote_ideas.py +297 -0
  120. package/scripts/rag_chat.py +191 -0
  121. package/scripts/scan_decrypt_4x.py +329 -0
  122. package/scripts/semantic_search.py +431 -0
  123. package/scripts/sync_fav.py +146 -0
  124. package/scripts/sync_weread.py +192 -0
  125. package/scripts/vault_rag.py +139 -0
  126. package/scripts/vault_search.py +141 -0
  127. package/src/core/dbPathService.ts +348 -0
  128. package/src/core/keyService.ts +409 -0
  129. package/src/core/ntCore.ts +224 -0
  130. package/src/core/sqlcipherCore.ts +764 -0
  131. package/src/core/wcdbCore.ts +4568 -0
  132. package/src/core/wechatClient.ts +204 -0
  133. package/src/lz4.d.ts +10 -0
  134. package/src/services/chatService.ts +296 -0
  135. package/src/services/configService.ts +197 -0
  136. package/src/services/exportService.ts +305 -0
  137. package/src/services/wechat-formatter.ts +348 -0
  138. package/src/services/wechatMessageService.ts +383 -0
  139. package/src/services/wereadService.ts +308 -0
  140. package/src/services/whitelistService.ts +72 -0
  141. package/src/types.ts +141 -0
  142. package/src/utils/errors.ts +42 -0
  143. package/src/utils/pathUtils.ts +16 -0
  144. package/src/utils/pythonRunner.ts +81 -0
  145. 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()