diff --git a/kb-workflow/SKILL.md b/kb-workflow/SKILL.md index 260d97b..f25bf93 100644 --- a/kb-workflow/SKILL.md +++ b/kb-workflow/SKILL.md @@ -36,6 +36,8 @@ export AI_BASE_URL="https://open.bigmodel.cn/api/coding/paas/v4" | `BILIBILI_COOKIE` | 下载会员视频 | `SESSDATA=xxx; bili_jct=xxx` | | `KB_GIT_USER` | Git提交用户名 | `Your Name` | | `KB_GIT_EMAIL` | Git提交邮箱 | `your@email.com` | +| `KB_ARCHIVE_PATH` | 归档目录路径 | `~/work/zq/30.资源/AI分析` | +| `KB_GIT_ROOT` | Git仓库根目录 | `~/work/zq` | ### 检查命令 @@ -445,10 +447,9 @@ python3 kb_workflow.py --archive-file "[分析报告文件路径]" ## 目录结构 +**工作目录(~/work/knowledge-base/):** ``` ~/work/knowledge-base/ -├── archive/ -│ └── YYYY-MM-DD/ ├── pending/ │ └── {platform}_{id}.link.json ├── metadata/ @@ -462,6 +463,16 @@ python3 kb_workflow.py --archive-file "[分析报告文件路径]" └── {platform}_{id}.md ``` +**归档目录(~/work/zq/30.资源/AI分析/):** +``` +~/work/zq/30.资源/AI分析/ +└── YYYY-MM-DD/ + ├── {platform}_{id}.md # 深度分析报告 + └── {platform}_{id}.meta.json # 元数据(可选) +``` + +> 📌 **注意**:归档目录通过 `KB_ARCHIVE_PATH` 环境变量配置,默认为 `~/work/zq/30.资源/AI分析` + ## 辅助命令 ```bash diff --git a/kb-workflow/kb_workflow.py b/kb-workflow/kb_workflow.py index 979ff08..40fd971 100644 --- a/kb-workflow/kb_workflow.py +++ b/kb-workflow/kb_workflow.py @@ -104,6 +104,24 @@ def get_knowledge_base_path() -> Path: return Path.home() / "work" / "knowledge-base" +def get_archive_path() -> Path: + """获取归档目录(AI分析文档存放位置)""" + archive_path_str = os.environ.get('KB_ARCHIVE_PATH', '') + if archive_path_str: + return Path(archive_path_str).expanduser() + # 默认:~/work/zq/30.资源/AI分析 + return Path.home() / "work" / "zq" / "30.资源" / "AI分析" + + +def get_git_root() -> Path: + """获取 Git 仓库根目录(用于归档提交)""" + git_root_str = os.environ.get('KB_GIT_ROOT', '') + if git_root_str: + return Path(git_root_str).expanduser() + # 默认:~/work/zq + return Path.home() / "work" / "zq" + + def ensure_directories(base_path: Path = None) -> Dict[str, Path]: """确保目录存在""" if base_path is None: @@ -173,7 +191,7 @@ def archive_and_git( if base_path is None: base_path = get_knowledge_base_path() if git_root is None: - git_root = base_path / "archive" + git_root = get_git_root() if git_user is None: git_user = os.environ.get('KB_GIT_USER', '') if git_email is None: @@ -222,7 +240,8 @@ def archive_and_git( # 2. 创建归档目录 date_str = datetime.now().strftime('%Y-%m-%d') - date_dir = base_path / "archive" / date_str + archive_base = get_archive_path() + date_dir = archive_base / date_str date_dir.mkdir(parents=True, exist_ok=True) # 3. 复制分析报告 @@ -365,7 +384,7 @@ def main(): print(json.dumps({"path": str(dirs["analyzed"])}, ensure_ascii=False, indent=2)) elif args.archive_dir: - print(json.dumps({"path": str(dirs["archive"])}, ensure_ascii=False, indent=2)) + print(json.dumps({"path": str(get_archive_path())}, ensure_ascii=False, indent=2)) elif args.archive_subscriptions: print(json.dumps({"path": str(dirs["archive_subscriptions"])}, ensure_ascii=False, indent=2))