@lunacode/opencode-plugin-intelligence 0.1.2 → 0.1.3

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.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@lunacode/opencode-plugin-intelligence",
3
- "version": "0.1.2",
3
+ "version": "0.1.3",
4
4
  "license": "CC-BY-NC-SA-4.0",
5
5
  "description": "Annotate OpenCode model names with the Artificial Analysis Intelligence Index.",
6
6
  "type": "module",
@@ -2,6 +2,15 @@ function decodeFlightChunk(chunk) {
2
2
  return JSON.parse(`"${chunk}"`);
3
3
  }
4
4
 
5
+ function hasScoredModels(models) {
6
+ return (
7
+ Array.isArray(models) &&
8
+ models.some((model) =>
9
+ Number.isFinite(model?.intelligenceIndex ?? model?.intelligence_index),
10
+ )
11
+ );
12
+ }
13
+
5
14
  function visit(value, predicate) {
6
15
  if (predicate(value)) {
7
16
  return value;
@@ -41,7 +50,8 @@ function extractModelsFromFlightPayload(html) {
41
50
  if (separatorIndex === -1) continue;
42
51
  const payloadText = record.slice(separatorIndex + 1).trim();
43
52
  if (
44
- !payloadText.includes('"models"') ||
53
+ (!payloadText.includes('"models"') &&
54
+ !payloadText.includes('"initialModels"')) ||
45
55
  (!payloadText.includes('"intelligence_index"') &&
46
56
  !payloadText.includes('"intelligenceIndex"'))
47
57
  )
@@ -56,14 +66,12 @@ function extractModelsFromFlightPayload(html) {
56
66
  const matchedNode = visit(
57
67
  payload,
58
68
  (node) =>
59
- Array.isArray(node?.models) &&
60
- node.models.some((model) =>
61
- Number.isFinite(
62
- model?.intelligenceIndex ?? model?.intelligence_index,
63
- ),
64
- ),
69
+ hasScoredModels(node?.models) || hasScoredModels(node?.initialModels),
65
70
  );
66
- if (matchedNode) return matchedNode.models;
71
+ if (matchedNode)
72
+ return hasScoredModels(matchedNode.models)
73
+ ? matchedNode.models
74
+ : matchedNode.initialModels;
67
75
  }
68
76
 
69
77
  throw new Error("Could not find leaderboard models in React Flight payload");