# Configuration reference

This page describes every file and preference kurama may write. The short rule
is: kurama owns `user.js` and the files it names; everything else in a Firefox
profile is left alone.

## Profiles

### New profile

A new profile is created under the browser's profile root (normally
`%APPDATA%\Mozilla\Firefox\Profiles` on Windows) and registered in
`profiles.ini`. The default name is `kurama`. If the name exists, kurama adds a
numeric suffix rather than overwriting it.

The new profile is marked as the browser's default by updating the relevant
`Default=` keys. Existing profiles remain registered and can be reopened from
`about:profiles`.

kurama writes `profiles.ini` itself for deterministic, fork-independent
behaviour. The browser must be closed, because Firefox rewrites that file on
exit.

### Existing profile

Selecting an existing profile runs the same pipeline against its folder. The
first step after selecting it is a complete backup. kurama never deletes a
profile and never copies one.

### Profile state

After a successful run:

```
<profile>/.kurama/
├── state.json
└── backups/
    └── 20260101-120000.000/
        ├── manifest.json
        ├── user.js
        ├── prefs.js
        ├── bookmarks.html
        └── chrome/
```

`state.json` records the run ID, browser, profile, options, add-ons, bookmark
IDs, wallpaper, shortcut, kurama version, and timestamp. `manifest.json` records
which managed files existed before the run and their sizes.

## Files kurama may modify

| File | Purpose |
| --- | --- |
| `user.js` | Preferences Firefox applies on every launch. |
| `prefs.js` | Backed up and restored, never written by kurama. |
| `bookmarks.html` | Generated Netscape bookmark file for the next import. |
| `chrome/userContent.css` | Wallpaper styling for `about:home` and `about:newtab`. |
| `chrome/kurama-wallpaper.*` | Bundled or custom wallpaper image. |
| `extensions/uBlock0@raymondhill.net.xpi` | Bundled signed uBlock Origin. |
| `extensions.json` | Written by Firefox when WebDriver installs an add-on; not edited by kurama. |

All paths above except `extensions.json` are covered by backups. Restore removes
a file that did not exist before the backed-up run, so kurama-created wallpaper
and CSS do not linger after a restore.

## The preference model

Preferences are plain text files under `internal/prefs/data/`. The builder
concatenates:

1. `mandatory.txt` — the always-on baseline.
2. Every enabled option file, in catalog order.
3. Add-on support prefs when uBlock Origin is installed.
4. Bookmark import prefs when a bookmark file was generated.
5. A wallpaper comment when a wallpaper was installed.

The result is written atomically as `user.js`. Each file is validated first:
entries must use the `user_pref("name", value);` form the builder understands.
Comments and blank lines are preserved with normalized line endings.

A manual edit to `user.js` may be overwritten on the next run. Put personal
preferences in a second file or re-apply with your choices instead.

### Baseline highlights

`mandatory.txt` is intentionally conservative. It includes:

- strict tracking protection,
- OCSP/TLS hardening and 0-RTT disabled,
- disk-avoidance and telemetry reductions,
- a clean new-tab page without sponsored content, Pocket, or VPN promos,
- Do Not Track and Global Privacy Control,
- Firefox fingerprinting protection (not the high-breakage RFP mode),
- query stripping, bounce-tracking protection, and email/social tracking
  protection,
- full URLs in the address bar, plus close/quit warnings,
- DoH through Quad9 in **mode 2** (fall back to the system resolver).

DoH mode 2 is a deliberate layman-friendly choice. Mode 3 ("max protection") can
leave a laptop with no working DNS on hotel, campus, or office networks that
block the resolver. Users who want strict DoH can add mode 3 themselves.

### Optional bundles

| ID | Name | Default | Risk | What it does |
| --- | --- | --- | --- | --- |
| `block_ai` | Block built-in AI | on in Balanced | low | Disables Firefox's local AI features, AI chat, smart tab groups, and link previews. AI websites still work. |
| `ghost_mode` | Ghost Mode | off | high | Enables `privacy.resistFingerprinting`. Sites see a generic fingerprint. Some layouts and canvas-dependent features may break. Does not hide your IP. |
| `disable_drm` | Disable DRM | off | high | Disables Encrypted Media Extensions. Netflix, Disney+, and similar services stop playing. |
| `disable_webrtc` | Disable WebRTC | off | high | Disables WebRTC. Browser calls (Discord, Meet) stop working; desktop apps are unaffected. |
| `reduce_graphics` | Reduce graphics acceleration | off | medium | Disables GPU acceleration and parts of the JIT. Slower games and design tools. |

