test: address custom widget review findings
This commit is contained in:
1 parent
6eff1da08f
commit
45dd20f4f7
6 files changed
+96
-16
No files matched your search
@@ -47,6 +47,7 @@ const program = ts.createProgram({ rootNames: [...config.fileNames, import.meta.
|
||||
const checker = program.getTypeChecker();
|
||||
const source = program.getSourceFile(import.meta.filename);
|
||||
if (!source) throw new Error("Unable to inspect the component catalog generator");
|
||||
const sourceNode: ts.Node = source;
|
||||
|
||||
const moduleSymbols = new Map<string, ts.Symbol>();
|
||||
for (const declaration of source.statements) {
|
||||
@@ -163,7 +164,7 @@ function inspectMantineComponent(component: CatalogSourceComponent): InspectedCo
|
||||
const rootName = component.name.split(".")[0];
|
||||
let symbol =
|
||||
moduleSymbol && checker.getExportsOfModule(moduleSymbol).find((candidate) => candidate.name === rootName);
|
||||
let location = symbol?.valueDeclaration ?? symbol?.declarations?.[0] ?? source;
|
||||
let location: ts.Node = symbol?.valueDeclaration ?? symbol?.declarations?.[0] ?? sourceNode;
|
||||
let type = symbol && checker.getTypeOfSymbolAtLocation(symbol, location);
|
||||
for (const segment of component.name.split(".").slice(1)) {
|
||||
symbol = type?.getProperty(segment);
|
||||
@@ -311,7 +312,7 @@ function mergeGlobalProp(name: string, candidates: UninternedPropDescriptor[]):
|
||||
const fallback = createFallbackProp(name, "global");
|
||||
const type = mostFrequent(candidates.map((candidate) => candidate.type)) ?? fallback.type;
|
||||
const descriptions = candidates.flatMap(({ description }) => (description ? [description] : []));
|
||||
const literalValues = uniqueLiterals(candidates.flatMap(({ literalValues }) => literalValues ?? []));
|
||||
const literalValues = uniqueLiterals(candidates.flatMap((candidate) => candidate.literalValues ?? []));
|
||||
return {
|
||||
name,
|
||||
type,
|
||||
|
||||
@@ -23,7 +23,7 @@ export const customWidgetMcpAgentResultSchema = z.strictObject({
|
||||
status: z.enum(["pass", "needs-user-configuration", "fail"]),
|
||||
summary: z.string().min(1).max(1_000),
|
||||
definitionId: z.string().min(1).nullable(),
|
||||
previewUrl: z.string().url().nullable(),
|
||||
previewUrl: z.url().nullable(),
|
||||
iterations: z.number().int().min(1).max(20),
|
||||
evidence: z
|
||||
.array(
|
||||
@@ -168,7 +168,8 @@ export function getCustomWidgetMcpWorkflowIssues(args: {
|
||||
issues.push("customWidget_get must run before validating an edit");
|
||||
}
|
||||
const previewCreate = firstSuccessfulIndex("customWidget_previewCreate");
|
||||
if (finalValidation >= 0 && previewCreate >= 0 && finalValidation > previewCreate) {
|
||||
const finalPreviewCreate = lastSuccessfulIndex("customWidget_previewCreate");
|
||||
if (finalValidation >= 0 && finalPreviewCreate >= 0 && finalValidation > finalPreviewCreate) {
|
||||
issues.push("The final validation must run before customWidget_previewCreate");
|
||||
}
|
||||
const previewChecks = [
|
||||
@@ -194,10 +195,12 @@ export function getCustomWidgetMcpWorkflowIssues(args: {
|
||||
}
|
||||
}
|
||||
const finalJournal = lastSuccessfulIndex("customWidget_previewJournal");
|
||||
for (const tool of ["customWidget_previewQuery", "customWidget_previewAction"]) {
|
||||
if (lastSuccessfulIndex(tool) > finalJournal) {
|
||||
issues.push("customWidget_previewJournal must run after all preview requests");
|
||||
break;
|
||||
if (finalJournal >= 0) {
|
||||
for (const tool of ["customWidget_previewQuery", "customWidget_previewAction"]) {
|
||||
if (lastSuccessfulIndex(tool) > finalJournal) {
|
||||
issues.push("customWidget_previewJournal must run after all preview requests");
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user