{
"event": "PreToolUse",
"tool_name": "Edit",
"tool_input": {
"file_path": "\/var\/www\/migration\/content-pipeline\/src\/web_chat.py",
"old_string": "# Change to pipeline directory and add to path\nPIPELINE_PATH = \"\/var\/www\/scripts\/pipeline\"\nos.chdir(PIPELINE_PATH)\nsys.path.insert(0, PIPELINE_PATH)",
"new_string": "# Add current directory to path (portable)\nPIPELINE_PATH = os.path.dirname(os.path.abspath(__file__))\nos.chdir(PIPELINE_PATH)\nsys.path.insert(0, PIPELINE_PATH)"
}
}
{
"tool_response": {
"filePath": "\/var\/www\/migration\/content-pipeline\/src\/web_chat.py",
"oldString": "# Change to pipeline directory and add to path\nPIPELINE_PATH = \"\/var\/www\/scripts\/pipeline\"\nos.chdir(PIPELINE_PATH)\nsys.path.insert(0, PIPELINE_PATH)",
"newString": "# Add current directory to path (portable)\nPIPELINE_PATH = os.path.dirname(os.path.abspath(__file__))\nos.chdir(PIPELINE_PATH)\nsys.path.insert(0, PIPELINE_PATH)",
"originalFile": "#!\/usr\/bin\/env python3\n\"\"\"\nWeb Chat Interface for KI-System\nCalled from PHP with question file as argument.\n\"\"\"\n\nimport json\nimport os\nimport sys\n\n# Change to pipeline directory and add to path\nPIPELINE_PATH = \"\/var\/www\/scripts\/pipeline\"\nos.chdir(PIPELINE_PATH)\nsys.path.insert(0, PIPELINE_PATH)\n\nfrom chat import chat\n\n\ndef main():\n \"\"\"Process chat question from file and return JSON response.\"\"\"\n if len(sys.argv) < 2:\n print(json.dumps({\"error\": \"No question file provided\"}))\n return\n\n question_file = sys.argv[1]\n\n try:\n with open(question_file, encoding=\"utf-8\") as f:\n question = f.read().strip()\n\n if not question:\n print(json.dumps({\"error\": \"Empty question\"}))\n return\n\n result = chat(question)\n print(json.dumps(result, ensure_ascii=False))\n\n except Exception as e:\n print(json.dumps({\"error\": str(e)}))\n\n\nif __name__ == \"__main__\":\n main()\n",
"structuredPatch": [
{
"oldStart": 8,
"oldLines": 8,
"newStart": 8,
"newLines": 8,
"lines": [
" import os",
" import sys",
" ",
"-# Change to pipeline directory and add to path",
"-PIPELINE_PATH = \"\/var\/www\/scripts\/pipeline\"",
"+# Add current directory to path (portable)",
"+PIPELINE_PATH = os.path.dirname(os.path.abspath(__file__))",
" os.chdir(PIPELINE_PATH)",
" sys.path.insert(0, PIPELINE_PATH)",
" "
]
}
],
"userModified": false,
"replaceAll": false
}
}