refactor(skills): host-agnostic prompts, replace raw gh with tools/curl #6
Loading…
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Контекст
PR #1 (refactor tools) вырезал GitHub-fallback из кода и расширил
pipeline-statusоракул. Но 9 skills и 2 agents всё ещё инструктируют агентов вызывать rawghчерез bash — что в Forgejo-режиме (безghbinary) падает. 62 упоминания GitHub/gh в skills, 0 — Forgejo. Нужно переписать промпты на host-agnostic + Forgejo-first инструкции.Принцип: новые tools НЕ создаём (см. PR #1 — решение пользователя). Для операций без существующего tool'а (
release create,repo edit,repo create,label create,branch protection set) — используем прямойcurlк Forgejo API в bash-блоке skill'а. Дляpr view/run list/issue view— используемpipeline-statusоракул (расширенный в PR #1).Задача
9 skills — host-agnostic описания (frontmatter description + тело):
issue/SKILL.mdL3: "Creates GitHub issues" → "Creates issues"audit/SKILL.mdL10, L111, L133, L144: "GitHub issue" → "issue"bug-discovery/SKILL.mdL10-11: "gh issue list" →pipeline-statusоракул илиcurl; "GitHub issue" → "issue"spec/SKILL.mdL10, L29, L76, L303, L321: "GitHub owner" → "git-host owner"; "GitHub issues" → "issues"configure-opencode/SKILL.mdL118, L124: примерыgh pr merge*/gh pr checks*→ host-agnostic examplesproject-template/SKILL.mdL3, L8, L11, L49, L80, L82, L96, L99, L124, L173-174, L184: "GitHub" → host-agnosticrelease/SKILL.mdL3, L73, L83: "GitHub Release" → "release"repo-readme/SKILL.mdL26, L29, L31-33, L35, L57, L197, L209, L232: "GitHub" → host-agnosticrun-pipeline/SKILL.mdL30, L69, L75-76, L90-91, L93, L113, L146, L151: "GitHub"/"gh" → host-agnostic6 критичных skills — заменить raw
ghинструкции:issue/SKILL.mdL155-157:gh label create <name> --color <hex>→curl -sX POST -H "Authorization: token $FORGEJO_TOKEN" -H "Content-Type: application/json" "$FORGEJO_URL/api/v1/repos/{owner}/{repo}/labels" -d '{"name":"<name>","color":"<hex>"}'run-pipeline/SKILL.md:gh pr view M --json headRefName,body,title) →pipeline-status({pr_number: M})оракул (возвращает headRefName, body, title)gh run list --branch <headRefName>) →pipeline-status({pr_number: M})оракул (расширенный в PR #1, возвращает CI runs из/actions/tasks)gh run view <run-id> --log-failed) → ссылка наhttps://git.slaid098.dev/{repo}/actions/runs/{N}(веб-UI, деталей jobs через API нет)gh pr checkout M) →git fetch origin pull/M/head:pr-M && git checkout pr-M(git-native, неgh)gh pr view M --json body,title+gh issue view) →pipeline-statusоракулgh run list/view,gh api repos/.../actions/runs— разрешено) →pipeline-statusоракул как единственный способrelease/SKILL.mdL76:gh release create vX.Y.Z --title ... --notes ...→curl -sX POST -H "Authorization: token $FORGEJO_TOKEN" -H "Content-Type: application/json" "$FORGEJO_URL/api/v1/repos/{owner}/{repo}/releases" -d '{"tag_name":"vX.Y.Z","name":"vX.Y.Z","body":"<содержание из changelog>","draft":false,"prerelease":false}'repo-readme/SKILL.mdL29-32:gh repo edit --description/--add-topic→curl -sX PATCH -H "Authorization: token $FORGEJO_TOKEN" -H "Content-Type: application/json" "$FORGEJO_URL/api/v1/repos/{owner}/{repo}" -d '{"description":"<описание>","topics":["topic1","topic2"]}'spec/SKILL.mdL76:GitHub owner: ___→git-host owner: ___(вопрос юзеру)project-template/SKILL.mdL224-304 (Template GITHUB → Template FORGEJO):gh repo view <owner>/<project_name>→curl -s -o /dev/null -w "%{http_code}" -H "Authorization: token $FORGEJO_TOKEN" "$FORGEJO_URL/api/v1/repos/<owner>/<project_name>"(200 = существует, 404 = нет)gh repo create <owner>/<project_name> --public --source=. --remote=origin --push→curl -sX POST -H "Authorization: token $FORGEJO_TOKEN" -H "Content-Type: application/json" "$FORGEJO_URL/api/v1/user/repos" -d '{"name":"<project_name>","private":false,"auto_init":false}'+git remote add origin $FORGEJO_URL/<owner>/<project_name>.git+git push -u origin maingh auth setup-git→git config --local http.https://git.slaid098.dev/.extraheader "Authorization: token $FORGEJO_TOKEN"(или token-in-URL)gh api repos/.../PATCH -f allow_squash_merge=true ...→curl -sX PATCH -H "Authorization: token $FORGEJO_TOKEN" -H "Content-Type: application/json" "$FORGEJO_URL/api/v1/repos/<owner>/<project_name>" -d '{"allow_squash_merge":true,"allow_merge_commit":false,"allow_rebase":false,"default_delete_branch_after_merge":true}'gh api repos/.../rules/branches/main POST --input - <<EOF ... EOF→curl -sX POST -H "Authorization: token $FORGEJO_TOKEN" -H "Content-Type: application/json" "$FORGEJO_URL/api/v1/repos/<owner>/<project_name>/branch_protections" -d '{"branch_name":"main","enable_push":false,"enable_status_check":true,"required_approvals":0}'(Forgejo schema, НЕ GitHub Rules API)2 agents — raw
gh→ tools/оракулы:memory-syncer.md:gh pr view <N> --json body,title→pipeline-status({pr_number: N})оракул (расширенный в PR #1, возвращает body, title)gh pr merge*: deny), L31-33 (gh pr view*/gh issue view*/gh issue list*: allow) → удалить (rawghбольше не используется)reviewer.md:gh pr view <PR_NUMBER> --json headRefName,body,title→pipeline-status({pr_number: N})оракулgh run list --branch <headRefName> --limit 3→pipeline-statusоракулgh pr view --json author→pipeline-statusоракул (расширить, если ещё не возвращает author) илиcurl GET /repos/{repo}/pulls/{N}для authorgh*allow правил), L69 (gh pr merge*: deny) → удалитьgh pr checks/gh pr commentкак запрещённых → обновить (rawghвообще запрещён, не только specific commands)bug-discovery/SKILL.mdL10:gh issue list→curl -s -H "Authorization: token $FORGEJO_TOKEN" "$FORGEJO_URL/api/v1/repos/{owner}/{repo}/issues?state=open&type=issues"илиpipeline-statusоракулКонтракты
pipeline-status({pr_number: N})оракул — после PR #1 возвращает: CI status, PR body, title, headRefName, author, issue context. Используется вместоgh pr view/gh run list/gh issue view.curlк Forgejo REST API:${FORGEJO_URL}/api/v1/..., authAuthorization: token ${FORGEJO_TOKEN}POST /repos/{repo}/labels— body{name, color}(color без#, hex)POST /repos/{repo}/releases— body{tag_name, name, body, draft, prerelease}PATCH /repos/{repo}— body{description, topics, allow_squash_merge, allow_merge_commit, allow_rebase, default_delete_branch_after_merge}POST /user/repos— body{name, private, auto_init, default_branch}POST /repos/{repo}/branch_protections— body{branch_name, enable_push, enable_status_check, required_approvals}git fetch origin pull/N/head:pr-N && git checkout pr-N— git-native checkout PR (неgh pr checkout)Инварианты
curlк Forgejo API в bash-блокеghCLI НЕ используется НИГДЕ в skills/agents (вырезано в PR #1 из кода, здесь из промптов)/run-pipeline,/release,/specработают так жеГраничные случаи
pipeline-statusоракул недоступен (tool не вызван) → skills должны fallback на прямойcurlк Forgejo API (но это редко, оракул всегда доступен)curlв skill безFORGEJO_TOKENenv → понятная ошибка "FORGEJO_TOKEN required"git fetch origin pull/N/head— remoteoriginдолжен указывать на Forgejo (после миграции PR #1 это так)curl POST /branch_protections— если branch protection уже существует (409) → PATCH вместо POST, или skipcurl POST /user/repos— если repo уже существует (409) → skip create, переходить к settingsproject_nameможет содержать дефисы — URL-encoding не нужен (Forgejo принимает)pipeline-statusне возвращаетauthor→ добавитьcurl GET /repos/{repo}/pulls/{N}дляuser.loginВлияние на связанные компоненты
pipeline-statusоракул должен быть расширен (returns body, title, author, CI runs) ДО этого PRopencode.jsonagentсекция — memory-syncer и reviewer tool-флаги НЕ меняются (tools те же)opencode.jsonpermission.bash— 24gh*правила удаляются в PR #3 (этот PR не трогает opencode.json)permission.bashсекции (memory-syncer L19/L31-33, reviewer L33-55/L69) — удаляются в этом PR (это agent files, не opencode.json)commands/*.md— 3 упоминанияgh(audit, project-template, spec) — косметика, обновить в этом PRbug-discovery/SKILL.md— связан с issue skill (оба упоминаютgh issue list/create)project-template/SKILL.mdTemplate GITHUB → FORGEJO — самый объёмный кусок (L224-304, 80 строк)gh pr checks403) — устаревает (GitHub-специфика), пометить superseded в PR #3Вне scope
opencode.jsonglobalpermission.bash— PR #3Dockerfile(убратьgh) — PR #3.env.example(удалитьGITHUB_TOKEN) — PR #3AGENTS.md(секция про git-host) — PR #3pyproject.toml/README.mdURLs — PR #3.github/workflows/— НЕ трогаем (рабочий CI)Критерии приемки
rg "gh " .opencode/skills/ .opencode/agents/ .opencode/commands/→ 0 совпадений в инструкциях (описания-запреты "НЕ raw gh" можно оставить)rg "github.com" .opencode/skills/ .opencode/agents/ .opencode/commands/→ 0 совпадений (кроме исторических примеров в ADR)rg "GitHub" .opencode/skills/ .opencode/agents/ .opencode/commands/→ 0 совпадений в descriptions/instructionsissue/SKILL.mdL155-157 —gh label createзаменён наcurl POST /repos/{repo}/labelsrun-pipeline/SKILL.mdL70/L90/L91/L93/L113/L146 — rawghзаменён наpipeline-statusоракул или git-nativerelease/SKILL.mdL76 —gh release createзаменён наcurl POST /repos/{repo}/releasesrepo-readme/SKILL.mdL29-32 —gh repo editзаменён наcurl PATCH /repos/{repo}project-template/SKILL.mdL224-304 — Template GITHUB → Template FORGEJO (curl POST/PATCH, Forgejo branch protection schema)memory-syncer.mdL44/L119 — rawgh pr viewзаменён наpipeline-statusоракул; frontmatter L19/L31-33 удаленыreviewer.mdL98/L106/L397 — rawghзаменён наpipeline-statusоракул; frontmatter L33-55/L69 удаленыbug-discovery/SKILL.mdL10 —gh issue listзаменён наcurlилиpipeline-status/run-pipelineна тестовом PR работает без rawgh(pipeline-status оракул используется)