feat(gateway): polish /status command response format
Format /status response with clear heading, visual task status icons, canonical lifecycle ordering, and separated runtime details with graceful fallbacks.
This commit is contained in:
1 parent
34e36adf36
commit
f0709829c6
5 files changed
+368
-23
No files matched your search
+1
-1
@@ -81,4 +81,4 @@ bd.db
|
||||
# They would override fork protection in .git/info/exclude.
|
||||
# Config files (metadata.json, config.yaml) are tracked by git by default
|
||||
# since no pattern above ignores them.
|
||||
config.yaml
|
||||
# config.yaml
|
||||
@@ -0,0 +1,79 @@
|
||||
# Beads Configuration File
|
||||
# This file configures default behavior for all bd commands in this repository
|
||||
# All settings can also be set via environment variables (BD_* prefix)
|
||||
# or overridden with command-line flags
|
||||
|
||||
# Issue prefix for this repository (used by bd init)
|
||||
# If not set, bd init will auto-detect from directory name
|
||||
# Example: issue-prefix: "myproject" creates issues like "myproject-1", "myproject-2", etc.
|
||||
# issue-prefix: ""
|
||||
|
||||
# Use no-db mode: JSONL-only, no Dolt database
|
||||
# When true, .beads/issues.jsonl is the only local store
|
||||
# no-db: false
|
||||
|
||||
# Enable JSON output by default
|
||||
# json: false
|
||||
|
||||
# Feedback title formatting for mutating commands (create/update/close/dep/edit)
|
||||
# 0 = hide titles, N > 0 = truncate to N characters
|
||||
# output:
|
||||
# title-length: 255
|
||||
|
||||
# Default actor for audit trails (overridden by BEADS_ACTOR or --actor)
|
||||
# actor: ""
|
||||
|
||||
# Optional JSONL sidecar for explicit agent/tool interaction audit records.
|
||||
# Issue history is always recorded in the database and is visible with
|
||||
# bd history <id> --events; this only controls .beads/interactions.jsonl.
|
||||
# audit:
|
||||
# enabled: false
|
||||
|
||||
# Export events (audit trail) to .beads/events.jsonl on each flush/sync
|
||||
# When enabled, new events are appended incrementally using a high-water mark.
|
||||
# Use 'bd export --events' to trigger manually regardless of this setting.
|
||||
# events-export: false
|
||||
|
||||
# Multi-repo configuration (experimental - bd-307)
|
||||
# Allows hydrating from multiple repositories and routing writes to the correct database
|
||||
# repos:
|
||||
# primary: "." # Primary repo (where this database lives)
|
||||
# additional: # Additional repos to hydrate from (read-only)
|
||||
# - ~/beads-planning # Personal planning repo
|
||||
# - ~/work-planning # Work planning repo
|
||||
|
||||
# Dolt-native backup (periodic backup for off-machine recovery)
|
||||
# This is full database backup only. Cross-machine sync uses Dolt remotes.
|
||||
# backup:
|
||||
# enabled: false # Disable auto-backup entirely
|
||||
# interval: 15m # Minimum time between auto-backups
|
||||
# git-push: false # Disable git push (backup locally only)
|
||||
# git-repo: "" # Separate git repo for backups (default: project repo)
|
||||
|
||||
# Optional JSONL auto-export for viewers, interchange, and issue-level migration.
|
||||
# Disabled by default; enable only when an integration needs fresh .beads/issues.jsonl.
|
||||
# Use relative paths under .beads/ for JSONL import/export filenames.
|
||||
export:
|
||||
auto: true
|
||||
path: issues.jsonl
|
||||
interval: 60s
|
||||
git-add: false
|
||||
import:
|
||||
path: issues.jsonl
|
||||
|
||||
# Integration settings (access with 'bd config get/set')
|
||||
# Non-secret keys (stored in the database):
|
||||
# - jira.url, jira.project
|
||||
# - linear.team_id
|
||||
# - github.org, github.repo
|
||||
#
|
||||
# Secret keys (stored in this file but prefer env vars to avoid git exposure):
|
||||
# - linear.api_key → use LINEAR_API_KEY env var instead
|
||||
# - github.token → use GITHUB_TOKEN env var instead
|
||||
|
||||
sync.remote: "git+https://github.com/samcharles93/archie-core.git"
|
||||
dolt:
|
||||
shared-server: true
|
||||
auto-commit: "on"
|
||||
audit:
|
||||
enabled: true
|
||||
@@ -0,0 +1,2 @@
|
||||
{"id":"int-ca573b1f243d5e820077aadb21af8595","kind":"field_change","created_at":"2026-08-15T12:27:33.967613847Z","actor":"Sam Catlow","issue_id":"archie-core-1786637491053-48-fe78cd53","extra":{"field":"status","new_value":"closed","old_value":"open","reason":"Verified against current main: Route/RouteStream reject unrecognized slash commands before any LLM call (gateway.go:299-318, 449-462), /start is deterministic in both gateway and Telegram handlers, and full test matrix from acceptance criteria exists (gateway_test.go:106-133, gateway_stream_test.go:54-88, telegram_test.go:135-157). Confirmed by fresh code-tracing pass, not just prior user experience."}}
|
||||
{"id":"int-73ca4d209481e52e20c00c128fc6a3ca","kind":"field_change","created_at":"2026-08-15T12:41:34.047451864Z","actor":"Sam Catlow","issue_id":"archie-core-1786748942519-17-5999d55b","extra":{"field":"status","new_value":"closed","old_value":"in_progress","reason":"Closed"}}
|
||||
+157
-15
@@ -9,17 +9,19 @@
|
||||
package gateway
|
||||
|
||||
import (
|
||||
"cmp"
|
||||
"context"
|
||||
"fmt"
|
||||
"log/slog"
|
||||
"slices"
|
||||
"sort"
|
||||
"strconv"
|
||||
"strings"
|
||||
"sync"
|
||||
"time"
|
||||
"unicode"
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/releaseupdate"
|
||||
"github.com/samcharles93/archie-core/internal/taskstate"
|
||||
)
|
||||
|
||||
// Message is an inbound message from a gateway connection.
|
||||
@@ -714,31 +716,171 @@ func (r *Router) handleStatus(ctx context.Context) (string, error) {
|
||||
if err != nil {
|
||||
return "", fmt.Errorf("status: %w", err)
|
||||
}
|
||||
if len(counts) == 0 && r.Models == nil {
|
||||
return "No tasks yet.", nil
|
||||
}
|
||||
return formatStatus(counts, r.Models), nil
|
||||
}
|
||||
|
||||
type taskStateDisplay struct {
|
||||
icon string
|
||||
label string
|
||||
}
|
||||
|
||||
var taskStateDisplays = map[string]taskStateDisplay{
|
||||
taskstate.Running: {icon: "▶", label: "Running"},
|
||||
taskstate.WaitingHuman: {icon: "👤", label: "Waiting"},
|
||||
taskstate.Parked: {icon: "⏸", label: "Parked"},
|
||||
taskstate.Queued: {icon: "⏳", label: "Queued"},
|
||||
taskstate.PROpen: {icon: "🔀", label: "PR open"},
|
||||
taskstate.Merged: {icon: "✅", label: "Merged"},
|
||||
taskstate.Rejected: {icon: "❌", label: "Rejected"},
|
||||
taskstate.Declined: {icon: "🚫", label: "Declined"},
|
||||
"declined": {icon: "🚫", label: "Declined"},
|
||||
taskstate.Dead: {icon: "🛑", label: "Dead"},
|
||||
}
|
||||
|
||||
var statusOrder = []string{
|
||||
taskstate.Running,
|
||||
taskstate.WaitingHuman,
|
||||
taskstate.Parked,
|
||||
taskstate.Queued,
|
||||
taskstate.PROpen,
|
||||
taskstate.Merged,
|
||||
taskstate.Rejected,
|
||||
taskstate.Declined,
|
||||
"declined",
|
||||
taskstate.Dead,
|
||||
}
|
||||
|
||||
func sortStatuses(counts map[string]int) []string {
|
||||
statuses := make([]string, 0, len(counts))
|
||||
for s := range counts {
|
||||
statuses = append(statuses, s)
|
||||
}
|
||||
sort.Strings(statuses)
|
||||
|
||||
orderMap := make(map[string]int, len(statusOrder))
|
||||
for i, s := range statusOrder {
|
||||
orderMap[s] = i
|
||||
}
|
||||
|
||||
slices.SortFunc(statuses, func(a, b string) int {
|
||||
idxA, okA := orderMap[a]
|
||||
idxB, okB := orderMap[b]
|
||||
if okA && okB {
|
||||
return cmp.Compare(idxA, idxB)
|
||||
}
|
||||
if okA {
|
||||
return -1
|
||||
}
|
||||
if okB {
|
||||
return 1
|
||||
}
|
||||
return strings.Compare(a, b)
|
||||
})
|
||||
|
||||
return statuses
|
||||
}
|
||||
|
||||
func formatCustomStatus(s string) string {
|
||||
s = strings.TrimSpace(strings.ReplaceAll(s, "_", " "))
|
||||
if s == "" {
|
||||
return "Unknown"
|
||||
}
|
||||
r := []rune(s)
|
||||
r[0] = unicode.ToUpper(r[0])
|
||||
return string(r)
|
||||
}
|
||||
|
||||
var knownProviderNames = map[string]string{
|
||||
"openai": "OpenAI",
|
||||
"openrouter": "OpenRouter",
|
||||
"anthropic": "Anthropic",
|
||||
"deepseek": "DeepSeek",
|
||||
"google": "Google",
|
||||
"ollama": "Ollama",
|
||||
"github": "GitHub",
|
||||
"gh": "GitHub",
|
||||
"groq": "Groq",
|
||||
"together": "Together",
|
||||
"bedrock": "Bedrock",
|
||||
"azure": "Azure",
|
||||
}
|
||||
|
||||
func formatProviderName(provider string) string {
|
||||
trimmed := strings.TrimSpace(provider)
|
||||
if trimmed == "" {
|
||||
return ""
|
||||
}
|
||||
if name, ok := knownProviderNames[strings.ToLower(trimmed)]; ok {
|
||||
return name
|
||||
}
|
||||
if strings.ToLower(trimmed) == trimmed {
|
||||
r := []rune(trimmed)
|
||||
r[0] = unicode.ToUpper(r[0])
|
||||
return string(r)
|
||||
}
|
||||
return trimmed
|
||||
}
|
||||
|
||||
func extractRuntimeInfo(models ModelManager) (provider, model string) {
|
||||
if models == nil {
|
||||
return "", ""
|
||||
}
|
||||
model = strings.TrimSpace(models.ActiveModel())
|
||||
if pmm, ok := models.(ProviderModelManager); ok {
|
||||
provider = strings.TrimSpace(pmm.ActiveProvider())
|
||||
}
|
||||
if provider == "" && model != "" {
|
||||
if p, _, ok := strings.Cut(model, "/"); ok {
|
||||
provider = p
|
||||
}
|
||||
}
|
||||
if pdn, ok := models.(ProviderDisplayNamer); ok && provider != "" {
|
||||
if name := strings.TrimSpace(pdn.ProviderDisplayName(provider)); name != "" {
|
||||
return name, model
|
||||
}
|
||||
}
|
||||
return formatProviderName(provider), model
|
||||
}
|
||||
|
||||
func formatRuntimeSection(b *strings.Builder, provider, model string) {
|
||||
b.WriteString("\nRuntime\n")
|
||||
if provider == "" && model == "" {
|
||||
b.WriteString("Not configured\n")
|
||||
return
|
||||
}
|
||||
if provider == "" {
|
||||
provider = "Not configured"
|
||||
}
|
||||
if model == "" {
|
||||
model = "Not configured"
|
||||
}
|
||||
fmt.Fprintf(b, "Provider: %s\nModel: %s\n", provider, model)
|
||||
}
|
||||
|
||||
// formatStatus formats the task counts and active runtime details into
|
||||
// a clean, mobile-friendly summary.
|
||||
func formatStatus(counts map[string]int, models ModelManager) string {
|
||||
var b strings.Builder
|
||||
b.WriteString("📊 Archie status\n\nTasks\n")
|
||||
|
||||
statuses := sortStatuses(counts)
|
||||
if len(statuses) == 0 {
|
||||
b.WriteString("No tasks yet.\n")
|
||||
b.WriteString("No tasks yet\n")
|
||||
} else {
|
||||
b.WriteString("Task status:\n")
|
||||
for _, s := range statuses {
|
||||
fmt.Fprintf(&b, " %s: %d\n", s, counts[s])
|
||||
count := counts[s]
|
||||
d, ok := taskStateDisplays[s]
|
||||
if ok {
|
||||
fmt.Fprintf(&b, "%s %s: %d\n", d.icon, d.label, count)
|
||||
} else {
|
||||
fmt.Fprintf(&b, "• %s: %d\n", formatCustomStatus(s), count)
|
||||
}
|
||||
}
|
||||
}
|
||||
if r.Models != nil {
|
||||
if manager, ok := r.Models.(ProviderModelManager); ok {
|
||||
fmt.Fprintf(&b, "\nProvider: %s\n", manager.ActiveProvider())
|
||||
}
|
||||
fmt.Fprintf(&b, "Model: %s\n", r.Models.ActiveModel())
|
||||
}
|
||||
return strings.TrimSpace(b.String()), nil
|
||||
|
||||
provider, model := extractRuntimeInfo(models)
|
||||
formatRuntimeSection(&b, provider, model)
|
||||
|
||||
return strings.TrimSpace(b.String())
|
||||
}
|
||||
|
||||
func (r *Router) handleWhoami() (string, error) {
|
||||
|
||||
@@ -28,8 +28,9 @@ func TestRouteStatusWithTasks(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Route: %v", err)
|
||||
}
|
||||
if !strings.Contains(reply, "queued: 2") || !strings.Contains(reply, "pr_open: 1") {
|
||||
t.Errorf("reply missing counts: %q", reply)
|
||||
want := "📊 Archie status\n\nTasks\n⏳ Queued: 2\n🔀 PR open: 1\n\nRuntime\nNot configured"
|
||||
if reply != want {
|
||||
t.Errorf("reply =\n%q\nwant:\n%q", reply, want)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -47,8 +48,9 @@ func TestRouteStatusIncludesActiveProviderAndModel(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatal(err)
|
||||
}
|
||||
if !strings.Contains(reply, "Provider: openai") || !strings.Contains(reply, "Model: openai/gpt-5.6") {
|
||||
t.Fatalf("status missing active provider/model:\n%s", reply)
|
||||
want := "📊 Archie status\n\nTasks\n▶ Running: 1\n\nRuntime\nProvider: OpenAI\nModel: openai/gpt-5.6"
|
||||
if reply != want {
|
||||
t.Fatalf("reply =\n%q\nwant:\n%q", reply, want)
|
||||
}
|
||||
}
|
||||
|
||||
@@ -58,7 +60,7 @@ func TestRouteStatusAtMention(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Route: %v", err)
|
||||
}
|
||||
if !strings.Contains(reply, "running: 3") {
|
||||
if !strings.Contains(reply, "▶ Running: 3") {
|
||||
t.Errorf("reply missing counts: %q", reply)
|
||||
}
|
||||
}
|
||||
@@ -69,8 +71,128 @@ func TestRouteStatusEmpty(t *testing.T) {
|
||||
if err != nil {
|
||||
t.Fatalf("Route: %v", err)
|
||||
}
|
||||
if reply != "No tasks yet." {
|
||||
t.Errorf("reply = %q, want %q", reply, "No tasks yet.")
|
||||
want := "📊 Archie status\n\nTasks\nNo tasks yet\n\nRuntime\nNot configured"
|
||||
if reply != want {
|
||||
t.Errorf("reply = %q, want %q", reply, want)
|
||||
}
|
||||
}
|
||||
|
||||
type fakeCustomDisplayNamerManager struct {
|
||||
fakeProviderModelManager
|
||||
}
|
||||
|
||||
func (f *fakeCustomDisplayNamerManager) ProviderDisplayName(provider string) string {
|
||||
if provider == "openai" {
|
||||
return "OpenAI Custom Enterprise"
|
||||
}
|
||||
return provider
|
||||
}
|
||||
|
||||
func TestFormatStatus(t *testing.T) {
|
||||
tests := []struct {
|
||||
name string
|
||||
counts map[string]int
|
||||
models ModelManager
|
||||
want string
|
||||
}{
|
||||
{
|
||||
name: "example from specification - single parked task with provider and model",
|
||||
counts: map[string]int{"parked": 2},
|
||||
models: &fakeProviderModelManager{
|
||||
fakeModelManager: fakeModelManager{
|
||||
activeModel: "openai/gpt-5.6-luna",
|
||||
},
|
||||
},
|
||||
want: "📊 Archie status\n\nTasks\n⏸ Parked: 2\n\nRuntime\nProvider: OpenAI\nModel: openai/gpt-5.6-luna",
|
||||
},
|
||||
{
|
||||
name: "multiple task states in canonical order",
|
||||
counts: map[string]int{
|
||||
"queued": 4,
|
||||
"running": 1,
|
||||
"waiting_human": 2,
|
||||
"parked": 3,
|
||||
"pr_open": 5,
|
||||
"merged": 6,
|
||||
"rejected": 7,
|
||||
"closed_wont_do": 8,
|
||||
"dead": 9,
|
||||
"custom_state": 10,
|
||||
},
|
||||
models: &fakeProviderModelManager{
|
||||
fakeModelManager: fakeModelManager{
|
||||
activeModel: "deepseek/deepseek-v4-pro",
|
||||
},
|
||||
},
|
||||
want: "📊 Archie status\n\nTasks\n▶ Running: 1\n👤 Waiting: 2\n⏸ Parked: 3\n⏳ Queued: 4\n🔀 PR open: 5\n✅ Merged: 6\n❌ Rejected: 7\n🚫 Declined: 8\n🛑 Dead: 9\n• Custom state: 10\n\nRuntime\nProvider: DeepSeek\nModel: deepseek/deepseek-v4-pro",
|
||||
},
|
||||
{
|
||||
name: "empty task counts with active model",
|
||||
counts: map[string]int{},
|
||||
models: &fakeModelManager{
|
||||
activeModel: "anthropic/claude-3-5-sonnet",
|
||||
},
|
||||
want: "📊 Archie status\n\nTasks\nNo tasks yet\n\nRuntime\nProvider: Anthropic\nModel: anthropic/claude-3-5-sonnet",
|
||||
},
|
||||
{
|
||||
name: "nil counts with active model",
|
||||
counts: nil,
|
||||
models: &fakeModelManager{
|
||||
activeModel: "google/gemini-2.5-flash",
|
||||
},
|
||||
want: "📊 Archie status\n\nTasks\nNo tasks yet\n\nRuntime\nProvider: Google\nModel: google/gemini-2.5-flash",
|
||||
},
|
||||
{
|
||||
name: "nil model manager",
|
||||
counts: map[string]int{"running": 2},
|
||||
models: nil,
|
||||
want: "📊 Archie status\n\nTasks\n▶ Running: 2\n\nRuntime\nNot configured",
|
||||
},
|
||||
{
|
||||
name: "empty counts and nil model manager",
|
||||
counts: map[string]int{},
|
||||
models: nil,
|
||||
want: "📊 Archie status\n\nTasks\nNo tasks yet\n\nRuntime\nNot configured",
|
||||
},
|
||||
{
|
||||
name: "custom display namer interface",
|
||||
counts: map[string]int{"running": 1},
|
||||
models: &fakeCustomDisplayNamerManager{
|
||||
fakeProviderModelManager: fakeProviderModelManager{
|
||||
fakeModelManager: fakeModelManager{
|
||||
activeModel: "openai/gpt-5.6",
|
||||
},
|
||||
},
|
||||
},
|
||||
want: "📊 Archie status\n\nTasks\n▶ Running: 1\n\nRuntime\nProvider: OpenAI Custom Enterprise\nModel: openai/gpt-5.6",
|
||||
},
|
||||
{
|
||||
name: "provider set but model empty",
|
||||
counts: map[string]int{"queued": 1},
|
||||
models: &fakeProviderModelManager{
|
||||
fakeModelManager: fakeModelManager{
|
||||
activeModel: "",
|
||||
},
|
||||
},
|
||||
want: "📊 Archie status\n\nTasks\n⏳ Queued: 1\n\nRuntime\nNot configured",
|
||||
},
|
||||
{
|
||||
name: "model without slash and no provider manager",
|
||||
counts: map[string]int{"running": 1},
|
||||
models: &fakeModelManager{
|
||||
activeModel: "custom-local-model",
|
||||
},
|
||||
want: "📊 Archie status\n\nTasks\n▶ Running: 1\n\nRuntime\nProvider: Not configured\nModel: custom-local-model",
|
||||
},
|
||||
}
|
||||
|
||||
for _, tc := range tests {
|
||||
t.Run(tc.name, func(t *testing.T) {
|
||||
got := formatStatus(tc.counts, tc.models)
|
||||
if got != tc.want {
|
||||
t.Errorf("formatStatus() =\n%q\nwant:\n%q\ndiff:\ngot:\n%s\nwant:\n%s", got, tc.want, got, tc.want)
|
||||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user