Skip to content
Myr

annotations.ts

This file

Path

packages/protocol/src/annotations.ts

75 lines · 2.7 KiB · TypeScript

Last changed by

Merge build/516-cli-ask-positional-and-local-ratchets: every CLI command names the ask the same way, and check counts ratchets before the pushoscabrielbefore adoption8780e97

History of this file

Take it

The walk stopped after 200 commits: lines older than 878da37 point at it.

Merge build/420-release-downloads: the CLI installs from the platform itself, with no GitHub in the release pathoscabrielbefore adoption878da37

lines 1–53why, one step back
1import { Context, Schema } from "effect";
23/**4 * What every contract says about itself, beside its schemas. Each is set with5 * `.annotate(Key, value)` on `Rpc.make(…)` and read with `Context.get`; a6 * contract that sets none gets the defaults below.7 */89/** What a contract does, in one sentence, for every surface that lists it. */10export const Description = Context.Reference<string>("protocol/Description", {11 defaultValue: () => "",12});1314/**15 * Who may call it: anyone, a signed-in person, or one of the project's16 * deciders. The handler checks `decider`; the annotation documents it.17 */18export const Audience = Context.Reference<"public" | "signedIn" | "decider">(19 "protocol/Audience",20 { defaultValue: () => "signedIn" }21);2223/** Whether its response may be shown to anyone, or only to maintainers. */24export const Visibility = Context.Reference<"public" | "maintainers">(25 "protocol/Visibility",26 { defaultValue: () => "public" }27);2829/** It only reads: it changes nothing. */30export const ReadOnly = Context.Reference<boolean>("protocol/ReadOnly", {31 defaultValue: () => false,32});3334/** Calling it again with the same payload changes nothing more. */35export const Idempotent = Context.Reference<boolean>("protocol/Idempotent", {36 defaultValue: () => false,37});3839/**40 * It can destroy something a person cannot get back. Set it on every41 * contract: every tool carries this value, so a destructive contract that42 * forgot it would tell an agent it is safe (`annotations.test.ts` holds this).43 */44export const Destructive = Context.Reference<boolean>("protocol/Destructive", {45 defaultValue: () => false,46});4748/** A person approves it before it runs: the CLI asks for `--yes`. */49export const NeedsApproval = Context.Reference<boolean>(50 "protocol/NeedsApproval",51 { defaultValue: () => false }52);53

Merge build/516-cli-ask-positional-and-local-ratchets: every CLI command names the ask the same way, and check counts ratchets before the pushoscabrielbefore adoption8780e97

lines 54–59why, one step back
54/**
55 * The CLI command it becomes: its name, the payload fields taken in order,56 * and those of them that were flags until now (`formerFlags`): each still57 * parses as a flag of its own name, hidden from help, so a script that types58 * it keeps working for a release. Drop a name from `formerFlags` to end that.59 */

Merge build/420-release-downloads: the CLI installs from the platform itself, with no GitHub in the release pathoscabrielbefore adoption878da37

lines 60–62why, one step back
60export const Cli = Context.Reference<{
61 readonly name?: string;62 readonly positional?: readonly string[];

Merge build/516-cli-ask-positional-and-local-ratchets: every CLI command names the ask the same way, and check counts ratchets before the pushoscabrielbefore adoption8780e97

line 63why, one step back
63 readonly formerFlags?: readonly string[];

Merge build/420-release-downloads: the CLI installs from the platform itself, with no GitHub in the release pathoscabrielbefore adoption878da37

lines 64–75why, one step back
64}>("protocol/Cli", { defaultValue: () => ({}) });
6566/** Every surface a contract can be served on. */67export const SurfaceName = Schema.Literals(["rpc", "mcp", "cli", "web"]);6869export type SurfaceName = typeof SurfaceName.Type;7071/** The surfaces it is served on; every one by default. */72export const Surfaces = Context.Reference<readonly SurfaceName[]>(73 "protocol/Surfaces",74 { defaultValue: () => SurfaceName.literals }75);