feat: add dingtalk-feishu-collector SOP skill
Reusable 6-step pipeline for collecting DingTalk group messages, extracting Feishu doc links, fetching content, and generating summaries. Skills structure: - SKILL.md: trigger rules, workflow, config reference - config.yaml: group IDs, collection settings - scripts/paths.py: shared path resolution - scripts/step1-6: modular pipeline steps - scripts/run_all.py: one-click runner
This commit is contained in:
@@ -0,0 +1,75 @@
|
||||
"""共享路径和配置工具"""
|
||||
|
||||
import os
|
||||
import sys
|
||||
|
||||
def find_project_root():
|
||||
"""向上查找项目根目录(包含 data/ 目录的最顶层)"""
|
||||
# 从当前脚本位置开始
|
||||
script_dir = os.path.dirname(os.path.abspath(__file__))
|
||||
|
||||
# 向上查找,找到包含 data/ 目录的目录
|
||||
d = script_dir
|
||||
for _ in range(5): # 最多向上5级
|
||||
if os.path.isdir(os.path.join(d, "data")):
|
||||
return d
|
||||
parent = os.path.dirname(d)
|
||||
if parent == d:
|
||||
break
|
||||
d = parent
|
||||
|
||||
# 如果找不到,假设项目根在 scripts/ 的上一级
|
||||
return os.path.dirname(os.path.dirname(script_dir))
|
||||
|
||||
def find_dws():
|
||||
"""查找 dws CLI"""
|
||||
import shutil
|
||||
|
||||
# 1. 环境变量
|
||||
env = os.environ.get("DWS_PATH")
|
||||
if env and os.path.isfile(env):
|
||||
return env
|
||||
|
||||
# 2. 项目 tools/ 目录
|
||||
root = find_project_root()
|
||||
local = os.path.join(root, "tools", "dws.exe")
|
||||
if os.path.isfile(local):
|
||||
return local
|
||||
|
||||
# 3. 悟空内置
|
||||
candidates = [
|
||||
os.path.expanduser(r"~\.real\.bin\dws\bin\dws.exe"),
|
||||
r"C:\Program Files\Wukong\0.9.51-26052503\bin\dws.exe",
|
||||
]
|
||||
for p in candidates:
|
||||
if os.path.isfile(p):
|
||||
return p
|
||||
|
||||
# 4. PATH
|
||||
found = shutil.which("dws")
|
||||
if found:
|
||||
return found
|
||||
|
||||
print("ERROR: 找不到 dws CLI,请设置 DWS_PATH 环境变量或安装悟空", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
def find_lark_cli():
|
||||
"""查找 lark-cli"""
|
||||
import shutil
|
||||
found = shutil.which("lark-cli")
|
||||
if found:
|
||||
return found
|
||||
print("ERROR: 找不到 lark-cli,请运行 npm install -g @larksuite/cli", file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
# 常用路径
|
||||
PROJECT_ROOT = find_project_root()
|
||||
DATA_DIR = os.path.join(PROJECT_ROOT, "data")
|
||||
RAW_DIR = os.path.join(DATA_DIR, "raw-messages")
|
||||
LINKS_DIR = os.path.join(DATA_DIR, "links")
|
||||
OUTPUT_DIR = os.path.join(PROJECT_ROOT, "output")
|
||||
DOCS_DIR = os.path.join(OUTPUT_DIR, "feishu-docs")
|
||||
REPORTS_DIR = os.path.join(OUTPUT_DIR, "reports")
|
||||
DOWNLOAD_DIR = os.path.join(OUTPUT_DIR, "downloaded-files")
|
||||
OBSIDIAN_DIR = os.path.join(OUTPUT_DIR, "obsidian-vault")
|
||||
KG_DIR = os.path.join(OUTPUT_DIR, "knowledge-graph")
|
||||
Reference in New Issue
Block a user