[{"data":1,"prerenderedAt":-1},["ShallowReactive",2],{"skill:01M6JTFFDRZTAX3WAGN19571VN":3,"skill-same:01M6JTFFDRZTAX3WAGN19571VN":69},{"skillNo":4,"name":5,"nameZh":6,"description":7,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":15,"licenseFileUrl":6,"sourceHtmlUrl":16,"categories":17,"keywords":18,"publishedAt":40,"linkOnly":41,"markdownContent":42,"markdownBody":43,"frontMatter":44,"refName":45,"commitSha":46,"skillDirectory":47,"forksCount":48,"repositoryHtmlUrl":49,"repositoryHomepageUrl":50,"ownerHtmlUrl":51,"ownerBlogUrl":52,"ownerDescription":53,"updatedAt":54,"install":55,"resources":68},"01M6JTFFDRZTAX3WAGN19571VN","maintaining-modding-environments",null,"Use after first-run for ongoing modpack maintenance: update\u002Finstall KB packs, author or register custom\u002Fmod KB packs, maintain localization glossary KBs for translator use, prune KB cache, health-check the environment, version-pin KB\u002Ftooling, or handle recurring BGS modding environment care.","hashgraph-online\u002Fawesome-codex-plugins","hashgraph-online","https:\u002F\u002Favatars.githubusercontent.com\u002Fu\u002F160371962?v=4","01M6CNB6NRJVNNGN14TR01Q6D3","HOL (Hashgraph Online)","01M6JT1HSKKG9V68KQAQGBA7XP",1575,"Apache-2.0","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FBB-84C\u002Fbgs-modding-superpowers\u002Fskills\u002Fmaintaining-modding-environments\u002FSKILL.md",[],[19,20,21,22,23,24,25,26,27,28,29,30,31,32,33,34,35,36,37,38,39],"maintaining modding environments","environments","modpack","author","custom","for","register","localization","health-check","maintain","maintenance","run","version","use","kb","check","glossary","translator","prune","health","update","2026-11-10 10:12:30",false,"---\nname: maintaining-modding-environments\ndescription: \"Use after first-run for ongoing modpack maintenance: update\u002Finstall KB packs, author or register custom\u002Fmod KB packs, maintain localization glossary KBs for translator use, prune KB cache, health-check the environment, version-pin KB\u002Ftooling, or handle recurring BGS modding environment care.\"\n---\n\n# Maintaining Modding Environments\n\n## When to use\n\n- The environment is already set up and the user asks to maintain, refresh, update, or health-check it.\n- The user says \"register custom pack\", \"install my KB pack\", \"set `BGS_KB_USER_PACKS`\", or asks how to author a local KB pack.\n- The user asks how to maintain a mod knowledge base, a translator glossary KB, or a third-party localization KB for Skyrim\u002FFallout\u002FStarfield.\n- The user asks to install, upgrade, repair, or verify the standalone\n  `xtl`\u002F`bgs-translator` CLI after first-run.\n- The user asks to check or apply knowledge-base updates after first-run.\n- The user asks to prune the KB cache or clean old pack versions.\n- The user asks whether to pin a KB pack version, follow latest, or handle a `minPluginVersion` warning.\n\n## What this skill replaces\n\nUse `setting-up-bgs-modding-environment` for first-run: MO2 detection, control-plane install, visible MO2 launch, first xEdit acquisition, first KB pack acquisition, and first semantic smoke.\n\nThis skill owns ongoing care after that first-run boundary: KB updates, cache hygiene, custom-pack authoring and registration, translator CLI maintenance, recurring environment health checks, and version-pinning advice.\n\n## Translator CLI maintenance\n\n`xtl` is the standalone AI translation CLI\u002FWeb GUI launcher. It is published on\nPyPI as `bgs-translator`; the portable plugin may include translator-facing\nskills, but a fresh user machine still needs the Python package installed before\nhigh-speed agents can call `xtl`.\n\nStart every maintenance pass with an explicit readback:\n\n```powershell\n# Check whether xtl is installed and can report its version\u002Fcapabilities.\nxtl version\n\n# Inspect top-level commands before choosing a workflow.\nxtl --help\n```\n\nIf `xtl` is missing or too old, prefer an isolated user-level CLI install:\n\n```powershell\n# Install the current release-candidate build as an isolated command-line tool.\npipx install bgs-translator==0.9.0rc1\n\n# Upgrade an existing pipx-managed xtl install when a newer stable build exists.\npipx upgrade bgs-translator\n```\n\nIf `pipx` is unavailable, or the user explicitly wants `xtl` inside a project\nvirtual environment, use Python's package installer from that environment:\n\n```powershell\n# Install or upgrade xtl inside the selected Python environment.\npy -3.12 -m pip install --upgrade bgs-translator==0.9.0rc1\n```\n\nFor a future stable release, use the unpinned package name for normal installs:\n`pipx install bgs-translator`, `pipx upgrade bgs-translator`, or\n`py -3.12 -m pip install --upgrade bgs-translator`. Do **not** use broad\n`--pre` during routine maintenance; it can allow prerelease dependency versions\nthat were not part of the tested translator build. Pin an exact prerelease only\nwhen the user intentionally wants that version.\n\nAfter any install or upgrade, inspect subcommand help instead of assuming\nspecific option values:\n\n```powershell\n# Verify provider-profile setup options, including all supported SDK kinds.\nxtl profile add --help\n\n# Verify web GUI launch options and ports.\nxtl gui --help\n\n# Verify batch controls before telling an agent to submit or resume work.\nxtl batch --help\n```\n\nIf a GUI or background translator service gets into an inconsistent state,\nrestart it with the repo's reusable helper instead of inventing process-kill\nsteps:\n\n```powershell\n# Restart the translator GUI\u002Fservice stack using the project helper.\npwsh tools\\bgs-translator\\scripts\\restart-web-gui.ps1 -Port 7847\n```\n\nIf that helper is absent in an older checkout, fall back to the current\n`using-bgs-translator` instructions for launching `xtl gui`, then file a note in\nthe environment maintenance log that the helper should be added or backported.\n\n## Check + apply KB updates\n\n1. Start with `bgs_kb_status({})` to see loaded packs, versions, cache root, user roots, and warnings.\n2. If `bgs_kb_check_updates` exists, call it for the installed pack IDs. Surface available updates, `breakingChange`, and release URLs before taking action.\n3. If `bgs_kb_check_updates` is not present yet (pre-KB-6), check GitHub Releases for `bgs-modding-superpowers` KB pack artifacts and `manifest-index.json`. Do not invent release names.\n4. Before installing or replacing a pack, get user consent for the download \u002F cache mutation.\n5. If `bgs_kb_install_pack` exists, use it with an exact `{ packId, version }`. Prefer `dryRun: true` before live install when the tool supports it.\n6. If the install tool is not present yet, download the Release asset manually only after consent, verify the published sha256, extract into the cache layout below, then restart or reconnect the MCP so discovery runs again.\n7. After any update, run the health checks below.\n\n## Cache hygiene\n\nCache root (all platforms — unified with `xtl` \u002F `bgs-translator`):\n\n```text\n~\u002F.bgs-modding-superpowers\u002Fkb\u002Fpacks\u002F\u003CpackId>\u002F\u003Cversion>\u002F\n```\n\nThe legacy Windows-only cache at `%LOCALAPPDATA%\u002Fbgs-modding-superpowers\u002Fkb\u002Fpacks\u002F`\nis **no longer used**. If `bgs_kb_status` surfaces packs that are not visible to\n`xtl batch plan`, suspect a legacy cache and either:\n\n- move the directory tree from `%LOCALAPPDATA%\u002Fbgs-modding-superpowers\u002Fkb\u002F` to\n  `~\u002F.bgs-modding-superpowers\u002Fkb\u002F`, or\n- export the legacy root via `$env:BGS_KB_USER_PACKS` so the MCP keeps reading\n  it as an additional read-only root while the user finishes migrating.\n\nEach version directory contains `manifest.json`, `records\u002F`, and `kb.sqlite`. Current policy: retain the current version and the immediately previous version as rollback\u002Ffallback. Prune versions older than that only after confirming the pack is not pinned by the user or referenced by a current modpack workflow.\n\nUse the KB MCP CLI for routine pruning:\n\n```powershell\n# Preview which cached pack versions would be removed.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js prune-cache --dry-run\n\n# Apply the prune after the user accepts the preview.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js prune-cache\n```\n\nThe dry run should be surfaced before deletion when the user has not already approved cache mutation. The command keeps the highest version and the immediately previous version per pack, then removes older cached versions.\n\nDo not delete `incoming\u002F` while an install is running. If an install failed earlier and no installer is active, stale `incoming\u002F` contents can be removed after surfacing the path to the user.\n\n## Custom pack authoring + registration\n\nAuthor records as:\n\n```text\n\u003Cpack-root>\u002Frecords\u002F\u003Cdomain>\u002F\u003Cid>.md\n```\n\nRecord frontmatter uses the same schema as official packs under `knowledge\u002Fbgs-kb\u002Fschema\u002Frecord.schema.json`: stable `id`, `title`, `domains`, `appliesTo`, `canonical`, `sources`, `lastReviewed`, and `schemaVersion` are the important fields to check first.\n\nEvery pack needs a `bgs-kb-meta.yml` at the pack root. Minimum fields:\n\n```yaml\npackId: user-my-pack\ndisplayName: My Modpack Knowledge\nversion: 2026.06.02\nschemaVersion: 1\nminPluginVersion: 0.2.0\n```\n\nReserved official pack IDs: `bgs-kb-core`, `bgs-kb-skyrim`, `bgs-kb-fallout4`, `bgs-kb-fallout3-fnv`, `bgs-kb-starfield`. End-user packs must not use the `bgs-kb-*` namespace; recommend a `user-*` prefix.\n\nBuild the pack:\n\n```powershell\n# Build kb.sqlite and manifest.json from the pack's records\u002F tree.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js build \u003Cpack-root>\n```\n\nThis produces `kb.sqlite` and `manifest.json` next to `records\u002F`.\n\nValidate and inspect:\n\n```powershell\n# Validate every Markdown record against the official KB schema.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js validate \u003Cpack-root>\n\n# Inspect pack metadata, counts, games, and domains.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js info \u003Cpack-root>\n```\n\nImportant `BGS_KB_USER_PACKS` semantics: each entry is a directory that contains one or more pack directories, not a pack directory itself. Multiple roots are separated by `;` on Windows.\n\nWorked example:\n\n```text\nC:\\my-kb-roots\\\n  my-custom-pack\\\n    bgs-kb-meta.yml\n    manifest.json\n    kb.sqlite\n    records\\\n      load-order\\\n        my-local-rule.v1.md\n```\n\nSet:\n\n```powershell\n# Point discovery at the directory that contains one or more pack folders.\n$env:BGS_KB_USER_PACKS = \"C:\\my-kb-roots\"\n```\n\nDo not set it to `C:\\my-kb-roots\\my-custom-pack`; that points at the pack itself and discovery will look one level too deep.\n\nAfter registration, restart\u002Freconnect the MCP so pack discovery runs, then call `bgs_kb_status({})` and verify the custom pack appears with the intended `packId`.\n\n## Pack discovery + collision recovery\n\n`bgs_kb_status({})` may report two warning codes when discovery sees the same `packId` at multiple roots:\n\n| Code | Meaning |\n|---|---|\n| `pack_id_overridden` (MEDIUM, informational) | Multiple sources for the same `packId`; precedence picked a winner automatically and listed the loser(s). All packs still load. |\n| `pack_id_collision` (HIGH, fail-closed fallback) | Precedence could not choose a winner — should be rare; all colliding copies are refused. |\n\n**Discovery precedence (apply in order):**\n1. Sort candidates with the same `packId` by `builtAt` timestamp DESC — newest manifest wins.\n2. Tie-break by root class: `bundled > cache > user`.\n\n**Common cause: `install-pack` over an already-bundled `packId`.** Plugin distributions ship per-game packs (e.g. `bgs-kb-fallout4`) in the bundled tree. If a user runs `bgs_kb_install_pack({ packId: \"bgs-kb-fallout4\", ... })` to fetch a Release-channel update, the new version lands in the cache root `~\u002F.bgs-modding-superpowers\u002Fkb\u002Fpacks\u002Fbgs-kb-fallout4\u002F\u003Cversion>\u002F`. On the next MCP restart:\n\n- If the cache copy has a newer `builtAt` (the normal update case) → cache wins, bundled loser warning. No action needed.\n- If the bundled copy is somehow newer (e.g. you pulled a plugin update that shipped a newer KB) → bundled wins, cache becomes the loser. To make the cache copy authoritative, install a newer Release or remove the stale cache copy.\n\n**Other causes:**\n\n- Two `$BGS_KB_USER_PACKS` parent directories contain pack folders with the same `packId` → warning per loser.\n- Manual file copy of a pack between roots without removing the original.\n\n**Preview before restarting MCP:** the bgs-kb-mcp CLI exposes a read-only `dev-status` subcommand that shows the same discovery decision the MCP would make, without requiring a server restart:\n\n```powershell\n# Preview every discovered packId, every candidate source, and which one would win.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js dev-status\n\n# Filter to one pack id (useful before install-pack or before editing user packs).\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js dev-status --pack bgs-kb-fallout4\n\n# Machine-readable output for scripting.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js dev-status --json\n```\n\n**Recovery patterns:**\n\n- **Want the cache copy to win**: ensure its `builtAt` is newer than the bundled copy's (run `bgs_kb_install_pack` for a fresh Release version), restart MCP, verify.\n- **Want the bundled copy to win**: remove or rename the cache pack directory, restart MCP.\n- **Two user roots collide**: drop one parent from `$BGS_KB_USER_PACKS`, or rename the colliding pack folder to a unique `packId` (after also updating its `bgs-kb-meta.yml`), restart MCP.\n- **Pre-flight before authoring or installing**: always run `dev-status --pack \u003CpackId>` first — it surfaces collisions before the next MCP restart turns them into status warnings.\n\nDo not delete cache copies aggressively as a first-line fix; the precedence rule selects automatically, so warnings are usually informational, not blocking.\n\n## Localization and translator KBs\n\nLocalization glossary packs are KB packs whose SQLite store includes\n`glossary_entries` and `glossary_aliases`. They feed `bgs-translator` RAG so an\nLLM receives canonical terms such as places, factions, item names, UI concepts,\nand do-not-translate entries. Put this guidance here, not in\n`using-bgs-translator`, because the same maintenance rules apply to official,\nmod-specific, and third-party glossary packs.\n\nOfficial bundled policy:\n\n- `bgs-l10n-starfield-zhhans` is the only official zh-Hans glossary pack we\n  ship from vanilla game data because Starfield is the only supported BGS game\n  with official Simplified Chinese localization.\n- Do not fabricate official Skyrim\u002FFallout4 Chinese packs. If the user wants\n  them, create third-party\u002Fuser packs with explicit source, license, scope, and\n  review notes.\n- The Starfield official pack is large and should be distributed through KB\n  Release artifacts, not copied into the portable plugin tree.\n\nFor a mod-specific translator KB, prefer a user namespace such as\n`user-l10n-\u003Cgame>-\u003Cmod>-zhcn`. Include only the mod's accepted terminology,\ncharacter\u002Fplace names, recurring UI labels, and do-not-translate terms. Do not\ndump every translated sentence into a term KB unless the user explicitly wants a\ntranslation-memory style pack and accepts the recall\u002Fnoise tradeoff.\n\nFor a third-party game localization KB, require:\n\n- source language, target language, game, source project\u002Fversion, and license;\n- provenance in `bgs-kb-meta.yml` and in generated notes;\n- a stable pack id outside reserved `bgs-kb-*` official namespaces;\n- a small sample query after registration to verify the pack is discoverable.\n\nIf the input is an xTranslator SST dictionary, the translator tool has a\none-shot builder that creates the glossary SQLite shape directly:\n\n```powershell\n# Build a user-maintained glossary pack from an SST dictionary.\npy -3.12 tools\\bgs-translator\\bgs_translator\\tools\\xtranslator_sst_to_kb_pack.py `\n  --input \"D:\\path\\to\\source_english_chinese.sst\" `\n  --output-dir \"C:\\my-kb-roots\\user-l10n-skyrim-thirdparty-zhcn\" `\n  --pack-id user-l10n-skyrim-thirdparty-zhcn `\n  --display-name \"User Skyrim zh-CN Localization Glossary\" `\n  --game SkyrimSE `\n  --source-lang en `\n  --target-lang zh-cn\n```\n\nThen set `BGS_KB_USER_PACKS` to the parent root, restart\u002Freconnect the MCP, and\nquery a known term. For translator-only packs, use `xtl`\u002Ftranslator glossary\nsmokes as the stronger check because `bgs_kb_query` only searches Markdown-style\nrecords unless the MCP has been upgraded for glossary-table queries.\n\n## Official KB release maintenance\n\nFor project maintainers cutting a KB Release, use the release staging script:\n\n```powershell\n# Rebuild source-record packs, verify prebuilt glossary packs, zip all packs,\n# and write dist\u002Fkb-release\u002Fmanifest-index.json.\npwsh scripts\u002Fbuild-kb-release.ps1 -Force\n```\n\nThe script includes the generated Starfield zh-Hans glossary pack in the release\nindex but does not rebuild it from Markdown records. If `kb.sqlite` hash\nverification fails, regenerate that pack from its approved source SST before\npublishing. The script prints the exact `gh release create ...` command; review\nthe staged `manifest-index.json` before running that network-side publish.\n\n## Version-pinning advice\n\nFollow latest when the user wants current general guidance and accepts normal KB refresh cadence.\n\nPin a specific pack version when a modpack release, guide, benchmark, or reproducibility note depends on exact advice staying stable. Record the pin in the modpack dev-log or release docs.\n\nIf a new pack's `minPluginVersion` exceeds the installed plugin version, warn and stop. Do not auto-upgrade the plugin. Offer choices: update the plugin with user consent, keep the older pack version, or pin the previous version until the plugin can be upgraded.\n\nKB cadence is independent of plugin cadence. A new KB pack can be consumed when `schemaVersion` and `minPluginVersion` are compatible; it does not automatically imply an xEdit or MO2 change.\n\n## Health checks\n\nQuick KB smoke after maintenance:\n\n```text\nbgs_kb_status({})\nbgs_kb_query({ query: \"plugins\", maxResults: 3 })\n```\n\nExpected: at least one loaded pack, no unexpected collision \u002F integrity warnings, and at least one query hit. If the target game is known, include the game filter, for example:\n\n```text\nbgs_kb_query({ query: \"plugins\", games: [\"Fallout4\"], maxResults: 3 })\n```\n\nFor custom packs, query a term from one of the custom records and verify hits are tagged with the custom `packId`.\n\nIf maintenance touched MO2 or xEdit runtime state, also use the appropriate setup \u002F xEdit skill checks. Do not treat KB health as proof of live load-order or plugin state.\n\n## Anti-patterns + warnings\n\n- Never write directly into Stock Game \u002F vanilla game `Data`. Any game-local change goes through an MO2 mod overlay or overwrite surface.\n- KB records are advisory. xEdit MCP readback remains authoritative for actual plugin, record, conflict, and load-order state.\n- Do not use `BGS_KB_USER_PACKS` to point at a single pack directory; point it at a root containing pack directories.\n- Do not use reserved `bgs-kb-*` pack IDs for local packs.\n- Do not install or upgrade KB packs with a `minPluginVersion` the current plugin does not satisfy.\n- Do not delete all old cache versions; keep current + previous unless the user explicitly chooses otherwise.\n\n## Refreshing Nexus update state without opening MO2 (Option B)\n\nUse this when the user wants fresh `newestVersion`, `nexusFileStatus`,\n`lastNexusQuery`, and `lastNexusUpdate` metadata without opening MO2 and running\n`Tools -> Check All for Updates`.\n\nWhy this exists: mobase's Python API does not expose the GUI update-check\ntrigger, and three of the four timestamp fields are not on the abstract\n`IModInterface`. See KB record\n`install-planning.nexus-direct-api-update-check.v1`. The direct Nexus API read\npath works for both Free and Premium accounts; these read endpoints are not\nPremium-gated.\n\nPrerequisite: the user must already have Nexus auth configured in MO2. That same\nMO2 credential store is the API-key source for the agent; see the next section.\n\nEndpoints used:\n\n```text\nGET https:\u002F\u002Fapi.nexusmods.com\u002Fv1\u002Fgames\u002F{game_domain}\u002Fmods\u002Fupdated.json?period=1m\nGET https:\u002F\u002Fapi.nexusmods.com\u002Fv1\u002Fgames\u002F{game_domain}\u002Fmods\u002F{id}.json\n```\n\nThe first endpoint is one bulk call to discover recently updated mods. The\nsecond endpoint is one per-mod call for fresh metadata. Nexus' rate budget is\n20,000 calls\u002Fday; a full 300-mod refresh is about 301 calls and is comfortable.\n\nPer-mod `meta.ini` update shape:\n\n```powershell\n$statusMap = @{ \"published\"=1; \"hidden\"=9; \"removed\"=6; \"wastebinned\"=6; \"under_moderation\"=9 }\n$mod = Invoke-RestMethod -Uri \"https:\u002F\u002Fapi.nexusmods.com\u002Fv1\u002Fgames\u002Fstarfield\u002Fmods\u002F$modid.json\" -Headers $headers\n$statusInt = if ($statusMap.ContainsKey($mod.status)) { $statusMap[$mod.status] } else { 1 }\n$nowIso = (Get-Date).ToUniversalTime().ToString(\"yyyy-MM-ddTHH:mm:ssZ\")\n$updatedIso = [DateTimeOffset]::FromUnixTimeSeconds($mod.updated_timestamp).ToString(\"yyyy-MM-ddTHH:mm:ssZ\")\n$content = [IO.File]::ReadAllText($metaPath, [Text.UTF8Encoding]::new($false))\n$content = $content -replace '(?m)^newestVersion=.*$', \"newestVersion=$($mod.version)\"\n$content = $content -replace '(?m)^nexusFileStatus=.*$', \"nexusFileStatus=$statusInt\"\n$content = $content -replace '(?m)^lastNexusQuery=.*$', \"lastNexusQuery=$nowIso\"\n$content = $content -replace '(?m)^lastNexusUpdate=.*$', \"lastNexusUpdate=$updatedIso\"\n[IO.File]::WriteAllText($metaPath, $content, [Text.UTF8Encoding]::new($false))\n```\n\nFor production-grade automation, prefer the helper script:\n\n```powershell\npwsh scripts\\refresh-nexus-update-state.ps1 -MO2Root \u003Cpath> -Game starfield\n```\n\nCaveat: direct `meta.ini` writes do not refresh MO2's in-memory\n`ModInfoRegular` until the next `organizer.refresh()` or MO2 restart.\n\n## Reading Nexus credentials from MO2's Windows Credential Manager store\n\nMO2 stores Nexus credentials globally for the current Windows user, not per MO2\ninstance. All portable MO2 instances under the same Windows account share them.\nMO2 uses `getWindowsCredential` \u002F `setWindowsCredential` in `settings.cpp`.\n\nCredential Manager targets:\n\n| Target | Meaning |\n|---|---|\n| `ModOrganizer2_APIKEY` | Legacy 162-character personal API key. |\n| `ModOrganizer2_NEXUS_OAUTH_TOKENS` | Compact JSON `{access_token, refresh_token, expires_at, scope, token_type}` from the modern OAuth flow. |\n\nRead pattern:\n\n```powershell\n$signature = @'\nusing System;\nusing System.Runtime.InteropServices;\nusing System.Text;\npublic class CredMan {\n  [DllImport(\"advapi32.dll\", SetLastError=true, EntryPoint=\"CredReadW\", CharSet=CharSet.Unicode)]\n  static extern bool CredRead(string target, uint type, uint flag, out IntPtr cred);\n  [DllImport(\"advapi32.dll\")] static extern void CredFree(IntPtr p);\n  [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]\n  public struct CREDENTIAL { public uint Flags,Type; public IntPtr TargetName,Comment; public System.Runtime.InteropServices.ComTypes.FILETIME LastWritten; public uint CredentialBlobSize; public IntPtr CredentialBlob; public uint Persist,AttributeCount; public IntPtr Attributes,TargetAlias,UserName; }\n  public static string Read(string t) { IntPtr p; if (!CredRead(t,1,0,out p)) return null; try { var c=(CREDENTIAL)Marshal.PtrToStructure(p,typeof(CREDENTIAL)); byte[] b=new byte[c.CredentialBlobSize]; Marshal.Copy(c.CredentialBlob,b,0,(int)c.CredentialBlobSize); int nz=0; for(int i=1;i\u003Cb.Length;i+=2)if(b[i]==0)nz++; return nz>(b.Length\u002F4)?Encoding.Unicode.GetString(b):Encoding.UTF8.GetString(b); } finally { CredFree(p); } }\n}\n'@\nAdd-Type -TypeDefinition $signature -Language CSharp\n$apiKey = [CredMan]::Read(\"ModOrganizer2_APIKEY\")\n$oauthJson = [CredMan]::Read(\"ModOrganizer2_NEXUS_OAUTH_TOKENS\")\n```\n\nVerification call:\n\n```powershell\nInvoke-RestMethod -Uri \"https:\u002F\u002Fapi.nexusmods.com\u002Fv1\u002Fusers\u002Fvalidate.json\" -Headers @{ APIKEY = $apiKey }\n```\n\nExpected fields include `user_id`, `name`, `is_premium`, and `is_supporter`.\n\n[WARNING]\nReading user credentials requires explicit user consent. Mask the key in any\nlogged output, for example `d0Ra...72d4 (len=162)`. Recommend key rotation after\nthe session if there is any leak risk.\n\nFailure modes:\n\n- `cmdkey \u002Flist | findstr nexus` returns nothing because the target name has no\n  `nexus` string. Use `cmdkey \u002Flist | findstr ModOrganizer2` instead.\n- HKCU registry entries such as `HideCreateInstanceIntro` are cosmetic flags,\n  not credentials.\n- `ModOrganizer.ini` `[Settings]` has no auth fields.\n- If `CredRead` returns null, Nexus auth is not set up in MO2 yet. Direct the\n  user to `Settings -> Nexus -> Connect to Nexus`.\n\nSee KB record `install-planning.mo2-windows-credential-mining.v1`.\n\n## Script Extender (xSE) update workflow — game-root drop, runtime-pinned\n\nUse this when Steam updates the game runtime and the existing xSE DLL no longer\nmatches it. The signal is a launch refusal through the xSE loader because the\nDLL runtime tag does not match the current `\u003Cgame>.exe` `FileVersion`.\n\nDetection:\n\n```powershell\n# Current xSE version (filename pattern)\nGet-ChildItem \"$gameRoot\\sfse_*.dll\" | Select Name  # e.g. sfse_1_15_222.dll = SFSE for runtime 1.15.222\n\n# Current Steam runtime\n(Get-Item \"$gameRoot\\Starfield.exe\").VersionInfo.FileVersion  # e.g. 1.16.244.0\n\n# If they do not match, update is needed.\n```\n\nLatest-version sources: silverlock.org points to Nexus mod `#106` for SFSE,\n`#100216` for SKSE64, and `#42147` for F4SE.\n\nUpdate workflow:\n\n1. Get the latest `file_id` from\n   `\u002Fv1\u002Fgames\u002F{game}\u002Fmods\u002F{xse_mod_id}\u002Ffiles.json`; use the file with\n   `category_name=MAIN`.\n2. Premium: call\n   `POST \u002Fv1\u002Fgames\u002F{game}\u002Fmods\u002F{xse_mod_id}\u002Ffiles\u002F{file_id}\u002Fdownload_link.json`.\n   The response is an array of seven CDN mirrors (Chicago, Amsterdam, Prague,\n   LA, Miami, Dallas, plus Nexus CDN). Pick the first URL.\n3. Free: open the Nexus page in a browser, click manual download, and save the\n   `.7z` to a known location.\n4. Extract the `.7z`. Gotcha: the archive expands to an `\u003Cxse>_\u003Cversion>\u002F`\n   subdirectory, such as `sfse_0_2_21\u002F`, not a flat folder. Glob-find files:\n   `Get-ChildItem -Recurse -Filter \"sfse_*.dll\" | Select-Object -First 1`.\n5. Backup current game-root xSE files to\n   `\u003CMO2_Root>\\.backups\\sfse-\u003Coldver>_pre-\u003Cnewver>-update_\u003Ctimestamp>\\`.\n6. Copy the new DLL, readme, and whatsnew files to the game root. Skip files\n   with unchanged sha256; the `\u003Cxse>_loader.exe` often does not change between\n   minor versions.\n7. Delete the old runtime DLL. This is optional but recommended for cleanliness;\n   the loader auto-picks by runtime match and does not need the old DLL.\n8. Verify sha256 for all four game-root files against staging.\n\n### After SFSE: the cascade is the principle\n\nA game runtime bump is a dependency cascade, not a single-file event. xSE is\nonly the first layer. Address Library and every runtime-bound DLL plugin also\nbind to runtime-specific addresses, so a correct maintenance pass follows the\nchain until the launch dialog stops reporting downstream leaks.\n\nRead the chain this way:\n\n1. **xSE binary** is the game-root layer and must match `\u003Cgame>.exe`.\n2. **Address Library** (Nexus mod #3256 for Starfield, #32444 for SkyrimSE,\n   #47327 for Fallout4) is a normal MO2 mod projected into\n   `Data\\SFSE\\Plugins\\`. It supplies `versionlib-\u003Cruntime>.bin` for the\n   current runtime.\n3. **SFSE\u002FSKSE\u002FF4SE plugin mods** each ship their own DLL and may need an\n   author-side rebuild.\n\nThe SFSE Plugin Loader dialog is the cascade readback surface:\n\n- `address library needs to be updated` means the plugin could not find the new\n  versionlib file; update Address Library first.\n- `incompatible with current version of the game` means the plugin DLL itself\n  is behind the game runtime; investigate whether the author has released a\n  compatible build.\n\nFor the actual update of each SFSE plugin mod, the mechanical pattern remains:\n- Premium API: `POST \u002Fv1\u002Fgames\u002F{game}\u002Fmods\u002F{id}\u002Ffiles\u002F{file_id}\u002Fdownload_link.json`\n- Extract to staging (remember the 7z subdirectory gotcha noted above)\n- Backup current MO2 mod folder contents\n- Replace files in mod folder\n- Update meta.ini's `version`, `newestVersion`, `installationFile`, `lastNexusUpdate`\n- If folder name encodes a version (for example `\u003Cmodname> - AddLib 18` or\n  `\u003Cmodname> - Game version 1.15.222`), rename folder and update `modlist.txt`\n  to match.\n\nIf Nexus reports `status=not_published` or `status=hidden`, treat it as a\ncontinuity investigation signal, not an instant disable verdict. Check whether\nthe same author republished or moved the release before proposing replacement.\n\n### Intent-aware mutation methodology\n\nA mod update is complete only when the observed post-state satisfies the intent\nthat motivated the update. Replacing files proves one effect; it does not prove\nruntime compatibility, curator-visible classification, metadata consistency, or\nenablement.\n\nAfter acting, ask: **did this satisfy the intent across all dependent MO2 state\ndimensions, or only the dimension I directly touched?** The dependent dimensions\nusually include:\n\n- files in the mod folder;\n- `meta.ini` version\u002Fsource\u002Fstatus fields and visible annotations;\n- folder name when it encodes version or runtime support;\n- `modlist.txt` line text after any rename;\n- separator ownership, especially for mods previously parked in\n  `版本已过期`, `等待作者更新`, or `[弃用]`;\n- enable flag when the original disable reason has been resolved;\n- for DLL plugins, the author's claimed runtime support versus the local game\n  runtime.\n\nThis is a ReAct-style observation rule at the level of intent, not a rote\nchecklist. If observation shows that only files changed while the mod remains in\na waiting separator, still disabled, or still behind the current runtime, report\nthe intent gap and propose the next reconciliation step before declaring done.\nDo not trust an action return value or a delegated fixer's summary as proof;\nread `modlist.txt`, read affected `meta.ini` files, and use launch readback when\nruntime compatibility is load-bearing.\n\nCross-link: KB record `install-planning.mod-update-post-state-discipline.v1` for the full discipline.\n\n### Placeholder dummy mod for xSE binary tracking (curator convention, optional)\n\nBB84's personal pattern: keep an empty MOD folder under `\u003CMO2Root>\u002Fmods\u002F\u003CXSE\nName> \u003Cruntime-tag>\u002F` (e.g. `Starfield Script Extender 1-15-222\u002F`) with a\nsingle `sfse_\u003Cbinary-ver>\u002F` empty subdir + a complete `meta.ini` carrying\nthe real `modid=106` + `version=` + `installationFile=` + nexus-side\nmetadata. Effect: the MO2 mod list visibly tracks the current SFSE binary\nversion even though the actual SFSE binaries live in game root and are\notherwise invisible to MO2's update-tracking. On each xSE update, rename\nboth the outer folder and the inner marker dir, and update the meta.ini.\nThis is a curator preference, not a required workflow.\n\n[WARNING]\nThis writes to the real game install, for example\n`D:\\SteamLibrary\\steamapps\\common\\\u003Cgame>\\`. It requires explicit per-session\nuser confirmation. xSE has no MO2 VFS overlay path: the loader must spawn\n`\u003Cgame>.exe`, so it has to live next to it.\n\nFor production-grade automation:\n\n```powershell\npwsh scripts\\install-xse-update.ps1 -GameRoot \u003Cpath> -XseMod sfse|skse|f4se|nvse\n```\n\nSee KB record `engine.xse-update-workflow.v1`.\n\n## xEdit binary upgrade workflow — sister of xSE upgrade, but tools-tree-local\n\nUse this when the user wants to verify or upgrade the xEdit installation\nwithout launching the MO2 GUI by hand. Sister flow to xSE upgrade but with\ndifferent mechanics: xEdit lives in `\u003CMO2_Root>\u002Ftools\u002FxEdit\u002F` (NOT game root,\nNOT under STOCK001 protection), and its runtime carries a versioned binary\ncache that must be invalidated on every binary swap or the daemon launches\nagainst a stale cache and either crashes or returns wrong data.\n\n### When to check\n\n- The user explicitly asks to verify \u002F upgrade xEdit.\n- A scheduled environment health pass is running.\n- The xEdit MCP daemon fails to launch, crashes mid-session, or returns\n  unexpected protocol errors against a load order that worked before.\n- New automation features are needed (multi-pattern filters, reverse\n  navigation, WRLD parent coords, etc. — anything past the contract version\n  the deployed binary supports).\n\n### Stale detection — SHA-256 hash comparison\n\n`Get-Item.VersionInfo.FileVersion` is unreliable for xEdit because the\ncontrib fork ships multiple builds under the same `4.1.5.0` \u002F `4.1.6` label.\nUse SHA-256 against the reference source:\n\n```powershell\n$mo2Bin     = \"$MO2_Root\\tools\\xEdit\\SF1Edit64.exe\"\n$refSource  = \"D:\\TES5Edit-contrib\\Build\\xEdit64.exe\"   # OR the path returned by fetch-xedit-release.ps1\n$mo2Hash    = (Get-FileHash -LiteralPath $mo2Bin -Algorithm SHA256).Hash\n$refHash    = (Get-FileHash -LiteralPath $refSource -Algorithm SHA256).Hash\nif ($mo2Hash -ne $refHash) {\n  Write-Warning \"xEdit stale: MO2 has $($mo2Hash.Substring(0,16))... reference has $($refHash.Substring(0,16))...\"\n}\n```\n\nAlso surface mtimes for human readability — a 10-day gap with non-matching\nhashes is a real version drift, not a build metadata glitch.\n\n`xEditHookBridge.dll` is retired and must not be hash-checked, copied, or\ndeployed. Native `xEdit.exe -automation-serve` is the supported path.\n\n### Reference source — contrib build vs release channel\n\nTwo reference sources exist:\n\n1. **Local dev build at `D:\\TES5Edit-contrib\\Build\\`** — the contrib fork's\n   continuously-rebuilt artifacts. Captures unreleased features (contract\n   0.18 → 0.19 → 0.20 additions, WRLD parent, reverse navigation, etc.) and\n   bug fixes. Use this when the user is developing against the latest\n   automation surface or needs features not yet in a tagged release.\n\n2. **GitHub release artifacts via `fetch-xedit-release.ps1`** — the\n   `BB-84C\u002FTES5Edit` tagged-release stream. Stable, reproducible, ships\n   with a manifest. Use this for end-user installs, reproducible modpack\n   build chains, or any scenario where the user is not the binary's author.\n\nFor BB84's developer workstation: contrib build is canonical because BB84\nauthors the contrib fork. For end-user installs: release channel is\ncanonical. The skill should ask which source the user wants when ambiguous.\n\n### Upgrade workflow\n\n```powershell\n$ts = Get-Date -Format 'yyyyMMdd-HHmmss'\n\n# 1. Backup current tools\u002FxEdit\u002F (full mirror, mtimes preserved)\nrobocopy \"$MO2_Root\\tools\\xEdit\" \"$MO2_Root\\tools\\xEdit.backup-$ts\" \u002FMIR \u002FNFL \u002FNDL \u002FNJH \u002FNJS\n\n# 2. Swap binaries (rename to game-specific filename so xEdit auto-detects mode)\nCopy-Item \"$refSource\\xEdit64.exe\" \"$MO2_Root\\tools\\xEdit\\SF1Edit64.exe\" -Force  # Starfield\nCopy-Item \"$refSource\\xEdit64.exe\" \"$MO2_Root\\tools\\xEdit\\xEdit64.exe\"   -Force\nCopy-Item \"$refSource\\xEdit.exe\"   \"$MO2_Root\\tools\\xEdit\\xEdit.exe\"     -Force\n\n# (For other games: FO4Edit64.exe, SSEEdit64.exe, etc. — the xEdit binary\n#  detects game mode from its filename when launched directly.)\n\n# 3. INVALIDATE CACHE — mandatory after any binary swap\n$cacheDir = \"$MO2_Root\\overwrite\\\u003CGame>Edit Cache\"  # e.g. SF1Edit Cache\nMove-Item -LiteralPath $cacheDir \"$MO2_Root\\overwrite\\\u003CGame>Edit Cache.stale-$ts\" -ErrorAction SilentlyContinue\n```\n\n### Cache lifecycle — REQUIRED reading before launch\n\nxEdit's binary cache lives at `\u003CMO2_Root>\u002Foverwrite\u002F\u003CGame>Edit Cache\u002F`\n(e.g. `SF1Edit Cache\u002F`, `FO4Edit Cache\u002F`, `SSEEdit Cache\u002F`). Files are\nnamed `\u003Cload-order-hash>_\u003Cplugin>_\u003Cplugin-hash>_g\u003Ccp>_t\u003Ccp>_l\u003Ccp>_\u003Clang>.refcache`.\n\n**The cache is binary-version-bound.** A binary upgrade invalidates every\ncache file because:\n\n- xEdit's internal record-parsing logic may have changed (new contract\n  features, fixes to malformed-data tolerance, etc.).\n- The cache format itself may have evolved.\n- Stale caches produce subtle wrong-answer bugs that look like xEdit\n  protocol errors but are actually parser drift.\n\nALWAYS move the cache dir aside (don't delete — it's the safety net) before\nthe first launch after a binary swap. Pattern:\n`overwrite\u002F\u003CGame>Edit Cache.stale-\u003Ctimestamp>\u002F`.\n\nThe cache will be rebuilt automatically on first launch. Once stable and\nverified, the `.stale-*` backup can be removed in a future cleanup pass.\n\n### First-launch timing (cold cache)\n\nCache-cold launch on a 175-plugin Starfield profile takes **9-10 minutes**.\nThis is real-time wall clock for xEdit to:\n\n1. Parse every plugin in the load order.\n2. Hash each plugin's records.\n3. Write the per-plugin `.refcache` file.\n\nThe current xedit-mcp `xedit-client.ps1` has a **240-second timeout** for\ndaemon readiness. **First-launch on a real-world load order will exceed\nthis timeout and fail.**\n\nWorkaround options:\n\n1. **Build cache via manual GUI launch first** (preferred for current\n   tooling): run xEdit through MO2's normal launch path (either via\n   `Mo2Mo2RunTool_tool` with the configured customExecutable, or have the\n   user click the MO2 button). Wait until xEdit's window finishes loading\n   (status bar shows \"Background Loader: finished\" or similar). Close\n   xEdit. Then `xedit_start` will launch in \u003C3 min wall-clock against the\n   warm cache.\n2. **Bump the timeout in xedit-client.ps1** if scripting around step 1 is\n   undesirable. The relevant constant is documented in the xedit-mcp\n   broker source.\n\n### Polling discipline during cold-cache launch\n\n`xedit_status({})` sends a lightweight read against the daemon's state file,\nbut the daemon's response handler is on the same Pascal thread that's\nparsing the load order. **Aggressive polling during the cold-cache build\ncan stall or crash xEdit's parser.** Empirically observed on a 175-plugin\nStarfield profile on 2026-06-27: 30-second poll cadence during cold-cache\nbuild correlated with a parse hang requiring manual kill.\n\nPolling discipline:\n\n- During cold-cache build (first launch after binary swap): wait at least\n  60 seconds between polls. Better: don't poll at all until 8+ minutes have\n  elapsed, then check once.\n- During cache-warm launch (subsequent launches): 30-60 second poll cadence\n  is fine. Total launch time ~3 minutes.\n- After `status: \"ready\"`: domain tools (`xedit_session`, `xedit_health`,\n  `xedit_call`) can be called freely.\n\n### Verification after launch\n\n```text\nxedit_health({})       -> { responsive: true, pingEnvelope: { ok: true } }\nxedit_session({})      -> { gameMode: \"Starfield\", contractVersion: \"0.20\",\n                            loadOrderSize: N, consentEnabled: false (read-only)\n                                                or true (mutations allowed) }\nxedit_dirty({})        -> { dirty: false, unsavedChangeCount: 0 }\n```\n\nCheck `contractVersion` against the contract level the new binary should\nhave shipped. If contractVersion is lower than expected, the binary didn't\nswap correctly OR the daemon picked up the wrong binary path.\n\n### Clean shutdown — cache preserved\n\n`xedit_stop({})` on a clean dirty state preserves the cache for the next\nlaunch. Subsequent `xedit_start({})` will hit the warm cache and complete\nin ~3 minutes. Do not delete the cache dir between sessions unless a\nbinary upgrade is happening.\n\n### See also\n\n- KB record `engine.xedit-binary-cache-lifecycle.v1` for the full\n  binary-cache binding mechanism.\n- KB record `engine.xedit-stale-detection-via-hash.v1` for the SHA-256\n  comparison method against reference sources.\n- KB record `tooling.xedit-contrib-build-vs-release-channel.v1` for the\n  source-selection strategy.\n- KB record `debugging.xedit-cold-cache-launch-timeout-and-polling.v1`\n  for the 240s timeout + polling-discipline gotchas.\n\n## meta.ini `comments=` vs `notes=` as visibility design\n\nMO2 has two note-shaped fields because it has two different reading modes:\nvisibility-at-a-glance and detail-on-demand.\n\n- **`comments=`** serves the at-a-glance mode. It appears in the mod-list\n  Comments column, so it is the right place for short summaries, status tags\n  (`[UPDATE→vX]`, `[WAITING-FOR-X.Y.Z]`), CC markers (`[CC]`, `[CC·汉化版]`),\n  and other information the curator should see without opening a dialog.\n- **`notes=`** serves the detail-on-demand mode. It appears only in the mod's\n  properties Notes tab, so it is the right place for install procedure memos,\n  FOMOD choice records, conflict-resolution notes, and verbose version history.\n\nChoose the field by intended reader behavior. If the curator must see the fact\nwhile scanning the list, use `comments=`. If the fact is reference material for\nwhen the mod is already being inspected, use `notes=`. Automation that\nsynthesizes 1-2 sentence per-mod summaries from `nexusDescription` therefore\nwrites to `comments=` by default; putting those summaries in `notes=` makes the\nlist look empty even though the information exists.\n\n## Post-patch loose-extract hygiene (game-install Data\\ stale CK extracts)\n\nAfter every BGS game patch, a standard maintenance pass should sweep the\ngame-install `Data\\` tree for stale Creation Kit loose extracts. The full\nmethodology lives in KB record\n`archive-precedence.stale-ck-extract-loose-files.v1`; the operational shape\nfor a maintenance pass is short:\n\nThe trap. When the curator installs the Creation Kit alongside the game, the\nCK auto-extracts authoring-time loose files from `Tools\\ContentResources.zip`\ninto `Data\\` — `Data\\Materials\\` (`.mat`), `Data\\Particles\\` (`.psfx`),\n`Data\\Scripts\\Source\\` (`.psc`), plus editor metadata. Archive invalidation,\nwhich any modded curator has enabled, makes those loose files override the\ncompiled BA2 databases at runtime. While the game version matches the CK\nextract version this is invisible; the moment the game patches its compiled\nmaterial database, particle archive, or compiled scripts, the loose files\nbecome stale references against the new BA2 and the runtime breaks silently\n(purple\u002Firidescent terrain, missing meshes, wrong VFX, subtle Papyrus drift).\n\nThe cheap diagnostic test. Before bisecting mods on any post-patch visual or\nbehavioral regression:\n\n```powershell\n# Inspect the game-install Data\\ for stale CK extracts.\n$gd = \"\u003Cgame-install>\\Data\"\nGet-ChildItem -LiteralPath $gd -Directory |\n  Where-Object { $_.Name -in @('Materials','Particles','Scripts','Source','Textures','EditorFiles','DataViews') } |\n  ForEach-Object {\n    $files = Get-ChildItem -LiteralPath $_.FullName -Recurse -File -ErrorAction SilentlyContinue\n    $oldest = ($files | Sort-Object LastWriteTime | Select-Object -First 1).LastWriteTime\n    \"{0,-14}  files: {1,5}  oldest: {2}\" -f $_.Name, $files.Count, $oldest\n  }\n```\n\nCompare oldest mtime to the current patch's BA2 mtime. If older, the extract\nis stale. If `Tools\\ContentResources.zip` modification time matches the\ncurrent patch, the recovery path is intact — deletion is fully reversible.\n\nThe fix. Delete the stale extract trees from `Data\\`. Runtime falls back to\nBA2. For Starfield specifically the priority order is `Data\\Materials\\` →\n`Data\\Particles\\` → `Data\\Textures\\` → `Data\\Scripts\\` (runtime impact),\nthen `Data\\Source\\`, `Data\\DataViews\\`, `Data\\EditorFiles\\` (CK-editor-only,\nharmless to keep, harmless to delete).\n\n[WARNING]\nThis writes to the real game install, for example\n`D:\\SteamLibrary\\steamapps\\common\\\u003Cgame>\\Data\\`. It requires explicit\nper-session user confirmation. The action is reversible by re-extracting\n`Tools\\ContentResources.zip` into `Data\\`, but the deletion itself is\ndestructive against the loose extracts that are currently there.\n\nA cleaner long-term pattern: extract `ContentResources.zip` into a dedicated\nMod Organizer 2 mod folder (e.g. `mods\u002FCK Resources Vanilla\u002F`) so the CK\nloose files can be toggled per-profile and never touch the real game install.\n\nCross-link: KB record `archive-precedence.stale-ck-extract-loose-files.v1`\nfor the full mechanism. KB record\n`debugging.asymmetric-evidence-self-falsify.v1` for the diagnostic\ndiscipline that prevents the trap from misleading bisection planning.\n\n## meta.ini comment vs note field hygiene (HARD RULE)\n\nEvery time an agent touches a mod folder's `meta.ini`, two text fields exist\nand they have STRICTLY DIFFERENT purposes. Putting content in the wrong field\nbreaks the curator's mental model of their own modpack.\n\n**`comments=` = SHORT description of WHAT THE MOD DOES (the mod's CONTENT)**\n\n- 1-2 sentences max\n- Language: match the curator (Chinese for BB84-style packs, English otherwise)\n- Shown in MO2 GUI mod-list \"Comments\" column (visible at a glance without clicking)\n- Describes the mod's GAMEPLAY\u002FVISUAL\u002FSYSTEM effect, not its install metadata\n\nExample (good): `调整起降过场镜头比例,提供更沉浸的驾驶舱视角与速度选项。`\n\n**`notes=` = TIME-SENSITIVE markers + operational memory (the mod's STATUS)**\n\n- Update history with datestamp + version diff + file_id\n- Archive \u002F obsolescence \u002F version-tag-unsync \u002F user-install \u002F local-patch markers\n- FOMOD choice records, conflict resolution memos, investigation findings\n- Shown in Notes tab (hidden until clicked)\n- MOST text per mod ends up here\n\nMarker prefixes that ALWAYS belong in `notes=`, NEVER in `comments=`:\n\n```\n[UPDATED YYYY-MM-DD] x.y.z -> a.b.c | file_id N [MAJOR|MINOR|PATCH]\n[ARCHIVED YYYY-MM-DD] reason\n[OBSOLETE YYYY-MM-DD] reason\n[FIXED YYYY-MM-DD] reason\n[USER-INSTALLED YYYY-MM-DD] FOMOD picks \u002F manual install footprint\n[NEW-INSTALL YYYY-MM-DD] reactivation cluster context\n[STALE YYYY-MM-DD] SC translation lags \u002F lifecycle drift\n[LOCAL-PATCH] curator's local fixup\n[VERSION-TAG-UNSYNC] page-version-vs-file-version mismatch\n[INVESTIGATION YYYY-MM-DD] analysis findings + anti-stale-fact note\n[UPDATE→x.y.z] BB84's pre-existing update-pending arrow flag (marker is JUST the bracket; description after it belongs in `comments=`)\n```\n\n**bash extract-on-top update path MUST preserve existing `comments=`**:\n\nWhen updating a mod's content (e.g. v1.3.1 → v1.3.2 via extract-on-top),\nthe helper MUST NOT overwrite `comments=`. Instead, APPEND the update marker\nto `notes=` (preserving any pre-existing notes with `\\n` separator).\n\nAnti-pattern that destroyed BB84's curator descriptions on 2026-06-25:\n\n```powershell\n# WRONG — overwrites comments, destroys description\n$content = [Regex]::Replace($content, '(?m)^comments\\s*=.*$', \"comments=[UPDATED ...] $versionDiff\")\n```\n\nCorrect pattern:\n\n```powershell\n# RIGHT — preserve comments, append marker to notes (Qt INI literal \\n)\n$newMarker = \"[UPDATED $date] $oldVersion -> $newVersion | file_id $fileId\"\n$content = [Regex]::Replace($content, '(?m)^notes[\\t ]*=[\\t ]*(.*)$', { param($m) \n  $existing = $m.Groups[1].Value\n  if ([string]::IsNullOrWhiteSpace($existing)) { \"notes=$newMarker\" }\n  else { \"notes=$newMarker\\n$existing\" }  # \\n is literal backslash-n; Qt INI renders as newline\n})\n```\n\n**Regex bug to avoid**: do NOT use `\\s*` in INI line anchoring — it consumes\n`\\r\\n` and captures content from the next line. Use `[\\t ]*` for in-line\nwhitespace only:\n\n```powershell\n# WRONG — \\s* crosses lines, leaks neighbour key's value into your match\n$cmtM = [Regex]::Match($content, '(?m)^comments\\s*=\\s*(.*)$')\n\n# RIGHT — [\\t ]* stays on one line\n$cmtM = [Regex]::Match($content, '(?m)^comments[\\t ]*=[\\t ]*(.*)$')\n```\n\n**Before any batch meta.ini migration**, write a 3-case unit-test fixture:\n\n1. Pure marker only (`[ARCHIVED 2026-06-25] reason`) → expect comments empty, marker stays in notes\n2. BB84 arrow style (`[UPDATE→2.0.0.0] 中文描述`) → expect comments has Chinese, notes has `[UPDATE→2.0.0.0]`\n3. Mixed (description text first, then marker) → expect comments has description, notes has marker\n\nThen dry-run on 3-5 sample mods spanning all three cases BEFORE batch dispatch.\nSkipping this check is what destroyed 49 mods' Chinese descriptions in the\n2026-06-25 buggy migration. See `.opencode\u002Fmemory\u002F45-mo2-mcp-internals.md`\nrule 18 for the full incident postmortem.\n\n### Qt QSettings INI quoting (silent display-empty trap)\n\nMO2's backend uses Qt QSettings to parse meta.ini. Qt's INI parser conflates\na value that STARTS with `[` (e.g. `[UPDATED ...]`, `[CC]`, `[UPDATE→x.y.z]`)\nwith a section-header start (`[Section]`) and silently returns empty for that\nkey. MO2 GUI's Notes\u002FComments tab then shows blank, even though a raw text\npreview of the same meta.ini clearly displays the value populated.\n\n**Hard rule**: whenever a `comments=` or `notes=` value starts with `[`,\nwrap the value in double quotes:\n\n```\n# BROKEN — Qt parses as empty, MO2 GUI shows blank\nnotes=[UPDATED 2026-06-25] 1.1.5.0 -> 1.2.77.0 [MAJOR] | file_id 61879\ncomments=[CC] Watchtower: Orbital.Strike\\Fleet.Command\n\n# CORRECT — Qt strips outer quotes, returns bracketed content; MO2 GUI displays correctly\nnotes=\"[UPDATED 2026-06-25] 1.1.5.0 -> 1.2.77.0 [MAJOR] | file_id 61879\"\ncomments=\"[CC] Watchtower: Orbital.Strike\\Fleet.Command\"\n```\n\nImplementation rules:\n1. **WRITE path**: before serializing a `comments=` \u002F `notes=` line, check if\n   the value's first non-whitespace char is `[`. If yes, emit double quotes\n   around the value. If the value contains internal `\"`, escape them as `\\\"`.\n   Internal `\\n` (literal backslash-n) IS preserved by Qt as a multi-line\n   escape inside quoted strings and renders as a newline in MO2 GUI.\n2. **READ path**: after reading a `comments=` \u002F `notes=` line, strip a single\n   leading and trailing `\"` pair (if present) BEFORE parsing the value\n   semantically. Unescape internal `\\\"` to `\"`.\n3. **Idempotence**: re-running the quoting step on an already-quoted value\n   should be a no-op (`if ($val -match '^\".*\"$') { skip }`).\n4. **Special cases**: values already starting with `@ByteArray(...)`,\n   `\u003CHTML>`, or other Qt-supported wrapper forms are left untouched — they\n   have their own parsing path.\n\nReproduction: 2026-06-26 Xeno Master screenshot pair (BB84). 268-char notes\nvalue with `[UPDATED ...]` start displayed empty in MO2 GUI. Adding double\nquotes around the value fixed display immediately on MO2 refresh (no\nrestart). Sweep across BB84 Starfield modpack found 220 affected meta.ini\nfiles; backups preserved at\n`D:\\Starfield MO2\\.backups\\meta-qt-quote-fix-20260626-003856\\`.\n\nCross-link: KB record `engine.qt-ini-bracket-quote-requirement.v1` (TBD)\nshould codify this for end-users authoring their own meta.ini writers.\n\nCross-link: KB record `install-planning.mod-mutation-cleanliness-discipline.v1`\ncovers the broader 7-discipline mutation hygiene checklist that this hygiene\nrule plugs into.\n\n## See also\n\n- `setting-up-bgs-modding-environment` — first-run MO2 \u002F xEdit \u002F KB acquisition orchestrator.\n- `using-bgs-modding-superpowers` — session bootstrap, available tools, and hard BGS modding rules.\n- `docs\u002Finternal\u002Froadmap.md` — KB track status and phase closeouts.\n- Deep reference: `docs\u002Finternal\u002Fsuperpowers\u002Fspecs\u002F2026-06-02-agentic-cross-game-kb-design.md`.\n","# Maintaining Modding Environments\n\n## When to use\n\n- The environment is already set up and the user asks to maintain, refresh, update, or health-check it.\n- The user says \"register custom pack\", \"install my KB pack\", \"set `BGS_KB_USER_PACKS`\", or asks how to author a local KB pack.\n- The user asks how to maintain a mod knowledge base, a translator glossary KB, or a third-party localization KB for Skyrim\u002FFallout\u002FStarfield.\n- The user asks to install, upgrade, repair, or verify the standalone\n  `xtl`\u002F`bgs-translator` CLI after first-run.\n- The user asks to check or apply knowledge-base updates after first-run.\n- The user asks to prune the KB cache or clean old pack versions.\n- The user asks whether to pin a KB pack version, follow latest, or handle a `minPluginVersion` warning.\n\n## What this skill replaces\n\nUse `setting-up-bgs-modding-environment` for first-run: MO2 detection, control-plane install, visible MO2 launch, first xEdit acquisition, first KB pack acquisition, and first semantic smoke.\n\nThis skill owns ongoing care after that first-run boundary: KB updates, cache hygiene, custom-pack authoring and registration, translator CLI maintenance, recurring environment health checks, and version-pinning advice.\n\n## Translator CLI maintenance\n\n`xtl` is the standalone AI translation CLI\u002FWeb GUI launcher. It is published on\nPyPI as `bgs-translator`; the portable plugin may include translator-facing\nskills, but a fresh user machine still needs the Python package installed before\nhigh-speed agents can call `xtl`.\n\nStart every maintenance pass with an explicit readback:\n\n```powershell\n# Check whether xtl is installed and can report its version\u002Fcapabilities.\nxtl version\n\n# Inspect top-level commands before choosing a workflow.\nxtl --help\n```\n\nIf `xtl` is missing or too old, prefer an isolated user-level CLI install:\n\n```powershell\n# Install the current release-candidate build as an isolated command-line tool.\npipx install bgs-translator==0.9.0rc1\n\n# Upgrade an existing pipx-managed xtl install when a newer stable build exists.\npipx upgrade bgs-translator\n```\n\nIf `pipx` is unavailable, or the user explicitly wants `xtl` inside a project\nvirtual environment, use Python's package installer from that environment:\n\n```powershell\n# Install or upgrade xtl inside the selected Python environment.\npy -3.12 -m pip install --upgrade bgs-translator==0.9.0rc1\n```\n\nFor a future stable release, use the unpinned package name for normal installs:\n`pipx install bgs-translator`, `pipx upgrade bgs-translator`, or\n`py -3.12 -m pip install --upgrade bgs-translator`. Do **not** use broad\n`--pre` during routine maintenance; it can allow prerelease dependency versions\nthat were not part of the tested translator build. Pin an exact prerelease only\nwhen the user intentionally wants that version.\n\nAfter any install or upgrade, inspect subcommand help instead of assuming\nspecific option values:\n\n```powershell\n# Verify provider-profile setup options, including all supported SDK kinds.\nxtl profile add --help\n\n# Verify web GUI launch options and ports.\nxtl gui --help\n\n# Verify batch controls before telling an agent to submit or resume work.\nxtl batch --help\n```\n\nIf a GUI or background translator service gets into an inconsistent state,\nrestart it with the repo's reusable helper instead of inventing process-kill\nsteps:\n\n```powershell\n# Restart the translator GUI\u002Fservice stack using the project helper.\npwsh tools\\bgs-translator\\scripts\\restart-web-gui.ps1 -Port 7847\n```\n\nIf that helper is absent in an older checkout, fall back to the current\n`using-bgs-translator` instructions for launching `xtl gui`, then file a note in\nthe environment maintenance log that the helper should be added or backported.\n\n## Check + apply KB updates\n\n1. Start with `bgs_kb_status({})` to see loaded packs, versions, cache root, user roots, and warnings.\n2. If `bgs_kb_check_updates` exists, call it for the installed pack IDs. Surface available updates, `breakingChange`, and release URLs before taking action.\n3. If `bgs_kb_check_updates` is not present yet (pre-KB-6), check GitHub Releases for `bgs-modding-superpowers` KB pack artifacts and `manifest-index.json`. Do not invent release names.\n4. Before installing or replacing a pack, get user consent for the download \u002F cache mutation.\n5. If `bgs_kb_install_pack` exists, use it with an exact `{ packId, version }`. Prefer `dryRun: true` before live install when the tool supports it.\n6. If the install tool is not present yet, download the Release asset manually only after consent, verify the published sha256, extract into the cache layout below, then restart or reconnect the MCP so discovery runs again.\n7. After any update, run the health checks below.\n\n## Cache hygiene\n\nCache root (all platforms — unified with `xtl` \u002F `bgs-translator`):\n\n```text\n~\u002F.bgs-modding-superpowers\u002Fkb\u002Fpacks\u002F\u003CpackId>\u002F\u003Cversion>\u002F\n```\n\nThe legacy Windows-only cache at `%LOCALAPPDATA%\u002Fbgs-modding-superpowers\u002Fkb\u002Fpacks\u002F`\nis **no longer used**. If `bgs_kb_status` surfaces packs that are not visible to\n`xtl batch plan`, suspect a legacy cache and either:\n\n- move the directory tree from `%LOCALAPPDATA%\u002Fbgs-modding-superpowers\u002Fkb\u002F` to\n  `~\u002F.bgs-modding-superpowers\u002Fkb\u002F`, or\n- export the legacy root via `$env:BGS_KB_USER_PACKS` so the MCP keeps reading\n  it as an additional read-only root while the user finishes migrating.\n\nEach version directory contains `manifest.json`, `records\u002F`, and `kb.sqlite`. Current policy: retain the current version and the immediately previous version as rollback\u002Ffallback. Prune versions older than that only after confirming the pack is not pinned by the user or referenced by a current modpack workflow.\n\nUse the KB MCP CLI for routine pruning:\n\n```powershell\n# Preview which cached pack versions would be removed.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js prune-cache --dry-run\n\n# Apply the prune after the user accepts the preview.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js prune-cache\n```\n\nThe dry run should be surfaced before deletion when the user has not already approved cache mutation. The command keeps the highest version and the immediately previous version per pack, then removes older cached versions.\n\nDo not delete `incoming\u002F` while an install is running. If an install failed earlier and no installer is active, stale `incoming\u002F` contents can be removed after surfacing the path to the user.\n\n## Custom pack authoring + registration\n\nAuthor records as:\n\n```text\n\u003Cpack-root>\u002Frecords\u002F\u003Cdomain>\u002F\u003Cid>.md\n```\n\nRecord frontmatter uses the same schema as official packs under `knowledge\u002Fbgs-kb\u002Fschema\u002Frecord.schema.json`: stable `id`, `title`, `domains`, `appliesTo`, `canonical`, `sources`, `lastReviewed`, and `schemaVersion` are the important fields to check first.\n\nEvery pack needs a `bgs-kb-meta.yml` at the pack root. Minimum fields:\n\n```yaml\npackId: user-my-pack\ndisplayName: My Modpack Knowledge\nversion: 2026.06.02\nschemaVersion: 1\nminPluginVersion: 0.2.0\n```\n\nReserved official pack IDs: `bgs-kb-core`, `bgs-kb-skyrim`, `bgs-kb-fallout4`, `bgs-kb-fallout3-fnv`, `bgs-kb-starfield`. End-user packs must not use the `bgs-kb-*` namespace; recommend a `user-*` prefix.\n\nBuild the pack:\n\n```powershell\n# Build kb.sqlite and manifest.json from the pack's records\u002F tree.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js build \u003Cpack-root>\n```\n\nThis produces `kb.sqlite` and `manifest.json` next to `records\u002F`.\n\nValidate and inspect:\n\n```powershell\n# Validate every Markdown record against the official KB schema.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js validate \u003Cpack-root>\n\n# Inspect pack metadata, counts, games, and domains.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js info \u003Cpack-root>\n```\n\nImportant `BGS_KB_USER_PACKS` semantics: each entry is a directory that contains one or more pack directories, not a pack directory itself. Multiple roots are separated by `;` on Windows.\n\nWorked example:\n\n```text\nC:\\my-kb-roots\\\n  my-custom-pack\\\n    bgs-kb-meta.yml\n    manifest.json\n    kb.sqlite\n    records\\\n      load-order\\\n        my-local-rule.v1.md\n```\n\nSet:\n\n```powershell\n# Point discovery at the directory that contains one or more pack folders.\n$env:BGS_KB_USER_PACKS = \"C:\\my-kb-roots\"\n```\n\nDo not set it to `C:\\my-kb-roots\\my-custom-pack`; that points at the pack itself and discovery will look one level too deep.\n\nAfter registration, restart\u002Freconnect the MCP so pack discovery runs, then call `bgs_kb_status({})` and verify the custom pack appears with the intended `packId`.\n\n## Pack discovery + collision recovery\n\n`bgs_kb_status({})` may report two warning codes when discovery sees the same `packId` at multiple roots:\n\n| Code | Meaning |\n|---|---|\n| `pack_id_overridden` (MEDIUM, informational) | Multiple sources for the same `packId`; precedence picked a winner automatically and listed the loser(s). All packs still load. |\n| `pack_id_collision` (HIGH, fail-closed fallback) | Precedence could not choose a winner — should be rare; all colliding copies are refused. |\n\n**Discovery precedence (apply in order):**\n1. Sort candidates with the same `packId` by `builtAt` timestamp DESC — newest manifest wins.\n2. Tie-break by root class: `bundled > cache > user`.\n\n**Common cause: `install-pack` over an already-bundled `packId`.** Plugin distributions ship per-game packs (e.g. `bgs-kb-fallout4`) in the bundled tree. If a user runs `bgs_kb_install_pack({ packId: \"bgs-kb-fallout4\", ... })` to fetch a Release-channel update, the new version lands in the cache root `~\u002F.bgs-modding-superpowers\u002Fkb\u002Fpacks\u002Fbgs-kb-fallout4\u002F\u003Cversion>\u002F`. On the next MCP restart:\n\n- If the cache copy has a newer `builtAt` (the normal update case) → cache wins, bundled loser warning. No action needed.\n- If the bundled copy is somehow newer (e.g. you pulled a plugin update that shipped a newer KB) → bundled wins, cache becomes the loser. To make the cache copy authoritative, install a newer Release or remove the stale cache copy.\n\n**Other causes:**\n\n- Two `$BGS_KB_USER_PACKS` parent directories contain pack folders with the same `packId` → warning per loser.\n- Manual file copy of a pack between roots without removing the original.\n\n**Preview before restarting MCP:** the bgs-kb-mcp CLI exposes a read-only `dev-status` subcommand that shows the same discovery decision the MCP would make, without requiring a server restart:\n\n```powershell\n# Preview every discovered packId, every candidate source, and which one would win.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js dev-status\n\n# Filter to one pack id (useful before install-pack or before editing user packs).\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js dev-status --pack bgs-kb-fallout4\n\n# Machine-readable output for scripting.\nnode \u003Cplugin>\\tools\\bgs-kb-mcp\\dist\\cli.js dev-status --json\n```\n\n**Recovery patterns:**\n\n- **Want the cache copy to win**: ensure its `builtAt` is newer than the bundled copy's (run `bgs_kb_install_pack` for a fresh Release version), restart MCP, verify.\n- **Want the bundled copy to win**: remove or rename the cache pack directory, restart MCP.\n- **Two user roots collide**: drop one parent from `$BGS_KB_USER_PACKS`, or rename the colliding pack folder to a unique `packId` (after also updating its `bgs-kb-meta.yml`), restart MCP.\n- **Pre-flight before authoring or installing**: always run `dev-status --pack \u003CpackId>` first — it surfaces collisions before the next MCP restart turns them into status warnings.\n\nDo not delete cache copies aggressively as a first-line fix; the precedence rule selects automatically, so warnings are usually informational, not blocking.\n\n## Localization and translator KBs\n\nLocalization glossary packs are KB packs whose SQLite store includes\n`glossary_entries` and `glossary_aliases`. They feed `bgs-translator` RAG so an\nLLM receives canonical terms such as places, factions, item names, UI concepts,\nand do-not-translate entries. Put this guidance here, not in\n`using-bgs-translator`, because the same maintenance rules apply to official,\nmod-specific, and third-party glossary packs.\n\nOfficial bundled policy:\n\n- `bgs-l10n-starfield-zhhans` is the only official zh-Hans glossary pack we\n  ship from vanilla game data because Starfield is the only supported BGS game\n  with official Simplified Chinese localization.\n- Do not fabricate official Skyrim\u002FFallout4 Chinese packs. If the user wants\n  them, create third-party\u002Fuser packs with explicit source, license, scope, and\n  review notes.\n- The Starfield official pack is large and should be distributed through KB\n  Release artifacts, not copied into the portable plugin tree.\n\nFor a mod-specific translator KB, prefer a user namespace such as\n`user-l10n-\u003Cgame>-\u003Cmod>-zhcn`. Include only the mod's accepted terminology,\ncharacter\u002Fplace names, recurring UI labels, and do-not-translate terms. Do not\ndump every translated sentence into a term KB unless the user explicitly wants a\ntranslation-memory style pack and accepts the recall\u002Fnoise tradeoff.\n\nFor a third-party game localization KB, require:\n\n- source language, target language, game, source project\u002Fversion, and license;\n- provenance in `bgs-kb-meta.yml` and in generated notes;\n- a stable pack id outside reserved `bgs-kb-*` official namespaces;\n- a small sample query after registration to verify the pack is discoverable.\n\nIf the input is an xTranslator SST dictionary, the translator tool has a\none-shot builder that creates the glossary SQLite shape directly:\n\n```powershell\n# Build a user-maintained glossary pack from an SST dictionary.\npy -3.12 tools\\bgs-translator\\bgs_translator\\tools\\xtranslator_sst_to_kb_pack.py `\n  --input \"D:\\path\\to\\source_english_chinese.sst\" `\n  --output-dir \"C:\\my-kb-roots\\user-l10n-skyrim-thirdparty-zhcn\" `\n  --pack-id user-l10n-skyrim-thirdparty-zhcn `\n  --display-name \"User Skyrim zh-CN Localization Glossary\" `\n  --game SkyrimSE `\n  --source-lang en `\n  --target-lang zh-cn\n```\n\nThen set `BGS_KB_USER_PACKS` to the parent root, restart\u002Freconnect the MCP, and\nquery a known term. For translator-only packs, use `xtl`\u002Ftranslator glossary\nsmokes as the stronger check because `bgs_kb_query` only searches Markdown-style\nrecords unless the MCP has been upgraded for glossary-table queries.\n\n## Official KB release maintenance\n\nFor project maintainers cutting a KB Release, use the release staging script:\n\n```powershell\n# Rebuild source-record packs, verify prebuilt glossary packs, zip all packs,\n# and write dist\u002Fkb-release\u002Fmanifest-index.json.\npwsh scripts\u002Fbuild-kb-release.ps1 -Force\n```\n\nThe script includes the generated Starfield zh-Hans glossary pack in the release\nindex but does not rebuild it from Markdown records. If `kb.sqlite` hash\nverification fails, regenerate that pack from its approved source SST before\npublishing. The script prints the exact `gh release create ...` command; review\nthe staged `manifest-index.json` before running that network-side publish.\n\n## Version-pinning advice\n\nFollow latest when the user wants current general guidance and accepts normal KB refresh cadence.\n\nPin a specific pack version when a modpack release, guide, benchmark, or reproducibility note depends on exact advice staying stable. Record the pin in the modpack dev-log or release docs.\n\nIf a new pack's `minPluginVersion` exceeds the installed plugin version, warn and stop. Do not auto-upgrade the plugin. Offer choices: update the plugin with user consent, keep the older pack version, or pin the previous version until the plugin can be upgraded.\n\nKB cadence is independent of plugin cadence. A new KB pack can be consumed when `schemaVersion` and `minPluginVersion` are compatible; it does not automatically imply an xEdit or MO2 change.\n\n## Health checks\n\nQuick KB smoke after maintenance:\n\n```text\nbgs_kb_status({})\nbgs_kb_query({ query: \"plugins\", maxResults: 3 })\n```\n\nExpected: at least one loaded pack, no unexpected collision \u002F integrity warnings, and at least one query hit. If the target game is known, include the game filter, for example:\n\n```text\nbgs_kb_query({ query: \"plugins\", games: [\"Fallout4\"], maxResults: 3 })\n```\n\nFor custom packs, query a term from one of the custom records and verify hits are tagged with the custom `packId`.\n\nIf maintenance touched MO2 or xEdit runtime state, also use the appropriate setup \u002F xEdit skill checks. Do not treat KB health as proof of live load-order or plugin state.\n\n## Anti-patterns + warnings\n\n- Never write directly into Stock Game \u002F vanilla game `Data`. Any game-local change goes through an MO2 mod overlay or overwrite surface.\n- KB records are advisory. xEdit MCP readback remains authoritative for actual plugin, record, conflict, and load-order state.\n- Do not use `BGS_KB_USER_PACKS` to point at a single pack directory; point it at a root containing pack directories.\n- Do not use reserved `bgs-kb-*` pack IDs for local packs.\n- Do not install or upgrade KB packs with a `minPluginVersion` the current plugin does not satisfy.\n- Do not delete all old cache versions; keep current + previous unless the user explicitly chooses otherwise.\n\n## Refreshing Nexus update state without opening MO2 (Option B)\n\nUse this when the user wants fresh `newestVersion`, `nexusFileStatus`,\n`lastNexusQuery`, and `lastNexusUpdate` metadata without opening MO2 and running\n`Tools -> Check All for Updates`.\n\nWhy this exists: mobase's Python API does not expose the GUI update-check\ntrigger, and three of the four timestamp fields are not on the abstract\n`IModInterface`. See KB record\n`install-planning.nexus-direct-api-update-check.v1`. The direct Nexus API read\npath works for both Free and Premium accounts; these read endpoints are not\nPremium-gated.\n\nPrerequisite: the user must already have Nexus auth configured in MO2. That same\nMO2 credential store is the API-key source for the agent; see the next section.\n\nEndpoints used:\n\n```text\nGET https:\u002F\u002Fapi.nexusmods.com\u002Fv1\u002Fgames\u002F{game_domain}\u002Fmods\u002Fupdated.json?period=1m\nGET https:\u002F\u002Fapi.nexusmods.com\u002Fv1\u002Fgames\u002F{game_domain}\u002Fmods\u002F{id}.json\n```\n\nThe first endpoint is one bulk call to discover recently updated mods. The\nsecond endpoint is one per-mod call for fresh metadata. Nexus' rate budget is\n20,000 calls\u002Fday; a full 300-mod refresh is about 301 calls and is comfortable.\n\nPer-mod `meta.ini` update shape:\n\n```powershell\n$statusMap = @{ \"published\"=1; \"hidden\"=9; \"removed\"=6; \"wastebinned\"=6; \"under_moderation\"=9 }\n$mod = Invoke-RestMethod -Uri \"https:\u002F\u002Fapi.nexusmods.com\u002Fv1\u002Fgames\u002Fstarfield\u002Fmods\u002F$modid.json\" -Headers $headers\n$statusInt = if ($statusMap.ContainsKey($mod.status)) { $statusMap[$mod.status] } else { 1 }\n$nowIso = (Get-Date).ToUniversalTime().ToString(\"yyyy-MM-ddTHH:mm:ssZ\")\n$updatedIso = [DateTimeOffset]::FromUnixTimeSeconds($mod.updated_timestamp).ToString(\"yyyy-MM-ddTHH:mm:ssZ\")\n$content = [IO.File]::ReadAllText($metaPath, [Text.UTF8Encoding]::new($false))\n$content = $content -replace '(?m)^newestVersion=.*$', \"newestVersion=$($mod.version)\"\n$content = $content -replace '(?m)^nexusFileStatus=.*$', \"nexusFileStatus=$statusInt\"\n$content = $content -replace '(?m)^lastNexusQuery=.*$', \"lastNexusQuery=$nowIso\"\n$content = $content -replace '(?m)^lastNexusUpdate=.*$', \"lastNexusUpdate=$updatedIso\"\n[IO.File]::WriteAllText($metaPath, $content, [Text.UTF8Encoding]::new($false))\n```\n\nFor production-grade automation, prefer the helper script:\n\n```powershell\npwsh scripts\\refresh-nexus-update-state.ps1 -MO2Root \u003Cpath> -Game starfield\n```\n\nCaveat: direct `meta.ini` writes do not refresh MO2's in-memory\n`ModInfoRegular` until the next `organizer.refresh()` or MO2 restart.\n\n## Reading Nexus credentials from MO2's Windows Credential Manager store\n\nMO2 stores Nexus credentials globally for the current Windows user, not per MO2\ninstance. All portable MO2 instances under the same Windows account share them.\nMO2 uses `getWindowsCredential` \u002F `setWindowsCredential` in `settings.cpp`.\n\nCredential Manager targets:\n\n| Target | Meaning |\n|---|---|\n| `ModOrganizer2_APIKEY` | Legacy 162-character personal API key. |\n| `ModOrganizer2_NEXUS_OAUTH_TOKENS` | Compact JSON `{access_token, refresh_token, expires_at, scope, token_type}` from the modern OAuth flow. |\n\nRead pattern:\n\n```powershell\n$signature = @'\nusing System;\nusing System.Runtime.InteropServices;\nusing System.Text;\npublic class CredMan {\n  [DllImport(\"advapi32.dll\", SetLastError=true, EntryPoint=\"CredReadW\", CharSet=CharSet.Unicode)]\n  static extern bool CredRead(string target, uint type, uint flag, out IntPtr cred);\n  [DllImport(\"advapi32.dll\")] static extern void CredFree(IntPtr p);\n  [StructLayout(LayoutKind.Sequential, CharSet=CharSet.Unicode)]\n  public struct CREDENTIAL { public uint Flags,Type; public IntPtr TargetName,Comment; public System.Runtime.InteropServices.ComTypes.FILETIME LastWritten; public uint CredentialBlobSize; public IntPtr CredentialBlob; public uint Persist,AttributeCount; public IntPtr Attributes,TargetAlias,UserName; }\n  public static string Read(string t) { IntPtr p; if (!CredRead(t,1,0,out p)) return null; try { var c=(CREDENTIAL)Marshal.PtrToStructure(p,typeof(CREDENTIAL)); byte[] b=new byte[c.CredentialBlobSize]; Marshal.Copy(c.CredentialBlob,b,0,(int)c.CredentialBlobSize); int nz=0; for(int i=1;i\u003Cb.Length;i+=2)if(b[i]==0)nz++; return nz>(b.Length\u002F4)?Encoding.Unicode.GetString(b):Encoding.UTF8.GetString(b); } finally { CredFree(p); } }\n}\n'@\nAdd-Type -TypeDefinition $signature -Language CSharp\n$apiKey = [CredMan]::Read(\"ModOrganizer2_APIKEY\")\n$oauthJson = [CredMan]::Read(\"ModOrganizer2_NEXUS_OAUTH_TOKENS\")\n```\n\nVerification call:\n\n```powershell\nInvoke-RestMethod -Uri \"https:\u002F\u002Fapi.nexusmods.com\u002Fv1\u002Fusers\u002Fvalidate.json\" -Headers @{ APIKEY = $apiKey }\n```\n\nExpected fields include `user_id`, `name`, `is_premium`, and `is_supporter`.\n\n[WARNING]\nReading user credentials requires explicit user consent. Mask the key in any\nlogged output, for example `d0Ra...72d4 (len=162)`. Recommend key rotation after\nthe session if there is any leak risk.\n\nFailure modes:\n\n- `cmdkey \u002Flist | findstr nexus` returns nothing because the target name has no\n  `nexus` string. Use `cmdkey \u002Flist | findstr ModOrganizer2` instead.\n- HKCU registry entries such as `HideCreateInstanceIntro` are cosmetic flags,\n  not credentials.\n- `ModOrganizer.ini` `[Settings]` has no auth fields.\n- If `CredRead` returns null, Nexus auth is not set up in MO2 yet. Direct the\n  user to `Settings -> Nexus -> Connect to Nexus`.\n\nSee KB record `install-planning.mo2-windows-credential-mining.v1`.\n\n## Script Extender (xSE) update workflow — game-root drop, runtime-pinned\n\nUse this when Steam updates the game runtime and the existing xSE DLL no longer\nmatches it. The signal is a launch refusal through the xSE loader because the\nDLL runtime tag does not match the current `\u003Cgame>.exe` `FileVersion`.\n\nDetection:\n\n```powershell\n# Current xSE version (filename pattern)\nGet-ChildItem \"$gameRoot\\sfse_*.dll\" | Select Name  # e.g. sfse_1_15_222.dll = SFSE for runtime 1.15.222\n\n# Current Steam runtime\n(Get-Item \"$gameRoot\\Starfield.exe\").VersionInfo.FileVersion  # e.g. 1.16.244.0\n\n# If they do not match, update is needed.\n```\n\nLatest-version sources: silverlock.org points to Nexus mod `#106` for SFSE,\n`#100216` for SKSE64, and `#42147` for F4SE.\n\nUpdate workflow:\n\n1. Get the latest `file_id` from\n   `\u002Fv1\u002Fgames\u002F{game}\u002Fmods\u002F{xse_mod_id}\u002Ffiles.json`; use the file with\n   `category_name=MAIN`.\n2. Premium: call\n   `POST \u002Fv1\u002Fgames\u002F{game}\u002Fmods\u002F{xse_mod_id}\u002Ffiles\u002F{file_id}\u002Fdownload_link.json`.\n   The response is an array of seven CDN mirrors (Chicago, Amsterdam, Prague,\n   LA, Miami, Dallas, plus Nexus CDN). Pick the first URL.\n3. Free: open the Nexus page in a browser, click manual download, and save the\n   `.7z` to a known location.\n4. Extract the `.7z`. Gotcha: the archive expands to an `\u003Cxse>_\u003Cversion>\u002F`\n   subdirectory, such as `sfse_0_2_21\u002F`, not a flat folder. Glob-find files:\n   `Get-ChildItem -Recurse -Filter \"sfse_*.dll\" | Select-Object -First 1`.\n5. Backup current game-root xSE files to\n   `\u003CMO2_Root>\\.backups\\sfse-\u003Coldver>_pre-\u003Cnewver>-update_\u003Ctimestamp>\\`.\n6. Copy the new DLL, readme, and whatsnew files to the game root. Skip files\n   with unchanged sha256; the `\u003Cxse>_loader.exe` often does not change between\n   minor versions.\n7. Delete the old runtime DLL. This is optional but recommended for cleanliness;\n   the loader auto-picks by runtime match and does not need the old DLL.\n8. Verify sha256 for all four game-root files against staging.\n\n### After SFSE: the cascade is the principle\n\nA game runtime bump is a dependency cascade, not a single-file event. xSE is\nonly the first layer. Address Library and every runtime-bound DLL plugin also\nbind to runtime-specific addresses, so a correct maintenance pass follows the\nchain until the launch dialog stops reporting downstream leaks.\n\nRead the chain this way:\n\n1. **xSE binary** is the game-root layer and must match `\u003Cgame>.exe`.\n2. **Address Library** (Nexus mod #3256 for Starfield, #32444 for SkyrimSE,\n   #47327 for Fallout4) is a normal MO2 mod projected into\n   `Data\\SFSE\\Plugins\\`. It supplies `versionlib-\u003Cruntime>.bin` for the\n   current runtime.\n3. **SFSE\u002FSKSE\u002FF4SE plugin mods** each ship their own DLL and may need an\n   author-side rebuild.\n\nThe SFSE Plugin Loader dialog is the cascade readback surface:\n\n- `address library needs to be updated` means the plugin could not find the new\n  versionlib file; update Address Library first.\n- `incompatible with current version of the game` means the plugin DLL itself\n  is behind the game runtime; investigate whether the author has released a\n  compatible build.\n\nFor the actual update of each SFSE plugin mod, the mechanical pattern remains:\n- Premium API: `POST \u002Fv1\u002Fgames\u002F{game}\u002Fmods\u002F{id}\u002Ffiles\u002F{file_id}\u002Fdownload_link.json`\n- Extract to staging (remember the 7z subdirectory gotcha noted above)\n- Backup current MO2 mod folder contents\n- Replace files in mod folder\n- Update meta.ini's `version`, `newestVersion`, `installationFile`, `lastNexusUpdate`\n- If folder name encodes a version (for example `\u003Cmodname> - AddLib 18` or\n  `\u003Cmodname> - Game version 1.15.222`), rename folder and update `modlist.txt`\n  to match.\n\nIf Nexus reports `status=not_published` or `status=hidden`, treat it as a\ncontinuity investigation signal, not an instant disable verdict. Check whether\nthe same author republished or moved the release before proposing replacement.\n\n### Intent-aware mutation methodology\n\nA mod update is complete only when the observed post-state satisfies the intent\nthat motivated the update. Replacing files proves one effect; it does not prove\nruntime compatibility, curator-visible classification, metadata consistency, or\nenablement.\n\nAfter acting, ask: **did this satisfy the intent across all dependent MO2 state\ndimensions, or only the dimension I directly touched?** The dependent dimensions\nusually include:\n\n- files in the mod folder;\n- `meta.ini` version\u002Fsource\u002Fstatus fields and visible annotations;\n- folder name when it encodes version or runtime support;\n- `modlist.txt` line text after any rename;\n- separator ownership, especially for mods previously parked in\n  `版本已过期`, `等待作者更新`, or `[弃用]`;\n- enable flag when the original disable reason has been resolved;\n- for DLL plugins, the author's claimed runtime support versus the local game\n  runtime.\n\nThis is a ReAct-style observation rule at the level of intent, not a rote\nchecklist. If observation shows that only files changed while the mod remains in\na waiting separator, still disabled, or still behind the current runtime, report\nthe intent gap and propose the next reconciliation step before declaring done.\nDo not trust an action return value or a delegated fixer's summary as proof;\nread `modlist.txt`, read affected `meta.ini` files, and use launch readback when\nruntime compatibility is load-bearing.\n\nCross-link: KB record `install-planning.mod-update-post-state-discipline.v1` for the full discipline.\n\n### Placeholder dummy mod for xSE binary tracking (curator convention, optional)\n\nBB84's personal pattern: keep an empty MOD folder under `\u003CMO2Root>\u002Fmods\u002F\u003CXSE\nName> \u003Cruntime-tag>\u002F` (e.g. `Starfield Script Extender 1-15-222\u002F`) with a\nsingle `sfse_\u003Cbinary-ver>\u002F` empty subdir + a complete `meta.ini` carrying\nthe real `modid=106` + `version=` + `installationFile=` + nexus-side\nmetadata. Effect: the MO2 mod list visibly tracks the current SFSE binary\nversion even though the actual SFSE binaries live in game root and are\notherwise invisible to MO2's update-tracking. On each xSE update, rename\nboth the outer folder and the inner marker dir, and update the meta.ini.\nThis is a curator preference, not a required workflow.\n\n[WARNING]\nThis writes to the real game install, for example\n`D:\\SteamLibrary\\steamapps\\common\\\u003Cgame>\\`. It requires explicit per-session\nuser confirmation. xSE has no MO2 VFS overlay path: the loader must spawn\n`\u003Cgame>.exe`, so it has to live next to it.\n\nFor production-grade automation:\n\n```powershell\npwsh scripts\\install-xse-update.ps1 -GameRoot \u003Cpath> -XseMod sfse|skse|f4se|nvse\n```\n\nSee KB record `engine.xse-update-workflow.v1`.\n\n## xEdit binary upgrade workflow — sister of xSE upgrade, but tools-tree-local\n\nUse this when the user wants to verify or upgrade the xEdit installation\nwithout launching the MO2 GUI by hand. Sister flow to xSE upgrade but with\ndifferent mechanics: xEdit lives in `\u003CMO2_Root>\u002Ftools\u002FxEdit\u002F` (NOT game root,\nNOT under STOCK001 protection), and its runtime carries a versioned binary\ncache that must be invalidated on every binary swap or the daemon launches\nagainst a stale cache and either crashes or returns wrong data.\n\n### When to check\n\n- The user explicitly asks to verify \u002F upgrade xEdit.\n- A scheduled environment health pass is running.\n- The xEdit MCP daemon fails to launch, crashes mid-session, or returns\n  unexpected protocol errors against a load order that worked before.\n- New automation features are needed (multi-pattern filters, reverse\n  navigation, WRLD parent coords, etc. — anything past the contract version\n  the deployed binary supports).\n\n### Stale detection — SHA-256 hash comparison\n\n`Get-Item.VersionInfo.FileVersion` is unreliable for xEdit because the\ncontrib fork ships multiple builds under the same `4.1.5.0` \u002F `4.1.6` label.\nUse SHA-256 against the reference source:\n\n```powershell\n$mo2Bin     = \"$MO2_Root\\tools\\xEdit\\SF1Edit64.exe\"\n$refSource  = \"D:\\TES5Edit-contrib\\Build\\xEdit64.exe\"   # OR the path returned by fetch-xedit-release.ps1\n$mo2Hash    = (Get-FileHash -LiteralPath $mo2Bin -Algorithm SHA256).Hash\n$refHash    = (Get-FileHash -LiteralPath $refSource -Algorithm SHA256).Hash\nif ($mo2Hash -ne $refHash) {\n  Write-Warning \"xEdit stale: MO2 has $($mo2Hash.Substring(0,16))... reference has $($refHash.Substring(0,16))...\"\n}\n```\n\nAlso surface mtimes for human readability — a 10-day gap with non-matching\nhashes is a real version drift, not a build metadata glitch.\n\n`xEditHookBridge.dll` is retired and must not be hash-checked, copied, or\ndeployed. Native `xEdit.exe -automation-serve` is the supported path.\n\n### Reference source — contrib build vs release channel\n\nTwo reference sources exist:\n\n1. **Local dev build at `D:\\TES5Edit-contrib\\Build\\`** — the contrib fork's\n   continuously-rebuilt artifacts. Captures unreleased features (contract\n   0.18 → 0.19 → 0.20 additions, WRLD parent, reverse navigation, etc.) and\n   bug fixes. Use this when the user is developing against the latest\n   automation surface or needs features not yet in a tagged release.\n\n2. **GitHub release artifacts via `fetch-xedit-release.ps1`** — the\n   `BB-84C\u002FTES5Edit` tagged-release stream. Stable, reproducible, ships\n   with a manifest. Use this for end-user installs, reproducible modpack\n   build chains, or any scenario where the user is not the binary's author.\n\nFor BB84's developer workstation: contrib build is canonical because BB84\nauthors the contrib fork. For end-user installs: release channel is\ncanonical. The skill should ask which source the user wants when ambiguous.\n\n### Upgrade workflow\n\n```powershell\n$ts = Get-Date -Format 'yyyyMMdd-HHmmss'\n\n# 1. Backup current tools\u002FxEdit\u002F (full mirror, mtimes preserved)\nrobocopy \"$MO2_Root\\tools\\xEdit\" \"$MO2_Root\\tools\\xEdit.backup-$ts\" \u002FMIR \u002FNFL \u002FNDL \u002FNJH \u002FNJS\n\n# 2. Swap binaries (rename to game-specific filename so xEdit auto-detects mode)\nCopy-Item \"$refSource\\xEdit64.exe\" \"$MO2_Root\\tools\\xEdit\\SF1Edit64.exe\" -Force  # Starfield\nCopy-Item \"$refSource\\xEdit64.exe\" \"$MO2_Root\\tools\\xEdit\\xEdit64.exe\"   -Force\nCopy-Item \"$refSource\\xEdit.exe\"   \"$MO2_Root\\tools\\xEdit\\xEdit.exe\"     -Force\n\n# (For other games: FO4Edit64.exe, SSEEdit64.exe, etc. — the xEdit binary\n#  detects game mode from its filename when launched directly.)\n\n# 3. INVALIDATE CACHE — mandatory after any binary swap\n$cacheDir = \"$MO2_Root\\overwrite\\\u003CGame>Edit Cache\"  # e.g. SF1Edit Cache\nMove-Item -LiteralPath $cacheDir \"$MO2_Root\\overwrite\\\u003CGame>Edit Cache.stale-$ts\" -ErrorAction SilentlyContinue\n```\n\n### Cache lifecycle — REQUIRED reading before launch\n\nxEdit's binary cache lives at `\u003CMO2_Root>\u002Foverwrite\u002F\u003CGame>Edit Cache\u002F`\n(e.g. `SF1Edit Cache\u002F`, `FO4Edit Cache\u002F`, `SSEEdit Cache\u002F`). Files are\nnamed `\u003Cload-order-hash>_\u003Cplugin>_\u003Cplugin-hash>_g\u003Ccp>_t\u003Ccp>_l\u003Ccp>_\u003Clang>.refcache`.\n\n**The cache is binary-version-bound.** A binary upgrade invalidates every\ncache file because:\n\n- xEdit's internal record-parsing logic may have changed (new contract\n  features, fixes to malformed-data tolerance, etc.).\n- The cache format itself may have evolved.\n- Stale caches produce subtle wrong-answer bugs that look like xEdit\n  protocol errors but are actually parser drift.\n\nALWAYS move the cache dir aside (don't delete — it's the safety net) before\nthe first launch after a binary swap. Pattern:\n`overwrite\u002F\u003CGame>Edit Cache.stale-\u003Ctimestamp>\u002F`.\n\nThe cache will be rebuilt automatically on first launch. Once stable and\nverified, the `.stale-*` backup can be removed in a future cleanup pass.\n\n### First-launch timing (cold cache)\n\nCache-cold launch on a 175-plugin Starfield profile takes **9-10 minutes**.\nThis is real-time wall clock for xEdit to:\n\n1. Parse every plugin in the load order.\n2. Hash each plugin's records.\n3. Write the per-plugin `.refcache` file.\n\nThe current xedit-mcp `xedit-client.ps1` has a **240-second timeout** for\ndaemon readiness. **First-launch on a real-world load order will exceed\nthis timeout and fail.**\n\nWorkaround options:\n\n1. **Build cache via manual GUI launch first** (preferred for current\n   tooling): run xEdit through MO2's normal launch path (either via\n   `Mo2Mo2RunTool_tool` with the configured customExecutable, or have the\n   user click the MO2 button). Wait until xEdit's window finishes loading\n   (status bar shows \"Background Loader: finished\" or similar). Close\n   xEdit. Then `xedit_start` will launch in \u003C3 min wall-clock against the\n   warm cache.\n2. **Bump the timeout in xedit-client.ps1** if scripting around step 1 is\n   undesirable. The relevant constant is documented in the xedit-mcp\n   broker source.\n\n### Polling discipline during cold-cache launch\n\n`xedit_status({})` sends a lightweight read against the daemon's state file,\nbut the daemon's response handler is on the same Pascal thread that's\nparsing the load order. **Aggressive polling during the cold-cache build\ncan stall or crash xEdit's parser.** Empirically observed on a 175-plugin\nStarfield profile on 2026-06-27: 30-second poll cadence during cold-cache\nbuild correlated with a parse hang requiring manual kill.\n\nPolling discipline:\n\n- During cold-cache build (first launch after binary swap): wait at least\n  60 seconds between polls. Better: don't poll at all until 8+ minutes have\n  elapsed, then check once.\n- During cache-warm launch (subsequent launches): 30-60 second poll cadence\n  is fine. Total launch time ~3 minutes.\n- After `status: \"ready\"`: domain tools (`xedit_session`, `xedit_health`,\n  `xedit_call`) can be called freely.\n\n### Verification after launch\n\n```text\nxedit_health({})       -> { responsive: true, pingEnvelope: { ok: true } }\nxedit_session({})      -> { gameMode: \"Starfield\", contractVersion: \"0.20\",\n                            loadOrderSize: N, consentEnabled: false (read-only)\n                                                or true (mutations allowed) }\nxedit_dirty({})        -> { dirty: false, unsavedChangeCount: 0 }\n```\n\nCheck `contractVersion` against the contract level the new binary should\nhave shipped. If contractVersion is lower than expected, the binary didn't\nswap correctly OR the daemon picked up the wrong binary path.\n\n### Clean shutdown — cache preserved\n\n`xedit_stop({})` on a clean dirty state preserves the cache for the next\nlaunch. Subsequent `xedit_start({})` will hit the warm cache and complete\nin ~3 minutes. Do not delete the cache dir between sessions unless a\nbinary upgrade is happening.\n\n### See also\n\n- KB record `engine.xedit-binary-cache-lifecycle.v1` for the full\n  binary-cache binding mechanism.\n- KB record `engine.xedit-stale-detection-via-hash.v1` for the SHA-256\n  comparison method against reference sources.\n- KB record `tooling.xedit-contrib-build-vs-release-channel.v1` for the\n  source-selection strategy.\n- KB record `debugging.xedit-cold-cache-launch-timeout-and-polling.v1`\n  for the 240s timeout + polling-discipline gotchas.\n\n## meta.ini `comments=` vs `notes=` as visibility design\n\nMO2 has two note-shaped fields because it has two different reading modes:\nvisibility-at-a-glance and detail-on-demand.\n\n- **`comments=`** serves the at-a-glance mode. It appears in the mod-list\n  Comments column, so it is the right place for short summaries, status tags\n  (`[UPDATE→vX]`, `[WAITING-FOR-X.Y.Z]`), CC markers (`[CC]`, `[CC·汉化版]`),\n  and other information the curator should see without opening a dialog.\n- **`notes=`** serves the detail-on-demand mode. It appears only in the mod's\n  properties Notes tab, so it is the right place for install procedure memos,\n  FOMOD choice records, conflict-resolution notes, and verbose version history.\n\nChoose the field by intended reader behavior. If the curator must see the fact\nwhile scanning the list, use `comments=`. If the fact is reference material for\nwhen the mod is already being inspected, use `notes=`. Automation that\nsynthesizes 1-2 sentence per-mod summaries from `nexusDescription` therefore\nwrites to `comments=` by default; putting those summaries in `notes=` makes the\nlist look empty even though the information exists.\n\n## Post-patch loose-extract hygiene (game-install Data\\ stale CK extracts)\n\nAfter every BGS game patch, a standard maintenance pass should sweep the\ngame-install `Data\\` tree for stale Creation Kit loose extracts. The full\nmethodology lives in KB record\n`archive-precedence.stale-ck-extract-loose-files.v1`; the operational shape\nfor a maintenance pass is short:\n\nThe trap. When the curator installs the Creation Kit alongside the game, the\nCK auto-extracts authoring-time loose files from `Tools\\ContentResources.zip`\ninto `Data\\` — `Data\\Materials\\` (`.mat`), `Data\\Particles\\` (`.psfx`),\n`Data\\Scripts\\Source\\` (`.psc`), plus editor metadata. Archive invalidation,\nwhich any modded curator has enabled, makes those loose files override the\ncompiled BA2 databases at runtime. While the game version matches the CK\nextract version this is invisible; the moment the game patches its compiled\nmaterial database, particle archive, or compiled scripts, the loose files\nbecome stale references against the new BA2 and the runtime breaks silently\n(purple\u002Firidescent terrain, missing meshes, wrong VFX, subtle Papyrus drift).\n\nThe cheap diagnostic test. Before bisecting mods on any post-patch visual or\nbehavioral regression:\n\n```powershell\n# Inspect the game-install Data\\ for stale CK extracts.\n$gd = \"\u003Cgame-install>\\Data\"\nGet-ChildItem -LiteralPath $gd -Directory |\n  Where-Object { $_.Name -in @('Materials','Particles','Scripts','Source','Textures','EditorFiles','DataViews') } |\n  ForEach-Object {\n    $files = Get-ChildItem -LiteralPath $_.FullName -Recurse -File -ErrorAction SilentlyContinue\n    $oldest = ($files | Sort-Object LastWriteTime | Select-Object -First 1).LastWriteTime\n    \"{0,-14}  files: {1,5}  oldest: {2}\" -f $_.Name, $files.Count, $oldest\n  }\n```\n\nCompare oldest mtime to the current patch's BA2 mtime. If older, the extract\nis stale. If `Tools\\ContentResources.zip` modification time matches the\ncurrent patch, the recovery path is intact — deletion is fully reversible.\n\nThe fix. Delete the stale extract trees from `Data\\`. Runtime falls back to\nBA2. For Starfield specifically the priority order is `Data\\Materials\\` →\n`Data\\Particles\\` → `Data\\Textures\\` → `Data\\Scripts\\` (runtime impact),\nthen `Data\\Source\\`, `Data\\DataViews\\`, `Data\\EditorFiles\\` (CK-editor-only,\nharmless to keep, harmless to delete).\n\n[WARNING]\nThis writes to the real game install, for example\n`D:\\SteamLibrary\\steamapps\\common\\\u003Cgame>\\Data\\`. It requires explicit\nper-session user confirmation. The action is reversible by re-extracting\n`Tools\\ContentResources.zip` into `Data\\`, but the deletion itself is\ndestructive against the loose extracts that are currently there.\n\nA cleaner long-term pattern: extract `ContentResources.zip` into a dedicated\nMod Organizer 2 mod folder (e.g. `mods\u002FCK Resources Vanilla\u002F`) so the CK\nloose files can be toggled per-profile and never touch the real game install.\n\nCross-link: KB record `archive-precedence.stale-ck-extract-loose-files.v1`\nfor the full mechanism. KB record\n`debugging.asymmetric-evidence-self-falsify.v1` for the diagnostic\ndiscipline that prevents the trap from misleading bisection planning.\n\n## meta.ini comment vs note field hygiene (HARD RULE)\n\nEvery time an agent touches a mod folder's `meta.ini`, two text fields exist\nand they have STRICTLY DIFFERENT purposes. Putting content in the wrong field\nbreaks the curator's mental model of their own modpack.\n\n**`comments=` = SHORT description of WHAT THE MOD DOES (the mod's CONTENT)**\n\n- 1-2 sentences max\n- Language: match the curator (Chinese for BB84-style packs, English otherwise)\n- Shown in MO2 GUI mod-list \"Comments\" column (visible at a glance without clicking)\n- Describes the mod's GAMEPLAY\u002FVISUAL\u002FSYSTEM effect, not its install metadata\n\nExample (good): `调整起降过场镜头比例,提供更沉浸的驾驶舱视角与速度选项。`\n\n**`notes=` = TIME-SENSITIVE markers + operational memory (the mod's STATUS)**\n\n- Update history with datestamp + version diff + file_id\n- Archive \u002F obsolescence \u002F version-tag-unsync \u002F user-install \u002F local-patch markers\n- FOMOD choice records, conflict resolution memos, investigation findings\n- Shown in Notes tab (hidden until clicked)\n- MOST text per mod ends up here\n\nMarker prefixes that ALWAYS belong in `notes=`, NEVER in `comments=`:\n\n```\n[UPDATED YYYY-MM-DD] x.y.z -> a.b.c | file_id N [MAJOR|MINOR|PATCH]\n[ARCHIVED YYYY-MM-DD] reason\n[OBSOLETE YYYY-MM-DD] reason\n[FIXED YYYY-MM-DD] reason\n[USER-INSTALLED YYYY-MM-DD] FOMOD picks \u002F manual install footprint\n[NEW-INSTALL YYYY-MM-DD] reactivation cluster context\n[STALE YYYY-MM-DD] SC translation lags \u002F lifecycle drift\n[LOCAL-PATCH] curator's local fixup\n[VERSION-TAG-UNSYNC] page-version-vs-file-version mismatch\n[INVESTIGATION YYYY-MM-DD] analysis findings + anti-stale-fact note\n[UPDATE→x.y.z] BB84's pre-existing update-pending arrow flag (marker is JUST the bracket; description after it belongs in `comments=`)\n```\n\n**bash extract-on-top update path MUST preserve existing `comments=`**:\n\nWhen updating a mod's content (e.g. v1.3.1 → v1.3.2 via extract-on-top),\nthe helper MUST NOT overwrite `comments=`. Instead, APPEND the update marker\nto `notes=` (preserving any pre-existing notes with `\\n` separator).\n\nAnti-pattern that destroyed BB84's curator descriptions on 2026-06-25:\n\n```powershell\n# WRONG — overwrites comments, destroys description\n$content = [Regex]::Replace($content, '(?m)^comments\\s*=.*$', \"comments=[UPDATED ...] $versionDiff\")\n```\n\nCorrect pattern:\n\n```powershell\n# RIGHT — preserve comments, append marker to notes (Qt INI literal \\n)\n$newMarker = \"[UPDATED $date] $oldVersion -> $newVersion | file_id $fileId\"\n$content = [Regex]::Replace($content, '(?m)^notes[\\t ]*=[\\t ]*(.*)$', { param($m) \n  $existing = $m.Groups[1].Value\n  if ([string]::IsNullOrWhiteSpace($existing)) { \"notes=$newMarker\" }\n  else { \"notes=$newMarker\\n$existing\" }  # \\n is literal backslash-n; Qt INI renders as newline\n})\n```\n\n**Regex bug to avoid**: do NOT use `\\s*` in INI line anchoring — it consumes\n`\\r\\n` and captures content from the next line. Use `[\\t ]*` for in-line\nwhitespace only:\n\n```powershell\n# WRONG — \\s* crosses lines, leaks neighbour key's value into your match\n$cmtM = [Regex]::Match($content, '(?m)^comments\\s*=\\s*(.*)$')\n\n# RIGHT — [\\t ]* stays on one line\n$cmtM = [Regex]::Match($content, '(?m)^comments[\\t ]*=[\\t ]*(.*)$')\n```\n\n**Before any batch meta.ini migration**, write a 3-case unit-test fixture:\n\n1. Pure marker only (`[ARCHIVED 2026-06-25] reason`) → expect comments empty, marker stays in notes\n2. BB84 arrow style (`[UPDATE→2.0.0.0] 中文描述`) → expect comments has Chinese, notes has `[UPDATE→2.0.0.0]`\n3. Mixed (description text first, then marker) → expect comments has description, notes has marker\n\nThen dry-run on 3-5 sample mods spanning all three cases BEFORE batch dispatch.\nSkipping this check is what destroyed 49 mods' Chinese descriptions in the\n2026-06-25 buggy migration. See `.opencode\u002Fmemory\u002F45-mo2-mcp-internals.md`\nrule 18 for the full incident postmortem.\n\n### Qt QSettings INI quoting (silent display-empty trap)\n\nMO2's backend uses Qt QSettings to parse meta.ini. Qt's INI parser conflates\na value that STARTS with `[` (e.g. `[UPDATED ...]`, `[CC]`, `[UPDATE→x.y.z]`)\nwith a section-header start (`[Section]`) and silently returns empty for that\nkey. MO2 GUI's Notes\u002FComments tab then shows blank, even though a raw text\npreview of the same meta.ini clearly displays the value populated.\n\n**Hard rule**: whenever a `comments=` or `notes=` value starts with `[`,\nwrap the value in double quotes:\n\n```\n# BROKEN — Qt parses as empty, MO2 GUI shows blank\nnotes=[UPDATED 2026-06-25] 1.1.5.0 -> 1.2.77.0 [MAJOR] | file_id 61879\ncomments=[CC] Watchtower: Orbital.Strike\\Fleet.Command\n\n# CORRECT — Qt strips outer quotes, returns bracketed content; MO2 GUI displays correctly\nnotes=\"[UPDATED 2026-06-25] 1.1.5.0 -> 1.2.77.0 [MAJOR] | file_id 61879\"\ncomments=\"[CC] Watchtower: Orbital.Strike\\Fleet.Command\"\n```\n\nImplementation rules:\n1. **WRITE path**: before serializing a `comments=` \u002F `notes=` line, check if\n   the value's first non-whitespace char is `[`. If yes, emit double quotes\n   around the value. If the value contains internal `\"`, escape them as `\\\"`.\n   Internal `\\n` (literal backslash-n) IS preserved by Qt as a multi-line\n   escape inside quoted strings and renders as a newline in MO2 GUI.\n2. **READ path**: after reading a `comments=` \u002F `notes=` line, strip a single\n   leading and trailing `\"` pair (if present) BEFORE parsing the value\n   semantically. Unescape internal `\\\"` to `\"`.\n3. **Idempotence**: re-running the quoting step on an already-quoted value\n   should be a no-op (`if ($val -match '^\".*\"$') { skip }`).\n4. **Special cases**: values already starting with `@ByteArray(...)`,\n   `\u003CHTML>`, or other Qt-supported wrapper forms are left untouched — they\n   have their own parsing path.\n\nReproduction: 2026-06-26 Xeno Master screenshot pair (BB84). 268-char notes\nvalue with `[UPDATED ...]` start displayed empty in MO2 GUI. Adding double\nquotes around the value fixed display immediately on MO2 refresh (no\nrestart). Sweep across BB84 Starfield modpack found 220 affected meta.ini\nfiles; backups preserved at\n`D:\\Starfield MO2\\.backups\\meta-qt-quote-fix-20260626-003856\\`.\n\nCross-link: KB record `engine.qt-ini-bracket-quote-requirement.v1` (TBD)\nshould codify this for end-users authoring their own meta.ini writers.\n\nCross-link: KB record `install-planning.mod-mutation-cleanliness-discipline.v1`\ncovers the broader 7-discipline mutation hygiene checklist that this hygiene\nrule plugs into.\n\n## See also\n\n- `setting-up-bgs-modding-environment` — first-run MO2 \u002F xEdit \u002F KB acquisition orchestrator.\n- `using-bgs-modding-superpowers` — session bootstrap, available tools, and hard BGS modding rules.\n- `docs\u002Finternal\u002Froadmap.md` — KB track status and phase closeouts.\n- Deep reference: `docs\u002Finternal\u002Fsuperpowers\u002Fspecs\u002F2026-06-02-agentic-cross-game-kb-design.md`.\n",{"name":5,"description":7},"main","b0f0a87593c578a7898eccaf1b363f7f87c1f99b","plugins\u002FBB-84C\u002Fbgs-modding-superpowers\u002Fskills\u002Fmaintaining-modding-environments",491,"https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins","https:\u002F\u002Fhol.org\u002Fplugins\u002Fbest-codex-plugins","https:\u002F\u002Fgithub.com\u002Fhashgraph-online","https:\u002F\u002Fhol.org","Open-source standards and developer tools for interoperable AI agents: discovery, identity, communication, payments, privacy and security.","2026-11-14 14:06:13",{"source":8,"skillName":5,"commands":56,"prompt":66,"zipAvailable":67},[57,60,63],{"tool":58,"command":59},"npx","npx skills add hashgraph-online\u002Fawesome-codex-plugins --skill maintaining-modding-environments",{"tool":61,"command":62},"bunx","bunx skills add hashgraph-online\u002Fawesome-codex-plugins --skill maintaining-modding-environments",{"tool":64,"command":65},"pnpm","pnpm dlx skills add hashgraph-online\u002Fawesome-codex-plugins --skill maintaining-modding-environments","安装技能，技能地址：https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002FBB-84C\u002Fbgs-modding-superpowers\u002Fskills\u002Fmaintaining-modding-environments\u002FSKILL.md",true,[],[70,80,88,96,104,112],{"skillNo":71,"name":72,"nameZh":6,"description":73,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":74,"licenseFileUrl":75,"sourceHtmlUrl":76,"categories":77,"keywords":78,"publishedAt":79},"01M7DV332YQMGD8WTRJ9DZQXTB","worktable-review-with-annotations","Create, inspect, reply to, update, or resolve situated Worktable annotations. Use when feedback belongs to a Doc section, block, text range, or HTML Doc, or when the user asks to address existing review feedback and coordinate a requested artifact edit.","MIT","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-review-with-annotations\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-review-with-annotations\u002FSKILL.md",[],[],"2026-11-15 14:19:17",{"skillNo":81,"name":82,"nameZh":6,"description":83,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":74,"licenseFileUrl":84,"sourceHtmlUrl":85,"categories":86,"keywords":87,"publishedAt":79},"01M7DV2YGHCZVBEB1AHYB6CGHE","worktable-find-and-synthesize-context","Find, assess, and synthesize context from Worktable Docs and Records. Use when the user asks what a workspace contains, wants workspace-backed research, needs current facts reconciled across artifacts, or requests a cited synthesis without changing workspace state.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-find-and-synthesize-context\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-find-and-synthesize-context\u002FSKILL.md",[],[],{"skillNo":89,"name":90,"nameZh":6,"description":91,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":74,"licenseFileUrl":92,"sourceHtmlUrl":93,"categories":94,"keywords":95,"publishedAt":79},"01M7DV2TQN1H11ME2SAF9MXN7V","worktable-create-or-update-docs","Create, edit, rename, or maintain narrative Worktable Docs. Use for plans, decisions, briefs, notes, research syntheses, and other durable prose when the user requests a new artifact or a safe update to an existing one.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-update-docs\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-update-docs\u002FSKILL.md",[],[],{"skillNo":97,"name":98,"nameZh":6,"description":99,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":74,"licenseFileUrl":100,"sourceHtmlUrl":101,"categories":102,"keywords":103,"publishedAt":79},"01M7DV2NE452NEA8TXATKSNAJH","worktable-create-or-manage-records","Organize repeated structured information as durable Worktable Records. Use for research datasets, inventories, directories, pipelines, trackers, and other collections whose items need identity, fields, filtering, links, validation, or individual updates.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-records\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-records\u002FSKILL.md",[],[],{"skillNo":105,"name":106,"nameZh":6,"description":107,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":74,"licenseFileUrl":108,"sourceHtmlUrl":109,"categories":110,"keywords":111,"publishedAt":79},"01M7DV2HENRBR2KSCVM064WH0Y","worktable-create-or-manage-interactive-html","Create or improve durable visual and interactive artifacts in Worktable. Use for dashboards, trackers, calculators, mini apps, slide presentations, and other requests that benefit from a polished HTML Doc.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-interactive-html\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-create-or-manage-interactive-html\u002FSKILL.md",[],[],{"skillNo":113,"name":114,"nameZh":6,"description":115,"descriptionZh":6,"repositoryFullName":8,"ownerLogin":9,"ownerAvatarUrl":10,"ownerAccountNo":11,"ownerDisplayName":12,"repositoryNo":13,"starsCount":14,"licenseSpdxId":74,"licenseFileUrl":116,"sourceHtmlUrl":117,"categories":118,"keywords":119,"publishedAt":79},"01M7DV2CADR5R7RQFFYPNAGR9Y","worktable-collaborate-threads","Read, answer, and hand off messages through durable Worktable threads with users or other authenticated participants. Use when the user asks to check addressed messages, reply to a participant, continue a thread, request another agent's help, wait briefly for a response, or watch for comments and messages sent to the agent.","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-collaborate-threads\u002FLICENSE","https:\u002F\u002Fgithub.com\u002Fhashgraph-online\u002Fawesome-codex-plugins\u002Fblob\u002Fmain\u002Fplugins\u002Fworktable\u002Fworktable-plugin\u002Fskills\u002Fworktable-collaborate-threads\u002FSKILL.md",[],[]]