refactor(task): 重命名 kotonebot.tasks 为 kotonebot.kaa

This commit is contained in:
XcantloadX 2025-05-05 19:00:06 +08:00
parent c9c67e6520
commit 333b3f0557
61 changed files with 45 additions and 45 deletions

6
.gitignore vendored
View File

@ -2,8 +2,9 @@
tests/output_images tests/output_images
tests/output_images/* tests/output_images/*
R.py R.py
kotonebot/tasks/sprites kotonebot/kaa/sprites
kotonebot/tasks/metadata.py kotonebot/kaa/metadata.py
kotonebot/kaa/resources
kotonebot-ui/node_modules kotonebot-ui/node_modules
kotonebot-ui/.vite kotonebot-ui/.vite
dumps*/ dumps*/
@ -16,7 +17,6 @@ messages/
logs/ logs/
traces/ traces/
version version
kotonebot/tasks/resources
cache/ cache/
########################## ##########################

View File

@ -1,5 +1,5 @@
graft kotonebot/tasks/sprites graft kotonebot/kaa/sprites
graft kotonebot/tasks/resources graft kotonebot/kaa/resources
prune tests prune tests
prune tools prune tools
prune experiments prune experiments

View File

@ -50,7 +50,7 @@ generate-metadata: env
from pathlib import Path from pathlib import Path
with open("WHATS_NEW.md", "r", encoding="utf-8") as f: with open("WHATS_NEW.md", "r", encoding="utf-8") as f:
content = f.read() content = f.read()
metadata_path = Path("kotonebot/tasks/metadata.py") metadata_path = Path("kotonebot/kaa/metadata.py")
metadata_path.parent.mkdir(parents=True, exist_ok=True) metadata_path.parent.mkdir(parents=True, exist_ok=True)
with open(metadata_path, "w", encoding="utf-8") as f: with open(metadata_path, "w", encoding="utf-8") as f:
f.write(f'WHATS_NEW = """\n{content}\n"""') f.write(f'WHATS_NEW = """\n{content}\n"""')
@ -67,10 +67,10 @@ extract-game-data:
#!{{shebang_pwsh}} #!{{shebang_pwsh}}
Write-Host "Extracting game data..." Write-Host "Extracting game data..."
New-Item -ItemType File -Force -Path .\kotonebot\tasks\resources\__init__.py New-Item -ItemType File -Force -Path .\kotonebot\kaa\resources\__init__.py
$currentHash = git -C .\submodules\gakumasu-diff rev-parse HEAD $currentHash = git -C .\submodules\gakumasu-diff rev-parse HEAD
$hashFile = ".\kotonebot\tasks\resources\game_ver.txt" $hashFile = ".\kotonebot\kaa\resources\game_ver.txt"
$shouldUpdate = $true $shouldUpdate = $true
if (Test-Path $hashFile) { if (Test-Path $hashFile) {

View File

@ -143,7 +143,7 @@ def list_dir(path: str) -> list[File]:
@app.get("/api/resources/autocomplete") @app.get("/api/resources/autocomplete")
def autocomplete(class_path: str) -> list[str]: def autocomplete(class_path: str) -> list[str]:
from kotonebot.tasks import R # HACK: hardcode from kotonebot.kaa import R # HACK: hardcode
class_names = class_path.split(".")[:-1] class_names = class_path.split(".")[:-1]
target_class = R target_class = R
# 定位到目标类 # 定位到目标类

View File

@ -2,7 +2,7 @@ import runpy
import logging import logging
import argparse import argparse
from kotonebot.tasks.common import BaseConfig from kotonebot.kaa.common import BaseConfig
def run_script(script_path: str) -> None: def run_script(script_path: str) -> None:

View File

@ -6,7 +6,7 @@ from cv2.typing import MatLike
from .. import R from .. import R
from ..game_ui import dialog from ..game_ui import dialog
from kotonebot.util import Interval, Countdown from kotonebot.util import Interval, Countdown
from kotonebot.tasks.game_ui import WhiteFilter from kotonebot.kaa.game_ui import WhiteFilter
from kotonebot import device, image, user, action, use_screenshot from kotonebot import device, image, user, action, use_screenshot
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -2,8 +2,8 @@ import logging
from .. import R from .. import R
from kotonebot.util import Interval from kotonebot.util import Interval
from kotonebot.tasks.game_ui import dialog from kotonebot.kaa.game_ui import dialog
from kotonebot.tasks.game_ui import toolbar_home from kotonebot.kaa.game_ui import toolbar_home
from kotonebot import device, image, action, until, sleep from kotonebot import device, image, action, until, sleep
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -2,7 +2,7 @@ import os
import sqlite3 import sqlite3
from typing import Any, cast from typing import Any, cast
from kotonebot.tasks import resources as res from kotonebot.kaa import resources as res
_db: sqlite3.Connection | None = None _db: sqlite3.Connection | None = None
_db_path = cast(str, res.__path__)[0] + '/game.db' _db_path = cast(str, res.__path__)[0] + '/game.db'

View File

@ -7,7 +7,7 @@ from cv2.typing import MatLike
from kotonebot.backend.image import TemplateMatchResult from kotonebot.backend.image import TemplateMatchResult
from kotonebot.tasks import R from kotonebot.kaa import R
from kotonebot import action, color, image from kotonebot import action, color, image
from kotonebot.backend.color import HsvColor from kotonebot.backend.color import HsvColor
from kotonebot.util import Rect from kotonebot.util import Rect

View File

@ -1,7 +1,7 @@
from dataclasses import dataclass from dataclasses import dataclass
from typing import Sequence from typing import Sequence
from kotonebot.tasks import R from kotonebot.kaa import R
from kotonebot.backend.core import HintBox from kotonebot.backend.core import HintBox
from kotonebot.backend.color import HsvColor from kotonebot.backend.color import HsvColor
from kotonebot import action, device, ocr, sleep, Rect from kotonebot import action, device, ocr, sleep, Rect

View File

@ -1,4 +1,4 @@
from kotonebot.tasks import R from kotonebot.kaa import R
from kotonebot import device, image from kotonebot import device, image
def expect_yes(): def expect_yes():

View File

@ -7,13 +7,13 @@ import cv2
import numpy as np import numpy as np
from cv2.typing import MatLike from cv2.typing import MatLike
from kotonebot.tasks import R from kotonebot.kaa import R
from kotonebot.tasks.util import paths from kotonebot.kaa.util import paths
from kotonebot.util import Rect, cv2_imread from kotonebot.util import Rect, cv2_imread
from kotonebot.tasks.game_ui import Scrollable from kotonebot.kaa.game_ui import Scrollable
from kotonebot.backend.debug import result, img from kotonebot.backend.debug import result, img
from kotonebot import device, color, action, sleep, contains from kotonebot import device, color, action, sleep, contains
from kotonebot.tasks.image_db import ImageDatabase, HistDescriptor, FileDataSource from kotonebot.kaa.image_db import ImageDatabase, HistDescriptor, FileDataSource
from kotonebot.backend.preprocessor import HsvColorRemover, HsvColorsRemover from kotonebot.backend.preprocessor import HsvColorRemover, HsvColorsRemover
logger = logging.getLogger(__name__) logger = logging.getLogger(__name__)

View File

@ -2,7 +2,7 @@ from typing import Literal, overload
from kotonebot.backend.image import TemplateMatchResult from kotonebot.backend.image import TemplateMatchResult
from kotonebot.tasks import R from kotonebot.kaa import R
from .common import WhiteFilter from .common import WhiteFilter
from kotonebot import action, device, image from kotonebot import action, device, image

View File

@ -167,7 +167,7 @@ class ImageDatabase:
if __name__ == '__main__': if __name__ == '__main__':
from kotonebot.tasks.image_db.db import Db from kotonebot.kaa.image_db.db import Db
logging.basicConfig(level=logging.DEBUG, format='[%(asctime)s] [%(levelname)s] [%(name)s] [%(funcName)s] [%(lineno)d] %(message)s') logging.basicConfig(level=logging.DEBUG, format='[%(asctime)s] [%(levelname)s] [%(name)s] [%(funcName)s] [%(lineno)d] %(message)s')
imgs_path = r'E:\GithubRepos\KotonesAutoAssistant.worktrees\dev\kotonebot\tasks\resources\idol_cards' imgs_path = r'E:\GithubRepos\KotonesAutoAssistant.worktrees\dev\kotonebot\tasks\resources\idol_cards'
needle_path = r'D:\05.png' needle_path = r'D:\05.png'

View File

@ -8,12 +8,12 @@ from typing import List, Dict, Tuple, Literal, Generator
import cv2 import cv2
import gradio as gr import gradio as gr
from kotonebot.tasks.main import Kaa from kotonebot.kaa.main import Kaa
from kotonebot.tasks.db import IdolCard from kotonebot.kaa.db import IdolCard
from kotonebot.config.manager import load_config, save_config from kotonebot.config.manager import load_config, save_config
from kotonebot.config.base_config import UserConfig, BackendConfig from kotonebot.config.base_config import UserConfig, BackendConfig
from kotonebot.backend.context import task_registry, ContextStackVars from kotonebot.backend.context import task_registry, ContextStackVars
from kotonebot.tasks.common import ( from kotonebot.kaa.common import (
BaseConfig, APShopItems, CapsuleToysConfig, ClubRewardConfig, PurchaseConfig, ActivityFundsConfig, BaseConfig, APShopItems, CapsuleToysConfig, ClubRewardConfig, PurchaseConfig, ActivityFundsConfig,
PresentsConfig, AssignmentConfig, ContestConfig, ProduceConfig, PresentsConfig, AssignmentConfig, ContestConfig, ProduceConfig,
MissionRewardConfig, DailyMoneyShopItems, ProduceAction, MissionRewardConfig, DailyMoneyShopItems, ProduceAction,
@ -1120,7 +1120,7 @@ class KotoneBotUI:
def _create_whats_new_tab(self) -> None: def _create_whats_new_tab(self) -> None:
"""创建更新日志标签页,并显示最新版本更新内容""" """创建更新日志标签页,并显示最新版本更新内容"""
with gr.Tab("更新日志"): with gr.Tab("更新日志"):
from kotonebot.tasks.metadata import WHATS_NEW from kotonebot.kaa.metadata import WHATS_NEW
gr.Markdown(WHATS_NEW) gr.Markdown(WHATS_NEW)
def _create_screen_tab(self) -> None: def _create_screen_tab(self) -> None:

View File

@ -12,10 +12,10 @@ from kotonebot import (
) )
from .p_drink import acquire_p_drink from .p_drink import acquire_p_drink
from kotonebot.util import measure_time from kotonebot.util import measure_time
from kotonebot.tasks.common import conf from kotonebot.kaa.common import conf
from kotonebot.tasks.actions.loading import loading from kotonebot.kaa.actions.loading import loading
from kotonebot.tasks.game_ui import CommuEventButtonUI, dialog, badge from kotonebot.kaa.game_ui import CommuEventButtonUI, dialog, badge
from kotonebot.tasks.actions.commu import handle_unread_commu from kotonebot.kaa.actions.commu import handle_unread_commu
logger = getLogger(__name__) logger = getLogger(__name__)

View File

@ -5,7 +5,7 @@
""" """
from logging import getLogger from logging import getLogger
from kotonebot.tasks.game_ui import dialog from kotonebot.kaa.game_ui import dialog
from .. import R from .. import R

View File

@ -365,7 +365,7 @@ if __name__ == '__main__':
import time import time
from kotonebot.backend.context import init_context, manual_context from kotonebot.backend.context import init_context, manual_context
from kotonebot.tasks.common import BaseConfig from kotonebot.kaa.common import BaseConfig
from kotonebot.util import Profiler from kotonebot.util import Profiler
init_context(config_type=BaseConfig) init_context(config_type=BaseConfig)
conf().produce.enabled = True conf().produce.enabled = True

View File

@ -1,7 +1,7 @@
import os import os
from typing import cast from typing import cast
from kotonebot.tasks import resources as res from kotonebot.kaa import resources as res
CACHE = os.path.join('cache') CACHE = os.path.join('cache')
RESOURCE = cast(list[str], res.__path__)[0] RESOURCE = cast(list[str], res.__path__)[0]

View File

@ -48,7 +48,7 @@ dependencies = [
package-dir = { "kotonebot" = "kotonebot" } package-dir = { "kotonebot" = "kotonebot" }
[project.scripts] [project.scripts]
kaa = "kotonebot.tasks.main.cli:main" kaa = "kotonebot.kaa.main.cli:main"
[tool.setuptools.dynamic] [tool.setuptools.dynamic]
version = {file = "./version"} version = {file = "./version"}

View File

@ -1,5 +1,5 @@
from unittest import TestCase from unittest import TestCase
from kotonebot.tasks.game_ui.badge import match, BadgeResult from kotonebot.kaa.game_ui.badge import match, BadgeResult
from kotonebot.util import Rect from kotonebot.util import Rect
def rect_from_center(x: int, y: int) -> Rect: def rect_from_center(x: int, y: int) -> Rect:

View File

@ -82,7 +82,7 @@ class BaseTestCase(unittest.TestCase):
cls.device = MockDevice() cls.device = MockDevice()
from kotonebot.backend.debug.server import start_server from kotonebot.backend.debug.server import start_server
from kotonebot.backend.debug import debug from kotonebot.backend.debug import debug
from kotonebot.tasks.common import BaseConfig from kotonebot.kaa.common import BaseConfig
debug.enabled = True debug.enabled = True
# debug.wait_for_message_sent = True # debug.wait_for_message_sent = True
start_server() start_server()

View File

@ -3,7 +3,7 @@
####### 此文件为自动生成,请勿编辑 ####### ####### 此文件为自动生成,请勿编辑 #######
####### AUTO GENERATED. DO NOT EDIT. ####### ####### AUTO GENERATED. DO NOT EDIT. #######
{%- endif %} {%- endif %}
from kotonebot.tasks.common import sprite_path from kotonebot.kaa.common import sprite_path
from kotonebot.backend.core import Image, HintBox, HintPoint from kotonebot.backend.core import Image, HintBox, HintPoint

View File

@ -17,10 +17,10 @@ print("拉取资源...")
manifest = gom.fetch() manifest = gom.fetch()
print("提取 P 偶像卡资源...") print("提取 P 偶像卡资源...")
base_path = './kotonebot/tasks/resources/idol_cards' base_path = './kotonebot/kaa/resources/idol_cards'
os.makedirs(base_path, exist_ok=True) os.makedirs(base_path, exist_ok=True)
db = sqlite3.connect("./kotonebot/tasks/resources/game.db") db = sqlite3.connect("./kotonebot/kaa/resources/game.db")
cursor = db.execute(""" cursor = db.execute("""
SELECT SELECT
IC.id AS cardId, IC.id AS cardId,

View File

@ -457,12 +457,12 @@ if __name__ == '__main__':
parser.add_argument('-i', '--ide', help='IDE 类型', default=ide_type()) parser.add_argument('-i', '--ide', help='IDE 类型', default=ide_type())
args = parser.parse_args() args = parser.parse_args()
if os.path.exists(r'kotonebot\tasks\sprites'): if os.path.exists(r'kotonebot\kaa\sprites'):
shutil.rmtree(r'kotonebot\tasks\sprites') shutil.rmtree(r'kotonebot\kaa\sprites')
path = PATH + '\\jp' path = PATH + '\\jp'
files = scan_png_files(path) files = scan_png_files(path)
sprites = load_sprites(path, files) sprites = load_sprites(path, files)
sprites = copy_sprites(sprites, r'kotonebot\tasks\sprites') sprites = copy_sprites(sprites, r'kotonebot\kaa\sprites')
classes = make_classes(sprites, args.ide) classes = make_classes(sprites, args.ide)
env = jinja2.Environment(loader=jinja2.FileSystemLoader('./tools')) env = jinja2.Environment(loader=jinja2.FileSystemLoader('./tools'))
@ -470,9 +470,9 @@ if __name__ == '__main__':
template = env.get_template('R.jinja2') template = env.get_template('R.jinja2')
print(f'Rendering template: {template.name}') print(f'Rendering template: {template.name}')
with open('./kotonebot/tasks/R.py', 'w', encoding='utf-8') as f: with open('./kotonebot/kaa/tasks/R.py', 'w', encoding='utf-8') as f:
f.write(template.render(data=classes, production=args.production)) f.write(template.render(data=classes, production=args.production))
print('Creating __init__.py') print('Creating __init__.py')
with open('./kotonebot/tasks/sprites/__init__.py', 'w', encoding='utf-8') as f: with open('./kotonebot/kaa/sprites/__init__.py', 'w', encoding='utf-8') as f:
f.write('') f.write('')
print('All done!') print('All done!')