The ultimate harness for coding agents and beyond. All your agents. All your machines. One command center. Start with code, then follow your curiosity and build across disciplines: CAD, circuits, robots, games and music.
New Project can create a new GitHub repository (task #1788) Plan
Worked by the Engineer, test first (superpowers test-driven-development): each task's failing test is committed and seen red before the code that passes it. Tasks 1 to 6 are the backend (this pull request). Tasks 7 and 8 are the phone and Desktop. They share no files with the backend and only the contract in Task 6, so they can run in parallel on machines with Flutter.
Goal: New Project offers "New repository": the person names it, it is created private in an organization the Swarm uses, through their own GitHub sign-in, and the project's Product Manager starts in it.
Architecture: The backend creates the repository in the existing app sign-in callback, with the person's short-lived
user token, and never with an installation token. The outcome is written on the project in the Swarm state
(repositoryCreation), so the apps learn it from the state they already sync. On created, the app sends today's
lead.start with the new address. Installation tokens are pinned so they can never ask for creation permissions.
Tech Stack: TypeScript backend (Fastify, Prisma/MongoDB, vitest, mongodb-memory-server integration). Flutter
phone (mobile/) and Desktop (desktop/).
Spec: docs/plans/2026-11-05-new-repository-design.md
Global Constraints
- Administration is never requested. Installation tokens never carry
repository_creationorinstallation_repositories. - The user token is used for at most four calls and revoked in
finally. It is never stored or logged. - People only: an agent is refused (
HUMAN_REQUIRED). Only the project's owner starts it, and only while the project has no repository address. - Created with
{ name, private, auto_init: true }. Private by default. - Name rule:
^[A-Za-z0-9._-]{1,100}$, and not.or... Owner rule:^[A-Za-z0-9](?:[A-Za-z0-9-]{0,38})$. - Organizations only in v1 (
/orgs/{owner}/installation). - Harness never deletes a repository it created.
- Copy follows the design's failure table (F1 to F12) word for word.
- Swarm code stays out of
cli/src/core.
Review Focus
- A late or replayed callback (second tab, back button) must not overwrite a newer attempt, or create twice: the outcome
is written only over the matching waiting request (same
byandat). Task 5 tests it. - A create state must never pass as an approval state, nor the reverse. Task 4 tests both.
- Name taken by a repository the same person just made through Harness (lost answer) reads as created, not F2. One made by anyone else, or long ago, reads as F2. Task 4 tests it.
- The token is revoked even when GitHub throws mid-way. Task 3 tests a throwing callback.
- Owner names with mixed case (
Autonomous-AIvsautonomous-ai) compare without case. Tasks 2 and 4 test it.
Task 1: Installation tokens can never carry creation permissions
Files: Modify backend/src/github/app.ts (mint). Test backend/src/github/app.test.ts.
Interfaces: Produces export const NEVER_ON_INSTALLATION_TOKENS = ['administration', 'repository_creation', 'installation_repositories'] as const.
- Test
installation tokens never ask for administration or repository creation: for every exported*_PERMISSIONSconstant andGRANTED_TOKEN_PERMISSIONS, no key is inNEVER_ON_INSTALLATION_TOKENS. AndcreateToken(id, repo, { repository_creation: 'write' })rejects with codeGITHUB_APP_PERMISSIONS_FORBIDDEN, with no call to/access_tokensmade (fake GitHubcalls). - Run
npx vitest run src/github/app.test.ts, which fails on the missing export. - In
mint, throwGitHubAppError('GITHUB_APP_PERMISSIONS_FORBIDDEN', …, 500)before calling GitHub when any asked permission is in the list. Then run it green and commit.
Task 2: What an organization allows (ownerReadiness)
Files: Modify backend/src/github/app.ts, backend/src/github/fakeGitHub.ts (nothing new; it already has owners
and grants). Test backend/src/github/app.test.ts.
Interfaces: Produces GitHubApp.ownerReadiness(owner: string): Promise<OwnerReadiness>, where
type OwnerReadiness = { state: 'ready'; installation: number; canAdd: boolean } | { state: 'not-installed'; installUrl: string | null } | { state: 'not-accepted' }.
- Test
says whether an organization lets Harness create repositories:- no
/orgs/{owner}/installationgivesnot-installedwithinstallUrlhttps://github.com/apps/harness-fixture/installations/new; - installed, with grants lacking
repository_creation: 'write', givesnot-accepted; - with it gives
readyandcanAdd: false; - also with
installation_repositories: 'write'givescanAdd: true; Exampleandexampleread the same installation, asked once within ten minutes.
- no
- Run it red. Then implement with
/orgs/{owner}/installationonly (users are v1 not-installed), the privategranted()read, and an owner cache ofINSTALLATION_TTL_MS(NOT_INSTALLED_TTL_MSfor a missing one). Run it green and commit.
Task 3: Run a callback's user token, then revoke it (withUserToken)
Files: Modify backend/src/github/approvals.ts. Test backend/src/github/approvals.test.ts.
Interfaces: Produces type UserCall = (method: string, path: string, body?: unknown) => Promise<{ status: number; body: Record<string, unknown> }>,
and GitHubSignIn.withUserToken<T>(code: string, use: (call: UserCall) => Promise<T>): Promise<T | null>. Null when
GitHub refuses the code. permission() is rebuilt on it, with unchanged behaviour.
- Test
revokes the person's token after use, even when the use throws:withUserToken('c', async () => { throw new Error('x') })rejects withx, and the last call isDELETE /applications/Iv23client/token. A refused code givesnull, with no API call. The existingpermissiontests still pass. - Run it red, implement, run
src/github/approvals.test.tsgreen, and commit.
Task 4: Create the repository (repositoryCreate.ts)
Files: Create backend/src/github/repositoryCreate.ts. Test backend/src/github/repositoryCreate.test.ts.
Interfaces:
- Consumes
UserCall(Task 3),GitHubApp.ownerReadinessandGitHubApp.installation(Task 2),stateSecretandSTATE_TTL_MS. - Produces:
repositoryNameProblem(name: string): string | null(F1 copy, or null);interface CreateRequest { userId; autonomousEnv; tabId; projectId; owner; name; private: boolean; at: number };signCreateState(secret, request, now): stringandreadCreateState(secret, state, now): CreateRequest | null(body carrieskind: 'create');type CreateOutcome = { state: 'created'; repository: string; repositoryUrl: string; login: string; reachable: boolean } | { state: 'taken' } | { state: 'refused'; reason: string } | { state: 'failed' };createRepository(call: UserCall, app: GitHubApp, request: CreateRequest): Promise<CreateOutcome>.
- Tests, each with a scripted
UserCallfake:names follow GitHub's rule:notes-app,a.b_cpass;'',.,..,a b, 101 characters fail.a create state is not an approval state, nor the reverse:readStateof a create state is null, andreadCreateStateof an approval state is null. The same expiry and forgery rules apply as forreadState.creates it private with a first commit, as the person: POST/orgs/acme/reposgets body{ name: 'notes', private: true, auto_init: true }. The result iscreated, withrepositoryUrlhttps://github.com/acme/notes, andreachable: truewhenapp.installationfinds it.adds it to the installation only where that is granted: not covered withcanAdd: PUT/user/installations/91/repositories/{id}, thenreachable: true. Not covered withoutcanAdd: no PUT, andreachable: false(F7).a name taken by someone else is taken; the same person's create since the request is created: on 422 "name already exists", GET/repos/acme/noteswithpermissions.adminandcreated_at≥request.atgivescreated. Otherwisetaken.GitHub's refusal is said in its words: 403{ message: 'You need admin access…' }givesrefusedwith that message cut to 300 characters. A 5xx or a throw givesfailed.
- Run them red, implement, run them green, and commit.
Task 5: The project's repositoryCreation in the Swarm state
Files: Modify backend/src/superTabs/projects.ts (type), backend/src/superTabs/store.ts. Test:
backend/integration/superTabGithub.test.ts (the store needs MongoDB).
Interfaces: Produces:
interface RepositoryCreation { owner: string; name: string; private: boolean; by: string; at: number; state: 'waiting' | 'created' | 'taken' | 'refused' | 'failed' | 'cancelled'; repositoryUrl?: string; reachable?: boolean; reason?: string }onSwarmProject.repositoryCreation?;store.startRepositoryCreation(user, tabId, projectId, ask: { owner; name; private }, at: number): Promise<void>. It refuses an agent (HUMAN_REQUIRED), a non-owner (PROJECT_OWNER_REQUIRED), and a project with an address (PROJECT_REPOSITORY_SET);store.finishRepositoryCreation(tabId, projectId, by: string, at: number, outcome: Omit<RepositoryCreation, 'owner' | 'name' | 'private' | 'by' | 'at'>): Promise<'recorded' | 'stale' | 'gone'>. It movesgithubRevision.- Tests (in the route suite, Task 6):
waitingthencreatedshows on the project. A finish for an olderatisstaleand changes nothing. A deleted project isgone. - Red, implement, green, commit (with Task 6's suite).
Task 6: Routes (the contract the apps use)
Files: Modify backend/src/routes/superTabs.ts. Test backend/integration/superTabGithub.test.ts.
Contract:
GET /api/super-tabs/:tabId/github/owners/:owner(a person who reads the Swarm) gives{ state: 'ready' | 'not-installed' | 'not-accepted' | 'not-configured', installUrl?: string }.not-configuredmeans the server has no app or no sign-in (F6: hide the choice).POST /api/super-tabs/:tabId/projects/:projectId/github/repositorywith body{ owner, name, private }gives{ authorizeUrl, at }. The errors areREPOSITORY_NAME(400, F1 copy),GITHUB_APP_NOT_INSTALLED(409, withinstallUrl, F4),GITHUB_APP_PERMISSIONS(409, F5),GITHUB_APP_NOT_CONFIGURED/GITHUB_APPROVAL_NOT_CONFIGURED(503), and the store's refusals.GET /api/github/callbackreads a create state first. Its pages are:- created: "owner/name is ready. Go back to Harness.";
- taken: F2;
- refused: F3;
- cancelled or expired: F8;
- failed: F9;
- project gone: F11.
On created it also approves the repository for the project (
approvals.approve, scopeproject).Tests, with the stub sign-in exposing
withUserTokenover the fake GitHub, which gainsPOST /orgs/:org/repos,GET /repos/:o/:nfor user tokens andPUT /user/installations/:id/repositories/:rid:the owner creates a new repository for their new project and its PM can start in it: POST, then callback, then the project'srepositoryCreationiscreatedwith the URL, the approval is recorded, andlead.startwith that URL succeeds;another member, an agent, or a project with a repository can't start it;each organization state is said before sign-in(F4, F5, F6);cancel, a taken name and GitHub's refusal come back to the app(F8, F2, F3 asrepositoryCreationstates);a second callback for an older request changes nothing(Review Focus 1).
Red, implement, run
npx vitest run --config vitest.super-tabs.config.ts integration/superTabGithub.test.tsgreen, updatedocs/swarm-github-app.md(permission row, the two endpoints, the callback's create pages), and commit.
Task 7: Phone (mobile/, on a machine with Flutter: Tony's Mac per Routing)
Files: mobile/lib/swarm/swarm_new_project_sheet.dart, a new mobile/lib/swarm/swarm_new_repository.dart (the
subpage and its state), mobile/lib/swarm/model.dart (parse repositoryCreation). Tests:
mobile/test/swarm/swarm_new_project_test.dart, swarm_new_project_shots_test.dart.
Consumes: Task 6's contract. The outcome is on the project row as repositoryCreation.
- Tests first:
- the Repository subpage lists "New repository" above "Enter a link" only when the owner check is not
not-configured, and a 404 hides it; - the subpage's owner list is the distinct GitHub owners of
swarmProjectRepositories, most recent first, the first chosen; - Private is on by default;
- F1 copy shows while typing, and "Use this name" stays off;
- F4 and F5 copy shows after the owner check, with Copy message;
- Create sends
project.create, thenmessage.send, then the POST, opensauthorizeUrlin the system browser, and shows "Creating owner/name…" with Check again; - on
repositoryCreation.state == 'created'with thisat, it sendslead.startwithrepositoryUrl, thenproject.renameto the name; taken,refused,failedandcancelledshow F2, F3, F9 and F8 with Try again;reachable: falsestill starts the PM and shows the F7 line;- light and dark shots of the subpage and the sheet.
- the Repository subpage lists "New repository" above "Enter a link" only when the owner check is not
- Implement to the design's phone mockups, run those test files green, and commit.
Task 8: Desktop (desktop/, on a Mac with Flutter)
Files: desktop/lib/state/new_harness.dart (a "New Repository" row and its prompt state),
desktop/lib/widgets/new_harness_form.dart (prompt UI and chip), desktop/lib/super_tabs/launch.dart (the create
flow), desktop/lib/super_tabs/model.dart (parse repositoryCreation). Tests: desktop/test/new_harness_form_test.dart,
desktop/test/new_agent_rows_and_task_test.dart.
- The same tests as Task 7, Desktop-shaped:
- the "New Repository" / "Create one on GitHub" row in Choose repo, for a new project only;
- the prompt with Owner, Name and Private on;
- the chip "owner/name · new";
- the button reads "Continue in GitHub";
- the note "Creates owner/name on GitHub, then clones it on ";
- the same outcome handling, opening the browser through the existing link launcher (no console window on Windows);
- light and dark shots.
- Implement, run those test files green, and commit.