spacehub

surshar / claude-code

Claude Code is an agentic coding tool that lives in your terminal, understands your codebase, and helps you code faster by executing routine tasks, explaining complex code, and handling git workflows - all through natural language commands.

Built by Anthropic · github.com/anthropics

claude-code / mods / telemetry / hooks / context / version-of / version-of.ts
13 lines · 514 BRaw
1/**
2 * A version string reduced to what a row may carry, as the CLI reduces the
3 * Agent SDK's: its semver core, `unknown` as said, else `other`.
4 *
5 * @param version the variable as read; undefined stays undefined
6 * @returns the version for the row, or undefined
7 */
8export function versionOf(version: string | undefined) {
9 const isKept = version === undefined || version === 'unknown'
10 const core = /^\d{1,8}\.\d{1,8}\.\d{1,8}(?!\d)/.exec(version ?? '')?.[0]
11
12 return isKept ? version : (core ?? 'other')
13}