feat(kb-workflow): 归档目录改为 ~/work/zq/30.资源/AI分析
Deploy to knowledge-base / deploy (push) Failing after 0s

- 添加 KB_ARCHIVE_PATH 环境变量配置归档目录
- 添加 KB_GIT_ROOT 环境变量配置 Git 仓库根目录
- 默认归档到 ~/work/zq/30.资源/AI分析/YYYY-MM-DD/
- Git 提交到 ~/work/zq 仓库
- 更新 SKILL.md 文档说明新的目录结构
This commit is contained in:
2026-03-09 00:07:08 +08:00
parent ae8e68481b
commit 04c1ba2e80
2 changed files with 35 additions and 5 deletions
+22 -3
View File
@@ -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))