Skip to content

Where agent teams gather. Cross-platform team chat where AI agents are first-class teammates — with cloud or bring-your-own (Claude Code / Codex) brains.

TypeScript

Merge pull request #90 from bingqilinweimaotai/fix/windows-cli-path-encoding

LILAC0fd1e0878b17
diff --cc electron/main.cjs
index 5f32809,33bc859..77e2bd1
--- a/electron/main.cjs
+++ b/electron/main.cjs
@@@ -1514,97 -1439,14 +1515,101 @@@ function spawnText(cmd, args, envPath,
})
}
+function parseCliVersion(text) {
+ if (!text) return null
+ const m = text.match(/v?(\d{4}\.\d{2}\.\d{2}(?:-[\w.]+)?|\d+\.\d+\.\d+(?:[-+][\w.]+)?)/i)
+ return m ? m[1] : null
+}
+
+function versionParts(v) {
+ const main = String(v).replace(/^v/i, '').split(/[-+]/)[0]
+ return main.split('.').map((n) => Number.parseInt(n, 10) || 0)
+}
+
+function isCliOutdated(current, latest) {
+ if (!current || !latest) return false
+ if (current === latest) return false
+ const a = versionParts(current)
+ const b = versionParts(latest)
+ const n = Math.max(a.length, b.length)
+ for (let i = 0; i < n; i++) {
+ const x = a[i] ?? 0
+ const y = b[i] ?? 0
+ if (y > x) return true
+ if (y < x) return false
+ }
+ return false
+}
+
+function fetchJson(url, timeoutMs = 5000) {
+ return new Promise((resolve) => {
+ const req = https.get(url, {
+ headers: { 'User-Agent': 'cumora-desktop', Accept: 'application/json' },
+ }, (res) => {
+ if (res.statusCode && res.statusCode >= 300 && res.statusCode < 400 && res.headers.location) {
+ res.resume()
+ fetchJson(res.headers.location, timeoutMs).then(resolve)
+ return
+ }
+ let body = ''
+ res.on('data', (chunk) => { body += chunk })
+ res.on('end', () => {
+ try { resolve(JSON.parse(body)) } catch { resolve(null) }
+ })
+ })
+ req.on('error', () => resolve(null))
+ req.setTimeout(timeoutMs, () => { req.destroy(); resolve(null) })
+ })
+}
+
+async function npmLatest(pkg) {
+ const cached = npmLatestCache.get(pkg)
+ if (cached && Date.now() - cached.at < NPM_LATEST_TTL_MS) return cached.version
+ const data = await fetchJson(`https://registry.npmjs.org/${encodeURIComponent(pkg)}/latest`)
+ const version = typeof data?.version === 'string' ? data.version : null
+ if (version) npmLatestCache.set(pkg, { at: Date.now(), version })
+ return version
+}
+
+function parseCursorAbout(text) {
+ const latestLine = text.split(/\r?\n/).find((line) => /^\s*Latest\b/i.test(line))
+ if (!latestLine) return null
+ return parseCliVersion(latestLine)
+}
+
+function parseGrokCheck(text) {
+ try {
+ const data = JSON.parse(text)
+ return typeof data.latestVersion === 'string' ? data.latestVersion : null
+ } catch {
+ return parseCliVersion(text)
+ }
+}
+
+async function detectCliLatest(spec, resolved, envPath) {
+ try {
+ if (spec.latestVia === 'cursor-about') {
+ const about = await spawnText(resolved, ['about'], envPath, 10000)
+ return parseCursorAbout(about) || parseCliVersion(about)
+ }
+ if (spec.latestVia === 'grok-check') {
+ const check = await spawnText(resolved, ['update', '--check', '--json'], envPath, 12000)
+ const fromCheck = parseGrokCheck(check)
+ if (fromCheck) return fromCheck
+ }
+ if (spec.npm) return await npmLatest(spec.npm)
+ } catch { /* keep local-only */ }
+ return null
+}
+
async function resolveCliPath(bin, envPath) {
- const whichCmd = process.platform === 'win32' ? 'where' : 'which'
- const fromWhich = (await spawnText(whichCmd, [bin], envPath)).split(/\r?\n/)[0]?.trim()
- if (fromWhich) return fromWhich
+ if (process.platform === 'win32') {
+ const fromPath = await findWindowsCommand(bin, envPath ?? process.env.PATH ?? '')
+ if (fromPath) return fromPath
+ } else {
+ const fromWhich = (await spawnText('which', [bin], envPath)).split(/\r?\n/)[0]?.trim()
+ if (fromWhich) return fromWhich
+ }
const home = os.homedir()
const names = process.platform === 'win32' ? [bin, `${bin}.cmd`, `${bin}.exe`] : [bin]
const dirs = [