54 lines
2.1 KiB
Python
54 lines
2.1 KiB
Python
from pathlib import Path
|
|
|
|
DEFAULT_LINK = "https://acnuoqgha8fk.feishu.cn/wiki/RBSxwq8woiQDCUkRZfkcg7x8nMb?table=tblzuMy85WiRAUX5&view=vewuydm9EI"
|
|
DEFAULT_APP_TOKEN = "SZ4ebCKU3a9OdfspetxcSeg1n4g"
|
|
DEFAULT_TABLE_ID = "tblzuMy85WiRAUX5"
|
|
|
|
agents = Path('/root/.openclaw/workspace/AGENTS.md')
|
|
text = agents.read_text(encoding='utf-8')
|
|
|
|
start = text.find('## 5) Feishu Delivery Rules\n')
|
|
end = text.find('\n## 6) Workspace Paths\n', start)
|
|
if start == -1 or end == -1:
|
|
raise SystemExit('Feishu section not found in AGENTS.md')
|
|
|
|
new_section = f'''## 5) Feishu Delivery Rules
|
|
|
|
Trigger keywords: 推到飞书表格 / 写入飞书 / 同步飞书 / 发送飞书表格链接
|
|
|
|
Default target (pinned):
|
|
- default_link: {DEFAULT_LINK}
|
|
- default_app_token: {DEFAULT_APP_TOKEN}
|
|
- default_table_id: {DEFAULT_TABLE_ID}
|
|
|
|
Required behavior:
|
|
- When user asks to push result to Feishu Bitable, run write action first (feishu_bitable_create_record or feishu_bitable_update_record).
|
|
- In continuous chat, if user says "把上一个结果推到飞书", use the previous assistant result as write payload.
|
|
- If user does not provide a link in current turn, ALWAYS use the pinned default target above.
|
|
- Do NOT ask user for Feishu link again unless user explicitly asks to switch to another table.
|
|
- In final reply, always include:
|
|
1) push status (success/failed)
|
|
2) target sheet link (actual link used)
|
|
3) written record_id (or updated count)
|
|
- If write partially fails, return succeeded records and failed reason list separately.
|
|
- If user explicitly asks for "只要结果", keep reasoning short but still include the sheet link and write status line.
|
|
|
|
'''
|
|
|
|
text = text[:start] + new_section + text[end+1:]
|
|
agents.write_text(text, encoding='utf-8')
|
|
print('updated', agents)
|
|
|
|
user = Path('/root/.openclaw/workspace/USER.md')
|
|
ut = user.read_text(encoding='utf-8')
|
|
line = f'- 飞书推送默认固定到:{DEFAULT_LINK}'
|
|
line2 = '- 除非我明确要求切换,不要再向我索要飞书表格链接。'
|
|
if line not in ut:
|
|
if not ut.endswith('\n'):
|
|
ut += '\n'
|
|
ut += line + '\n'
|
|
if line2 not in ut:
|
|
ut += line2 + '\n'
|
|
user.write_text(ut, encoding='utf-8')
|
|
print('updated', user)
|