The VS Code of video editing, built for agents.
TypeScript
Remove unused skill management and prompt serving functionality
konstantin-paulusf1e6809c20d6
diff --git a/apps/desktop/src/dapi/docs.ts b/apps/desktop/src/dapi/docs.tsindex cbe1534a..be394074 100644--- a/apps/desktop/src/dapi/docs.ts+++ b/apps/desktop/src/dapi/docs.ts@@ -27,33 +27,6 @@ export function instructions(docsDir: string | null): string {return parts.join("\n\n");}-/** A skill page INSTRUCTIONS.md names: `skills/<name>.md`, and the description after the dash. */-export type Skill = { name: string; description: string; path: string };--const SKILL_ENTRY = /^- `skills\/([\w-]+)\.md`[^—\n]*— (.+)$/gm;--/**- * The skills, read off INSTRUCTIONS.md's list, so the page stays the one- * place a skill is declared. An entry whose page is missing is dropped.- */-export function skills(docsDir: string | null): Skill[] {- const text = docsDir ? readText(join(docsDir, INSTRUCTIONS_FILE)) : null;- if (!docsDir || !text) return [];- return [...text.matchAll(SKILL_ENTRY)]- .map((m) => ({ name: m[1], description: m[2].trim(), path: join(docsDir, "skills", `${m[1]}.md`) }))- .filter((skill) => readText(skill.path) !== null);-}--/**- * What invoking a skill puts in the conversation: the page itself, not a- * request to go read it, so the skill is loaded whatever the model decides.- * The path anchors the page's relative links.- */-export function skillPrompt(skill: Skill): string {- const page = readText(skill.path)?.trim() ?? "";- return `Follow this Diffusion Studio skill for the rest of the session. It is the page \`${skill.path}\`, already read in full below; its relative links resolve from there.\n\n${page}`;-}-function readText(path: string): string | null {try {return readFileSync(path, "utf8");diff --git a/apps/desktop/src/dapi/prompts-session.test.ts b/apps/desktop/src/dapi/prompts-session.test.tsdeleted file mode 100644index f6e28401..00000000--- a/apps/desktop/src/dapi/prompts-session.test.ts+++ /dev/null@@ -1,47 +0,0 @@-/* This Source Code Form is subject to the terms of the Mozilla Public- * License, v. 2.0. If a copy of the MPL was not distributed with this- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */--import { existsSync, readFileSync } from "node:fs";-import { join } from "node:path";-import { afterAll, beforeAll, describe, expect, it } from "vitest";-import { Client } from "@modelcontextprotocol/sdk/client/index.js";-import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";-import { InMemoryTransport } from "@modelcontextprotocol/sdk/inMemory.js";-import { servePrompts } from "./prompts-session";--const repoDocs = join(__dirname, "..", "..", "..", "..", "docs");--let client: Client;--beforeAll(async () => {- const session = new McpServer({ name: "diffusion", version: "0.0.0" });- servePrompts(session, existsSync(repoDocs) ? repoDocs : null);- const [clientTransport, serverTransport] = InMemoryTransport.createLinkedPair();- await session.connect(serverTransport);- client = new Client({ name: "test-client", version: "0.0.0" });- await client.connect(clientTransport);-});--afterAll(() => client.close());--describe("servePrompts", () => {- it("lists the skills INSTRUCTIONS.md names, each with its description", async () => {- if (!existsSync(repoDocs)) return;- const listed = (await client.listPrompts()).prompts;- expect(listed.map((prompt) => prompt.name)).toEqual(["editor", "watch"]);- for (const prompt of listed) expect(prompt.description, prompt.name).toBeTruthy();- expect(listed[0].description).not.toContain("(the default)");- });-- it("answers with the skill page itself, anchored to its path", async () => {- if (!existsSync(repoDocs)) return;- const path = join(repoDocs, "skills", "watch.md");- const { messages } = await client.getPrompt({ name: "watch" });- expect(messages).toHaveLength(1);- expect(messages[0].role).toBe("user");- const text = (messages[0].content as { text: string }).text;- expect(text).toContain(`\`${path}\``);- expect(text).toContain(readFileSync(path, "utf8").trim());- });-});diff --git a/apps/desktop/src/dapi/prompts-session.ts b/apps/desktop/src/dapi/prompts-session.tsdeleted file mode 100644index 833a276e..00000000--- a/apps/desktop/src/dapi/prompts-session.ts+++ /dev/null@@ -1,23 +0,0 @@-/* This Source Code Form is subject to the terms of the Mozilla Public- * License, v. 2.0. If a copy of the MPL was not distributed with this- * file, You can obtain one at http://mozilla.org/MPL/2.0/. */--import { skillPrompt, skills } from "./docs";--import type { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";--/**- * Serves each skill as an MCP prompt named after it. Clients show a server's- * prompts as slash commands under its name — `/diffusion:editor`,- * `/diffusion:watch` — and running one puts the skill page into the- * conversation as a user message: loaded by the client, not left to the- * model to go and read.- */-export function servePrompts(session: McpServer, docsDir: string | null): void {- for (const skill of skills(docsDir)) {- session.registerPrompt(skill.name, { title: skill.name, description: skill.description }, () => ({- description: skill.description,- messages: [{ role: "user", content: { type: "text", text: skillPrompt(skill) } }],- }));- }-}diff --git a/apps/desktop/src/dapi/server.ts b/apps/desktop/src/dapi/server.tsindex 3126c949..386bd251 100644--- a/apps/desktop/src/dapi/server.ts+++ b/apps/desktop/src/dapi/server.ts@@ -8,7 +8,6 @@ import { mainHandlers } from "./handlers";import { DapiHttpServer } from "./http";import { instructions } from "./docs";import { RendererCalls } from "./renderer-calls";-import { servePrompts } from "./prompts-session";import { serveCatalog } from "./tools-session";import type { LogEntry } from "@diffusionstudio/dapi";@@ -88,11 +87,7 @@ export class DapiServer {this.http.stop();}- /**- * One MCP server over the whole catalog. The docs and skills are plain- * files; the instructions say where, and each skill is also a prompt, for- * loading it by slash command.- */+ /** One MCP server over the whole catalog. The docs and skills are plain files; the instructions say where. */private createSession(): McpServer {this.instructionsText ??= instructions(this.deps.docsDir);// `name` is the machine identity, and matches the key we write into agent@@ -103,7 +98,6 @@ export class DapiServer {this.runInMain(tool.name as MainToolName, args, signal): this.renderer.call(tool.name, args, signal),);- servePrompts(session, this.deps.docsDir);return session;}