diff --git a/.github/workflows/sync-listings-bot.yml b/.github/workflows/sync-listings-bot.yml new file mode 100644 index 0000000..6cc8b0b --- /dev/null +++ b/.github/workflows/sync-listings-bot.yml @@ -0,0 +1,48 @@ +name: Listings Sync Bot + +# main への push 後に同期ブロックを再生成し、差分があれば +# github-actions[bot] が main に直接 commit する。PR 段階のチェック +# (sync-listings-check.yml) を通過していれば通常は no-op で終わる。 +# +# ループ防止: bot 自身の push では走らせない。 + +on: + push: + branches: [main] + +permissions: + contents: write + +concurrency: + group: listings-sync-main + cancel-in-progress: false + +jobs: + sync: + if: github.actor != 'github-actions[bot]' + name: Auto-commit listing sync + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + token: ${{ secrets.GITHUB_TOKEN }} + + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Run sync_listings --write + run: python3 scripts/sync_listings.py --write + + - name: Commit if changed + run: | + if [[ -z "$(git status --porcelain)" ]]; then + echo "No changes — listings already in sync." + exit 0 + fi + git config user.name "github-actions[bot]" + git config user.email "41898282+github-actions[bot]@users.noreply.github.com" + git add sitemap.xml llms.txt index.html README.md + git commit -m "chore(listings): auto-sync $(date +%F)" + git push diff --git a/.github/workflows/sync-listings-check.yml b/.github/workflows/sync-listings-check.yml new file mode 100644 index 0000000..38aa042 --- /dev/null +++ b/.github/workflows/sync-listings-check.yml @@ -0,0 +1,30 @@ +name: Listings Sync Check + +# PR 用の verify-only。NN-slug/index.html の追加・変更があった際に +# sitemap.xml / llms.txt / index.html / README.md の自動生成ブロックが +# 同期されていなければ fail させる。 +# ローカルでの修正コマンド: python3 scripts/sync_listings.py --write +# +# 詳細: scripts/README.md + +on: + pull_request: + +permissions: + contents: read + +jobs: + check: + name: Verify auto-generated listing blocks + runs-on: ubuntu-latest + steps: + - uses: actions/checkout@v4 + with: + fetch-depth: 0 + + - uses: actions/setup-python@v5 + with: + python-version: '3.x' + + - name: Run sync_listings --check + run: python3 scripts/sync_listings.py --check diff --git a/CLAUDE.md b/CLAUDE.md index d8cf586..e08fdc1 100644 --- a/CLAUDE.md +++ b/CLAUDE.md @@ -49,6 +49,12 @@ - AI 周辺は移り変わりが激しい。古くなったら直す、ではなく、**最初から "更新される前提" で設計** - HTML × Git × PR ベースの運用は、その変化への対応手段 +### 5. 講義一覧は自動同期する(手で更新しない) +- 新しい講義 `NN-slug/index.html` を追加するだけで、`sitemap.xml` / `llms.txt` / ルート `index.html` / `README.md` の講義一覧ブロックが自動同期される +- 真実源は各 `NN-slug/index.html` の `` と `<meta name="description">` +- 同期スクリプト: `python3 scripts/sync_listings.py --write`(PR では `--check` が CI 強制) +- 詳細: [`scripts/README.md`](./scripts/README.md) + --- ## 期待する効果(長期) diff --git a/CONTRIBUTING.md b/CONTRIBUTING.md index 469fa35..7a0d7d6 100644 --- a/CONTRIBUTING.md +++ b/CONTRIBUTING.md @@ -100,7 +100,26 @@ commit に `Co-Authored-By: Name <email>` trailer を付けると、GitHub の C ### CI - **Prompt Injection Guard** が HTML/CSS/JS の追加行を自動スキャン -- 失敗時は job summary に検出箇所が表示される +- **Listings Sync Check** が `sitemap.xml` / `llms.txt` / `index.html` / `README.md` の講義一覧ブロックを検証 +- 失敗時は job summary に検出箇所・修正コマンドが表示される + +### 新しい Lecture を追加するとき + +`sitemap.xml` / `llms.txt` / `index.html`(ルート)/ `README.md` の講義一覧は **自動同期** されます。`NN-slug/index.html` の `<title>` と `<meta name="description">` から自動生成されるので、これらのファイルを手で編集する必要はありません。 + +```bash +# 講義ディレクトリを作って書く +cp -r _template NN-slug +# ... NN-slug/index.html を編集 ... + +# 4 つの listing ファイルを同期 +python3 scripts/sync_listings.py --write + +# 確認用 +python3 scripts/sync_listings.py --check +``` + +PR で同期し忘れた場合は CI(`sync-listings-check.yml`)が落とします。詳細は [`scripts/README.md`](./scripts/README.md)。 ### 大きな変更の場合 diff --git a/README.md b/README.md index 98f41fb..73bd418 100644 --- a/README.md +++ b/README.md @@ -27,8 +27,13 @@ AI コーディング(Claude Code 等)を中心に、散在しがちな情 | 章 | 内容 | スライド | |---|---|---| -| [`00-about/`](./00-about/index.html) | この資料の歩き方(Read me) | 10 枚 | -| [`01-claude-code-intro/`](./01-claude-code-intro/index.html) | Claude Code 入門 | 13 枚 | +<!-- Auto-generated by scripts/sync_listings.py. Do not edit by hand. --> +<!-- listings:auto:lectures-table:start --> +| [`00-about/`](./00-about/index.html) | Read me | 10 枚 | +| [`01-claude-code-intro/`](./01-claude-code-intro/index.html) | なぜ今、Claude Code を学ぶのか | 13 枚 | +| [`02-setup/`](./02-setup/index.html) | Claude Code 環境構築 | 13 枚 | +| [`03-claude-md/`](./03-claude-md/index.html) | CLAUDE.md でプロジェクトを記憶させる | 13 枚 | +<!-- listings:auto:lectures-table:end --> 各章は単体の HTML として完結しているので、ブラウザで開けばそのまま読めます。 @@ -39,8 +44,13 @@ AI コーディング(Claude Code 等)を中心に、散在しがちな情 ### 方法 1: 公開サイト(GitHub Pages) ``` +<!-- Auto-generated by scripts/sync_listings.py. Do not edit by hand. --> +<!-- listings:auto:lectures-urls:start --> https://co-lect.github.io/lectures/00-about/ https://co-lect.github.io/lectures/01-claude-code-intro/ +https://co-lect.github.io/lectures/02-setup/ +https://co-lect.github.io/lectures/03-claude-md/ +<!-- listings:auto:lectures-urls:end --> ``` ### 方法 2: クローンしてローカルで開く diff --git a/_template/index.html b/_template/index.html index 3863b1d..3e32081 100644 --- a/_template/index.html +++ b/_template/index.html @@ -2,6 +2,9 @@ <html lang="ja"> <head> <meta charset="UTF-8"> +<!-- 注意: <title> と <meta name="description"> はルートの sitemap.xml / llms.txt / + index.html / README.md の講義一覧に自動転記されます(scripts/sync_listings.py)。 + listing にそのまま載る前提で、短く・的確に書いてください。 --> <title>{{ 講義タイトル }} — Lectures diff --git a/index.html b/index.html index e690a72..a6b70ca 100644 --- a/index.html +++ b/index.html @@ -102,14 +102,25 @@

