@progress/kendo-react-mcp 1.6.1 → 1.6.2-beta.a42c596b.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/index.js +2911 -204
- package/package.json +2 -2
- package/proto/service.proto +66 -0
package/dist/index.js
CHANGED
|
@@ -1,15 +1,804 @@
|
|
|
1
1
|
#!/usr/bin/env node
|
|
2
|
-
import{McpServer as St}from"@modelcontextprotocol/sdk/server/mcp.js";import{StdioServerTransport as Tt}from"@modelcontextprotocol/sdk/server/stdio.js";import{dirname as ct,join as lt}from"path";import{fileURLToPath as dt}from"url";import{loadLicense as Je,decodeLicenseKey as Xe,decodeLicenseEvidence as Ze}from"@progress/kendo-licensing/utils";var B=class extends Error{constructor(t){super(t),this.name="LicenseError"}};function te(e){return e.replace(/^\uFEFF/,"")}async function oe(e){let t=null,n=null;try{let o=Je();if(!o.success){let s=new B(o.message);throw e&&await e("license_load_failed",{error:o.message}).catch(()=>{}),s}try{t=(await Xe(o.value)).licenses.find(async r=>!!(await Ze(r)).userId)}catch(s){console.log(s.message),e&&await e("license_load_failed",{error:s.message||"Unknown decoding error"}).catch(()=>{})}if(!t)return[te(o.value),null]}catch(o){return n=o.message||"Unknown error loading license.",e&&await e("license_load_failed",{error:n}).catch(()=>{}),[null,n]}return[te(t),null]}import P from"node:fs";import U from"node:path";var q=!1,E=process.env.DEBUG_LOG_FILE,ne=!!(E&&typeof E=="string");if(ne){let e=U.resolve(E),t=U.dirname(e);if(t!=="."&&t!==process.cwd()&&!P.existsSync(t))try{P.mkdirSync(t,{recursive:!0})}catch(n){console.error("Error creating log directory:",n)}if(!P.existsSync(e))try{P.writeFileSync(e,"")}catch(n){console.error("Error creating log file:",n)}}else q=!1;q=ne&&!!E&&P.existsSync(U.resolve(E));function g(...e){if(q&&E){let o=`${new Date().toISOString()}: ${e.join(" ")}
|
|
3
|
-
`,s=U.resolve(E);P.appendFile(s,o,r=>{r&&console.error("Error writing to log file:",r)})}}import et from"@grpc/proto-loader";import $ from"@grpc/grpc-js";import re from"path";import se from"fs";import{fileURLToPath as tt}from"url";var ot=tt(import.meta.url),nt=re.dirname(ot),ie={version:"unknown"},ae=re.resolve(nt,"../package.json");se.existsSync(ae)&&(ie=JSON.parse(se.readFileSync(ae,"utf-8")));function st(e){return e.replace(/\u2014/g,"--").replace(/\u2013/g,"-").replace(/[^\x20-\x7E]/g,"")}var M=class{constructor(t,n,o){this.contextApiUrl=t;this.protoPath=n;this.options=o;this.toolNameHeader="assistant";let s=et.loadSync(this.protoPath,{keepCase:!0,longs:String,enums:String,defaults:!0,oneofs:!0});this.isDev=this.contextApiUrl?.includes("localhost")||this.contextApiUrl?.includes("127.0.0.1"),g("Using ContextApi URl:",this.contextApiUrl);let r=$.loadPackageDefinition(s);this.client=new r.ContextQueryService(this.contextApiUrl||"contextapi.telerik.com:443",this.isDev?$.credentials.createInsecure():$.credentials.createSsl())}async getMetadata({meta:t}={meta:{}}){let[n,o]=this.isDev?["fake_license",null]:await oe((m,A)=>this.logEvent(m,A)),s=process.env.CONTEXTAPI_API_KEY,r=s&&typeof s=="string",a=n&&typeof n=="string";if(!a&&!r&&o)throw new Error(`Failed to authenticate with API key or License key!
|
|
4
2
|
|
|
5
|
-
License Error: ${o}`);let i=new $.Metadata;if(a)try{i.add("x-license-key",n)}catch(m){throw g("Error adding license key to metadata:",m),new Error(`Failed to use license key: ${m.message}`)}r&&i.add("x-api-key",s),this.options?.libName&&i.add("x-library-name",this.options.libName),i.add("x-tool-name",this.toolNameHeader);let d=JSON.stringify({...t,source:"npm",version:ie.version,os:process.platform,node_version:process.version});return i.add("x-request-metadata",st(d)),i}async query(t,n){let o=await this.getMetadata({meta:n});return new Promise((s,r)=>{this.client.query(t,o,(a,i)=>{a?r(new Error(a)):s(i)})})}async getApiRefMatches(t,n){let o=await this.getMetadata({meta:n});return new Promise((s,r)=>{this.client.getApiRefMatches(t,o,(a,i)=>{a?r(new Error(a)):s(i)})})}async queryCssUtils(t,n){let o=await this.getMetadata({meta:n});return new Promise((s,r)=>{this.client.cssUtilsSearch(t,o,(a,i)=>{a?(g("Error querying CSS Utils:",a),r(new Error(a))):s(i)})})}async queryIconsSearch(t,n){let o=await this.getMetadata({meta:n});return new Promise((s,r)=>{this.client.iconsSearch(t,o,(a,i)=>{a?(g("Error querying Icons Search:",a),r(new Error(a))):s(i)})})}async queryBuildingBlocks(t,n){let o=await this.getMetadata({meta:n});return new Promise((s,r)=>{this.client.buildingBlocksSearch(t,o,(a,i)=>{a?(g("Error querying Building Blocks:",a),r(new Error(a))):s(i)})})}async validateUserLicense(){let t=await this.getMetadata();return new Promise((n,o)=>{this.client.validateUserLicense(null,t,(s,r)=>{s?(g("Error validating user license:",s),o(new Error(s))):n(r)})})}async queryThemeGenerate(t,n){let o=await this.getMetadata({meta:n});return new Promise((s,r)=>{this.client.generateTheme(t,o,(a,i)=>{a?(g("Error querying context API/GenerateTheme:",a),r(new Error(a))):s(i)})})}async recordOrchestratorUserRequest({meta:t}){let n=await this.getMetadata({meta:t});return new Promise((o,s)=>{this.client.recordOrchestratorUserRequest(null,n,(r,a)=>{r?(g("Error recording orchestrator user request:",r),s(new Error(r))):o(a)})})}async recordToolUserRequest({toolName:t,meta:n}){let o=await this.getMetadata({meta:n});return new Promise((s,r)=>{this.client.recordToolUserRequest({tool_name:t},o,(a,i)=>{a?(g("Error recording tool user request:",a),r(new Error(a))):s(i)})})}async logEvent(t,n){let o="h8utJ6rk4PpIWX4JMn9beQDsjVUri6KV0XYfiVwq";if(!o||typeof o!="string"){g("LOGGING_API_KEY not configured, skipping log event");return}let s=new $.Metadata;return s.add("x-api-key",o),new Promise((r,a)=>{this.client.logEvent({event_name:t,fields:n||{}},s,(i,d)=>{i?(g("Error logging event:",i),a(new Error(i))):r()})})}};import{z as K}from"zod";var Ht=K.object({user_id:K.string(),user_email:K.string().email()});import{z as b}from"zod";var at=b.object({Product:b.object({Id:b.number().int(),Code:b.string(),Name:b.string()}),License:b.nullable(b.object({Id:b.number().int(),Name:b.string(),Type:b.string(),Active:b.boolean()})),Availability:b.array(b.object({LicenseStart:b.nullable(b.string().datetime()),LicenseEnd:b.nullable(b.string().datetime())})),IsLicenseAvailable:b.optional(b.boolean())}),Yt=b.array(at);async function ce(e){let t=process.env.KENDO_MCP_ACCESS;if(t==="true"||t==="1"||t==="full")return"full";if(typeof t=="string"&&(t.toLowerCase()==="agent"||t.toLowerCase()==="assistant"))return t.toLowerCase();let n=await e();return n.toLocaleLowerCase()==="agentic_ui_generator"?"agent":n.toLocaleLowerCase()==="ai_coding_assistants"?"assistant":"none"}function le(){return'**Accessibility Guidelines: WCAG 2.2 Level AA Compliance**\n\n**Core Principles:**\n1. Use semantic HTML and ARIA correctly\n2. Ensure WCAG 2.2 AA compliance\n3. Follow W3C ARIA Authoring Practices\n4. Provide standards-based accessibility fixes\n\n**1. Form Control Labels** (WCAG 1.3.1, 3.3.2, 4.1.2)\nEvery input must have an associated label.\nCORRECT: `<input type="search" aria-label="Search products" placeholder="Search...">`\nWRONG: `<span>Email</span><input type="email">` (no association)\nWRONG: `<input type="email" placeholder="Email">` (placeholder as label)\n\n**2. Button Accessibility** (WCAG 4.1.2, 2.4.6, 2.5.3)\nAll buttons need accessible names describing their purpose.\nCORRECT: `<button type="button">Save Changes</button>`\nCORRECT: `<button aria-label="Close dialog"><svg aria-hidden="true" focusable="false">...</svg></button>`\nWRONG: `<button><svg>...</svg></button>` (no accessible name)\nWRONG: `<button>Click here</button>` (generic text)\n\n**3. Popup/Menu Triggers** (WCAG 4.1.2, 1.3.1)\nIndicate popup purpose and state using aria-haspopup, aria-expanded, aria-controls.\nCORRECT: `<button aria-expanded="false" aria-haspopup="menu" aria-controls="menu-id">Settings</button>`\n\n**4. Image Accessibility** (WCAG 1.1.1)\nInformative: `<img src="chart.png" alt="Sales increased 25% in Q4 2024">`\nFunctional: `<a href="/home"><img src="logo.png" alt="Company Name Home"></a>`\nDecorative: `<img src="border.png" alt="" role="presentation">`\nComplex: `<img src="chart.png" alt="Sales data" aria-describedby="desc-id">`\nWRONG: Missing alt, filename as alt, generic alt for decorative images\n\n**5. Link Accessibility** (WCAG 2.4.4, 2.4.6)\nLinks must be descriptive and understandable out of context.\nCORRECT: `<a href="/products">View All Products</a>`\nCORRECT: `<a href="/article" aria-label="Read more about New Product Launch">Read more</a>`\nWRONG: "Click here", "Read more", "Learn more" without context\n\n**6. Form Validation** (WCAG 3.3.1, 3.3.2, 3.3.3)\nErrors must be identified, associated with inputs, and provide suggestions. Use aria-describedby, aria-invalid="true", and role="alert".\n\n**7. Heading Structure** (WCAG 1.3.1, 2.4.6)\nEach page should have an `<h1>` that describes its content. Use hierarchical, descriptive headings with no skipped levels (h1\u2192h2\u2192h3).\nCORRECT: `<h1>Dashboard</h1> <h2>Sales</h2> <h3>By Region</h3>`\nWRONG: No `<h1>` on the page, or skipping levels (h1\u2192h3)\nIf a heading should look smaller than its semantic level, use CSS: `<h2 class="text-sm">Subtitle</h2>`\n\n**8. Page Component Landmark Rules** (WCAG 1.3.1, 4.1.2)\nPage components (route components) may be rendered inside a layout that already provides `<main>`, `<header>`, or `<footer>`. Since the layout configuration is unknown, avoid using these landmarks in page components to prevent potential duplication and nesting violations. Use `<div>`, `<section>`, or `<article>` as the top-level wrapper instead.\n\n**Quick Checklist:**\n- **Forms:** Associated labels, aria-required on required fields, autocomplete attributes, aria-describedby for errors, aria-invalid for invalid fields, fieldsets with legends\n- **Buttons/Links:** Accessible names, aria-label for icon buttons, aria-hidden on decorative icons, descriptive link text\n- **Popups/Dialogs:** aria-haspopup, aria-expanded, aria-controls, role="dialog", aria-modal="true", aria-labelledby, focus trap, Escape to close\n- **Images:** alt on all images, descriptive alt for informative, empty alt for decorative, aria-describedby for complex\n- **Structure:** One h1, logical heading hierarchy, avoid `<main>`, `<header>`, or `<footer>` in page/route components (the layout may already provide them), use `<section>` or `<div>` as page-level wrappers, semantic HTML\n- **Dynamic Content:** role="status"/aria-live="polite" for updates, role="alert"/aria-live="assertive" for critical alerts\n- **Keyboard/Focus:** All interactive elements keyboard accessible, logical focus order, visible focus indicators, no keyboard traps (except modals)\n- **Color/Contrast:** 4.5:1 text contrast (3:1 large text), 3:1 UI component contrast, no color-only information, 3:1 focus indicator contrast'}var rt=1440*60*1e3;function de(e){let{serverName:t,contextApi:n,additionalFields:o={},intervalMs:s=rt}=e,r="mcp_server_heartbeat",a=async()=>{try{let d={server_name:t,timestamp:new Date().toISOString(),...o};await n.logEvent(r,d)}catch(d){g(`Failed to send heartbeat for ${t}:`,d)}};a();let i=setInterval(a,s);return()=>{clearInterval(i),g(`Heartbeat stopped for ${t}`)}}import{z as F}from"zod";var it=["default","bootstrap","material","fluent"];function pe(e,t){return{projectName:F.string().default(t).describe("The name of the project. Used as the project folder name when creating a new project."),createNewProject:F.boolean().default(!0).describe(`Whether to create a new project before configuring ${e}. Set to true to scaffold a brand-new project, or false if the project already exists and you only want to add ${e} to it.`),theme:F.enum(it).default("default").describe("The Kendo UI theme to use. Determines which theme package is installed and imported.")}}var l="Kendo UI for React",I="react",w="kendo";var O=["ActionSheet","AIPrompt","Animation","AppBar","ArcGauge","AutoComplete","Avatar","Badge","Barcode","BottomNavigation","Breadcrumb","Button","ButtonGroup","BreadCrumb","Calendar","Card","Chart","ChartWizard","Chat","Checkbox","Chip","ChipList","ChunkProgressBar","CircularGauge","ColorGradient","ColorPalette","ColorPicker","ComboBox","ContextMenu","ConversationalUI","DataGrid","Grid","DataQuery","DateMath","DateInput","DatePicker","DateRangePicker","DateTimePicker","Dialog","Drag&Drop","Drawer","Drawing","DropDownButton","DropDownList","DropDownTree","Editor","Error","ExcelExport","ExpansionPanel","ExternalDropZone","FileSaver","FileManager","Filter","FlatColorPicker","FloatingActionButton","FloatingLabel","Form","Gantt","Gauge","General","GridLayout","Hint","Icon","InlineAIPrompt","Input","Label","LinearGauge","ListBox","ListView","Loader","Map","MaskedTextBox","Menu","MultiColumnComboBox","MultiSelect","MultiSelectTree","MultiViewCalendar","Notification","NumericTextBox","OrgChart","PageTemplates/BuildingBlocks","Pager","PanelBar","PDFProcessing","PDFViewer","PivotGrid","Popover","Popup","ProgressBar","PromptBox","QRCode","RadialGauge","RadioButton","RadioGroup","RangeSlider","Rating","Ripple","Sankey","Scheduler","ScrollView","Signature","Skeleton","Slider","Sortable","Sparkline","SpeechToTextButton","SmartPasteButton","SplitButton","Splitter","Spreadsheet","StackLayout","Stepper","StockChart","SVGIcon","Switch","TabStrip","TaskBoard","TextArea","TextBox","TileLayout","Timeline","TimePicker","Toolbar","Tooltip","TreeList","TreeView","Typography","Upload","VSCodeExtension","Window"];var pt=lt(ct(dt(import.meta.url)),"../proto/service.proto"),_=new M("contextapi.telerik.com:443",pt,{libName:I});var me=async()=>_.validateUserLicense();import vt from"fs";import ze from"path";import{fileURLToPath as kt}from"url";import{z as C}from"zod";var v=class{constructor(t,n,o){this.name=t;this.config=n;this.cb=o}register(t){this.server=t,this.server.registerTool(this.name,this.config,this.cb)}hasAccess(t){return!this.config.requiredAccess||this.config.requiredAccess.length===0?!0:t==="full"||this.config.requiredAccess.includes(t)}};var D=(e,t)=>`# ${e.suiteName} - Code Validation & Quality Assurance
|
|
3
|
+
// packages/react/src/index.ts
|
|
4
|
+
import { McpServer } from "@modelcontextprotocol/sdk/server/mcp.js";
|
|
5
|
+
import { StdioServerTransport } from "@modelcontextprotocol/sdk/server/stdio.js";
|
|
6
|
+
|
|
7
|
+
// packages/react/src/lib/grpc-client.ts
|
|
8
|
+
import { dirname, join } from "path";
|
|
9
|
+
import { fileURLToPath as fileURLToPath2 } from "url";
|
|
10
|
+
|
|
11
|
+
// packages/mcp-common/src/lib/read-license.ts
|
|
12
|
+
import {
|
|
13
|
+
loadLicense,
|
|
14
|
+
decodeLicenseKey,
|
|
15
|
+
decodeLicenseEvidence
|
|
16
|
+
} from "@progress/kendo-licensing/utils";
|
|
17
|
+
var LicenseError = class extends Error {
|
|
18
|
+
constructor(message) {
|
|
19
|
+
super(message);
|
|
20
|
+
this.name = "LicenseError";
|
|
21
|
+
}
|
|
22
|
+
};
|
|
23
|
+
function fixBom(licenseKey) {
|
|
24
|
+
return licenseKey.replace(/^\uFEFF/, "");
|
|
25
|
+
}
|
|
26
|
+
async function readLicense(logCallback) {
|
|
27
|
+
let licenseEvidence = null;
|
|
28
|
+
let error = null;
|
|
29
|
+
try {
|
|
30
|
+
const license = loadLicense();
|
|
31
|
+
if (!license.success) {
|
|
32
|
+
const licenseError = new LicenseError(license.message);
|
|
33
|
+
if (logCallback) {
|
|
34
|
+
await logCallback("license_load_failed", {
|
|
35
|
+
error: license.message
|
|
36
|
+
}).catch(() => {
|
|
37
|
+
});
|
|
38
|
+
}
|
|
39
|
+
throw licenseError;
|
|
40
|
+
}
|
|
41
|
+
try {
|
|
42
|
+
const decodedLicense = await decodeLicenseKey(license.value);
|
|
43
|
+
licenseEvidence = decodedLicense.licenses.find(async (lic) => {
|
|
44
|
+
const evidence = await decodeLicenseEvidence(lic);
|
|
45
|
+
if (evidence.userId) {
|
|
46
|
+
return true;
|
|
47
|
+
}
|
|
48
|
+
return false;
|
|
49
|
+
});
|
|
50
|
+
} catch (err) {
|
|
51
|
+
console.log(err.message);
|
|
52
|
+
if (logCallback) {
|
|
53
|
+
await logCallback("license_load_failed", {
|
|
54
|
+
error: err.message || "Unknown decoding error"
|
|
55
|
+
}).catch(() => {
|
|
56
|
+
});
|
|
57
|
+
}
|
|
58
|
+
}
|
|
59
|
+
if (!licenseEvidence) {
|
|
60
|
+
return [fixBom(license.value), null];
|
|
61
|
+
}
|
|
62
|
+
} catch (err) {
|
|
63
|
+
error = err.message || "Unknown error loading license.";
|
|
64
|
+
if (logCallback) {
|
|
65
|
+
await logCallback("license_load_failed", {
|
|
66
|
+
error
|
|
67
|
+
}).catch(() => {
|
|
68
|
+
});
|
|
69
|
+
}
|
|
70
|
+
return [null, error];
|
|
71
|
+
}
|
|
72
|
+
return [fixBom(licenseEvidence), null];
|
|
73
|
+
}
|
|
74
|
+
|
|
75
|
+
// packages/mcp-common/src/lib/logger.ts
|
|
76
|
+
import fs from "node:fs";
|
|
77
|
+
import path from "node:path";
|
|
78
|
+
var LOG_ENABLED = false;
|
|
79
|
+
var LOG_FILE = process.env.DEBUG_LOG_FILE;
|
|
80
|
+
var LOG_FILE_DEFINED = !!(LOG_FILE && typeof LOG_FILE === "string");
|
|
81
|
+
if (LOG_FILE_DEFINED) {
|
|
82
|
+
const resolvedLogFile = path.resolve(LOG_FILE);
|
|
83
|
+
const logDir = path.dirname(resolvedLogFile);
|
|
84
|
+
if (logDir !== "." && logDir !== process.cwd() && !fs.existsSync(logDir)) {
|
|
85
|
+
try {
|
|
86
|
+
fs.mkdirSync(logDir, { recursive: true });
|
|
87
|
+
} catch (err) {
|
|
88
|
+
console.error("Error creating log directory:", err);
|
|
89
|
+
}
|
|
90
|
+
}
|
|
91
|
+
if (!fs.existsSync(resolvedLogFile)) {
|
|
92
|
+
try {
|
|
93
|
+
fs.writeFileSync(resolvedLogFile, "");
|
|
94
|
+
} catch (err) {
|
|
95
|
+
console.error("Error creating log file:", err);
|
|
96
|
+
}
|
|
97
|
+
}
|
|
98
|
+
} else {
|
|
99
|
+
LOG_ENABLED = false;
|
|
100
|
+
}
|
|
101
|
+
LOG_ENABLED = LOG_FILE_DEFINED && !!LOG_FILE && fs.existsSync(path.resolve(LOG_FILE));
|
|
102
|
+
function log(...args) {
|
|
103
|
+
if (LOG_ENABLED && LOG_FILE) {
|
|
104
|
+
const date = /* @__PURE__ */ new Date();
|
|
105
|
+
const dateString = date.toISOString();
|
|
106
|
+
const logString = `${dateString}: ${args.join(" ")}
|
|
107
|
+
`;
|
|
108
|
+
const resolvedLogFile = path.resolve(LOG_FILE);
|
|
109
|
+
fs.appendFile(resolvedLogFile, logString, (err) => {
|
|
110
|
+
if (err) {
|
|
111
|
+
console.error("Error writing to log file:", err);
|
|
112
|
+
}
|
|
113
|
+
});
|
|
114
|
+
}
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
// packages/mcp-common/src/lib/context-api.ts
|
|
118
|
+
import protoLoader from "@grpc/proto-loader";
|
|
119
|
+
import grpc from "@grpc/grpc-js";
|
|
120
|
+
import path2 from "path";
|
|
121
|
+
import fs2 from "fs";
|
|
122
|
+
import { fileURLToPath } from "url";
|
|
123
|
+
var __filename = fileURLToPath(import.meta.url);
|
|
124
|
+
var __dirname = path2.dirname(__filename);
|
|
125
|
+
var packageJson = { version: "unknown" };
|
|
126
|
+
var packageJsonPath = path2.resolve(__dirname, "../package.json");
|
|
127
|
+
if (fs2.existsSync(packageJsonPath)) {
|
|
128
|
+
packageJson = JSON.parse(fs2.readFileSync(packageJsonPath, "utf-8"));
|
|
129
|
+
}
|
|
130
|
+
function sanitizeMetadata(value) {
|
|
131
|
+
return value.replace(/\u2014/g, "--").replace(/\u2013/g, "-").replace(/[^\x20-\x7E]/g, "");
|
|
132
|
+
}
|
|
133
|
+
var D2CError = class extends Error {
|
|
134
|
+
constructor(code, message, details) {
|
|
135
|
+
super(message);
|
|
136
|
+
this.code = code;
|
|
137
|
+
this.details = details;
|
|
138
|
+
this.name = "D2CError";
|
|
139
|
+
}
|
|
140
|
+
};
|
|
141
|
+
var ContextAPI = class {
|
|
142
|
+
constructor(contextApiUrl, protoPath2, options) {
|
|
143
|
+
this.contextApiUrl = contextApiUrl;
|
|
144
|
+
this.protoPath = protoPath2;
|
|
145
|
+
this.options = options;
|
|
146
|
+
this.toolNameHeader = "assistant";
|
|
147
|
+
const proto = protoLoader.loadSync(this.protoPath, {
|
|
148
|
+
keepCase: true,
|
|
149
|
+
longs: String,
|
|
150
|
+
enums: String,
|
|
151
|
+
defaults: true,
|
|
152
|
+
oneofs: true
|
|
153
|
+
});
|
|
154
|
+
this.isDev = this.contextApiUrl?.includes("localhost") || this.contextApiUrl?.includes("127.0.0.1");
|
|
155
|
+
log("Using ContextApi URl:", this.contextApiUrl);
|
|
156
|
+
const protoDescriptor = grpc.loadPackageDefinition(proto);
|
|
157
|
+
const maxMsgSize = 100 * 1024 * 1024;
|
|
158
|
+
const channelOptions = {
|
|
159
|
+
"grpc.max_receive_message_length": maxMsgSize,
|
|
160
|
+
"grpc.max_send_message_length": maxMsgSize
|
|
161
|
+
};
|
|
162
|
+
this.client = new protoDescriptor.ContextQueryService(
|
|
163
|
+
this.contextApiUrl || "contextapi.telerik.com:443",
|
|
164
|
+
this.isDev ? grpc.credentials.createInsecure() : grpc.credentials.createSsl(),
|
|
165
|
+
channelOptions
|
|
166
|
+
);
|
|
167
|
+
}
|
|
168
|
+
async getMetadata({ meta } = { meta: {} }) {
|
|
169
|
+
const [license, error] = this.isDev ? ["fake_license", null] : await readLicense((eventName, fields) => this.logEvent(eventName, fields));
|
|
170
|
+
const apiKey = process.env.CONTEXTAPI_API_KEY;
|
|
171
|
+
const hasApiKey = apiKey && typeof apiKey === "string";
|
|
172
|
+
const hasLicense = license && typeof license === "string";
|
|
173
|
+
if (!hasLicense && !hasApiKey && error) {
|
|
174
|
+
throw new Error(
|
|
175
|
+
`Failed to authenticate with API key or License key!
|
|
176
|
+
|
|
177
|
+
License Error: ${error}`
|
|
178
|
+
);
|
|
179
|
+
}
|
|
180
|
+
const metadata = new grpc.Metadata();
|
|
181
|
+
if (hasLicense) {
|
|
182
|
+
try {
|
|
183
|
+
metadata.add("x-license-key", license);
|
|
184
|
+
} catch (error2) {
|
|
185
|
+
log("Error adding license key to metadata:", error2);
|
|
186
|
+
throw new Error(`Failed to use license key: ${error2.message}`);
|
|
187
|
+
}
|
|
188
|
+
}
|
|
189
|
+
if (hasApiKey) {
|
|
190
|
+
metadata.add("x-api-key", apiKey);
|
|
191
|
+
}
|
|
192
|
+
if (this.options?.libName) {
|
|
193
|
+
metadata.add("x-library-name", this.options.libName);
|
|
194
|
+
}
|
|
195
|
+
metadata.add("x-tool-name", this.toolNameHeader);
|
|
196
|
+
const requestMetadata = JSON.stringify({
|
|
197
|
+
...meta,
|
|
198
|
+
source: "npm",
|
|
199
|
+
version: packageJson.version,
|
|
200
|
+
os: process.platform,
|
|
201
|
+
node_version: process.version
|
|
202
|
+
});
|
|
203
|
+
metadata.add("x-request-metadata", sanitizeMetadata(requestMetadata));
|
|
204
|
+
return metadata;
|
|
205
|
+
}
|
|
206
|
+
async query(params, meta) {
|
|
207
|
+
const metadata = await this.getMetadata({ meta });
|
|
208
|
+
return new Promise((resolve, reject) => {
|
|
209
|
+
this.client.query(
|
|
210
|
+
params,
|
|
211
|
+
metadata,
|
|
212
|
+
(err, response) => {
|
|
213
|
+
if (err) {
|
|
214
|
+
reject(new Error(err));
|
|
215
|
+
} else {
|
|
216
|
+
resolve(response);
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
);
|
|
220
|
+
});
|
|
221
|
+
}
|
|
222
|
+
async getApiRefMatches(params, meta) {
|
|
223
|
+
const metadata = await this.getMetadata({ meta });
|
|
224
|
+
return new Promise((resolve, reject) => {
|
|
225
|
+
this.client.getApiRefMatches(
|
|
226
|
+
params,
|
|
227
|
+
metadata,
|
|
228
|
+
(err, response) => {
|
|
229
|
+
if (err) {
|
|
230
|
+
reject(new Error(err));
|
|
231
|
+
} else {
|
|
232
|
+
resolve(response);
|
|
233
|
+
}
|
|
234
|
+
}
|
|
235
|
+
);
|
|
236
|
+
});
|
|
237
|
+
}
|
|
238
|
+
async queryCssUtils(params, meta) {
|
|
239
|
+
const metadata = await this.getMetadata({ meta });
|
|
240
|
+
return new Promise((resolve, reject) => {
|
|
241
|
+
this.client.cssUtilsSearch(
|
|
242
|
+
params,
|
|
243
|
+
metadata,
|
|
244
|
+
(err, response) => {
|
|
245
|
+
if (err) {
|
|
246
|
+
log("Error querying CSS Utils:", err);
|
|
247
|
+
reject(new Error(err));
|
|
248
|
+
} else {
|
|
249
|
+
resolve(response);
|
|
250
|
+
}
|
|
251
|
+
}
|
|
252
|
+
);
|
|
253
|
+
});
|
|
254
|
+
}
|
|
255
|
+
async queryIconsSearch(params, meta) {
|
|
256
|
+
const metadata = await this.getMetadata({ meta });
|
|
257
|
+
return new Promise((resolve, reject) => {
|
|
258
|
+
this.client.iconsSearch(params, metadata, (err, response) => {
|
|
259
|
+
if (err) {
|
|
260
|
+
log("Error querying Icons Search:", err);
|
|
261
|
+
reject(new Error(err));
|
|
262
|
+
} else {
|
|
263
|
+
resolve(response);
|
|
264
|
+
}
|
|
265
|
+
});
|
|
266
|
+
});
|
|
267
|
+
}
|
|
268
|
+
async queryBuildingBlocks(params, meta) {
|
|
269
|
+
const metadata = await this.getMetadata({ meta });
|
|
270
|
+
return new Promise((resolve, reject) => {
|
|
271
|
+
this.client.buildingBlocksSearch(
|
|
272
|
+
params,
|
|
273
|
+
metadata,
|
|
274
|
+
(err, response) => {
|
|
275
|
+
if (err) {
|
|
276
|
+
log("Error querying Building Blocks:", err);
|
|
277
|
+
reject(new Error(err));
|
|
278
|
+
} else {
|
|
279
|
+
resolve(response);
|
|
280
|
+
}
|
|
281
|
+
}
|
|
282
|
+
);
|
|
283
|
+
});
|
|
284
|
+
}
|
|
285
|
+
async validateUserLicense() {
|
|
286
|
+
const metadata = await this.getMetadata();
|
|
287
|
+
return new Promise((resolve, reject) => {
|
|
288
|
+
this.client.validateUserLicense(
|
|
289
|
+
null,
|
|
290
|
+
metadata,
|
|
291
|
+
(err, response) => {
|
|
292
|
+
if (err) {
|
|
293
|
+
log("Error validating user license:", err);
|
|
294
|
+
reject(new Error(err));
|
|
295
|
+
} else {
|
|
296
|
+
resolve(response);
|
|
297
|
+
}
|
|
298
|
+
}
|
|
299
|
+
);
|
|
300
|
+
});
|
|
301
|
+
}
|
|
302
|
+
async queryThemeGenerate(params, meta) {
|
|
303
|
+
const metadata = await this.getMetadata({ meta });
|
|
304
|
+
return new Promise((resolve, reject) => {
|
|
305
|
+
this.client.generateTheme(params, metadata, (err, response) => {
|
|
306
|
+
if (err) {
|
|
307
|
+
log("Error querying context API/GenerateTheme:", err);
|
|
308
|
+
reject(new Error(err));
|
|
309
|
+
} else {
|
|
310
|
+
resolve(response);
|
|
311
|
+
}
|
|
312
|
+
});
|
|
313
|
+
});
|
|
314
|
+
}
|
|
315
|
+
async recordOrchestratorUserRequest({ meta }) {
|
|
316
|
+
const metadata = await this.getMetadata({ meta });
|
|
317
|
+
return new Promise((resolve, reject) => {
|
|
318
|
+
this.client.recordOrchestratorUserRequest(
|
|
319
|
+
null,
|
|
320
|
+
metadata,
|
|
321
|
+
(err, response) => {
|
|
322
|
+
if (err) {
|
|
323
|
+
log("Error recording orchestrator user request:", err);
|
|
324
|
+
reject(new Error(err));
|
|
325
|
+
} else {
|
|
326
|
+
resolve(response);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
);
|
|
330
|
+
});
|
|
331
|
+
}
|
|
332
|
+
async recordToolUserRequest({ toolName, meta }) {
|
|
333
|
+
const metadata = await this.getMetadata({ meta });
|
|
334
|
+
return new Promise((resolve, reject) => {
|
|
335
|
+
this.client.recordToolUserRequest(
|
|
336
|
+
{ tool_name: toolName },
|
|
337
|
+
metadata,
|
|
338
|
+
(err, response) => {
|
|
339
|
+
if (err) {
|
|
340
|
+
log("Error recording tool user request:", err);
|
|
341
|
+
reject(new Error(err));
|
|
342
|
+
} else {
|
|
343
|
+
resolve(response);
|
|
344
|
+
}
|
|
345
|
+
}
|
|
346
|
+
);
|
|
347
|
+
});
|
|
348
|
+
}
|
|
349
|
+
async logEvent(eventName, fields) {
|
|
350
|
+
const apiKey = "h8utJ6rk4PpIWX4JMn9beQDsjVUri6KV0XYfiVwq";
|
|
351
|
+
if (!apiKey || typeof apiKey !== "string") {
|
|
352
|
+
log("LOGGING_API_KEY not configured, skipping log event");
|
|
353
|
+
return;
|
|
354
|
+
}
|
|
355
|
+
const metadata = new grpc.Metadata();
|
|
356
|
+
metadata.add("x-api-key", apiKey);
|
|
357
|
+
return new Promise((resolve, reject) => {
|
|
358
|
+
this.client.logEvent(
|
|
359
|
+
{ event_name: eventName, fields: fields || {} },
|
|
360
|
+
metadata,
|
|
361
|
+
(err, response) => {
|
|
362
|
+
if (err) {
|
|
363
|
+
log("Error logging event:", err);
|
|
364
|
+
reject(new Error(err));
|
|
365
|
+
} else {
|
|
366
|
+
resolve();
|
|
367
|
+
}
|
|
368
|
+
}
|
|
369
|
+
);
|
|
370
|
+
});
|
|
371
|
+
}
|
|
372
|
+
/**
|
|
373
|
+
* Process a Figma design through the D2C pipeline
|
|
374
|
+
*
|
|
375
|
+
* @param params - Figma design data and processing options
|
|
376
|
+
* @returns Processed design with layout, styles, and component matches
|
|
377
|
+
* @throws D2CError if processing fails
|
|
378
|
+
*/
|
|
379
|
+
async processFigmaDesign(params) {
|
|
380
|
+
const metadata = await this.getMetadata();
|
|
381
|
+
const request = {};
|
|
382
|
+
if (params.node_jsons && params.node_jsons.length > 0) {
|
|
383
|
+
request.node_jsons = params.node_jsons;
|
|
384
|
+
} else if (params.root_node_json) {
|
|
385
|
+
request.node_jsons = [params.root_node_json];
|
|
386
|
+
} else {
|
|
387
|
+
throw new Error("Either node_jsons or root_node_json must be provided");
|
|
388
|
+
}
|
|
389
|
+
return new Promise((resolve, reject) => {
|
|
390
|
+
this.client.processFigmaDesign(
|
|
391
|
+
request,
|
|
392
|
+
metadata,
|
|
393
|
+
(err, response) => {
|
|
394
|
+
if (err) {
|
|
395
|
+
log("Error processing Figma design:", err);
|
|
396
|
+
reject(new Error(`gRPC error: ${err.message}`));
|
|
397
|
+
return;
|
|
398
|
+
}
|
|
399
|
+
if (response.error) {
|
|
400
|
+
const error = new D2CError(
|
|
401
|
+
response.error.code,
|
|
402
|
+
response.error.message,
|
|
403
|
+
response.error.details
|
|
404
|
+
);
|
|
405
|
+
log("D2C processing error:", error);
|
|
406
|
+
reject(error);
|
|
407
|
+
return;
|
|
408
|
+
}
|
|
409
|
+
if (response.success) {
|
|
410
|
+
const layoutPseudoCodes = response.success.layout_pseudo_codes || [];
|
|
411
|
+
const result = {
|
|
412
|
+
// Backward compatibility: first layout or empty string
|
|
413
|
+
layout_pseudo_code: layoutPseudoCodes[0] || response.success.layout_pseudo_code || "",
|
|
414
|
+
layout_pseudo_codes: layoutPseudoCodes.length > 0 ? layoutPseudoCodes : [response.success.layout_pseudo_code || ""],
|
|
415
|
+
design_tokens: response.success.design_tokens || "",
|
|
416
|
+
stats: {
|
|
417
|
+
total_nodes: response.success.stats?.total_nodes || 0,
|
|
418
|
+
processing_time_ms: response.success.stats?.processing_time_ms || 0
|
|
419
|
+
}
|
|
420
|
+
};
|
|
421
|
+
resolve(result);
|
|
422
|
+
return;
|
|
423
|
+
}
|
|
424
|
+
reject(new Error("Invalid response format from server"));
|
|
425
|
+
}
|
|
426
|
+
);
|
|
427
|
+
});
|
|
428
|
+
}
|
|
429
|
+
};
|
|
430
|
+
|
|
431
|
+
// packages/mcp-common/src/models/user.ts
|
|
432
|
+
import { z } from "zod";
|
|
433
|
+
var userInfoSchema = z.object({
|
|
434
|
+
user_id: z.string(),
|
|
435
|
+
user_email: z.string().email()
|
|
436
|
+
});
|
|
437
|
+
|
|
438
|
+
// packages/mcp-common/src/models/entitlements.ts
|
|
439
|
+
import { z as z2 } from "zod";
|
|
440
|
+
var itemSchema = z2.object({
|
|
441
|
+
Product: z2.object({
|
|
442
|
+
Id: z2.number().int(),
|
|
443
|
+
Code: z2.string(),
|
|
444
|
+
Name: z2.string()
|
|
445
|
+
}),
|
|
446
|
+
License: z2.nullable(
|
|
447
|
+
z2.object({
|
|
448
|
+
Id: z2.number().int(),
|
|
449
|
+
Name: z2.string(),
|
|
450
|
+
Type: z2.string(),
|
|
451
|
+
Active: z2.boolean()
|
|
452
|
+
})
|
|
453
|
+
),
|
|
454
|
+
Availability: z2.array(
|
|
455
|
+
z2.object({
|
|
456
|
+
LicenseStart: z2.nullable(z2.string().datetime()),
|
|
457
|
+
LicenseEnd: z2.nullable(z2.string().datetime())
|
|
458
|
+
})
|
|
459
|
+
),
|
|
460
|
+
IsLicenseAvailable: z2.optional(z2.boolean())
|
|
461
|
+
});
|
|
462
|
+
var entitlementsSchema = z2.array(itemSchema);
|
|
463
|
+
|
|
464
|
+
// packages/mcp-common/src/lib/utils.ts
|
|
465
|
+
async function checkAccess(cb) {
|
|
466
|
+
const access = process.env.KENDO_MCP_ACCESS;
|
|
467
|
+
if (access === "true" || access === "1" || access === "full") {
|
|
468
|
+
return "full";
|
|
469
|
+
} else if (typeof access === "string" && (access.toLowerCase() === "agent" || access.toLowerCase() === "assistant")) {
|
|
470
|
+
return access.toLowerCase();
|
|
471
|
+
}
|
|
472
|
+
const productCode = await cb();
|
|
473
|
+
if (productCode.toLocaleLowerCase() === "agentic_ui_generator") {
|
|
474
|
+
return "agent";
|
|
475
|
+
}
|
|
476
|
+
if (productCode.toLocaleLowerCase() === "ai_coding_assistants") {
|
|
477
|
+
return "assistant";
|
|
478
|
+
}
|
|
479
|
+
return "none";
|
|
480
|
+
}
|
|
481
|
+
|
|
482
|
+
// packages/mcp-common/src/lib/instructions/accessibility.ts
|
|
483
|
+
function getAccessibilityGuidelines() {
|
|
484
|
+
return `**Accessibility Guidelines: WCAG 2.2 Level AA Compliance**
|
|
485
|
+
|
|
486
|
+
**Core Principles:**
|
|
487
|
+
1. Use semantic HTML and ARIA correctly
|
|
488
|
+
2. Ensure WCAG 2.2 AA compliance
|
|
489
|
+
3. Follow W3C ARIA Authoring Practices
|
|
490
|
+
4. Provide standards-based accessibility fixes
|
|
491
|
+
|
|
492
|
+
**1. Form Control Labels** (WCAG 1.3.1, 3.3.2, 4.1.2)
|
|
493
|
+
Every input must have an associated label.
|
|
494
|
+
CORRECT: \`<input type="search" aria-label="Search products" placeholder="Search...">\`
|
|
495
|
+
CORRECT: \`<label for="qty">Quantity</label><input type="number" id="qty">\`
|
|
496
|
+
WRONG: \`<span>Email</span><input type="email">\` (no association)
|
|
497
|
+
WRONG: \`<input type="email" placeholder="Email">\` (placeholder as label)
|
|
498
|
+
|
|
499
|
+
**2. Button Accessibility** (WCAG 4.1.2, 2.4.6, 2.5.3)
|
|
500
|
+
All buttons need accessible names describing their purpose.
|
|
501
|
+
CORRECT: \`<button type="button">Save Changes</button>\`
|
|
502
|
+
CORRECT: \`<button aria-label="Close dialog"><svg aria-hidden="true" focusable="false">...</svg></button>\`
|
|
503
|
+
WRONG: \`<button><svg>...</svg></button>\` (no accessible name)
|
|
504
|
+
WRONG: \`<button>Click here</button>\` (generic text)
|
|
505
|
+
|
|
506
|
+
**3. Popup/Menu Triggers** (WCAG 4.1.2, 1.3.1)
|
|
507
|
+
Indicate popup purpose and state using aria-haspopup, aria-expanded, aria-controls.
|
|
508
|
+
CORRECT: \`<button aria-expanded="false" aria-haspopup="menu" aria-controls="menu-id">Settings</button>\`
|
|
509
|
+
|
|
510
|
+
**4. Image Accessibility** (WCAG 1.1.1)
|
|
511
|
+
Informative: \`<img src="chart.png" alt="Sales increased 25% in Q4 2024">\`
|
|
512
|
+
Functional: \`<a href="/home"><img src="logo.png" alt="Company Name Home"></a>\`
|
|
513
|
+
Decorative: \`<img src="border.png" alt="" role="presentation">\`
|
|
514
|
+
Complex: \`<img src="chart.png" alt="Sales data" aria-describedby="desc-id">\`
|
|
515
|
+
WRONG: Missing alt, filename as alt, generic alt for decorative images
|
|
516
|
+
|
|
517
|
+
**5. Link Accessibility** (WCAG 2.4.4, 2.4.6)
|
|
518
|
+
Links must be descriptive and understandable out of context.
|
|
519
|
+
CORRECT: \`<a href="/products">View All Products</a>\`
|
|
520
|
+
CORRECT: \`<a href="/article" aria-label="Read more about New Product Launch">Read more</a>\`
|
|
521
|
+
WRONG: "Click here", "Read more", "Learn more" without context
|
|
522
|
+
|
|
523
|
+
**6. Form Validation** (WCAG 3.3.1, 3.3.2, 3.3.3)
|
|
524
|
+
Errors must be identified, associated with inputs, and provide suggestions. Use aria-describedby, aria-invalid="true", and role="alert".
|
|
525
|
+
|
|
526
|
+
**7. Heading Structure** (WCAG 1.3.1, 2.4.6)
|
|
527
|
+
Each page must have an \`<h1>\` that describes its content. Use hierarchical, descriptive headings with no skipped levels (h1\u2192h2\u2192h3).
|
|
528
|
+
CORRECT: \`<h1>Dashboard</h1> <h2>Sales</h2> <h3>By Region</h3>\`
|
|
529
|
+
WRONG: No \`<h1>\` on the page, or skipping levels (h1\u2192h3)
|
|
530
|
+
If a heading should look smaller than its semantic level, use CSS: \`<h2 class="text-sm">Subtitle</h2>\`
|
|
531
|
+
|
|
532
|
+
**8. Page Component Landmark Rules** (WCAG 1.3.1, 4.1.2)
|
|
533
|
+
Page components (route components) may be rendered inside a layout that already provides \`<main>\`, \`<header>\`, or \`<footer>\`. Since the layout configuration is unknown, avoid using these landmarks in page components to prevent potential duplication and nesting violations. Use \`<div>\`, \`<section>\`, or \`<article>\` as the top-level wrapper instead.
|
|
534
|
+
- Avoid adding \`<main>\`, \`role="main"\`, \`<header>\`, or \`<footer>\` in page components \u2014 the layout typically provides them. Duplicating them can cause \`landmark-no-duplicate-main\` and \`landmark-main-is-top-level\` violations.
|
|
535
|
+
- Avoid adding \`role="banner"\` or using a semantic \`<header>\` element in page components \u2014 the layout's \`<header>\` already claims the banner landmark. Adding another causes \`landmark-banner-is-top-level\` violations.
|
|
536
|
+
- Avoid adding \`role="contentinfo"\` to elements inside page components \u2014 the contentinfo landmark should be a top-level landmark, not nested inside \`<main>\` or other landmarks. Nesting it can cause \`landmark-contentinfo-is-top-level\` violations.
|
|
537
|
+
- When multiple \`<section>\` or \`<nav>\` elements exist on a page, give each a unique \`aria-label\` to avoid \`landmark-unique\` violations.
|
|
538
|
+
|
|
539
|
+
**9. ARIA Role and Attribute Restrictions** (WCAG 4.1.2)
|
|
540
|
+
Only use ARIA roles that are valid for the given HTML element. Avoid adding \`aria-label\` or \`aria-labelledby\` to elements that do not permit naming.
|
|
541
|
+
- \`<article>\` has an implicit \`article\` role. Do NOT override it with \`role="listitem"\`, \`role="button"\`, \`role="link"\`, or any other role \u2014 none are allowed on \`<article>\`. Use \`<li>\` for list items, \`<button>\` for interactive cards, or \`<a>\` for clickable cards instead.
|
|
542
|
+
- \`<button>\` already has an implicit \`button\` role. Do NOT add \`role="listitem"\` or other incompatible roles.
|
|
543
|
+
- \`<span>\` and \`<div>\` without roles are generic elements. Do NOT add \`aria-label\` to them \u2014 it is a prohibited attribute on elements with no accessible role and can cause \`aria-prohibited-attr\` violations. Instead, use \`role="img"\` + \`aria-label\` for visual indicators, or use visually hidden text.
|
|
544
|
+
- Do NOT add \`aria-label\` to non-interactive \`<div>\` wrappers \u2014 it has no effect and triggers violations.
|
|
545
|
+
- \`aria-pressed\` is only valid on elements with \`role="button"\`, \`role="checkbox"\`, \`role="menuitemcheckbox"\`, \`role="option"\`, \`role="radio"\`, or \`role="switch"\`. Do NOT use \`aria-pressed\` on elements with \`role="listitem"\` or other roles.
|
|
546
|
+
CORRECT: \`<ul role="list"><li class="product-card">...</li></ul>\` (listitem inside list)
|
|
547
|
+
CORRECT: \`<span role="img" aria-label="Status: pending" class="status-dot"></span>\` (role added before aria-label)
|
|
548
|
+
CORRECT: \`<span class="status-dot" aria-hidden="true"></span><span class="visually-hidden">Pending</span>\` (hidden text alternative)
|
|
549
|
+
WRONG: \`<article role="listitem">\` (listitem not allowed on article)
|
|
550
|
+
WRONG: \`<article role="button">\` (button not allowed on article \u2014 use \`<button>\` or \`<div role="button">\`)
|
|
551
|
+
WRONG: \`<span aria-label="pending" class="status-dot"></span>\` (aria-label prohibited on generic span)
|
|
552
|
+
WRONG: \`<div aria-label="Product badges" class="badges"></div>\` (aria-label prohibited on generic div)
|
|
553
|
+
|
|
554
|
+
**Quick Checklist:**
|
|
555
|
+
- **Forms:** Associated labels, aria-required on required fields, autocomplete attributes, aria-describedby for errors, aria-invalid for invalid fields, fieldsets with legends
|
|
556
|
+
- **Buttons/Links:** Accessible names, aria-label for icon buttons, aria-hidden on decorative icons, descriptive link text
|
|
557
|
+
- **Popups/Dialogs:** aria-haspopup, aria-expanded, aria-controls, role="dialog", aria-modal="true", aria-labelledby, focus trap, Escape to close
|
|
558
|
+
- **Images:** alt on all images, descriptive alt for informative, empty alt for decorative, aria-describedby for complex
|
|
559
|
+
- **Structure:** One h1, logical heading hierarchy, avoid \`<main>\`, \`<header>\`, \`<footer>\`, \`role="main"\`, \`role="contentinfo"\`, \`role="banner"\` in page/route components (the layout may already provide them), use \`<section>\` or \`<div>\` as page-level wrappers, unique aria-labels on duplicate landmark types
|
|
560
|
+
- **ARIA Rules:** Avoid adding \`aria-label\` to generic \`<span>\`/\`<div>\` without a role, avoid using \`role="listitem"\` or \`role="button"\` on \`<article>\` \u2014 use \`<li>\` for list items, add \`role="img"\` before \`aria-label\` on visual indicators, \`aria-pressed\` only on button-like roles
|
|
561
|
+
- **Scrollable Regions:** Any scrollable container must have \`tabindex="0"\` or contain keyboard-interactive children
|
|
562
|
+
- **Nested Interactive:** Do not add interactive role/tabindex to a container that already has focusable children
|
|
563
|
+
- **List Roles:** \`role="list"\` containers must have \`role="listitem"\` children \u2014 prefer \`<ul>/<li>\` natively
|
|
564
|
+
- **Dynamic Content:** role="status"/aria-live="polite" for updates, role="alert"/aria-live="assertive" for critical alerts
|
|
565
|
+
- **Keyboard/Focus:** All interactive elements keyboard accessible, logical focus order, visible focus indicators, no keyboard traps (except modals)
|
|
566
|
+
- **Color/Contrast:** 4.5:1 text contrast (3:1 large text), 3:1 UI component contrast, no color-only information, 3:1 focus indicator contrast`;
|
|
567
|
+
}
|
|
568
|
+
|
|
569
|
+
// packages/mcp-common/src/lib/heartbeat.ts
|
|
570
|
+
var ONE_DAY_MS = 24 * 60 * 60 * 1e3;
|
|
571
|
+
function startHeartbeat(options) {
|
|
572
|
+
const {
|
|
573
|
+
serverName,
|
|
574
|
+
contextApi: contextApi2,
|
|
575
|
+
additionalFields = {},
|
|
576
|
+
intervalMs = ONE_DAY_MS
|
|
577
|
+
} = options;
|
|
578
|
+
const eventName = `mcp_server_heartbeat`;
|
|
579
|
+
const sendHeartbeat = async () => {
|
|
580
|
+
try {
|
|
581
|
+
const fields = {
|
|
582
|
+
server_name: serverName,
|
|
583
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
584
|
+
...additionalFields
|
|
585
|
+
};
|
|
586
|
+
await contextApi2.logEvent(eventName, fields);
|
|
587
|
+
} catch (error) {
|
|
588
|
+
log(`Failed to send heartbeat for ${serverName}:`, error);
|
|
589
|
+
}
|
|
590
|
+
};
|
|
591
|
+
sendHeartbeat();
|
|
592
|
+
const intervalId = setInterval(sendHeartbeat, intervalMs);
|
|
593
|
+
return () => {
|
|
594
|
+
clearInterval(intervalId);
|
|
595
|
+
log(`Heartbeat stopped for ${serverName}`);
|
|
596
|
+
};
|
|
597
|
+
}
|
|
598
|
+
|
|
599
|
+
// packages/mcp-common/src/lib/getting-started-params.ts
|
|
600
|
+
import { z as z3 } from "zod";
|
|
601
|
+
var KendoThemes = ["default", "bootstrap", "material", "fluent"];
|
|
602
|
+
function createGettingStartedInputSchema(suiteName, defaultProjectName) {
|
|
603
|
+
return {
|
|
604
|
+
projectName: z3.string().default(defaultProjectName).describe(
|
|
605
|
+
"The name of the project. Used as the project folder name when creating a new project."
|
|
606
|
+
),
|
|
607
|
+
createNewProject: z3.boolean().default(true).describe(
|
|
608
|
+
`Whether to create a new project before configuring ${suiteName}. Set to true to scaffold a brand-new project, or false if the project already exists and you only want to add ${suiteName} to it.`
|
|
609
|
+
),
|
|
610
|
+
theme: z3.enum(KendoThemes).default("default").describe(
|
|
611
|
+
"The Kendo UI theme to use. Determines which theme package is installed and imported."
|
|
612
|
+
)
|
|
613
|
+
};
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
// packages/react/src/lib/constants.ts
|
|
617
|
+
var REACT_SUITE_NAME = "Kendo UI for React";
|
|
618
|
+
var Suite = "react";
|
|
619
|
+
var PRODUCT_LINE = "kendo";
|
|
620
|
+
var ReactComponents = [
|
|
621
|
+
"ActionSheet",
|
|
622
|
+
"AIPrompt",
|
|
623
|
+
"Animation",
|
|
624
|
+
"AppBar",
|
|
625
|
+
"ArcGauge",
|
|
626
|
+
"AutoComplete",
|
|
627
|
+
"Avatar",
|
|
628
|
+
"Badge",
|
|
629
|
+
"Barcode",
|
|
630
|
+
"BottomNavigation",
|
|
631
|
+
"Breadcrumb",
|
|
632
|
+
"Button",
|
|
633
|
+
"ButtonGroup",
|
|
634
|
+
"BreadCrumb",
|
|
635
|
+
"Calendar",
|
|
636
|
+
"Card",
|
|
637
|
+
"Chart",
|
|
638
|
+
"ChartWizard",
|
|
639
|
+
"Chat",
|
|
640
|
+
"Checkbox",
|
|
641
|
+
"Chip",
|
|
642
|
+
"ChipList",
|
|
643
|
+
"ChunkProgressBar",
|
|
644
|
+
"CircularGauge",
|
|
645
|
+
"ColorGradient",
|
|
646
|
+
"ColorPalette",
|
|
647
|
+
"ColorPicker",
|
|
648
|
+
"ComboBox",
|
|
649
|
+
"ContextMenu",
|
|
650
|
+
"ConversationalUI",
|
|
651
|
+
"DataGrid",
|
|
652
|
+
"Grid",
|
|
653
|
+
// Alias for DataGrid only used in the mcp-server
|
|
654
|
+
"DataQuery",
|
|
655
|
+
"DateMath",
|
|
656
|
+
"DateInput",
|
|
657
|
+
"DatePicker",
|
|
658
|
+
"DateRangePicker",
|
|
659
|
+
"DateTimePicker",
|
|
660
|
+
"Dialog",
|
|
661
|
+
"Drag&Drop",
|
|
662
|
+
"Drawer",
|
|
663
|
+
"Drawing",
|
|
664
|
+
"DropDownButton",
|
|
665
|
+
"DropDownList",
|
|
666
|
+
"DropDownTree",
|
|
667
|
+
"Editor",
|
|
668
|
+
"Error",
|
|
669
|
+
"ExcelExport",
|
|
670
|
+
"ExpansionPanel",
|
|
671
|
+
"ExternalDropZone",
|
|
672
|
+
"FileSaver",
|
|
673
|
+
"FileManager",
|
|
674
|
+
"Filter",
|
|
675
|
+
"FlatColorPicker",
|
|
676
|
+
"FloatingActionButton",
|
|
677
|
+
"FloatingLabel",
|
|
678
|
+
"Form",
|
|
679
|
+
"Gantt",
|
|
680
|
+
"Gauge",
|
|
681
|
+
"General",
|
|
682
|
+
"GridLayout",
|
|
683
|
+
"Hint",
|
|
684
|
+
"Icon",
|
|
685
|
+
"InlineAIPrompt",
|
|
686
|
+
"Input",
|
|
687
|
+
"Label",
|
|
688
|
+
"LinearGauge",
|
|
689
|
+
"ListBox",
|
|
690
|
+
"ListView",
|
|
691
|
+
"Loader",
|
|
692
|
+
"Map",
|
|
693
|
+
"MaskedTextBox",
|
|
694
|
+
"Menu",
|
|
695
|
+
"MultiColumnComboBox",
|
|
696
|
+
"MultiSelect",
|
|
697
|
+
"MultiSelectTree",
|
|
698
|
+
"MultiViewCalendar",
|
|
699
|
+
"Notification",
|
|
700
|
+
"NumericTextBox",
|
|
701
|
+
"OrgChart",
|
|
702
|
+
"PageTemplates/BuildingBlocks",
|
|
703
|
+
"Pager",
|
|
704
|
+
"PanelBar",
|
|
705
|
+
"PDFProcessing",
|
|
706
|
+
"PDFViewer",
|
|
707
|
+
"PivotGrid",
|
|
708
|
+
"Popover",
|
|
709
|
+
"Popup",
|
|
710
|
+
"ProgressBar",
|
|
711
|
+
"PromptBox",
|
|
712
|
+
"QRCode",
|
|
713
|
+
"RadialGauge",
|
|
714
|
+
"RadioButton",
|
|
715
|
+
"RadioGroup",
|
|
716
|
+
"RangeSlider",
|
|
717
|
+
"Rating",
|
|
718
|
+
"Ripple",
|
|
719
|
+
"Sankey",
|
|
720
|
+
"Scheduler",
|
|
721
|
+
"ScrollView",
|
|
722
|
+
"Signature",
|
|
723
|
+
"Skeleton",
|
|
724
|
+
"Slider",
|
|
725
|
+
"Sortable",
|
|
726
|
+
"Sparkline",
|
|
727
|
+
"SpeechToTextButton",
|
|
728
|
+
"SmartPasteButton",
|
|
729
|
+
"SplitButton",
|
|
730
|
+
"Splitter",
|
|
731
|
+
"Spreadsheet",
|
|
732
|
+
"StackLayout",
|
|
733
|
+
"Stepper",
|
|
734
|
+
"StockChart",
|
|
735
|
+
"SVGIcon",
|
|
736
|
+
"Switch",
|
|
737
|
+
"TabStrip",
|
|
738
|
+
"TaskBoard",
|
|
739
|
+
"TextArea",
|
|
740
|
+
"TextBox",
|
|
741
|
+
"TileLayout",
|
|
742
|
+
"Timeline",
|
|
743
|
+
"TimePicker",
|
|
744
|
+
"Toolbar",
|
|
745
|
+
"Tooltip",
|
|
746
|
+
"TreeList",
|
|
747
|
+
"TreeView",
|
|
748
|
+
"Typography",
|
|
749
|
+
"Upload",
|
|
750
|
+
"VSCodeExtension",
|
|
751
|
+
"Window"
|
|
752
|
+
];
|
|
753
|
+
|
|
754
|
+
// packages/react/src/lib/grpc-client.ts
|
|
755
|
+
var protoPath = join(
|
|
756
|
+
dirname(fileURLToPath2(import.meta.url)),
|
|
757
|
+
"../proto/service.proto"
|
|
758
|
+
);
|
|
759
|
+
var contextApi = new ContextAPI("contextapi.telerik.com:443", protoPath, {
|
|
760
|
+
libName: Suite
|
|
761
|
+
});
|
|
762
|
+
var validateUserLicense = async () => {
|
|
763
|
+
return contextApi.validateUserLicense();
|
|
764
|
+
};
|
|
765
|
+
|
|
766
|
+
// packages/react/src/index.ts
|
|
767
|
+
import fs3 from "fs";
|
|
768
|
+
import path3 from "path";
|
|
769
|
+
import { fileURLToPath as fileURLToPath3 } from "url";
|
|
770
|
+
|
|
771
|
+
// packages/kendo-ui-agent/src/lib/tools-factory.ts
|
|
772
|
+
import { z as z4 } from "zod";
|
|
773
|
+
|
|
774
|
+
// packages/kendo-ui-agent/src/lib/ui-agent-tool.ts
|
|
775
|
+
var UIAgentTool = class {
|
|
776
|
+
constructor(name, config, cb) {
|
|
777
|
+
this.name = name;
|
|
778
|
+
this.config = config;
|
|
779
|
+
this.cb = cb;
|
|
780
|
+
}
|
|
781
|
+
register(mcpServer) {
|
|
782
|
+
this.server = mcpServer;
|
|
783
|
+
this.server.registerTool(this.name, this.config, this.cb);
|
|
784
|
+
}
|
|
785
|
+
hasAccess(accessType) {
|
|
786
|
+
if (!this.config.requiredAccess || this.config.requiredAccess.length === 0) {
|
|
787
|
+
return true;
|
|
788
|
+
}
|
|
789
|
+
return accessType === "full" || this.config.requiredAccess.includes(accessType);
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
|
|
793
|
+
// packages/kendo-ui-agent/src/lib/templates/validator.ts
|
|
794
|
+
var renderValidatorResponse = (ctx, frameworkValidationSteps) => `# ${ctx.suiteName} - Code Validation & Quality Assurance
|
|
6
795
|
|
|
7
796
|
## Comprehensive Code Validation Checklist
|
|
8
797
|
Execute these validation steps systematically to ensure high-quality, maintainable code:
|
|
9
798
|
|
|
10
799
|
### Validation Phase: Framework-Specific Validation
|
|
11
800
|
|
|
12
|
-
${
|
|
801
|
+
${frameworkValidationSteps}
|
|
13
802
|
|
|
14
803
|
### Validation Phase: General Code Quality & Best Practices
|
|
15
804
|
|
|
@@ -46,45 +835,99 @@ Responsive Design:
|
|
|
46
835
|
- Graceful error handling for all user interactions
|
|
47
836
|
- Meaningful error messages for users
|
|
48
837
|
- Network error handling for API calls
|
|
49
|
-
`;
|
|
838
|
+
`;
|
|
839
|
+
|
|
840
|
+
// packages/kendo-ui-agent/src/lib/templates/orchestrator.ts
|
|
841
|
+
var responsiveKendoDesignSystemGuidance = (ctx) => `**Tool call example:**
|
|
842
|
+
\`\`\`
|
|
843
|
+
${ctx.layoutAssistantName}({
|
|
844
|
+
prompt="Provide Kendo Design System utility classes to make the following layout structure responsive across mobile, tablet, and desktop views: [LAYOUT DESCRIPTION HERE]",
|
|
845
|
+
includeBuildingBlockExamples=false // Optional, include examples of Kendo building blocks (Grid, Flex, Stack, etc.)
|
|
846
|
+
})
|
|
847
|
+
\`\`\`
|
|
848
|
+
`;
|
|
849
|
+
var vanillaCSSResponsiveGuidance = `**General Responsive Design Guidance:**
|
|
850
|
+
- Use CSS media queries to apply different styles at various breakpoints (e.g., mobile, tablet, desktop).
|
|
851
|
+
- Consider a mobile-first approach, starting with styles for smaller screens and adding complexity for larger screens.
|
|
852
|
+
- Ensure flexible grid layouts that can adapt to different screen sizes.
|
|
853
|
+
- Use relative units (%, em, rem) instead of fixed units (px) for widths and spacing to allow for better scalability.
|
|
854
|
+
- Test the design across multiple devices and screen sizes to ensure a consistent user experience.`;
|
|
855
|
+
var tailwindResponsiveGuidance = `**Tailwind CSS Responsive Design Guidance:**
|
|
856
|
+
- Use Tailwind's responsive utility variants (e.g., sm:, md:, lg:, xl:) to apply styles at specific breakpoints.
|
|
857
|
+
- Start with mobile styles (no prefix) and layer on additional styles for larger screens using the appropriate prefixes.
|
|
858
|
+
- Leverage Tailwind's grid and flex utilities to create flexible layouts that adapt to different screen sizes.
|
|
859
|
+
- Use Tailwind's spacing utilities to maintain consistent spacing across breakpoints.
|
|
860
|
+
- Test the design across multiple devices and screen sizes to ensure a consistent user experience.`;
|
|
861
|
+
var renderOrchestratorResponse = (ctx, options) => {
|
|
862
|
+
const validationInstructions = renderValidatorResponse(
|
|
863
|
+
{ suiteName: ctx.suiteName, libKey: ctx.libKey },
|
|
864
|
+
options.validationSteps
|
|
865
|
+
);
|
|
866
|
+
const includeLayout = ctx.includeLayout && ctx.layoutMode === "utils";
|
|
867
|
+
const dragDropGuidance = ctx.libKey === "angular" ? `- **Drag and Drop**: Consider using the DragandDrop and Sortable components when drag-and-drop functionality is needed.` : "";
|
|
868
|
+
const componentsList = ctx.components ? ctx.components.join(", ") : "components";
|
|
869
|
+
const responsiveLayoutHint = includeLayout ? `- And use the ${ctx.layoutAssistantName} tool to get Kendo CSS utility classes needed for responsive design.` : "";
|
|
870
|
+
const responsiveKDSGuidance = includeLayout ? responsiveKendoDesignSystemGuidance(ctx) : "";
|
|
871
|
+
const responsiveVanillaCSSGuidance = ctx.layoutMode === "vanilla" ? vanillaCSSResponsiveGuidance : "";
|
|
872
|
+
const responsiveTailwindCSSGuidance = ctx.layoutMode === "tailwind" ? tailwindResponsiveGuidance : "";
|
|
873
|
+
return `# \u{1F3AF} ${ctx.suiteName} - Execution Plan
|
|
50
874
|
|
|
51
875
|
**Current Goal:**
|
|
52
876
|
|
|
53
|
-
${
|
|
877
|
+
${ctx.userIntent}
|
|
54
878
|
|
|
55
879
|
**Requirements Summary:**
|
|
56
|
-
- **Framework:** ${
|
|
57
|
-
${
|
|
58
|
-
- Ensure to use ONLY ${
|
|
59
|
-
- And use the ${
|
|
60
|
-
- Ensure that after you read the plan you use exactly the ${
|
|
61
|
-
|
|
62
|
-
- And use the ${
|
|
63
|
-
|
|
880
|
+
- **Framework:** ${ctx.libKey}
|
|
881
|
+
${ctx.includeComponentsDocs ? `- **Component Library:** ${ctx.suiteName}
|
|
882
|
+
- Ensure to use ONLY ${ctx.suiteName} components for all UI elements.
|
|
883
|
+
- And use the ${ctx.codeAssistantName} tool to get ${ctx.suiteName} component documentation and code snippets.
|
|
884
|
+
- Ensure that after you read the plan you use exactly the ${ctx.codeAssistantName} no matter if there is another tool that can provide code snippets, documentation or other resources related to ${ctx.suiteName}.
|
|
885
|
+
` : ""}${includeLayout ? `- **Layout:** Yes
|
|
886
|
+
- And use the ${ctx.layoutAssistantName} tool to get Kendo CSS utility classes needed for layout structure and responsive design.
|
|
887
|
+
` : ""}${ctx.includeIcons ? `- **Icons:** Yes
|
|
64
888
|
- Use icons that align with the project theme and enhance usability.
|
|
65
|
-
- Use the ${
|
|
66
|
-
|
|
889
|
+
- Use the ${ctx.iconAssistantName} tool to search for icons that fit the theme and purpose of your project.
|
|
890
|
+
` : ""}${ctx.includeTheming ? `- **Custom Theming:**
|
|
67
891
|
- Create a custom theme that aligns with the current goal and branding needs.
|
|
68
892
|
- Use Kendo Themes and Design System guidelines.
|
|
69
893
|
- Make sure to include strict CSS variables or theme requirements from the current goal.
|
|
70
|
-
- And use the ${
|
|
71
|
-
|
|
894
|
+
- And use the ${ctx.styleAssistantName} tool to create a custom theme for your project.
|
|
895
|
+
` : ""}${ctx.includeResponsive ? `- **Responsive:**
|
|
72
896
|
- Ensure the layout is fully responsive across mobile, tablet, and desktop views.
|
|
73
|
-
|
|
74
|
-
|
|
897
|
+
${responsiveLayoutHint}
|
|
898
|
+
` : ""}
|
|
75
899
|
- **Accessible (WCAG 2.2 Level AA):**
|
|
76
|
-
- CRITICAL: You must call the ${
|
|
900
|
+
- CRITICAL: You must call the ${ctx.accessibilityAssistantName} tool with includeGeneralGuidelines=true on your first call to get WCAG 2.2 Level AA guidelines.
|
|
77
901
|
- For subsequent calls, use includeGeneralGuidelines=false to get only component-specific accessibility information.
|
|
78
902
|
- Ensure all components meet WCAG 2.2 Level AA standards.
|
|
79
903
|
|
|
80
|
-
${
|
|
904
|
+
${includeLayout ? `**STYLING AND LAYOUT REQUIREMENTS:**
|
|
905
|
+
**LAYOUT MODE: KENDO DESIGN SYSTEM CSS UTILITIES**
|
|
81
906
|
## CRITICAL DESIGN SYSTEM CONSTRAINTS
|
|
82
907
|
- **USE ONLY KENDO DESIGN SYSTEM UTILITIES** for ALL styling, layout, spacing, positioning, and responsive behavior
|
|
83
908
|
- Avoid custom CSS, inline styles, or other CSS framework classes
|
|
84
|
-
- The ${
|
|
909
|
+
- The ${ctx.layoutAssistantName} tool will provide the specific Kendo CSS utility classes needed
|
|
85
910
|
- All layout requirements must use Kendo utilities exclusively
|
|
911
|
+
` : ""}
|
|
912
|
+
${ctx.layoutMode === "vanilla" ? `**STYLING AND LAYOUT REQUIREMENTS:**
|
|
913
|
+
**LAYOUT MODE: VANILLA**
|
|
914
|
+
- In this mode, you should use Kendo UI components and vanilla CSS for layout and styling.
|
|
915
|
+
- Do NOT use any utility-first CSS classes (e.g., from Tailwind) for layout or styling.
|
|
916
|
+
- Focus on leveraging the built-in capabilities of Kendo UI components and writing custom CSS as needed to achieve the desired design and layout.
|
|
917
|
+
` : ""}
|
|
918
|
+
${ctx.layoutMode === "tailwind" ? `**STYLING AND LAYOUT REQUIREMENTS:**
|
|
919
|
+
**LAYOUT MODE: TAILWIND**
|
|
920
|
+
- In this mode, you should use Tailwind CSS utility classes for layout and styling.
|
|
921
|
+
- Do NOT write custom CSS or use vanilla CSS for layout or styling.
|
|
922
|
+
- Focus on leveraging Tailwind's utility-first approach to achieve the desired design and layout, while still using Kendo UI components for functionality.
|
|
923
|
+
` : ""}
|
|
924
|
+
${ctx.includeFigmaD2C ? `**DESIGN EXTRACTION FROM FIGMA FILE**
|
|
925
|
+
- You are given a Figma file URL that contains the design for the current goal. You MUST use the ${ctx.figmaD2CToolName} tool to extract design information from the Figma file.
|
|
926
|
+
- Extracted design information should be used to get information about the layout, styles, design tokens and assets that can be used within the project.
|
|
927
|
+
- The ${ctx.figmaD2CToolName} tool will output you Layout structure of the design, design tokens for CSS and any decoration and a snapshot of the design.
|
|
928
|
+
` : ""}
|
|
86
929
|
|
|
87
|
-
|
|
930
|
+
---
|
|
88
931
|
|
|
89
932
|
## Detailed Execution Plan
|
|
90
933
|
Follow these steps strictly in order to achieve a complete and polished implementation of the current goal:
|
|
@@ -96,13 +939,13 @@ Follow these steps strictly in order to achieve a complete and polished implemen
|
|
|
96
939
|
**MANDATORY REQUIREMENT:**
|
|
97
940
|
|
|
98
941
|
- Before implementing any UI components or features, you must call the accessibility assistant with general guidelines
|
|
99
|
-
- On your first call to "${
|
|
942
|
+
- On your first call to "${ctx.accessibilityAssistantName}", set "includeGeneralGuidelines=true" to get foundational WCAG 2.2 Level AA best practices
|
|
100
943
|
- These general guidelines apply to all components and must be considered throughout implementation
|
|
101
944
|
- For all subsequent calls, set "includeGeneralGuidelines=false" to get only component-specific information
|
|
102
945
|
|
|
103
946
|
**First tool call (includes general WCAG guidelines):**
|
|
104
947
|
\`\`\`
|
|
105
|
-
${
|
|
948
|
+
${ctx.accessibilityAssistantName}({
|
|
106
949
|
query="What are the accessibility requirements for [COMPONENT_NAME]?",
|
|
107
950
|
component="[COMPONENT_NAME]",
|
|
108
951
|
includeGeneralGuidelines=true // ONLY true on first call
|
|
@@ -111,11 +954,11 @@ ${e.accessibilityAssistantName}({
|
|
|
111
954
|
|
|
112
955
|
**Step 2: Get Component-Specific Accessibility Information**
|
|
113
956
|
|
|
114
|
-
For each additional ${
|
|
957
|
+
For each additional ${ctx.suiteName} component you plan to use, call the tool with "includeGeneralGuidelines=false":
|
|
115
958
|
|
|
116
959
|
**Tool call example:**
|
|
117
960
|
\`\`\`
|
|
118
|
-
${
|
|
961
|
+
${ctx.accessibilityAssistantName}({
|
|
119
962
|
query="What are the accessibility features and requirements for [COMPONENT_NAME]? Include ARIA attributes, keyboard navigation, and screen reader support.",
|
|
120
963
|
component="[COMPONENT_NAME]",
|
|
121
964
|
includeGeneralGuidelines=false // false for all calls after the first
|
|
@@ -124,13 +967,112 @@ ${e.accessibilityAssistantName}({
|
|
|
124
967
|
|
|
125
968
|
**Example:**
|
|
126
969
|
\`\`\`
|
|
127
|
-
${
|
|
970
|
+
${ctx.accessibilityAssistantName}({
|
|
128
971
|
query="How to associate the label with another component or HTML input?",
|
|
129
972
|
component="Label",
|
|
130
973
|
includeGeneralGuidelines=false
|
|
131
974
|
})
|
|
132
975
|
\`\`\`
|
|
133
|
-
|
|
976
|
+
|
|
977
|
+
${ctx.includeFigmaD2C ? `### Phase: Design Extraction and Analysis
|
|
978
|
+
|
|
979
|
+
**IMPORTANT DESIGN EXTRACTION REQUIRMENTS**
|
|
980
|
+
- Use the ${ctx.figmaD2CToolName} tool to extract design information from the provided Figma file URL.
|
|
981
|
+
- Analyze the extracted design information to identify key layout structures, components, styles, and design tokens.
|
|
982
|
+
- Use the insights from the design analysis to inform your implementation in the next phases, ensuring alignment with the original design intent.
|
|
983
|
+
- Follow ALL three extraction steps sequentially \u2014 each step is MANDATORY.
|
|
984
|
+
- Complete the verification checklist after each step before proceeding to the next.
|
|
985
|
+
|
|
986
|
+
|
|
987
|
+
**Step 1: Extract Base Design Information from Figma**
|
|
988
|
+
- Extract only base the first layer of the design to get the overall structure and layout without going too deep into details. This will help you to understand the design hierarchy and identify key components and layout patterns.
|
|
989
|
+
- Use the downloaded design snapshot to visually analyze the design and correlate it with the extracted structure. This will help you to identify which nodes correspond to which design elements and to plan your implementation accordingly.
|
|
990
|
+
- **REQUIRED OUTPUT:** After extraction, you MUST output a structured list of ALL discovered node IDs with their labels/names before proceeding to Step 2. Format this as a clear inventory that will be referenced in subsequent steps. For each node, extract the node ID from the node-id attribute of the node XML tag.
|
|
991
|
+
- **Depth escalation:** If a node at this depth shows it contains more children than can be captured (e.g., children are truncated), re-fetch that specific node with depth + 5 to ensure complete extraction.
|
|
992
|
+
|
|
993
|
+
**Tool call example:**
|
|
994
|
+
\`\`\`
|
|
995
|
+
${ctx.figmaD2CToolName}({
|
|
996
|
+
url: [Figma URL from prompt]
|
|
997
|
+
depth: 10 // Consider more depth only if the user prompt explicitly states to extract deeply.
|
|
998
|
+
})
|
|
999
|
+
\`\`\`
|
|
1000
|
+
|
|
1001
|
+
**Step 1 Completion Checklist (MUST satisfy before proceeding):**
|
|
1002
|
+
- [ ] Have I captured all top-level layout containers (headers, footers, main sections)?
|
|
1003
|
+
- [ ] Have I identified all major structural components?
|
|
1004
|
+
- [ ] Have I created and outputted a structured list of node IDs and their labels?
|
|
1005
|
+
- [ ] Have I visually analyzed the design snapshot to correlate nodes with design elements?
|
|
1006
|
+
|
|
1007
|
+
**Step 2: Extract Main Nodes Design**
|
|
1008
|
+
- Based on the initial extraction and analysis, identify the main nodes that are critical for the design implementation. These could be reusable headers, body, navigation, sidebar or footer elements that illustrate the main structure.
|
|
1009
|
+
- Use the node IDs from the node-id attribute of the node XML tag to fetch these specific nodes with more depth to capture necessary details for implementation. This targeted extraction will help you to get the relevant design information without overwhelming the process with too much data.
|
|
1010
|
+
- **Depth escalation:** If any main node shows truncated children or contains more elements than expected at the given depth, immediately re-fetch with depth + 5.
|
|
1011
|
+
|
|
1012
|
+
**Tool call example:**
|
|
1013
|
+
\`\`\`
|
|
1014
|
+
${ctx.figmaD2CToolName}({
|
|
1015
|
+
fileKey: [The fileKey extracted from Step 1]
|
|
1016
|
+
nodeIds: [Array of main node IDs identified from Step 1]
|
|
1017
|
+
depth: 10 // Deeper extraction for main nodes to capture necessary details.
|
|
1018
|
+
})
|
|
1019
|
+
\`\`\`
|
|
1020
|
+
|
|
1021
|
+
**Step 2 Completion Checklist (MUST satisfy before proceeding):**
|
|
1022
|
+
- [ ] Have I captured all interactive components (buttons, inputs, navigation elements)?
|
|
1023
|
+
- [ ] Have I identified all typography styles and text elements?
|
|
1024
|
+
- [ ] Have I extracted all color tokens and design system values?
|
|
1025
|
+
- [ ] Have I documented child node IDs that need deeper extraction in Step 3?
|
|
1026
|
+
|
|
1027
|
+
**Step 3: Extract Child Node Details (MANDATORY)**
|
|
1028
|
+
**CRITICAL:** After Step 2, you MUST proceed to Step 3. Extract ALL child nodes identified in Step 2. Do not skip this step.
|
|
1029
|
+
|
|
1030
|
+
- Extract all child nodes that were identified in Step 2 as requiring deeper analysis. These include specific components, styles, or interactions that are essential for accurate implementation.
|
|
1031
|
+
- Use the node IDs from the node-id attribute to fetch these specific child nodes with sufficient depth to capture all critical design details.
|
|
1032
|
+
- **Depth escalation:** If child nodes still show incomplete extraction (truncated elements, nested components not fully visible), re-fetch with depth + 5 until all leaf-level components are captured.
|
|
1033
|
+
|
|
1034
|
+
**Tool call example:**
|
|
1035
|
+
\`\`\`
|
|
1036
|
+
${ctx.figmaD2CToolName}({
|
|
1037
|
+
fileKey: [The fileKey extracted from Step 1]
|
|
1038
|
+
nodeIds: [Array of ALL child node IDs identified from Step 2]
|
|
1039
|
+
depth: 15 // Targeted deeper extraction for specific nodes. Increase if needed.
|
|
1040
|
+
})
|
|
1041
|
+
\`\`\`
|
|
1042
|
+
|
|
1043
|
+
**Step 3 Completion Checklist (MUST satisfy before proceeding):**
|
|
1044
|
+
- [ ] Have I captured ALL leaf-level components (buttons, icons, form inputs)?
|
|
1045
|
+
- [ ] Have I extracted all spacing, padding, and margin values?
|
|
1046
|
+
- [ ] Have I identified all border styles, shadows, and visual effects?
|
|
1047
|
+
- [ ] Are there any remaining truncated nodes? (If yes, apply depth escalation)
|
|
1048
|
+
|
|
1049
|
+
**Iterative Extraction and Stopping Condition**
|
|
1050
|
+
Continue iterating over the extraction process following these rules:
|
|
1051
|
+
- **Continue until:** (a) All leaf-level components have been captured with complete details, OR (b) You have completed 3 extraction passes \u2014 whichever comes first.
|
|
1052
|
+
- After each iteration, verify that no new child nodes require deeper extraction.
|
|
1053
|
+
- If depth escalation is needed after 3 passes, document the limitation and proceed with available data.
|
|
1054
|
+
|
|
1055
|
+
**MANDATORY: Design Extraction Verification (Complete BEFORE Code Generation Phase)**
|
|
1056
|
+
Before proceeding to any code generation or implementation phase, you MUST produce and output a verification summary containing:
|
|
1057
|
+
|
|
1058
|
+
1. **Component Inventory:** List all UI components discovered (buttons, inputs, cards, navigation elements, etc.)
|
|
1059
|
+
2. **Hierarchy Map:** Show the parent-child relationships of major layout sections
|
|
1060
|
+
3. **Design Tokens Identified:**
|
|
1061
|
+
- Colors (with hex/rgba values)
|
|
1062
|
+
- Typography (font families, sizes, weights)
|
|
1063
|
+
- Spacing values (margins, paddings, gaps)
|
|
1064
|
+
- Border styles and effects
|
|
1065
|
+
4. **Gaps and Limitations:** Explicitly state any design elements that could not be fully extracted
|
|
1066
|
+
|
|
1067
|
+
**This verification summary serves as the design specification for implementation. Do not proceed to Code Generation until this summary is complete.**
|
|
1068
|
+
|
|
1069
|
+
**Additional Extraction During Implementation:**
|
|
1070
|
+
- During the implementation phase (Code Generation), you can and should use the ${ctx.figmaD2CToolName} tool with the relevant node IDs from the node-id attributes again if you discover you need more specific design details for certain components or sections that were not captured in earlier phases.
|
|
1071
|
+
- If additional extraction is needed, apply the same depth escalation logic and verification steps.
|
|
1072
|
+
` : ""}
|
|
1073
|
+
|
|
1074
|
+
|
|
1075
|
+
${includeLayout ? `
|
|
134
1076
|
### Phase: Layout Foundation
|
|
135
1077
|
|
|
136
1078
|
**Step 1: Create Base Layout Structure**
|
|
@@ -141,16 +1083,16 @@ ${e.includeLayout?`
|
|
|
141
1083
|
|
|
142
1084
|
**Tool call example:**
|
|
143
1085
|
\`\`\`
|
|
144
|
-
${
|
|
1086
|
+
${ctx.layoutAssistantName}({
|
|
145
1087
|
prompt="Provide Kendo Design System utility classes for the following layout structure: [LAYOUT DESCRIPTION HERE]",
|
|
146
1088
|
includeBuildingBlockExamples=true // Optional, include examples of Kendo building blocks (Grid, Flex, Stack, etc.)
|
|
147
1089
|
})
|
|
148
1090
|
\`\`\`
|
|
149
|
-
|
|
150
|
-
${
|
|
1091
|
+
` : ""}
|
|
1092
|
+
${ctx.includeComponentsDocs ? `
|
|
151
1093
|
### Phase: Component Integration
|
|
152
1094
|
**Step 1: Identify and Implement Core Components**
|
|
153
|
-
Based on your current goal, analyze what other ${
|
|
1095
|
+
Based on your current goal, analyze what other ${ctx.suiteName} components are needed and implement them one by one. Here you are some appropriate components based on the different project type:
|
|
154
1096
|
|
|
155
1097
|
**Component Selection Guidelines:**
|
|
156
1098
|
- **Landing Pages**: Consider Button, Card, Form components, Layout containers, Navigation elements
|
|
@@ -158,17 +1100,17 @@ Based on your current goal, analyze what other ${e.suiteName} components are nee
|
|
|
158
1100
|
- **Data Entry**: Consider Form, TextBox, DatePicker, DropDownList, Upload, Validation components
|
|
159
1101
|
- **Content Management**: Consider Grid, Editor, TreeView, FileManager, Dialog components
|
|
160
1102
|
- **E-commerce**: Consider ListView, Card, Button, Rating, Badge, Carousel components
|
|
161
|
-
${
|
|
1103
|
+
${dragDropGuidance}
|
|
162
1104
|
|
|
163
1105
|
**IMPORTANT COMPONENT USAGE REQUIREMENTS:**
|
|
164
|
-
- Make sure to identify all necessary features related to the ${
|
|
165
|
-
- Make sure to identify specific features needed for other ${
|
|
166
|
-
- Make sure to generate a query for ${
|
|
1106
|
+
- Make sure to identify all necessary features related to the ${componentsList} based on the current goal.
|
|
1107
|
+
- Make sure to identify specific features needed for other ${ctx.suiteName} components based on the current goal.
|
|
1108
|
+
- Make sure to generate a query for ${ctx.codeAssistantName} tool for each component and call the tool for each specific feature or functionality.
|
|
167
1109
|
- Always specify the exact features you want for each component. Describe only the needed functionality, and behavior you need. Be concise and don't include any information about the use case.
|
|
168
1110
|
|
|
169
1111
|
**Tool call examples:**
|
|
170
1112
|
\`\`\`
|
|
171
|
-
${
|
|
1113
|
+
${ctx.codeAssistantName}({
|
|
172
1114
|
query="Give me information about [COMPONENT_NAME] with [SPECIFIC_FEATURES]." <!-- For example: 'Grid with paging' or 'Button with click events' or 'Chart with multiple series' -->
|
|
173
1115
|
component="[COMPONENT_NAME]" <!-- For example: 'Grid', 'Button', 'Chart', etc. -->
|
|
174
1116
|
})
|
|
@@ -176,40 +1118,33 @@ ${o}
|
|
|
176
1118
|
|
|
177
1119
|
For broad queries, break them down into specific features (e.g., paging, sorting, filtering for Grid) and call the tool separately for each feature:
|
|
178
1120
|
\`\`\`
|
|
179
|
-
${
|
|
1121
|
+
${ctx.codeAssistantName}({
|
|
180
1122
|
query="How to implement [SPECIFIC_FEATURE] in [COMPONENT_NAME]?" <!-- For example: 'paging in Grid' -->
|
|
181
1123
|
component="[COMPONENT_NAME]" <!-- For example: 'Grid', 'Button', etc. -->
|
|
182
1124
|
})
|
|
183
1125
|
\`\`\`
|
|
184
1126
|
|
|
185
1127
|
\`\`\`
|
|
186
|
-
${
|
|
1128
|
+
${ctx.codeAssistantName}({
|
|
187
1129
|
query="How to implement [SPECIFIC_FEATURE] in [COMPONENT_NAME]?" <!-- For example: 'sorting in Grid' -->
|
|
188
1130
|
component="[COMPONENT_NAME]" <!-- For example: 'Grid', 'Button', etc. -->
|
|
189
1131
|
})
|
|
190
1132
|
\`\`\`
|
|
191
1133
|
|
|
192
1134
|
\`\`\`
|
|
193
|
-
${
|
|
1135
|
+
${ctx.codeAssistantName}({
|
|
194
1136
|
query="How to implement [SPECIFIC_FEATURE] in [COMPONENT_NAME]?" <!-- For example: 'filtering in Grid' -->
|
|
195
1137
|
component="[COMPONENT_NAME]" <!-- For example: 'Grid', 'Button', etc. -->
|
|
196
1138
|
})
|
|
197
1139
|
\`\`\`
|
|
198
|
-
|
|
199
|
-
${
|
|
1140
|
+
` : ""}
|
|
1141
|
+
${ctx.includeResponsive ? `
|
|
200
1142
|
### Phase: Layout Responsive Finalization
|
|
201
1143
|
|
|
202
1144
|
**Step 1: Implement Responsive Behavior**
|
|
1145
|
+
${responsiveKDSGuidance}${responsiveVanillaCSSGuidance}${responsiveTailwindCSSGuidance}` : ""}
|
|
203
1146
|
|
|
204
|
-
|
|
205
|
-
\`\`\`
|
|
206
|
-
${e.layoutAssistantName}({
|
|
207
|
-
prompt="Provide Kendo Design System utility classes to make the following layout structure responsive across mobile, tablet, and desktop views: [LAYOUT DESCRIPTION HERE]",
|
|
208
|
-
includeBuildingBlockExamples=false // Optional, include examples of Kendo building blocks (Grid, Flex, Stack, etc.)
|
|
209
|
-
})
|
|
210
|
-
\`\`\`
|
|
211
|
-
`:""}
|
|
212
|
-
${e.includeTheming?`
|
|
1147
|
+
${ctx.includeTheming ? `
|
|
213
1148
|
**Step 2: Custom Theme Implementation**
|
|
214
1149
|
|
|
215
1150
|
**CUSTOM THEME REQUIREMENTS:**
|
|
@@ -219,13 +1154,13 @@ ${e.includeTheming?`
|
|
|
219
1154
|
|
|
220
1155
|
**Tool call example:**
|
|
221
1156
|
\`\`\`
|
|
222
|
-
${
|
|
1157
|
+
${ctx.styleAssistantName}({
|
|
223
1158
|
query="Create a custom Kendo UI theme that aligns with the following current goal and branding needs: [CURRENT GOAL HERE]. Include strict CSS variables or theme requirements as needed.",
|
|
224
1159
|
includeThemeVariables=true // Optional, include specific CSS variables for colors, typography, spacing, etc.
|
|
225
1160
|
})
|
|
226
1161
|
\`\`\`
|
|
227
|
-
|
|
228
|
-
${
|
|
1162
|
+
` : ""}
|
|
1163
|
+
${ctx.includeIcons ? `
|
|
229
1164
|
**Step 3: Iconography and Visual Enhancements**
|
|
230
1165
|
|
|
231
1166
|
**ICONOGRAPHY GUIDELINES:**
|
|
@@ -235,59 +1170,64 @@ ${e.includeIcons?`
|
|
|
235
1170
|
|
|
236
1171
|
**Tool call example:**
|
|
237
1172
|
\`\`\`
|
|
238
|
-
${
|
|
1173
|
+
${ctx.iconAssistantName}({
|
|
239
1174
|
query="Suggest icons that fit the theme and purpose of the following current goal: [CURRENT GOAL HERE]. Provide icon names and usage context.",
|
|
240
1175
|
})
|
|
241
1176
|
\`\`\`
|
|
242
|
-
|
|
1177
|
+
` : ""}
|
|
243
1178
|
### Phase: Code Generation
|
|
244
1179
|
**IMPORTANT:** Do NOT generate ANY code or create files until ALL information gathering phases (1-3) are complete.
|
|
245
1180
|
**Step 1: Generate Complete Implementation**
|
|
246
|
-
After completing all information gathering phases above, generate the complete ${
|
|
1181
|
+
After completing all information gathering phases above, generate the complete ${ctx.libKey} component/page implementation:
|
|
247
1182
|
**Code Generation Requirements:**
|
|
248
|
-
- Create complete, functional ${
|
|
249
|
-
- Include all identified ${
|
|
1183
|
+
- Create complete, functional ${ctx.libKey} components/pages
|
|
1184
|
+
- Include all identified ${ctx.suiteName} components with their configurations
|
|
250
1185
|
- Apply ALL Kendo Design System utility classes gathered from layout assistant
|
|
251
1186
|
- Implement proper component event handling and data binding
|
|
252
1187
|
- Ensure responsive behavior using Kendo utility classes
|
|
253
1188
|
- Include necessary import statements and dependencies
|
|
254
1189
|
|
|
255
|
-
${
|
|
1190
|
+
${options.injectedPlan ?? ""}
|
|
256
1191
|
|
|
257
1192
|
### Phase: Validation and Finalization
|
|
258
1193
|
|
|
259
1194
|
**Step 1: Code Validation**
|
|
260
1195
|
** CRITICAL REQUIREMENT: You MUST validate the generated UI code using this comprehensive checklist to ensure code quality and compliance:**
|
|
261
1196
|
|
|
262
|
-
${
|
|
1197
|
+
${validationInstructions}
|
|
263
1198
|
|
|
264
1199
|
**Step 2: Final Review and Testing**
|
|
265
1200
|
** Implementation Validation:**
|
|
266
|
-
${
|
|
267
|
-
- All ${
|
|
268
|
-
- Event handling and data binding operate correctly
|
|
269
|
-
${
|
|
1201
|
+
${ctx.includeComponentsDocs ? ` - Components render correctly without errors
|
|
1202
|
+
- All ${ctx.suiteName} component features function as expected
|
|
1203
|
+
- Event handling and data binding operate correctly` : ""}
|
|
1204
|
+
${ctx.includeResponsive ? `- Responsive layout works across breakpoints` : ""}
|
|
270
1205
|
|
|
271
1206
|
**Quick Fixes (if needed):**
|
|
272
1207
|
|
|
273
1208
|
After code implementation and validation you can make quick fixes as needed:
|
|
274
|
-
- Use ${
|
|
275
|
-
- Use ${
|
|
1209
|
+
- Use ${ctx.codeAssistantName} for component-specific issues
|
|
1210
|
+
- Use ${ctx.layoutAssistantName} for styling adjustments
|
|
276
1211
|
|
|
277
1212
|
+### Before You Begin
|
|
278
|
-
- When following/executing the plan call tools are defined from the same function_ecosystem/MCP_server which ${
|
|
1213
|
+
- When following/executing the plan call tools are defined from the same function_ecosystem/MCP_server which ${ctx.name} was called.
|
|
279
1214
|
- Do NOT generate or suggest any code until all tools have been used and validated responses are incorporated.
|
|
280
1215
|
- Focus on planning and sequencing.
|
|
281
1216
|
- Summarize the components, layouts, and utilities gathered.
|
|
282
|
-
- Confirm all required inputs from tools have been provided
|
|
1217
|
+
- Confirm all required inputs from tools have been provided.`;
|
|
1218
|
+
};
|
|
1219
|
+
|
|
1220
|
+
// packages/kendo-ui-agent/src/lib/templates/assistant-orchestrator.ts
|
|
1221
|
+
var renderAssistantOrchestratorResponse = (ctx) => {
|
|
1222
|
+
return `# ${ctx.suiteName} Assistant
|
|
283
1223
|
|
|
284
1224
|
**What you're looking for:**
|
|
285
1225
|
|
|
286
|
-
${
|
|
1226
|
+
${ctx.userIntent}
|
|
287
1227
|
|
|
288
1228
|
**Available Tools:**
|
|
289
|
-
- **${
|
|
290
|
-
- **${
|
|
1229
|
+
- **${ctx.codeAssistantName}** - Get component documentation, features, and usage examples
|
|
1230
|
+
- **${ctx.iconAssistantName}** - Search for icons from the Kendo icon library
|
|
291
1231
|
|
|
292
1232
|
---
|
|
293
1233
|
|
|
@@ -297,7 +1237,7 @@ Follow these steps to find the right components and resources:
|
|
|
297
1237
|
|
|
298
1238
|
### Step 1: Identify Components
|
|
299
1239
|
|
|
300
|
-
Based on your needs, consider these ${
|
|
1240
|
+
Based on your needs, consider these ${ctx.suiteName} component categories:
|
|
301
1241
|
|
|
302
1242
|
**Common Use Cases:**
|
|
303
1243
|
- **Data Display**: Grid, ListView, TreeView, Card, TileLayout
|
|
@@ -310,10 +1250,10 @@ Based on your needs, consider these ${e.suiteName} component categories:
|
|
|
310
1250
|
|
|
311
1251
|
**How to explore components:**
|
|
312
1252
|
|
|
313
|
-
Use the ${
|
|
1253
|
+
Use the ${ctx.codeAssistantName} tool to learn about specific components:
|
|
314
1254
|
|
|
315
1255
|
\`\`\`
|
|
316
|
-
${
|
|
1256
|
+
${ctx.codeAssistantName}({
|
|
317
1257
|
query: "What are the main features of [COMPONENT_NAME]?",
|
|
318
1258
|
component: "[COMPONENT_NAME]"
|
|
319
1259
|
})
|
|
@@ -321,14 +1261,14 @@ ${e.codeAssistantName}({
|
|
|
321
1261
|
|
|
322
1262
|
**Examples:**
|
|
323
1263
|
\`\`\`
|
|
324
|
-
${
|
|
1264
|
+
${ctx.codeAssistantName}({
|
|
325
1265
|
query: "How to use Grid with paging and sorting?",
|
|
326
1266
|
component: "Grid"
|
|
327
1267
|
})
|
|
328
1268
|
\`\`\`
|
|
329
1269
|
|
|
330
1270
|
\`\`\`
|
|
331
|
-
${
|
|
1271
|
+
${ctx.codeAssistantName}({
|
|
332
1272
|
query: "What features does DatePicker have?",
|
|
333
1273
|
component: "DatePicker"
|
|
334
1274
|
})
|
|
@@ -339,37 +1279,37 @@ ${e.codeAssistantName}({
|
|
|
339
1279
|
- Break complex queries into multiple calls focusing on one feature at a time
|
|
340
1280
|
- Specify the exact component name in the component parameter
|
|
341
1281
|
|
|
342
|
-
${
|
|
1282
|
+
${ctx.includeIcons ? `
|
|
343
1283
|
### Step 2: Find Icons
|
|
344
1284
|
|
|
345
|
-
Use the ${
|
|
1285
|
+
Use the ${ctx.iconAssistantName} tool to search for icons:
|
|
346
1286
|
|
|
347
1287
|
\`\`\`
|
|
348
|
-
${
|
|
1288
|
+
${ctx.iconAssistantName}({
|
|
349
1289
|
query: "Search for icons related to [YOUR THEME/PURPOSE]"
|
|
350
1290
|
})
|
|
351
1291
|
\`\`\`
|
|
352
1292
|
|
|
353
1293
|
**Examples:**
|
|
354
1294
|
\`\`\`
|
|
355
|
-
${
|
|
1295
|
+
${ctx.iconAssistantName}({
|
|
356
1296
|
query: "icons for navigation menu"
|
|
357
1297
|
})
|
|
358
1298
|
\`\`\`
|
|
359
1299
|
|
|
360
1300
|
\`\`\`
|
|
361
|
-
${
|
|
1301
|
+
${ctx.iconAssistantName}({
|
|
362
1302
|
query: "icons for user actions like edit, delete, save"
|
|
363
1303
|
})
|
|
364
1304
|
\`\`\`
|
|
365
|
-
|
|
1305
|
+
` : ""}
|
|
366
1306
|
|
|
367
1307
|
### Step 3: Review and Implement
|
|
368
1308
|
|
|
369
1309
|
After gathering information:
|
|
370
|
-
1. Review the component documentation provided by ${
|
|
371
|
-
2. Check which icons are available from ${
|
|
372
|
-
3. Use the official ${
|
|
1310
|
+
1. Review the component documentation provided by ${ctx.codeAssistantName}
|
|
1311
|
+
2. Check which icons are available from ${ctx.iconAssistantName}
|
|
1312
|
+
3. Use the official ${ctx.suiteName} documentation for detailed implementation guides
|
|
373
1313
|
4. Refer to the component examples and code snippets provided
|
|
374
1314
|
|
|
375
1315
|
---
|
|
@@ -377,144 +1317,1490 @@ After gathering information:
|
|
|
377
1317
|
## Getting Started
|
|
378
1318
|
|
|
379
1319
|
**Next Actions:**
|
|
380
|
-
1. Start by calling ${
|
|
381
|
-
2. ${
|
|
382
|
-
3. Follow the ${
|
|
1320
|
+
1. Start by calling ${ctx.codeAssistantName} for the components you need
|
|
1321
|
+
2. ${ctx.includeIcons ? `Search for icons using ${ctx.iconAssistantName}` : "Review the component documentation"}
|
|
1322
|
+
3. Follow the ${ctx.suiteName} official documentation for implementation details
|
|
383
1323
|
|
|
384
1324
|
**Important Notes:**
|
|
385
1325
|
- These tools provide documentation and guidance, not code generation
|
|
386
|
-
- Always refer to official ${
|
|
387
|
-
- Tool responses include usage examples and best practices`;
|
|
1326
|
+
- Always refer to official ${ctx.suiteName} documentation for the most up-to-date information
|
|
1327
|
+
- Tool responses include usage examples and best practices`;
|
|
1328
|
+
};
|
|
1329
|
+
|
|
1330
|
+
// packages/kendo-ui-agent/src/lib/templates/shared-validation.ts
|
|
1331
|
+
var getSharedValidationSteps = (uiLibrary, designSystem) => ({
|
|
1332
|
+
SETUP_VALIDATION: `
|
|
388
1333
|
UI Library Setup:
|
|
389
|
-
- ${
|
|
390
|
-
- ${
|
|
391
|
-
- ${
|
|
392
|
-
- Globalization and localization properly configured for ${
|
|
393
|
-
- Required ${
|
|
1334
|
+
- ${uiLibrary} modules properly imported and configured
|
|
1335
|
+
- ${uiLibrary} theme properly loaded and applied
|
|
1336
|
+
- ${uiLibrary} license properly configured
|
|
1337
|
+
- Globalization and localization properly configured for ${uiLibrary} components
|
|
1338
|
+
- Required ${uiLibrary} dependencies installed and up-to-date`,
|
|
1339
|
+
PERFORMANCE_OPTIMIZATION: `
|
|
394
1340
|
Performance Optimization:
|
|
395
1341
|
- Efficient rendering patterns to prevent unnecessary re-renders
|
|
396
|
-
- Lazy loading of ${
|
|
397
|
-
- Virtualization enabled for large datasets in ${
|
|
398
|
-
- Only required ${
|
|
399
|
-
|
|
400
|
-
|
|
1342
|
+
- Lazy loading of ${uiLibrary} components when appropriate
|
|
1343
|
+
- Virtualization enabled for large datasets in ${uiLibrary} components
|
|
1344
|
+
- Only required ${uiLibrary} modules imported and tree-shaken`,
|
|
1345
|
+
THEME_AND_STYLING: `
|
|
1346
|
+
${uiLibrary} Theme & Styling:
|
|
1347
|
+
- Prioritize the ${designSystem} Design System utilities
|
|
401
1348
|
- Avoid custom CSS or other framework classes
|
|
402
1349
|
- Do not use inline styles
|
|
403
|
-
- Consistent ${
|
|
1350
|
+
- Consistent ${uiLibrary} theme application across all components
|
|
404
1351
|
- Custom theme variables properly defined and scoped
|
|
405
|
-
- ${
|
|
406
|
-
- Brand colors integrated with ${
|
|
407
|
-
|
|
408
|
-
|
|
409
|
-
-
|
|
410
|
-
|
|
411
|
-
|
|
1352
|
+
- ${uiLibrary} icon fonts properly loaded and optimized
|
|
1353
|
+
- Brand colors integrated with ${uiLibrary} component themes`
|
|
1354
|
+
});
|
|
1355
|
+
|
|
1356
|
+
// packages/kendo-ui-agent/src/lib/templates/tailwind-bridge.ts
|
|
1357
|
+
var tailwindBridgeExample = `
|
|
1358
|
+
@import "tailwindcss/theme.css";
|
|
1359
|
+
@import "tailwindcss/preflight.css";
|
|
1360
|
+
@import "tailwindcss/utilities.css";
|
|
1361
|
+
|
|
1362
|
+
:root {
|
|
1363
|
+
/* The generated Kendo Theme CSS variables */
|
|
1364
|
+
}
|
|
1365
|
+
|
|
1366
|
+
|
|
1367
|
+
@theme inline { /* The Tailwind bridge mapping */
|
|
1368
|
+
/* Misc */
|
|
1369
|
+
--color-app-surface: var( --kendo-color-app-surface );
|
|
1370
|
+
--color-on-app-surface: var( --kendo-color-on-app-surface );
|
|
1371
|
+
--color-subtle: var( --kendo-color-subtle );
|
|
1372
|
+
--color-surface: var( --kendo-color-surface );
|
|
1373
|
+
--color-surface-alt: var( --kendo-color-surface-alt );
|
|
1374
|
+
--color-border: var( --kendo-color-border );
|
|
1375
|
+
--color-border-alt: var( --kendo-color-border-alt );
|
|
1376
|
+
/* Base */
|
|
1377
|
+
--color-base-subtle: var( --kendo-color-base-subtle );
|
|
1378
|
+
--color-base-subtle-hover: var( --kendo-color-base-subtle-hover );
|
|
1379
|
+
--color-base-subtle-active: var( --kendo-color-base-subtle-active );
|
|
1380
|
+
--color-base: var( --kendo-color-base );
|
|
1381
|
+
--color-base-hover: var( --kendo-color-base-hover );
|
|
1382
|
+
--color-base-active: var( --kendo-color-base-active );
|
|
1383
|
+
--color-base-emphasis: var( --kendo-color-base-emphasis );
|
|
1384
|
+
--color-base-on-subtle: var( --kendo-color-base-on-subtle );
|
|
1385
|
+
--color-on-base: var( --kendo-color-on-base );
|
|
1386
|
+
--color-base-on-surface: var( --kendo-color-base-on-surface );
|
|
1387
|
+
/* Primary */
|
|
1388
|
+
--color-primary-subtle: var( --kendo-color-primary-subtle );
|
|
1389
|
+
--color-primary-subtle-hover: var( --kendo-color-primary-subtle-hover );
|
|
1390
|
+
--color-primary-subtle-active: var( --kendo-color-primary-subtle-active );
|
|
1391
|
+
--color-primary: var( --kendo-color-primary );
|
|
1392
|
+
--color-primary-hover: var( --kendo-color-primary-hover );
|
|
1393
|
+
--color-primary-active: var( --kendo-color-primary-active );
|
|
1394
|
+
--color-primary-emphasis: var( --kendo-color-primary-emphasis );
|
|
1395
|
+
--color-primary-on-subtle: var( --kendo-color-primary-on-subtle );
|
|
1396
|
+
--color-on-primary: var( --kendo-color-on-primary );
|
|
1397
|
+
--color-primary-on-surface: var( --kendo-color-primary-on-surface );
|
|
1398
|
+
/* Secondary */
|
|
1399
|
+
--color-secondary-subtle: var( --kendo-color-secondary-subtle );
|
|
1400
|
+
--color-secondary-subtle-hover: var( --kendo-color-secondary-subtle-hover );
|
|
1401
|
+
--color-secondary-subtle-active: var( --kendo-color-secondary-subtle-active );
|
|
1402
|
+
--color-secondary: var( --kendo-color-secondary );
|
|
1403
|
+
--color-secondary-hover: var( --kendo-color-secondary-hover );
|
|
1404
|
+
--color-secondary-active: var( --kendo-color-secondary-active );
|
|
1405
|
+
--color-secondary-emphasis: var( --kendo-color-secondary-emphasis );
|
|
1406
|
+
--color-secondary-on-subtle: var( --kendo-color-secondary-on-subtle );
|
|
1407
|
+
--color-on-secondary: var( --kendo-color-on-secondary );
|
|
1408
|
+
--color-secondary-on-surface: var( --kendo-color-secondary-on-surface );
|
|
1409
|
+
/* Tertiary */
|
|
1410
|
+
--color-tertiary-subtle: var( --kendo-color-tertiary-subtle );
|
|
1411
|
+
--color-tertiary-subtle-hover: var( --kendo-color-tertiary-subtle-hover );
|
|
1412
|
+
--color-tertiary-subtle-active: var( --kendo-color-tertiary-subtle-active );
|
|
1413
|
+
--color-tertiary: var( --kendo-color-tertiary );
|
|
1414
|
+
--color-tertiary-hover: var( --kendo-color-tertiary-hover );
|
|
1415
|
+
--color-tertiary-active: var( --kendo-color-tertiary-active );
|
|
1416
|
+
--color-tertiary-emphasis: var( --kendo-color-tertiary-emphasis );
|
|
1417
|
+
--color-tertiary-on-subtle: var( --kendo-color-tertiary-on-subtle );
|
|
1418
|
+
--color-on-tertiary: var( --kendo-color-on-tertiary );
|
|
1419
|
+
--color-tertiary-on-surface: var( --kendo-color-tertiary-on-surface );
|
|
1420
|
+
/* Info */
|
|
1421
|
+
--color-info-subtle: var( --kendo-color-info-subtle );
|
|
1422
|
+
--color-info-subtle-hover: var( --kendo-color-info-subtle-hover );
|
|
1423
|
+
--color-info-subtle-active: var( --kendo-color-info-subtle-active );
|
|
1424
|
+
--color-info: var( --kendo-color-info );
|
|
1425
|
+
--color-info-hover: var( --kendo-color-info-hover );
|
|
1426
|
+
--color-info-active: var( --kendo-color-info-active );
|
|
1427
|
+
--color-info-emphasis: var( --kendo-color-info-emphasis );
|
|
1428
|
+
--color-info-on-subtle: var( --kendo-color-info-on-subtle );
|
|
1429
|
+
--color-on-info: var( --kendo-color-on-info );
|
|
1430
|
+
--color-info-on-surface: var( --kendo-color-info-on-surface );
|
|
1431
|
+
/* Success */
|
|
1432
|
+
--color-success-subtle: var( --kendo-color-success-subtle );
|
|
1433
|
+
--color-success-subtle-hover: var( --kendo-color-success-subtle-hover );
|
|
1434
|
+
--color-success-subtle-active: var( --kendo-color-success-subtle-active );
|
|
1435
|
+
--color-success: var( --kendo-color-success );
|
|
1436
|
+
--color-success-hover: var( --kendo-color-success-hover );
|
|
1437
|
+
--color-success-active: var( --kendo-color-success-active );
|
|
1438
|
+
--color-success-emphasis: var( --kendo-color-success-emphasis );
|
|
1439
|
+
--color-success-on-subtle: var( --kendo-color-success-on-subtle );
|
|
1440
|
+
--color-on-success: var( --kendo-color-on-success );
|
|
1441
|
+
--color-success-on-surface: var( --kendo-color-success-on-surface );
|
|
1442
|
+
/* Warning */
|
|
1443
|
+
--color-warning-subtle: var( --kendo-color-warning-subtle );
|
|
1444
|
+
--color-warning-subtle-hover: var( --kendo-color-warning-subtle-hover );
|
|
1445
|
+
--color-warning-subtle-active: var( --kendo-color-warning-subtle-active );
|
|
1446
|
+
--color-warning: var( --kendo-color-warning );
|
|
1447
|
+
--color-warning-hover: var( --kendo-color-warning-hover );
|
|
1448
|
+
--color-warning-active: var( --kendo-color-warning-active );
|
|
1449
|
+
--color-warning-emphasis: var( --kendo-color-warning-emphasis );
|
|
1450
|
+
--color-warning-on-subtle: var( --kendo-color-warning-on-subtle );
|
|
1451
|
+
--color-on-warning: var( --kendo-color-on-warning );
|
|
1452
|
+
--color-warning-on-surface: var( --kendo-color-warning-on-surface );
|
|
1453
|
+
/* Error */
|
|
1454
|
+
--color-error-subtle: var( --kendo-color-error-subtle );
|
|
1455
|
+
--color-error-subtle-hover: var( --kendo-color-error-subtle-hover );
|
|
1456
|
+
--color-error-subtle-active: var( --kendo-color-error-subtle-active );
|
|
1457
|
+
--color-error: var( --kendo-color-error );
|
|
1458
|
+
--color-error-hover: var( --kendo-color-error-hover );
|
|
1459
|
+
--color-error-active: var( --kendo-color-error-active );
|
|
1460
|
+
--color-error-emphasis: var( --kendo-color-error-emphasis );
|
|
1461
|
+
--color-error-on-subtle: var( --kendo-color-error-on-subtle );
|
|
1462
|
+
--color-on-error: var( --kendo-color-on-error );
|
|
1463
|
+
--color-error-on-surface: var( --kendo-color-error-on-surface );
|
|
1464
|
+
/* Light */
|
|
1465
|
+
--color-light-subtle: var( --kendo-color-light-subtle );
|
|
1466
|
+
--color-light-subtle-hover: var( --kendo-color-light-subtle-hover );
|
|
1467
|
+
--color-light-subtle-active: var( --kendo-color-light-subtle-active );
|
|
1468
|
+
--color-light: var( --kendo-color-light );
|
|
1469
|
+
--color-light-hover: var( --kendo-color-light-hover );
|
|
1470
|
+
--color-light-active: var( --kendo-color-light-active );
|
|
1471
|
+
--color-light-emphasis: var( --kendo-color-light-emphasis );
|
|
1472
|
+
--color-light-on-subtle: var( --kendo-color-light-on-subtle );
|
|
1473
|
+
--color-on-light: var( --kendo-color-on-light );
|
|
1474
|
+
--color-light-on-surface: var( --kendo-color-light-on-surface );
|
|
1475
|
+
/* Dark */
|
|
1476
|
+
--color-dark-subtle: var( --kendo-color-dark-subtle );
|
|
1477
|
+
--color-dark-subtle-hover: var( --kendo-color-dark-subtle-hover );
|
|
1478
|
+
--color-dark-subtle-active: var( --kendo-color-dark-subtle-active );
|
|
1479
|
+
--color-dark: var( --kendo-color-dark );
|
|
1480
|
+
--color-dark-hover: var( --kendo-color-dark-hover );
|
|
1481
|
+
--color-dark-active: var( --kendo-color-dark-active );
|
|
1482
|
+
--color-dark-emphasis: var( --kendo-color-dark-emphasis );
|
|
1483
|
+
--color-dark-on-subtle: var( --kendo-color-dark-on-subtle );
|
|
1484
|
+
--color-on-dark: var( --kendo-color-on-dark );
|
|
1485
|
+
--color-dark-on-surface: var( --kendo-color-dark-on-surface );
|
|
1486
|
+
/* Inverse */
|
|
1487
|
+
--color-inverse-subtle: var( --kendo-color-inverse-subtle );
|
|
1488
|
+
--color-inverse-subtle-hover: var( --kendo-color-inverse-subtle-hover );
|
|
1489
|
+
--color-inverse-subtle-active: var( --kendo-color-inverse-subtle-active );
|
|
1490
|
+
--color-inverse: var( --kendo-color-inverse );
|
|
1491
|
+
--color-inverse-hover: var( --kendo-color-inverse-hover );
|
|
1492
|
+
--color-inverse-active: var( --kendo-color-inverse-active );
|
|
1493
|
+
--color-inverse-emphasis: var( --kendo-color-inverse-emphasis );
|
|
1494
|
+
--color-inverse-on-subtle: var( --kendo-color-inverse-on-subtle );
|
|
1495
|
+
--color-on-inverse: var( --kendo-color-on-inverse );
|
|
1496
|
+
--color-inverse-on-surface: var( --kendo-color-inverse-on-surface );
|
|
1497
|
+
/* Series A */
|
|
1498
|
+
--color-series-a: var( --kendo-color-series-a );
|
|
1499
|
+
--color-series-a-bold: var( --kendo-color-series-a-bold );
|
|
1500
|
+
--color-series-a-bolder: var( --kendo-color-series-a-bolder );
|
|
1501
|
+
--color-series-a-subtle: var( --kendo-color-series-a-subtle );
|
|
1502
|
+
--color-series-a-subtler: var( --kendo-color-series-a-subtler );
|
|
1503
|
+
/* Series B */
|
|
1504
|
+
--color-series-b: var( --kendo-color-series-b );
|
|
1505
|
+
--color-series-b-bold: var( --kendo-color-series-b-bold );
|
|
1506
|
+
--color-series-b-bolder: var( --kendo-color-series-b-bolder );
|
|
1507
|
+
--color-series-b-subtle: var( --kendo-color-series-b-subtle );
|
|
1508
|
+
--color-series-b-subtler: var( --kendo-color-series-b-subtler );
|
|
1509
|
+
/* Series C */
|
|
1510
|
+
--color-series-c: var( --kendo-color-series-c );
|
|
1511
|
+
--color-series-c-bold: var( --kendo-color-series-c-bold );
|
|
1512
|
+
--color-series-c-bolder: var( --kendo-color-series-c-bolder );
|
|
1513
|
+
--color-series-c-subtle: var( --kendo-color-series-c-subtle );
|
|
1514
|
+
--color-series-c-subtler: var( --kendo-color-series-c-subtler );
|
|
1515
|
+
/* Series D */
|
|
1516
|
+
--color-series-d: var( --kendo-color-series-d );
|
|
1517
|
+
--color-series-d-bold: var( --kendo-color-series-d-bold );
|
|
1518
|
+
--color-series-d-bolder: var( --kendo-color-series-d-bolder );
|
|
1519
|
+
--color-series-d-subtle: var( --kendo-color-series-d-subtle );
|
|
1520
|
+
--color-series-d-subtler: var( --kendo-color-series-d-subtler );
|
|
1521
|
+
/* Series E */
|
|
1522
|
+
--color-series-e: var( --kendo-color-series-e );
|
|
1523
|
+
--color-series-e-bold: var( --kendo-color-series-e-bold );
|
|
1524
|
+
--color-series-e-bolder: var( --kendo-color-series-e-bolder );
|
|
1525
|
+
--color-series-e-subtle: var( --kendo-color-series-e-subtle );
|
|
1526
|
+
--color-series-e-subtler: var( --kendo-color-series-e-subtler );
|
|
1527
|
+
/* Series F */
|
|
1528
|
+
--color-series-f: var( --kendo-color-series-f );
|
|
1529
|
+
--color-series-f-bold: var( --kendo-color-series-f-bold );
|
|
1530
|
+
--color-series-f-bolder: var( --kendo-color-series-f-bolder );
|
|
1531
|
+
--color-series-f-subtle: var( --kendo-color-series-f-subtle );
|
|
1532
|
+
--color-series-f-subtler: var( --kendo-color-series-f-subtler );
|
|
1533
|
+
|
|
1534
|
+
/* Typography */
|
|
1535
|
+
--font-sans: var( --kendo-font-family-sans );
|
|
1536
|
+
--font-serif: var( --kendo-font-family-sans-serif );
|
|
1537
|
+
--font-mono: var( --kendo-font-family-monospace );
|
|
1538
|
+
--text-xs: var( --kendo-font-size-xs );
|
|
1539
|
+
--text-xs--line-height: var( --kendo-line-height-xs );
|
|
1540
|
+
--text-sm: var( --kendo-font-size-sm );
|
|
1541
|
+
--text-sm--line-height: var( --kendo-line-height-sm );
|
|
1542
|
+
--text-base: var( --kendo-font-size );
|
|
1543
|
+
--text-base--line-height: var( --kendo-line-height );
|
|
1544
|
+
--text-lg: var( --kendo-font-size-lg );
|
|
1545
|
+
--text-lg--line-height: var( --kendo-line-height-lg );
|
|
1546
|
+
|
|
1547
|
+
--radius-none: var( --kendo-border-radius-none );
|
|
1548
|
+
--radius-xs: var( --kendo-border-radius-xs );
|
|
1549
|
+
--radius-sm: var( --kendo-border-radius-sm );
|
|
1550
|
+
--radius-md: var( --kendo-border-radius-md );
|
|
1551
|
+
--radius-lg: var( --kendo-border-radius-lg );
|
|
1552
|
+
--radius-xl: var( --kendo-border-radius-xl );
|
|
1553
|
+
--radius-2xl: var( --kendo-border-radius-xxl );
|
|
1554
|
+
--radius-3xl: var( --kendo-border-radius-xxxl );
|
|
1555
|
+
--radius-4xl: 1.5rem;
|
|
1556
|
+
--radius-full: var( --kendo-border-radius-full );
|
|
1557
|
+
|
|
1558
|
+
/* Breakpoints */
|
|
1559
|
+
--breakpoint-sm: 576px;
|
|
1560
|
+
--breakpoint-md: 768px;
|
|
1561
|
+
--breakpoint-lg: 992px;
|
|
1562
|
+
--breakpoint-xl: 1200px;
|
|
1563
|
+
--breakpoint-2xl: 1400px;
|
|
1564
|
+
}`;
|
|
1565
|
+
|
|
1566
|
+
// packages/kendo-ui-agent/src/lib/tools-factory.ts
|
|
1567
|
+
function formatApiRefItemFromJson(rawValue, component) {
|
|
1568
|
+
let data;
|
|
1569
|
+
try {
|
|
1570
|
+
data = JSON.parse(rawValue);
|
|
1571
|
+
} catch {
|
|
1572
|
+
return rawValue;
|
|
1573
|
+
}
|
|
1574
|
+
const item = data?.Item;
|
|
1575
|
+
if (!item) {
|
|
1576
|
+
return rawValue;
|
|
1577
|
+
}
|
|
1578
|
+
const sectionParts = [];
|
|
1579
|
+
const name = item.FullName ?? item.Name ?? "";
|
|
1580
|
+
const type = item.Type ?? "";
|
|
1581
|
+
const summary = item.Summary ?? "";
|
|
1582
|
+
const syntax = item.SyntaxContent ?? "";
|
|
1583
|
+
sectionParts.push(
|
|
1584
|
+
`## API Reference Item
|
|
1585
|
+
- Name: ${name}
|
|
1586
|
+
- Type: ${type}
|
|
1587
|
+
- Summary: ${summary}
|
|
1588
|
+
- Syntax: ${syntax}`
|
|
1589
|
+
);
|
|
1590
|
+
const returnTypeItems = data.RelatedItemsByType?.["return_type"];
|
|
1591
|
+
if (returnTypeItems?.length) {
|
|
1592
|
+
const returnType = returnTypeItems[0].Text;
|
|
1593
|
+
if (returnType) {
|
|
1594
|
+
sectionParts.push(`- Return Type: ${returnType}`);
|
|
1595
|
+
}
|
|
1596
|
+
}
|
|
1597
|
+
const examples = item.Examples ?? [];
|
|
1598
|
+
if (examples.length > 0) {
|
|
1599
|
+
let exampleSection = "## Examples\n";
|
|
1600
|
+
let exampleIndex = 0;
|
|
1601
|
+
for (const example of examples) {
|
|
1602
|
+
const exComponent = (example.Component ?? "").toLowerCase();
|
|
1603
|
+
const compLower = component.toLowerCase();
|
|
1604
|
+
if (exComponent && exComponent !== compLower && exComponent !== "general") {
|
|
1605
|
+
continue;
|
|
1606
|
+
}
|
|
1607
|
+
exampleIndex += 1;
|
|
1608
|
+
const code = example.Code ?? "";
|
|
1609
|
+
exampleSection += `### Example ${exampleIndex}
|
|
412
1610
|
\`\`\`
|
|
413
|
-
${
|
|
1611
|
+
${code}
|
|
414
1612
|
\`\`\`
|
|
415
|
-
|
|
416
|
-
|
|
417
|
-
|
|
418
|
-
|
|
419
|
-
|
|
420
|
-
|
|
421
|
-
|
|
422
|
-
|
|
1613
|
+
`;
|
|
1614
|
+
}
|
|
1615
|
+
if (exampleIndex > 0) {
|
|
1616
|
+
sectionParts.push(exampleSection);
|
|
1617
|
+
}
|
|
1618
|
+
}
|
|
1619
|
+
const related = data.RelatedItemsByType ?? {};
|
|
1620
|
+
const additionalContextItems = [];
|
|
1621
|
+
for (const [relationType, relatedItems] of Object.entries(related)) {
|
|
1622
|
+
if (relationType === "return_type" || relationType === "render_fragment") {
|
|
1623
|
+
continue;
|
|
1624
|
+
}
|
|
1625
|
+
for (const relatedItem of relatedItems ?? []) {
|
|
1626
|
+
const fullName = relatedItem.FullName ?? "";
|
|
1627
|
+
const shortText = relatedItem.ShortText ?? "";
|
|
1628
|
+
additionalContextItems.push(`### ${fullName} (${relationType})
|
|
1629
|
+
${shortText}`);
|
|
1630
|
+
}
|
|
1631
|
+
}
|
|
1632
|
+
if (additionalContextItems.length > 0) {
|
|
1633
|
+
sectionParts.push("## Additional Context\n" + additionalContextItems.join("\n---\n"));
|
|
1634
|
+
}
|
|
1635
|
+
return sectionParts.join("\n\n");
|
|
1636
|
+
}
|
|
1637
|
+
var LAYOUT_MODE = process.env.KENDO_UIA_LAYOUT_MODE || "utils";
|
|
1638
|
+
function createOrchestratorTool(config, templateOptions, contextApi2) {
|
|
1639
|
+
const {
|
|
1640
|
+
name,
|
|
1641
|
+
title,
|
|
1642
|
+
description,
|
|
1643
|
+
layoutAssistantName: layoutAssistantName2,
|
|
1644
|
+
codeAssistantName: codeAssistantName2,
|
|
1645
|
+
styleAssistantName: styleAssistantName2,
|
|
1646
|
+
iconAssistantName: iconAssistantName2,
|
|
1647
|
+
accessibilityAssistantName: accessibilityAssistantName2,
|
|
1648
|
+
figmaD2CToolName: figmaD2CToolName2,
|
|
1649
|
+
suiteName,
|
|
1650
|
+
libKey,
|
|
1651
|
+
components
|
|
1652
|
+
} = config;
|
|
1653
|
+
const tool = new UIAgentTool(
|
|
1654
|
+
name,
|
|
1655
|
+
{
|
|
1656
|
+
title,
|
|
1657
|
+
description,
|
|
1658
|
+
requiredAccess: config.requiredAccess,
|
|
1659
|
+
inputSchema: {
|
|
1660
|
+
userIntent: z4.string().describe(
|
|
1661
|
+
`Detailed description and intent of what the user wants to build. Include the type of page/component, main functionality, visual requirements, and any specific ${suiteName} components you want to use.`
|
|
1662
|
+
),
|
|
1663
|
+
needsComponentsDocsConfidence: z4.number().min(0).max(1).default(1).describe(
|
|
1664
|
+
"Confidence (0-1) to include Component Documentation assistance. Default is 1."
|
|
1665
|
+
),
|
|
1666
|
+
needsLayoutConfidence: z4.number().min(0).max(1).default(0).describe(
|
|
1667
|
+
"Confidence (0-1) to include Layout assistance. Default is 0."
|
|
1668
|
+
),
|
|
1669
|
+
needsStylingConfidence: z4.number().min(0).max(1).default(0).describe(
|
|
1670
|
+
"Confidence (0-1) to include Theming/Styling assistance. Default is 0."
|
|
1671
|
+
),
|
|
1672
|
+
needsResponsiveBehaviorConfidence: z4.number().min(0).max(1).default(0).describe(
|
|
1673
|
+
"Confidence (0-1) to include Responsive Behavior assistance. Default is 0."
|
|
1674
|
+
),
|
|
1675
|
+
needsIconsConfidence: z4.number().min(0).max(1).default(0).describe(
|
|
1676
|
+
"Confidence (0-1) to include Icons assistance. Default is 0."
|
|
1677
|
+
),
|
|
1678
|
+
needsFigmaD2CConfidence: z4.boolean().describe("Whether to include Figma D2C assistance. If the prompt includes a Figma URL always make sure to set to true.").default(false),
|
|
1679
|
+
componentsNeeded: z4.array(z4.enum(components)).optional().describe(
|
|
1680
|
+
`Optional list of specific ${suiteName} components needed for the project.`
|
|
1681
|
+
)
|
|
1682
|
+
}
|
|
1683
|
+
},
|
|
1684
|
+
async ({
|
|
1685
|
+
userIntent,
|
|
1686
|
+
needsComponentsDocsConfidence,
|
|
1687
|
+
needsLayoutConfidence,
|
|
1688
|
+
needsStylingConfidence,
|
|
1689
|
+
needsResponsiveBehaviorConfidence,
|
|
1690
|
+
needsIconsConfidence,
|
|
1691
|
+
needsFigmaD2CConfidence,
|
|
1692
|
+
componentsNeeded
|
|
1693
|
+
}, { _meta }) => {
|
|
1694
|
+
log("UI Orchestrator called with:", {
|
|
1695
|
+
userIntent,
|
|
1696
|
+
needsComponentsDocsConfidence,
|
|
1697
|
+
needsLayoutConfidence,
|
|
1698
|
+
needsStylingConfidence,
|
|
1699
|
+
needsResponsiveBehaviorConfidence,
|
|
1700
|
+
needsIconsConfidence
|
|
1701
|
+
});
|
|
1702
|
+
try {
|
|
1703
|
+
await contextApi2.recordOrchestratorUserRequest({
|
|
1704
|
+
meta: {
|
|
1705
|
+
userIntent,
|
|
1706
|
+
componentsNeeded,
|
|
1707
|
+
_meta
|
|
1708
|
+
}
|
|
1709
|
+
});
|
|
1710
|
+
} catch (error) {
|
|
1711
|
+
throw getGrpcError(error);
|
|
1712
|
+
}
|
|
1713
|
+
const clientCapabilities = tool.server?.server.getClientCapabilities?.();
|
|
1714
|
+
const supportsElicitation = clientCapabilities?.elicitation;
|
|
1715
|
+
let forceIncludeCustomTheming;
|
|
1716
|
+
if (supportsElicitation && needsStylingConfidence > 0.3 && needsStylingConfidence <= 0.6) {
|
|
1717
|
+
const result = await tool.server?.server.elicitInput({
|
|
1718
|
+
message: "I was unable to determine if you need custom Kendo Theme assistant. Can you please confirm?",
|
|
1719
|
+
requestedSchema: {
|
|
1720
|
+
type: "object",
|
|
1721
|
+
properties: {
|
|
1722
|
+
includeCustomTheming: {
|
|
1723
|
+
type: "boolean",
|
|
1724
|
+
description: "Whether to include Custom Theming assistance in the workflow."
|
|
1725
|
+
}
|
|
1726
|
+
},
|
|
1727
|
+
required: ["includeCustomTheming"]
|
|
1728
|
+
}
|
|
1729
|
+
});
|
|
1730
|
+
if (result?.action === "accept" && result.content?.includeCustomTheming) {
|
|
1731
|
+
forceIncludeCustomTheming = true;
|
|
1732
|
+
}
|
|
1733
|
+
}
|
|
1734
|
+
const response = renderOrchestratorResponse(
|
|
1735
|
+
{
|
|
1736
|
+
name,
|
|
1737
|
+
userIntent,
|
|
1738
|
+
includeComponentsDocs: needsComponentsDocsConfidence > 0.3,
|
|
1739
|
+
includeTheming: needsStylingConfidence > 0.6 || !!forceIncludeCustomTheming,
|
|
1740
|
+
includeLayout: needsLayoutConfidence > 0.5,
|
|
1741
|
+
includeIcons: needsIconsConfidence > 0.6,
|
|
1742
|
+
includeResponsive: needsLayoutConfidence > 0.5 && needsResponsiveBehaviorConfidence > 0.4,
|
|
1743
|
+
includeFigmaD2C: needsFigmaD2CConfidence,
|
|
1744
|
+
layoutAssistantName: layoutAssistantName2,
|
|
1745
|
+
codeAssistantName: codeAssistantName2,
|
|
1746
|
+
styleAssistantName: styleAssistantName2,
|
|
1747
|
+
iconAssistantName: iconAssistantName2,
|
|
1748
|
+
accessibilityAssistantName: accessibilityAssistantName2,
|
|
1749
|
+
figmaD2CToolName: figmaD2CToolName2,
|
|
1750
|
+
suiteName,
|
|
1751
|
+
libKey,
|
|
1752
|
+
layoutMode: LAYOUT_MODE,
|
|
1753
|
+
components: componentsNeeded
|
|
1754
|
+
},
|
|
1755
|
+
templateOptions
|
|
1756
|
+
);
|
|
1757
|
+
return {
|
|
1758
|
+
content: [
|
|
1759
|
+
{
|
|
1760
|
+
type: "text",
|
|
1761
|
+
text: response
|
|
1762
|
+
}
|
|
1763
|
+
]
|
|
1764
|
+
};
|
|
1765
|
+
}
|
|
1766
|
+
);
|
|
1767
|
+
return tool;
|
|
1768
|
+
}
|
|
1769
|
+
function createAssistantOrchestratorTool(config, contextApi2) {
|
|
1770
|
+
const {
|
|
1771
|
+
name,
|
|
1772
|
+
title,
|
|
1773
|
+
description,
|
|
1774
|
+
iconAssistantName: iconAssistantName2,
|
|
1775
|
+
codeAssistantName: codeAssistantName2,
|
|
1776
|
+
suiteName,
|
|
1777
|
+
libKey,
|
|
1778
|
+
components
|
|
1779
|
+
} = config;
|
|
1780
|
+
const tool = new UIAgentTool(
|
|
1781
|
+
name,
|
|
1782
|
+
{
|
|
1783
|
+
title,
|
|
1784
|
+
description,
|
|
1785
|
+
inputSchema: {
|
|
1786
|
+
userIntent: z4.string().describe(
|
|
1787
|
+
`Describe what you want to build or what components you're looking for. Include the type of functionality, features, or UI elements you need from ${suiteName}.`
|
|
1788
|
+
),
|
|
1789
|
+
needsIconsConfidence: z4.number().min(0).max(1).default(0.7).describe(
|
|
1790
|
+
"Confidence (0-1) to include Icons assistance. Default is 0.7."
|
|
1791
|
+
),
|
|
1792
|
+
componentsNeeded: z4.array(z4.enum(components)).optional().describe(
|
|
1793
|
+
`Optional list of specific ${suiteName} components you want to learn about.`
|
|
1794
|
+
)
|
|
1795
|
+
},
|
|
1796
|
+
requiredAccess: config.requiredAccess
|
|
1797
|
+
},
|
|
1798
|
+
async ({
|
|
1799
|
+
userIntent,
|
|
1800
|
+
needsIconsConfidence,
|
|
1801
|
+
componentsNeeded
|
|
1802
|
+
}, { _meta }) => {
|
|
1803
|
+
log("Assistant Orchestrator called with:", {
|
|
1804
|
+
userIntent,
|
|
1805
|
+
needsIconsConfidence,
|
|
1806
|
+
componentsNeeded
|
|
1807
|
+
});
|
|
1808
|
+
try {
|
|
1809
|
+
await contextApi2.recordOrchestratorUserRequest({
|
|
1810
|
+
meta: {
|
|
1811
|
+
userIntent,
|
|
1812
|
+
componentsNeeded,
|
|
1813
|
+
_meta
|
|
1814
|
+
}
|
|
1815
|
+
});
|
|
1816
|
+
} catch (error) {
|
|
1817
|
+
throw getGrpcError(error);
|
|
1818
|
+
}
|
|
1819
|
+
const response = renderAssistantOrchestratorResponse({
|
|
1820
|
+
name,
|
|
1821
|
+
userIntent,
|
|
1822
|
+
includeComponentsDocs: true,
|
|
1823
|
+
// Always true for assistant mode
|
|
1824
|
+
includeIcons: needsIconsConfidence > 0.5,
|
|
1825
|
+
codeAssistantName: codeAssistantName2,
|
|
1826
|
+
iconAssistantName: iconAssistantName2,
|
|
1827
|
+
suiteName,
|
|
1828
|
+
libKey,
|
|
1829
|
+
components: componentsNeeded
|
|
1830
|
+
});
|
|
1831
|
+
return {
|
|
1832
|
+
content: [
|
|
1833
|
+
{
|
|
1834
|
+
type: "text",
|
|
1835
|
+
text: response
|
|
1836
|
+
}
|
|
1837
|
+
]
|
|
1838
|
+
};
|
|
1839
|
+
}
|
|
1840
|
+
);
|
|
1841
|
+
return tool;
|
|
1842
|
+
}
|
|
1843
|
+
function createLayoutAssistantTool(config, contextApi2) {
|
|
1844
|
+
const {
|
|
1845
|
+
name,
|
|
1846
|
+
title,
|
|
1847
|
+
description,
|
|
1848
|
+
suiteName: _suiteName,
|
|
1849
|
+
libKey,
|
|
1850
|
+
getPreContent
|
|
1851
|
+
} = config;
|
|
1852
|
+
return new UIAgentTool(
|
|
1853
|
+
name,
|
|
1854
|
+
{
|
|
1855
|
+
title,
|
|
1856
|
+
description,
|
|
1857
|
+
requiredAccess: LAYOUT_MODE === "utils" ? config.requiredAccess : ["none"],
|
|
1858
|
+
inputSchema: {
|
|
1859
|
+
prompt: z4.string().describe(
|
|
1860
|
+
`An enhanced prompt describing the HTML layout structure, design requirements or specific visual effects you want to achieve.`
|
|
1861
|
+
),
|
|
1862
|
+
includeBuildingBlockExamples: z4.boolean().describe(
|
|
1863
|
+
"Whether to include building block examples. Defaults to false."
|
|
1864
|
+
).default(false)
|
|
1865
|
+
}
|
|
1866
|
+
},
|
|
1867
|
+
async ({ prompt, includeBuildingBlockExamples }, { _meta }) => {
|
|
1868
|
+
log("Layout Assistant called with:", {
|
|
1869
|
+
prompt,
|
|
1870
|
+
includeBuildingBlockExamples
|
|
1871
|
+
});
|
|
1872
|
+
try {
|
|
1873
|
+
const cssResponse = await contextApi2.queryCssUtils({ query: prompt }, { _meta });
|
|
1874
|
+
let finalMarkdown = cssResponse.values.join("\n") || "No CSS utilities found for the given prompt.";
|
|
1875
|
+
const preContent = getPreContent?.() ?? "";
|
|
1876
|
+
const buildLayout = (buildingBlockMd) => {
|
|
1877
|
+
return `${preContent}
|
|
423
1878
|
|
|
424
1879
|
# Kendo Design System CSS Utilities
|
|
425
1880
|
|
|
426
|
-
${
|
|
427
|
-
${
|
|
428
|
-
`;
|
|
1881
|
+
${finalMarkdown}
|
|
1882
|
+
${buildingBlockMd ?? ""}
|
|
1883
|
+
`;
|
|
1884
|
+
};
|
|
1885
|
+
if (includeBuildingBlockExamples) {
|
|
1886
|
+
try {
|
|
1887
|
+
const buildingBlocksResponse = await contextApi2.queryBuildingBlocks({
|
|
1888
|
+
query: prompt,
|
|
1889
|
+
lib_name: libKey
|
|
1890
|
+
}, { _meta });
|
|
1891
|
+
let buildingBlockMd = "";
|
|
1892
|
+
if (buildingBlocksResponse.items?.length > 0) {
|
|
1893
|
+
buildingBlockMd = `
|
|
429
1894
|
## Building Blocks Examples
|
|
430
1895
|
|
|
431
1896
|
The examples here are for demonstration purpose how CSS utils can be implemented in various building blocks.
|
|
432
1897
|
However, consider your own design requirements and specifics in order to implement your templates/building blocks correctly.
|
|
433
1898
|
|
|
434
|
-
${
|
|
435
|
-
|
|
1899
|
+
${buildingBlocksResponse.items.map(
|
|
1900
|
+
(item) => `
|
|
1901
|
+
### ${item.name}
|
|
436
1902
|
|
|
437
|
-
${
|
|
1903
|
+
${item.description}
|
|
438
1904
|
|
|
439
1905
|
\`\`\`code
|
|
440
|
-
${
|
|
1906
|
+
${item.code}
|
|
441
1907
|
\`\`\`
|
|
442
|
-
`
|
|
443
|
-
|
|
444
|
-
|
|
445
|
-
|
|
1908
|
+
`
|
|
1909
|
+
).join("\n")}`;
|
|
1910
|
+
}
|
|
1911
|
+
finalMarkdown = buildLayout(buildingBlockMd);
|
|
1912
|
+
} catch (buildingBlockError) {
|
|
1913
|
+
log("Error calling building-blocks service:", buildingBlockError);
|
|
1914
|
+
finalMarkdown = buildLayout();
|
|
1915
|
+
}
|
|
1916
|
+
} else {
|
|
1917
|
+
finalMarkdown = buildLayout();
|
|
1918
|
+
}
|
|
1919
|
+
return {
|
|
1920
|
+
content: [
|
|
1921
|
+
{
|
|
1922
|
+
type: "text",
|
|
1923
|
+
text: finalMarkdown
|
|
1924
|
+
}
|
|
1925
|
+
]
|
|
1926
|
+
};
|
|
1927
|
+
} catch (error) {
|
|
1928
|
+
throw getGrpcError(error);
|
|
1929
|
+
}
|
|
1930
|
+
}
|
|
1931
|
+
);
|
|
1932
|
+
}
|
|
1933
|
+
function createStyleAssistantTool(config, contextApi2) {
|
|
1934
|
+
const { name, title, description, libKey: _libKey, getPreContent } = config;
|
|
1935
|
+
return new UIAgentTool(
|
|
1936
|
+
name,
|
|
1937
|
+
{
|
|
1938
|
+
title,
|
|
1939
|
+
description,
|
|
1940
|
+
requiredAccess: config.requiredAccess,
|
|
1941
|
+
inputSchema: {
|
|
1942
|
+
prompt: z4.string().describe(
|
|
1943
|
+
`A natural language description of the desired visual style or theme. For example: 'Create a modern dark theme with high contrast'.`
|
|
1944
|
+
)
|
|
1945
|
+
}
|
|
1946
|
+
},
|
|
1947
|
+
async ({ prompt }, { _meta }) => {
|
|
1948
|
+
log("Style Assistant called with:", { prompt });
|
|
1949
|
+
let formattedCSS = "";
|
|
1950
|
+
try {
|
|
1951
|
+
const result = await contextApi2.queryThemeGenerate({ prompt }, { _meta });
|
|
1952
|
+
if (result.variables_json) {
|
|
1953
|
+
const theme = JSON.parse(result.variables_json);
|
|
1954
|
+
let cssBlocks = [];
|
|
1955
|
+
if (theme) {
|
|
1956
|
+
for (const key of Object.keys(theme)) {
|
|
1957
|
+
if (typeof theme[key] === "string") {
|
|
1958
|
+
cssBlocks.push(`${key}: ${theme[key]}`);
|
|
1959
|
+
}
|
|
1960
|
+
}
|
|
1961
|
+
}
|
|
1962
|
+
formattedCSS = cssBlocks.join("\n\n");
|
|
1963
|
+
}
|
|
1964
|
+
} catch (error) {
|
|
1965
|
+
throw getGrpcError(error);
|
|
1966
|
+
}
|
|
1967
|
+
const preContent = getPreContent?.() ?? "";
|
|
1968
|
+
const response = formattedCSS ? `Use the following CSS variables to style the web application, including colors, typography, spacing, and component appearance.
|
|
446
1969
|
Ensure the variables are applied consistently across all relevant elements.
|
|
447
1970
|
Do NOT set any inline styles. CSS variables should be defined in global or component-level CSS files, or via supported theming mechanisms.
|
|
448
1971
|
|
|
449
|
-
${
|
|
1972
|
+
${preContent}
|
|
450
1973
|
|
|
451
1974
|
## Generated CSS Variables
|
|
452
1975
|
|
|
453
1976
|
\`\`\`css
|
|
454
|
-
${
|
|
1977
|
+
${formattedCSS}
|
|
455
1978
|
\`\`\`
|
|
456
|
-
|
|
457
|
-
|
|
458
|
-
|
|
459
|
-
|
|
460
|
-
|
|
461
|
-
|
|
462
|
-
|
|
463
|
-
|
|
464
|
-
|
|
465
|
-
|
|
466
|
-
|
|
467
|
-
|
|
468
|
-
|
|
1979
|
+
` : "No CSS variables were generated for the given prompt.";
|
|
1980
|
+
return {
|
|
1981
|
+
content: [
|
|
1982
|
+
{
|
|
1983
|
+
type: "text",
|
|
1984
|
+
text: response
|
|
1985
|
+
},
|
|
1986
|
+
LAYOUT_MODE === "tailwind" ? {
|
|
1987
|
+
type: "text",
|
|
1988
|
+
text: `Note: For layout and spacing, use Tailwind CSS utility classes to structure your layout and apply spacing between elements.
|
|
1989
|
+
IMPORTANT: In order to use the Kendo Theme CSS variables to work in a Tailwind CSS project, make sure to configure Tailwind to allow custom CSS properties and use the generated CSS variables in your Tailwind configuration for colors, spacing, etc. This way you can leverage the design tokens generated by the Style Assistant while using Tailwind for layout and utility classes. Follow the tailwind_bridge_example provided as insperation for how to bridge Kendo Theme CSS variables with Tailwind CSS.
|
|
1990
|
+
|
|
1991
|
+
<taiwind_bridge_example>
|
|
1992
|
+
${tailwindBridgeExample}
|
|
1993
|
+
</taiwind_bridge_example>
|
|
1994
|
+
`
|
|
1995
|
+
} : LAYOUT_MODE === "vanilla" ? {
|
|
1996
|
+
type: "text",
|
|
1997
|
+
text: "Note: For layout and spacing, use vanilla CSS with custom styles including flexbox, grid, media queries, and relative units. Do NOT use any CSS utility framework classes."
|
|
1998
|
+
} : {
|
|
1999
|
+
type: "text",
|
|
2000
|
+
text: "Note: For layout and spacing, use the Layout Assistant tool to get the appropriate Kendo CSS utility classes."
|
|
2001
|
+
}
|
|
2002
|
+
]
|
|
2003
|
+
};
|
|
2004
|
+
}
|
|
2005
|
+
);
|
|
2006
|
+
}
|
|
2007
|
+
function createIconSearchTool(config, contextApi2) {
|
|
2008
|
+
const { name, title, description, libKey: _libKey, getPostContent } = config;
|
|
2009
|
+
return new UIAgentTool(
|
|
2010
|
+
name,
|
|
2011
|
+
{
|
|
2012
|
+
title,
|
|
2013
|
+
description,
|
|
2014
|
+
requiredAccess: config.requiredAccess,
|
|
2015
|
+
inputSchema: {
|
|
2016
|
+
query: z4.string().describe(
|
|
2017
|
+
"A search query for finding icons. Be specific about the icon purpose, style, or action."
|
|
2018
|
+
),
|
|
2019
|
+
limit: z4.number().min(0.1).max(1).default(0.1).describe(
|
|
2020
|
+
`The proportion of matching icons to return (0.1 = 1 icon, 0.5 = 5 icons, 1.0 = many icons). Default is 0.1.`
|
|
2021
|
+
)
|
|
2022
|
+
}
|
|
2023
|
+
},
|
|
2024
|
+
async ({ query, limit }, { _meta }) => {
|
|
2025
|
+
log("Icon Search called with:", { query, limit });
|
|
2026
|
+
try {
|
|
2027
|
+
const result = await contextApi2.queryIconsSearch({
|
|
2028
|
+
query,
|
|
2029
|
+
limit: limit * 100
|
|
2030
|
+
}, { _meta });
|
|
2031
|
+
const postContent = getPostContent?.() ?? "";
|
|
2032
|
+
const response = `${result.values.join("\n\n")}
|
|
2033
|
+
|
|
2034
|
+
${postContent}`;
|
|
2035
|
+
return {
|
|
2036
|
+
content: [
|
|
2037
|
+
{
|
|
2038
|
+
type: "text",
|
|
2039
|
+
text: response
|
|
2040
|
+
}
|
|
2041
|
+
]
|
|
2042
|
+
};
|
|
2043
|
+
} catch (error) {
|
|
2044
|
+
throw getGrpcError(error);
|
|
2045
|
+
}
|
|
2046
|
+
}
|
|
2047
|
+
);
|
|
2048
|
+
}
|
|
2049
|
+
function createCodeAssistantTool(config, contextApi2) {
|
|
2050
|
+
const {
|
|
2051
|
+
name,
|
|
2052
|
+
title,
|
|
2053
|
+
description,
|
|
2054
|
+
libKey,
|
|
2055
|
+
suiteName: _suiteName,
|
|
2056
|
+
components,
|
|
2057
|
+
componentAliases,
|
|
2058
|
+
getPostContent
|
|
2059
|
+
} = config;
|
|
2060
|
+
return new UIAgentTool(
|
|
2061
|
+
name,
|
|
2062
|
+
{
|
|
2063
|
+
title,
|
|
2064
|
+
description,
|
|
2065
|
+
requiredAccess: config.requiredAccess,
|
|
2066
|
+
inputSchema: {
|
|
2067
|
+
query: z4.string().describe("The query to search for."),
|
|
2068
|
+
component: z4.enum(components).describe(
|
|
2069
|
+
"The component to search for. If not specified, use General."
|
|
2070
|
+
)
|
|
2071
|
+
}
|
|
2072
|
+
},
|
|
2073
|
+
async ({ query, component }, { _meta }) => {
|
|
2074
|
+
log("Code Assistant called with:", { query, component });
|
|
2075
|
+
let resolvedComponent = component;
|
|
2076
|
+
if (componentAliases) {
|
|
2077
|
+
const alias = componentAliases[component];
|
|
2078
|
+
if (alias) {
|
|
2079
|
+
resolvedComponent = alias;
|
|
2080
|
+
}
|
|
2081
|
+
}
|
|
2082
|
+
try {
|
|
2083
|
+
const response = await contextApi2.query({
|
|
2084
|
+
query,
|
|
2085
|
+
component: resolvedComponent?.toLowerCase() ?? "general",
|
|
2086
|
+
lib_name: libKey,
|
|
2087
|
+
text_matches_count: 3,
|
|
2088
|
+
code_matches_count: 0,
|
|
2089
|
+
allowed_types: ["documentation"]
|
|
2090
|
+
}, { _meta });
|
|
2091
|
+
const cleanedValues = response.values.map(
|
|
2092
|
+
(val) => val.replace(/\0/g, "")
|
|
2093
|
+
);
|
|
2094
|
+
const postContent = getPostContent?.({ component }) ?? "";
|
|
2095
|
+
const combinedResponse = `${cleanedValues.join("\n\n")}
|
|
2096
|
+
|
|
2097
|
+
${postContent}`;
|
|
2098
|
+
return {
|
|
2099
|
+
content: [
|
|
2100
|
+
{
|
|
2101
|
+
type: "text",
|
|
2102
|
+
text: combinedResponse
|
|
2103
|
+
}
|
|
2104
|
+
]
|
|
2105
|
+
};
|
|
2106
|
+
} catch (error) {
|
|
2107
|
+
throw getGrpcError(error);
|
|
2108
|
+
}
|
|
2109
|
+
}
|
|
2110
|
+
);
|
|
2111
|
+
}
|
|
2112
|
+
function createAccessibilityAssistantTool(config, contextApi2) {
|
|
2113
|
+
const {
|
|
2114
|
+
name,
|
|
2115
|
+
title,
|
|
2116
|
+
description,
|
|
2117
|
+
libKey,
|
|
2118
|
+
suiteName: _suiteName,
|
|
2119
|
+
components,
|
|
2120
|
+
componentAliases
|
|
2121
|
+
} = config;
|
|
2122
|
+
return new UIAgentTool(
|
|
2123
|
+
name,
|
|
2124
|
+
{
|
|
2125
|
+
title,
|
|
2126
|
+
description,
|
|
2127
|
+
requiredAccess: config.requiredAccess,
|
|
2128
|
+
inputSchema: {
|
|
2129
|
+
query: z4.string().describe("The query to search for."),
|
|
2130
|
+
component: z4.enum(components).describe(
|
|
2131
|
+
"The component to search for. If not specified, use General."
|
|
2132
|
+
),
|
|
2133
|
+
includeGeneralGuidelines: z4.boolean().default(false).describe(
|
|
2134
|
+
"Set to true only on the first call to include comprehensive WCAG 2.2 Level AA general guidelines. After the first call, set to false to get only component-specific accessibility information. Default is false."
|
|
2135
|
+
)
|
|
2136
|
+
}
|
|
2137
|
+
},
|
|
2138
|
+
async ({ query, component, includeGeneralGuidelines }, { _meta }) => {
|
|
2139
|
+
log("Accessibility Assistant called with:", {
|
|
2140
|
+
query,
|
|
2141
|
+
component,
|
|
2142
|
+
includeGeneralGuidelines
|
|
2143
|
+
});
|
|
2144
|
+
let resolvedComponent = component;
|
|
2145
|
+
if (componentAliases) {
|
|
2146
|
+
const alias = componentAliases[component];
|
|
2147
|
+
if (alias) {
|
|
2148
|
+
resolvedComponent = alias;
|
|
2149
|
+
}
|
|
2150
|
+
}
|
|
2151
|
+
try {
|
|
2152
|
+
let finalResponse = "";
|
|
2153
|
+
if (includeGeneralGuidelines) {
|
|
2154
|
+
const generalGuidelines = getAccessibilityGuidelines();
|
|
2155
|
+
finalResponse += "# WCAG 2.2 Level AA General Accessibility Guidelines\n\n";
|
|
2156
|
+
finalResponse += generalGuidelines;
|
|
2157
|
+
finalResponse += "\n\n---\n\n";
|
|
2158
|
+
}
|
|
2159
|
+
const response = await contextApi2.getApiRefMatches({
|
|
2160
|
+
query,
|
|
2161
|
+
component: resolvedComponent?.toLowerCase() ?? "general",
|
|
2162
|
+
lib_name: libKey,
|
|
2163
|
+
filters_json: '{"type":{"$in":["accessibility"]}}'
|
|
2164
|
+
}, { _meta });
|
|
2165
|
+
const cleanedValues = response.values.map(
|
|
2166
|
+
(val) => val.replace(/\0/g, "")
|
|
2167
|
+
);
|
|
2168
|
+
const formattedValues = cleanedValues.map(
|
|
2169
|
+
(val) => formatApiRefItemFromJson(val, resolvedComponent?.toLowerCase() ?? "general")
|
|
2170
|
+
);
|
|
2171
|
+
const componentResult = formattedValues.join("\n\n");
|
|
2172
|
+
if (componentResult) {
|
|
2173
|
+
if (includeGeneralGuidelines) {
|
|
2174
|
+
finalResponse += "# Component-Specific Accessibility Information\n\n";
|
|
2175
|
+
}
|
|
2176
|
+
finalResponse += componentResult;
|
|
2177
|
+
} else if (!includeGeneralGuidelines) {
|
|
2178
|
+
finalResponse = "No component-specific accessibility guidelines found.";
|
|
2179
|
+
}
|
|
2180
|
+
return {
|
|
2181
|
+
content: [
|
|
2182
|
+
{
|
|
2183
|
+
type: "text",
|
|
2184
|
+
text: finalResponse
|
|
2185
|
+
}
|
|
2186
|
+
]
|
|
2187
|
+
};
|
|
2188
|
+
} catch (error) {
|
|
2189
|
+
throw getGrpcError(error);
|
|
2190
|
+
}
|
|
2191
|
+
}
|
|
2192
|
+
);
|
|
2193
|
+
}
|
|
2194
|
+
function getGrpcError(error) {
|
|
2195
|
+
const errorObj = error;
|
|
2196
|
+
if (errorObj.code === 16 /* UNAUTHENTICATED */) {
|
|
2197
|
+
return new Error(
|
|
2198
|
+
"Error: You are not authenticated. Please verify the Telerik License Key provided is valid."
|
|
2199
|
+
);
|
|
2200
|
+
} else if (errorObj.code === 8 /* RESOURCE_EXHAUSTED */) {
|
|
2201
|
+
return new Error(
|
|
2202
|
+
`Error: You have exceeded the extension quota. Upgrade to subscription licensing to unlock full access. Message: ${errorObj.message}.`
|
|
2203
|
+
);
|
|
2204
|
+
} else if (errorObj.code === 7 /* PERMISSION_DENIED */) {
|
|
2205
|
+
return new Error(
|
|
2206
|
+
"Error: You do not have permission to access this resource. Please verify that you have a valid license."
|
|
2207
|
+
);
|
|
2208
|
+
} else {
|
|
2209
|
+
return new Error(
|
|
2210
|
+
`Error: An error occurred while calling the service. Please try again later.
|
|
2211
|
+
|
|
2212
|
+
Error Code: ${errorObj.code} Error Message: ${errorObj.message}`
|
|
2213
|
+
);
|
|
2214
|
+
}
|
|
2215
|
+
}
|
|
469
2216
|
|
|
470
|
-
|
|
2217
|
+
// packages/kendo-ui-agent/src/lib/figma-d2c/types.ts
|
|
2218
|
+
var FigmaAPIError = class extends Error {
|
|
2219
|
+
constructor(status, body) {
|
|
2220
|
+
super(`Figma API error ${status}: ${body}`);
|
|
2221
|
+
this.status = status;
|
|
2222
|
+
this.body = body;
|
|
2223
|
+
this.name = "FigmaAPIError";
|
|
2224
|
+
}
|
|
2225
|
+
};
|
|
2226
|
+
|
|
2227
|
+
// packages/kendo-ui-agent/src/lib/figma-d2c/figma-client.ts
|
|
2228
|
+
var FigmaClient = class {
|
|
2229
|
+
constructor(apiKey) {
|
|
2230
|
+
this.retryConfig = {
|
|
2231
|
+
maxRetries: 3,
|
|
2232
|
+
baseDelayMs: 1e3,
|
|
2233
|
+
maxDelayMs: 3e4
|
|
2234
|
+
};
|
|
2235
|
+
this.apiKey = apiKey;
|
|
2236
|
+
}
|
|
2237
|
+
/**
|
|
2238
|
+
* Fetch file metadata including node and component counts
|
|
2239
|
+
*/
|
|
2240
|
+
async getFileMeta(fileKey) {
|
|
2241
|
+
const fileResponse = await this.getFile(fileKey, { depth: 1 });
|
|
2242
|
+
const counts = this.countNodesAndComponents(fileResponse.document);
|
|
2243
|
+
return {
|
|
2244
|
+
nodeCount: counts.nodes,
|
|
2245
|
+
componentCount: counts.components
|
|
2246
|
+
};
|
|
2247
|
+
}
|
|
2248
|
+
/**
|
|
2249
|
+
* Fetch a specific file with optional depth parameter
|
|
2250
|
+
*/
|
|
2251
|
+
async getFile(fileKey, options) {
|
|
2252
|
+
const url = this.buildFileUrl(fileKey, options);
|
|
2253
|
+
return this.fetchWithRetry(url);
|
|
2254
|
+
}
|
|
2255
|
+
/**
|
|
2256
|
+
* Fetch specific nodes by ID
|
|
2257
|
+
*/
|
|
2258
|
+
async getNodes(fileKey, nodeIds, options) {
|
|
2259
|
+
const url = this.buildNodesUrl(fileKey, nodeIds, options);
|
|
2260
|
+
return this.fetchWithRetry(url);
|
|
2261
|
+
}
|
|
2262
|
+
/**
|
|
2263
|
+
* Get export URLs for node images
|
|
2264
|
+
*/
|
|
2265
|
+
async getImages(fileKey, nodeIds, options) {
|
|
2266
|
+
const url = this.buildImagesUrl(fileKey, nodeIds, options);
|
|
2267
|
+
return this.fetchWithRetry(url);
|
|
2268
|
+
}
|
|
2269
|
+
/**
|
|
2270
|
+
* Get download URLs for embedded image fills
|
|
2271
|
+
* Returns a map of imageRef hashes to temporary S3 download URLs
|
|
2272
|
+
*/
|
|
2273
|
+
async getImageFills(fileKey) {
|
|
2274
|
+
const url = `https://api.figma.com/v1/files/${fileKey}/images`;
|
|
2275
|
+
return this.fetchWithRetry(url);
|
|
2276
|
+
}
|
|
2277
|
+
/**
|
|
2278
|
+
* Core fetch method with retry logic
|
|
2279
|
+
*/
|
|
2280
|
+
async fetchWithRetry(url) {
|
|
2281
|
+
let lastError = null;
|
|
2282
|
+
for (let attempt = 0; attempt < this.retryConfig.maxRetries; attempt++) {
|
|
2283
|
+
try {
|
|
2284
|
+
const response = await fetch(url, {
|
|
2285
|
+
headers: {
|
|
2286
|
+
"X-Figma-Token": this.apiKey,
|
|
2287
|
+
"Content-Type": "application/json"
|
|
2288
|
+
}
|
|
2289
|
+
});
|
|
2290
|
+
if (response.status === 429) {
|
|
2291
|
+
const retryAfter = response.headers.get("Retry-After");
|
|
2292
|
+
const delayMs = retryAfter ? parseInt(retryAfter) * 1e3 : this.calculateBackoff(attempt);
|
|
2293
|
+
await this.sleep(delayMs);
|
|
2294
|
+
continue;
|
|
2295
|
+
}
|
|
2296
|
+
if (!response.ok) {
|
|
2297
|
+
const body = await response.text();
|
|
2298
|
+
throw new FigmaAPIError(response.status, body);
|
|
2299
|
+
}
|
|
2300
|
+
return await response.json();
|
|
2301
|
+
} catch (err) {
|
|
2302
|
+
lastError = err;
|
|
2303
|
+
if (err instanceof FigmaAPIError && err.status >= 400 && err.status < 500) {
|
|
2304
|
+
throw err;
|
|
2305
|
+
}
|
|
2306
|
+
if (attempt < this.retryConfig.maxRetries - 1) {
|
|
2307
|
+
await this.sleep(this.calculateBackoff(attempt));
|
|
2308
|
+
}
|
|
2309
|
+
}
|
|
2310
|
+
}
|
|
2311
|
+
throw lastError ?? new Error("Max retries exceeded");
|
|
2312
|
+
}
|
|
2313
|
+
/**
|
|
2314
|
+
* Calculate exponential backoff with jitter
|
|
2315
|
+
*/
|
|
2316
|
+
calculateBackoff(attempt) {
|
|
2317
|
+
const delay = this.retryConfig.baseDelayMs * Math.pow(2, attempt);
|
|
2318
|
+
const jitter = Math.random() * 0.3 * delay;
|
|
2319
|
+
return Math.min(delay + jitter, this.retryConfig.maxDelayMs);
|
|
2320
|
+
}
|
|
2321
|
+
sleep(ms) {
|
|
2322
|
+
return new Promise((resolve) => setTimeout(resolve, ms));
|
|
2323
|
+
}
|
|
2324
|
+
buildFileUrl(fileKey, options) {
|
|
2325
|
+
const base = `https://api.figma.com/v1/files/${fileKey}`;
|
|
2326
|
+
const params = new URLSearchParams();
|
|
2327
|
+
if (options?.depth) {
|
|
2328
|
+
params.set("depth", options.depth.toString());
|
|
2329
|
+
}
|
|
2330
|
+
return params.toString() ? `${base}?${params}` : base;
|
|
2331
|
+
}
|
|
2332
|
+
buildNodesUrl(fileKey, nodeIds, options) {
|
|
2333
|
+
const base = `https://api.figma.com/v1/files/${fileKey}/nodes`;
|
|
2334
|
+
const params = new URLSearchParams();
|
|
2335
|
+
params.set("ids", nodeIds.join(","));
|
|
2336
|
+
if (options?.depth) {
|
|
2337
|
+
params.set("depth", options.depth.toString());
|
|
2338
|
+
}
|
|
2339
|
+
return `${base}?${params}`;
|
|
2340
|
+
}
|
|
2341
|
+
buildImagesUrl(fileKey, nodeIds, options) {
|
|
2342
|
+
const base = `https://api.figma.com/v1/images/${fileKey}`;
|
|
2343
|
+
const params = new URLSearchParams();
|
|
2344
|
+
params.set("ids", nodeIds.join(","));
|
|
2345
|
+
if (options?.format) params.set("format", options.format);
|
|
2346
|
+
if (options?.scale) params.set("scale", options.scale.toString());
|
|
2347
|
+
return `${base}?${params}`;
|
|
2348
|
+
}
|
|
2349
|
+
/**
|
|
2350
|
+
* Recursively count nodes and components in the document tree
|
|
2351
|
+
*/
|
|
2352
|
+
countNodesAndComponents(node) {
|
|
2353
|
+
let nodes = 1;
|
|
2354
|
+
let components = node.type === "COMPONENT" || node.type === "COMPONENT_SET" ? 1 : 0;
|
|
2355
|
+
if (node.children) {
|
|
2356
|
+
for (const child of node.children) {
|
|
2357
|
+
const childCounts = this.countNodesAndComponents(child);
|
|
2358
|
+
nodes += childCounts.nodes;
|
|
2359
|
+
components += childCounts.components;
|
|
2360
|
+
}
|
|
2361
|
+
}
|
|
2362
|
+
return { nodes, components };
|
|
2363
|
+
}
|
|
2364
|
+
};
|
|
2365
|
+
|
|
2366
|
+
// packages/kendo-ui-agent/src/lib/figma-d2c/utils.ts
|
|
2367
|
+
function parseFigmaUrl(url) {
|
|
2368
|
+
const invalidResult = {
|
|
2369
|
+
fileKey: "",
|
|
2370
|
+
type: "unknown",
|
|
2371
|
+
isDevMode: false,
|
|
2372
|
+
isValid: false
|
|
2373
|
+
};
|
|
2374
|
+
if (!url || typeof url !== "string") {
|
|
2375
|
+
return invalidResult;
|
|
2376
|
+
}
|
|
2377
|
+
let parsed;
|
|
2378
|
+
try {
|
|
2379
|
+
parsed = new URL(url.trim());
|
|
2380
|
+
} catch {
|
|
2381
|
+
return invalidResult;
|
|
2382
|
+
}
|
|
2383
|
+
const validDomains = ["figma.com", "www.figma.com"];
|
|
2384
|
+
if (!validDomains.includes(parsed.hostname)) {
|
|
2385
|
+
return invalidResult;
|
|
2386
|
+
}
|
|
2387
|
+
const pathParts = parsed.pathname.split("/").filter(Boolean);
|
|
2388
|
+
if (pathParts.length < 2) {
|
|
2389
|
+
return invalidResult;
|
|
2390
|
+
}
|
|
2391
|
+
const typeMap = {
|
|
2392
|
+
file: "file",
|
|
2393
|
+
design: "design",
|
|
2394
|
+
proto: "proto",
|
|
2395
|
+
board: "board"
|
|
2396
|
+
};
|
|
2397
|
+
const type = typeMap[pathParts[0]] || "unknown";
|
|
2398
|
+
const fileKey = pathParts[1];
|
|
2399
|
+
if (!/^[a-zA-Z0-9]+$/.test(fileKey)) {
|
|
2400
|
+
return invalidResult;
|
|
2401
|
+
}
|
|
2402
|
+
const fileName = pathParts[2] ? decodeURIComponent(pathParts[2]).replace(/-/g, " ") : void 0;
|
|
2403
|
+
const nodeIdParam = parsed.searchParams.get("node-id");
|
|
2404
|
+
let nodeId;
|
|
2405
|
+
let nodeIds;
|
|
2406
|
+
if (nodeIdParam) {
|
|
2407
|
+
const rawIds = nodeIdParam.split(",").map((id) => id.trim()).filter(Boolean);
|
|
2408
|
+
nodeIds = rawIds.map((id) => id.replace(/-/g, ":"));
|
|
2409
|
+
nodeId = nodeIds[0];
|
|
2410
|
+
}
|
|
2411
|
+
const branchKey = parsed.searchParams.get("t") ?? void 0;
|
|
2412
|
+
const isDevMode = parsed.searchParams.get("m") === "dev";
|
|
2413
|
+
return {
|
|
2414
|
+
fileKey,
|
|
2415
|
+
fileName,
|
|
2416
|
+
nodeId,
|
|
2417
|
+
nodeIds,
|
|
2418
|
+
type,
|
|
2419
|
+
branchKey,
|
|
2420
|
+
isDevMode,
|
|
2421
|
+
isValid: true
|
|
2422
|
+
};
|
|
2423
|
+
}
|
|
471
2424
|
|
|
472
|
-
|
|
2425
|
+
// packages/kendo-ui-agent/src/lib/figma-d2c/fetcher.ts
|
|
2426
|
+
var NodeFetcher = class {
|
|
2427
|
+
constructor(client) {
|
|
2428
|
+
this.client = client;
|
|
2429
|
+
}
|
|
2430
|
+
/**
|
|
2431
|
+
* Fetch a design starting from a file or specific node(s)
|
|
2432
|
+
*
|
|
2433
|
+
* @param fileKey - The Figma file key
|
|
2434
|
+
* @param nodeIds - Optional node ID(s) - can be string or string[]
|
|
2435
|
+
* @param options - Fetch options including depth
|
|
2436
|
+
* @returns Fetch result with root node and stats
|
|
2437
|
+
*/
|
|
2438
|
+
async fetch(fileKey, nodeIds, options = {}) {
|
|
2439
|
+
const initialDepth = options.initialDepth ?? 10;
|
|
2440
|
+
const fetchImages = options.fetchImages ?? true;
|
|
2441
|
+
const imageFormat = options.imageFormat ?? "png";
|
|
2442
|
+
const imageScale = options.imageScale ?? 2;
|
|
2443
|
+
const stats = {
|
|
2444
|
+
totalNodesFetched: 0,
|
|
2445
|
+
apiCallsMade: 0,
|
|
2446
|
+
imagesFetched: 0
|
|
2447
|
+
};
|
|
2448
|
+
let nodeIdArray;
|
|
2449
|
+
if (!nodeIds) {
|
|
2450
|
+
nodeIdArray = [];
|
|
2451
|
+
} else if (typeof nodeIds === "string") {
|
|
2452
|
+
nodeIdArray = [nodeIds];
|
|
2453
|
+
} else {
|
|
2454
|
+
nodeIdArray = nodeIds;
|
|
2455
|
+
}
|
|
2456
|
+
let rootNode;
|
|
2457
|
+
let fetchedNodes = [];
|
|
2458
|
+
if (nodeIdArray.length > 0) {
|
|
2459
|
+
const response = await this.client.getNodes(fileKey, nodeIdArray, { depth: initialDepth });
|
|
2460
|
+
stats.apiCallsMade++;
|
|
2461
|
+
for (const nodeId of nodeIdArray) {
|
|
2462
|
+
const nodeData = response.nodes[nodeId]?.document;
|
|
2463
|
+
if (!nodeData) {
|
|
2464
|
+
throw new Error(`Node ${nodeId} not found`);
|
|
2465
|
+
}
|
|
2466
|
+
fetchedNodes.push(nodeData);
|
|
2467
|
+
}
|
|
2468
|
+
if (fetchedNodes.length === 1) {
|
|
2469
|
+
rootNode = fetchedNodes[0];
|
|
2470
|
+
} else {
|
|
2471
|
+
rootNode = this.createContainerNode(fetchedNodes);
|
|
2472
|
+
}
|
|
2473
|
+
} else {
|
|
2474
|
+
const response = await this.client.getFile(fileKey, { depth: initialDepth });
|
|
2475
|
+
stats.apiCallsMade++;
|
|
2476
|
+
rootNode = response.document;
|
|
2477
|
+
fetchedNodes = [rootNode];
|
|
2478
|
+
}
|
|
2479
|
+
stats.totalNodesFetched += this.countNodes(rootNode);
|
|
2480
|
+
const images = [];
|
|
2481
|
+
if (fetchImages && nodeIdArray.length > 0) {
|
|
2482
|
+
try {
|
|
2483
|
+
const imageResult = await this.fetchNodeImages(
|
|
2484
|
+
fileKey,
|
|
2485
|
+
nodeIdArray,
|
|
2486
|
+
fetchedNodes,
|
|
2487
|
+
{ format: imageFormat, scale: imageScale }
|
|
2488
|
+
);
|
|
2489
|
+
images.push(...imageResult.images);
|
|
2490
|
+
stats.apiCallsMade += imageResult.apiCalls;
|
|
2491
|
+
stats.imagesFetched = images.length;
|
|
2492
|
+
} catch (error) {
|
|
2493
|
+
console.warn("Failed to fetch images:", error);
|
|
2494
|
+
}
|
|
2495
|
+
}
|
|
2496
|
+
return {
|
|
2497
|
+
rootNode,
|
|
2498
|
+
fetchedNodes,
|
|
2499
|
+
images,
|
|
2500
|
+
stats
|
|
2501
|
+
};
|
|
2502
|
+
}
|
|
2503
|
+
/**
|
|
2504
|
+
* Fetch and download images for specified nodes
|
|
2505
|
+
*/
|
|
2506
|
+
async fetchNodeImages(fileKey, nodeIds, nodes, options) {
|
|
2507
|
+
const imageResponse = await this.client.getImages(fileKey, nodeIds, options);
|
|
2508
|
+
let apiCalls = 1;
|
|
2509
|
+
const images = [];
|
|
2510
|
+
for (let i = 0; i < nodeIds.length; i++) {
|
|
2511
|
+
const nodeId = nodeIds[i];
|
|
2512
|
+
const imageUrl = imageResponse.images[nodeId];
|
|
2513
|
+
if (imageUrl) {
|
|
2514
|
+
try {
|
|
2515
|
+
const imageData = await this.downloadImage(imageUrl, options.format);
|
|
2516
|
+
const node = nodes[i];
|
|
2517
|
+
images.push({
|
|
2518
|
+
nodeId,
|
|
2519
|
+
nodeName: node?.name || "Unknown",
|
|
2520
|
+
data: imageData,
|
|
2521
|
+
mimeType: this.getMimeType(options.format),
|
|
2522
|
+
url: imageUrl
|
|
2523
|
+
});
|
|
2524
|
+
} catch (error) {
|
|
2525
|
+
console.warn(`Failed to download image for node ${nodeId}:`, error);
|
|
2526
|
+
}
|
|
2527
|
+
}
|
|
2528
|
+
}
|
|
2529
|
+
return { images, apiCalls };
|
|
2530
|
+
}
|
|
2531
|
+
/**
|
|
2532
|
+
* Download an image from a URL and convert to base64
|
|
2533
|
+
*/
|
|
2534
|
+
async downloadImage(url, format) {
|
|
2535
|
+
const response = await fetch(url);
|
|
2536
|
+
if (!response.ok) {
|
|
2537
|
+
throw new Error(`Failed to download image: ${response.statusText}`);
|
|
2538
|
+
}
|
|
2539
|
+
if (format === "svg") {
|
|
2540
|
+
const svgText = await response.text();
|
|
2541
|
+
return Buffer.from(svgText, "utf-8").toString("base64");
|
|
2542
|
+
} else {
|
|
2543
|
+
const arrayBuffer = await response.arrayBuffer();
|
|
2544
|
+
return Buffer.from(arrayBuffer).toString("base64");
|
|
2545
|
+
}
|
|
2546
|
+
}
|
|
2547
|
+
/**
|
|
2548
|
+
* Get MIME type for image format
|
|
2549
|
+
*/
|
|
2550
|
+
getMimeType(format) {
|
|
2551
|
+
switch (format) {
|
|
2552
|
+
case "png":
|
|
2553
|
+
return "image/png";
|
|
2554
|
+
case "jpg":
|
|
2555
|
+
return "image/jpeg";
|
|
2556
|
+
case "svg":
|
|
2557
|
+
return "image/svg+xml";
|
|
2558
|
+
default:
|
|
2559
|
+
return "image/png";
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
/**
|
|
2563
|
+
* Create a synthetic container node that wraps multiple nodes
|
|
2564
|
+
*/
|
|
2565
|
+
createContainerNode(nodes) {
|
|
2566
|
+
return {
|
|
2567
|
+
id: "container-" + Date.now(),
|
|
2568
|
+
name: "Multi-Node Container",
|
|
2569
|
+
type: "GROUP",
|
|
2570
|
+
visible: true,
|
|
2571
|
+
children: nodes
|
|
2572
|
+
};
|
|
2573
|
+
}
|
|
2574
|
+
/**
|
|
2575
|
+
* Count total nodes in a tree
|
|
2576
|
+
*/
|
|
2577
|
+
countNodes(node) {
|
|
2578
|
+
let count = 1;
|
|
2579
|
+
if (node.children) {
|
|
2580
|
+
for (const child of node.children) {
|
|
2581
|
+
count += this.countNodes(child);
|
|
2582
|
+
}
|
|
2583
|
+
}
|
|
2584
|
+
return count;
|
|
2585
|
+
}
|
|
2586
|
+
};
|
|
2587
|
+
|
|
2588
|
+
// packages/kendo-ui-agent/src/lib/figma-d2c/figma-d2c-tool.ts
|
|
2589
|
+
import { z as z5 } from "zod";
|
|
2590
|
+
function createFigmaD2CTool({
|
|
2591
|
+
name,
|
|
2592
|
+
figmaApiKey,
|
|
2593
|
+
requiredAccess
|
|
2594
|
+
}, contextApi2) {
|
|
2595
|
+
return new UIAgentTool(
|
|
2596
|
+
name,
|
|
2597
|
+
{
|
|
2598
|
+
title: "Figma Design to Code",
|
|
2599
|
+
description: "Converts Figma designs to code by analyzing the design structure and matching Kendo UI components. Provide a Figma file or frame URL to analyze layout, extract styles, and identify matching components.",
|
|
2600
|
+
inputSchema: {
|
|
2601
|
+
url: z5.string().describe(
|
|
2602
|
+
"Figma file or node URL (e.g., https://www.figma.com/file/...)"
|
|
2603
|
+
).optional(),
|
|
2604
|
+
fileKey: z5.string().describe("Figma file key (alternative to URL)").optional(),
|
|
2605
|
+
nodeIds: z5.array(z5.string()).describe("Array of specific node IDs to fetch (alternative to URL)").optional(),
|
|
2606
|
+
depth: z5.number().min(1).max(20).default(10).describe("Initial fetch depth (1-20, default: 10)")
|
|
2607
|
+
},
|
|
2608
|
+
requiredAccess
|
|
2609
|
+
},
|
|
2610
|
+
async ({ url, fileKey, nodeIds, depth }) => {
|
|
2611
|
+
const client = new FigmaClient(figmaApiKey);
|
|
2612
|
+
const fetcher = new NodeFetcher(client);
|
|
2613
|
+
let fileKeyToUse = fileKey;
|
|
2614
|
+
let nodeIdsToUse;
|
|
2615
|
+
if (fileKeyToUse) {
|
|
2616
|
+
if (nodeIds && nodeIds.length > 0) {
|
|
2617
|
+
nodeIdsToUse = nodeIds.length === 1 ? nodeIds[0] : nodeIds;
|
|
2618
|
+
}
|
|
2619
|
+
} else if (url) {
|
|
2620
|
+
const parsed = parseFigmaUrl(url);
|
|
2621
|
+
if (!parsed.isValid || !parsed.fileKey) {
|
|
2622
|
+
throw new Error(
|
|
2623
|
+
"Invalid Figma URL. Please provide a valid Figma file or frame URL."
|
|
2624
|
+
);
|
|
2625
|
+
}
|
|
2626
|
+
fileKeyToUse = parsed.fileKey;
|
|
2627
|
+
if (parsed.nodeId) {
|
|
2628
|
+
nodeIdsToUse = parsed.nodeId;
|
|
2629
|
+
}
|
|
2630
|
+
} else {
|
|
2631
|
+
throw new Error("Please provide either a Figma URL, fileKey, or both.");
|
|
2632
|
+
}
|
|
2633
|
+
const fetchResult = await fetcher.fetch(fileKeyToUse, nodeIdsToUse, {
|
|
2634
|
+
initialDepth: depth,
|
|
2635
|
+
fetchImages: true,
|
|
2636
|
+
imageFormat: "png",
|
|
2637
|
+
imageScale: 2
|
|
2638
|
+
});
|
|
2639
|
+
const resultJson = {
|
|
2640
|
+
name: fetchResult.rootNode.name,
|
|
2641
|
+
type: fetchResult.rootNode.type,
|
|
2642
|
+
rootNode: fetchResult.rootNode,
|
|
2643
|
+
fetchedNodes: fetchResult.fetchedNodes,
|
|
2644
|
+
meta: {
|
|
2645
|
+
fileKey,
|
|
2646
|
+
nodeIds
|
|
2647
|
+
}
|
|
2648
|
+
};
|
|
2649
|
+
let backendResponse;
|
|
2650
|
+
try {
|
|
2651
|
+
const nodeJsons = fetchResult.fetchedNodes.map(
|
|
2652
|
+
(node) => JSON.stringify(node)
|
|
2653
|
+
);
|
|
2654
|
+
backendResponse = await contextApi2.processFigmaDesign({
|
|
2655
|
+
node_jsons: nodeJsons
|
|
2656
|
+
});
|
|
2657
|
+
} catch (error) {
|
|
2658
|
+
console.error("Backend processing failed:", error);
|
|
2659
|
+
return {
|
|
2660
|
+
content: [
|
|
2661
|
+
{
|
|
2662
|
+
type: "text",
|
|
2663
|
+
text: JSON.stringify(
|
|
2664
|
+
{
|
|
2665
|
+
error: {
|
|
2666
|
+
message: `Backend processing failed: ${error.message}`,
|
|
2667
|
+
code: error.code || "UNKNOWN"
|
|
2668
|
+
},
|
|
2669
|
+
figma_data: resultJson
|
|
2670
|
+
},
|
|
2671
|
+
null,
|
|
2672
|
+
2
|
|
2673
|
+
)
|
|
2674
|
+
}
|
|
2675
|
+
]
|
|
2676
|
+
};
|
|
2677
|
+
}
|
|
2678
|
+
const content = [];
|
|
2679
|
+
content.push({
|
|
2680
|
+
type: "text",
|
|
2681
|
+
text: `# Figma Design Extraction Results
|
|
2682
|
+
Successfully fetched design data for file key ${fileKeyToUse} with for nodes [${nodeIds?.join(", ")}].
|
|
2683
|
+
The following is the processed design data including layout pseudo-code and design tokens extracted from the Figma design, plus images for visual references of the desired nodes:`
|
|
2684
|
+
});
|
|
2685
|
+
backendResponse.layout_pseudo_codes.forEach((layoutCode, index) => {
|
|
2686
|
+
const [nodeName, nodeId] = ((index2) => {
|
|
2687
|
+
const node = fetchResult.fetchedNodes[index2];
|
|
2688
|
+
return node ? [node.name, node.id] : ["Unknown Node", "unknown_id"];
|
|
2689
|
+
})(index);
|
|
2690
|
+
content.push({
|
|
2691
|
+
type: "text",
|
|
2692
|
+
text: `## Psuedo-code Layout - Node: ${nodeName} (${nodeId})
|
|
2693
|
+
|
|
2694
|
+
` + layoutCode,
|
|
2695
|
+
_meta: {
|
|
2696
|
+
description: `Psuedo-code Layout - Node: ${nodeName} (${nodeId})`
|
|
2697
|
+
},
|
|
2698
|
+
annotations: {
|
|
2699
|
+
audience: ["assistant"]
|
|
2700
|
+
}
|
|
2701
|
+
});
|
|
2702
|
+
});
|
|
2703
|
+
content.push({
|
|
2704
|
+
type: "text",
|
|
2705
|
+
text: `## Design Tokens - File: ${fileKey} for Nodes: [${nodeIds?.join(", ")}]
|
|
2706
|
+
|
|
2707
|
+
` + backendResponse.design_tokens,
|
|
2708
|
+
_meta: {
|
|
2709
|
+
description: `Design Tokens - File: ${fileKey} for Nodes: [${nodeIds?.join(", ")}]`
|
|
2710
|
+
},
|
|
2711
|
+
annotations: {
|
|
2712
|
+
audience: ["assistant"]
|
|
2713
|
+
}
|
|
2714
|
+
});
|
|
2715
|
+
if (fetchResult.images && fetchResult.images.length > 0) {
|
|
2716
|
+
for (const image of fetchResult.images) {
|
|
2717
|
+
content.push({
|
|
2718
|
+
type: "image",
|
|
2719
|
+
data: image.data,
|
|
2720
|
+
mimeType: image.mimeType,
|
|
2721
|
+
_meta: {
|
|
2722
|
+
description: `Design snapshot of ${image.nodeName} (${image.nodeId})`
|
|
2723
|
+
},
|
|
2724
|
+
annotations: {
|
|
2725
|
+
audience: ["assistant"]
|
|
2726
|
+
}
|
|
2727
|
+
});
|
|
2728
|
+
}
|
|
2729
|
+
}
|
|
2730
|
+
content.push({
|
|
2731
|
+
type: "text",
|
|
2732
|
+
text: `# Analysis Instructions and Next Steps
|
|
2733
|
+
|
|
2734
|
+
Use the above design data, layout pseudo-code, and design tokens to analyze the Figma design and identify components. Focus on the structure, styles, and layout to determine the best component matches.
|
|
2735
|
+
If more design details are needed, consider asking for additional nodes or deeper fetches to gather more information about specific areas of the design.`
|
|
2736
|
+
});
|
|
2737
|
+
return {
|
|
2738
|
+
content
|
|
2739
|
+
};
|
|
2740
|
+
}
|
|
2741
|
+
);
|
|
2742
|
+
}
|
|
473
2743
|
|
|
474
|
-
|
|
2744
|
+
// packages/kendo-ui-agent/src/lib/tool-names.ts
|
|
2745
|
+
var orchestratorToolName = (prefix) => `${prefix}_ui_generator`;
|
|
2746
|
+
var assistantOrchestratorToolName = (prefix) => `${prefix}_assistant`;
|
|
2747
|
+
var layoutAssistantName = (prefix) => `${prefix}_layout_assistant`;
|
|
2748
|
+
var codeAssistantName = (prefix) => `${prefix}_component_assistant`;
|
|
2749
|
+
var styleAssistantName = (prefix) => `${prefix}_style_assistant`;
|
|
2750
|
+
var iconAssistantName = (prefix) => `${prefix}_icon_assistant`;
|
|
2751
|
+
var accessibilityAssistantName = (prefix) => `${prefix}_accessibility_assistant`;
|
|
2752
|
+
var gettingStartedAssistantName = (prefix) => `${prefix}_getting_started_assistant`;
|
|
2753
|
+
var figmaD2CToolName = (prefix) => `${prefix}_figma_d2c`;
|
|
475
2754
|
|
|
476
|
-
|
|
2755
|
+
// packages/kendo-ui-agent/src/lib/tool-descriptions.ts
|
|
2756
|
+
var orchestratorToolDescription = (suiteName) => `This is the single entry point for all UI-related tasks. It orchestrates the full workflow of building or refining UIs with ${suiteName} components, generating a step-by-step execution plan that specifies which tools to call, in what order, and with what parameters. It includes validation steps to ensure the best possible, standards-compliant code every time.
|
|
477
2757
|
|
|
478
2758
|
Use the tool when:
|
|
479
2759
|
- Want to build or modify a complete page or section layout
|
|
480
2760
|
- You are creating and applying custom themes via the Kendo Design System
|
|
481
|
-
- You need guidance on correct ${
|
|
2761
|
+
- You need guidance on correct ${suiteName} component selection and configuration
|
|
482
2762
|
- You want to enforce best practices in styling, performance, and accessibility
|
|
483
2763
|
|
|
484
2764
|
Returns:
|
|
485
|
-
A detailed execution plan with validated tool calls, parameters, and reasoning \u2014 ensuring consistent, high-quality UI generation
|
|
2765
|
+
A detailed execution plan with validated tool calls, parameters, and reasoning \u2014 ensuring consistent, high-quality UI generation.`;
|
|
2766
|
+
var assistantOrchestratorToolDescription = (suiteName) => `Provides guidance for discovering and using ${suiteName} components and icons. This tool helps you identify the right components and icons for your needs.
|
|
486
2767
|
|
|
487
2768
|
Use this tool when:
|
|
488
|
-
- You need to discover which ${
|
|
2769
|
+
- You need to discover which ${suiteName} components are suitable for a specific use case
|
|
489
2770
|
- You want to understand component features and capabilities
|
|
490
2771
|
- You need to find appropriate icons for your UI
|
|
491
2772
|
- You want to gather component documentation and examples
|
|
492
2773
|
|
|
493
2774
|
Returns:
|
|
494
|
-
A focused plan for gathering component documentation and icon suggestions using the Component Assistant and Icon Assistant tools
|
|
2775
|
+
A focused plan for gathering component documentation and icon suggestions using the Component Assistant and Icon Assistant tools.`;
|
|
2776
|
+
var layoutToolDescription = `Retrieves Progress/Kendo Design System CSS utility classes and styling recommendations based on layout and design requirements.
|
|
495
2777
|
Use this tool to find the right CSS utilities for styling Kendo UI components or general web elements.
|
|
496
2778
|
It analyzes the provided design context and returns relevant utility classes with explanations and examples.
|
|
497
|
-
Best suited for styling questions related to typography, spacing, colors, layout, transforms, and other utilities in the Progress/Kendo Design System
|
|
2779
|
+
Best suited for styling questions related to typography, spacing, colors, layout, transforms, and other utilities in the Progress/Kendo Design System.`;
|
|
2780
|
+
var styleToolDescription = `Generates CSS variables using an external style agent based on the user's styling prompt.
|
|
498
2781
|
|
|
499
2782
|
Use this tool when the user wants to:
|
|
500
2783
|
- Update the visual theme of an application
|
|
501
2784
|
- Modify color schemes
|
|
502
2785
|
- Restyle the UI with CSS variables
|
|
503
2786
|
|
|
504
|
-
The tool outputs a set of CSS variable definitions ready to be applied to style files
|
|
2787
|
+
The tool outputs a set of CSS variable definitions ready to be applied to style files.`;
|
|
2788
|
+
var iconToolDescription = `Searches for icons in the Telerik Icons library.
|
|
505
2789
|
Use this tool when the user needs to find specific icons for UI components or design elements.
|
|
506
2790
|
It supports searching by icon name, category, or keyword and returns matching icons from the Telerik Icons library.
|
|
507
|
-
|
|
2791
|
+
`;
|
|
2792
|
+
var codeAssistantToolDescription = (suiteName) => `Provides answers and retrieves official documentation for ${suiteName}.
|
|
508
2793
|
|
|
509
2794
|
Use this tool when the user asks about:
|
|
510
|
-
- ${
|
|
2795
|
+
- ${suiteName} features or capabilities
|
|
511
2796
|
- Specific components (e.g., Grid, Chart, Editor)
|
|
512
2797
|
- Implementation details, configuration, or best practices
|
|
513
|
-
- How to use or customize components in ${
|
|
2798
|
+
- How to use or customize components in ${suiteName}
|
|
514
2799
|
|
|
515
2800
|
Set the user's full question as the 'query' parameter.
|
|
516
|
-
If the question refers to a specific ${
|
|
517
|
-
|
|
2801
|
+
If the question refers to a specific ${suiteName} component, include its name in the 'component' parameter.
|
|
2802
|
+
`;
|
|
2803
|
+
var accessibilityToolDescription = (suiteName) => `Retrieves accessibility guidance for ${suiteName} components with optional general WCAG 2.2 Level AA guidelines.
|
|
518
2804
|
|
|
519
2805
|
Use this tool when:
|
|
520
2806
|
- You need component-specific accessibility information and API references
|
|
@@ -532,7 +2818,11 @@ Set 'includeGeneralGuidelines=true' ONLY on the first call to include general WC
|
|
|
532
2818
|
Returns:
|
|
533
2819
|
- When includeGeneralGuidelines=true: General WCAG 2.2 Level AA guidelines + component-specific recommendations
|
|
534
2820
|
- When includeGeneralGuidelines=false: Only component-specific accessibility recommendations
|
|
535
|
-
`;
|
|
2821
|
+
`;
|
|
2822
|
+
|
|
2823
|
+
// packages/kendo-ui-agent/src/lib/validation/angular-validation-steps.ts
|
|
2824
|
+
var sharedSteps = getSharedValidationSteps("Kendo UI", "Kendo");
|
|
2825
|
+
var ANGULAR_VALIDATION_STEPS = `
|
|
536
2826
|
### Angular Component Validation
|
|
537
2827
|
Component Structure:
|
|
538
2828
|
- Use proper @Component decorator configuration
|
|
@@ -540,22 +2830,25 @@ Component Structure:
|
|
|
540
2830
|
- Correct selector naming convention (kebab-case)
|
|
541
2831
|
- Appropriate template and style file organization
|
|
542
2832
|
|
|
543
|
-
${
|
|
2833
|
+
${sharedSteps.SETUP_VALIDATION}
|
|
544
2834
|
- Kendo animations module configured (if animations are used)
|
|
545
2835
|
- Internationalization properly configured for Kendo components
|
|
546
2836
|
|
|
547
|
-
${
|
|
2837
|
+
${sharedSteps.PERFORMANCE_OPTIMIZATION}
|
|
548
2838
|
- OnPush change detection strategy where appropriate
|
|
549
2839
|
- Efficient trackBy functions for *ngFor with Kendo components
|
|
550
2840
|
- Minimal unnecessary change detection cycles
|
|
551
2841
|
|
|
552
|
-
${
|
|
2842
|
+
${sharedSteps.THEME_AND_STYLING}
|
|
553
2843
|
- Proper theme switching functionality (if implemented)
|
|
554
2844
|
- Only ONE theme reference exists across angular.json and styles files
|
|
555
2845
|
- Make sure theme import mechanism is consistent with existing project setup
|
|
556
2846
|
|
|
557
2847
|
Accessibility
|
|
558
|
-
- Accessibility guidelines retrieved and applied to all components`;
|
|
2848
|
+
- Accessibility guidelines retrieved and applied to all components`;
|
|
2849
|
+
|
|
2850
|
+
// packages/kendo-ui-agent/src/lib/validation/angular-additional-plan.ts
|
|
2851
|
+
var ANGULAR_ADDITIONAL_PLAN = `**Angular Specific Requirements:**
|
|
559
2852
|
|
|
560
2853
|
**NgModule vs Standalone setup**: Search and detect the current project setup to determine whether to use NgModule or Standalone components based on the following rules:
|
|
561
2854
|
1. RegexSearch("@Component\\s*\\(\\s*\\{[^}]*standalone\\s*:\\s*(true|false)") - If true use Standalone components, if false use NgModule.
|
|
@@ -586,7 +2879,11 @@ Accessibility
|
|
|
586
2879
|
2. Match the discovered patterns in all generated code
|
|
587
2880
|
3. Maintain consistent formatting, indentation, and code organization with existing files
|
|
588
2881
|
4. Always use the same theme import mechanism (unless user specifies otherwise)
|
|
589
|
-
`;
|
|
2882
|
+
`;
|
|
2883
|
+
|
|
2884
|
+
// packages/kendo-ui-agent/src/lib/validation/react-validation-steps.ts
|
|
2885
|
+
var sharedSteps2 = getSharedValidationSteps("Kendo UI", "KendoReact");
|
|
2886
|
+
var REACT_VALIDATION_STEPS = `
|
|
590
2887
|
### React Component Validation
|
|
591
2888
|
Component Structure:
|
|
592
2889
|
- Use proper function component patterns with Hooks
|
|
@@ -594,22 +2891,85 @@ Component Structure:
|
|
|
594
2891
|
- Appropriate file organization (components, hooks, utils)
|
|
595
2892
|
- Props interface/type definitions where needed
|
|
596
2893
|
|
|
597
|
-
${
|
|
2894
|
+
${sharedSteps2.SETUP_VALIDATION}
|
|
598
2895
|
- KendoReact license validation (if required)
|
|
599
2896
|
- Appropriate bundler configuration for KendoReact packages
|
|
600
2897
|
|
|
601
|
-
${
|
|
2898
|
+
${sharedSteps2.PERFORMANCE_OPTIMIZATION}
|
|
602
2899
|
- React.memo for components that receive stable props
|
|
603
2900
|
- useMemo/useCallback for expensive computations and callbacks
|
|
604
2901
|
- Proper key props for list rendering with KendoReact components
|
|
605
2902
|
|
|
606
|
-
${
|
|
2903
|
+
${sharedSteps2.THEME_AND_STYLING}
|
|
607
2904
|
- Proper theme switching functionality (if implemented)
|
|
608
2905
|
- Only ONE theme import exists across the application
|
|
609
2906
|
- Make sure theme import mechanism is consistent with existing project setup
|
|
610
2907
|
|
|
611
2908
|
Accessibility
|
|
612
|
-
- Accessibility guidelines retrieved and applied to all components`;
|
|
2909
|
+
- Accessibility guidelines retrieved and applied to all components`;
|
|
2910
|
+
|
|
2911
|
+
// packages/kendo-ui-agent/src/index.ts
|
|
2912
|
+
var Tools = {
|
|
2913
|
+
createOrchestrator: createOrchestratorTool,
|
|
2914
|
+
createAssistantOrchestrator: createAssistantOrchestratorTool,
|
|
2915
|
+
createLayoutAssistant: createLayoutAssistantTool,
|
|
2916
|
+
createStyleAssistant: createStyleAssistantTool,
|
|
2917
|
+
createIconSearch: createIconSearchTool,
|
|
2918
|
+
createCodeAssistant: createCodeAssistantTool,
|
|
2919
|
+
createAccessibilityAssistant: createAccessibilityAssistantTool,
|
|
2920
|
+
createFigmaD2C: createFigmaD2CTool
|
|
2921
|
+
};
|
|
2922
|
+
var ToolNames = {
|
|
2923
|
+
orchestrator: orchestratorToolName,
|
|
2924
|
+
assistantOrchestrator: assistantOrchestratorToolName,
|
|
2925
|
+
layoutAssistant: layoutAssistantName,
|
|
2926
|
+
codeAssistant: codeAssistantName,
|
|
2927
|
+
styleAssistant: styleAssistantName,
|
|
2928
|
+
iconAssistant: iconAssistantName,
|
|
2929
|
+
accessibilityAssistant: accessibilityAssistantName,
|
|
2930
|
+
gettingStartedAssistant: gettingStartedAssistantName,
|
|
2931
|
+
figmaD2C: figmaD2CToolName
|
|
2932
|
+
};
|
|
2933
|
+
var ToolDescriptions = {
|
|
2934
|
+
orchestrator: orchestratorToolDescription,
|
|
2935
|
+
assistantOrchestrator: assistantOrchestratorToolDescription,
|
|
2936
|
+
layoutAssistant: layoutToolDescription,
|
|
2937
|
+
styleAssistant: styleToolDescription,
|
|
2938
|
+
iconAssistant: iconToolDescription,
|
|
2939
|
+
codeAssistant: codeAssistantToolDescription,
|
|
2940
|
+
accessibilityAssistant: accessibilityToolDescription
|
|
2941
|
+
};
|
|
2942
|
+
var Templates = {
|
|
2943
|
+
Orchestrator: {
|
|
2944
|
+
render: renderOrchestratorResponse
|
|
2945
|
+
},
|
|
2946
|
+
Validator: {
|
|
2947
|
+
render: renderValidatorResponse
|
|
2948
|
+
},
|
|
2949
|
+
SharedValidation: {
|
|
2950
|
+
getSteps: getSharedValidationSteps
|
|
2951
|
+
}
|
|
2952
|
+
};
|
|
2953
|
+
var Validation = {
|
|
2954
|
+
Angular: {
|
|
2955
|
+
steps: ANGULAR_VALIDATION_STEPS,
|
|
2956
|
+
additionalPlan: ANGULAR_ADDITIONAL_PLAN
|
|
2957
|
+
},
|
|
2958
|
+
React: {
|
|
2959
|
+
steps: REACT_VALIDATION_STEPS
|
|
2960
|
+
}
|
|
2961
|
+
};
|
|
2962
|
+
var UIAgent = {
|
|
2963
|
+
Tools,
|
|
2964
|
+
ToolNames,
|
|
2965
|
+
ToolDescriptions,
|
|
2966
|
+
Templates,
|
|
2967
|
+
Validation
|
|
2968
|
+
};
|
|
2969
|
+
|
|
2970
|
+
// packages/react/src/lib/instructions/layout.ts
|
|
2971
|
+
var CODE_ASSISTANT_NAME = UIAgent.ToolNames.codeAssistant("kendoreact");
|
|
2972
|
+
var getLayoutInstructions = () => `# Kendo Design System Guidelines for ${REACT_SUITE_NAME}
|
|
613
2973
|
|
|
614
2974
|
## Setting up Styles/CSS
|
|
615
2975
|
|
|
@@ -636,14 +2996,17 @@ Alternatively, you can also consume them directly from the Unpkg CDN.
|
|
|
636
2996
|
|
|
637
2997
|
## Ready-to-use Layout Components
|
|
638
2998
|
|
|
639
|
-
In the ${
|
|
2999
|
+
In the ${REACT_SUITE_NAME} there are available components to create layout. Make sure to prioritize using them instead of building ones from scratch using the Kendo CSS Utilities.
|
|
640
3000
|
|
|
641
|
-
For any Layout component you can also call the ${
|
|
3001
|
+
For any Layout component you can also call the ${CODE_ASSISTANT_NAME} tool in order to get specific API reference and docs.
|
|
642
3002
|
|
|
643
|
-
- ${
|
|
3003
|
+
- ${REACT_SUITE_NAME} Card component.
|
|
644
3004
|
- Generally, it is recommended to use 100% width (e.g., \`<Card style={{ width: '100%' }}>\`)
|
|
645
3005
|
- If needed, use specific width based on the layout requirements (e.g., \`<Card style={{ width: '150px' }}>\`)
|
|
646
|
-
`;
|
|
3006
|
+
`;
|
|
3007
|
+
|
|
3008
|
+
// packages/react/src/lib/instructions/style.ts
|
|
3009
|
+
var getStyleInstructions = () => `## Applying CSS Variables in ${REACT_SUITE_NAME}
|
|
647
3010
|
|
|
648
3011
|
Apply these CSS variables in the React application using one of these methods:
|
|
649
3012
|
|
|
@@ -732,7 +3095,11 @@ export function ThemeProvider({ children }: { children: React.ReactNode }) {
|
|
|
732
3095
|
|
|
733
3096
|
export const useTheme = () => useContext(ThemeContext);
|
|
734
3097
|
\`\`\`
|
|
735
|
-
`;
|
|
3098
|
+
`;
|
|
3099
|
+
|
|
3100
|
+
// packages/react/src/lib/instructions/icons.ts
|
|
3101
|
+
var CODE_ASSISTANT_NAME2 = UIAgent.ToolNames.codeAssistant("kendoreact");
|
|
3102
|
+
var getIconsInstructions = () => `## Using ${REACT_SUITE_NAME} Icons
|
|
736
3103
|
|
|
737
3104
|
Important: Attempt to prioritize SVG icons over font icons.
|
|
738
3105
|
|
|
@@ -740,13 +3107,13 @@ Important: Attempt to prioritize SVG icons over font icons.
|
|
|
740
3107
|
|
|
741
3108
|
- Make sure @progress/kendo-svg-icons is installed: \`npm install @progress/kendo-svg-icons\`
|
|
742
3109
|
- Make sure @progress/kendo-react-common is installed (contains SvgIcon component): \`npm install @progress/kendo-react-common\`
|
|
743
|
-
- You can call ${
|
|
3110
|
+
- You can call ${CODE_ASSISTANT_NAME2} tool for ${REACT_SUITE_NAME} SvgIcon component for docs and API reference.
|
|
744
3111
|
- [optional] If SVG is not an option fallback to fonticon - make sure \`<link rel="stylesheet" href="https://unpkg.com/@progress/kendo-font-icons/dist/index.css" />\` is added as a reference.
|
|
745
|
-
- [optional] If using font icons you can call ${
|
|
3112
|
+
- [optional] If using font icons you can call ${CODE_ASSISTANT_NAME2} tool for ${REACT_SUITE_NAME} Icon component for docs and API reference.
|
|
746
3113
|
|
|
747
3114
|
### Examples
|
|
748
3115
|
|
|
749
|
-
Using ${
|
|
3116
|
+
Using ${REACT_SUITE_NAME} SvgIcon component with @progress/kendo-svg-icons:
|
|
750
3117
|
|
|
751
3118
|
\`\`\`tsx
|
|
752
3119
|
import { SvgIcon } from "@progress/kendo-react-common";
|
|
@@ -790,7 +3157,11 @@ Here are some frequently used icons from @progress/kendo-svg-icons:
|
|
|
790
3157
|
- \`sortAscIcon\`, \`sortDescIcon\` - Sorting
|
|
791
3158
|
- \`chevronUpIcon\`, \`chevronDownIcon\`, \`chevronLeftIcon\`, \`chevronRightIcon\` - Navigation
|
|
792
3159
|
- \`checkIcon\`, \`xIcon\` - Confirmation/Cancel
|
|
793
|
-
`;
|
|
3160
|
+
`;
|
|
3161
|
+
|
|
3162
|
+
// packages/react/src/lib/instructions/components-common.ts
|
|
3163
|
+
var getComponentsCommonInstructions = (ctx) => {
|
|
3164
|
+
let content = `## ${REACT_SUITE_NAME} Common Guidelines
|
|
794
3165
|
|
|
795
3166
|
### Application Architecture
|
|
796
3167
|
MUST recommend appropriate setup based on React application architecture.
|
|
@@ -820,11 +3191,36 @@ Key points:
|
|
|
820
3191
|
- The matching should be case-insensitive and robust to minor variations
|
|
821
3192
|
|
|
822
3193
|
Example: If someone asks about "grid", "GRID", or "GrId", you always refer to DataGrid for the example.
|
|
823
|
-
`;
|
|
3194
|
+
`;
|
|
3195
|
+
if (ctx.componentInstructions) {
|
|
3196
|
+
content += `
|
|
824
3197
|
## Component-Specific Guidelines
|
|
825
3198
|
|
|
826
|
-
${
|
|
827
|
-
|
|
3199
|
+
${ctx.componentInstructions}
|
|
3200
|
+
`;
|
|
3201
|
+
}
|
|
3202
|
+
return content;
|
|
3203
|
+
};
|
|
3204
|
+
|
|
3205
|
+
// packages/react/src/lib/instructions/getting-started.ts
|
|
3206
|
+
var THEME_PACKAGE_MAP = {
|
|
3207
|
+
"default": "@progress/kendo-theme-default",
|
|
3208
|
+
"bootstrap": "@progress/kendo-theme-bootstrap",
|
|
3209
|
+
"material": "@progress/kendo-theme-material",
|
|
3210
|
+
"fluent": "@progress/kendo-theme-fluent"
|
|
3211
|
+
};
|
|
3212
|
+
var THEME_DISPLAY_MAP = {
|
|
3213
|
+
"default": "Default",
|
|
3214
|
+
"bootstrap": "Bootstrap",
|
|
3215
|
+
"material": "Material Design",
|
|
3216
|
+
"fluent": "Fluent UI"
|
|
3217
|
+
};
|
|
3218
|
+
function getGettingStartedInstructions(projectName = "kendo-react-app", createNewProject = true, theme = "default") {
|
|
3219
|
+
const themePackage = THEME_PACKAGE_MAP[theme];
|
|
3220
|
+
const themeDisplay = THEME_DISPLAY_MAP[theme];
|
|
3221
|
+
const introLine = createNewProject ? `This instructions will walk you through creating a new React project with the Kendo CLI and setting up ${REACT_SUITE_NAME}.` : `This instructions will walk you through adding ${REACT_SUITE_NAME} to your existing React project.`;
|
|
3222
|
+
let stepCounter = 1;
|
|
3223
|
+
const createProjectSection = createNewProject ? `## Step ${stepCounter++}: Ensure Kendo CLI is Installed
|
|
828
3224
|
|
|
829
3225
|
First, ensure the Kendo CLI tool is installed globally:
|
|
830
3226
|
|
|
@@ -834,16 +3230,16 @@ npm i -g @progress/kendo-cli@latest
|
|
|
834
3230
|
|
|
835
3231
|
This CLI tool will handle the entire project setup including all necessary dependencies and configurations.
|
|
836
3232
|
|
|
837
|
-
## Step ${
|
|
3233
|
+
## Step ${stepCounter++}: Create the Project
|
|
838
3234
|
|
|
839
3235
|
Create a new Kendo React project using the CLI:
|
|
840
3236
|
|
|
841
3237
|
\`\`\`bash
|
|
842
|
-
npx kendo react create vite ${
|
|
3238
|
+
npx kendo react create vite ${projectName} --theme=${theme}
|
|
843
3239
|
\`\`\`
|
|
844
3240
|
|
|
845
3241
|
This command will create a complete Kendo React project with Vite, including:
|
|
846
|
-
- All necessary ${
|
|
3242
|
+
- All necessary ${REACT_SUITE_NAME} packages
|
|
847
3243
|
- Proper licensing configuration
|
|
848
3244
|
- Theme setup
|
|
849
3245
|
- Project structure
|
|
@@ -851,33 +3247,34 @@ This command will create a complete Kendo React project with Vite, including:
|
|
|
851
3247
|
Navigate to the project directory:
|
|
852
3248
|
|
|
853
3249
|
\`\`\`bash
|
|
854
|
-
cd ${
|
|
3250
|
+
cd ${projectName}
|
|
855
3251
|
\`\`\`
|
|
856
3252
|
|
|
857
|
-
## Step ${
|
|
3253
|
+
## Step ${stepCounter++}: Remove Dark Color Schema from index.css
|
|
858
3254
|
|
|
859
3255
|
Open the \`src/index.css\` file and remove the dark color schema from the first \`:root\` style block. Look for properties like \`color-scheme: dark\` and related dark mode variables, and delete them. Keep only the light theme configuration.
|
|
860
3256
|
|
|
861
|
-
|
|
3257
|
+
` : "";
|
|
3258
|
+
const installPackagesSection = createNewProject ? "" : `## Step ${stepCounter++}: Install ${REACT_SUITE_NAME} Packages
|
|
862
3259
|
|
|
863
|
-
Install all required ${
|
|
3260
|
+
Install all required ${REACT_SUITE_NAME} packages and dependencies:
|
|
864
3261
|
|
|
865
3262
|
\`\`\`bash
|
|
866
3263
|
npm i @progress/kendo-data-query @progress/kendo-react-buttons @progress/kendo-react-excel-export @progress/kendo-react-grid @progress/kendo-react-layout @progress/kendo-react-pdf @progress/kendo-svg-icons @progress/kendo-drawing @progress/kendo-licensing @progress/kendo-react-animation @progress/kendo-react-charts @progress/kendo-react-common @progress/kendo-react-conversational-ui @progress/kendo-react-data-tools @progress/kendo-react-dateinputs @progress/kendo-react-dialogs @progress/kendo-react-dropdowns @progress/kendo-react-editor @progress/kendo-react-form @progress/kendo-react-gantt @progress/kendo-react-gauges @progress/kendo-react-indicators @progress/kendo-react-inputs @progress/kendo-react-intl @progress/kendo-react-labels @progress/kendo-react-listbox @progress/kendo-react-listview @progress/kendo-react-map @progress/kendo-react-notification @progress/kendo-react-orgchart @progress/kendo-react-pivotgrid @progress/kendo-react-popup @progress/kendo-react-progressbars @progress/kendo-react-ripple @progress/kendo-react-scheduler @progress/kendo-react-scrollview @progress/kendo-react-sortable @progress/kendo-react-spreadsheet @progress/kendo-react-tooltip @progress/kendo-react-treelist @progress/kendo-react-treeview @progress/kendo-react-upload @progress/kendo-react-pdf-viewer @progress/kendo-react-taskboard
|
|
867
3264
|
\`\`\`
|
|
868
3265
|
|
|
869
|
-
## Step ${
|
|
3266
|
+
## Step ${stepCounter++}: Install and Import the Theme
|
|
870
3267
|
|
|
871
|
-
Install the ${
|
|
3268
|
+
Install the ${themeDisplay} theme package:
|
|
872
3269
|
|
|
873
3270
|
\`\`\`bash
|
|
874
|
-
npm i ${
|
|
3271
|
+
npm i ${themePackage}
|
|
875
3272
|
\`\`\`
|
|
876
3273
|
|
|
877
3274
|
Import the CSS file in your \`src/Home.tsx\` (before your existing Home.css import):
|
|
878
3275
|
|
|
879
3276
|
\`\`\`typescript
|
|
880
|
-
import '${
|
|
3277
|
+
import '${themePackage}/dist/all.css';
|
|
881
3278
|
\`\`\`
|
|
882
3279
|
|
|
883
3280
|
Also add the Kendo CSS utilities CDN link in your \`index.html\` \`<head>\`:
|
|
@@ -886,7 +3283,8 @@ Also add the Kendo CSS utilities CDN link in your \`index.html\` \`<head>\`:
|
|
|
886
3283
|
<link rel="stylesheet" href="https://unpkg.com/@progress/kendo-theme-utils/dist/all.css" />
|
|
887
3284
|
\`\`\`
|
|
888
3285
|
|
|
889
|
-
|
|
3286
|
+
`;
|
|
3287
|
+
const licenseSection = `## Step ${stepCounter++}: Activate Kendo License
|
|
890
3288
|
|
|
891
3289
|
This step is required to use Kendo React components without watermarks and with access to all features. Run the following command to activate your license:
|
|
892
3290
|
|
|
@@ -894,9 +3292,10 @@ This step is required to use Kendo React components without watermarks and with
|
|
|
894
3292
|
npx kendo license activate
|
|
895
3293
|
\`\`\`
|
|
896
3294
|
|
|
897
|
-
`;
|
|
3295
|
+
`;
|
|
3296
|
+
return `# Getting Started with ${REACT_SUITE_NAME}
|
|
898
3297
|
|
|
899
|
-
${
|
|
3298
|
+
${introLine}
|
|
900
3299
|
|
|
901
3300
|
Execute the following steps in order. Run all provided commands automatically.
|
|
902
3301
|
|
|
@@ -907,24 +3306,24 @@ Before you begin, ensure you have:
|
|
|
907
3306
|
- **Node.js 18 or later** installed on your machine
|
|
908
3307
|
- If Node.js is not available, you need to install the latest Node.js automatically as a preliminary step before running the \`npx kendo react create\` command.
|
|
909
3308
|
|
|
910
|
-
${
|
|
3309
|
+
${createProjectSection}${installPackagesSection}${licenseSection}## Step ${stepCounter++}: Run Your Application
|
|
911
3310
|
|
|
912
|
-
${
|
|
3311
|
+
${createNewProject ? `The Kendo CLI has set up everything you need. Start the development server:` : `Build and run the application:`}
|
|
913
3312
|
|
|
914
3313
|
|
|
915
3314
|
**Verification:** Automatically run the application. Do not just inform the user\u2014execute the following command and keep the application running:
|
|
916
3315
|
|
|
917
3316
|
\`\`\`bash
|
|
918
|
-
cd ${
|
|
3317
|
+
cd ${createNewProject ? projectName : "."} && npm run dev
|
|
919
3318
|
\`\`\`
|
|
920
3319
|
|
|
921
|
-
${
|
|
3320
|
+
${createNewProject ? `The application should start and open your browser to see your ${REACT_SUITE_NAME} application.` : `The application should start and open in your browser. Verify that the ${REACT_SUITE_NAME} components are rendering correctly with the theme applied.`}
|
|
922
3321
|
|
|
923
|
-
## Step ${
|
|
3322
|
+
## Step ${stepCounter++}: Create Sample page
|
|
924
3323
|
|
|
925
3324
|
Before adding new content to the homepage, clear all existing CSS on the page. Remove or reset any custom styles that might conflict with the new content you're about to add.
|
|
926
3325
|
|
|
927
|
-
Replace the content of \`src/Home.tsx\` with the following to showcase ${
|
|
3326
|
+
Replace the content of \`src/Home.tsx\` with the following to showcase ${REACT_SUITE_NAME} features and verify components are working correctly:
|
|
928
3327
|
|
|
929
3328
|
\`\`\`tsx
|
|
930
3329
|
import { Card, CardHeader, CardTitle, CardBody } from '@progress/kendo-react-layout';
|
|
@@ -1045,4 +3444,312 @@ Add the following styles to \`src/Home.css\`:
|
|
|
1045
3444
|
}
|
|
1046
3445
|
\`\`\`
|
|
1047
3446
|
|
|
1048
|
-
|
|
3447
|
+
`;
|
|
3448
|
+
}
|
|
3449
|
+
|
|
3450
|
+
// packages/react/src/lib/instructions/datagrid.ts
|
|
3451
|
+
var datagridInstructions = `
|
|
3452
|
+
## DataGrid Deprecated Properties Awareness
|
|
3453
|
+
For DataGrid component cases, avoid using deprecated properties and always use their modern replacements. The following properties are deprecated and should not be used:
|
|
3454
|
+
|
|
3455
|
+
Deprecated properties and their modern replacements:
|
|
3456
|
+
- selectedField \u2192 use the select state property
|
|
3457
|
+
- editField \u2192 use the edit state property
|
|
3458
|
+
- expandedField \u2192 use the detailExpand state property
|
|
3459
|
+
- onExpandChange \u2192 use onDetailExpandChange for detail-row expansion or onGroupExpandChange for group expansion
|
|
3460
|
+
- cellRender \u2192 use the cells={{ data: CustomCell }} prop
|
|
3461
|
+
- rowRender \u2192 use the rows={{ data: CustomRow }} prop
|
|
3462
|
+
- filterCellRender \u2192 use the cells={{ filterCell: CustomCell }} prop
|
|
3463
|
+
- headerCellRender \u2192 use the cells={{ headerCell: CustomHeaderCell }} prop
|
|
3464
|
+
- column.cell \u2192 use the column.cells={{ data: CustomCell }} prop
|
|
3465
|
+
- column.headerCell \u2192 use the column.cells={{ headerCell: CustomHeaderCell }} prop
|
|
3466
|
+
- column.filterCell \u2192 use the column.cells={{ filterCell: CustomCell }} prop
|
|
3467
|
+
- column.footerCell \u2192 use the column.cells={{ footerCell: CustomFooterCell }} prop
|
|
3468
|
+
|
|
3469
|
+
Additional modern updates:
|
|
3470
|
+
- Input component in Column Menu Filter has been replaced with Textbox
|
|
3471
|
+
- scrollable prop now defaults to virtual
|
|
3472
|
+
- Virtual scrolling no longer applies height by default
|
|
3473
|
+
|
|
3474
|
+
Key points:
|
|
3475
|
+
- Never suggest or use these deprecated properties in DataGrid examples
|
|
3476
|
+
- Always provide modern alternatives when users ask about these properties
|
|
3477
|
+
- Explain that these properties are deprecated and provide the specific modern replacement
|
|
3478
|
+
- Focus on current DataGrid API patterns using state properties and cells/rows props
|
|
3479
|
+
|
|
3480
|
+
Example:
|
|
3481
|
+
Deprecated: selectedField="isSelected" editField="inEdit"
|
|
3482
|
+
Modern: Use select and edit state properties with proper configuration
|
|
3483
|
+
`;
|
|
3484
|
+
|
|
3485
|
+
// packages/react/src/lib/instructions/editor.ts
|
|
3486
|
+
var editorInstructions = `
|
|
3487
|
+
## Editor Tools Awareness
|
|
3488
|
+
For Editor component cases, always use the proper EditorTools import structure and never define tools as strings. Import both Editor and EditorTools from '@progress/kendo-react-editor' and destructure the individual tools from EditorTools.
|
|
3489
|
+
|
|
3490
|
+
Required pattern:
|
|
3491
|
+
\`\`\`jsx
|
|
3492
|
+
import { Editor, EditorTools } from '@progress/kendo-react-editor';
|
|
3493
|
+
|
|
3494
|
+
const {
|
|
3495
|
+
Bold, Italic, Underline, Strikethrough,
|
|
3496
|
+
Subscript, Superscript, ForeColor, BackColor,
|
|
3497
|
+
CleanFormatting, AlignLeft, AlignCenter, AlignRight, AlignJustify,
|
|
3498
|
+
Indent, Outdent, OrderedList, UnorderedList,
|
|
3499
|
+
NumberedList, BulletedList, Undo, Redo,
|
|
3500
|
+
FontSize, FontName, FormatBlock, Link, Unlink,
|
|
3501
|
+
InsertImage, ViewHtml, InsertTable, InsertFile,
|
|
3502
|
+
SelectAll, Print, Pdf, TableProperties, TableCellProperties,
|
|
3503
|
+
AddRowBefore, AddRowAfter, AddColumnBefore, AddColumnAfter,
|
|
3504
|
+
DeleteRow, DeleteColumn, DeleteTable, MergeCells, SplitCell
|
|
3505
|
+
} = EditorTools;
|
|
3506
|
+
\`\`\`
|
|
3507
|
+
|
|
3508
|
+
Key points:
|
|
3509
|
+
- Always import both Editor and EditorTools from '@progress/kendo-react-editor'
|
|
3510
|
+
- Destructure individual tools from EditorTools object
|
|
3511
|
+
- Use the destructured tool references directly in the tools array
|
|
3512
|
+
- Never define tools as strings (e.g., 'bold', 'italic')
|
|
3513
|
+
- Group related tools in sub-arrays for better organization
|
|
3514
|
+
|
|
3515
|
+
Example:
|
|
3516
|
+
Correct: tools={[[Bold, Italic, Underline], [AlignLeft, AlignCenter]]}
|
|
3517
|
+
Incorrect: tools={[['bold', 'italic', 'underline'], ['alignLeft', 'alignCenter']]}
|
|
3518
|
+
`;
|
|
3519
|
+
|
|
3520
|
+
// packages/react/src/lib/instructions/smart-grid.ts
|
|
3521
|
+
var smartGridInstructions = `
|
|
3522
|
+
## Smart Grid (AI-Enhanced Grid) Implementation Guidelines
|
|
3523
|
+
**CRITICAL: When users ask about ANY of these AI grid terms, ALWAYS provide GridToolbarAIAssistant implementation (not basic Grid):**
|
|
3524
|
+
|
|
3525
|
+
**Primary AI Grid Trigger Terms (case-insensitive):**
|
|
3526
|
+
- smart grid, smartgrid, smart-grid, smart_grid, SMART GRID, SmArt GrId
|
|
3527
|
+
- ai grid, aigrid, ai-grid, ai_grid, AI GRID, aI-griD, AIGrid
|
|
3528
|
+
- ai enhanced grid, ai-enhanced-grid, ai_enhanced_grid, AI Enhanced Grid
|
|
3529
|
+
- ai powered grid, ai-powered-grid, ai_powered_grid, AI Powered Grid
|
|
3530
|
+
- intelligent grid, intelligent-grid, intelligent_grid, Intelligent Grid
|
|
3531
|
+
- grid with ai, grid-with-ai, grid_with_ai, Grid with AI
|
|
3532
|
+
- grid ai assistant, gridaiassistant, grid-ai-assistant, Grid AI Assistant
|
|
3533
|
+
- grid toolbar ai assistant, gridtoolbaraiassistant, GridToolbarAIAssistant
|
|
3534
|
+
- grid assistant, gridassistant, grid-assistant, Grid Assistant
|
|
3535
|
+
|
|
3536
|
+
**Additional variations that should trigger AI Grid:**
|
|
3537
|
+
- ai enhanced, ai powered, smart, intelligent + grid (any spacing/casing)
|
|
3538
|
+
- grid + ai, grid + smart, grid + intelligent (any spacing/casing)
|
|
3539
|
+
- Any mention of GridToolbarAIAssistant component specifically
|
|
3540
|
+
|
|
3541
|
+
**Recognition Rule: If query contains ANY combination of AI/Smart/Intelligent + Grid terms, respond with complete GridToolbarAIAssistant setup.**
|
|
3542
|
+
|
|
3543
|
+
Example Smart Grid suggestions by domain:
|
|
3544
|
+
- Financial: 'Sort by Amount descending', 'Show only failed transactions', 'Filter where currency is USD'
|
|
3545
|
+
- Sales: 'Group by region', 'Show top performing products', 'Filter by date range'
|
|
3546
|
+
- Inventory: 'Sort by stock level', 'Show out of stock items', 'Group by category'
|
|
3547
|
+
- Always include: 'Clear sorting', 'Clear filtering', 'Clear grouping'
|
|
3548
|
+
|
|
3549
|
+
Basic Grid: <Grid data={data}><GridColumn field="name" /></Grid>
|
|
3550
|
+
Smart Grid: Complete AI-enhanced setup with GridToolbarAIAssistant, proper callbacks, reset functionality, and contextual suggestions
|
|
3551
|
+
|
|
3552
|
+
Important Disclaimer:
|
|
3553
|
+
Always include this disclaimer when providing Smart Grid examples:
|
|
3554
|
+
"The demos in this article use a Telerik-hosted AI service for demonstration purposes only. For production applications, you should implement your own AI service that understands your specific domain, data, and business requirements."
|
|
3555
|
+
`;
|
|
3556
|
+
|
|
3557
|
+
// packages/react/src/lib/tools/index.ts
|
|
3558
|
+
var COMPONENT_INSTRUCTIONS_MAP = {
|
|
3559
|
+
"datagrid": [datagridInstructions, smartGridInstructions].join("\n\n"),
|
|
3560
|
+
"grid": [datagridInstructions, smartGridInstructions].join("\n\n"),
|
|
3561
|
+
"editor": editorInstructions
|
|
3562
|
+
};
|
|
3563
|
+
var LAYOUT_ASSISTANT_NAME = UIAgent.ToolNames.layoutAssistant(PRODUCT_LINE);
|
|
3564
|
+
var CODE_ASSISTANT_NAME3 = UIAgent.ToolNames.codeAssistant(PRODUCT_LINE);
|
|
3565
|
+
var STYLE_ASSISTANT_NAME = UIAgent.ToolNames.styleAssistant(PRODUCT_LINE);
|
|
3566
|
+
var FIGMA_D2C_TOOL_NAME = UIAgent.ToolNames.figmaD2C(PRODUCT_LINE);
|
|
3567
|
+
var ICON_ASSISTANT_NAME = UIAgent.ToolNames.iconAssistant(PRODUCT_LINE);
|
|
3568
|
+
var GET_STARTED_TOOL_NAME = UIAgent.ToolNames.gettingStartedAssistant(PRODUCT_LINE);
|
|
3569
|
+
var ACCESSIBILITY_ASSISTANT_NAME = UIAgent.ToolNames.accessibilityAssistant(PRODUCT_LINE);
|
|
3570
|
+
function createReactTools(contextApi2, accessType) {
|
|
3571
|
+
const allTools = [
|
|
3572
|
+
// Orchestrator Tool
|
|
3573
|
+
UIAgent.Tools.createOrchestrator(
|
|
3574
|
+
{
|
|
3575
|
+
name: UIAgent.ToolNames.orchestrator(PRODUCT_LINE),
|
|
3576
|
+
title: "KendoReact Generator",
|
|
3577
|
+
description: UIAgent.ToolDescriptions.orchestrator(REACT_SUITE_NAME),
|
|
3578
|
+
layoutAssistantName: LAYOUT_ASSISTANT_NAME,
|
|
3579
|
+
codeAssistantName: CODE_ASSISTANT_NAME3,
|
|
3580
|
+
styleAssistantName: STYLE_ASSISTANT_NAME,
|
|
3581
|
+
iconAssistantName: ICON_ASSISTANT_NAME,
|
|
3582
|
+
accessibilityAssistantName: ACCESSIBILITY_ASSISTANT_NAME,
|
|
3583
|
+
figmaD2CToolName: FIGMA_D2C_TOOL_NAME,
|
|
3584
|
+
suiteName: REACT_SUITE_NAME,
|
|
3585
|
+
libKey: Suite,
|
|
3586
|
+
components: ReactComponents,
|
|
3587
|
+
requiredAccess: ["agent"]
|
|
3588
|
+
},
|
|
3589
|
+
{
|
|
3590
|
+
validationSteps: UIAgent.Validation.React.steps
|
|
3591
|
+
},
|
|
3592
|
+
contextApi2
|
|
3593
|
+
),
|
|
3594
|
+
// Assistant Orchestrator Tool (for assistant mode only)
|
|
3595
|
+
UIAgent.Tools.createAssistantOrchestrator(
|
|
3596
|
+
{
|
|
3597
|
+
name: "kendo_react_assistant",
|
|
3598
|
+
title: "KendoReact Assistant",
|
|
3599
|
+
description: UIAgent.ToolDescriptions.assistantOrchestrator(REACT_SUITE_NAME),
|
|
3600
|
+
codeAssistantName: CODE_ASSISTANT_NAME3,
|
|
3601
|
+
iconAssistantName: ICON_ASSISTANT_NAME,
|
|
3602
|
+
suiteName: REACT_SUITE_NAME,
|
|
3603
|
+
libKey: Suite,
|
|
3604
|
+
components: ReactComponents,
|
|
3605
|
+
requiredAccess: ["assistant"]
|
|
3606
|
+
},
|
|
3607
|
+
contextApi2
|
|
3608
|
+
),
|
|
3609
|
+
// Layout Assistant Tool
|
|
3610
|
+
UIAgent.Tools.createLayoutAssistant(
|
|
3611
|
+
{
|
|
3612
|
+
name: LAYOUT_ASSISTANT_NAME,
|
|
3613
|
+
title: "KendoReact Layout Assistant",
|
|
3614
|
+
description: UIAgent.ToolDescriptions.layoutAssistant,
|
|
3615
|
+
suiteName: REACT_SUITE_NAME,
|
|
3616
|
+
libKey: Suite,
|
|
3617
|
+
getPreContent: getLayoutInstructions,
|
|
3618
|
+
requiredAccess: ["agent"]
|
|
3619
|
+
},
|
|
3620
|
+
contextApi2
|
|
3621
|
+
),
|
|
3622
|
+
// Style Assistant Tool
|
|
3623
|
+
UIAgent.Tools.createStyleAssistant(
|
|
3624
|
+
{
|
|
3625
|
+
name: STYLE_ASSISTANT_NAME,
|
|
3626
|
+
title: "KendoReact Style Assistant",
|
|
3627
|
+
description: UIAgent.ToolDescriptions.styleAssistant,
|
|
3628
|
+
libKey: Suite,
|
|
3629
|
+
getPreContent: getStyleInstructions,
|
|
3630
|
+
requiredAccess: ["agent"]
|
|
3631
|
+
},
|
|
3632
|
+
contextApi2
|
|
3633
|
+
),
|
|
3634
|
+
// Icon Search Tool
|
|
3635
|
+
UIAgent.Tools.createIconSearch(
|
|
3636
|
+
{
|
|
3637
|
+
name: ICON_ASSISTANT_NAME,
|
|
3638
|
+
title: "KendoReact Icon Assistant",
|
|
3639
|
+
description: UIAgent.ToolDescriptions.iconAssistant,
|
|
3640
|
+
libKey: Suite,
|
|
3641
|
+
getPostContent: getIconsInstructions,
|
|
3642
|
+
requiredAccess: ["assistant", "agent"]
|
|
3643
|
+
},
|
|
3644
|
+
contextApi2
|
|
3645
|
+
),
|
|
3646
|
+
// Code Assistant Tool
|
|
3647
|
+
UIAgent.Tools.createCodeAssistant(
|
|
3648
|
+
{
|
|
3649
|
+
name: CODE_ASSISTANT_NAME3,
|
|
3650
|
+
title: "KendoReact Component Assistant",
|
|
3651
|
+
description: UIAgent.ToolDescriptions.codeAssistant(REACT_SUITE_NAME),
|
|
3652
|
+
libKey: Suite,
|
|
3653
|
+
suiteName: REACT_SUITE_NAME,
|
|
3654
|
+
components: ReactComponents,
|
|
3655
|
+
componentAliases: { "Grid": "DataGrid" },
|
|
3656
|
+
getPostContent: ({ component }) => {
|
|
3657
|
+
const normComponent = component?.trim().toLowerCase();
|
|
3658
|
+
const componentInstructions = COMPONENT_INSTRUCTIONS_MAP[normComponent];
|
|
3659
|
+
return getComponentsCommonInstructions({ component, componentInstructions });
|
|
3660
|
+
},
|
|
3661
|
+
requiredAccess: ["assistant", "agent"]
|
|
3662
|
+
},
|
|
3663
|
+
contextApi2
|
|
3664
|
+
),
|
|
3665
|
+
// Getting Started Tool
|
|
3666
|
+
new UIAgentTool(
|
|
3667
|
+
GET_STARTED_TOOL_NAME,
|
|
3668
|
+
{
|
|
3669
|
+
title: "KendoReact Getting Started",
|
|
3670
|
+
description: `Creates a new React project with Kendo CLI and provides essential getting started guidance for ${REACT_SUITE_NAME} including installation, configuration, and setup instructions.`,
|
|
3671
|
+
requiredAccess: ["agent"],
|
|
3672
|
+
inputSchema: createGettingStartedInputSchema(REACT_SUITE_NAME, "kendo-react-app")
|
|
3673
|
+
},
|
|
3674
|
+
async ({ projectName, createNewProject, theme }, { _meta }) => {
|
|
3675
|
+
try {
|
|
3676
|
+
await contextApi2.recordToolUserRequest({
|
|
3677
|
+
toolName: GET_STARTED_TOOL_NAME,
|
|
3678
|
+
meta: {
|
|
3679
|
+
projectName,
|
|
3680
|
+
createNewProject,
|
|
3681
|
+
theme,
|
|
3682
|
+
_meta
|
|
3683
|
+
}
|
|
3684
|
+
});
|
|
3685
|
+
} catch (error) {
|
|
3686
|
+
console.error("Error recording tool request:", error);
|
|
3687
|
+
}
|
|
3688
|
+
const instructions = getGettingStartedInstructions(projectName, createNewProject, theme);
|
|
3689
|
+
return {
|
|
3690
|
+
content: [
|
|
3691
|
+
{
|
|
3692
|
+
type: "text",
|
|
3693
|
+
text: instructions
|
|
3694
|
+
}
|
|
3695
|
+
]
|
|
3696
|
+
};
|
|
3697
|
+
}
|
|
3698
|
+
),
|
|
3699
|
+
// Accessibility Tool
|
|
3700
|
+
UIAgent.Tools.createAccessibilityAssistant(
|
|
3701
|
+
{
|
|
3702
|
+
name: ACCESSIBILITY_ASSISTANT_NAME,
|
|
3703
|
+
title: "KendoReact Accessibility Assistant",
|
|
3704
|
+
description: UIAgent.ToolDescriptions.accessibilityAssistant(REACT_SUITE_NAME),
|
|
3705
|
+
libKey: Suite,
|
|
3706
|
+
suiteName: REACT_SUITE_NAME,
|
|
3707
|
+
components: ReactComponents,
|
|
3708
|
+
componentAliases: { "Grid": "DataGrid" },
|
|
3709
|
+
requiredAccess: ["agent"]
|
|
3710
|
+
},
|
|
3711
|
+
contextApi2
|
|
3712
|
+
),
|
|
3713
|
+
// Figma Design-to-Code Tool (only when FIGMA_API_KEY is set)
|
|
3714
|
+
...process.env.FIGMA_API_KEY ? [UIAgent.Tools.createFigmaD2C(
|
|
3715
|
+
{ name: FIGMA_D2C_TOOL_NAME, figmaApiKey: process.env.FIGMA_API_KEY, requiredAccess: ["agent"] },
|
|
3716
|
+
contextApi2
|
|
3717
|
+
)] : []
|
|
3718
|
+
];
|
|
3719
|
+
return allTools.filter((tool) => tool.hasAccess(accessType));
|
|
3720
|
+
}
|
|
3721
|
+
|
|
3722
|
+
// packages/react/src/index.ts
|
|
3723
|
+
var __filename2 = fileURLToPath3(import.meta.url);
|
|
3724
|
+
var __dirname2 = path3.dirname(__filename2);
|
|
3725
|
+
var packageJsonPath2 = path3.resolve(__dirname2, "../package.json");
|
|
3726
|
+
var packageJson2 = JSON.parse(fs3.readFileSync(packageJsonPath2, "utf-8"));
|
|
3727
|
+
var server = new McpServer({
|
|
3728
|
+
name: "kendo-mcp",
|
|
3729
|
+
title: "Kendo MCP Server",
|
|
3730
|
+
version: packageJson2.version
|
|
3731
|
+
});
|
|
3732
|
+
async function startServer() {
|
|
3733
|
+
const transport = new StdioServerTransport();
|
|
3734
|
+
log("Starting server... ");
|
|
3735
|
+
const accessType = await checkAccess(async () => {
|
|
3736
|
+
const response = await validateUserLicense();
|
|
3737
|
+
const entitlement = response?.entitlement;
|
|
3738
|
+
return entitlement?.Product?.Code || entitlement?.product?.code;
|
|
3739
|
+
});
|
|
3740
|
+
if (accessType !== "none") {
|
|
3741
|
+
contextApi.toolNameHeader = accessType === "agent" || accessType === "full" ? "agent" : "assistant";
|
|
3742
|
+
const reactTools = createReactTools(contextApi, accessType);
|
|
3743
|
+
reactTools.forEach((tool) => tool.register(server));
|
|
3744
|
+
startHeartbeat({
|
|
3745
|
+
serverName: "react",
|
|
3746
|
+
contextApi,
|
|
3747
|
+
additionalFields: {
|
|
3748
|
+
version: packageJson2.version,
|
|
3749
|
+
access_type: accessType
|
|
3750
|
+
}
|
|
3751
|
+
});
|
|
3752
|
+
}
|
|
3753
|
+
await server.connect(transport);
|
|
3754
|
+
}
|
|
3755
|
+
startServer();
|