Skip to content

Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.

Go

fix: honor quick-create squad mentions (#2586)

Multica Eve58cc189dcd1d
diff --git a/server/cmd/multica/cmd_issue.go b/server/cmd/multica/cmd_issue.go
index 8337435564..bce2c5770b 100644
--- a/server/cmd/multica/cmd_issue.go
+++ b/server/cmd/multica/cmd_issue.go
@@ -1374,7 +1374,7 @@ func resolveAssignee(ctx context.Context, client *cli.APIClient, name string, ki
return "", "", fmt.Errorf("workspace ID is required to resolve assignees; use --workspace-id or set MULTICA_WORKSPACE_ID")
}
- input := strings.TrimSpace(name)
+ input := normalizeAssigneeLookupInput(name)
if input == "" {
return "", "", fmt.Errorf("no %s found matching %q", kinds.describe(), name)
}
@@ -1476,6 +1476,20 @@ func resolveAssignee(ctx context.Context, client *cli.APIClient, name string, ki
return "", "", fmt.Errorf("no %s found matching %q", kinds.describe(), input)
}
+func normalizeAssigneeLookupInput(raw string) string {
+ input := strings.TrimSpace(raw)
+ if m := util.MentionRe.FindStringSubmatch(input); len(m) == 4 && m[0] == input {
+ switch m[2] {
+ case "member", "agent", "squad":
+ return m[3]
+ }
+ }
+ input = strings.TrimLeftFunc(input, func(r rune) bool {
+ return r == '@' || r == '@'
+ })
+ return strings.TrimSpace(input)
+}
+
func ambiguousAssigneeError(input string, matches []assigneeMatch) error {
parts := make([]string, 0, len(matches))
for _, m := range matches {
diff --git a/server/cmd/multica/cmd_issue_test.go b/server/cmd/multica/cmd_issue_test.go
index 45d00a5dca..338b7ec77c 100644
--- a/server/cmd/multica/cmd_issue_test.go
+++ b/server/cmd/multica/cmd_issue_test.go
@@ -649,6 +649,16 @@ func TestResolveAssignee(t *testing.T) {
}
})
+ t.Run("match squad by bare @ display name", func(t *testing.T) {
+ aType, aID, err := resolveAssignee(ctx, client, "@Super Human", issueAssigneeKinds)
+ if err != nil {
+ t.Fatalf("unexpected error: %v", err)
+ }
+ if aType != "squad" || aID != "squad-4444" {
+ t.Errorf("got (%q, %q), want (squad, squad-4444)", aType, aID)
+ }
+ })
+
t.Run("no match", func(t *testing.T) {
_, _, err := resolveAssignee(ctx, client, "nobody", issueAssigneeKinds)
if err == nil {
@@ -677,6 +687,31 @@ func TestResolveAssignee(t *testing.T) {
})
}
+func TestNormalizeAssigneeLookupInput(t *testing.T) {
+ tests := []struct {
+ name string
+ in string
+ want string
+ }{
+ {"plain name", "Super Human", "Super Human"},
+ {"bare at name", "@Super Human", "Super Human"},
+ {"fullwidth at name", "@独立团", "独立团"},
+ {"spaced at name", " @ Super Human ", "Super Human"},
+ {
+ name: "mention link",
+ in: "[@Super Human](mention://squad/ccccccc1-2222-3333-4444-555555555555)",
+ want: "ccccccc1-2222-3333-4444-555555555555",
+ },
+ }
+ for _, tt := range tests {
+ t.Run(tt.name, func(t *testing.T) {
+ if got := normalizeAssigneeLookupInput(tt.in); got != tt.want {
+ t.Errorf("normalizeAssigneeLookupInput(%q) = %q, want %q", tt.in, got, tt.want)
+ }
+ })
+ }
+}
+
// TestResolveAssigneeRespectsKinds covers the MUL-2165 follow-up: callers
// whose target schema is member-or-agent-only (project.lead_type DB CHECK
// at server/migrations/034_projects.up.sql:10, and the subscriber handler's
diff --git a/server/internal/daemon/prompt.go b/server/internal/daemon/prompt.go
index caedd21af4..3b439988d2 100644
--- a/server/internal/daemon/prompt.go
+++ b/server/internal/daemon/prompt.go
@@ -55,7 +55,7 @@ func buildQuickCreatePrompt(task Task) string {
// description — the core optimization
b.WriteString("- **description**: The description is the executing agent's primary context. Aim for high fidelity — they should grasp the user's intent as if they had read the raw input themselves. Use a two-section structure:\n\n")
- b.WriteString(" 1. **User request** — Faithfully restate what the user wants in their own words. Preserve specific names, identifiers, file paths, code snippets, and technical terms verbatim. Strip non-spec material before writing it (this is removal, not paraphrasing): verbal routing wrappers about creating the issue (e.g. \"create an issue\", \"分配给 X\") and pure conversational fillers (e.g. \"对吧?\"). When in doubt, keep it.\n\n")
+ b.WriteString(" 1. **User request** — Faithfully restate what the user wants in their own words. Preserve specific names, identifiers, file paths, code snippets, and technical terms verbatim. Strip non-spec material before writing it (this is removal, not paraphrasing): verbal routing wrappers about creating the issue or routing it (e.g. \"create an issue\", \"分配给 X\", \"让 @X 处理\") and pure conversational fillers (e.g. \"对吧?\"). When in doubt, keep it.\n\n")
b.WriteString(" CC exception: `multica issue create` has no `--subscriber` flag, and the platform auto-subscribes members whose `[@Name](mention://member/<uuid>)` link appears in the description. When the user wrote \"cc @Y\", strip the verbal \"cc\" wrapper from the User request body and append a final `CC: <mention link(s)>` line to the description so the cc routing still fires.\n\n")
b.WriteString(" 2. **Context** — include ONLY when the input cited external resources AND you successfully fetched them AND they produced verifiable facts worth recording. Summarize facts only (e.g. \"PR #45 changes auth to JWT\"), not interpretation or unsolicited reference implementations. If you have nothing factual to add, omit the section entirely — never use it as an apology log for resources you could not fetch.\n\n")
b.WriteString(" Hard rules: never invent requirements, implementation details, or acceptance criteria the user did not express; never reduce multi-sentence input to a single vague sentence; never echo the title.\n\n")
@@ -66,6 +66,7 @@ func buildQuickCreatePrompt(task Task) string {
// assignee
b.WriteString("- **assignee**:\n")
b.WriteString(" - When the user names someone (\"assign to X\" / \"@X\"), call `multica workspace members --output json`, `multica agent list --output json`, and `multica squad list --output json` and find the matching entity by display name. Squads are first-class assignees too — a squad name (e.g. \"Super Human\") routes work to the squad leader, who then delegates. On a clean unambiguous match, prefer `--assignee-id <uuid>` using the `user_id` (member) or `id` (agent or squad) from that JSON — UUID matching is exact and robust to name collisions in workspaces with overlapping names. `--assignee <name>` (fuzzy) is acceptable as a fallback when names are unambiguous. On no match or ambiguous match, do NOT pass either flag — instead append a final line to the description: `Unrecognized assignee: X`.\n")
+ b.WriteString(" - Treat bare @-routing as an assignee directive even when the user did not write the English word \"assign\". This includes Chinese imperatives like `让 @独立团 review 这个 PR`, `给 @X 处理`, or `交给 @X`; strip the leading `@`/`@` before matching display names. Do not keep that routing wrapper or `@Name` in the description unless it is a true CC-style notification rather than ownership. If the matched entity is a squad, pass the squad's `id` as `--assignee-id`, not the leader agent's id.\n")
agentID := ""
agentName := ""
if task.Agent != nil {
diff --git a/server/internal/daemon/prompt_test.go b/server/internal/daemon/prompt_test.go
index 311e0d4205..2ecf5d50d4 100644
--- a/server/internal/daemon/prompt_test.go
+++ b/server/internal/daemon/prompt_test.go
@@ -51,6 +51,9 @@ func TestBuildQuickCreatePromptAssigneeIncludesSquads(t *testing.T) {
mustContain := []string{
"multica squad list",
"Squads are first-class assignees",
+ "Treat bare @-routing as an assignee directive",
+ "让 @独立团 review 这个 PR",
+ "pass the squad's `id` as `--assignee-id`",
}
for _, s := range mustContain {
if !strings.Contains(out, s) {