/** * Plan helper commands. * * The `plan local` commands are intentionally separate from the Plan app * actions. They do not call MCP, hosted write actions, SQLite, or hosted * storage; they only read local files or serve them from a localhost bridge so * privacy-focused users have an auditable no-DB path. The top-level * `plan blocks` command is a schema-only, no-auth helper for fetching the * public block catalog before authoring local MDX; it never sends plan content. */ import { type Server } from "node:http"; type LocalPlanKind = "plan" | "recap"; type LocalPlanFiles = { dir: string; planMdx: string; canvasMdx?: string; prototypeMdx?: string; stateJson?: string; assets?: Record; }; export type LocalPlanValidationIssue = { file: string; line: number; message: string; }; type LocalPlanPreviewInput = { dir: string; kind?: LocalPlanKind; title?: string; brief?: string; appUrl?: string; }; type LocalPlanPreviewResult = { ok: true; dir: string; out?: string; url: string; title: string; kind: LocalPlanKind; files: string[]; opened?: boolean; openCommand?: string; openError?: string; }; type LocalPlanBridgeMdxFolder = { "plan.mdx": string; "canvas.mdx"?: string; "prototype.mdx"?: string; ".plan-state.json"?: string; "assets/"?: Record; }; type LocalPlanBridgeComment = { id: string; planId: string; parentCommentId: string | null; sectionId: string | null; kind: string; status: string; anchor: string | null; message: string; createdBy: string; authorEmail: string | null; authorName: string | null; resolutionTarget: string | null; mentions: unknown[]; mentionsJson: string | null; resolvedBy: string | null; resolvedAt: string | null; consumedAt: string | null; deletedAt: string | null; deletedBy: string | null; createdAt: string; updatedAt: string; }; type VisualAnswerSourcePayload = { question?: string; title?: string; brief?: string; repoPath?: string; sourceUrl?: string; sourceType?: string; mdx: { "plan.mdx": string; "canvas.mdx"?: string; "prototype.mdx"?: string; "assets/"?: Record; }; }; export type PublishVisualAnswerInput = { appUrl: string; token: string; question?: string; sourcePath?: string; out?: string; prevPlanId?: string; repo?: string; sourceUrl?: string; sourceType?: string; visibility?: "private" | "org" | "public"; fetchFn?: typeof fetch; cwd?: string; }; export type LocalPlanBridgePayload = { ok: true; version: 1; source: "agent-native-local-bridge"; localOnly: true; slug: string; dir: string; title: string; brief: string; kind: LocalPlanKind; updatedAt: string; files: string[]; mdx: LocalPlanBridgeMdxFolder; comments: LocalPlanBridgeComment[]; }; export type LocalPlanServeResult = { ok: true; dir: string; url: string; urlFile?: string; bridgeUrl: string; appUrl: string; title: string; kind: LocalPlanKind; files: string[]; host: string; port: number; opened?: boolean; openCommand?: string; openError?: string; }; export type LocalPlanBridgeServer = { server: Server; result: LocalPlanServeResult; }; export type RendererValidationIssue = { path: string; message: string; }; export type RendererValidation = { /** Whether a loopback renderer validate endpoint was reachable and answered. */ ran: boolean; endpoint: string; /** Renderer verdict — present only when `ran` is true. */ valid?: boolean; issues?: RendererValidationIssue[]; /** Transport/endpoint error when `ran` is false (unreachable, 404, old deploy). */ error?: string; }; export type LocalPlanVerifyResult = { ok: boolean; dir: string; url: string; urlFile?: string; bridgeUrl: string; appUrl: string; title: string; kind: LocalPlanKind; files: string[]; preflight: { status: number; allowOrigin: string | null; allowPrivateNetwork: string | null; }; bridge: { status: number; ok: boolean; source?: string; localOnly?: boolean; files?: string[]; mdxFiles?: string[]; error?: string; }; validation: RendererValidation; warnings: string[]; }; type OpenLocalUrlResult = { ok: boolean; command: string; error?: string; }; export declare function localPlanFolderName(title: string): string; export declare function readLocalPlanFiles(dir: string): LocalPlanFiles; export declare function validateLocalPlanFiles(files: LocalPlanFiles): LocalPlanValidationIssue[]; export declare function assertLocalPlanFilesValid(files: LocalPlanFiles): void; export declare function buildLocalPlanPreviewHtml(input: LocalPlanPreviewInput): string; export declare function writeLocalPlanPreview(input: { dir: string; out?: string; kind?: LocalPlanKind; title?: string; brief?: string; appUrl?: string; open?: boolean; openUrl?: (url: string) => OpenLocalUrlResult; }): LocalPlanPreviewResult; export declare function startLocalPlanBridge(input: { dir: string; kind?: LocalPlanKind; title?: string; brief?: string; appUrl?: string; host?: string; port?: number; token?: string; open?: boolean; urlFile?: string | false; openUrl?: (url: string) => OpenLocalUrlResult; skipSourceValidation?: boolean; }): Promise; /** * Ask a loopback Plan app to validate the folder against its real renderer schema * (`parsePlanMdxFolder` + `planContentSchema`) via the public, no-DB * `validate-local-plan-source` action. This is what makes `verify` * authoritative without transmitting local plan source off-device. Remote app * URLs are intentionally skipped: local-files privacy mode must never POST MDX * or assets to a hosted validation action. Degrades gracefully (`ran: false`) * when no local Plan app is running or it predates the action. */ export declare function fetchRendererValidation(input: { appUrl: string; files: LocalPlanFiles; fetchFn?: typeof fetch; }): Promise; export declare function verifyLocalPlanBridge(input: { dir: string; kind?: LocalPlanKind; title?: string; brief?: string; appUrl?: string; host?: string; port?: number; token?: string; urlFile?: string | false; fetchFn?: typeof fetch; }): Promise; export declare function readVisualAnswerSourcePayload(sourcePath: string): VisualAnswerSourcePayload; export declare function publishVisualAnswerSource(input: PublishVisualAnswerInput): Promise<{ ok: true; url: string; out: string; }>; export declare function runPlan(argv: string[]): Promise; export {}; //# sourceMappingURL=plan-local.d.ts.map