feat: Update check against pi.dev (#3877)
This commit is contained in:
@@ -83,8 +83,10 @@ import { getChangelogPath, getNewEntries, parseChangelog } from "../../utils/cha
|
||||
import { copyToClipboard } from "../../utils/clipboard.js";
|
||||
import { extensionForImageMimeType, readClipboardImage } from "../../utils/clipboard-image.js";
|
||||
import { parseGitUrl } from "../../utils/git.js";
|
||||
import { getPiUserAgent } from "../../utils/pi-user-agent.js";
|
||||
import { killTrackedDetachedChildren } from "../../utils/shell.js";
|
||||
import { ensureTool } from "../../utils/tools-manager.js";
|
||||
import { checkForNewPiVersion } from "../../utils/version-check.js";
|
||||
import { ArminComponent } from "./components/armin.js";
|
||||
import { AssistantMessageComponent } from "./components/assistant-message.js";
|
||||
import { BashExecutionComponent } from "./components/bash-execution.js";
|
||||
@@ -708,7 +710,7 @@ export class InteractiveMode {
|
||||
await this.init();
|
||||
|
||||
// Start version check asynchronously
|
||||
this.checkForNewVersion().then((newVersion) => {
|
||||
checkForNewPiVersion(this.version).then((newVersion) => {
|
||||
if (newVersion) {
|
||||
this.showNewVersionNotification(newVersion);
|
||||
}
|
||||
@@ -779,31 +781,6 @@ export class InteractiveMode {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Check npm registry for a newer version.
|
||||
*/
|
||||
private async checkForNewVersion(): Promise<string | undefined> {
|
||||
if (process.env.PI_SKIP_VERSION_CHECK || process.env.PI_OFFLINE) return undefined;
|
||||
|
||||
try {
|
||||
const response = await fetch("https://registry.npmjs.org/@mariozechner/pi-coding-agent/latest", {
|
||||
signal: AbortSignal.timeout(10000),
|
||||
});
|
||||
if (!response.ok) return undefined;
|
||||
|
||||
const data = (await response.json()) as { version?: string };
|
||||
const latestVersion = data.version;
|
||||
|
||||
if (latestVersion && latestVersion !== this.version) {
|
||||
return latestVersion;
|
||||
}
|
||||
|
||||
return undefined;
|
||||
} catch {
|
||||
return undefined;
|
||||
}
|
||||
}
|
||||
|
||||
private async checkForPackageUpdates(): Promise<string[]> {
|
||||
if (process.env.PI_OFFLINE) {
|
||||
return [];
|
||||
@@ -909,7 +886,10 @@ export class InteractiveMode {
|
||||
return;
|
||||
}
|
||||
|
||||
void fetch(`https://pi.dev/install?version=${encodeURIComponent(version)}`, {
|
||||
void fetch(`https://pi.dev/api/report-install?version=${encodeURIComponent(version)}`, {
|
||||
headers: {
|
||||
"User-Agent": getPiUserAgent(version),
|
||||
},
|
||||
signal: AbortSignal.timeout(5000),
|
||||
})
|
||||
.then(() => undefined)
|
||||
|
||||
Reference in New Issue
Block a user