|
| 1 | +# AGENTS.md |
| 2 | + |
| 3 | +Guidance for future agents working in this repository. |
| 4 | + |
| 5 | +## Repository Context |
| 6 | + |
| 7 | +This is the HackTricks Cloud mdBook repository. The related main book lives at: |
| 8 | + |
| 9 | +`/Users/carlospolop/git/hacktricks` |
| 10 | + |
| 11 | +Changes to shared theme/search behavior often need to be applied in both repositories. |
| 12 | + |
| 13 | +## Search Index Loading Contract |
| 14 | + |
| 15 | +The custom search UI lives in: |
| 16 | + |
| 17 | +`theme/ht_searcher.js` |
| 18 | + |
| 19 | +There may also be a generated copy at: |
| 20 | + |
| 21 | +`book/theme/ht_searcher.js` |
| 22 | + |
| 23 | +If production is deploying the already-built `book/` directory, update both copies or rebuild the |
| 24 | +book before deployment. |
| 25 | + |
| 26 | +The search index loading order is important and cost-sensitive: |
| 27 | + |
| 28 | +1. Load every language-specific and fallback search index from the GitHub repository: |
| 29 | + `HackTricks-wiki/hacktricks-searchindex` |
| 30 | +2. Only if all GitHub-hosted candidates fail, fall back to the same-origin mdBook output. |
| 31 | + |
| 32 | +Do not place the local `/searchindex.js` fallback before any GitHub-hosted fallback such as |
| 33 | +`searchindex-cloud-en.js.gz`. Serving `searchindex.js` from `cloud.hacktricks.wiki` in production is expensive. |
| 34 | + |
| 35 | +For this repo, the expected local fallback is: |
| 36 | + |
| 37 | +`/searchindex.js` |
| 38 | + |
| 39 | +The main-book fallback for this repo is: |
| 40 | + |
| 41 | +`/searchindex-book.js` |
| 42 | + |
| 43 | +That file is only a fallback. The primary source must remain the remote |
| 44 | +`searchindex-<lang>.js.gz` and `searchindex-cloud-<lang>.js.gz` files in |
| 45 | +`HackTricks-wiki/hacktricks-searchindex`. |
| 46 | + |
| 47 | +## Search Index Publishing |
| 48 | + |
| 49 | +The workflows that publish encrypted compressed search indexes to |
| 50 | +`HackTricks-wiki/hacktricks-searchindex` are: |
| 51 | + |
| 52 | +- `.github/workflows/build_master.yml` |
| 53 | +- `.github/workflows/translate_all.yml` |
| 54 | + |
| 55 | +The generated source file is `book/searchindex.js`. The published remote artifact names are: |
| 56 | + |
| 57 | +- `searchindex-cloud-en.js.gz` |
| 58 | +- `searchindex-cloud-<lang>.js.gz` |
| 59 | + |
| 60 | +The browser loader expects the remote `.js.gz` files to be XOR-encrypted gzip payloads using the |
| 61 | +key defined in `theme/ht_searcher.js`. |
| 62 | + |
| 63 | +## Build And Validation |
| 64 | + |
| 65 | +Common local checks: |
| 66 | + |
| 67 | +- `node --check theme/ht_searcher.js` |
| 68 | +- `mdbook build` |
| 69 | + |
| 70 | +If `mdbook build` fails, check: |
| 71 | + |
| 72 | +- `hacktricks-preprocessor-error.log` |
| 73 | +- `hacktricks-preprocessor.log` |
| 74 | + |
| 75 | +## Editing Notes |
| 76 | + |
| 77 | +- Prefer `rg` for searching. |
| 78 | +- Keep generated `book/` output out of commits unless explicitly requested. Search loader fixes are |
| 79 | + an exception when the already-built pages must be corrected immediately. |
| 80 | +- If changing shared theme behavior, compare and update the matching file in |
| 81 | + `/Users/carlospolop/git/hacktricks`. |
| 82 | +- Do not revert unrelated local changes. |
0 commit comments