pi-free 2.2.5 → 2.2.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -128,6 +128,28 @@ export async function saveProviderCache(
128
128
  _logger.debug(`Saved ${models.length} models to cache for ${providerId}`);
129
129
  }
130
130
 
131
+ /**
132
+ * Persist models to the cache, but refuse to overwrite a healthy existing
133
+ * entry with a drastically smaller list (a transient partial/error response).
134
+ * Also never caches an empty list. Returns true when the cache was written.
135
+ */
136
+ export async function saveProviderCacheGuarded(
137
+ providerId: string,
138
+ models: ProviderModelConfig[],
139
+ ): Promise<boolean> {
140
+ if (!models || models.length === 0) return false;
141
+ const existing = getProviderCacheEntry(providerId);
142
+ const existingCount = existing?.models.length ?? 0;
143
+ if (existingCount > 0 && models.length < existingCount * 0.5) {
144
+ _logger.debug(
145
+ `Not caching ${providerId}: ${models.length} models vs ${existingCount} cached (likely transient shrink)`,
146
+ );
147
+ return false;
148
+ }
149
+ await saveProviderCache(providerId, models);
150
+ return true;
151
+ }
152
+
131
153
  /**
132
154
  * Clear cached models for a provider.
133
155
  */
package/package.json CHANGED
@@ -1,74 +1,74 @@
1
- {
2
- "name": "pi-free",
3
- "version": "2.2.5",
4
- "type": "module",
5
- "description": "AI model providers for Pi with free model filtering and dynamic model fetching",
6
- "keywords": [
7
- "pi-package",
8
- "pi-extension",
9
- "free-models",
10
- "paid-models",
11
- "model-filter",
12
- "nvidia-nim",
13
- "kilo",
14
- "cline",
15
- "zenmux",
16
- "crofai",
17
- "ollama-cloud"
18
- ],
19
- "license": "MIT",
20
- "author": "Apostolos Mantzaris",
21
- "homepage": "https://github.com/apmantza/pi-free#readme",
22
- "bugs": {
23
- "url": "https://github.com/apmantza/pi-free/issues"
24
- },
25
- "repository": {
26
- "type": "git",
27
- "url": "git+https://github.com/apmantza/pi-free.git"
28
- },
29
- "engines": {
30
- "node": ">=20.0.0"
31
- },
32
- "files": [
33
- "index.ts",
34
- "providers/**/*.ts",
35
- "lib/**/*.ts",
36
- "provider-failover/**/*.ts",
37
- "config.ts",
38
- "constants.ts",
39
- "provider-helper.ts",
40
- "README.md",
41
- "LICENSE",
42
- "CHANGELOG.md",
43
- "banner.svg",
44
- "scripts/check-extensions.mjs"
45
- ],
46
- "scripts": {
47
- "audit:prod": "npm audit --omit=dev --audit-level=high",
48
- "check": "node scripts/check-extensions.mjs",
49
- "check:lockfile": "node scripts/check-lockfile-sync.mjs",
50
- "check:tarball": "node scripts/check-tarball.mjs",
51
- "lint": "tsc --noEmit",
52
- "test": "vitest",
53
- "test:ui": "vitest --ui",
54
- "test:run": "vitest run",
55
- "smoke:cline": "tsx scripts/smoke-cline-xml-bridge.ts",
56
- "smoke:openmodel": "tsx scripts/smoke-openmodel-wire-format.ts"
57
- },
58
- "peerDependencies": {
59
- "@earendil-works/pi-ai": "^0.79.8",
60
- "@earendil-works/pi-coding-agent": "^0.79.8",
61
- "@earendil-works/pi-tui": "^0.79.8"
62
- },
63
- "devDependencies": {
64
- "@vitest/ui": "^4.1.5",
65
- "tsx": "^4.0.0",
66
- "typescript": "^6.0.3",
67
- "vitest": "^4.1.5"
68
- },
69
- "pi": {
70
- "extensions": [
71
- "./index.ts"
72
- ]
73
- }
74
- }
1
+ {
2
+ "name": "pi-free",
3
+ "version": "2.2.7",
4
+ "type": "module",
5
+ "description": "AI model providers for Pi with free model filtering and dynamic model fetching",
6
+ "keywords": [
7
+ "pi-package",
8
+ "pi-extension",
9
+ "free-models",
10
+ "paid-models",
11
+ "model-filter",
12
+ "nvidia-nim",
13
+ "kilo",
14
+ "cline",
15
+ "zenmux",
16
+ "crofai",
17
+ "ollama-cloud"
18
+ ],
19
+ "license": "MIT",
20
+ "author": "Apostolos Mantzaris",
21
+ "homepage": "https://github.com/apmantza/pi-free#readme",
22
+ "bugs": {
23
+ "url": "https://github.com/apmantza/pi-free/issues"
24
+ },
25
+ "repository": {
26
+ "type": "git",
27
+ "url": "git+https://github.com/apmantza/pi-free.git"
28
+ },
29
+ "engines": {
30
+ "node": ">=20.0.0"
31
+ },
32
+ "files": [
33
+ "index.ts",
34
+ "providers/**/*.ts",
35
+ "lib/**/*.ts",
36
+ "provider-failover/**/*.ts",
37
+ "config.ts",
38
+ "constants.ts",
39
+ "provider-helper.ts",
40
+ "README.md",
41
+ "LICENSE",
42
+ "CHANGELOG.md",
43
+ "banner.svg",
44
+ "scripts/check-extensions.mjs"
45
+ ],
46
+ "scripts": {
47
+ "audit:prod": "npm audit --omit=dev --audit-level=high",
48
+ "check": "node scripts/check-extensions.mjs",
49
+ "check:lockfile": "node scripts/check-lockfile-sync.mjs",
50
+ "check:tarball": "node scripts/check-tarball.mjs",
51
+ "lint": "tsc --noEmit",
52
+ "test": "vitest",
53
+ "test:ui": "vitest --ui",
54
+ "test:run": "vitest run",
55
+ "smoke:cline": "tsx scripts/smoke-cline-xml-bridge.ts",
56
+ "smoke:openmodel": "tsx scripts/smoke-openmodel-wire-format.ts"
57
+ },
58
+ "peerDependencies": {
59
+ "@earendil-works/pi-ai": ">=0.80.0",
60
+ "@earendil-works/pi-coding-agent": ">=0.80.0",
61
+ "@earendil-works/pi-tui": ">=0.80.0"
62
+ },
63
+ "devDependencies": {
64
+ "@vitest/ui": "^4.1.10",
65
+ "tsx": "^4.23.0",
66
+ "typescript": "^6.0.3",
67
+ "vitest": "^4.1.10"
68
+ },
69
+ "pi": {
70
+ "extensions": [
71
+ "./index.ts"
72
+ ]
73
+ }
74
+ }
@@ -27,7 +27,10 @@ export { HARDCODED_BENCHMARKS, type HardcodedBenchmark };
27
27
 
28
28
  const LOG_DIR = join(homedir(), ".pi");
29
29
  const LOG_FILE = join(LOG_DIR, "modelmatch.log");
30
- let debugEnabled = true;
30
+ // Debug logging writes one sync appendFileSync per model per attempt — far too
31
+ // expensive to leave on during startup (hundreds–thousands of blocking writes).
32
+ // Opt in via PI_FREE_BENCHMARK_DEBUG=1 (or setDebugLogging(true)).
33
+ let debugEnabled = process.env.PI_FREE_BENCHMARK_DEBUG === "1";
31
34
 
32
35
  /**
33
36
  * Enable/disable debug logging