Only `block_ai` is on by default because it has no meaningful compatibility
cost. Everything else is opt-in and carries a review-screen warning.

### Presets

| ID | Name | Options | Add-ons | Interests |
| --- | --- | --- | --- | --- |
| `balanced` | Balanced (recommended) | `block_ai` only | uBlock Origin | tech, privacy, learning |
| `maximum_privacy` | Maximum privacy | all five | uBlock Origin, ClearURLs, Multi-Account Containers | privacy, tech, news |
| `compatibility` | Compatibility first | none | uBlock Origin | tech, learning |
| `custom` | Custom | whatever you toggle | whatever you pick | whatever you pick |

"Maximum privacy" is allowed to break streaming, calls, and graphics-heavy
sites. That is why it is not the default.

### Phoenix-inspired preferences

A small set of low-breakage ideas from
[Phoenix](https://codeberg.org/celenity/Phoenix) is included in the baseline or
in `mandatory.txt`:

- Global Privacy Control and Do Not Track,
- fingerprinting protection in normal and private windows,
- email and social tracking protection,
- bounce-tracking protection,
- query-parameter stripping, including when sharing links,
- blocking the add-on list from `mozAddonManager` fingerprinting,
- full URLs in the address bar,
- sponsored address-bar suggestions and add-on/MDN/Pocket/Yelp/weather/Fakespot
  features disabled,
- close/quit warnings.

Phoenix is GPL-3.0. kurama does not copy its files, locked preferences, or
hardening policy, and remains a separate project. Attribution is kept in the
preference file.

## Bookmarks

The generated file is standard Netscape `bookmarks.html`, the format Firefox
exports. kurama also parses that format for imports, so an uploaded export is
merged with the suggestions rather than replacing anything.

On the next launch, Firefox reads:

```
user_pref("browser.bookmarks.file", "/absolute/path/to/bookmarks.html");
user_pref("browser.places.importBookmarksHTML", true);
```

Firefox turns the import flag off after importing. The file stays on disk for
future runs and for inspection. With no bookmarks selected and no import, these
prefs are omitted and no file is written.

Suggested bookmarks are grouped by interest. Essentials (Firefox, uBlock Origin,
Wikipedia, Internet Archive) are included for every interest selection.

## Wallpaper

The bundled image is embedded at build time. A custom image may be JPEG, PNG,
WebP, GIF, or AVIF; the original extension is preserved. kurama writes:

```
chrome/kurama-wallpaper.jpg   (or .jpeg/.png/.webp/.gif/.avif)
chrome/userContent.css
```

The stylesheet is scoped with `@-moz-document url("about:home"),
url("about:newtab")` so it cannot affect normal websites. The baseline enables
`toolkit.legacyUserProfileCustomizations.stylesheets`, which Firefox requires for
`userContent.css` to load.

The `about:newtab` background is a cosmetic integration, not a supported
extension point. A future Firefox redesign could change how it looks; it cannot
break normal browsing.

## Desktop shortcut

On Windows, kurama creates a `.lnk` that launches the browser with
`-P <profile>` and the profile's working directory. On Linux it writes a
`.desktop` file. macOS shortcut creation is not offered because it needs an app
bundle; launch the browser normally and choose the profile in `about:profiles`.

A shortcut failure is a warning. It never rolls back a successful
configuration.

## Launch

When `launch` is enabled, kurama starts the browser with the new profile and
passes any add-on store pages as arguments. Automatic add-on installation
failures therefore become one-click finishing steps instead of a blocked setup.

## Config and logs

| Path | Contents |
| --- | --- |
| `<user config>/kurama/config.json` | Theme, last browser/preset/options/add-ons/interests, last profile mode. |
| `<user cache>/kurama/logs/` | Per-launch diagnostic log. |

`config.json` contains no secrets and no browsing data. A corrupt config is
ignored with defaults and repaired on the next save. `KURAMA_CONFIG_DIR`
overrides its directory.

## Exit and safety rules

- The browser must be closed before kurama writes profile files.
- A backup is created before the first write.
- A failed required step stops the pipeline and reports what completed.
- A failed optional step (shortcut, launch, one add-on) becomes a warning.
- Re-running is safe and creates another backup.
- `kurama restore` returns the managed files to a previous state.
