Skip to content
Myr

Sign in and read on the platform itself when nothing names another: login's --url, the variable and the profile still win in that order, the anonymous client calls the platform rather than refusing, Brand names the platform's host once, and the install script, the docs, the Install page, the platform's home and the AGENTS.md block say a bare login

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by oscabriel · committed by oscabriel · parent 2ee8d82 · Browse files · 20 files+143 added−109 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

20 files+143 added−109 removed

  • tests:+93 added−24 removed
  • other:+50 added−85 removed

20 files+143 added−109 removed

modified:apps/cli/src/local/login.ts+14 added-13 removed
215 unmodified lines
216 onSome: ({ origin }) => Effect.succeed(origin),217 }218 );219220/** `Credentials` reads back only the current profile, so another profile needs `--url`. */220/**221 * The flag, then the variable, then the current profile's platform, then the222 * platform itself. `Credentials` reads back only the current profile, so223 * another profile with no flag signs in to the platform itself.224 */225const platformOf = (226 flag: Option.Option<string>,227 profile: Option.Option<string>,228 env: Readonly<Record<string, string>>
6 unmodified lines
235 if (Option.isSome(named)) {236 return yield* originOf(named.value);237 }238235 const name = profileName(profile, env);236239 const current =238 name === profileName(Option.none(), env)240 profileName(profile, env) === profileName(Option.none(), env)241 ? yield* (yield* Credentials).current242 : Option.none<Profile>();243242 if (Option.isSome(current)) {243 return yield* originOf(current.value.url);244 }245246 return yield* new LoginUsage({247 reason: `no platform to log in to for profile ${name}: run ${Brand.cli} login --url https://git.${Brand.domain}${Option.isSome(profile) ? ` --profile ${name}` : ""}`,248 });244 return yield* originOf(245 Option.match(current, {246 onNone: () => Brand.platformUrl,247 onSome: ({ url }) => url,248 })249 );250 });251252const tokenFromStdin = Effect.gen(function* () {253 const { stdin } = yield* Stdio.Stdio;
255 unmodified lines
509 )510 ),511 url: Flag.String("url").pipe(512 Flag.withDescription(512 `The platform's origin, e.g. https://<host> (default: $${SLUG}_URL, else the profile's)`513 `The platform's origin, e.g. https://<host> (default: $${SLUG}_URL, else the profile's, else ${Brand.platformUrl})`514 ),515 Flag.optional516 ),517 },
45 unmodified lines
563 });564 })565).pipe(566 Command.withDescription(566 "Sign in to a platform; git and this CLI then use its token."567 "Sign in (to the platform itself unless --url names another); git and this CLI then use its token."568 )569);570571/** Exit 5 means the line is already gone. */
85 unmodified lines
modified:apps/cli/src/main.ts+1 added-4 removed
modified:apps/cli/src/remote.ts+5 added-53 removed
26 unmodified lines
27import { Credentials } from "./credentials.ts";2829const URL_VARIABLE = `${Brand.slug.toUpperCase()}_URL`;3031export class NoPlatform extends Schema.TaggedError<NoPlatform>()("NoPlatform", {32 variable: Schema.String,33}) {34 override get message() {35 return `no platform to call: run ${Brand.cli} login, or set ${this.variable} to call one as anyone`;36 }37}3831const isClientError = Schema.is(RpcClientError.RpcClientError);3241const isDefect = Schema.is(RpcClientError.RpcClientDefect);4243const isNoPlatformError = Schema.is(NoPlatform);4433const isHttpFailure = Schema.is(HttpClientError.HttpClientErrorSchema);3435export const isTransportFailure = isClientError;36
4 unmodified lines
41 Predicate.isString(failure.reason.cause.message)42 ? failure.reason.cause.message43 : failure.message;4457export const noPlatformOf = (58 failure: RpcClientError.RpcClientError59): Option.Option<NoPlatform> =>60 isDefect(failure.reason) && isNoPlatformError(failure.reason.cause)61 ? Option.some(failure.reason.cause)62 : Option.none();6345const isUnauthorized = (failure: RpcClientError.RpcClientError) =>46 Predicate.hasProperty(failure.reason, "cause") &&47 failure.reason.cause instanceof HttpClientError.StatusCodeError &&48 failure.reason.cause.response.status === 401;
40 unmodified lines
89 ),90 Layer.provide([FetchHttpClient.layer, RpcSerialization.layerJson])91 );92112const noPlatform = new NoPlatform({ variable: URL_VARIABLE });113114const nowhere = Layer.effect(Client)(RpcClient.make(Contracts)).pipe(115 Layer.provide(116 Layer.effect(RpcClient.Protocol)(117 Effect.flatMap(118 Effect.service(RpcSerialization.RpcSerialization),119 (serialization) =>120 RpcClient.Protocol.make(() =>121 Effect.succeed({122 codecFor: serialization.codecFor,123 send: () =>124 Effect.fail(125 new RpcClientError.RpcClientError({126 reason: new RpcClientError.RpcClientDefect({127 cause: noPlatform,128 message: noPlatform.message,129 }),130 })131 ),132 supportsAck: false,133 supportsTransferables: false,134 })135 )136 )137 )138 ),139 Layer.provide(RpcSerialization.layerJson)140);14193export const RemoteClient: Layer.Layer<Client, never, Credentials> =94 Layer.unwrap(95 Effect.gen(function* () {96 const profile = yield* Effect.flatMap(
8 unmodified lines
105 const url = yield* Config.option(106 Config.NonEmptyString(URL_VARIABLE)107 ).pipe(Effect.orElseSucceed(() => Option.none()));108158 return Option.match(url, {159 onNone: () => nowhere,160 onSome: (origin) => over(origin, Option.none()),161 });109 // With nothing naming a platform, the platform itself, as anyone.110 return over(111 Option.getOrElse(url, () => Brand.platformUrl),112 Option.none()113 );114 })115 );
modified:apps/cli/test/local/login.test.ts+51 added-10 removed
432 unmodified lines
433 30_000434 );435436 it.live(437 "without --url, logs the current profile in again on its platform, but asks for --url for another profile",437 "without --url, logs the current profile in again on its platform, and another profile in on the platform itself",438 () =>439 Effect.gen(function* () {440 const env = yield* home;441 const platform = yield* seams(signedInAs("alice"));
9 unmodified lines
451 );452453 expect({454 again: Exit.isSuccess(again),455 bob: yield* stored(env, "bob"),455 bob: Option.map(yield* stored(env, "bob"), ({ url: at }) => at),456 checked: (yield* platform.connected).map(({ url: at }) => at),457 other: Exit.isSuccess(other),458 }).toStrictEqual({459 again: true,460 bob: Option.none(),461 checked: [url, url],462 other: false,460 bob: Option.some(Brand.platformUrl),461 checked: [url, url, Brand.platformUrl],462 other: true,463 });464 expect((yield* printed).stderr.join("\n")).toContain("--url");464 }).pipe(Effect.scoped, Effect.provide(testServices)),465 30_000466 );467468 it.live(470 "with no --url and no stored profile, asks for --url, naming the platform's own host",469 "with no --url, no variable and no stored profile, signs in to the platform itself",470 () =>471 Effect.gen(function* () {472 const env = yield* home;473 const platform = yield* seams(signedInAs("alice"));
3 unmodified lines
477 seams: platform.layer,478 stdin: `${given}\n`,479 });480482 expect(Exit.isFailure(exit)).toBeTruthy();483 expect((yield* printed).stderr.join("\n")).toContain(484 `${Brand.cli} login --url https://git.${Brand.domain}`481 expect({482 checked: (yield* platform.connected).map(({ url: at }) => at),483 signedIn: Exit.isSuccess(exit),484 stored: Option.map(485 yield* stored(env, "default"),486 ({ url: at }) => at487 ),488 }).toStrictEqual({489 checked: [Brand.platformUrl],490 signedIn: true,491 stored: Option.some(Brand.platformUrl),492 });493 }).pipe(Effect.scoped, Effect.provide(testServices)),494 30_000495 );496497 it.live(498 "takes the platform from --url, then the variable, then the stored profile, then the platform itself",499 () =>500 Effect.gen(function* () {501 const env = yield* home;502 const platform = yield* seams(signedInAs("alice"));503 const fromVariable = "https://variable.test";504 const fromFlag = "https://flag.test";505506 const run = (extra: Record<string, string>) => ({507 env: { ...env, ...extra },508 seams: platform.layer,509 stdin: `${given}\n`,510 });511512 yield* cli(["login", "--token-stdin"], run({}));513 yield* cli(["login", "--url", url, "--token-stdin"], run({}));514 yield* cli(["login", "--token-stdin"], run({}));515 yield* cli(516 ["login", "--token-stdin"],517 run({ [`${SLUG}_URL`]: fromVariable })518 );519 yield* cli(520 ["login", "--url", fromFlag, "--token-stdin"],521 run({ [`${SLUG}_URL`]: fromVariable })522 );523524 expect(525 (yield* platform.connected).map(({ url: at }) => at)526 ).toStrictEqual([Brand.platformUrl, url, url, fromVariable, fromFlag]);527 }).pipe(Effect.scoped, Effect.provide(testServices)),528 30_000529 );530});
286 unmodified lines
modified:apps/cli/test/remote.test.ts+27 added-10 removed
2 unmodified lines
3import { Contracts } from "@repo/protocol/contracts";4import { AskId, Handle, KindName } from "@repo/protocol/ids";5import { unanswered } from "@repo/protocol/testing";6import { ConfigProvider, Effect, Layer, Option, Redacted } from "effect";7import { FetchHttpClient } from "effect/http";89import { Credentials } from "../src/credentials.ts";10import type { Profile } from "../src/credentials.ts";11import { RemoteClient } from "../src/remote.ts";
173 unmodified lines
185 expect(run.err[0]).toContain(`${origin}/rpc`);186 }).pipe(Effect.scoped)187 );188188 it.live("with no profile and no url, is a usage error naming login", () =>189 Effect.gen(function* () {190 const run = yield* runProgram(["asks", "--project", "datekit"], {191 client: remote(holding(Option.none())),192 handlers,193 });189 it.live(190 "with no profile and no url, calls the platform itself, as anyone",191 () =>192 Effect.gen(function* () {193 const sent: (string | null)[] = [];194195 expect(run.code).toBe(2);196 expect(run.err).toHaveLength(1);197 expect(run.err[0]).toContain(`${Brand.cli} login`);198 })195 // The platform itself is never called from a test: the fetch notes196 // where it was sent and answers 503.197 const noted: typeof globalThis.fetch = (input, init) => {198 sent.push(199 new Request(input, init).url,200 new Headers(init?.headers).get("authorization")201 );202203 return Promise.resolve(new Response(null, { status: 503 }));204 };205206 const run = yield* runProgram(["asks", "--project", "datekit"], {207 client: remote(holding(Option.none())).pipe(208 Layer.provide(Layer.succeed(FetchHttpClient.Fetch)(noted))209 ),210 handlers,211 });212213 expect(run.code).toBe(69);214 expect(sent).toStrictEqual([`${Brand.platformUrl}/rpc/`, null]);215 })216 );217});
modified:apps/platform/src/home.ts+2 added-1 removed
1import { commandDocs } from "@repo/agent-kit/command-doc";2import { frontLlms, MCP_PROTOCOL } from "@repo/agent-kit/host-doc";3import { loginCommand } from "@repo/agent-kit/install";4import { Brand } from "@repo/brand";5import { FrontPage } from "@repo/project/front-page";6import type { Projects } from "@repo/project/projects";7import { withStandingPosture } from "@repo/project/standing-posture";
94 unmodified lines
102 section(103 "CLI",104 pre(`curl -fsSL ${origin}/install.sh | sh`),105 `<p>Releases: ${link(`${origin}/releases/manifest.json`)}</p>`,105 `<p>Then sign in: ${code(`${Brand.cli} login --url ${origin}`)}</p>`106 `<p>Then sign in: ${code(loginCommand(origin))}</p>`107 ),108 section(109 "Agents",110 list([
68 unmodified lines
modified:infra/stages.ts+1 added-1 removed
40 unmodified lines
4142export const customHosts = (stage: Stage): Option.Option<Hosts> =>43 stage === "prod"44 ? Option.some({45 platform: `git.${Brand.domain}`,45 platform: Brand.platformHost,46 web: Brand.domain,47 webAliases: [`www.${Brand.domain}`],48 })49 : Option.none();
123 unmodified lines
modified:packages/agent-kit/src/docs/answer-an-ask.ts+2 added-2 removed
1import { Brand } from "@repo/brand";23import { installCommand, pushCommand } from "../install.ts";3import { installCommand, loginCommand, pushCommand } from "../install.ts";4import { code } from "../text.ts";5import type { DocSource } from "./page.ts";6import { cli, shell } from "./page.ts";7
2 unmodified lines
10export const answerAnAsk: DocSource = {11 body: ({ platformUrl, webUrl }) => [12 "## Install the CLI and sign in",13 "",14 ...shell(installCommand(webUrl), `${Brand.cli} login --url ${platformUrl}`),14 ...shell(installCommand(webUrl), loginCommand(platformUrl)),15 "",16 "Signing in stores your token, and git uses it from then on through the CLI's credential helper: no token in a URL, and no prompt.",17 "",18 "## Find an ask",
54 unmodified lines
modified:packages/agent-kit/src/agent-setup.ts+2 added-2 removed
2 unmodified lines
3import { groups } from "@repo/protocol/refusal";4import { Array as Arr, Schema } from "effect";56import type { CommandDoc } from "./command-doc.ts";7import { installCommand } from "./install.ts";7import { installCommand, loginCommand } from "./install.ts";8import { mcpServersFor } from "./platform.ts";9import { span } from "./sections.ts";10import { code, listed, page, printJson, table } from "./text.ts";11
81 unmodified lines
93 {94 label: "Sign in once; git pushes with your token from then on",95 language: "sh",96 name: "Sign in",97 text: `${Brand.cli} login --url ${platformUrl}`,97 text: loginCommand(platformUrl),98 },99 ]100 : [];101
248 unmodified lines
modified:packages/agent-kit/src/agents-block.ts+1 added-1 removed
45 unmodified lines
46 `## Contributing to ${project}`,47 "",48 `This project takes changes through ${Brand.name}: an answer to one of its asks lands only by passing the gate. This block is generated from the config folder, and the gate decides what lands. The full guide is the ${code(contributeSkillName(project))} skill (${code(agentsPath)}).`,49 "",50 `It needs the ${Brand.name} CLI (the install script on the platform's ${code("/install")} page) signed in with ${code(`${Brand.cli} login --url <platform>`)}, and runs in a clone of the project, ${code(`git clone <platform>/${project}.git`)}, where ${code("<platform>")} is the host this project lives on: in such a clone, ${code("git remote get-url origin")} names it.`,50 `It needs the ${Brand.name} CLI (the install script on the platform's ${code("/install")} page) signed in with ${code(`${Brand.cli} login`)} (adding ${code("--url <platform>")} when that is not ${code(Brand.platformHost)}), and runs in a clone of the project, ${code(`git clone <platform>/${project}.git`)}, where ${code("<platform>")} is the host this project lives on: in such a clone, ${code("git remote get-url origin")} names it.`,51 "",52 ...loopSteps(),53 "",54 ...rules(policy),
60 unmodified lines
modified:packages/agent-kit/src/command-doc.ts+2 added-1 removed
36 unmodified lines
37 path: ["login"],38 positional: [],39 readOnly: false,40 source: "local",41 summary: "Sign in to a platform; git and this CLI then use its token.",41 summary:42 "Sign in (to the platform itself unless --url names another); git and this CLI then use its token.",43 },44 {45 flags: ["--profile", "--json"],46 needsApproval: false,
197 unmodified lines
modified:packages/agent-kit/src/host-doc.ts+2 added-2 removed
4 unmodified lines
5import type { Posture } from "@repo/protocol/posture";6import { Array as Arr, Option } from "effect";78import type { CommandDoc } from "./command-doc.ts";9import { installCommand, pushCommand } from "./install.ts";9import { installCommand, loginCommand, pushCommand } from "./install.ts";1011type Command = CommandDoc;1213type Commands = readonly CommandDoc[];
167 unmodified lines
181 onSome: () => [182 "Then sign in once; git pushes to the platform with your token from then on:",183 "",184 "```sh",185 `${Brand.cli} login --url ${platformUrl}`,185 loginCommand(platformUrl),186 "```",187 "",188 ],189 }),
118 unmodified lines
modified:packages/agent-kit/src/install.ts+6 added
1 unmodified line
23export const installCommand = (webUrl: string) =>4 `curl -fsSL ${webUrl}/install.sh | sh`;56/** Signing in: bare on the platform itself, which `login` defaults to; `--url` only for another. */7export const loginCommand = (platformUrl: string) =>8 platformUrl.replace(/\/+$/u, "") === Brand.platformUrl9 ? `${Brand.cli} login`10 : `${Brand.cli} login --url ${platformUrl}`;1112/** How an answer reaches its fork: the remote the claim's step names, then `main`. */13export const pushCommand = `git push ${Brand.slug} HEAD:main`;
modified:packages/agent-kit/test/golden/agents-block.txt+1 added-1 removed
2 unmodified lines
3## Contributing to oscabriel/datekit45This project takes changes through __NAME__: an answer to one of its asks lands only by passing the gate. This block is generated from the config folder, and the gate decides what lands. The full guide is the `datekit-contribute` skill (`.agents/skills/datekit-contribute/SKILL.md`).67It needs the __NAME__ CLI (the install script on the platform's `/install` page) signed in with `__CLI__ login --url <platform>`, and runs in a clone of the project, `git clone <platform>/oscabriel/datekit.git`, where `<platform>` is the host this project lives on: in such a clone, `git remote get-url origin` names it.7It needs the __NAME__ CLI (the install script on the platform's `/install` page) signed in with `__CLI__ login` (adding `--url <platform>` when that is not `git.__SLUG__.technology`), and runs in a clone of the project, `git clone <platform>/oscabriel/datekit.git`, where `<platform>` is the host this project lives on: in such a clone, `git remote get-url origin` names it.891. Read the ask, then claim it: `__CLI__ ask <ask>`, then `__CLI__ claim <ask>`. The claim prints your fork's remote; add it with `git remote add __SLUG__ <remote>`.102. Work inside the ask's territory until its check passes.113. Run `__CLI__ check`. It gives the refusals a push would get, then runs the ask's check and the project's lanes; fix everything it reports.
14 unmodified lines
modified:packages/agent-kit/test/install-channels.test.ts+11 added
63 unmodified lines
64 channels.flatMap(textsOf).filter((each) => /\bnpm install\b/u.test(each))65 ).toStrictEqual([]);66 });6768 it("sign in with a bare login on the platform itself, which login defaults to", () => {69 expect(70 textsOf(71 channel(72 "cli",73 installChannels({ commands, platformUrl: Brand.platformUrl, webUrl })74 )75 )[1]76 ).toBe(`${Brand.cli} login`);77 });7879 it("give Claude Code's settings.json a hook for each event the CLI answers, the edit tools guarded", () => {80 const hooks = channel("cli").snippets.find(({ name }) => name === "Hooks");8182 expect(hooks?.language).toBe("json");
111 unmodified lines
modified:packages/brand/src/index.ts+9 added-1 removed
1const slug = "myr";23const domain = `${slug}.technology`;45// The platform's own host on prod: where the CLI signs in and reads when6// nothing names another platform.7const platformHost = `git.${domain}`;89export const Brand = {10 cli: slug,11 cliPackage: `@${slug}/cli`,12 configDir: `.${slug}`,7 domain: `${slug}.technology`,13 domain,14 gitCredentialHelper: `git-credential-${slug}`,15 gitRemoteHelper: `git-remote-${slug}`,16 githubOrg: `get${slug}`,17 name: "Myr",18 npmScope: `@${slug}`,19 platformHost,20 platformUrl: `https://${platformHost}`,21 refsPrefix: `refs/${slug}/`,22 slug,23 urlScheme: `${slug}://`,24} as const;
modified:packages/config/test/release.test.ts+3 added-3 removed
566 unmodified lines
567 posix: true,568 });569 });570571 it("ends by naming the next step, login on the brand's own platform host", () => {572 expect(script).toContain(`platform='https://git.${Brand.domain}'`);573 expect(script).toContain('echo "next: $name login --url $platform"');571 it("ends by naming the next step, login, which signs in to the platform itself", () => {572 expect(script).toContain('echo "next: $name login"');573 expect(script).not.toContain("--url");574 });575576 const install = (files: Readonly<Record<string, string>>) =>577 Effect.gen(function* () {
169 unmodified lines
modified:scripts/lib/release/install-script.ts+1 added-2 removed
26 unmodified lines
27 `base=${quoted(input.baseUrl)}`,28 `version=${quoted(input.version)}`,29 `slug=${quoted(brand.slug)}`,30 `name=${quoted(brand.cli)}`,31 `platform=${quoted(`https://git.${brand.domain}`)}`,31 `helper=${quoted(brand.gitCredentialHelper)}`,32 `dir="\${${installDir}:-$HOME/.local/bin}"`,33 "",34 "fail() {",
51 unmodified lines
86 'mv -f "$tmp/$asset" "$dir/$name"',87 'ln -sf "$name" "$dir/$helper"',88 "",89 'echo "installed $name $version as $dir/$name, with $helper beside it"',91 'echo "next: $name login --url $platform"',90 'echo "next: $name login"',91 'case ":$PATH:" in',92 ' *":$dir:"*) ;;',93 ' *) echo "add $dir to your PATH to run $name" ;;',94 "esac",
3 unmodified lines
modified:scripts/lib/release/readme.ts+1 added-1 removed
26 unmodified lines
27 "",28 "## Start",29 "",30 ...fence([31 `${brand.cli} login --url <platform>`,31 `${brand.cli} login # sign in; --url <platform> names another platform`,32 `${brand.cli} asks # list the open asks you could take`,33 `${brand.cli} claim <ask> # take one; you get a fork to push your answer to`,34 `${brand.cli} check # run the gate's checks locally before you push`,35 ]),
21 unmodified lines
modified:README.md+1 added-1 removed
48 unmodified lines
49The CLI comes from the platform itself: the web at `https://myr.technology` serves the installer, and `myr login` signs you in to the platform at `https://git.myr.technology` through the browser and sets up git's credential helper, so plain `git clone` and `git push` work:5051```sh52curl -fsSL https://myr.technology/install.sh | sh53myr login --url https://git.myr.technology53myr login54myr asks --project oscabriel/datekit55myr claim <ask> --project oscabriel/datekit56```57
79 unmodified lines