@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.
- package/package.json +1 -1
- package/src/index.ts +8 -6
package/package.json
CHANGED
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
|
-
//
|
|
103
|
-
const
|
|
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
|
-
|
|
121
|
-
|
|
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
|