UNPKG

@hasna/projects

Version:

High-level project management CLI, MCP server, SDK, and AI SDK agent loop for coding agents

80 lines • 3.74 kB
import type { Database } from "bun:sqlite"; import { type WorkspaceFilter } from "../db/workspaces.js"; import { type ProjectChannelExistenceProbe } from "./project-channel.js"; import type { ProjectStore } from "../store/project-store.js"; import type { Workspace } from "../types/workspace.js"; export type WorkspaceCheckStatus = "ok" | "warn" | "error"; export interface WorkspaceDoctorCheck { code: string; name: string; status: WorkspaceCheckStatus; message: string; fixable?: boolean; } export interface WorkspaceDoctorFix { code: string; message: string; changed: boolean; dryRun: boolean; /** * For a marker rewrite: the marker on disk was re-read and re-compared with * the project row after the write. Absent when nothing was written. */ verified?: boolean; } export interface WorkspaceDoctorResult { workspace: Workspace; checks: WorkspaceDoctorCheck[]; fixes: WorkspaceDoctorFix[]; ok: boolean; } export type WorkspaceDoctorTransport = "local" | "http"; /** * The shared-registry references a HOSTED doctor run resolved through the * ProjectStore (`/v1/roots`, `/v1/recipes`) before the synchronous doctor ran: * `true` = found, `false` = missing, absent = not resolved in this call. * {@link doctorWorkspaceWithStore} fills this in; a direct hosted call without * it reports the reference as not checked rather than opening the on-box * SQLite to answer a question the hosted registry owns (hasna/apps#1720). */ export interface WorkspaceDoctorReferences { root?: boolean; recipe?: boolean; } export interface WorkspaceDoctorOptions { fix?: boolean; dryRun?: boolean; transport?: WorkspaceDoctorTransport; references?: WorkspaceDoctorReferences; /** * Optional probe that verifies the project's advertised * `integrations.conversations_channel` exists in the conversations app. * When absent, the check is a self-contained verdict only when the project * pins no channel; a pinned channel that cannot be probed reports * "not verified" (never a fabricated error). */ channelProbe?: ProjectChannelExistenceProbe; } /** * Synchronous doctor. On the hosted transport (`transport: "http"`) NOTHING * here reaches the on-box registry: references come from `options.references`, * and the location, agent-run and migration-map checks answer "local only". * Prefer {@link doctorWorkspaceWithStore}, which resolves the references. */ export declare function doctorWorkspace(workspace: Workspace, options?: WorkspaceDoctorOptions, db?: Database): WorkspaceDoctorResult; /** The slice of the Store the doctor needs; a test can hand in a fake. */ export type WorkspaceDoctorStore = Pick<ProjectStore, "transport" | "getRoot" | "getRecipe">; /** * Doctor a project through the active Store — the entry point the CLI, the MCP * server and the prompt agent share. * * Hosted: the root/recipe references are resolved against the shared registry * (`/v1/roots`, `/v1/recipes`) and the synchronous doctor runs with * `transport: "http"`, so the on-box SQLite is never opened or created for an * API-backed project (hasna/apps#1720, acceptance f). Local: the synchronous * doctor, unchanged, completed synchronously (no await) so a caller holding a * synchronous lock still covers the whole run. */ export declare function doctorWorkspaceWithStore(store: WorkspaceDoctorStore, workspace: Workspace, options?: Omit<WorkspaceDoctorOptions, "transport" | "references">): Promise<WorkspaceDoctorResult>; export declare function doctorWorkspaces(filter?: WorkspaceFilter, options?: WorkspaceDoctorOptions, db?: Database): WorkspaceDoctorResult[]; //# sourceMappingURL=workspace-doctor.d.ts.map