MCPcopy Index your code
hub / github.com/codeaashu/claude-code / parseAutoPercentage

Function parseAutoPercentage

src/utils/toolSearch.ts:55–70  ·  view source on GitHub ↗

* Parse auto:N syntax from ENABLE_TOOL_SEARCH env var. * Returns the percentage clamped to 0-100, or null if not auto:N format or not a number.

(value: string)

Source from the content-addressed store, hash-verified

53 * Returns the percentage clamped to 0-100, or null if not auto:N format or not a number.
54 */
55function parseAutoPercentage(value: string): number | null {
56 if (!value.startsWith('auto:')) return null
57
58 const percentStr = value.slice(5)
59 const percent = parseInt(percentStr, 10)
60
61 if (isNaN(percent)) {
62 logForDebugging(
63 `Invalid ENABLE_TOOL_SEARCH value "${value}": expected auto:N where N is a number.`,
64 )
65 return null
66 }
67
68 // Clamp to valid range
69 return Math.max(0, Math.min(100, percent))
70}
71
72/**
73 * Check if ENABLE_TOOL_SEARCH is set to auto mode (auto or auto:N).

Callers 2

getToolSearchModeFunction · 0.85

Calls 2

logForDebuggingFunction · 0.85
maxMethod · 0.80

Tested by

no test coverage detected