refactor: use script_dir for init paths
This commit is contained in:
20
agentmain.py
20
agentmain.py
@@ -14,14 +14,18 @@ with open(os.path.join(script_dir, 'assets/tools_schema.json'), 'r', encoding='u
|
|||||||
TS = f.read()
|
TS = f.read()
|
||||||
TOOLS_SCHEMA = json.loads(TS if os.name == 'nt' else TS.replace('powershell', 'bash'))
|
TOOLS_SCHEMA = json.loads(TS if os.name == 'nt' else TS.replace('powershell', 'bash'))
|
||||||
|
|
||||||
if not os.path.exists('memory'): os.makedirs('memory')
|
mem_dir = os.path.join(script_dir, 'memory')
|
||||||
if not os.path.exists('memory/global_mem.txt'):
|
if not os.path.exists(mem_dir): os.makedirs(mem_dir)
|
||||||
with open('memory/global_mem.txt', 'w', encoding='utf-8') as f: f.write('')
|
mem_txt = os.path.join(mem_dir, 'global_mem.txt')
|
||||||
if not os.path.exists('memory/global_mem_insight.txt'):
|
if not os.path.exists(mem_txt):
|
||||||
t = 'assets/global_mem_insight_template.txt'
|
with open(mem_txt, 'w', encoding='utf-8') as f: f.write('')
|
||||||
open('memory/global_mem_insight.txt', 'w', encoding='utf-8').write(open(t, encoding='utf-8').read() if os.path.exists(t) else '')
|
mem_insight = os.path.join(mem_dir, 'global_mem_insight.txt')
|
||||||
if not os.path.exists('assets/tmwd_cdp_bridge/config.js'):
|
if not os.path.exists(mem_insight):
|
||||||
with open('assets/tmwd_cdp_bridge/config.js', 'w', encoding='utf-8') as f:
|
t = os.path.join(script_dir, 'assets/global_mem_insight_template.txt')
|
||||||
|
open(mem_insight, 'w', encoding='utf-8').write(open(t, encoding='utf-8').read() if os.path.exists(t) else '')
|
||||||
|
cdp_cfg = os.path.join(script_dir, 'assets/tmwd_cdp_bridge/config.js')
|
||||||
|
if not os.path.exists(cdp_cfg):
|
||||||
|
with open(cdp_cfg, 'w', encoding='utf-8') as f:
|
||||||
f.write(f"const TID = '__ljq_{hex(random.randint(0, 99999999))[2:8]}';")
|
f.write(f"const TID = '__ljq_{hex(random.randint(0, 99999999))[2:8]}';")
|
||||||
|
|
||||||
def get_system_prompt():
|
def get_system_prompt():
|
||||||
|
|||||||
Reference in New Issue
Block a user