Skip to content
This repository was archived by the owner on Oct 27, 2026. It is now read-only.

Commit 9d2b05a

Browse files
fix: resolve lint complexity failures blocking CI test check
Extract helpers and apply Biome style fixes so Ultracite passes in the toolkit-docs-generator. Co-authored-by: Cursor <cursoragent@cursor.com>
1 parent 835f255 commit 9d2b05a

4 files changed

Lines changed: 118 additions & 72 deletions

File tree

‎toolkit-docs-generator/scripts/check-stale-summaries.ts‎

Lines changed: 31 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -39,18 +39,29 @@ const listToolkitFiles = (): string[] => {
3939
}
4040
};
4141

42-
const main = (): number => {
42+
const readToolkitShape = (
43+
file: string
44+
): { toolkit: ToolkitShape } | { error: string } => {
45+
try {
46+
const raw = readFileSync(join(TOOLKITS_DIR, file), "utf8");
47+
return { toolkit: JSON.parse(raw) as ToolkitShape };
48+
} catch (error) {
49+
const message = error instanceof Error ? error.message : String(error);
50+
return { error: message };
51+
}
52+
};
53+
54+
const collectStaleSummaries = (
55+
files: string[]
56+
): Array<{ file: string; id: string; reason: string }> => {
4357
const stale: Array<{ file: string; id: string; reason: string }> = [];
44-
for (const file of listToolkitFiles()) {
45-
let toolkit: ToolkitShape;
46-
try {
47-
const raw = readFileSync(join(TOOLKITS_DIR, file), "utf8");
48-
toolkit = JSON.parse(raw) as ToolkitShape;
49-
} catch (error) {
50-
const message = error instanceof Error ? error.message : String(error);
51-
console.error(`✗ Cannot parse ${file}: ${message}`);
52-
return 1;
58+
for (const file of files) {
59+
const result = readToolkitShape(file);
60+
if ("error" in result) {
61+
console.error(`✗ Cannot parse ${file}: ${result.error}`);
62+
throw new Error(`Cannot parse ${file}`);
5363
}
64+
const toolkit = result.toolkit;
5465
if (toolkit.summaryStale === true) {
5566
stale.push({
5667
file,
@@ -62,6 +73,16 @@ const main = (): number => {
6273
});
6374
}
6475
}
76+
return stale;
77+
};
78+
79+
const main = (): number => {
80+
let stale: Array<{ file: string; id: string; reason: string }>;
81+
try {
82+
stale = collectStaleSummaries(listToolkitFiles());
83+
} catch {
84+
return 1;
85+
}
6586

6687
if (stale.length === 0) {
6788
console.log(`✓ No stale summaries in ${TOOLKITS_DIR}`);

‎toolkit-docs-generator/src/cli/exclusion-cleanup.ts‎

Lines changed: 41 additions & 29 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,37 @@ export interface CleanupExcludedToolkitOutputResult {
1818
warnings: string[];
1919
}
2020

21+
const collectRebuildWarnings = (
22+
rebuildResult: RebuildIndexResult,
23+
verbose: boolean
24+
): string[] => {
25+
const warnings: string[] = [];
26+
27+
if (rebuildResult.readErrors.length > 0) {
28+
warnings.push(
29+
`Index rebuild skipped ${rebuildResult.readErrors.length} unreadable toolkit file(s).`
30+
);
31+
if (verbose) {
32+
for (const error of rebuildResult.readErrors) {
33+
warnings.push(`Index rebuild read error: ${error}`);
34+
}
35+
}
36+
}
37+
38+
if (rebuildResult.readWarnings.length > 0) {
39+
warnings.push(
40+
`Index rebuild reported ${rebuildResult.readWarnings.length} warning(s).`
41+
);
42+
if (verbose) {
43+
for (const warning of rebuildResult.readWarnings) {
44+
warnings.push(`Index rebuild warning: ${warning}`);
45+
}
46+
}
47+
}
48+
49+
return warnings;
50+
};
51+
2152
export const cleanupExcludedToolkitOutput = async (
2253
options: CleanupExcludedToolkitOutputOptions
2354
): Promise<CleanupExcludedToolkitOutputResult> => {
@@ -33,37 +64,18 @@ export const cleanupExcludedToolkitOutput = async (
3364
return { deleted, warnings: [] };
3465
}
3566

36-
const warnings: string[] = [];
37-
3867
try {
3968
const rebuildResult = await options.generator.rebuildIndexFromOutput();
40-
41-
if (rebuildResult.readErrors.length > 0) {
42-
warnings.push(
43-
`Index rebuild skipped ${rebuildResult.readErrors.length} unreadable toolkit file(s).`
44-
);
45-
if (options.verbose) {
46-
for (const error of rebuildResult.readErrors) {
47-
warnings.push(`Index rebuild read error: ${error}`);
48-
}
49-
}
50-
}
51-
52-
if (rebuildResult.readWarnings.length > 0) {
53-
warnings.push(
54-
`Index rebuild reported ${rebuildResult.readWarnings.length} warning(s).`
55-
);
56-
if (options.verbose) {
57-
for (const warning of rebuildResult.readWarnings) {
58-
warnings.push(`Index rebuild warning: ${warning}`);
59-
}
60-
}
61-
}
69+
return {
70+
deleted,
71+
warnings: collectRebuildWarnings(rebuildResult, options.verbose),
72+
};
6273
} catch (error) {
63-
warnings.push(
64-
`Excluded toolkit files were deleted, but index rebuild failed: ${error instanceof Error ? error.message : String(error)}`
65-
);
74+
return {
75+
deleted,
76+
warnings: [
77+
`Excluded toolkit files were deleted, but index rebuild failed: ${error instanceof Error ? error.message : String(error)}`,
78+
],
79+
};
6680
}
67-
68-
return { deleted, warnings };
6981
};

‎toolkit-docs-generator/src/diff/previous-output.ts‎

Lines changed: 43 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -259,6 +259,45 @@ type FallbackToolkitResult = {
259259
droppedParameterCount: number;
260260
};
261261

262+
type FallbackSummaryFields = {
263+
summary?: string;
264+
summaryStale?: boolean;
265+
summaryStaleReason?: string;
266+
generatedAt?: string;
267+
};
268+
269+
const readFallbackSummaryFields = (
270+
record: Record<string, unknown>
271+
): FallbackSummaryFields => ({
272+
...(typeof record.summary === "string" ? { summary: record.summary } : {}),
273+
...(typeof record.summaryStale === "boolean"
274+
? { summaryStale: record.summaryStale }
275+
: {}),
276+
...(typeof record.summaryStaleReason === "string"
277+
? { summaryStaleReason: record.summaryStaleReason }
278+
: {}),
279+
...(typeof record.generatedAt === "string"
280+
? { generatedAt: record.generatedAt }
281+
: {}),
282+
});
283+
284+
const readFallbackCustomSections = (
285+
record: Record<string, unknown>
286+
): Pick<
287+
MergedToolkit,
288+
"documentationChunks" | "customImports" | "subPages"
289+
> => ({
290+
documentationChunks: Array.isArray(record.documentationChunks)
291+
? (record.documentationChunks as MergedToolkit["documentationChunks"])
292+
: [],
293+
customImports: Array.isArray(record.customImports)
294+
? (record.customImports as MergedToolkit["customImports"])
295+
: [],
296+
subPages: Array.isArray(record.subPages)
297+
? (record.subPages as MergedToolkit["subPages"])
298+
: [],
299+
});
300+
262301
const buildFallbackToolkit = (
263302
record: Record<string, unknown>,
264303
fallbackId: string
@@ -274,39 +313,16 @@ const buildFallbackToolkit = (
274313

275314
const metadataResult = MergedToolkitMetadataSchema.safeParse(record.metadata);
276315
const authResult = MergedToolkitAuthSchema.safeParse(record.auth);
277-
const summary =
278-
typeof record.summary === "string" ? record.summary : undefined;
279-
const summaryStale =
280-
typeof record.summaryStale === "boolean" ? record.summaryStale : undefined;
281-
const summaryStaleReason =
282-
typeof record.summaryStaleReason === "string"
283-
? record.summaryStaleReason
284-
: undefined;
285-
const generatedAt =
286-
typeof record.generatedAt === "string" ? record.generatedAt : undefined;
287-
288-
// Carry forward custom sections even when strict schema parse fails.
289-
// These are hand-authored fields — losing them silently on any schema
290-
// mismatch would permanently wipe content on the next write.
291-
const documentationChunks = Array.isArray(record.documentationChunks)
292-
? (record.documentationChunks as MergedToolkit["documentationChunks"])
293-
: [];
294-
const customImports = Array.isArray(record.customImports)
295-
? (record.customImports as MergedToolkit["customImports"])
296-
: [];
297-
const subPages = Array.isArray(record.subPages)
298-
? (record.subPages as MergedToolkit["subPages"])
299-
: [];
316+
const summaryFields = readFallbackSummaryFields(record);
317+
const customSections = readFallbackCustomSections(record);
300318

301319
return {
302320
toolkit: {
303321
id: toolkitId,
304322
label,
305323
version,
306324
description,
307-
...(summary ? { summary } : {}),
308-
...(summaryStale !== undefined ? { summaryStale } : {}),
309-
...(summaryStaleReason !== undefined ? { summaryStaleReason } : {}),
325+
...summaryFields,
310326
metadata: metadataResult.success
311327
? metadataResult.data
312328
: DEFAULT_PREVIOUS_TOOLKIT_METADATA,
@@ -316,10 +332,7 @@ const buildFallbackToolkit = (
316332
secretsInfo: [],
317333
documentationChunks: [],
318334
})),
319-
documentationChunks,
320-
customImports,
321-
subPages,
322-
...(generatedAt ? { generatedAt } : {}),
335+
...customSections,
323336
},
324337
droppedToolCount,
325338
droppedParameterCount,

‎toolkit-docs-generator/src/diff/toolkit-diff.ts‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -243,10 +243,10 @@ const hasRelevantMetadataChanges = (
243243
// preserve the previous output (or report the recoverable failure). Only
244244
// two absent snapshots are genuinely unchanged; new toolkits are already
245245
// selected by their tool-level additions.
246-
if (!current && !previous) {
246+
if (!(current || previous)) {
247247
return false;
248248
}
249-
if (!current || !previous) {
249+
if (!(current && previous)) {
250250
return true;
251251
}
252252

@@ -337,7 +337,7 @@ export const compareToolkit = (
337337
toolkitId: string,
338338
currentTools: readonly ToolDefinition[],
339339
previousToolkit: MergedToolkit | undefined,
340-
currentMetadata: ToolkitMetadata | null | undefined = undefined
340+
currentMetadata?: ToolkitMetadata | null
341341
): ToolkitChange => {
342342
const toolChanges = compareTools(currentTools, previousToolkit);
343343
const currentVersion = getToolkitVersion(currentTools);

0 commit comments

Comments
 (0)