Implement plans

This commit is contained in:
2026-03-04 02:19:22 +00:00
parent 34ee49410d
commit 0718a06c19
31 changed files with 3987 additions and 181 deletions

View File

@@ -129,7 +129,10 @@ class CommandRoutingSettings(LoginRequiredMixin, View):
"channel_services": ("web", "xmpp", "signal", "whatsapp"),
"directions": ("ingress", "egress", "scratchpad_mirror"),
"action_types": ("extract_bp", "post_result", "save_document"),
"command_choices": (("bp", "Business Plan (bp)"),),
"command_choices": (
("bp", "Business Plan (bp)"),
("codex", "Codex (codex)"),
),
"scope_service": scope_service,
"scope_identifier": scope_identifier,
"scope_variants": scope_variants,
@@ -153,40 +156,55 @@ class CommandRoutingSettings(LoginRequiredMixin, View):
user=request.user,
slug=slug,
defaults={
"name": str(request.POST.get("name") or "Business Plan").strip()
or "Business Plan",
"name": str(request.POST.get("name") or ("Codex" if slug == "codex" else "Business Plan")).strip()
or ("Codex" if slug == "codex" else "Business Plan"),
"enabled": True,
"trigger_token": str(
request.POST.get("trigger_token") or "#bp#"
request.POST.get("trigger_token")
or (".codex" if slug == "codex" else ".bp")
).strip()
or "#bp#",
or (".codex" if slug == "codex" else ".bp"),
"template_text": str(request.POST.get("template_text") or ""),
},
)
profile.name = str(request.POST.get("name") or profile.name).strip() or profile.name
if slug == "bp":
profile.trigger_token = "#bp#"
profile.trigger_token = ".bp"
profile.template_text = str(request.POST.get("template_text") or profile.template_text or "")
profile.save(update_fields=["name", "trigger_token", "template_text", "updated_at"])
CommandAction.objects.get_or_create(
profile=profile,
action_type="extract_bp",
defaults={"enabled": True, "position": 0},
if slug == "codex":
profile.trigger_token = ".codex"
profile.reply_required = False
profile.exact_match_only = False
profile.save(
update_fields=[
"name",
"trigger_token",
"template_text",
"reply_required",
"exact_match_only",
"updated_at",
]
)
# Keep legacy action rows in storage for compatibility and for
# potential reuse by non-bp commands; bp UI now relies on
# variant policies instead of exposing the generic action matrix.
CommandAction.objects.get_or_create(
profile=profile,
action_type="save_document",
defaults={"enabled": True, "position": 1},
)
CommandAction.objects.get_or_create(
profile=profile,
action_type="post_result",
defaults={"enabled": True, "position": 2},
)
ensure_variant_policies_for_profile(profile)
if slug == "bp":
CommandAction.objects.get_or_create(
profile=profile,
action_type="extract_bp",
defaults={"enabled": True, "position": 0},
)
# Keep legacy action rows in storage for compatibility and for
# potential reuse by non-bp commands; bp UI now relies on
# variant policies instead of exposing the generic action matrix.
CommandAction.objects.get_or_create(
profile=profile,
action_type="save_document",
defaults={"enabled": True, "position": 1},
)
CommandAction.objects.get_or_create(
profile=profile,
action_type="post_result",
defaults={"enabled": True, "position": 2},
)
ensure_variant_policies_for_profile(profile)
return self._redirect_with_scope(request)
if action == "profile_update":
@@ -199,7 +217,7 @@ class CommandRoutingSettings(LoginRequiredMixin, View):
profile.enabled = bool(request.POST.get("enabled"))
profile.trigger_token = (
str(request.POST.get("trigger_token") or profile.trigger_token).strip()
or "#bp#"
or ".bp"
)
profile.reply_required = bool(request.POST.get("reply_required"))
profile.exact_match_only = bool(request.POST.get("exact_match_only"))