diff --git a/agentmain.py b/agentmain.py index cf1d47c09..189782738 100644 --- a/agentmain.py +++ b/agentmain.py @@ -265,7 +265,7 @@ def run(self): except Exception as e: print(f'[Reflect] on_done error: {e}') if getattr(mod, 'ONCE', False): print('[Reflect] ONCE=True, exiting.'); break else: - try: import readline + try: import readline # noqa: F401 — side-effect: enables REPL history except Exception: pass agent.inc_out = True if sys.stdout.isatty(): diff --git a/assets/agent_bbs.py b/assets/agent_bbs.py index d2fa931c9..632f3dbd2 100644 --- a/assets/agent_bbs.py +++ b/assets/agent_bbs.py @@ -5,7 +5,7 @@ import sqlite3, uuid, time, json, os from threading import Lock from fastapi import FastAPI, HTTPException, Query, Body, UploadFile, File -from fastapi.responses import JSONResponse, HTMLResponse, PlainTextResponse, FileResponse +from fastapi.responses import HTMLResponse, PlainTextResponse, FileResponse from contextlib import contextmanager from starlette.requests import Request from starlette.responses import Response diff --git a/assets/code_run_header.py b/assets/code_run_header.py index 59fb3416b..fe8d59e2f 100644 --- a/assets/code_run_header.py +++ b/assets/code_run_header.py @@ -1,4 +1,4 @@ -import sys, os, json, re, time, subprocess +import sys, os, subprocess sys.path.append(os.path.join(os.path.dirname(os.path.abspath(__file__)), '..', 'memory')) _r = subprocess.run def _d(b): diff --git a/frontends/conductor.py b/frontends/conductor.py index 8a15f4e2d..2fb4e716f 100644 --- a/frontends/conductor.py +++ b/frontends/conductor.py @@ -1,6 +1,6 @@ -import os, sys, re, time, json, uuid, queue, asyncio, threading, builtins +import os, sys, re, time, uuid, queue, asyncio, threading, builtins from dataclasses import dataclass, field -from typing import Dict, Any, Optional, List +from typing import Dict, Optional, List # Silence print() from subagent threads (they share stdout with conductor) _original_print = builtins.print diff --git a/frontends/dcapp.py b/frontends/dcapp.py index 481196d8c..1935f7e43 100644 --- a/frontends/dcapp.py +++ b/frontends/dcapp.py @@ -9,7 +9,7 @@ sys.path.insert(0, os.path.dirname(os.path.dirname(os.path.abspath(__file__)))) from agentmain import GeneraticAgent from chatapp_common import ( - AgentChatMixin, build_done_text, ensure_single_instance, extract_files, + AgentChatMixin, ensure_single_instance, extract_files, public_access, redirect_log, require_runtime, split_text, strip_files, clean_reply, HELP_TEXT, FILE_HINT, format_restore, _handle_continue_frontend, _reset_conversation, diff --git a/frontends/qtapp.py b/frontends/qtapp.py index 5e40a9c3f..19503cf98 100644 --- a/frontends/qtapp.py +++ b/frontends/qtapp.py @@ -20,7 +20,7 @@ ) from PySide6.QtCore import ( Qt, QTimer, QPoint, QPointF, QByteArray, QSize, - Signal, QMetaObject, Q_ARG, QObject, QDateTime, QEvent, + QDateTime, QEvent, ) from PySide6.QtGui import ( QPainter, QColor, QLinearGradient, QRadialGradient, @@ -29,7 +29,7 @@ sys.path.insert(0, os.path.abspath(os.path.join(os.path.dirname(__file__), '..'))) from agentmain import GeneraticAgent -from chatapp_common import FILE_HINT, HELP_TEXT, clean_reply, build_done_text, format_restore +from chatapp_common import FILE_HINT, HELP_TEXT, format_restore # ══════════════════════════════════════════════════════════════════════ @@ -823,7 +823,6 @@ def _do_rewrite(self): def _export_as_md(self): from PySide6.QtWidgets import QFileDialog - import os from datetime import datetime default_name = f"msg_{datetime.now().strftime('%Y%m%d_%H%M%S')}.md" file_path, _ = QFileDialog.getSaveFileName( diff --git a/frontends/stapp.py b/frontends/stapp.py index a19c134a1..73b41230d 100644 --- a/frontends/stapp.py +++ b/frontends/stapp.py @@ -14,7 +14,6 @@ import streamlit as st import time, json, re, threading, queue from agentmain import GeneraticAgent -import chatapp_common # activate /continue command (monkey patches GeneraticAgent) from continue_cmd import handle_frontend_command, reset_conversation, list_sessions, extract_ui_messages from btw_cmd import handle_frontend_command as btw_handle_frontend from export_cmd import last_assistant_text, export_to_temp, wrap_for_clipboard diff --git a/frontends/tui_v3.py b/frontends/tui_v3.py index ea6fc9166..60a3404ce 100644 --- a/frontends/tui_v3.py +++ b/frontends/tui_v3.py @@ -21,14 +21,12 @@ from agentmain import GeneraticAgent from dataclasses import dataclass from dataclasses import dataclass, field -from functools import lru_cache from io import StringIO from rich.cells import cell_len from rich.console import Console from rich.markdown import Markdown from rich.text import Text from rich.theme import Theme -from typing import Callable # Module-level `clip` shim: keep sb.py-style `clip.copy(...)` calls diff --git a/frontends/tuiapp.py b/frontends/tuiapp.py index 235134bce..79b220a9e 100644 --- a/frontends/tuiapp.py +++ b/frontends/tuiapp.py @@ -22,7 +22,6 @@ import re import sys import threading -import time from dataclasses import dataclass, field from itertools import count from typing import Any, Callable, Optional diff --git a/frontends/wechatapp.py b/frontends/wechatapp.py index aff57bf16..e0404e6d3 100644 --- a/frontends/wechatapp.py +++ b/frontends/wechatapp.py @@ -1,4 +1,4 @@ -import os, sys, re, threading, queue, time, socket, json, struct, base64, uuid, hashlib, math +import os, sys, re, threading, queue, time, socket, json, struct, base64, uuid, hashlib from pathlib import Path from urllib.parse import quote import requests, qrcode diff --git a/frontends/wecomapp.py b/frontends/wecomapp.py index 97d9e6608..d492ef11e 100644 --- a/frontends/wecomapp.py +++ b/frontends/wecomapp.py @@ -1,7 +1,7 @@ import asyncio, os, select, sys, threading, time, traceback from collections import deque from datetime import datetime -from typing import Any, Callable, Dict, Optional, TypedDict +from typing import Any, Callable, Optional, TypedDict class TurnContext(TypedDict, total=False): diff --git a/llmcore.py b/llmcore.py index 704874fd9..ea927bdee 100644 --- a/llmcore.py +++ b/llmcore.py @@ -1,4 +1,4 @@ -import os, json, re, time, requests, sys, threading, urllib3, base64, importlib, uuid +import os, json, re, time, requests, sys, threading, urllib3, importlib, uuid from datetime import datetime urllib3.disable_warnings(urllib3.exceptions.InsecureRequestWarning) _RESP_CACHE_KEY = str(uuid.uuid4()) diff --git a/memory/L4_raw_sessions/compress_session.py b/memory/L4_raw_sessions/compress_session.py index feb81dd27..b1a646461 100644 --- a/memory/L4_raw_sessions/compress_session.py +++ b/memory/L4_raw_sessions/compress_session.py @@ -1,7 +1,7 @@ """L4 Session Log Processor — compress & extract history. Format A (JSON): kept as-is. Format B (Raw): strip sys prompt & assistant echo. """ -import re, os, json, ast +import re, os from datetime import datetime L4_DIR = os.path.dirname(os.path.abspath(__file__)) diff --git a/memory/autonomous_operation_sop/helper.py b/memory/autonomous_operation_sop/helper.py index 14a68a655..885b61fa8 100644 --- a/memory/autonomous_operation_sop/helper.py +++ b/memory/autonomous_operation_sop/helper.py @@ -10,7 +10,6 @@ set_todo() → 返回TODO真实路径 """ -import os import re import shutil from pathlib import Path diff --git a/memory/ljqCtrl.py b/memory/ljqCtrl.py index b68d98073..95e3b02bf 100644 --- a/memory/ljqCtrl.py +++ b/memory/ljqCtrl.py @@ -10,12 +10,12 @@ - GrabWindow(hwnd) -> PIL Image: DPI-safe window screenshot """ -import os, sys, time, random, math, win32api, win32con, ctypes +import time, win32api, win32con, ctypes import numpy as np dpi_scale = 1 try: - from PIL import ImageGrab, Image, ImageEnhance, ImageFilter, ImageDraw + from PIL import ImageGrab, Image import cv2 except: pass diff --git a/memory/procmem_scanner.py b/memory/procmem_scanner.py index 7ca550130..c89b2e4d6 100644 --- a/memory/procmem_scanner.py +++ b/memory/procmem_scanner.py @@ -2,8 +2,6 @@ import ctypes.wintypes import argparse import yara -import sys -import os import json # Define WinAPI Types for 64-bit compatibility diff --git a/memory/ui_detect.py b/memory/ui_detect.py index d41dbbf6f..7b5ffd68b 100644 --- a/memory/ui_detect.py +++ b/memory/ui_detect.py @@ -7,7 +7,6 @@ from pathlib import Path from ultralytics import YOLO from PIL import Image, ImageDraw -import numpy as np DEFAULT_MODEL = str(Path(__file__).resolve().parent.parent / 'temp' / 'weights' / 'icon_detect' / 'model.pt') diff --git a/plugins/langfuse_tracing.py b/plugins/langfuse_tracing.py index 3d503183a..bb3c74ba2 100644 --- a/plugins/langfuse_tracing.py +++ b/plugins/langfuse_tracing.py @@ -7,7 +7,7 @@ Usage tracking (SSE parser wrapping) stays as internal llmcore patch. """ -import threading, sys +import threading try: from llmcore import _load_mykeys diff --git a/reflect/agent_team_worker.py b/reflect/agent_team_worker.py index a1de1771b..94926edea 100644 --- a/reflect/agent_team_worker.py +++ b/reflect/agent_team_worker.py @@ -1,6 +1,6 @@ # reflect module: BBS接单 # check()内预检BBS,无新帖返回None不唤醒agent -import json, time, os +import json, os from urllib import request INTERVAL = 60 diff --git a/simphtml.py b/simphtml.py index cd4b87912..84ea31575 100644 --- a/simphtml.py +++ b/simphtml.py @@ -659,7 +659,7 @@ def get_temp_texts(driver): print(e) return [] -import time, re, os +import time, re def get_main_block(driver, extra_js="", text_only=False): page = driver.execute_js(f"{extra_js}\n{js_optHTML}\nreturn optHTML({str(text_only).lower()});").get('data', '') if text_only: