@tscgoods/opencode-effort-discovery 0.3.1 → 0.4.8

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.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/src/index.ts +8 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tscgoods/opencode-effort-discovery",
3
- "version": "0.3.1",
3
+ "version": "0.4.8",
4
4
  "description": "OpenCode plugin: show exactly the reasoning effort levels your provider actually accepts.",
5
5
  "type": "module",
6
6
  "license": "MIT",
package/src/index.ts CHANGED
@@ -99,8 +99,10 @@ export function parseLevels(text: string): string[] | null {
99
99
  .map((item) => item.trim().replace(/^[`'"\s]+|[`'"\s.]+$/g, "").toLowerCase())
100
100
  .filter((item) => /^[a-z0-9_-]+$/.test(item))
101
101
 
102
- // "valid levels: none, low, high, max"
103
- const valid = /valid levels?:\s*([A-Za-z0-9_`'",\-\s]+)/i.exec(text)
102
+ // 只匹配逗号分隔的档位名,避免把 JSON 里的 "type":"invalid_request_error" 吞进来
103
+ const list = "[a-z0-9_-]+(?:\\s*,\\s*[a-z0-9_-]+)*"
104
+
105
+ const valid = new RegExp(`valid levels?:\\s*(${list})`, "i").exec(text)
104
106
  if (valid) {
105
107
  const levels = clean(valid[1])
106
108
  if (levels.length > 0) return levels
@@ -116,10 +118,10 @@ export function parseLevels(text: string): string[] | null {
116
118
  }
117
119
 
118
120
  // "supported levels are low|medium|high|max"
119
- const supported =
120
- /(?:supported|allowed|valid)\s+(?:levels|values|efforts)[^:\n]*[:-]\s*([A-Za-z0-9_`'",\-\s]+)/i.exec(
121
- text,
122
- )
121
+ const supported = new RegExp(
122
+ `(?:supported|allowed|valid)\\s+(?:levels|values|efforts)[^:\\n]*[:-]\\s*(${list})`,
123
+ "i",
124
+ ).exec(text)
123
125
  if (supported) {
124
126
  const levels = clean(supported[1])
125
127
  if (levels.length > 0) return levels