@extenshi/mcp
Version:
Extenshi MCP server — bring the extension catalog (search, security, market research) and pre-publish scanning into your AI tools
231 lines • 10.5 kB
TypeScript
/**
* What an agent does on the build map (plan 2026-11-03-extension-build-map
* §6.3–6.4, phase 2): report a step, offer the author variants to choose from,
* record the author's answer from the chat, and wait for the author's answer.
*
* The CLI (`extenshi map step|review|choose|wait`) and the stdio MCP server
* (`report_build_step`, `request_build_review`, `get_build_map`) both call
* these. Every write goes through updateMapState, so it lands in the one map of
* the project from whichever worktree the agent works in, and an open page shows
* it within a second. The MCP server ships a byte-identical copy of this file
* next to its copy of build-map-store.ts; build-map-store-sync.test.ts there
* fails on any drift. Edit this file, then copy it over.
*
* Files an agent names are resolved here. Evidence files are hashed, so the
* journal entry is `checked`. A variant's preview and image must be files of
* the project, in the main checkout or any of its worktrees, or https
* addresses. The map server serves those files only for a variant that names
* them (reviewFileOnDisk), so naming a file elsewhere is refused up front.
*/
import { type BuildAsk, type BuildEvidenceWhere, type BuildMapView, type BuildModulesSummary, type BuildModuleView, type BuildNodeRecord, type BuildNodeView, type BuildReview, type BuildStepReport } from '@extenshi/contracts';
import { type MapClient, type RunningServer } from './build-map-store.js';
/** The file types a variant's preview or image may be, with the type the map server answers with. */
export declare const REVIEW_FILE_TYPES: Readonly<Record<string, string>>;
export declare const REVIEW_FILE_MAX_BYTES: number;
/**
* Where a variant's preview or image is, as the state file keeps it: an https
* address as given; a file relative to `home` when it is in the main checkout,
* absolute when it is in another checkout of the project. Throws for anything
* else, with what to do instead.
*/
export declare function resolveReviewFile(home: string, from: string, value: string): Promise<string>;
/**
* The file behind a variant's preview or image, if the map may serve it: it
* is a file of a checkout of the project, of a type in REVIEW_FILE_TYPES, and
* not too big. Checked again at every request, since files change.
*/
export declare function reviewFileOnDisk(home: string, stored: string): Promise<{
file: string;
type: string;
bytes: number;
} | undefined>;
/**
* Evidence files hashed, each where the journal keeps it (journalPath). Throws
* for a file that is not there.
*/
export declare function evidenceFiles(home: string, from: string, files: readonly string[]): Promise<BuildEvidenceWhere[]>;
/**
* The map as the running map server derives it: with the project facts and
* the bound Dojo project. Undefined when no server runs or it does not answer.
* `client` tells the server which program asks (probeServer); `server` says
* which release and graph revision the map runs.
*/
export declare function serverSnapshot(home: string, client?: MapClient): Promise<{
url: string;
server: RunningServer;
snapshot: {
view: BuildMapView;
} & Record<string, unknown>;
} | undefined>;
/**
* What an agent should know about the release the author's map runs, in one
* sentence: the map draws older steps than the agent knows (switch it), newer
* ones (update the agent's own tool), or a newer release is out. Undefined
* when the two agree and nothing newer is known.
*/
export declare function mapUpdateNote(server: Pick<RunningServer, 'version' | 'graph' | 'available' | 'updating'>, client: MapClient): string | undefined;
/** The address that opens one step on the map. */
export declare const stepUrl: (url: string, node: string) => string;
/** A question waiting on the author, with the link that opens its step on the running map. */
export type MapAsk = BuildAsk & {
link?: string;
};
/** What an agent does with `needsYou`; said wherever the list is given. */
export declare const NEEDS_YOU_HOW = "Each entry is a question for the author. Put every one to them in this same reply, one at a time: what it decides, the options with the current values, your recommendation, and the link. Never list step ids alone, and never answer for the author.";
/**
* The steps waiting on the author as questions (`needsYou` of `map status
* --json` and get_build_map): what each decides, the options and their current
* values, where the author answers, and the steps it holds up. `url`: the
* running map, for a link to each step.
*/
export declare function needsYouOf(view: BuildMapView, reviews?: Record<string, BuildReview>, url?: string): MapAsk[];
/**
* The optional modules for `map status --json` and get_build_map: each with
* its switch, where the value comes from and what it adds, and the set in
* numbers. Undefined for a map that runs a release without them.
*/
export declare function modulesOf(view: BuildMapView): {
summary: BuildModulesSummary;
list: BuildModuleView[];
} | undefined;
/**
* Record the author's answer about a module from the chat: on, off, or back to
* what the project suggests (`on: null`). The author confirms the set on the map.
*/
export declare function setModule(home: string, input: {
setting: string;
on: boolean | null;
agent: string;
note?: string;
}): Promise<string | undefined>;
/** A published skill as an agent is told about it: what it teaches and the file to download. */
export type StepSkill = {
name: string;
teaches: string;
url: string;
};
/** How an agent uses the skills a step names; said wherever skills are listed. */
export declare const SKILLS_HOW = "Load the skills of a step before you work on it. Use the copy your client has installed when there is one (the Extenshi plugin ships them all); otherwise download the SKILL.md at `url` and follow it.";
/** The skills with the instructions for a step's work (the graph's `skills`), in the step's order. */
export declare function skillsOfStep(node: string): StepSkill[];
export type MapSkills = {
how: string;
/** The skill for working on the map itself, whatever the step. */
map?: StepSkill;
/** Step id → skill names, for every step this extension needs that is not done yet. */
steps: Record<string, string[]>;
/** Skill name → what it teaches and the file to download, for the names in `steps`. */
index: Record<string, {
teaches: string;
url: string;
}>;
};
/**
* The skills of the steps still ahead, for `map status --json` and
* get_build_map: an agent choosing a step from `next` sees which instructions
* to load first. Done and switched-off steps are left out.
*/
export declare function mapSkills(view: BuildMapView): MapSkills;
/** One task of a step's checklist, as an agent reads it. */
export type StepTask = {
task: number;
t: string;
by: 'author' | 'agent';
done: boolean;
};
/** The task a step is on, by its number and text; `byAuthor` when only the author does it. */
export type StepCurrent = {
task: number;
t: string;
byAuthor?: true;
};
/**
* A step's checklist with `ti` tasks closed: every task (whose it is, whether
* it is closed) and the one the step is on. `map step` and report_build_step
* answer with it, so an agent learns what task 1 is without reading the graph.
*/
export declare function stepTasks(id: string, ti: number): {
todos: StepTask[];
current?: StepCurrent;
};
/**
* Every step this extension needs, for `map status --json` and get_build_map
* alike (`steps`): its status, the task it is on and whose that is, who works
* on it, a re-run, what a done step rests on, and where the owner decides it.
*/
export declare function stepsOf(nodes: Record<string, BuildNodeView>): {
[k: string]: {
waitsOn?: string | undefined;
decide?: import("@extenshi/contracts").BuildDecide | undefined;
basis?: import("@extenshi/contracts").BuildEvidenceBasis | undefined;
redo?: boolean | undefined;
agent?: string | undefined;
byAuthor?: boolean | undefined;
task?: number | undefined;
current?: string | undefined;
status: import("@extenshi/contracts").BuildNodeStatus;
};
};
export type StepInput = Omit<BuildStepReport, 'at' | 'where' | 'checked'> & {
/** Files that show the task done: hashed, so the entry is checked. */
files?: readonly string[];
urls?: readonly string[];
dojo?: readonly string[];
command?: string;
};
/**
* Report on a step. `view` checks that the step's inputs are done; without it
* (no project facts) nothing is refused for that. The entry is `checked` when
* every proof is a file this call hashed.
*/
export declare function reportStep(home: string, from: string, input: StepInput, view?: BuildMapView): Promise<{
record: BuildNodeRecord | undefined;
checked: boolean;
}>;
export type VariantInput = {
label: string;
preview: string;
image?: string;
};
/** Offer the author variants to choose from; files are resolved against `from`. */
export declare function openReview(home: string, from: string, input: {
node: string;
agent: string;
variants: readonly VariantInput[];
}, view?: BuildMapView): Promise<BuildReview>;
/** Record the author's answer from the chat: the variant they picked, or what to change. */
export declare function answerReview(home: string, input: {
node: string;
agent: string;
choice?: string;
redo?: string;
round?: number;
}, view?: BuildMapView): Promise<BuildReview>;
export type ReviewAnswer = {
node: string;
round: number;
status: BuildReview['status'];
/** The variant picked. */
choice?: {
id: string;
label: string;
preview: string;
image?: string;
};
/** What to change, in the author's words. */
feedback?: string;
via?: 'map' | 'chat';
};
export declare function reviewAnswer(node: string, review: BuildReview): ReviewAnswer;
/**
* Wait until the author answers the review of `node`, reading the state file
* every `pollMs` (no map server needed). Resolves at once when it is answered
* already; with `timeoutMs`, resolves with the review still waiting once that
* passes.
*/
export declare function waitForReview(home: string, node: string, options?: {
timeoutMs?: number;
pollMs?: number;
signal?: AbortSignal;
}): Promise<ReviewAnswer>;
//# sourceMappingURL=build-map-agent.d.ts.map