---
name: feedback-github-gist-channel-setup-2026-06-30
description: GitHub Gist を 11 番目 publish channel として確立 (2026-06-30)、 Scrapbox CSRF 5 連続失敗の代替。 GITHUB_GIST_TOKEN = 別 fine-grained PAT (既 GITHUB_TOKEN と分離)、 Account permissions → Gists Read and write。 publish-paper-to-gist.ts (175 行) で public gist 作成 + 既 publish-log 自動 merge。 今後 paper publish の standard channel に組込推奨。
metadata: 
  node_type: memory
  type: feedback
  originSessionId: af1ab23c-b41d-4c41-9589-65cdb46779f8
---

# GitHub Gist Channel Setup — 2026-06-30 protocol

## Rule

GitHub Gist publish channel の運用は以下:

1. **Token は別管理**: `GITHUB_GIST_TOKEN` (`.env`) として `GITHUB_TOKEN` (repo 操作用) と **分離** — gist scope の漏洩 risk を repo scope と independent に管理可能
2. **Fine-grained PAT 推奨**: GitHub settings → Personal access tokens → fine-grained tokens で作成、 **Account permissions → Gists: Read and write** が必須
3. **Repository access**: Public Repositories (read-only) で OK (gist は repository scope と独立)
4. **Token format**: `github_pat_xxx...` (93 chars 程度)
5. **Script: `scripts/publish-paper-to-gist.ts`** で publish (175 行, 既存)

**Why:** Scrapbox CSRF schema mismatch で 5 連続失敗 ([[feedback-publishing-rate-limit-platform-side-risk-2026-06-27]] + [[feedback-scrapbox-pat-write-rejected-2026-06-30]]) → 自動化 path 必要 → GitHub Gist は token 既設 + markdown native + 公開検索可能 + 永続 (GitHub 存続中) で最高 ROI 代替。

**How to apply:**
- Paper publish 時に 10 platform stack に追加して **11 platform** で配信
- 例: `npx tsx scripts/publish-paper-to-gist.ts 39` で Paper 39 を public gist 化
- DRY_RUN=1 で preview 可能: `DRY_RUN=1 npx tsx scripts/publish-paper-to-gist.ts 39`
- `META` object に paper-specific description を追加可能、 META 不在時は auto-generate (first H1 + Zenodo DOI)
- 既存 `publish-log-paper{N}.json` の `results.gist` field に URL 自動 merge

## 本 session setup record (2026-06-30)

藤本さん操作:
- https://github.com/settings/tokens?type=beta で fine-grained PAT 作成
- Token name: `Rei-AIOS Gist Publish (Claude Code)`
- 有効期限: 「有効期限なし」 (security 上 1 year 推奨だが本人運用)
- Repository access: Public Repositories
- Account permissions → Gists: Read and write
- Token 文字列を chat で paste (`github_pat_11AM...EkmdcSnaF0tP5F4ULUH5LLNgmeHc`)

Rei 操作:
- `.env` に `SCRAPBOX_PERSONAL_ACCESS_TOKEN` (read 補助) + `GITHUB_GIST_TOKEN` (write) を追加
- Write-test 実行: HTTP 201 + test gist 作成成功 (https://gist.github.com/fc0web/9a181340c2da0b7d1ec2ebef8d95136c — 藤本さん手動 delete 可)
- `scripts/publish-paper-to-gist.ts` 新規作成 (175 行)
- Paper 39 publish: https://gist.github.com/fc0web/4d66421d47ae3efbff10cadd13888e37

## Honest 限界

- Gist は **rei-aios** repo (private) の Wiki と異なり public (gist は account-level、 repo-level でない)
- Description は 256 chars 制限、 long abstract は自動 truncate (`trimDescription` helper)
- GitHub Gist の永続性は GitHub Inc 存続に依存 (Internet Archive のような archival 保証なし、 但し long-term reliable)
- Token を classic PAT で発行する場合は `gist` scope 必要、 但し fine-grained 推奨 (scope 限定 + 1 year expiration option)

## 4 残未投稿 paper への適用 (今後の use)

| Paper | Gist publish 可能? |
|---|---|
| Paper 40 (Rei Vessel Voyage A-G) | ✅ standard publish stack に Gist 追加で 11 platform 達成可 |
| Paper 103 (T-FS Scale-Dependent) | ✅ 同上 |
| Paper 104 (T-WC+ Near-WSS Collatz) | ✅ 同上 |
| Paper 171 (D-FUMT₈ Recapture Region) | ✅ publish gate clear 後同上 |

## Search context

- Keywords: "GitHub Gist publish channel", "GITHUB_GIST_TOKEN", "publish-paper-to-gist.ts"
- Related: [[feedback-scrapbox-pat-write-rejected-2026-06-30]] (Scrapbox PAT write 拒否で Gist 採用契機)
- Related: [[feedback-publishing-rate-limit-platform-side-risk-2026-06-27]] (Scrapbox CSRF 5 連続失敗 pattern + 1 paper/day cap discipline)
- Related: [[project-paper39-publish-2026-06-30]] (Paper 39 で Gist 初使用)
- Related: [[project-session-2026-06-30-full-arc]]

## Script implementation note

```typescript
// scripts/publish-paper-to-gist.ts core flow:
// 1. Load GITHUB_GIST_TOKEN from .env
// 2. Find paper file (papers/paper-{N}-*.md)
// 3. Load Zenodo DOI from publish-log-paper{N}-zenodo.json (if exists)
// 4. Build description (META override or auto-generate from H1 + DOI)
// 5. Truncate description to 256 chars
// 6. POST https://api.github.com/gists with public: true
// 7. Save standalone publish-log-paper{N}-gist.json
// 8. Merge into consolidated publish-log-paper{N}.json results.gist field
```
