Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 3 additions & 2 deletions packages/cli/src/__tests__/manifest.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ describe("manifest", () => {
);
});

it("should use disk cache when fresh", async () => {
it("should always fetch from GitHub even when cache exists", async () => {
mkdirSync(join(env.testDir, "spawn"), {
recursive: true,
});
Expand All @@ -149,7 +149,8 @@ describe("manifest", () => {
expect(manifest).toHaveProperty("agents");
expect(manifest).toHaveProperty("clouds");
expect(manifest).toHaveProperty("matrix");
expect(global.fetch).not.toHaveBeenCalled();
// Always fetches fresh — cache is only an offline fallback
expect(global.fetch).toHaveBeenCalled();
});

it("should refresh cache when forceRefresh is true", async () => {
Expand Down
22 changes: 2 additions & 20 deletions packages/cli/src/manifest.ts
Original file line number Diff line number Diff line change
Expand Up @@ -117,8 +117,7 @@ const RAW_BASE = `https://raw.githubusercontent.com/${REPO}/main` as const;
const SPAWN_CDN = "https://openrouter.ai/labs/spawn" as const;
/** Static URL for version checks — GitHub release artifact, never changes with repo structure */
const VERSION_URL = `https://github.com/${REPO}/releases/download/cli-latest/version` as const;
const CACHE_TTL = 3600; // 1 hour in seconds
const FETCH_TIMEOUT = 10_000; // 10 seconds
const FETCH_TIMEOUT = 3_000; // 3 seconds — fast fallback on bad wifi

// ── Cache helpers ──────────────────────────────────────────────────────────────

Expand Down Expand Up @@ -236,13 +235,6 @@ async function fetchManifestFromGitHub(): Promise<Manifest | null> {
let _cached: Manifest | null = null;
let _staleCache = false;

function tryLoadFromDiskCache(): Manifest | null {
if (cacheAge() >= CACHE_TTL) {
return null;
}
return readCache();
}

function updateCache(manifest: Manifest): Manifest {
writeCache(manifest);
_cached = manifest;
Expand Down Expand Up @@ -287,17 +279,7 @@ export async function loadManifest(forceRefresh = false): Promise<Manifest> {
return local;
}

// Check disk cache first if not forcing refresh
if (!forceRefresh) {
const cached = tryLoadFromDiskCache();
if (cached) {
_cached = cached;
_staleCache = false;
return cached;
}
}

// Fetch from GitHub
// Always fetch fresh from GitHub — disk cache is offline-only fallback.
const fetched = await fetchManifestFromGitHub();
if (fetched) {
return updateCache(fetched);
Expand Down
Loading