Lectures

講義

鮮度について

diff --git a/llms.txt b/llms.txt index 6120444..a751f5f 100644 --- a/llms.txt +++ b/llms.txt @@ -6,8 +6,13 @@ ## 講義 -- [00 Read me](https://co-lect.github.io/lectures/00-about/): 教材シリーズの設計思想と歩き方。1 年で陳腐化する世界で資料をどう作るか(10 枚) -- [01 なぜ今、Claude Code を学ぶのか](https://co-lect.github.io/lectures/01-claude-code-intro/): AI コーディングの全体像、ツールの正体、人の立ち位置の変化(13 枚) + + +- [00 Read me](https://co-lect.github.io/lectures/00-about/): Lectures シリーズの歩き方 — 1 年で陳腐化する世界で、AI と共同編集する資料はどう作るべきか。教材全体の設計思想を 10 枚で示す Read me。 +- [01 なぜ今、Claude Code を学ぶのか](https://co-lect.github.io/lectures/01-claude-code-intro/): なぜ今 Claude Code を学ぶのか — AI コーディングの全体像、ツールの正体、人の立ち位置の変化を 13 枚で概観する HTML スライド教材。 +- [02 Claude Code 環境構築](https://co-lect.github.io/lectures/02-setup/): Claude Code を動かすまでの手順を 13 枚で解説。プランの選択からインストール・認証・初起動まで。 +- [03 CLAUDE.md でプロジェクトを記憶させる](https://co-lect.github.io/lectures/03-claude-md/): 毎回の説明をゼロにする CLAUDE.md の使い方。書き方・置き場所・効果的な3パターンを13枚で解説。 + ## メタ diff --git a/scripts/README.md b/scripts/README.md new file mode 100644 index 0000000..cb372e1 --- /dev/null +++ b/scripts/README.md @@ -0,0 +1,63 @@ +# scripts/ + +リポジトリ運用のためのユーティリティスクリプト。 + +--- + +## `sync_listings.py` — 講義一覧の自動同期 + +`NN-slug/index.html` を真実源(source of truth)として、以下の自動生成ブロックを同期する: + +| ファイル | 同期される場所 | +|---|---| +| `sitemap.xml` | ` ... :end -->` — 講義 URL の `` ブロック | +| `llms.txt` | 同上 — 「## 講義」の箇条書き | +| `index.html`(ルート) | 同上 — `