refactor(gateway,ui): the page catalogue is generated from the router (#2050)
The assistant's catalogue was a 33-entry literal in Go, hand-maintained beside the dashboard's routes: eight real pages were missing from it, so page_index could not name them, and descriptions had drifted where both copies existed. The routes move to ui/src/router/routes.ts, free of component imports, and ui/scripts/pages.ts writes the catalogue from them. The nav and page_index now read the same generated file, and task pages:check fails when it is stale, the way the proto, sqlc and OpenAPI outputs do.
This commit is contained in:
7 files changed
+887
-554
No files matched your search
@@ -8,63 +8,34 @@ import (
|
||||
|
||||
"github.com/samcharles93/archie-core/internal/prompts"
|
||||
"github.com/samcharles93/archie-core/internal/tools"
|
||||
"github.com/samcharles93/archie-core/ui/pages"
|
||||
)
|
||||
|
||||
// DashboardPage describes one dashboard surface so the chat agent can both
|
||||
// understand what each place is for and point the operator there.
|
||||
// understand what each place is for and point the operator there. It is the
|
||||
// catalogue the dashboard's own navigation renders from (ui/pages), so a page
|
||||
// the assistant can name is a page the operator can reach.
|
||||
type DashboardPage struct {
|
||||
// Path is the route (e.g. "/tasks"). It is what the browser hash becomes.
|
||||
Path string
|
||||
// Label is the human name shown in navigation (e.g. "Tasks").
|
||||
// Label is the human name the navigation shows (e.g. "Tasks").
|
||||
Label string
|
||||
// Description is a one-line plain-language explanation of what the page
|
||||
// shows, so the agent can answer "where do I go for that?" correctly.
|
||||
Description string
|
||||
}
|
||||
|
||||
// dashboardPages lists the dashboard pages the prompt and the
|
||||
// dashboard_navigate tool can name.
|
||||
var dashboardPages = []DashboardPage{
|
||||
{Path: "/", Label: "Dashboard", Description: "Running work, work needing attention, token spend."},
|
||||
{Path: "/tasks", Label: "Tasks", Description: "Picked-up issues and their status."},
|
||||
{Path: "/account", Label: "Your account", Description: "Password, recovery code, passkeys and personal API tokens."},
|
||||
{Path: "/org", Label: "Organisation", Description: "Members, identities, connections, models and automation."},
|
||||
{Path: "/org/members", Label: "Members", Description: "People in the organisation and their roles."},
|
||||
{Path: "/org/agents", Label: "Agents", Description: "Execution identities, their permissions and commit author."},
|
||||
{Path: "/org/workspaces", Label: "Workspaces", Description: "Groups of organisation work and resources."},
|
||||
{Path: "/org/policies", Label: "Policies", Description: "Access rules for the organisation."},
|
||||
{Path: "/org/connections", Label: "Connections", Description: "Forge hosts, credentials and permitted operations."},
|
||||
{Path: "/org/credential-bindings", Label: "Credential bindings", Description: "Service credentials granted to agent identities."},
|
||||
{Path: "/org/models", Label: "Models", Description: "Organisation providers and model aliases."},
|
||||
{Path: "/org/instructions", Label: "Instructions", Description: "Archie's identity, tone and standing instructions for the organisation."},
|
||||
{Path: "/org/playbooks", Label: "Playbooks", Description: "Edit event-driven automation rules."},
|
||||
{Path: "/settings/authentication", Label: "Authentication", Description: "Instance URL and OIDC sign-in."},
|
||||
{Path: "/workflows", Label: "Workflows", Description: "Workflows and run history."},
|
||||
{Path: "/settings/skills", Label: "Skills", Description: "Skills Archie can activate."},
|
||||
{Path: "/settings/curators", Label: "Curators", Description: "Scheduled memory and capture curation."},
|
||||
{Path: "/events", Label: "Events", Description: "Captured events, field mappings, workflow bindings."},
|
||||
{Path: "/logs", Label: "Logs", Description: "Daemon log by level and component."},
|
||||
{Path: "/org/channels", Label: "Channels", Description: "Chat and notification channels."},
|
||||
{Path: "/settings/status", Label: "Status", Description: "Update state, config sources, listen address."},
|
||||
{Path: "/account/appearance", Label: "Appearance", Description: "Theme, density, motion."},
|
||||
{Path: "/settings/task-execution", Label: "Task execution", Description: "Statuses, operator actions, budgets."},
|
||||
{Path: "/settings/models", Label: "Models", Description: "Instance model aliases and providers."},
|
||||
{Path: "/org/repositories", Label: "Repositories", Description: "Watched repositories and gate overrides."},
|
||||
{Path: "/org/scheduling-policy", Label: "Scheduling policy", Description: "Work discovery and forge labels."},
|
||||
{Path: "/settings/tools", Label: "Tools & MCP", Description: "Agent tools and MCP servers."},
|
||||
{Path: "/org/audit", Label: "Audit", Description: "Settings, access, identity and runtime events."},
|
||||
{Path: "/org/denials", Label: "Denials", Description: "Access requests the policy chain refused, newest first."},
|
||||
{Path: "/settings/plugins", Label: "Plugins", Description: "Extension directories loaded at startup."},
|
||||
{Path: "/settings/secret-engines", Label: "Secret engines"},
|
||||
{Path: "/settings/container-runtime", Label: "Container runtime"},
|
||||
{Path: "/settings/agent-profiles", Label: "Agent profiles", Description: "Execution profiles: the image and tools each agent runs with."},
|
||||
}
|
||||
|
||||
// DashboardPages returns a copy of the dashboard page registry.
|
||||
func DashboardPages() []DashboardPage {
|
||||
out := make([]DashboardPage, len(dashboardPages))
|
||||
copy(out, dashboardPages)
|
||||
return out
|
||||
// DashboardPages returns the dashboard's page catalogue, in its own order.
|
||||
func DashboardPages() ([]DashboardPage, error) {
|
||||
catalogue, err := pages.All()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
out := make([]DashboardPage, 0, len(catalogue))
|
||||
for _, p := range catalogue {
|
||||
out = append(out, DashboardPage{Path: p.Path, Label: p.Label, Description: p.Description})
|
||||
}
|
||||
return out, nil
|
||||
}
|
||||
|
||||
// PageIndexResult is what page_index returns: the full list of dashboard pages
|
||||
@@ -84,7 +55,11 @@ func pageIndexTool() (tools.ToolEntry, bool) {
|
||||
Description: "List every dashboard page, what it shows, and built-in guidance for creating workflows and using Archie. Use it to tell the operator where to go for something rather than guessing.",
|
||||
Classification: tools.ClassIdempotent,
|
||||
Handler: func(_ context.Context, _ map[string]any) (any, error) {
|
||||
return PageIndexResult{Pages: DashboardPages(), ProductGuide: prompts.ProductGuide()}, nil
|
||||
indexed, err := DashboardPages()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
return PageIndexResult{Pages: indexed, ProductGuide: prompts.ProductGuide()}, nil
|
||||
},
|
||||
}
|
||||
return entry, true
|
||||
@@ -114,7 +89,11 @@ func dashboardNavigateTool() (tools.ToolEntry, bool) {
|
||||
if path == "" {
|
||||
return nil, errors.New("dashboard_navigate: path is required")
|
||||
}
|
||||
for _, p := range dashboardPages {
|
||||
indexed, err := DashboardPages()
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
for _, p := range indexed {
|
||||
if p.Path == path {
|
||||
return DashboardNavigateResult{Path: p.Path, Label: p.Label}, nil
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user