command-doc.ts
This file
Path
packages/agent-kit/src/command-doc.ts
251 lines · 6.6 KiB · TypeScript
Last changed by
History of this fileTake it
The walk stopped after 200 commits: lines older than 7608aca point at it.
Say ask open's summary in one text on the CLI and the command list, naming the config folder by the brand's nameoscabrielbefore adoption6763f53
line 1why, one step back1import { Brand } from "@repo/brand";Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca
lines 2–7why, one step back2import {3 Cli,4 Description,5 NeedsApproval,6 ReadOnly,7 Surfaces,Merge docs/onboarding into main, keeping the Install page without the npm snippet the other branch dropped and naming the install script in the AGENTS.md blockoscabrielbefore adoption59ed81f
line 8why, one step back8 TodayOf,Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca
lines 9–31why, one step back9} from "@repo/protocol/contracts";10import type { Contracts } from "@repo/protocol/contracts";11import { Array as Arr, Context, Order, Schema, SchemaAST } from "effect";1213export const CommandDoc = Schema.Struct({14 contract: Schema.optionalKey(Schema.NonEmptyString),15 flags: Schema.Array(Schema.NonEmptyString),16 needsApproval: Schema.Boolean,17 path: Schema.NonEmptyArray(Schema.NonEmptyString),18 positional: Schema.Array(Schema.NonEmptyString),19 readOnly: Schema.Boolean,20 source: Schema.Literals(["contract", "local"]),21 summary: Schema.NonEmptyString,22});2324export type CommandDoc = typeof CommandDoc.Type;2526export const localCommandDocs: readonly CommandDoc[] = [27 {28 flags: [29 "--url",30 "--profile",31 "--token-stdin",32 "--paste",Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca
lines 33–41why, one step back33 "--no-browser",34 "--no-git-config",35 "--json",36 ],37 needsApproval: false,38 path: ["login"],39 positional: [],40 readOnly: false,41 source: "local",Merge cli/default-platform into mainoscabrielbefore adoptionb9fc54b
lines 42–43why, one step back42 summary:43 "Sign in (to the platform itself unless --url names another); git and this CLI then use its token.",Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca
lines 44–51why, one step back44 },45 {46 flags: ["--profile", "--json"],47 needsApproval: false,48 path: ["logout"],49 positional: [],50 readOnly: false,51 source: "local",Merge docs/onboarding into main, keeping the Install page without the npm snippet the other branch dropped and naming the install script in the AGENTS.md blockoscabrielbefore adoption59ed81f
lines 52–53why, one step back52 summary:53 "Forget a profile's token, and stop git asking for a platform no profile is on.",Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca
lines 54–75why, one step back54 },55 {56 contract: "initProject",57 flags: [58 "--project",59 "--import",60 "--branch",61 "--yes",62 "--dry-run",63 "--push",64 "--no-push",65 "--json",66 ],67 needsApproval: true,68 path: ["init"],69 positional: [],70 readOnly: false,71 source: "local",72 summary:73 "Make this repo, or a public HTTPS repo, a project: find its checks, write its config and push.",74 },75 {Merge cli/init-and-ask-open into mainoscabrielbefore adoption6be06d3
line 76why, one step back76 contract: "openAsk",Merge project/drop-proposals into mainoscabrielbefore adoptionb4ed08b
lines 77–84why, one step back77 flags: [78 "--files",79 "--discussion",80 "--project",81 "--yes",82 "--dry-run",83 "--json",84 ],Merge cli/init-and-ask-open into mainoscabrielbefore adoption6be06d3
lines 85–89why, one step back85 needsApproval: true,86 path: ["ask", "open"],87 positional: ["ask"],88 readOnly: false,89 source: "local",Merge project/drop-proposals into mainoscabrielbefore adoptionb4ed08b
line 90why, one step back90 summary: `Open an ask by landing its file and its check, read from the ask's own file under ${Brand.configDir}/asks/ and the path it names unless --files gives them, once the check fails on main by an assertion, twice in the same way; --discussion names the thread it comes from, and marks it asked.`,Merge cli/init-and-ask-open into mainoscabrielbefore adoption6be06d3
lines 91–92why, one step back91 },92 {Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca
lines 93–167why, one step back93 flags: [94 "--ask",95 "--project",96 "--base",97 "--offline",98 "--shape-only",99 "--lane",100 "--dir",101 "--json",102 ],103 needsApproval: false,104 path: ["check"],105 positional: [],106 readOnly: true,107 source: "local",108 summary: "Run the gate's checks on your answer locally, before you push.",109 },110 {111 contract: "landing",112 flags: ["--project", "--json"],113 needsApproval: false,114 path: ["why"],115 positional: ["location"],116 readOnly: true,117 source: "local",118 summary:119 "Explain a line: the ask, the answer and the people that landed it.",120 },121 {122 contract: "setEnv",123 flags: ["--project", "--acknowledge-short", "--yes", "--dry-run", "--json"],124 needsApproval: true,125 path: ["env", "set"],126 positional: ["key"],127 readOnly: false,128 source: "local",129 summary:130 "Set a sensitive env item's value from stdin; nobody can read it back.",131 },132 {133 flags: ["--json"],134 needsApproval: false,135 path: ["hook"],136 positional: ["event"],137 readOnly: true,138 source: "local",139 summary:140 "Answer a harness hook (session-start, pre-tool-use, stop) with the gate's policy.",141 },142 {143 flags: [],144 needsApproval: false,145 path: ["credential"],146 positional: ["operation"],147 readOnly: false,148 source: "local",149 summary:150 "Be git's credential helper: hand git the stored token for a platform.",151 },152 {153 flags: [],154 needsApproval: false,155 path: ["mcp"],156 positional: [],157 readOnly: false,158 source: "local",159 summary: "Serve the platform's tools over MCP on stdio.",160 },161 {162 flags: ["--json"],163 needsApproval: false,164 path: ["schema"],165 positional: ["command"],166 readOnly: true,167 source: "local",Merge docs/onboarding into main, keeping the Install page without the npm snippet the other branch dropped and naming the install script in the AGENTS.md blockoscabrielbefore adoption59ed81f
line 168why, one step back168 summary: "Print the JSON Schema of the payload a command sends.",Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca
lines 169–177why, one step back169 },170 {171 contract: "today",172 flags: ["--project", "--tui", "--json"],173 needsApproval: false,174 path: ["today"],175 positional: [],176 readOnly: true,177 source: "local",Merge docs/onboarding into main, keeping the Install page without the npm snippet the other branch dropped and naming the install script in the AGENTS.md blockoscabrielbefore adoption59ed81f
line 178why, one step back178 summary: `${Context.get(TodayOf.annotations, Description)} It only reads, unless --tui opens it full-screen to take decisions at a terminal.`,Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca
lines 179–192why, one step back179 },180];181182const standIns = new Set(183 localCommandDocs.flatMap(({ contract, path }) =>184 contract === undefined ? [] : [path.join(" ")]185 )186);187188const fieldsOf = (ast: SchemaAST.AST) =>189 SchemaAST.isObjects(ast)190 ? ast.propertySignatures.map(({ name }) => String(name))191 : [];192Merge project/discussions into mainoscabrielbefore adoption29b0353
lines 193–199why, one step back193const requiredFieldsOf = (ast: SchemaAST.AST) =>194 SchemaAST.isObjects(ast)195 ? ast.propertySignatures.flatMap(({ name, type }) =>196 type.context?.isOptional === true ? [] : [String(name)]197 )198 : [];199Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca
lines 200–217why, one step back200export const contractCommandDocs = (201 group: typeof Contracts202): readonly CommandDoc[] =>203 [...group.requests.values()].flatMap((rpc) => {204 const { annotations } = rpc;205 const cli = Context.get(annotations, Cli);206 const name = cli.name ?? rpc._tag;207 const [first, ...rest] = name.split(" ");208209 if (210 first === undefined ||211 !Context.get(annotations, Surfaces).includes("cli") ||212 standIns.has(name)213 ) {214 return [];215 }216217 const positional = cli.positional ?? [];Merge project/discussions into mainoscabrielbefore adoption29b0353
line 218why, one step back218 const required = requiredFieldsOf(rpc.payloadSchema.ast);Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca
lines 219–236why, one step back219 const readOnly = Context.get(annotations, ReadOnly);220 const needsApproval = Context.get(annotations, NeedsApproval);221222 const flags = fieldsOf(rpc.payloadSchema.ast)223 .filter((field) => !positional.includes(field))224 .map((field) => `--${field}`);225226 return [227 {228 contract: rpc._tag,229 flags: [230 ...flags,231 "--json",232 ...(needsApproval ? ["--yes"] : []),233 ...(readOnly ? [] : ["--dry-run"]),234 ],235 needsApproval,236 path: [first, ...rest],Merge project/discussions into mainoscabrielbefore adoption29b0353
lines 237–238why, one step back237 // An optional positional (a reply's discussion) is taken, not required, so the row leaves it out.238 positional: positional.filter((field) => required.includes(field)),Merge branch 'build/903-code-reads'oscabrielbefore adoption7608aca
lines 239–251why, one step back239 readOnly,240 source: "contract",241 summary: Context.get(annotations, Description),242 },243 ];244 });245246const byWords = Order.mapInput(Order.String, (doc: CommandDoc) =>247 doc.path.join(" ")248);249250export const commandDocs = (group: typeof Contracts): readonly CommandDoc[] =>251 Arr.sort([...contractCommandDocs(group), ...localCommandDocs], byWords);