feat: split resolve_destination, persona-driven prompts, qBittorrent relocation
Destination resolution
- Replace the single ResolveDestinationUseCase with four dedicated
functions, one per release type:
resolve_season_destination (pack season, folder move)
resolve_episode_destination (single episode, file move)
resolve_movie_destination (movie, file move)
resolve_series_destination (multi-season pack, folder move)
- Each returns a dedicated DTO carrying only the fields relevant to
that release type — no more polymorphic ResolvedDestination with
half the fields unused depending on the case.
- Looser series folder matching: exact computed-name match is reused
silently; any deviation (different group, multiple candidates) now
prompts the user with all options including the computed name.
Agent tools
- Four new tools wrapping the use cases above; old resolve_destination
removed from the registry.
- New move_to_destination tool: create_folder + move, chained — used
after a resolve_* call to perform the actual relocation.
- Low-level filesystem_operations module (create_folder, move via mv)
for instant same-FS renames (ZFS).
Prompt & persona
- New PromptBuilder (alfred/agent/prompt.py) replacing prompts.py:
identity + personality block, situational expressions, memory
schema, episodic/STM/config context, tool catalogue.
- Per-user expression system: knowledge/users/common.yaml +
{username}.yaml are merged at runtime; one phrase per situation
(greeting/success/error/...) is sampled into the system prompt.
qBittorrent integration
- Credentials now come from settings (qbittorrent_url/username/password)
instead of hardcoded defaults.
- New client methods: find_by_name, set_location, recheck — the trio
needed to update a torrent's save path and re-verify after a move.
- Host→container path translation settings (qbittorrent_host_path /
qbittorrent_container_path) for docker-mounted setups.
Subtitles
- Identifier: strip parenthesized qualifiers (simplified, brazil…) at
tokenization; new _tokenize_suffix used for the episode_subfolder
pattern so episode-stem tokens no longer pollute language detection.
- Placer: extract _build_dest_name so it can be reused by the new
dry_run path in ManageSubtitlesUseCase.
- Knowledge: add yue, ell, ind, msa, rus, vie, heb, tam, tel, tha,
hin, ukr; add 'fre' to fra; add 'simplified'/'traditional' to zho.
Misc
- LTM workspace: add 'trash' folder slot.
- Default LLM provider switched to deepseek.
- testing/debug_release.py: CLI to parse a release, hit TMDB, and
dry-run the destination resolution end-to-end.
This commit is contained in:
+21
-15
@@ -16,7 +16,6 @@ from bootstrap import (
|
||||
load_env_file,
|
||||
)
|
||||
|
||||
|
||||
# ---------------------------------------------------------------------------
|
||||
# Fixtures
|
||||
# ---------------------------------------------------------------------------
|
||||
@@ -171,11 +170,11 @@ class TestBuildUris:
|
||||
build_uris(alfred_file, secrets_file)
|
||||
uri = load_env_file(secrets_file)["MONGO_URI"]
|
||||
|
||||
assert "alfred" in uri # user
|
||||
assert "cafebabe" in uri # password from secrets
|
||||
assert "mongodb" in uri # host
|
||||
assert "27017" in uri # port
|
||||
assert "mydb" in uri # dbname
|
||||
assert "alfred" in uri # user
|
||||
assert "cafebabe" in uri # password from secrets
|
||||
assert "mongodb" in uri # host
|
||||
assert "27017" in uri # port
|
||||
assert "mydb" in uri # dbname
|
||||
assert "authSource=admin" in uri
|
||||
|
||||
def test_postgres_uri_contains_all_components(self, alfred_file, secrets_file):
|
||||
@@ -183,7 +182,7 @@ class TestBuildUris:
|
||||
uri = load_env_file(secrets_file)["POSTGRES_URI"]
|
||||
|
||||
assert "alfred" in uri
|
||||
assert "f00dface" in uri # password from secrets
|
||||
assert "f00dface" in uri # password from secrets
|
||||
assert "vectordb" in uri
|
||||
assert "5432" in uri
|
||||
assert uri.startswith("postgresql://")
|
||||
@@ -191,7 +190,9 @@ class TestBuildUris:
|
||||
def test_uri_is_updated_when_host_changes(self, tmp_path, secrets_file):
|
||||
"""If MONGO_HOST changes in .env.alfred, the URI must reflect it."""
|
||||
alfred = tmp_path / ".env.alfred"
|
||||
alfred.write_text(ALFRED_ENV.replace("MONGO_HOST=mongodb", "MONGO_HOST=newhost"))
|
||||
alfred.write_text(
|
||||
ALFRED_ENV.replace("MONGO_HOST=mongodb", "MONGO_HOST=newhost")
|
||||
)
|
||||
|
||||
build_uris(alfred, secrets_file)
|
||||
uri = load_env_file(secrets_file)["MONGO_URI"]
|
||||
@@ -217,7 +218,9 @@ class TestBuildUris:
|
||||
uri_v1 = load_env_file(secrets_file)["MONGO_URI"]
|
||||
|
||||
alfred_v2 = tmp_path / "alfred_v2"
|
||||
alfred_v2.write_text(ALFRED_ENV.replace("MONGO_DB_NAME=mydb", "MONGO_DB_NAME=otherdb"))
|
||||
alfred_v2.write_text(
|
||||
ALFRED_ENV.replace("MONGO_DB_NAME=mydb", "MONGO_DB_NAME=otherdb")
|
||||
)
|
||||
build_uris(alfred_v2, secrets_file)
|
||||
uri_v2 = load_env_file(secrets_file)["MONGO_URI"]
|
||||
|
||||
@@ -265,12 +268,15 @@ class TestCopyExampleIfMissing:
|
||||
|
||||
|
||||
class TestExtractPythonVersion:
|
||||
@pytest.mark.parametrize("spec,expected_full,expected_short", [
|
||||
("==3.14.3", "3.14.3", "3.14"),
|
||||
("^3.12.0", "3.12.0", "3.12"),
|
||||
("~3.11.1", "3.11.1", "3.11"),
|
||||
("3.10.5", "3.10.5", "3.10"),
|
||||
])
|
||||
@pytest.mark.parametrize(
|
||||
"spec,expected_full,expected_short",
|
||||
[
|
||||
("==3.14.3", "3.14.3", "3.14"),
|
||||
("^3.12.0", "3.12.0", "3.12"),
|
||||
("~3.11.1", "3.11.1", "3.11"),
|
||||
("3.10.5", "3.10.5", "3.10"),
|
||||
],
|
||||
)
|
||||
def test_parses_version_specifiers(self, spec, expected_full, expected_short):
|
||||
full, short = extract_python_version(spec)
|
||||
assert full == expected_full
|
||||
|
||||
Reference in New Issue
Block a user