refactor: чистка мёртвого кода, лимит ходов D3, HTML-экранирование и UTF-8 обрезка в Telegram
This commit is contained in:
@@ -4,7 +4,6 @@
|
||||
// Контракты перенесены 1-в-1 из Python-версии (extract.py / opencode.py):
|
||||
// - ExtractVerdict: последний text-парт из NDJSON-потока opencode run --format json
|
||||
// - ExtractJSON: fenced ```json``` → первый {...}
|
||||
// - Run/ResumeDev: запуск процесса с idle/hard timeout по opencode.db
|
||||
package opencode
|
||||
|
||||
import (
|
||||
@@ -14,9 +13,8 @@ import (
|
||||
)
|
||||
|
||||
var (
|
||||
fenceRe = regexp.MustCompile("```(?:json)?\\s*([\\s\\S]*?)```")
|
||||
jsonBlockRe = regexp.MustCompile("\\{[\\s\\S]*\\}")
|
||||
sessionRe = regexp.MustCompile(`"session_id"\s*:\s*"([^"]+)"`)
|
||||
fenceRe = regexp.MustCompile("```(?:json)?\\s*([\\s\\S]*?)```")
|
||||
jsonBlockRe = regexp.MustCompile("\\{[\\s\\S]*\\}")
|
||||
)
|
||||
|
||||
// ExtractVerdict возвращает текст вердикта из NDJSON-потока opencode run --format json.
|
||||
@@ -76,15 +74,6 @@ func ExtractJSON(text string) (map[string]json.RawMessage, bool) {
|
||||
return nil, false
|
||||
}
|
||||
|
||||
// SessionIDFromOutput извлекает session_id из текстового вывода opencode.
|
||||
func SessionIDFromOutput(out string) (string, bool) {
|
||||
m := sessionRe.FindStringSubmatch(out)
|
||||
if len(m) > 1 && m[1] != "" {
|
||||
return m[1], true
|
||||
}
|
||||
return "", false
|
||||
}
|
||||
|
||||
// stripFence обрезает внешние ```json``` (или ```) ограждения вокруг фрагмента.
|
||||
// Используется для вердиктов, которые модель может вернуть в markdown-фенсе.
|
||||
func stripFence(s string) string {
|
||||
|
||||
Reference in New Issue
Block a user