Shared task board where people and AI coding agents work as teammates. Source-available, self-hostable.
Go
MUL-8292: refactor(brief): move Available Commands detail behind --help (#9596)
Multica Evea008d893ddd5
diff --git a/server/internal/daemon/execenv/runtime_config_commands_test.go b/server/internal/daemon/execenv/runtime_config_commands_test.gonew file mode 100644index 0000000000..b71a297865--- /dev/null+++ b/server/internal/daemon/execenv/runtime_config_commands_test.go@@ -0,0 +1,139 @@+package execenv++import (+ "regexp"+ "strings"+ "testing"+)++// availableCommandsSection cuts `## Available Commands` out of a brief by its+// line-start heading, so a phrase that also appears in another section (the+// Comment Formatting rules, the Repositories checkout note) cannot satisfy an+// assertion meant for this one.+func availableCommandsSection(t *testing.T, brief string) string {+ t.Helper()+ start := strings.Index(brief, "\n## Available Commands\n")+ if start < 0 {+ t.Fatalf("brief has no ## Available Commands section:\n%s", brief)+ }+ rest := brief[start+1:]+ if end := strings.Index(rest[len("## Available Commands\n"):], "\n## "); end >= 0 {+ return rest[:len("## Available Commands\n")+end]+ }+ return rest+}++// availableCommandsKinds is every task kind that renders the full (non+// quick-create) Available Commands section. The section is shared verbatim+// across them, so a pointer it carries has to resolve in each one, not only in+// the issue brief.+var availableCommandsKinds = map[string]TaskContextForEnv{+ "issue": {IssueID: "issue-1", AgentID: "a-1", AgentName: "Eve"},+ "issue-reply": {IssueID: "issue-1", TriggerCommentID: "c-1", AgentID: "a-1", AgentName: "Eve"},+ "chat": {ChatSessionID: "chat-1", AgentID: "a-1", AgentName: "Eve"},+ "chat-slack": {ChatSessionID: "chat-1", ChatChannelType: ChannelTypeSlack, AgentID: "a-1", AgentName: "Eve"},+ "autopilot": {AutopilotRunID: "run-1", AutopilotID: "ap-1", AgentID: "a-1", AgentName: "Eve"},+ "squad-leader": {IssueID: "issue-1", IsSquadLeader: true, AgentID: "a-1", AgentName: "Eve"},+}++// TestAvailableCommandsKeepsCompressedContracts pins what MUL-8292 kept when it+// moved command detail out of the brief and into `--help` and the+// multica-platform references. Each entry is a behaviour the agent needs at+// the moment it reaches for the command, not something it can look up after+// the fact; the removed parts (wakeup condition catalogue, PR snapshot+// mechanics, actor-filter recipe) are covered where the pointer leads.+//+// Every kind and provider is checked: chat and autopilot carry the same+// section but no Workflow or Comment Formatting, so a rule kept only as a+// pointer into those sections would silently disappear there.+func TestAvailableCommandsKeepsCompressedContracts(t *testing.T) {+ t.Parallel()+ for kind, ctx := range availableCommandsKinds {+ for _, provider := range []string{"claude", "codex"} {+ kind, ctx, provider := kind, ctx, provider+ t.Run(kind+"/"+provider, func(t *testing.T) {+ t.Parallel()+ ac := availableCommandsSection(t, buildMetaSkillContent(provider, ctx))+ for _, want := range []string{+ // wakeup: the run ends after registering; conditions beat+ // polling; last_error is scoped to the failures it reports.+ "persist an event, condition or time wakeup on this issue, then finish the current run",+ "use one `--until-*` condition so no run starts before it holds",+ "check the rule's `last_error` for missing PR links or snapshots, which are retried automatically",+ "`multica issue wakeup create --help` and the multica-platform issues reference",+ // comment list: the two bounded reads, the THREADS trap and+ // the pagination pointer.+ "scan with `--roots-only --summary`, then expand one thread with `--thread <id> --tail N`",+ "it caps THREADS, not comments",+ "paging cursors, and full flag semantics: `--help`",+ // issue create: long descriptions go through a workdir file.+ "Put agent-authored long descriptions in `--description-file <path>`",+ "heredoc stdin can swallow trailing flags, #4182",+ "write that file inside your working directory, never `/tmp` or shared paths",+ // duplicate mark: why a plain cancel is not enough.+ "`multica issue status <id> cancelled --duplicate-of <original>`",+ "a plain cancel leaves no link",+ // comment add: the file-first mandate stays at the call site.+ "Agent-authored bodies MUST use `--content-file` with a file inside your working directory",+ // repo checkout: both keep conditions, the clean-checkout+ // counter-case, and the destructive flag's limit.+ "keeps a checkout that has uncommitted or unpushed work, or is already on this task's branch, and only fetches",+ "a clean, fully pushed checkout on another branch starts over on a new branch",+ "`--fresh` discards uncommitted and untracked files",+ "push any you still need first",+ // Git identity: the scoped override and the two prohibitions.+ "keep it unless asked",+ "`git config --worktree user.name` / `user.email`",+ "plain or `--local` config can leak into a shared cache",+ "never change the global identity",+ } {+ if !strings.Contains(ac, want) {+ t.Errorf("Available Commands lost %q\n---\n%s", want, ac)+ }+ }++ // Detail that now lives behind the pointers must not drift+ // back in, and the over-broad last_error claim must not return:+ // a pending check or an unmet condition fires nothing and+ // records no error.+ for _, banned := range []string{+ "--until-children-done",+ "server-side GitHub snapshots",+ "--filter-actor-id USER_ID",+ "records why in `last_error`",+ "re-running it keeps existing work and only fetches",+ } {+ if strings.Contains(ac, banned) {+ t.Errorf("Available Commands carries %q\n---\n%s", banned, ac)+ }+ }+ })+ }+ }+}++// TestAvailableCommandsReferencesResolveInEveryKind fails when the shared+// Available Commands section points at a brief section or workflow step that+// the rendering kind does not have. A pointer that resolves in the issue brief+// but not in chat or autopilot silently drops the rule it stands in for.+func TestAvailableCommandsReferencesResolveInEveryKind(t *testing.T) {+ t.Parallel()+ headingRef := regexp.MustCompile("`(##+ [^`]+)`")+ stepRef := regexp.MustCompile(`(?i)\bworkflow step \d`)+ for kind, ctx := range availableCommandsKinds {+ for _, provider := range []string{"claude", "codex"} {+ brief := buildMetaSkillContent(provider, ctx)+ ac := availableCommandsSection(t, brief)+ for _, m := range headingRef.FindAllStringSubmatch(ac, -1) {+ if !strings.HasPrefix(brief, m[1]+"\n") && !strings.Contains(brief, "\n"+m[1]+"\n") {+ t.Errorf("%s/%s: Available Commands points at %q, which this brief does not contain", kind, provider, m[1])+ }+ }+ if hasWorkflowSteps := strings.Contains(brief, "\n1. "); !hasWorkflowSteps {+ for _, m := range stepRef.FindAllString(ac, -1) {+ t.Errorf("%s/%s: Available Commands points at %q, but this brief has no numbered workflow", kind, provider, m)+ }+ }+ }+ }+}diff --git a/server/internal/daemon/execenv/runtime_config_sections.go b/server/internal/daemon/execenv/runtime_config_sections.goindex 67e5ee3e98..e5186fe582 100644--- a/server/internal/daemon/execenv/runtime_config_sections.go+++ b/server/internal/daemon/execenv/runtime_config_sections.go@@ -192,8 +192,13 @@ func sanitizeBriefCodeToken(s string) string {return s}-// writeAvailableCommands emits the slim Available Commands section-// (~3.0k chars vs legacy ~4.4k). Every test-asserted substring is+// writeAvailableCommands emits the slim Available Commands section.+// MUL-8292 cut it from ~4.4k back to ~3.4k bytes: each bullet keeps the+// signature and the behaviour needed at the call site, and points to+// `--help` / the multica-platform references for the rest (wakeup condition+// catalogue, PR snapshot mechanics, actor filters, repeated file rules).+// TestAvailableCommandsKeepsCompressedContracts pins what stayed. Every+// test-asserted substring is// preserved: each `multica issue …` command name, all three `comment add`// input modes, `--description-file <path>`, `--parent ""`, the// `Next reply cursor` / `Next thread cursor` stderr labels, the "core@@ -215,17 +220,17 @@ func writeAvailableCommands(b *strings.Builder, ctx TaskContextForEnv) {b.WriteString("`--output json` writes JSON to stdout; confirmations and warnings go to stderr. Do not merge them (`2>&1`) into anything that parses the output — that makes a write that SUCCEEDED look like it failed and invites a duplicate retry.\n\n")b.WriteString("### Core\n")b.WriteString("- `multica issue get <id> --output json` — full issue.\n")- b.WriteString("- `multica issue comment list <issue-id> [--roots-only] [--summary] [--thread <comment-id> [--tail N] | --recent N] [--since <RFC3339>] --output json` — thread-aware comment reads. Bound a wide read with `--roots-only --summary` (roots plus `reply_count` / `last_activity_at`, clipped bodies); bound a deep one with `--thread <id> --tail N`; add `--compact` to any JSON read to drop echoed/null/bookkeeping fields. Careful with `--recent N`: it caps THREADS, not comments, and can return the whole history on a small issue. Resolved-thread folding, paging cursors, and full flag semantics: `--help`.\n")- b.WriteString("- `multica issue create --title \"...\" [--description-file <path>] [--priority X] [--status X] [--assignee X | --assignee-id <uuid>] [--parent <issue-id>] [--stage N] [--project <project-id>] [--due-date <YYYY-MM-DD>] [--attachment <path>]` — create an issue. For agent-authored long descriptions prefer `--description-file <path>` (heredoc stdin can swallow trailing flags, #4182). Write that file inside your working directory (e.g. `./description.md`), never `/tmp` or shared paths — same workdir rule as `## Comment Formatting`.\n")+ b.WriteString("- `multica issue comment list <issue-id> [--roots-only] [--summary] [--thread <comment-id> [--tail N] | --recent N] [--since <RFC3339>] [--compact] --output json` — thread-aware comment reads. Read in two bounded steps: scan with `--roots-only --summary`, then expand one thread with `--thread <id> --tail N`. Careful with `--recent N`: it caps THREADS, not comments, and can return the whole history on a small issue. Resolved-thread folding, paging cursors, and full flag semantics: `--help`.\n")+ b.WriteString("- `multica issue create --title \"...\" [--description-file <path>] [--priority X] [--status X] [--assignee X | --assignee-id <uuid>] [--parent <issue-id>] [--stage N] [--project <project-id>] [--due-date <YYYY-MM-DD>] [--attachment <path>]` — create an issue. Put agent-authored long descriptions in `--description-file <path>` (heredoc stdin can swallow trailing flags, #4182); write that file inside your working directory, never `/tmp` or shared paths.\n")b.WriteString("- `multica issue update <id> [--title X] [--description-file <path>] [--priority X] [--status X] [--assignee X] [--parent <issue-id>] [--stage N] [--project <project-id>] [--due-date <YYYY-MM-DD>]` — update fields; pass `--parent \"\"` to clear parent.\n")b.WriteString("- `multica issue assign <id> (--to X | --to-id <uuid> | --unassign)` — change ownership; assigning to an agent can start a run.\n")writeIssueStatusCommand(b, ctx)b.WriteString(duplicateOfCommandLine)- b.WriteString("- `multica issue wakeup <create|list|get|update|disable|trigger|delete|runs|events>` — persist an event, condition or time wakeup on this issue, then finish the current run. When the platform can check the fact itself, use a condition (`--until-status`, `--until-pr checks|conflicts`, `--until-children-done`, `--until-issue`) so no run starts before it holds. PR conditions watch only PRs linked to this exact issue; `--until-pr checks|conflicts` also requires server-side GitHub snapshots. Check the rule's `last_error` for missing links or unavailable snapshots; delayed links and snapshots are retried automatically. Use `--event comment.created --filter-actor-type member --filter-actor-id USER_ID` to wait for a specific member to comment. See `multica issue wakeup --help` and the multica-platform issues reference.\n")+ b.WriteString("- `multica issue wakeup <create|list|get|update|disable|trigger|delete|runs|events>` — persist an event, condition or time wakeup on this issue, then finish the current run. When the platform can check the fact itself, use one `--until-*` condition so no run starts before it holds; check the rule's `last_error` for missing PR links or snapshots, which are retried automatically. Conditions, PR rules and actor filters: `multica issue wakeup create --help` and the multica-platform issues reference.\n")b.WriteString("- `multica issue children <id> [--output json]` — list a parent's sub-issues grouped by stage.\n")- b.WriteString("- `multica issue comment add <issue-id> [--content \"...\" | --content-file <path> | --content-stdin] [--parent <comment-id>] [--attachment <path>]` — post a comment. Agent-authored bodies MUST use `--content-file`; see `## Comment Formatting` for why. `multica issue comment add --help` for full flags.\n")- b.WriteString("- `multica repo checkout <url> [--ref <branch-or-sha>] [--fresh]` — repository checkout on a dedicated branch. Re-running it keeps an existing checkout that has uncommitted or unpushed work, or is already on this task's branch, and only fetches. `--fresh` discards uncommitted and untracked files and starts a new branch; commits stay on the old branch, but push any you still need first.\n\n")- b.WriteString("Git commits use the user's configured identity. Preserve it unless the user requests another identity. In a managed checkout, use `git config --worktree user.name` / `user.email` for an intentional task-local override; plain `git config` or `--local` can write into a shared cache and affect other tasks. Never change global Git identity for a task.\n\n")+ b.WriteString("- `multica issue comment add <issue-id> [--content \"...\" | --content-file <path> | --content-stdin] [--parent <comment-id>] [--attachment <path>]` — post a comment. Agent-authored bodies MUST use `--content-file` with a file inside your working directory; full flags: `multica issue comment add --help`.\n")+ b.WriteString("- `multica repo checkout <url> [--ref <branch-or-sha>] [--fresh]` — repository checkout on a dedicated branch; re-running it keeps a checkout that has uncommitted or unpushed work, or is already on this task's branch, and only fetches; a clean, fully pushed checkout on another branch starts over on a new branch. `--fresh` discards uncommitted and untracked files for a new branch; commits stay on the old branch, so push any you still need first.\n\n")+ b.WriteString("Commits use the user's configured Git identity; keep it unless asked. For a requested override in a managed checkout use `git config --worktree user.name` / `user.email` — plain or `--local` config can leak into a shared cache; never change the global identity.\n\n")// Squad maintenance is squad-leader surface: an agent that leads no squad// has no squad to change roles in, so this shipped to every run as dead// weight (MUL-5442). IsSquadLeader is a PER-TASK role (the daemon derives@@ -242,7 +247,7 @@ func writeAvailableCommands(b *strings.Builder, ctx TaskContextForEnv) {// duplicateOfCommandLine teaches the duplicate mark (MUL-7821). Without it// agents cancel duplicates with a plain status change plus a comment, which// leaves the original's duplicates list empty.-const duplicateOfCommandLine = "- `multica issue status <id> cancelled --duplicate-of <original>` — cancel an issue that duplicates another and record the mark, so the original lists it; a plain cancel plus a comment leaves no link.\n"+const duplicateOfCommandLine = "- `multica issue status <id> cancelled --duplicate-of <original>` — mark a duplicate so the original lists it; a plain cancel leaves no link.\n"// briefStatusCategoryOrder groups the briefing catalog by internal lifecycle,// matching ListIssueStatusEntries. User-facing columns still use status keys.