🔄 卡若AI 同步 2026-03-05 05:50 | 更新:总索引与入口、水桥平台对接、运营中枢工作台 | 排除 >20MB: 11 个
This commit is contained in:
3
.gitignore
vendored
3
.gitignore
vendored
@@ -23,6 +23,9 @@ sync_tokens.env
|
|||||||
# 飞书妙记(用户 token / Cookie,勿提交)
|
# 飞书妙记(用户 token / Cookie,勿提交)
|
||||||
**/智能纪要/脚本/feishu_user_token.txt
|
**/智能纪要/脚本/feishu_user_token.txt
|
||||||
**/智能纪要/脚本/cookie_minutes.txt
|
**/智能纪要/脚本/cookie_minutes.txt
|
||||||
|
# 飞书日志:用户授权 token 与月度文档 token(勿提交)
|
||||||
|
**/飞书管理/脚本/.feishu_tokens.json
|
||||||
|
**/飞书管理/脚本/.feishu_month_wiki_tokens.json
|
||||||
|
|
||||||
# 卡若AI 网关:多租户配置与访问日志(不入库)
|
# 卡若AI 网关:多租户配置与访问日志(不入库)
|
||||||
运营中枢/scripts/karuo_ai_gateway/config/gateway.yaml
|
运营中枢/scripts/karuo_ai_gateway/config/gateway.yaml
|
||||||
|
|||||||
@@ -109,6 +109,20 @@ python3 /Users/karuo/Documents/个人/卡若AI/02_卡人(水)/水桥_平台
|
|||||||
|
|
||||||
---
|
---
|
||||||
|
|
||||||
|
## Token 命令行(获取 / 写入均用命令行)
|
||||||
|
|
||||||
|
所有 Token 的获取与写入均通过命令行完成,无需手改配置文件。
|
||||||
|
|
||||||
|
| 命令 | 说明 |
|
||||||
|
|:---|:---|
|
||||||
|
| `python3 脚本/feishu_token_cli.py get-access-token` | 刷新并输出 access_token,并写入 `脚本/.feishu_tokens.json` |
|
||||||
|
| `python3 脚本/feishu_token_cli.py set-march-token <token>` | 将 3 月文档 wiki token 写入 `脚本/.feishu_month_wiki_tokens.json`,供 auto_log / write_today_three_focus 读取 |
|
||||||
|
| `python3 脚本/feishu_token_cli.py get-march-token` | 输出当前 3 月 wiki token(优先环境变量 `FEISHU_MARCH_WIKI_TOKEN`,否则读本地文件) |
|
||||||
|
|
||||||
|
**3 月 token 读取顺序**:环境变量 `FEISHU_MARCH_WIKI_TOKEN` → 本地 `脚本/.feishu_month_wiki_tokens.json` → CONFIG。写入用 `set-march-token` 即可,无需改代码或 .env。
|
||||||
|
|
||||||
|
---
|
||||||
|
|
||||||
## 日志格式规范
|
## 日志格式规范
|
||||||
|
|
||||||
### 1. 插入顺序:倒序
|
### 1. 插入顺序:倒序
|
||||||
|
|||||||
@@ -240,17 +240,38 @@ def parse_month_from_date_str(date_str):
|
|||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
||||||
|
def _get_month_wiki_token(month):
|
||||||
|
"""当月 wiki token:3 月优先 环境变量 > 本地 .feishu_month_wiki_tokens.json > CONFIG"""
|
||||||
|
if month == 3:
|
||||||
|
v = os.environ.get("FEISHU_MARCH_WIKI_TOKEN", "").strip()
|
||||||
|
if v:
|
||||||
|
return v
|
||||||
|
try:
|
||||||
|
path = os.path.join(os.path.dirname(__file__), ".feishu_month_wiki_tokens.json")
|
||||||
|
if os.path.exists(path):
|
||||||
|
with open(path, encoding="utf-8") as f:
|
||||||
|
v = (json.load(f).get("3") or "").strip()
|
||||||
|
if v:
|
||||||
|
return v
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return (CONFIG.get("MONTH_WIKI_TOKENS") or {}).get(3) or ""
|
||||||
|
return (CONFIG.get("MONTH_WIKI_TOKENS") or {}).get(month) or ""
|
||||||
|
|
||||||
|
|
||||||
def resolve_wiki_token_for_date(date_str, explicit_wiki_token=None):
|
def resolve_wiki_token_for_date(date_str, explicit_wiki_token=None):
|
||||||
"""根据日期路由文档token;允许显式覆盖;当月 token 为空时返回 None"""
|
"""根据日期路由文档token;允许显式覆盖;当月 token 为空时返回 None"""
|
||||||
if explicit_wiki_token:
|
if explicit_wiki_token:
|
||||||
return explicit_wiki_token
|
return explicit_wiki_token
|
||||||
month = parse_month_from_date_str(date_str)
|
month = parse_month_from_date_str(date_str)
|
||||||
if month and month in CONFIG.get('MONTH_WIKI_TOKENS', {}):
|
if month:
|
||||||
tok = CONFIG['MONTH_WIKI_TOKENS'][month]
|
tok = _get_month_wiki_token(month)
|
||||||
if tok and str(tok).strip():
|
if tok and str(tok).strip():
|
||||||
return tok
|
return tok
|
||||||
return None # 当月未配置 token(如 3 月需 FEISHU_MARCH_WIKI_TOKEN)
|
if month in (1, 2):
|
||||||
return CONFIG['WIKI_TOKEN']
|
return CONFIG["MONTH_WIKI_TOKENS"].get(month) or CONFIG["WIKI_TOKEN"]
|
||||||
|
return None # 3 月等未配置时返回 None
|
||||||
|
return CONFIG["WIKI_TOKEN"]
|
||||||
|
|
||||||
def _find_date_section_block_ids(blocks, date_str, doc_id):
|
def _find_date_section_block_ids(blocks, date_str, doc_id):
|
||||||
"""找到某日期区块的 block_id 列表(用于覆盖删除)"""
|
"""找到某日期区块的 block_id 列表(用于覆盖删除)"""
|
||||||
|
|||||||
87
02_卡人(水)/水桥_平台对接/飞书管理/脚本/feishu_token_cli.py
Normal file
87
02_卡人(水)/水桥_平台对接/飞书管理/脚本/feishu_token_cli.py
Normal file
@@ -0,0 +1,87 @@
|
|||||||
|
#!/usr/bin/env python3
|
||||||
|
"""
|
||||||
|
飞书 Token 命令行:获取 access_token、写入/读取月度 wiki token,全部用命令行操作。
|
||||||
|
用法:
|
||||||
|
python3 feishu_token_cli.py get-access-token # 刷新并输出 access_token,写入 .feishu_tokens.json
|
||||||
|
python3 feishu_token_cli.py set-march-token <token> # 将 3 月文档 token 写入本地,供 auto_log 读取
|
||||||
|
python3 feishu_token_cli.py get-march-token # 输出当前 3 月 wiki token(env 或本地文件)
|
||||||
|
"""
|
||||||
|
import os
|
||||||
|
import sys
|
||||||
|
import json
|
||||||
|
from pathlib import Path
|
||||||
|
|
||||||
|
SCRIPT_DIR = Path(__file__).resolve().parent
|
||||||
|
MONTH_TOKENS_FILE = SCRIPT_DIR / ".feishu_month_wiki_tokens.json"
|
||||||
|
|
||||||
|
|
||||||
|
def _load_month_tokens():
|
||||||
|
if MONTH_TOKENS_FILE.exists():
|
||||||
|
try:
|
||||||
|
with open(MONTH_TOKENS_FILE, "r", encoding="utf-8") as f:
|
||||||
|
return json.load(f)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
|
return {}
|
||||||
|
|
||||||
|
|
||||||
|
def _save_month_tokens(data):
|
||||||
|
with open(MONTH_TOKENS_FILE, "w", encoding="utf-8") as f:
|
||||||
|
json.dump(data, f, ensure_ascii=False, indent=2)
|
||||||
|
|
||||||
|
|
||||||
|
def cmd_get_access_token():
|
||||||
|
sys.path.insert(0, str(SCRIPT_DIR))
|
||||||
|
from auto_log import get_token_silent, load_tokens
|
||||||
|
token = get_token_silent()
|
||||||
|
if token:
|
||||||
|
print(token)
|
||||||
|
return 0
|
||||||
|
print("", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
def cmd_set_march_token(token_value):
|
||||||
|
token_value = (token_value or "").strip()
|
||||||
|
if not token_value:
|
||||||
|
print("用法: feishu_token_cli.py set-march-token <token>", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
data = _load_month_tokens()
|
||||||
|
data["3"] = token_value
|
||||||
|
_save_month_tokens(data)
|
||||||
|
print(f"✅ 3 月 wiki token 已写入 {MONTH_TOKENS_FILE}")
|
||||||
|
return 0
|
||||||
|
|
||||||
|
|
||||||
|
def cmd_get_march_token():
|
||||||
|
# 优先环境变量
|
||||||
|
env_tok = os.environ.get("FEISHU_MARCH_WIKI_TOKEN", "").strip()
|
||||||
|
if env_tok:
|
||||||
|
print(env_tok)
|
||||||
|
return 0
|
||||||
|
data = _load_month_tokens()
|
||||||
|
tok = data.get("3", "").strip()
|
||||||
|
if tok:
|
||||||
|
print(tok)
|
||||||
|
return 0
|
||||||
|
print("", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
def main():
|
||||||
|
if len(sys.argv) < 2:
|
||||||
|
print(__doc__.strip(), file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
cmd = sys.argv[1].lower()
|
||||||
|
if cmd == "get-access-token":
|
||||||
|
return cmd_get_access_token()
|
||||||
|
if cmd == "set-march-token":
|
||||||
|
return cmd_set_march_token(sys.argv[2] if len(sys.argv) > 2 else None)
|
||||||
|
if cmd == "get-march-token":
|
||||||
|
return cmd_get_march_token()
|
||||||
|
print(f"未知命令: {cmd}", file=sys.stderr)
|
||||||
|
return 1
|
||||||
|
|
||||||
|
|
||||||
|
if __name__ == "__main__":
|
||||||
|
sys.exit(main())
|
||||||
@@ -231,3 +231,4 @@
|
|||||||
| 2026-03-05 05:30:03 | 🔄 卡若AI 同步 2026-03-05 05:30 | 更新:水桥平台对接、运营中枢工作台 | 排除 >20MB: 11 个 |
|
| 2026-03-05 05:30:03 | 🔄 卡若AI 同步 2026-03-05 05:30 | 更新:水桥平台对接、运营中枢工作台 | 排除 >20MB: 11 个 |
|
||||||
| 2026-03-05 05:45:06 | 🔄 卡若AI 同步 2026-03-05 05:45 | 更新:水桥平台对接、运营中枢工作台 | 排除 >20MB: 11 个 |
|
| 2026-03-05 05:45:06 | 🔄 卡若AI 同步 2026-03-05 05:45 | 更新:水桥平台对接、运营中枢工作台 | 排除 >20MB: 11 个 |
|
||||||
| 2026-03-05 05:46:16 | 🔄 卡若AI 同步 2026-03-05 05:46 | 更新:运营中枢参考资料、运营中枢工作台 | 排除 >20MB: 11 个 |
|
| 2026-03-05 05:46:16 | 🔄 卡若AI 同步 2026-03-05 05:46 | 更新:运营中枢参考资料、运营中枢工作台 | 排除 >20MB: 11 个 |
|
||||||
|
| 2026-03-05 05:47:24 | 🔄 卡若AI 同步 2026-03-05 05:47 | 更新:Cursor规则、水桥平台对接、运营中枢工作台 | 排除 >20MB: 11 个 |
|
||||||
|
|||||||
@@ -234,3 +234,4 @@
|
|||||||
| 2026-03-05 05:30:03 | 成功 | 成功 | 🔄 卡若AI 同步 2026-03-05 05:30 | 更新:水桥平台对接、运营中枢工作台 | 排除 >20MB: 11 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) |
|
| 2026-03-05 05:30:03 | 成功 | 成功 | 🔄 卡若AI 同步 2026-03-05 05:30 | 更新:水桥平台对接、运营中枢工作台 | 排除 >20MB: 11 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) |
|
||||||
| 2026-03-05 05:45:06 | 成功 | 成功 | 🔄 卡若AI 同步 2026-03-05 05:45 | 更新:水桥平台对接、运营中枢工作台 | 排除 >20MB: 11 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) |
|
| 2026-03-05 05:45:06 | 成功 | 成功 | 🔄 卡若AI 同步 2026-03-05 05:45 | 更新:水桥平台对接、运营中枢工作台 | 排除 >20MB: 11 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) |
|
||||||
| 2026-03-05 05:46:16 | 成功 | 成功 | 🔄 卡若AI 同步 2026-03-05 05:46 | 更新:运营中枢参考资料、运营中枢工作台 | 排除 >20MB: 11 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) |
|
| 2026-03-05 05:46:16 | 成功 | 成功 | 🔄 卡若AI 同步 2026-03-05 05:46 | 更新:运营中枢参考资料、运营中枢工作台 | 排除 >20MB: 11 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) |
|
||||||
|
| 2026-03-05 05:47:24 | 成功 | 成功 | 🔄 卡若AI 同步 2026-03-05 05:47 | 更新:Cursor规则、水桥平台对接、运营中枢工作台 | 排除 >20MB: 11 个 | [仓库](http://open.quwanzhi.com:3000/fnvtk/karuo-ai) [百科](http://open.quwanzhi.com:3000/fnvtk/karuo-ai/wiki) |
|
||||||
|
|||||||
Reference in New Issue
Block a user