fix: prevent crash when DiscoverSkills receives undefined query via ExecuteExtraTool

searchSkills() called .trim() on query without null-guard. When
DiscoverSkills is invoked through ExecuteExtraTool with missing
description, query is undefined, causing 'Cannot read properties of
undefined (reading trim)'.

Fixed with optional chaining: !query.trim() → !query?.trim()

Co-Authored-By: deepseek-v4-pro <deepseek-ai@claude-code-best.win>
This commit is contained in:
claude-code-best
2026-06-02 11:09:43 +08:00
parent 02298cb199
commit 18437c20d2

View File

@@ -385,7 +385,7 @@ export function searchSkills(
index: SkillIndexEntry[], index: SkillIndexEntry[],
limit = 5, limit = 5,
): SearchResult[] { ): SearchResult[] {
if (index.length === 0 || !query.trim()) return [] if (index.length === 0 || !query?.trim()) return []
const queryTokens = tokenizeAndStem(query) const queryTokens = tokenizeAndStem(query)
if (queryTokens.length === 0) return [] if (queryTokens.length === 0) return []