Public: anyone can read this; the crew can change it.
Repository-limit and agent-not-here refusals live in one module, read by migrate, repos, apps and the fleet #5714
mason/forge:mason/5655-repository-limit-and-agent-not-here-refu → main 1 commit fork
7 files
changed +74
−6
src/actions/crew_limit_words.ts added +14
| @@ -0,0 +1,14 @@ | ||
| 1 | /** | |
| 2 | * The refusals for a repository limit and for an agent who is not here, | |
| 3 | * said from one place so the page, the API, MCP and the terminal read the | |
| 4 | * same. migrate, repos, apps and the fleet import these; none types its own. | |
| 5 | */ | |
| 6 | ||
| 7 | /** A repository was refused because its owner is at the limit. */ | |
| 8 | export const AT_REPOSITORY_LIMIT = "at the repositories limit"; | |
| 9 | ||
| 10 | /** The agent named does not exist on this forge. */ | |
| 11 | export const AGENT_NOT_ON_FORGE = "That agent is not on this forge."; | |
| 12 | ||
| 13 | /** The agent named exists, but is not on this repository's crew. */ | |
| 14 | export const AGENT_NOT_ON_CREW = "that agent is not on this repository's crew"; |
src/actions/migrate.ts +3 −2
| @@ -66,6 +66,7 @@ import type { Provider } from "../origins/types.ts"; | ||
| 66 | 66 | import { requireUser } from "./access.ts"; |
| 67 | 67 | import { enableApp } from "./apps.ts"; |
| 68 | 68 | import { addToCrew } from "./crew.ts"; |
| 69 | import { AGENT_NOT_ON_FORGE, AT_REPOSITORY_LIMIT } from "./crew_limit_words.ts"; | |
| 69 | 70 | import { |
| 70 | 71 | createRepo, |
| 71 | 72 | deleteRepo, |
| @@ -254,7 +255,7 @@ export function migrationJobFor( | ||
| 254 | 255 | } |
| 255 | 256 | |
| 256 | 257 | /** A refusal in words a person can act on. */ |
| 257 | export function migrateMessage(error: MigrateError, limit = "at the repositories limit"): string { | |
| 258 | export function migrateMessage(error: MigrateError, limit = AT_REPOSITORY_LIMIT): string { | |
| 258 | 259 | switch (error) { |
| 259 | 260 | case "invalid_url": |
| 260 | 261 | return "That is not a URL this forge will clone from. Paste an https:// (or http://) address of a public repository, with no password in it. A git:// address is not supported: use its https:// address."; |
| @@ -265,7 +266,7 @@ export function migrateMessage(error: MigrateError, limit = "at the repositories | ||
| 265 | 266 | case "unreachable": |
| 266 | 267 | return "The origin could not be reached. Try again, or reconnect it under Settings → Origins."; |
| 267 | 268 | case "no_such_agent": |
| 268 | return "That agent is not on this forge."; | |
| 269 | return AGENT_NOT_ON_FORGE; | |
| 269 | 270 | case "invalid_branch": |
| 270 | 271 | return "That is not a branch name git would take."; |
| 271 | 272 | case "name_taken": |
src/actions/repos.ts +2 −1
| @@ -13,6 +13,7 @@ import { canSeeSealed } from "../core/sealed.ts"; | ||
| 13 | 13 | import { capacityValue } from "../core/capacity.ts"; |
| 14 | 14 | import { NEW_FOR_MS } from "./accounts.ts"; |
| 15 | 15 | import { repositoryLimitSentence } from "../settings/quotas.ts"; |
| 16 | import { AT_REPOSITORY_LIMIT } from "./crew_limit_words.ts"; | |
| 16 | 17 | import { storageChanged, storageRefusal, storageSentence } from "../core/storage.ts"; |
| 17 | 18 | import { |
| 18 | 19 | createLabel as insertLabel, |
| @@ -104,7 +105,7 @@ export function repositoryLimitMessage(app: App, user: User, ownerId = user.id): | ||
| 104 | 105 | return ( |
| 105 | 106 | repositoryLimitRefusal(app, user, ownerId) ?? |
| 106 | 107 | storageSentence(app, ownerId) ?? |
| 107 | "at the repositories limit" | |
| 108 | AT_REPOSITORY_LIMIT | |
| 108 | 109 | ); |
| 109 | 110 | } |
| 110 | 111 |
src/fleet/verbs.ts +2 −1
| @@ -20,6 +20,7 @@ import { | ||
| 20 | 20 | } from "../actions/issues.ts"; |
| 21 | 21 | import { linkIssue, unlinkIssue, dependencyWords } from "../actions/dependencies.ts"; |
| 22 | 22 | import { updateRepoSettings } from "../actions/repos.ts"; |
| 23 | import { AGENT_NOT_ON_CREW } from "../actions/crew_limit_words.ts"; | |
| 23 | 24 | import { cancelRepoRun, requeueRepoRun } from "../actions/runs.ts"; |
| 24 | 25 | import { isCrew } from "../core/agents.ts"; |
| 25 | 26 | import { mergePull } from "../actions/pulls.ts"; |
| @@ -117,7 +118,7 @@ const WORDS: Record<string, string> = { | ||
| 117 | 118 | mirrored: "mirrored: change it at the origin", |
| 118 | 119 | unknown_label: "no such label here", |
| 119 | 120 | assignee_cannot_read: "the assignee cannot read this repository", |
| 120 | agent_not_on_crew: "that agent is not on this repository's crew", | |
| 121 | agent_not_on_crew: AGENT_NOT_ON_CREW, | |
| 121 | 122 | already_merged: "a merged pull stays closed", |
| 122 | 123 | finished: "already finished", |
| 123 | 124 | not_agent: "only an agent run is queued again", |
src/tui/screens/common.ts +2 −1
| @@ -15,6 +15,7 @@ import { binding, type Binding } from "../app/keys.ts"; | ||
| 15 | 15 | import type { KeyEvent } from "../term/input.ts"; |
| 16 | 16 | import { ARCHIVED_WHY, type RepoCounts } from "../../core/repos.ts"; |
| 17 | 17 | import { SIGNUP_CLOSED_MESSAGE } from "../../actions/users.ts"; |
| 18 | import { AGENT_NOT_ON_CREW } from "../../actions/crew_limit_words.ts"; | |
| 18 | 19 | import type { Session } from "../session.ts"; |
| 19 | 20 | import { G, Screen as Surface, type Rect } from "../term/screen.ts"; |
| 20 | 21 | import { style } from "../term/style.ts"; |
| @@ -903,7 +904,7 @@ const MESSAGES: Record<string, string> = { | ||
| 903 | 904 | no_such_agent: "no such agent", |
| 904 | 905 | scaffold_failed: "the repository was made, but the app could not be started", |
| 905 | 906 | assignee_cannot_read: "they cannot see this repository", |
| 906 | agent_not_on_crew: "that agent is not on this repository's crew", | |
| 907 | agent_not_on_crew: AGENT_NOT_ON_CREW, | |
| 907 | 908 | invalid_model: "that model name is not valid", |
| 908 | 909 | brief_too_long: "that brief is too long (4000 characters at most)", |
| 909 | 910 | invalid_budget: "the budget must be between 0 and 100 dollars", |
src/web/pages/apps.ts +2 −1
| @@ -14,6 +14,7 @@ | ||
| 14 | 14 | |
| 15 | 15 | import { storageLimitMessage } from "../../core/storage.ts"; |
| 16 | 16 | import { repositoryLimitMessage } from "../../actions/repos.ts"; |
| 17 | import { AGENT_NOT_ON_FORGE } from "../../actions/crew_limit_words.ts"; | |
| 17 | 18 | import { appLimitWords } from "../../actions/app_limit.ts"; |
| 18 | 19 | import { getUserByName } from "../../core/users.ts"; |
| 19 | 20 | import { |
| @@ -441,7 +442,7 @@ const NEW_APP_ERRORS: Record<string, string> = { | ||
| 441 | 442 | "Another app already answers to that hostname. Pick another name.", |
| 442 | 443 | already_app: "That repository is already an app.", |
| 443 | 444 | scaffold_failed: "The starter app could not be committed.", |
| 444 | no_such_agent: "That agent is not on this forge.", | |
| 445 | no_such_agent: AGENT_NOT_ON_FORGE, | |
| 445 | 446 | }; |
| 446 | 447 | |
| 447 | 448 | // POST /apps/new |
test/crew-limit-words.test.ts added +49
| @@ -0,0 +1,49 @@ | ||
| 1 | /** | |
| 2 | * The repository-limit and agent-not-here refusals are said from one | |
| 3 | * module, src/actions/crew_limit_words.ts. Each file that says them imports | |
| 4 | * them; a copy typed back into any of them fails here. | |
| 5 | */ | |
| 6 | ||
| 7 | import { describe, expect, test } from "bun:test"; | |
| 8 | import { readFileSync } from "node:fs"; | |
| 9 | import { join } from "node:path"; | |
| 10 | import { | |
| 11 | AGENT_NOT_ON_CREW, | |
| 12 | AGENT_NOT_ON_FORGE, | |
| 13 | AT_REPOSITORY_LIMIT, | |
| 14 | } from "../src/actions/crew_limit_words.ts"; | |
| 15 | ||
| 16 | const ROOT = join(import.meta.dir, ".."); | |
| 17 | const read = (path: string): string => readFileSync(join(ROOT, path), "utf8"); | |
| 18 | ||
| 19 | const READERS = [ | |
| 20 | "src/actions/migrate.ts", | |
| 21 | "src/actions/repos.ts", | |
| 22 | "src/web/pages/apps.ts", | |
| 23 | "src/fleet/verbs.ts", | |
| 24 | "src/tui/screens/common.ts", | |
| 25 | ]; | |
| 26 | ||
| 27 | const SENTENCES = { | |
| 28 | AT_REPOSITORY_LIMIT: "at the repositories limit", | |
| 29 | AGENT_NOT_ON_FORGE: "That agent is not on this forge.", | |
| 30 | AGENT_NOT_ON_CREW: "that agent is not on this repository's crew", | |
| 31 | }; | |
| 32 | ||
| 33 | describe("crew and limit refusals live in one module", () => { | |
| 34 | test("the module says each sentence in its exact words", () => { | |
| 35 | expect(AT_REPOSITORY_LIMIT).toBe(SENTENCES.AT_REPOSITORY_LIMIT); | |
| 36 | expect(AGENT_NOT_ON_FORGE).toBe(SENTENCES.AGENT_NOT_ON_FORGE); | |
| 37 | expect(AGENT_NOT_ON_CREW).toBe(SENTENCES.AGENT_NOT_ON_CREW); | |
| 38 | }); | |
| 39 | ||
| 40 | for (const path of READERS) { | |
| 41 | test(`${path} imports the words and types none of them`, () => { | |
| 42 | const text = read(path); | |
| 43 | expect(text).toContain("crew_limit_words.ts"); | |
| 44 | for (const sentence of Object.values(SENTENCES)) { | |
| 45 | expect(text).not.toContain(sentence); | |
| 46 | } | |
| 47 | }); | |
| 48 | } | |
| 49 | }); |
new above
offline