Reimplement compose and add tiling windows

This commit is contained in:
2026-03-12 22:03:30 +00:00
parent 79766d279d
commit 6ceff63b71
126 changed files with 5111 additions and 10796 deletions

View File

@@ -9,8 +9,6 @@ from core.commands.handlers.bp import (
bp_subcommands_enabled,
bp_trigger_matches,
)
from core.commands.handlers.claude import ClaudeCommandHandler, claude_trigger_matches
from core.commands.handlers.codex import CodexCommandHandler, codex_trigger_matches
from core.commands.policies import ensure_variant_policies_for_profile
from core.commands.registry import get as get_handler
from core.commands.registry import register
@@ -29,6 +27,7 @@ from core.util import logs
log = logs.get_logger("command_engine")
_REGISTERED = False
_SUPPORTED_PROFILE_SLUGS = {"bp"}
def _channel_variants(service: str, channel_identifier: str) -> list[str]:
@@ -177,59 +176,9 @@ def _ensure_bp_profile(user_id: int) -> CommandProfile:
return profile
def _ensure_codex_profile(user_id: int) -> CommandProfile:
profile, _ = CommandProfile.objects.get_or_create(
user_id=user_id,
slug="codex",
defaults={
"name": "Codex",
"enabled": True,
"trigger_token": ".codex",
"reply_required": False,
"exact_match_only": False,
"window_scope": "conversation",
"visibility_mode": "status_in_source",
},
)
if not profile.enabled:
profile.enabled = True
profile.save(update_fields=["enabled", "updated_at"])
if str(profile.trigger_token or "").strip() != ".codex":
profile.trigger_token = ".codex"
profile.save(update_fields=["trigger_token", "updated_at"])
return profile
def _ensure_claude_profile(user_id: int) -> CommandProfile:
profile, _ = CommandProfile.objects.get_or_create(
user_id=user_id,
slug="claude",
defaults={
"name": "Claude",
"enabled": True,
"trigger_token": ".claude",
"reply_required": False,
"exact_match_only": False,
"window_scope": "conversation",
"visibility_mode": "status_in_source",
},
)
if not profile.enabled:
profile.enabled = True
profile.save(update_fields=["enabled", "updated_at"])
if str(profile.trigger_token or "").strip() != ".claude":
profile.trigger_token = ".claude"
profile.save(update_fields=["trigger_token", "updated_at"])
return profile
def _ensure_profile_for_slug(user_id: int, slug: str) -> CommandProfile | None:
if slug == "bp":
return _ensure_bp_profile(user_id)
if slug == "codex":
return _ensure_codex_profile(user_id)
if slug == "claude":
return _ensure_claude_profile(user_id)
return None
@@ -237,10 +186,6 @@ def _detected_bootstrap_slugs(message_text: str) -> list[str]:
slugs: list[str] = []
if bp_trigger_matches(message_text, ".bp", False):
slugs.append("bp")
if codex_trigger_matches(message_text, ".codex", False):
slugs.append("codex")
if claude_trigger_matches(message_text, ".claude", False):
slugs.append("claude")
return slugs
@@ -306,8 +251,6 @@ def ensure_handlers_registered():
if _REGISTERED:
return
register(BPCommandHandler())
register(CodexCommandHandler())
register(ClaudeCommandHandler())
_REGISTERED = True
@@ -337,6 +280,7 @@ async def _eligible_profiles(ctx: CommandContext) -> list[CommandProfile]:
CommandProfile.objects.filter(
user_id=ctx.user_id,
enabled=True,
slug__in=_SUPPORTED_PROFILE_SLUGS,
channel_bindings__enabled=True,
channel_bindings__direction="ingress",
channel_bindings__service=ctx.service,
@@ -370,6 +314,7 @@ async def _eligible_profiles(ctx: CommandContext) -> list[CommandProfile]:
CommandProfile.objects.filter(
user_id=ctx.user_id,
enabled=True,
slug__in=_SUPPORTED_PROFILE_SLUGS,
channel_bindings__enabled=True,
channel_bindings__direction="ingress",
channel_bindings__service=fallback_service,
@@ -387,18 +332,6 @@ def _matches_trigger(profile: CommandProfile, text: str) -> bool:
trigger_token=profile.trigger_token,
exact_match_only=profile.exact_match_only,
)
if profile.slug == "codex":
return codex_trigger_matches(
message_text=text,
trigger_token=profile.trigger_token,
exact_match_only=profile.exact_match_only,
)
if profile.slug == "claude":
return claude_trigger_matches(
message_text=text,
trigger_token=profile.trigger_token,
exact_match_only=profile.exact_match_only,
)
body = str(text or "").strip()
trigger = str(profile.trigger_token or "").strip()
if not trigger: