[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6C3BG6FB276S27CSH2THTVZ":3,"skill-same:01M6C3BG6FB276S27CSH2THTVZ":112},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":8,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":13,"sourceHtmlUrl":17,"categories":18,"keywords":29,"publishedAt":57,"linkOnly":58,"markdownContent":59,"markdownBody":60,"frontMatter":61,"refName":67,"commitSha":68,"skillDirectory":69,"forksCount":70,"repositoryHtmlUrl":71,"repositoryHomepageUrl":13,"ownerHtmlUrl":72,"ownerBlogUrl":13,"ownerDescription":13,"updatedAt":73,"install":74,"resources":87},"01M6C3BG6FB276S27CSH2THTVZ","download-campaign","Firestore 活动数据下载归档","Download a Your Project campaign from Firestore, write raw archive + wiki source page. Use when the user says download a campaign, pull this campaign, fetch campaign from firestore, ingest campaign N, copy a campaign by id, or wants to walk a specific WA campaign for analysis. Single-campaign or filtered-batch modes. Wraps and supersedes ad-hoc subprocess-based approaches that hit gRPC FD inheritance bugs.","从 Firestore 下载 Your Project 的营销活动数据，写入原始归档和 wiki 源页面。当用户说下载某个活动、拉取该活动、从 firestore 获取活动、摄取活动 N、按 id 复制活动，或想要遍历某个具体的 WA 活动进行分析时使用。支持单活动或过滤批量模式。封装并取代了基于临时子进程、会触发 gRPC FD 继承错误的方法。","jleechanorg\u002Fjleechan-skills","jleechanorg","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F221404966?v=4","01M6C1VJ99XG950X1DWPEBCBGX",null,"01M6C1VJDK5YVDNT3362RT5WSB",6,"MIT","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002Fhermes\u002Fskills\u002Fdownload-campaign\u002FSKILL.md",[19,24],{"categoryNo":20,"categoryName":21,"taxonomyType":22,"taxonomyTypeDesc":23},"01M8BQGD5CX980XNXCJKQF70BY","数据分析师","PROFESSION","适用职业",{"categoryNo":25,"categoryName":26,"taxonomyType":27,"taxonomyTypeDesc":28},"01M8CAGKS1YAP5AE015P1W1TG8","文件下载管理","SCENARIO","使用场景",[30,31,32,33,34,35,36,37,38,39,40,41,42,43,44,45,46,47,48,49,50,51,52,53,54,55,56],"download campaign","campaign","download","write","when","inline","fd","inheritance","get","project","filters","only","use","fetch","user","writing","read","page","archive","wiki","wizard","analysis","file","grpc","batch","pull","terminal","2026-11-10 10:12:30",false,"---\nname: download-campaign\ndescription: \"Download a Your Project campaign from Firestore, write raw archive + wiki source page. Use when the user says download a campaign, pull this campaign, fetch campaign from firestore, ingest campaign N, copy a campaign by id, or wants to walk a specific WA campaign for analysis. Single-campaign or filtered-batch modes. Wraps and supersedes ad-hoc subprocess-based approaches that hit gRPC FD inheritance bugs.\"\nwhen_to_use: \"Use when the user says: download campaign, fetch this campaign, pull from firestore, ingest campaign, get campaign by id, copy campaign X, batch download recent campaigns, scan last N days, scan for >50 entries, last 2 weeks of campaigns, the campaign wizard walked. Do NOT use for: full wiki page writing (use wiki-ingest), Firestore read only with no download (use firestore_service.get_campaign_by_id directly).\"\narguments:\n  - campaign_id\n  - filters\nargument-hint: \"[campaign_id or 'recent' or 'batch'] [--min-entries N] [--days N] [--skip-existing] [--campaigns-dir \u003Cpath>]\"\ncontext: inline\nallowed-tools: terminal, file\n---\n\n# download-campaign — Your Project Firestore → raw archive + wiki source\n\nCanonical home for the \"get a campaign out of Firestore and put it on disk\" workflow.\nThis skill exists because ad-hoc one-liners repeatedly hit three pitfalls:\n\n1. **Subprocess-from-Firebase parents gRPC FD inheritance** — `download_campaign.py`\n   spawned from a Firebase-initialized process fails with\n   `ev_poll_posix.cc:593 FD from fork parent still in poll list: fd(13, generation: 1)`\n   on every single download. Fix: call `firestore_service.get_campaign_by_id()` and\n   `document_generator.get_story_text_from_context_enhanced()` directly in the same\n   process. Never use `download_campaign.py` as a subprocess.\n\n2. **`story` vs `story_entries` subcollection** — The WA campaign story subcollection\n   is `story`. Querying `story_entries` returns 0 entries for every campaign.\n\n3. **`.venv` ships without pip and deps** — Run `ensurepip` then install the full\n   dep chain (firebase-admin, google-cloud-firestore, flask, pydantic, jsonschema,\n   python-docx, fpdf2). Missing any one causes `firestore_service` or\n   `document_generator` import failure cascades.\n\n## Quick usage\n\n```bash\ncd $HOME\u002Fyour-project.com\n\n# IMPORTANT: prefix with `env -u MOCK_SERVICES_MODE` to defeat parent-shell\n# env trap (see Pitfall #13). Required when the parent shell has\n# MOCK_SERVICES_MODE=true exported (common in hermetic-test sessions).\nWORLDAI_DEV_MODE=true \\\nGOOGLE_APPLICATION_CREDENTIALS=~\u002FserviceAccountKey.json \\\nenv -u MOCK_SERVICES_MODE \\\n  .venv\u002Fbin\u002Fpython ~\u002F.hermes_prod\u002Fskills\u002Fdownload-campaign\u002Fscripts\u002Fdownload_campaign.py \\\n    --mode one --campaign-id vNU3AAXHd9N7adqWSM2p\n\n# Or batch mode with filters (one user — $USER by default)\n.venv\u002Fbin\u002Fpython ~\u002F.hermes_prod\u002Fskills\u002Fdownload-campaign\u002Fscripts\u002Fdownload_campaign.py \\\n    --mode batch --min-entries 50 --days 14 --skip-existing\n\n# Or all-users mode (every real user, skip test fixtures; $USER included)\n.venv\u002Fbin\u002Fpython ~\u002F.hermes_prod\u002Fskills\u002Fdownload-campaign\u002Fscripts\u002Fdownload_campaign.py \\\n    --mode all-users --min-entries 50 --skip-existing\n```\n\nThe script prints progress, writes:\n- `~\u002Fllm_wiki\u002Fraw\u002Fcampaigns\u002F\u003Ctitle>_\u003Cid8>\u002F\u003Ctitle>_\u003Cid8>.txt` (story text)\n- `~\u002Fllm_wiki\u002Fraw\u002Fcampaigns\u002F\u003Ctitle>_\u003Cid8>\u002F\u003Ctitle>_\u003Cid8>_game_state.json`\n- `~\u002Fllm_wiki\u002Fwiki\u002Fsources\u002F\u003Cslug>-\u003Cid8>.md` (frontmatter + body)\n\n## Modes\n\n`download_campaign.py` supports three modes:\n\n- `--mode one --campaign-id \u003Cid>` — pull a specific campaign (one user, $USER by default).\n- `--mode batch [--min-entries N] [--days N] [--skip-existing]` — one user ($USER by default; override with `WA_EMAIL` env).\n- `--mode all-users [--min-entries N] [--exclude-$USER] [--skip-existing]` — every real user across `auth.list_users()`, filtered by `is_test_email()`. Use this for the daily cron (`wiki-campaign-daily-ingest.sh`).\n\n### `--all-users` mode (multi-user batch)\n\nWalks `auth.list_users()` paginated, filters out test fixtures via\n`is_test_email()` (matches `test`, `anon`, `dev-runner`, `example.com`,\n`jleechantest` — same tokens as `wa-prod-data-query\u002Fscripts\u002Fquery_real_users.py`),\nthen iterates `query_candidates()` + `download_one()` per real user. $USER\nis **included by default**; pass `--exclude-$USER` to skip him.\n\nEach ingested campaign's wiki frontmatter carries `user_email:` + `user_uid:`\nso multi-user pages are auditable in the `jleechanorg\u002Fllm-wiki` private repo.\n\nUse case: the daily `ai.$USER.wiki-campaign-daily-ingest` launchd job uses\n`--mode all-users --min-entries 50 --skip-existing` to keep the private\nllm-wiki repo in sync with every real WA user's over-50-scene campaigns.\n\n## Phases\n\n### Phase 1 — Venv bootstrap (one-time per machine)\n\nThe WA `.venv` ships without pip. Run from `~\u002Fyour-project.com`:\n\n```bash\n.venv\u002Fbin\u002Fpython -m ensurepip\n.venv\u002Fbin\u002Fpython -m pip install \\\n  firebase-admin google-cloud-firestore \\\n  flask pydantic jsonschema python-docx fpdf2\n```\n\nAll five are required — `flask` and `jsonschema` are transitive imports of\n`firestore_service` and `document_generator`. Missing `pydantic` breaks\n`firestore_service.get_campaign_by_id()`. Missing `python-docx` breaks\n`document_generator.get_story_text_from_context_enhanced()`. Missing `fpdf2`\nbreaks `document_generator` import. **Install all of them, every time.**\n\n### Phase 2 — sys.path ordering (every run)\n\nThe `clock_skew_credentials` module lives in `$PROJECT_ROOT\u002F`, not the project root.\nPath order matters — insert `mvp_site` BEFORE the root:\n\n```python\nsys.path.insert(0, \"$HOME\u002Fyour-project.com\u002Fmvp_site\")\nsys.path.insert(0, \"$HOME\u002Fyour-project.com\")\n```\n\n`WORLDAI_DEV_MODE=true` is **required** for any local Firestore query. The\nclock-skew validator raises `ValueError` if `WORLDAI_GOOGLE_APPLICATION_CREDENTIALS`\nis set without `WORLDAI_DEV_MODE=true` to explicitly acknowledge dev mode.\n\n### Phase 3 — Auth + clock skew\n\n```python\nimport os\nos.environ[\"GOOGLE_APPLICATION_CREDENTIALS\"] = os.path.expanduser(\"~\u002FserviceAccountKey.json\")\nos.environ[\"WORLDAI_DEV_MODE\"] = \"true\"\n\nfrom clock_skew_credentials import apply_clock_skew_patch\napply_clock_skew_patch()  # adjusts time by -720 seconds\n\nimport firebase_admin\nfrom firebase_admin import auth, credentials, firestore\nif not firebase_admin._apps:\n    cred = credentials.Certificate(os.path.expanduser(\"~\u002FserviceAccountKey.json\"))\n    firebase_admin.initialize_app(cred)\n\nuser = auth.get_user_by_email(\"$USER@gmail.com\")\nuid = user.uid  # do not use Firestore user docs for email lookup\n```\n\n### Phase 4 — Pull campaign data\n\n```python\nimport firestore_service\nimport document_generator\nfrom google.cloud import firestore\n\ncampaign_id = \"vNU3AAXHd9N7adqWSM2p\"\ncampaign_data, story_context = firestore_service.get_campaign_by_id(uid, campaign_id)\n\n# campaign_data is a Firestore DocumentSnapshot\ncd = campaign_data.to_dict() if hasattr(campaign_data, \"to_dict\") else campaign_data\ntitle = cd.get(\"name\", cd.get(\"title\", \"Untitled\"))\n\n# story_context is a list of story entry dicts\nstory_text = document_generator.get_story_text_from_context_enhanced(\n    story_context, include_scenes=True\n)\n\n# Game state (separate call)\ngs = firestore_service.get_campaign_game_state(uid, campaign_id)\ngs_data = gs.to_dict() if gs is not None else {}\n```\n\n**Cross-check the helper — see Pitfall #8 below.** Some campaigns (e.g.\n`WlfgzI0ReBrFkmagW3wU` \"Nocturne bg3 v5 succubus copy\") return a\nzero-length story_context from `firestore_service.get_campaign_by_id`\neven though the `story` subcollection has hundreds of entries. The\nhelper has at least one bug path that drops entries silently. Before\ntrusting any \"0 entries\" result, cross-check with a direct\naggregation count and fall back to a direct stream if the helper\ncount disagrees with the direct count. The driver uses this pattern:\n\n```python\ndb = firestore.client()\ndirect_count = int(db.collection(\"users\").document(uid)\n                  .collection(\"campaigns\").document(campaign_id)\n                  .collection(\"story\").count().get()[0][0].value)\nif direct_count > len(story_context):\n    # helper returned truncated\u002Fmissing — pull directly\n    docs = list(db.collection(\"users\").document(uid)\n                .collection(\"campaigns\").document(campaign_id)\n                .collection(\"story\").stream())\n    story_context = [d.to_dict() for d in docs]\n    story_text = document_generator.get_story_text_from_context_enhanced(\n        story_context, include_scenes=True\n    )\n```\n\n### Phase 5 — Idempotent writes\n\nTwo campaigns with the same title (e.g. \"Vespera Thul (copy)\") must NOT\noverwrite each other. Use `campaign_id[:8]` suffix in BOTH the raw archive\npath and the wiki source path:\n\n```python\nslug = slugify(title)\nwiki_path = Path(f\"~\u002Fllm_wiki\u002Fwiki\u002Fsources\u002F{slug}-{campaign_id[:8]}.md\").expanduser()\nraw_dir = Path(f\"~\u002Fllm_wiki\u002Fraw\u002Fcampaigns\u002F{campaign_id}\").expanduser()\n```\n\nIdempotency check: skip if `wiki_path.exists()` AND its size > 500 bytes\n(skips blank\u002Fpartial frontmatter-only stubs).\n\n### Phase 5b — Verify the export (mandatory for batch runs)\n\nAfter a batch run, re-pull each exported campaign from Firestore and\nbyte-diff the live `get_story_text_from_context_enhanced` output against\nthe on-disk raw `.txt`. Campaigns are live — users keep typing in another\ntab while a batch runs, so any candidate that took >1s to export can\nhave a newer entry by the time the verify pass runs.\n\nPass criteria:\n- `live_count == on-disk entry_count` from frontmatter (no story loss)\n- `len(live_text)` within 1% of `len(on_disk_text)` (allow tiny drift from\n  new entries; >5% means the export raced with writes and should be\n  re-pulled)\n\nOutput a `\u002Ftmp\u002Fverify_\u003Cbatch_tag>_report.jsonl` with one row per\ncandidate, then run a repair pass for any row with `drift_pct > 1.0`\n(only those — re-pulling everyone wastes ~3 minutes on a 228-campaign batch).\n\nFor the 2026-07-12 batch-50plus run, 28\u002F228 candidates drifted between\nbatch and verify due to user activity; repair pass re-pulled only those\nin ~30s. Total verify+repair wall time: under 4 minutes for 228 candidates.\n\n### Phase 6 — Output contract\n\nEach campaign gets:\n\n1. **Raw archive** at `~\u002Fllm_wiki\u002Fraw\u002Fcampaigns\u002F\u003Cid8>\u002F\u003Csafe_title>_\u003Cid8>.txt`\n   — full story text, scenes included.\n2. **Game state** at `~\u002Fllm_wiki\u002Fraw\u002Fcampaigns\u002F\u003Cid8>\u002F\u003Csafe_title>_\u003Cid8>_game_state.json`\n   — full Firestore game_state doc, JSON serialised with `default=str` for datetimes.\n3. **Wiki source page** at `~\u002Fllm_wiki\u002Fwiki\u002Fsources\u002F\u003Cslug>-\u003Cid8>.md` — frontmatter:\n\n   ```yaml\n   ---\n   title: \"\u003Ctitle>\"\n   type: source\n   tags: [campaign, worldarchitect, \u003Cslug>]\n   date: YYYY-MM-DD\n   source_file: \u003Craw path>\n   campaign_id: \u003Cid>\n   entry_count: \u003CN>\n   last_updated: \u003Cts>\n   ingest_batch: \u003Cbatch tag>\n   ---\n   ```\n\n   Body: the story text, truncated to 100,000 chars per page.\n\n4. **Manifest entry** appended to `\u002Ftmp\u002Fcampaign_ingest_manifest.jsonl`.\n\n## Batch mode filters\n\n```bash\n--min-entries 50      # only campaigns with ≥N story entries\n--days 14             # only campaigns active in last N days (by max story timestamp)\n--skip-existing       # skip if wiki page already exists with content\n--campaigns-dir \u003Cpath> # output raw archive dir (default \u002Ftmp\u002Fcampaign_downloads)\n```\n\n## Discovery scan — entry-count recipe (replaces `.limit(2000).stream()`)\n\nFor scanning $USER's full campaign list (1,000+ campaigns in practice),\ndo NOT use `.limit(2000).stream()` for entry counts — it caps at 2000 and\ngives wrong answers for any campaign with more. Use Firestore aggregation\nqueries (preferred) or a single `.stream()` with no limit when count > 2000:\n\n```python\ndb = firestore.client()\n# Preferred: aggregation count (1 read, no document materialization)\nagg = (db.collection(\"users\").document(uid).collection(\"campaigns\")\n       .document(cid).collection(\"story\").count().get())\nentry_count = int(agg[0][0].value)\n\n# Fallback for when aggregation isn't enough (need actual entries to sort by\n# timestamp \u002F author etc.):\ndocs = list(db.collection(\"users\").document(uid).collection(\"campaigns\")\n            .document(cid).collection(\"story\").stream())\nentry_count = len(docs)\nlast_scene_ts = max(\n    (d.to_dict().get(\"timestamp\") or d.to_dict().get(\"created_at\") for d in docs),\n    default=None,\n)\n```\n\nFor the 1,080 $USER campaign discovery scan (2026-07-12 batch) the\naggregation path returned correct counts in ~3 minutes total wall time.\nScanning all story subcollections in one process is safe — gRPC FD bug\nonly fires when `download_campaign.py` is spawned as a subprocess.\n\n## Pitfalls (this list IS the skill — review before running)\n\n1. **Never subprocess `download_campaign.py`** — gRPC FD inheritance\n   (`ev_poll_posix.cc:593 FD from fork parent still in poll list`) makes\n   every download fail. Always inline.\n2. **Subcollection is `story`, not `story_entries`** — `story_entries`\n   returns 0 entries. The 2026-05-31 discovery cost a full day of confusion.\n3. **`WORLDAI_DEV_MODE=true` is mandatory** — the clock-skew validator\n   raises `ValueError: WORLDAI_GOOGLE_APPLICATION_CREDENTIALS requires\n   WORLDAI_DEV_MODE=true. Set WORLDAI_DEV_MODE=true to explicitly acknowledge\n   development mode.` without it.\n4. **`\u002Fprivate\u002Ftmp\u002Ftypes.py` collision** — if running from `\u002Ftmp\u002F`, a stale\n   `types.py` can shadow the stdlib module, causing\n   `ImportError: cannot import name 'GenericAlias'`. Fix: `rm \u002Fprivate\u002Ftmp\u002Ftypes.py`.\n5. **2000-entry Firestore limit** — counting entries with `.limit(2000).stream()`\n   shows exactly 2000 for any campaign with 2000+ entries. Use aggregation\n   queries or no limit for precise counts. For ≥50 detection, limit(2000) is\n   fine since the threshold is well below the cap.\n6. **Slug collision on duplicates** — campaigns with the same name (e.g.\n   \"Vespera Thul (copy)\") must use `campaign_id[:8]` in BOTH raw dir name\n   AND wiki page filename, or the second copy overwrites the first.\n7. **`.venv` dep chain** — must install `flask pydantic jsonschema python-docx fpdf2`\n   in addition to `firebase-admin google-cloud-firestore`. The five-app stack\n   import chain pulls in all of them transitively.\n8. **`firestore_service.get_campaign_by_id` can return an empty story list** —\n   some campaigns silently drop to `len(story_context)==0` even though their\n   `story` subcollection has hundreds of entries. Discovered 2026-07-12 on\n   `WlfgzI0ReBrFkmagW3wU` (\"Nocturne bg3 v5 succubus copy\", 554 entries on\n   disk, helper returns 0). Cause: an internal helper bug in\n   `firestore_service.get_campaign_by_id` — root-cause not yet isolated, but\n   the failure mode is consistent (helper returns 0, direct collection stream\n   returns full count). Fix: always cross-check with\n   `db.collection(...).collection(\"campaigns\").document(cid).collection(\"story\").count().get()`\n   and fall back to a direct `.stream()` if the direct count > helper count.\n   Treat any \"0 entries\" result from the helper as a bug, not as data.\n9. **macOS BSD `find -newermt @\u003Cepoch>` is silently broken — use a human-readable\n   date string instead.** GNU `find` accepts `-newermt @1784583090` (epoch\n   seconds). macOS BSD `find` does NOT — it silently returns 0 matches and\n   your batch script will look like \"no work was done\" when in fact it wrote\n   a dozen new files. This bites any launchd-managed batch script that uses\n   `find -newermt` for change detection. Verified 2026-07-20 on\n   `wiki-campaign-daily-ingest.sh`: after the `--mode all-users` ingest wrote\n   12 new wiki pages, the shell's `find -newermt \"@$RUN_START_TIME\"` returned\n   0, the script's \"Files added\u002Fmodified: added=0\" branch fired, and the\n   git push was skipped — leaving the 12 new files uncommitted in the\n   working tree. Fix: store BOTH the epoch AND a formatted date string\n   (`RUN_START_DATE=$(date -r \"$RUN_START_TIME\" '+%Y-%m-%d %H:%M:%S')`) and\n   use `-newermt \"$RUN_START_DATE\"` — works on both BSD and GNU find. The\n   `4 minutes ago` relative form also works but is unreliable when the run\n   wall-clock differs from the script's mtime capture.\n\n10. **`slack_post_message | tee` swallows the function's return code.** When\n    wrapping `slack_post_message` (or any helper that can fail) inside an\n    `if` guard with `| tee`, the pipeline's exit code is tee's, not the\n    helper's — Slack posts silently fail and the script logs \"sent\". Always\n    capture `$?` via `$()` command substitution:\n    ```bash\n    local out rc\n    out=$(slack_post_message \"$CHAN\" \"$TEXT\" 2>&1)\n    rc=$?\n    echo \"$out\" | tee -a \"$LOG\" >\u002Fdev\u002Fnull\n    if [[ $rc -eq 0 ]]; then log \"sent\"; else log \"WARN: rc=$rc\"; fi\n    ```\n    Caught 2026-07-20: bot was posting to #ai-general which it wasn't a\n    member of, but the script reported \"Slack notification sent\" anyway.\n\n11. **`[[ -z \"$X\" ]] && X=0` returns non-zero when X is non-empty** — the `&&`\n    short-circuits to the false branch, and the whole expression exits 1.\n    Combined with an ERR trap (or `set -e`), this fires spurious failure\n    notifications on every successful run. Use explicit assignment:\n    ```bash\n    # WRONG: ERR trap fires on every populated X\n    eval \"[[ -z \\\"\\${$v}\\\" ]] && $v=0\"\n    # RIGHT: plain assignment, always exits 0\n    eval \"val=\\${$v}\"\n    val=$(printf '%s' \"$val\" | tr -cd '0-9')\n    if [[ -z \"$val\" ]]; then val=0; fi\n    eval \"$v=$val\"\n    ```\n    Caught 2026-07-20: the wiki-campaign-daily-ingest.sh ingest-counter\n    loop was firing `notify_error()` on every run because the variable\n    assignment used the wrong pattern.\n\n12. **mcp_agent_mail bot is NOT a member of every channel.** The bot\n    (`U0A4G7LDJ4R`, app `A0A3WSV6BM1`) is in `#life` (`C0AMM2B4319`) and\n    `#all-$USER-ai` (`C09GRLXF9GR`) but NOT in `#ai-general`\n    (`C0AJQ5M0A0Y`). Verify with `conversations.info` before picking a\n    notification channel, or you'll get silent failures. To re-invite the\n    bot to a new channel, see `slack-mcp-mail-bot-reinstall` skill §6\n    (Aside-driven `slack.getClient()` recipe). For the daily wiki-campaign\n    cron, #life is the safe default.\n\n13. **`MOCK_SERVICES_MODE=true` parent shell env silently redirects Firestore to an in-memory mock.** Several launchd and\n    shell sessions export `MOCK_SERVICES_MODE=true` (it's set in `~\u002F.bashrc` \u002F `~\u002F.bash_profile` for hermetic-test tooling).\n    When `download_campaign.py` runs under such a parent, `firestore_service.get_firestore_client()` detects the env var\n    and returns a singleton in-memory client (`firestore_service.py` L3567-3575). Every Firestore read then returns\n    \"data not found\" or empty collections — the script logs `MOCK_SERVICES_MODE enabled - creating singleton in-memory\n    Firestore client` and exits with `RuntimeError: no data for \u003Ccampaign_id>` even though the real campaign has\n    hundreds of entries. **Detection**: scan the script's stdout for that exact log line; if present, the env var is\n    active and you must drop it. **Fix**: run with `env -u MOCK_SERVICES_MODE` prefix on the command line\n    (`env -u MOCK_SERVICES_MODE .venv\u002Fbin\u002Fpython ...`). Always add this prefix in any download \u002F ingest script\n    unless you specifically want the mock client. Verified 2026-07-26 on `qoQtHsU7DxZnR24VNU9w` (Visenya v9):\n    first run hit `RuntimeError: no data for qoQtHsU7DxZnR24VNU9w`; with `env -u` it pulled 824 entries in ~3s.\n\n## Game state key fields (for analysis)\n\n- `player_character_data` — PC stats, features, equipment, relationships.\n  Note: no personality fields (motivation, fear, speech patterns).\n- `npc_data` — dict keyed by NPC name; entries have `level`, `role`,\n  `relationships`, sometimes `mbti` \u002F `alignment` (labels only, no deep profile).\n- `custom_campaign_state` — `core_memories` (list of narrative milestone\n  strings), `active_missions`, `active_constraints`, `faction_minigame`,\n  `god_mode_directives`.\n- `npc_agendas` — often empty dict even in long campaigns.\n- `combat_state` — current encounter data.\n\n## Related\n\n- `wiki-ingest` — broader skill covering ported-source, Firestore batch, and\n  external-source ingest paths.\n- `~\u002Fllm_wiki\u002Ftools\u002Fbatch_campaign_ingest_inline.py` — older version of the\n  batch tool (slug-only paths, no id8 suffix). Superseded by the script\n  under `scripts\u002Fdownload_campaign.py` in this skill.\n- `~\u002Fllm_wiki\u002Fwiki\u002Fsources\u002Fwa-firestore-campaign-schema.md` — schema reference.\n- `references\u002Fbatch-50plus-2026-07-12.md` — session notes from the\n  228-campaign batch run: scan numbers, verification numbers, driver\n  scripts, Git workflow, daily-cron opportunity.\n- `references\u002Fmulti-user-batch-rollout-2026-07-20.md` — session notes from\n  extending the daily cron to all real users (auth.list_users + is_test_email\n  filter). Includes the `find -newermt @\u003Cepoch>` bug caught during\n  verification.\n\n## Tests\n\n- `tests\u002Ftest_slugify.py` — slug generation, including id8 suffix.\n- `tests\u002Ftest_idempotent_path.py` — verifies no slug collision for\n  duplicate titles (\"Vespera Thul (copy)\" 11× → 11 unique paths).\n- `tests\u002Ftest_dependencies.py` — verifies the .venv dep chain is present.\n\nRun: `cd ~\u002F.hermes_prod\u002Fskills\u002Fdownload-campaign && python3 -m unittest discover -s tests`\n","# download-campaign — Your Project Firestore → raw archive + wiki source\n\nCanonical home for the \"get a campaign out of Firestore and put it on disk\" workflow.\nThis skill exists because ad-hoc one-liners repeatedly hit three pitfalls:\n\n1. **Subprocess-from-Firebase parents gRPC FD inheritance** — `download_campaign.py`\n   spawned from a Firebase-initialized process fails with\n   `ev_poll_posix.cc:593 FD from fork parent still in poll list: fd(13, generation: 1)`\n   on every single download. Fix: call `firestore_service.get_campaign_by_id()` and\n   `document_generator.get_story_text_from_context_enhanced()` directly in the same\n   process. Never use `download_campaign.py` as a subprocess.\n\n2. **`story` vs `story_entries` subcollection** — The WA campaign story subcollection\n   is `story`. Querying `story_entries` returns 0 entries for every campaign.\n\n3. **`.venv` ships without pip and deps** — Run `ensurepip` then install the full\n   dep chain (firebase-admin, google-cloud-firestore, flask, pydantic, jsonschema,\n   python-docx, fpdf2). Missing any one causes `firestore_service` or\n   `document_generator` import failure cascades.\n\n## Quick usage\n\n```bash\ncd $HOME\u002Fyour-project.com\n\n# IMPORTANT: prefix with `env -u MOCK_SERVICES_MODE` to defeat parent-shell\n# env trap (see Pitfall #13). Required when the parent shell has\n# MOCK_SERVICES_MODE=true exported (common in hermetic-test sessions).\nWORLDAI_DEV_MODE=true \\\nGOOGLE_APPLICATION_CREDENTIALS=~\u002FserviceAccountKey.json \\\nenv -u MOCK_SERVICES_MODE \\\n  .venv\u002Fbin\u002Fpython ~\u002F.hermes_prod\u002Fskills\u002Fdownload-campaign\u002Fscripts\u002Fdownload_campaign.py \\\n    --mode one --campaign-id vNU3AAXHd9N7adqWSM2p\n\n# Or batch mode with filters (one user — $USER by default)\n.venv\u002Fbin\u002Fpython ~\u002F.hermes_prod\u002Fskills\u002Fdownload-campaign\u002Fscripts\u002Fdownload_campaign.py \\\n    --mode batch --min-entries 50 --days 14 --skip-existing\n\n# Or all-users mode (every real user, skip test fixtures; $USER included)\n.venv\u002Fbin\u002Fpython ~\u002F.hermes_prod\u002Fskills\u002Fdownload-campaign\u002Fscripts\u002Fdownload_campaign.py \\\n    --mode all-users --min-entries 50 --skip-existing\n```\n\nThe script prints progress, writes:\n- `~\u002Fllm_wiki\u002Fraw\u002Fcampaigns\u002F\u003Ctitle>_\u003Cid8>\u002F\u003Ctitle>_\u003Cid8>.txt` (story text)\n- `~\u002Fllm_wiki\u002Fraw\u002Fcampaigns\u002F\u003Ctitle>_\u003Cid8>\u002F\u003Ctitle>_\u003Cid8>_game_state.json`\n- `~\u002Fllm_wiki\u002Fwiki\u002Fsources\u002F\u003Cslug>-\u003Cid8>.md` (frontmatter + body)\n\n## Modes\n\n`download_campaign.py` supports three modes:\n\n- `--mode one --campaign-id \u003Cid>` — pull a specific campaign (one user, $USER by default).\n- `--mode batch [--min-entries N] [--days N] [--skip-existing]` — one user ($USER by default; override with `WA_EMAIL` env).\n- `--mode all-users [--min-entries N] [--exclude-$USER] [--skip-existing]` — every real user across `auth.list_users()`, filtered by `is_test_email()`. Use this for the daily cron (`wiki-campaign-daily-ingest.sh`).\n\n### `--all-users` mode (multi-user batch)\n\nWalks `auth.list_users()` paginated, filters out test fixtures via\n`is_test_email()` (matches `test`, `anon`, `dev-runner`, `example.com`,\n`jleechantest` — same tokens as `wa-prod-data-query\u002Fscripts\u002Fquery_real_users.py`),\nthen iterates `query_candidates()` + `download_one()` per real user. $USER\nis **included by default**; pass `--exclude-$USER` to skip him.\n\nEach ingested campaign's wiki frontmatter carries `user_email:` + `user_uid:`\nso multi-user pages are auditable in the `jleechanorg\u002Fllm-wiki` private repo.\n\nUse case: the daily `ai.$USER.wiki-campaign-daily-ingest` launchd job uses\n`--mode all-users --min-entries 50 --skip-existing` to keep the private\nllm-wiki repo in sync with every real WA user's over-50-scene campaigns.\n\n## Phases\n\n### Phase 1 — Venv bootstrap (one-time per machine)\n\nThe WA `.venv` ships without pip. Run from `~\u002Fyour-project.com`:\n\n```bash\n.venv\u002Fbin\u002Fpython -m ensurepip\n.venv\u002Fbin\u002Fpython -m pip install \\\n  firebase-admin google-cloud-firestore \\\n  flask pydantic jsonschema python-docx fpdf2\n```\n\nAll five are required — `flask` and `jsonschema` are transitive imports of\n`firestore_service` and `document_generator`. Missing `pydantic` breaks\n`firestore_service.get_campaign_by_id()`. Missing `python-docx` breaks\n`document_generator.get_story_text_from_context_enhanced()`. Missing `fpdf2`\nbreaks `document_generator` import. **Install all of them, every time.**\n\n### Phase 2 — sys.path ordering (every run)\n\nThe `clock_skew_credentials` module lives in `$PROJECT_ROOT\u002F`, not the project root.\nPath order matters — insert `mvp_site` BEFORE the root:\n\n```python\nsys.path.insert(0, \"$HOME\u002Fyour-project.com\u002Fmvp_site\")\nsys.path.insert(0, \"$HOME\u002Fyour-project.com\")\n```\n\n`WORLDAI_DEV_MODE=true` is **required** for any local Firestore query. The\nclock-skew validator raises `ValueError` if `WORLDAI_GOOGLE_APPLICATION_CREDENTIALS`\nis set without `WORLDAI_DEV_MODE=true` to explicitly acknowledge dev mode.\n\n### Phase 3 — Auth + clock skew\n\n```python\nimport os\nos.environ[\"GOOGLE_APPLICATION_CREDENTIALS\"] = os.path.expanduser(\"~\u002FserviceAccountKey.json\")\nos.environ[\"WORLDAI_DEV_MODE\"] = \"true\"\n\nfrom clock_skew_credentials import apply_clock_skew_patch\napply_clock_skew_patch()  # adjusts time by -720 seconds\n\nimport firebase_admin\nfrom firebase_admin import auth, credentials, firestore\nif not firebase_admin._apps:\n    cred = credentials.Certificate(os.path.expanduser(\"~\u002FserviceAccountKey.json\"))\n    firebase_admin.initialize_app(cred)\n\nuser = auth.get_user_by_email(\"$USER@gmail.com\")\nuid = user.uid  # do not use Firestore user docs for email lookup\n```\n\n### Phase 4 — Pull campaign data\n\n```python\nimport firestore_service\nimport document_generator\nfrom google.cloud import firestore\n\ncampaign_id = \"vNU3AAXHd9N7adqWSM2p\"\ncampaign_data, story_context = firestore_service.get_campaign_by_id(uid, campaign_id)\n\n# campaign_data is a Firestore DocumentSnapshot\ncd = campaign_data.to_dict() if hasattr(campaign_data, \"to_dict\") else campaign_data\ntitle = cd.get(\"name\", cd.get(\"title\", \"Untitled\"))\n\n# story_context is a list of story entry dicts\nstory_text = document_generator.get_story_text_from_context_enhanced(\n    story_context, include_scenes=True\n)\n\n# Game state (separate call)\ngs = firestore_service.get_campaign_game_state(uid, campaign_id)\ngs_data = gs.to_dict() if gs is not None else {}\n```\n\n**Cross-check the helper — see Pitfall #8 below.** Some campaigns (e.g.\n`WlfgzI0ReBrFkmagW3wU` \"Nocturne bg3 v5 succubus copy\") return a\nzero-length story_context from `firestore_service.get_campaign_by_id`\neven though the `story` subcollection has hundreds of entries. The\nhelper has at least one bug path that drops entries silently. Before\ntrusting any \"0 entries\" result, cross-check with a direct\naggregation count and fall back to a direct stream if the helper\ncount disagrees with the direct count. The driver uses this pattern:\n\n```python\ndb = firestore.client()\ndirect_count = int(db.collection(\"users\").document(uid)\n                  .collection(\"campaigns\").document(campaign_id)\n                  .collection(\"story\").count().get()[0][0].value)\nif direct_count > len(story_context):\n    # helper returned truncated\u002Fmissing — pull directly\n    docs = list(db.collection(\"users\").document(uid)\n                .collection(\"campaigns\").document(campaign_id)\n                .collection(\"story\").stream())\n    story_context = [d.to_dict() for d in docs]\n    story_text = document_generator.get_story_text_from_context_enhanced(\n        story_context, include_scenes=True\n    )\n```\n\n### Phase 5 — Idempotent writes\n\nTwo campaigns with the same title (e.g. \"Vespera Thul (copy)\") must NOT\noverwrite each other. Use `campaign_id[:8]` suffix in BOTH the raw archive\npath and the wiki source path:\n\n```python\nslug = slugify(title)\nwiki_path = Path(f\"~\u002Fllm_wiki\u002Fwiki\u002Fsources\u002F{slug}-{campaign_id[:8]}.md\").expanduser()\nraw_dir = Path(f\"~\u002Fllm_wiki\u002Fraw\u002Fcampaigns\u002F{campaign_id}\").expanduser()\n```\n\nIdempotency check: skip if `wiki_path.exists()` AND its size > 500 bytes\n(skips blank\u002Fpartial frontmatter-only stubs).\n\n### Phase 5b — Verify the export (mandatory for batch runs)\n\nAfter a batch run, re-pull each exported campaign from Firestore and\nbyte-diff the live `get_story_text_from_context_enhanced` output against\nthe on-disk raw `.txt`. Campaigns are live — users keep typing in another\ntab while a batch runs, so any candidate that took >1s to export can\nhave a newer entry by the time the verify pass runs.\n\nPass criteria:\n- `live_count == on-disk entry_count` from frontmatter (no story loss)\n- `len(live_text)` within 1% of `len(on_disk_text)` (allow tiny drift from\n  new entries; >5% means the export raced with writes and should be\n  re-pulled)\n\nOutput a `\u002Ftmp\u002Fverify_\u003Cbatch_tag>_report.jsonl` with one row per\ncandidate, then run a repair pass for any row with `drift_pct > 1.0`\n(only those — re-pulling everyone wastes ~3 minutes on a 228-campaign batch).\n\nFor the 2026-07-12 batch-50plus run, 28\u002F228 candidates drifted between\nbatch and verify due to user activity; repair pass re-pulled only those\nin ~30s. Total verify+repair wall time: under 4 minutes for 228 candidates.\n\n### Phase 6 — Output contract\n\nEach campaign gets:\n\n1. **Raw archive** at `~\u002Fllm_wiki\u002Fraw\u002Fcampaigns\u002F\u003Cid8>\u002F\u003Csafe_title>_\u003Cid8>.txt`\n   — full story text, scenes included.\n2. **Game state** at `~\u002Fllm_wiki\u002Fraw\u002Fcampaigns\u002F\u003Cid8>\u002F\u003Csafe_title>_\u003Cid8>_game_state.json`\n   — full Firestore game_state doc, JSON serialised with `default=str` for datetimes.\n3. **Wiki source page** at `~\u002Fllm_wiki\u002Fwiki\u002Fsources\u002F\u003Cslug>-\u003Cid8>.md` — frontmatter:\n\n   ```yaml\n   ---\n   title: \"\u003Ctitle>\"\n   type: source\n   tags: [campaign, worldarchitect, \u003Cslug>]\n   date: YYYY-MM-DD\n   source_file: \u003Craw path>\n   campaign_id: \u003Cid>\n   entry_count: \u003CN>\n   last_updated: \u003Cts>\n   ingest_batch: \u003Cbatch tag>\n   ---\n   ```\n\n   Body: the story text, truncated to 100,000 chars per page.\n\n4. **Manifest entry** appended to `\u002Ftmp\u002Fcampaign_ingest_manifest.jsonl`.\n\n## Batch mode filters\n\n```bash\n--min-entries 50      # only campaigns with ≥N story entries\n--days 14             # only campaigns active in last N days (by max story timestamp)\n--skip-existing       # skip if wiki page already exists with content\n--campaigns-dir \u003Cpath> # output raw archive dir (default \u002Ftmp\u002Fcampaign_downloads)\n```\n\n## Discovery scan — entry-count recipe (replaces `.limit(2000).stream()`)\n\nFor scanning $USER's full campaign list (1,000+ campaigns in practice),\ndo NOT use `.limit(2000).stream()` for entry counts — it caps at 2000 and\ngives wrong answers for any campaign with more. Use Firestore aggregation\nqueries (preferred) or a single `.stream()` with no limit when count > 2000:\n\n```python\ndb = firestore.client()\n# Preferred: aggregation count (1 read, no document materialization)\nagg = (db.collection(\"users\").document(uid).collection(\"campaigns\")\n       .document(cid).collection(\"story\").count().get())\nentry_count = int(agg[0][0].value)\n\n# Fallback for when aggregation isn't enough (need actual entries to sort by\n# timestamp \u002F author etc.):\ndocs = list(db.collection(\"users\").document(uid).collection(\"campaigns\")\n            .document(cid).collection(\"story\").stream())\nentry_count = len(docs)\nlast_scene_ts = max(\n    (d.to_dict().get(\"timestamp\") or d.to_dict().get(\"created_at\") for d in docs),\n    default=None,\n)\n```\n\nFor the 1,080 $USER campaign discovery scan (2026-07-12 batch) the\naggregation path returned correct counts in ~3 minutes total wall time.\nScanning all story subcollections in one process is safe — gRPC FD bug\nonly fires when `download_campaign.py` is spawned as a subprocess.\n\n## Pitfalls (this list IS the skill — review before running)\n\n1. **Never subprocess `download_campaign.py`** — gRPC FD inheritance\n   (`ev_poll_posix.cc:593 FD from fork parent still in poll list`) makes\n   every download fail. Always inline.\n2. **Subcollection is `story`, not `story_entries`** — `story_entries`\n   returns 0 entries. The 2026-05-31 discovery cost a full day of confusion.\n3. **`WORLDAI_DEV_MODE=true` is mandatory** — the clock-skew validator\n   raises `ValueError: WORLDAI_GOOGLE_APPLICATION_CREDENTIALS requires\n   WORLDAI_DEV_MODE=true. Set WORLDAI_DEV_MODE=true to explicitly acknowledge\n   development mode.` without it.\n4. **`\u002Fprivate\u002Ftmp\u002Ftypes.py` collision** — if running from `\u002Ftmp\u002F`, a stale\n   `types.py` can shadow the stdlib module, causing\n   `ImportError: cannot import name 'GenericAlias'`. Fix: `rm \u002Fprivate\u002Ftmp\u002Ftypes.py`.\n5. **2000-entry Firestore limit** — counting entries with `.limit(2000).stream()`\n   shows exactly 2000 for any campaign with 2000+ entries. Use aggregation\n   queries or no limit for precise counts. For ≥50 detection, limit(2000) is\n   fine since the threshold is well below the cap.\n6. **Slug collision on duplicates** — campaigns with the same name (e.g.\n   \"Vespera Thul (copy)\") must use `campaign_id[:8]` in BOTH raw dir name\n   AND wiki page filename, or the second copy overwrites the first.\n7. **`.venv` dep chain** — must install `flask pydantic jsonschema python-docx fpdf2`\n   in addition to `firebase-admin google-cloud-firestore`. The five-app stack\n   import chain pulls in all of them transitively.\n8. **`firestore_service.get_campaign_by_id` can return an empty story list** —\n   some campaigns silently drop to `len(story_context)==0` even though their\n   `story` subcollection has hundreds of entries. Discovered 2026-07-12 on\n   `WlfgzI0ReBrFkmagW3wU` (\"Nocturne bg3 v5 succubus copy\", 554 entries on\n   disk, helper returns 0). Cause: an internal helper bug in\n   `firestore_service.get_campaign_by_id` — root-cause not yet isolated, but\n   the failure mode is consistent (helper returns 0, direct collection stream\n   returns full count). Fix: always cross-check with\n   `db.collection(...).collection(\"campaigns\").document(cid).collection(\"story\").count().get()`\n   and fall back to a direct `.stream()` if the direct count > helper count.\n   Treat any \"0 entries\" result from the helper as a bug, not as data.\n9. **macOS BSD `find -newermt @\u003Cepoch>` is silently broken — use a human-readable\n   date string instead.** GNU `find` accepts `-newermt @1784583090` (epoch\n   seconds). macOS BSD `find` does NOT — it silently returns 0 matches and\n   your batch script will look like \"no work was done\" when in fact it wrote\n   a dozen new files. This bites any launchd-managed batch script that uses\n   `find -newermt` for change detection. Verified 2026-07-20 on\n   `wiki-campaign-daily-ingest.sh`: after the `--mode all-users` ingest wrote\n   12 new wiki pages, the shell's `find -newermt \"@$RUN_START_TIME\"` returned\n   0, the script's \"Files added\u002Fmodified: added=0\" branch fired, and the\n   git push was skipped — leaving the 12 new files uncommitted in the\n   working tree. Fix: store BOTH the epoch AND a formatted date string\n   (`RUN_START_DATE=$(date -r \"$RUN_START_TIME\" '+%Y-%m-%d %H:%M:%S')`) and\n   use `-newermt \"$RUN_START_DATE\"` — works on both BSD and GNU find. The\n   `4 minutes ago` relative form also works but is unreliable when the run\n   wall-clock differs from the script's mtime capture.\n\n10. **`slack_post_message | tee` swallows the function's return code.** When\n    wrapping `slack_post_message` (or any helper that can fail) inside an\n    `if` guard with `| tee`, the pipeline's exit code is tee's, not the\n    helper's — Slack posts silently fail and the script logs \"sent\". Always\n    capture `$?` via `$()` command substitution:\n    ```bash\n    local out rc\n    out=$(slack_post_message \"$CHAN\" \"$TEXT\" 2>&1)\n    rc=$?\n    echo \"$out\" | tee -a \"$LOG\" >\u002Fdev\u002Fnull\n    if [[ $rc -eq 0 ]]; then log \"sent\"; else log \"WARN: rc=$rc\"; fi\n    ```\n    Caught 2026-07-20: bot was posting to #ai-general which it wasn't a\n    member of, but the script reported \"Slack notification sent\" anyway.\n\n11. **`[[ -z \"$X\" ]] && X=0` returns non-zero when X is non-empty** — the `&&`\n    short-circuits to the false branch, and the whole expression exits 1.\n    Combined with an ERR trap (or `set -e`), this fires spurious failure\n    notifications on every successful run. Use explicit assignment:\n    ```bash\n    # WRONG: ERR trap fires on every populated X\n    eval \"[[ -z \\\"\\${$v}\\\" ]] && $v=0\"\n    # RIGHT: plain assignment, always exits 0\n    eval \"val=\\${$v}\"\n    val=$(printf '%s' \"$val\" | tr -cd '0-9')\n    if [[ -z \"$val\" ]]; then val=0; fi\n    eval \"$v=$val\"\n    ```\n    Caught 2026-07-20: the wiki-campaign-daily-ingest.sh ingest-counter\n    loop was firing `notify_error()` on every run because the variable\n    assignment used the wrong pattern.\n\n12. **mcp_agent_mail bot is NOT a member of every channel.** The bot\n    (`U0A4G7LDJ4R`, app `A0A3WSV6BM1`) is in `#life` (`C0AMM2B4319`) and\n    `#all-$USER-ai` (`C09GRLXF9GR`) but NOT in `#ai-general`\n    (`C0AJQ5M0A0Y`). Verify with `conversations.info` before picking a\n    notification channel, or you'll get silent failures. To re-invite the\n    bot to a new channel, see `slack-mcp-mail-bot-reinstall` skill §6\n    (Aside-driven `slack.getClient()` recipe). For the daily wiki-campaign\n    cron, #life is the safe default.\n\n13. **`MOCK_SERVICES_MODE=true` parent shell env silently redirects Firestore to an in-memory mock.** Several launchd and\n    shell sessions export `MOCK_SERVICES_MODE=true` (it's set in `~\u002F.bashrc` \u002F `~\u002F.bash_profile` for hermetic-test tooling).\n    When `download_campaign.py` runs under such a parent, `firestore_service.get_firestore_client()` detects the env var\n    and returns a singleton in-memory client (`firestore_service.py` L3567-3575). Every Firestore read then returns\n    \"data not found\" or empty collections — the script logs `MOCK_SERVICES_MODE enabled - creating singleton in-memory\n    Firestore client` and exits with `RuntimeError: no data for \u003Ccampaign_id>` even though the real campaign has\n    hundreds of entries. **Detection**: scan the script's stdout for that exact log line; if present, the env var is\n    active and you must drop it. **Fix**: run with `env -u MOCK_SERVICES_MODE` prefix on the command line\n    (`env -u MOCK_SERVICES_MODE .venv\u002Fbin\u002Fpython ...`). Always add this prefix in any download \u002F ingest script\n    unless you specifically want the mock client. Verified 2026-07-26 on `qoQtHsU7DxZnR24VNU9w` (Visenya v9):\n    first run hit `RuntimeError: no data for qoQtHsU7DxZnR24VNU9w`; with `env -u` it pulled 824 entries in ~3s.\n\n## Game state key fields (for analysis)\n\n- `player_character_data` — PC stats, features, equipment, relationships.\n  Note: no personality fields (motivation, fear, speech patterns).\n- `npc_data` — dict keyed by NPC name; entries have `level`, `role`,\n  `relationships`, sometimes `mbti` \u002F `alignment` (labels only, no deep profile).\n- `custom_campaign_state` — `core_memories` (list of narrative milestone\n  strings), `active_missions`, `active_constraints`, `faction_minigame`,\n  `god_mode_directives`.\n- `npc_agendas` — often empty dict even in long campaigns.\n- `combat_state` — current encounter data.\n\n## Related\n\n- `wiki-ingest` — broader skill covering ported-source, Firestore batch, and\n  external-source ingest paths.\n- `~\u002Fllm_wiki\u002Ftools\u002Fbatch_campaign_ingest_inline.py` — older version of the\n  batch tool (slug-only paths, no id8 suffix). Superseded by the script\n  under `scripts\u002Fdownload_campaign.py` in this skill.\n- `~\u002Fllm_wiki\u002Fwiki\u002Fsources\u002Fwa-firestore-campaign-schema.md` — schema reference.\n- `references\u002Fbatch-50plus-2026-07-12.md` — session notes from the\n  228-campaign batch run: scan numbers, verification numbers, driver\n  scripts, Git workflow, daily-cron opportunity.\n- `references\u002Fmulti-user-batch-rollout-2026-07-20.md` — session notes from\n  extending the daily cron to all real users (auth.list_users + is_test_email\n  filter). Includes the `find -newermt @\u003Cepoch>` bug caught during\n  verification.\n\n## Tests\n\n- `tests\u002Ftest_slugify.py` — slug generation, including id8 suffix.\n- `tests\u002Ftest_idempotent_path.py` — verifies no slug collision for\n  duplicate titles (\"Vespera Thul (copy)\" 11× → 11 unique paths).\n- `tests\u002Ftest_dependencies.py` — verifies the .venv dep chain is present.\n\nRun: `cd ~\u002F.hermes_prod\u002Fskills\u002Fdownload-campaign && python3 -m unittest discover -s tests`\n",{"name":5,"context":35,"arguments":62,"description":7,"when_to_use":64,"allowed-tools":65,"argument-hint":66},[63,40],"campaign_id","Use when the user says: download campaign, fetch this campaign, pull from firestore, ingest campaign, get campaign by id, copy campaign X, batch download recent campaigns, scan last N days, scan for >50 entries, last 2 weeks of campaigns, the campaign wizard walked. Do NOT use for: full wiki page writing (use wiki-ingest), Firestore read only with no download (use firestore_service.get_campaign_by_id directly).","terminal, file","[campaign_id or 'recent' or 'batch'] [--min-entries N] [--days N] [--skip-existing] [--campaigns-dir \u003Cpath>]","main","42ccd02cbf5e8e47839dc3eab6fc754dc6b339cf","hermes\u002Fskills\u002Fdownload-campaign",0,"https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills","https:\u002F\u002Fgithub.com\u002Fjleechanorg","2026-11-14 14:55:35",{"source":9,"skillName":5,"commands":75,"prompt":85,"zipAvailable":86},[76,79,82],{"tool":77,"command":78},"npx","npx skills add jleechanorg\u002Fjleechan-skills --skill download-campaign",{"tool":80,"command":81},"bunx","bunx skills add jleechanorg\u002Fjleechan-skills --skill download-campaign",{"tool":83,"command":84},"pnpm","pnpm dlx skills add jleechanorg\u002Fjleechan-skills --skill download-campaign","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002Fhermes\u002Fskills\u002Fdownload-campaign\u002FSKILL.md",true,[88,94,98,104,108],{"path":89,"resourceType":90,"resourceTypeDesc":91,"sizeBytes":92,"sourceHtmlUrl":93},"references\u002Fbatch-50plus-2026-07-12.md","REFERENCE","参考文档",4475,"https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002Fhermes\u002Fskills\u002Fdownload-campaign\u002Freferences\u002Fbatch-50plus-2026-07-12.md",{"path":95,"resourceType":90,"resourceTypeDesc":91,"sizeBytes":96,"sourceHtmlUrl":97},"references\u002Fmulti-user-batch-rollout-2026-07-20.md",3041,"https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002Fhermes\u002Fskills\u002Fdownload-campaign\u002Freferences\u002Fmulti-user-batch-rollout-2026-07-20.md",{"path":99,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":102,"sourceHtmlUrl":103},"scripts\u002Fdownload_campaign.py","SCRIPT","脚本",14893,"https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002Fhermes\u002Fskills\u002Fdownload-campaign\u002Fscripts\u002Fdownload_campaign.py",{"path":105,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":106,"sourceHtmlUrl":107},"tests\u002Ftest_download_campaign.py",6245,"https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002Fhermes\u002Fskills\u002Fdownload-campaign\u002Ftests\u002Ftest_download_campaign.py",{"path":109,"resourceType":100,"resourceTypeDesc":101,"sizeBytes":110,"sourceHtmlUrl":111},"tests\u002Ftest_resolver_triggers.py",3550,"https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002Fhermes\u002Fskills\u002Fdownload-campaign\u002Ftests\u002Ftest_resolver_triggers.py",[113,121,128,136,144,153],{"skillNo":114,"name":115,"nameZh":13,"description":116,"descriptionZh":13,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":13,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":120},"01M7DRVZXXMGY4G81K5GVF4V20","disk-reclaim-playbook","Use Disk Magician to diagnose disk growth or qualify cleanup on macOS or Linux.","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fdisk-reclaim-playbook\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":122,"name":123,"nameZh":13,"description":124,"descriptionZh":13,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":13,"sourceHtmlUrl":125,"categories":126,"keywords":127,"publishedAt":120},"01M7B63PNTT2TY78RFKHD8SP3X","claudea-bench","Compare `claudea` and normal `claude` on a fair split of comparable work by default; use `--strict` for duplicate runs of the exact same task.","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fclaudea-bench\u002FSKILL.md",[],[],{"skillNo":129,"name":130,"nameZh":13,"description":131,"descriptionZh":13,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":13,"sourceHtmlUrl":132,"categories":133,"keywords":134,"publishedAt":135},"01M7622KQJ32AV4K5BXEMVSSEB","pr","Alias for the canonical pr-lifecycle PR workflow skill (\u002Fpr-workflow, \u002Fprw).","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills\u002Fpr\u002FSKILL.md",[],[],"2026-11-12 13:55:43",{"skillNo":137,"name":138,"nameZh":13,"description":139,"descriptionZh":13,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":13,"sourceHtmlUrl":140,"categories":141,"keywords":142,"publishedAt":143},"01M7432W92AKC4D1TKJ00VCMMT","whisper","OpenAI's general-purpose speech recognition model. Supports 99 languages, transcription, translation to English, and language identification. Six model sizes from tiny (39M params) to large (1550M params). Use for speech-to-text, podcast transcription, or multilingual audio processing. Best for robust, multilingual ASR.","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills_archive\u002F2026-11-09-no-usage-evidence\u002Fwhisper\u002FSKILL.md",[],[],"2026-11-11 15:11:14",{"skillNo":145,"name":146,"nameZh":13,"description":147,"descriptionZh":13,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":148,"licenseFileUrl":149,"sourceHtmlUrl":150,"categories":151,"keywords":152,"publishedAt":143},"01M7432T6BN1A9SHB8RBQR5EMP","webapp-testing","Toolkit for interacting with and testing local web applications using Playwright. Supports verifying frontend functionality, debugging UI behavior, capturing browser screenshots, and viewing browser logs.","Apache-2.0","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills_archive\u002F2026-11-09-no-usage-evidence\u002Fwebapp-testing\u002FLICENSE.txt","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills_archive\u002F2026-11-09-no-usage-evidence\u002Fwebapp-testing\u002FSKILL.md",[],[],{"skillNo":154,"name":155,"nameZh":13,"description":156,"descriptionZh":13,"repositoryFullName":9,"ownerLogin":10,"ownerAvatarUrl":11,"ownerAccountNo":12,"ownerDisplayName":13,"repositoryNo":14,"starsCount":15,"licenseSpdxId":16,"licenseFileUrl":13,"sourceHtmlUrl":157,"categories":158,"keywords":159,"publishedAt":143},"01M7432NDC7S6C6MX7M6RW8CTT","pr-report","This skill should be used when the user asks for a PR report, PR audit, PR delta analysis, \u002Fpr-report, or wants per-PR summary with delta files\u002Flines. Generates a structured report for one or more open PRs covering purpose, files changed, +\u002F− line counts, \u002Fcode-standards + \u002Fthermo review findings, \u002Fponytail simplification opportunities, file-overlap combination candidates, and \u002Fgreen status per pr-green-definition. Output: machine-readable JSONL + human-readable markdown. Read-only by default; can apply simplifications if user opts in.","https:\u002F\u002Fgithub.com\u002Fjleechanorg\u002Fjleechan-skills\u002Fblob\u002Fmain\u002F.claude\u002Fskills_archive\u002F2026-11-09-no-usage-evidence\u002Fpr-report\u002FSKILL.md",[],[]]