improved a lot of things

This commit is contained in:
SinachPat
2026-04-26 09:09:55 +01:00
parent 2911f22df8
commit 97315846be
70 changed files with 4967 additions and 10 deletions
@@ -0,0 +1,70 @@
import { TOOLS } from '../tools.js';
// ── Claude Code adapter ───────────────────────────────────────────────────────
// Generates two artifacts for Claude Code MCP integration:
// 1. CLAUDE.md section — tool reference injected into the project memory
// 2. MCP server declaration — JSON block for .claude/settings.json
//
// Claude Code discovers MCP servers from .claude/settings.json and injects
// CLAUDE.md into every session's system context automatically.
export interface ClaudeCodeAdapterOptions {
/** MCP WebSocket endpoint URL */
mcpServerUrl: string;
/** Signed workspace token (from issueWorkspaceToken) */
workspaceToken: string;
workspaceName: string;
/** Optional project name shown in CLAUDE.md header */
projectName?: string;
}
export interface ClaudeCodeAdapterOutput {
claudeMdSection: string;
mcpServerDeclaration: ClaudeCodeMcpServer;
}
export interface ClaudeCodeMcpServer {
name: string;
type: 'sse' | 'stdio';
url: string;
headers: Record<string, string>;
}
export function generateClaudeCodeConfig(opts: ClaudeCodeAdapterOptions): ClaudeCodeAdapterOutput {
const projectLabel = opts.projectName ?? opts.workspaceName;
const toolLines = TOOLS.map(t => `- \`${t.name}\`: ${t.description}`).join('\n');
const claudeMdSection = `## Origin Design Agent Bridge — ${projectLabel}
This project is connected to an Origin MCP server that exposes design-to-code tools.
The server is pre-configured in \`.claude/settings.json\`.
### Available MCP Tools
${toolLines}
### Implementation Workflow
1. \`get_pending_diffs\` → list EXPORTED IntentDiffs that need code changes
2. \`get_artboard_context\` → load component tree, screenshots, and design language
3. Implement the required changes in the codebase
4. \`ask_design_agent\` → clarify design intent when the diff is ambiguous
5. \`update_diff_status\` → mark IMPLEMENTED or BLOCKED with an explanation
### Design Language Validation
Run \`get_design_language\` at session start to cache the team's active Design Language File.
All token references (colors, typography, spacing) must match the DLF.
### Rate Limit
100 diff exports/hour per workspace. If you hit the limit, wait before retrying.
`;
const mcpServerDeclaration: ClaudeCodeMcpServer = {
name: 'origin',
type: 'sse',
url: opts.mcpServerUrl,
headers: {
Authorization: `Bearer ${opts.workspaceToken}`,
},
};
return { claudeMdSection, mcpServerDeclaration };
}
@@ -0,0 +1,70 @@
import { TOOLS } from '../tools.js';
// ── Cursor adapter ────────────────────────────────────────────────────────────
// Generates the two files Cursor reads to discover MCP tools:
// 1. .cursorrules — natural-language context injected into every prompt
// 2. cursor_settings.json — MCP server registration (added to .cursor/settings)
//
// Both are returned as strings; the caller writes them to the workspace root.
export interface CursorAdapterOptions {
/** MCP WebSocket endpoint URL */
mcpServerUrl: string;
/** Signed workspace token (from issueWorkspaceToken) */
workspaceToken: string;
workspaceName: string;
}
export interface CursorAdapterOutput {
cursorrules: string;
cursorSettings: CursorSettings;
}
interface McpServerEntry {
url: string;
headers: Record<string, string>;
}
interface CursorSettings {
mcpServers: Record<string, McpServerEntry>;
}
export function generateCursorConfig(opts: CursorAdapterOptions): CursorAdapterOutput {
const toolDescriptions = TOOLS.map(t => `- **${t.name}**: ${t.description}`).join('\n');
const cursorrules = `# Origin — Design-to-Code Agent Bridge
# Workspace: ${opts.workspaceName}
#
# You have access to the following Origin MCP tools via the connected MCP server.
# Use them to fetch design diffs, query artboard context, and report implementation status.
#
## Available Tools
${toolDescriptions}
## Workflow
1. Call \`get_pending_diffs\` to retrieve EXPORTED IntentDiffs awaiting implementation.
2. Call \`get_artboard_context\` to load component tree, design language, and screenshots.
3. Implement the diff. Use \`ask_design_agent\` if design intent is unclear.
4. Call \`update_diff_status\` with IMPLEMENTED or BLOCKED when done.
## Design Language
Always validate tokens/colors/spacing against the workspace Design Language File.
Call \`get_design_language\` once per session to cache the active DLF locally.
## Rate Limits
100 diff exports per hour per workspace. The server returns HTTP 429 when exceeded.
`;
const cursorSettings: CursorSettings = {
mcpServers: {
origin: {
url: opts.mcpServerUrl,
headers: {
Authorization: `Bearer ${opts.workspaceToken}`,
},
},
},
};
return { cursorrules, cursorSettings };
}