UNPKG

@phren/cli

Version:

Knowledge layer for AI agents - CLI, MCP server, and data layer

102 lines (101 loc) • 4.45 kB
import { z } from "zod"; import { type Issue, type IssueEdit, type IssueList, type IssueQuery, type IssueRef, type NewIssue, type RepoRef } from "../forge/issues.js"; import { type Json } from "./protocol.js"; /** * The phone's forge issue routes (docs/phren-hook.md#issues-from-the-phone): * a list and an item read, and the five writes. Every route is owner-only; the * writes also go through owner-proof.ts. All forge work lives in ../forge/. */ /** A list body is trimmed to this many characters; /v1/issues/item has the whole body. */ export declare const LIST_BODY_LIMIT = 2000; /** The phone drops off Tailscale on big bursts, so one list answer stays under this. */ export declare const ISSUES_RESPONSE_LIMIT: number; export declare const issueListQuerySchema: z.ZodObject<{ repos: z.ZodOptional<z.ZodArray<z.ZodString>>; state: z.ZodOptional<z.ZodEnum<{ all: "all"; closed: "closed"; open: "open"; }>>; assignee: z.ZodOptional<z.ZodString>; label: z.ZodOptional<z.ZodString>; search: z.ZodOptional<z.ZodString>; limit: z.ZodOptional<z.ZodNumber>; }, z.core.$strict>; export declare const issueItemQuerySchema: z.ZodObject<{ repo: z.ZodString; number: z.ZodNumber; }, z.core.$strict>; /** The bodies mirror the MCP issue tools (../forge/issues.ts types). */ export declare const issueCreateSchema: z.ZodObject<{ repo: z.ZodString; title: z.ZodString; body: z.ZodOptional<z.ZodString>; checklist: z.ZodOptional<z.ZodArray<z.ZodString>>; labels: z.ZodOptional<z.ZodArray<z.ZodString>>; }, z.core.$strict>; export declare const issueEditSchema: z.ZodObject<{ repo: z.ZodString; number: z.ZodNumber; title: z.ZodOptional<z.ZodString>; body: z.ZodOptional<z.ZodString>; checklist: z.ZodOptional<z.ZodArray<z.ZodObject<{ text: z.ZodString; done: z.ZodBoolean; }, z.core.$strict>>>; addLabels: z.ZodOptional<z.ZodArray<z.ZodString>>; removeLabels: z.ZodOptional<z.ZodArray<z.ZodString>>; state: z.ZodOptional<z.ZodEnum<{ closed: "closed"; open: "open"; }>>; }, z.core.$strict>; export declare const issueCommentSchema: z.ZodObject<{ repo: z.ZodString; number: z.ZodNumber; body: z.ZodString; }, z.core.$strict>; /** `computer` defaults to the Hook's own computer name. */ export declare const issueClaimSchema: z.ZodObject<{ repo: z.ZodString; number: z.ZodNumber; computer: z.ZodOptional<z.ZodString>; release: z.ZodOptional<z.ZodBoolean>; }, z.core.$strict>; export declare const issueCloseSchema: z.ZodObject<{ repo: z.ZodString; number: z.ZodNumber; comment: z.ZodOptional<z.ZodString>; }, z.core.$strict>; export interface IssueRouteDeps { list(query: IssueQuery): Promise<IssueList>; get(ref: IssueRef): Promise<Issue>; create(input: NewIssue): Promise<Issue>; edit(ref: IssueRef, edit: IssueEdit): Promise<Issue>; comment(ref: IssueRef, body: string): Promise<{ url: string; }>; claim(ref: IssueRef, computer: string, release?: boolean): Promise<Issue>; close(ref: IssueRef, comment?: string): Promise<Issue>; /** Every project this Hook's stores hold, as store-qualified references. */ projects(store: string): Promise<string[]>; repoFor(project: string, store: string): Promise<RepoRef | undefined>; now(): number; } /** Tests swap the forge for a fake; the default repo cache goes with it. */ export declare function setIssueRouteDeps(overrides: Partial<IssueRouteDeps>): () => void; export declare function resetIssueRouteCache(): void; /** Put the real forge back, for tests. */ export declare function resetIssueRouteDeps(): void; /** * Every store project whose repository resolves, cached for five minutes: the * phone never names the repos, so this walk runs once per burst. Four projects * at a time, never one `git config` per project all at once. */ export declare function defaultIssueRepos(store: string): Promise<RepoRef[]>; /** `GET /v1/issues`: every named repo, or every store project's repo. */ export declare function issueListRoute(url: URL, store: string): Promise<Json>; /** `GET /v1/issues/item`: one issue with its full body. */ export declare function issueItemRoute(url: URL): Promise<Json>; /** `POST /v1/issues/{create,edit,comment,claim,close}` */ export declare function issueWriteRoute(pathname: string, data: Json, computer: string): Promise<Json>;