@phi-code-admin/phi-code 0.58.9 → 0.59.1
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.
|
@@ -456,7 +456,10 @@ export default function benchmarkExtension(pi: ExtensionAPI) {
|
|
|
456
456
|
const categories: ModelBenchmark["categories"] = {};
|
|
457
457
|
let totalTime = 0;
|
|
458
458
|
|
|
459
|
-
for (
|
|
459
|
+
for (let testIdx = 0; testIdx < tests.length; testIdx++) {
|
|
460
|
+
const test = tests[testIdx];
|
|
461
|
+
// Rate limiting: 1.5s between API calls to avoid throttling
|
|
462
|
+
if (testIdx > 0) await new Promise(r => setTimeout(r, 1500));
|
|
460
463
|
ctx.ui.notify(` ⏳ ${test.category}: ${test.name}...`, "info");
|
|
461
464
|
|
|
462
465
|
try {
|
|
@@ -622,10 +625,12 @@ Scoring: S (80+), A (65+), B (50+), C (35+), D (<35)`, "info");
|
|
|
622
625
|
return;
|
|
623
626
|
}
|
|
624
627
|
|
|
625
|
-
// Get available models
|
|
628
|
+
// Get available models (validates API keys are non-empty and reasonable length)
|
|
626
629
|
const available = getAvailableModels();
|
|
627
630
|
if (available.length === 0) {
|
|
628
|
-
|
|
631
|
+
const providers = getProviderConfigs();
|
|
632
|
+
const hint = providers.map(p => ` ${p.envVar}: ${process.env[p.envVar] ? "set but no models configured" : "not set"}`).join("\n");
|
|
633
|
+
ctx.ui.notify(`❌ No benchmarkable models found.\n\nProvider status:\n${hint}\n\nSet at least one API key with known models.`, "warning");
|
|
629
634
|
return;
|
|
630
635
|
}
|
|
631
636
|
|
package/extensions/phi/init.ts
CHANGED
|
@@ -174,13 +174,13 @@ function createRouting(assignments: Record<string, { preferred: string; fallback
|
|
|
174
174
|
description: role.desc,
|
|
175
175
|
keywords: KEYWORDS[role.key] || [],
|
|
176
176
|
preferredModel: assignment?.preferred || role.defaultModel,
|
|
177
|
-
fallback: assignment?.fallback ||
|
|
177
|
+
fallback: assignment?.fallback || role.defaultModel,
|
|
178
178
|
agent: role.agent,
|
|
179
179
|
};
|
|
180
180
|
}
|
|
181
181
|
return {
|
|
182
182
|
routes,
|
|
183
|
-
default: { model: assignments["default"]?.preferred || "
|
|
183
|
+
default: { model: assignments["default"]?.preferred || "default", agent: null },
|
|
184
184
|
};
|
|
185
185
|
}
|
|
186
186
|
|
|
@@ -381,7 +381,7 @@ _Edit this file to customize Phi Code's behavior for your project._
|
|
|
381
381
|
const assignments: Record<string, { preferred: string; fallback: string }> = {};
|
|
382
382
|
|
|
383
383
|
if (availableModels.length === 0) {
|
|
384
|
-
const fb = { preferred: "
|
|
384
|
+
const fb = { preferred: "default", fallback: "default" };
|
|
385
385
|
for (const role of TASK_ROLES) assignments[role.key] = fb;
|
|
386
386
|
assignments["default"] = fb;
|
|
387
387
|
return assignments;
|
package/extensions/phi/memory.ts
CHANGED
|
@@ -28,7 +28,7 @@ import { SigmaMemory } from "sigma-memory";
|
|
|
28
28
|
export default function memoryExtension(pi: ExtensionAPI) {
|
|
29
29
|
// Initialize sigma-memory
|
|
30
30
|
const sigmaMemory = new SigmaMemory({
|
|
31
|
-
//
|
|
31
|
+
// Default configuration, can be overridden
|
|
32
32
|
qmdEnabled: true,
|
|
33
33
|
qmdCommand: 'qmd'
|
|
34
34
|
});
|
|
@@ -80,7 +80,7 @@ export default function memoryExtension(pi: ExtensionAPI) {
|
|
|
80
80
|
for (const [source, sourceResults] of Object.entries(groupedResults)) {
|
|
81
81
|
resultText += `## ${source.toUpperCase()} (${sourceResults.length} results)\n\n`;
|
|
82
82
|
|
|
83
|
-
for (const result of sourceResults.slice(0, 5)) { //
|
|
83
|
+
for (const result of sourceResults.slice(0, 5)) { // Limit to 5 results per source
|
|
84
84
|
resultText += `**Score: ${result.score.toFixed(2)}** | Type: ${result.type}\n`;
|
|
85
85
|
|
|
86
86
|
if (result.source === 'notes') {
|
|
@@ -30,6 +30,19 @@ export default function webSearchExtension(pi: ExtensionAPI) {
|
|
|
30
30
|
const BRAVE_API_KEY = process.env.BRAVE_API_KEY;
|
|
31
31
|
const BRAVE_API_URL = "https://api.search.brave.com/res/v1/web/search";
|
|
32
32
|
|
|
33
|
+
// Rate limiting: max 1 request per second (Brave free tier limit)
|
|
34
|
+
let lastRequestTime = 0;
|
|
35
|
+
const MIN_INTERVAL_MS = 1100;
|
|
36
|
+
|
|
37
|
+
async function rateLimitWait(): Promise<void> {
|
|
38
|
+
const now = Date.now();
|
|
39
|
+
const elapsed = now - lastRequestTime;
|
|
40
|
+
if (elapsed < MIN_INTERVAL_MS) {
|
|
41
|
+
await new Promise(resolve => setTimeout(resolve, MIN_INTERVAL_MS - elapsed));
|
|
42
|
+
}
|
|
43
|
+
lastRequestTime = Date.now();
|
|
44
|
+
}
|
|
45
|
+
|
|
33
46
|
/**
|
|
34
47
|
* Search using Brave Search API
|
|
35
48
|
*/
|
|
@@ -49,6 +62,7 @@ export default function webSearchExtension(pi: ExtensionAPI) {
|
|
|
49
62
|
spellcheck: "true"
|
|
50
63
|
});
|
|
51
64
|
|
|
65
|
+
await rateLimitWait();
|
|
52
66
|
const response = await fetch(`${BRAVE_API_URL}?${params}`, {
|
|
53
67
|
method: "GET",
|
|
54
68
|
headers: {
|
|
@@ -278,7 +292,14 @@ export default function webSearchExtension(pi: ExtensionAPI) {
|
|
|
278
292
|
* Show search configuration on session start
|
|
279
293
|
*/
|
|
280
294
|
pi.on("session_start", async (_event, ctx) => {
|
|
281
|
-
|
|
282
|
-
|
|
295
|
+
if (BRAVE_API_KEY) {
|
|
296
|
+
if (BRAVE_API_KEY.length < 10) {
|
|
297
|
+
ctx.ui.notify("⚠️ BRAVE_API_KEY looks invalid (too short). Using DuckDuckGo fallback.", "warning");
|
|
298
|
+
} else {
|
|
299
|
+
ctx.ui.notify("🌐 Web search enabled (Brave Search API)", "info");
|
|
300
|
+
}
|
|
301
|
+
} else {
|
|
302
|
+
ctx.ui.notify("🌐 Web search enabled (DuckDuckGo fallback — set BRAVE_API_KEY for better results)", "info");
|
|
303
|
+
}
|
|
283
304
|
});
|
|
284
305
|
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@phi-code-admin/phi-code",
|
|
3
|
-
"version": "0.
|
|
3
|
+
"version": "0.59.1",
|
|
4
4
|
"description": "Coding agent CLI with read, bash, edit, write tools and session management",
|
|
5
5
|
"type": "module",
|
|
6
6
|
"piConfig": {
|
|
@@ -58,9 +58,9 @@
|
|
|
58
58
|
"phi-code-ai": "^0.56.3",
|
|
59
59
|
"phi-code-tui": "^0.56.3",
|
|
60
60
|
"proper-lockfile": "^4.1.2",
|
|
61
|
-
"sigma-agents": "^0.1.
|
|
62
|
-
"sigma-memory": "^0.1.
|
|
63
|
-
"sigma-skills": "^0.1.
|
|
61
|
+
"sigma-agents": "^0.1.5",
|
|
62
|
+
"sigma-memory": "^0.1.1",
|
|
63
|
+
"sigma-skills": "^0.1.1",
|
|
64
64
|
"strip-ansi": "^7.1.0",
|
|
65
65
|
"undici": "^7.19.1",
|
|
66
66
|
"yaml": "^2.8.2"
|