MCPcopy Create free account
hub / github.com/cortexkit/magic-context / getSelfVersion

Function getSelfVersion

packages/cli/src/commands/doctor-opencode.ts:126–137  ·  view source on GitHub ↗

Self-version with src/dist layout fallback.

()

Source from the content-addressed store, hash-verified

124
125/** Self-version with src/dist layout fallback. */
126function getSelfVersion(): string {
127 const req = createRequire(import.meta.url);
128 for (const relPath of ["../../package.json", "../package.json"]) {
129 try {
130 const pkg = req(relPath) as { version?: unknown };
131 if (typeof pkg.version === "string" && pkg.version.length > 0) return pkg.version;
132 } catch {
133 // try next
134 }
135 }
136 return "0.0.0";
137}
138
139/** Compare semver-like strings. Returns -1 if a<b, 0 if equal, 1 if a>b. */
140function compareVersions(a: string, b: string): number {

Callers 1

runDoctorFunction · 0.70

Calls 1

reqFunction · 0.85

Tested by

no test coverage detected