1818import sys
1919from datetime import datetime , timedelta
2020from pathlib import Path
21- from typing import Any , Optional
21+ from typing import Any , Dict , List , Optional , Union
2222
2323
2424class Colors :
@@ -43,7 +43,7 @@ def log(level: str, msg: str) -> None:
4343 print (f" { prefix } { msg } " )
4444
4545
46- def run_lark_cli (args : list [str ], dry_run : bool = False ) -> Optional [dict | str ]:
46+ def run_lark_cli (args : List [str ], dry_run : bool = False ) -> Optional [Union [ Dict , str ] ]:
4747 cmd = ["lark-cli" ] + args
4848 if dry_run :
4949 log ("info" , f"[DRY-RUN] { Colors .BOLD } { ' ' .join (cmd )} { Colors .ENDC } " )
@@ -82,7 +82,7 @@ def __init__(
8282 self .output_dir = Path (output_dir ) / expert_name
8383 self .dry_run = dry_run
8484 self .skip_consent = skip_consent
85- self .data : dict [str , Any ] = {
85+ self .data : Dict [str , Any ] = {
8686 "expert" : expert_name ,
8787 "email" : expert_email ,
8888 "forge_time" : datetime .now ().isoformat (),
@@ -292,6 +292,7 @@ def step4_collect_wiki(self) -> None:
292292
293293 log ("step" , "搜索知识库节点..." )
294294
295+ # TODO: 替换为实际的知识库 space_id,可通过 lark-cli wiki spaces list 获取
295296 result = run_lark_cli (
296297 ["wiki" , "+nodes-list" , "--space-id" , "spacexxx" ],
297298 dry_run = self .dry_run ,
@@ -321,6 +322,7 @@ def step5_collect_meetings(self) -> None:
321322
322323 log ("step" , "获取会议纪要..." )
323324
325+ # TODO: 替换为实际的会议 ID,可通过 lark-cli calendar +event-list 获取
324326 result = run_lark_cli (
325327 ["minutes" , "+get" , "--meeting-id" , "meeting_xxx" ],
326328 dry_run = self .dry_run ,
@@ -353,6 +355,7 @@ def step6_create_knowledge_base(self) -> None:
353355
354356 log ("step" , f"创建「Relic 专家知识库 - { self .expert_name } 」多维表格..." )
355357
358+ # TODO: 替换为实际的文件夹 token,可通过 lark-cli drive +folders-list 获取
356359 result = run_lark_cli (
357360 [
358361 "base" ,
@@ -421,6 +424,7 @@ def step6_create_knowledge_base(self) -> None:
421424
422425 for entry in knowledge_entries :
423426 fields_data = json .dumps (entry , ensure_ascii = False )
427+ # TODO: 替换为实际的数据表 ID,可通过 lark-cli base +tables-list 获取
424428 run_lark_cli (
425429 [
426430 "base" ,
@@ -601,6 +605,24 @@ def step8_generate_relic(self) -> None:
601605 json .dump (relic_config ["manifest" ], f , ensure_ascii = False , indent = 2 )
602606 log ("ok" , f"Manifest 已生成: { manifest_path } " )
603607
608+ # 调用 relic_writer.py 生成完整 Relic 文件夹
609+ if not self .dry_run :
610+ relic_writer_cmd = [
611+ "python" , "scripts/relic_writer.py" ,
612+ "--data" , str (self .output_dir / "relic_config.json" ),
613+ "--template" , "expert" ,
614+ "--slug" , self .expert_name .lower ().replace (" " , "-" ),
615+ ]
616+ log ("info" , f"正在生成 Relic 文件夹..." )
617+ result = subprocess .run (relic_writer_cmd , capture_output = True , text = True , timeout = 60 )
618+ if result .returncode == 0 :
619+ log ("ok" , f"Relic 文件夹已生成" )
620+ else :
621+ log ("warn" , f"relic_writer.py 执行失败,请手动运行:{ ' ' .join (relic_writer_cmd )} " )
622+ log ("info" , result .stderr [:200 ] if result .stderr else "无错误信息" )
623+ else :
624+ log ("info" , f"[DRY-RUN] 将调用: python scripts/relic_writer.py --data { self .output_dir } /relic_config.json --template expert --slug { self .expert_name .lower ().replace (' ' , '-' )} " )
625+
604626 def forge (self ) -> None :
605627 print (f"\n { Colors .BOLD } { Colors .HEADER } ═══════════════════════════════════════{ Colors .ENDC } " )
606628 print (f"{ Colors .BOLD } { Colors .HEADER } 🔥 飞书 CLI 专家数字身份锻造炉 { Colors .ENDC } " )
0 commit comments