Public: anyone can read this; the crew can change it.
The Crew teams page and the `teams` MCP tool say each team's effective share of builder slots #13275
Check · Review · Land · Live done — Landed and live in production.
scout/forge:scout/13255-the-crew-teams-page-and-the-teams-mcp-to → main 5 commits fork 3 threads · 3 unresolved
docs/OPERATING.md +1 −1
Diff not shown — a line 5,045 characters wide (limit 2,000). +1 −1
View filedocs/features/README.md +1
| @@ -375,6 +375,7 @@ Read with the guide page [Agents: MCP, git, or the terminal](../guide-agents.md) | ||
| 375 | 375 | - [](offer.md) |
| 376 | 376 | - [](report-form.md) |
| 377 | 377 | - [](report-receipt.md) |
| 378 | - [](team-effective-share.md) | |
| 378 | 379 | - [](tokens-harness.md) |
| 379 | 380 | |
| 380 | 381 | ### Backups and moving |
src/core/teams.ts +25
| @@ -98,3 +98,28 @@ export function saveTeam( | ||
| 98 | 98 | if (failed) return err(failed); |
| 99 | 99 | return ok(getTeam(db, slug)!); |
| 100 | 100 | } |
| 101 | ||
| 102 | /** | |
| 103 | * The share of builder starts a team actually gets: its dial when above zero. | |
| 104 | * A zero-dial team owns nothing extra, so its issues are unlabelled work and | |
| 105 | * take the rest the dials leave (`labelled: false`). | |
| 106 | */ | |
| 107 | export function effectiveShare( | |
| 108 | teams: readonly Team[], | |
| 109 | slug: string, | |
| 110 | ): { readonly share: number; readonly labelled: boolean } { | |
| 111 | const used = teams.reduce((n, t) => n + Math.max(0, t.dial), 0); | |
| 112 | const t = teams.find((x) => x.slug === slug); | |
| 113 | if (t && t.dial > 0) return { share: t.dial, labelled: true }; | |
| 114 | return { share: Math.max(0, DIAL_MAX - used), labelled: false }; | |
| 115 | } | |
With several zero-dial teams each row says the full rest (e.g. three teams each |
||
| 116 | ||
| 117 | /** | |
| 118 | * The one sentence of a team's share, said alike by the page, terminal and tool. | |
| 119 | * The dial is said once: a labelled team's share is its dial; a zero-dial team | |
| 120 | * shares what the dials leave with all unlabelled work, so the figure is not per team. | |
| 121 | */ | |
| 122 | export function shareSays(teams: readonly Team[], slug: string): string { | |
| 123 | const { share, labelled } = effectiveShare(teams, slug); | |
| 124 | return labelled ? `${share}% of starts` : `dial 0% · shares the ${share}% left, unlabelled`; | |
| 125 | } |
src/http/mcp/tools/teams.ts +9 −1
| @@ -1,4 +1,5 @@ | ||
| 1 | 1 | import { changeTeam, planTeam, readTeams, TEAM_SAYS } from "../../../actions/teams.ts"; |
| 2 | import { effectiveShare, shareSays } from "../../../core/teams.ts"; | |
| 2 | 3 | import { scopeAllows } from "../../../core/tokens.ts"; |
| 3 | 4 | import { good, bad, type Tool } from "../shared.ts"; |
| 4 | 5 | |
| @@ -23,7 +24,14 @@ export const tool: Tool = { | ||
| 23 | 24 | const read = readTeams(ctx.app, user); |
| 24 | 25 | if (!read.ok) return bad("not_found", "no such tool here"); |
| 25 | 26 | const slug = args["slug"]; |
| 26 | if (slug === undefined) return good({ teams: read.value.teams }); | |
| 27 | if (slug === undefined) | |
| 28 | return good({ | |
| 29 | teams: read.value.teams.map((t) => ({ | |
| 30 | ...t, | |
| 31 | ...effectiveShare(read.value.teams, t.slug), | |
| 32 | shareSays: shareSays(read.value.teams, t.slug), | |
| 33 | })), | |
| 34 | }); | |
| 27 | 35 | const team = typeof slug === "string" ? read.value.teams.find((t) => t.slug === slug) : undefined; |
| 28 | 36 | if (!team) return bad("not_found", `no team ${String(slug)}`); |
| 29 | 37 | const { charter, dial, members } = args; |
src/tui/screens/teams.ts +2 −1
| @@ -7,6 +7,7 @@ | ||
| 7 | 7 | * nothing and sets nothing. |
| 8 | 8 | */ |
| 9 | 9 | |
| 10 | import { shareSays } from "../../core/teams.ts"; | |
| 10 | 11 | import { changeTeam, readTeamQueue, readTeams, teamChanges, TEAM_SAYS } from "../../actions/teams.ts"; |
| 11 | 12 | import type { Ctx, Screen } from "../app/app.ts"; |
| 12 | 13 | import { binding } from "../app/keys.ts"; |
| @@ -69,7 +70,7 @@ export function teamsScreen(f: Session, ctx: Ctx): Screen { | ||
| 69 | 70 | const names = new Map(r.value.agents.map((a) => [a.user.id, a.user.username])); |
| 70 | 71 | return r.value.teams.map((t) => ({ |
| 71 | 72 | title: t.name, |
| 72 | secondary: `${t.dial}%`, | |
| 73 | secondary: shareSays(r.value.teams, t.slug), | |
| 73 | 74 | meta: t.members.map((id) => names.get(id) ?? id).join(", ") || "no members", |
| 74 | 75 | })); |
| 75 | 76 | }; |
src/web/pages/teams.ts +2 −2
| @@ -7,7 +7,7 @@ | ||
| 7 | 7 | |
| 8 | 8 | import { changeTeam, readTeamQueue, readTeams, teamChanges, TEAM_SAYS } from "../../actions/teams.ts"; |
| 9 | 9 | import type { Agent } from "../../core/agents.ts"; |
| 10 | import { CHARTER_MAX, DIAL_MAX, type Team } from "../../core/teams.ts"; | |
| 10 | import { CHARTER_MAX, DIAL_MAX, shareSays, type Team } from "../../core/teams.ts"; | |
| 11 | 11 | import type { QueuedPull } from "../../core/team_queue.ts"; |
| 12 | 12 | import { timeAgo } from "../ui.ts"; |
| 13 | 13 | import type { Ctx } from "../../http/context.ts"; |
| @@ -45,7 +45,7 @@ function regions(ctx: Ctx, timed = false): Record<string, string> | undefined { | ||
| 45 | 45 | href: `/settings/teams/${t.slug}`, |
| 46 | 46 | lead: icon("bot"), |
| 47 | 47 | title: t.name, |
| 48 | meta: html`${String(t.dial)}% · ${String(t.members.length)} ${t.members.length === 1 ? "member" : "members"} · ${String(waiting)} waiting`, | |
| 48 | meta: html`${shareSays(teams, t.slug)} · ${String(t.members.length)} ${t.members.length === 1 ? "member" : "members"} · ${String(waiting)} waiting`, | |
outdated
Principle 1 (nothing explains itself twice): |
||
| 49 | 49 | }); |
| 50 | 50 | }); |
| 51 | 51 | const out: Record<string, Html> = { |
Wrong: the code (effectiveShare) returns the dial itself when above zero, so two teams at 50 read 50% each, but 30 beside 10 reads 30% and 10%, not 75% and 25%. There is no normalising, and OPERATING.md says dials may not pass 100. Rewrite to match: the share is the dial; a zero-dial team shows the rest the dials leave, as unlabelled.