local repo = jarvis.memory.recall("github.repo") if not repo or repo == "" then return jarvis.cmd.not_found("Сначала укажите репозиторий: текущий репо owner/repo.") end local result = jarvis.system.exec(string.format( 'gh pr list --repo "%s" --state open --json number,title,author,createdAt --limit 10', repo )) if not result or not result.success then local err = (result and result.stderr) or "gh CLI не доступен" jarvis.log("warn", "gh failed: " .. err) return jarvis.cmd.error("gh CLI не отвечает. Установите gh и выполните gh auth login.") end local stdout = result.stdout or "" if stdout:gsub("%s", "") == "" or stdout:gsub("%s", "") == "[]" then return jarvis.cmd.ok("Открытых пиаров нет.") end -- Parse JSON via LLM (mlua doesn't ship a JSON parser by default). -- Alternatively count number entries with a regex. local _, count = stdout:gsub('"number"%s*:', "") if count == 0 then return jarvis.cmd.ok("Открытых пиаров нет.") end -- Get titles local titles = {} for title in stdout:gmatch('"title"%s*:%s*"([^"]+)"') do table.insert(titles, title) if #titles >= 3 then break end end local line = string.format("%d открытых пиаров. ", count) if #titles > 0 then line = line .. "Первые: " .. table.concat(titles, ". ") .. "." end return jarvis.cmd.ok(line)