---
name: liteprivatenav
description: Use this skill whenever the user asks you to work with LitePrivateNav (轻湖私人导航 / Lite Private Nav) bookmarks — add, list, update, move, delete or organize navigation links and categories, apply a layout order, preview a URL's title/icon, import browser bookmarks, export a backup, or check quota. LitePrivateNav is an optional end-to-end encrypted personal start page: when the vault is encrypted, the skill decrypts locally with the user's master password and the server only stores ciphertext. The skill is plain Python source; no pip, no build step, no platform binary.
skill_version: 1.0.0
protocol_version: 1
---

# LitePrivateNav Agent Skill

LitePrivateNav is a personal start page: categories, ordered links, automatic
title/icon completion, and an optional master-password vault. In encrypted
mode link URLs/titles/descriptions and category names/descriptions are
end-to-end encrypted in the browser and decrypted locally by this skill. The
server only stores ciphertext, ordering, timestamps, quotas and the icon
content hash. In plaintext mode the server stores a JSON document per row.

**Language rule:** this skill and its output are English. Always answer the
user in the user's own language. Use `--json` for machine-readable output and
translate the interesting fields for the user.

**Lifecycle boundary:** this skill only does day-to-day data operations.
Creating the vault, changing the master password, switching between plaintext
and encrypted mode, rotating keys and destroying all data happen **only in the
web app**. Do not try to do them with this skill.

## Install or update

Pick the skills directory of your agent platform:

| Platform | Skills directory |
| --- | --- |
| ZCode / DSH | `~/.agents/skills/liteprivatenav` |
| Claude Code | `~/.claude/skills/liteprivatenav` |
| Codex | `~/.codex/skills/liteprivatenav` |
| Pi | `~/.pi/agent/skills/liteprivatenav` |
| OpenClaw | `~/.openclaw/skills/liteprivatenav` |
| Other | any directory you keep on `PYTHONPATH` |

```bash
SKILLS_DIR="$HOME/.agents/skills"          # change for your platform
mkdir -p "$SKILLS_DIR/liteprivatenav" && cd "$SKILLS_DIR/liteprivatenav"
curl -fsSL https://nav.litelake.cn/skill/SKILL.md          -o SKILL.md
curl -fsSL https://nav.litelake.cn/skill/liteprivatenav.py -o liteprivatenav.py
curl -fsSL https://nav.litelake.cn/skill/lite_crypto.py    -o lite_crypto.py
```

Run the offline self-check first:

```bash
python3 liteprivatenav.py doctor --offline
# Windows usually has no python3:
python liteprivatenav.py doctor --offline
```

The three files are plain source; updating means re-running the three `curl`
commands. Configuration lives outside the skill directory, so an update never
touches credentials. There is no `curl | sh`.

## Configure

Configuration directory: `~/.lite-lake/lite-private-nav/` (Windows:
`C:\Users\<user>\.lite-lake\lite-private-nav`). Override with `--config-dir` or
`LITEPRIVATENAV_CONFIG_DIR`.

```text
~/.lite-lake/lite-private-nav/
├── master.key      # the user creates this: master password, one line (encrypted mode only)
├── config.json     # written by login: base_url, api_key, sub, key_id, key_name, scope
└── state.json      # written by login: mode, kdf, verifier_version, wrapped_dek
```

`master.key` is only needed for an encrypted vault. Plaintext vaults do not
need it; `login` just validates the API key. Create `master.key` yourself and
restrict it:

```bash
mkdir -p ~/.lite-lake/lite-private-nav && chmod 700 ~/.lite-lake/lite-private-nav
# Ask the user to write the master password into the file; never echo it.
chmod 600 ~/.lite-lake/lite-private-nav/master.key
```

Get an API key from the LitePrivateNav web app: **Settings → API & Skill →
create key** with `read_write` scope (use `read` for read-only agents). Pass the
key on stdin or through an environment variable; passing it as a command-line
flag is intentionally not supported because it would leak into shell history
and the process list.

```bash
# API key from stdin (recommended)
printf '%s\n' "$LITEPRIVATENAV_API_KEY" | python3 liteprivatenav.py --api-key-stdin login
# or from the environment
LITEPRIVATENAV_API_KEY=... python3 liteprivatenav.py login
```

`login` validates the key, reads the vault status, derives the KEK from the
master password (encrypted mode only), unlocks, unwraps the DEK in memory and
writes `config.json` + `state.json`. The master password, the KEK and the DEK
are never written to disk or printed.

## Commands

Global flags: `--json`, `--base-url`, `--api-key-stdin`, `--config-dir`,
`--master-password-file`, `--master-password-stdin`, `--timeout`, `--version`.
Flags are accepted before or after the subcommand. Provide the key on stdin or
via `LITEPRIVATENAV_API_KEY`; there is deliberately no command-line key flag.

```bash
python3 liteprivatenav.py --json status
python3 liteprivatenav.py --json limits
python3 liteprivatenav.py --json categories list
python3 liteprivatenav.py --json categories create --name "Work" --color "#7A8CA3"
python3 liteprivatenav.py --json categories update <category-id> --name "Job"
python3 liteprivatenav.py --json categories delete <category-id> --mode move --yes
python3 liteprivatenav.py --json links list --limit 100
python3 liteprivatenav.py --json links list --category <category-id>
python3 liteprivatenav.py --json links list --uncategorized
python3 liteprivatenav.py --json links create --url https://example.com --category <category-id>
python3 liteprivatenav.py --json links create --url https://example.com --no-fetch --title "Example"
python3 liteprivatenav.py --json links update <link-id> --title "New title"
python3 liteprivatenav.py --json links move <link-id> --category <category-id>
python3 liteprivatenav.py --json links move <link-id> --category none
python3 liteprivatenav.py --json links delete <link-id> --yes
python3 liteprivatenav.py --json layout --file layout.json
python3 liteprivatenav.py --json metadata https://example.com
python3 liteprivatenav.py --json metadata https://example.com --create --category <category-id>
python3 liteprivatenav.py --json snapshot
python3 liteprivatenav.py --json snapshot --raw        # server ciphertext, no decryption
python3 liteprivatenav.py export --output ~/nav-backup.json
python3 liteprivatenav.py --json import ~/nav-backup.json
python3 liteprivatenav.py --json import ~/bookmarks.html
python3 liteprivatenav.py --json doctor
python3 liteprivatenav.py doctor --offline
```

`--version` prints `liteprivatenav-skill 1.0.0`. With `--json`, stdout contains
exactly one JSON document and nothing else.

### Behavior notes

- `links create` calls `metadata/preview` unless `--no-fetch` is given (or the
  user disabled automatic fetching in the web app; the preview then simply
  returns less data). Encrypted mode encrypts locally **after** the preview.
- `links list` returns `{"items": [...], "next_cursor": "..."}`. Items carry
  decrypted `url`/`title`/`description`; `category_id: null` is the
  uncategorized inbox. An undecryptable item is returned with `title: "🔒"` and
  `_decrypt_error: true`; the rest of the list still works.
- `links update` and `categories update` read the current row, send its
  `version` (and `content_version` when content changes) and retry once on a
  version conflict (40003). Ordering-only changes never re-encrypt content.
- `layout --file` accepts `{"layout_version": N, "categories": [{"id",
  "sort_order"}], "links": [{"id", "category_id", "sort_order"}]}`. Omit
  `layout_version` to use the current one; a conflict is retried once.
- `import` supports the product JSON export and Netscape bookmark HTML
  (Chrome/Edge/Firefox/Safari). Top-level bookmark folders become categories;
  nested folders are merged into the top-level one. Duplicates are detected by
  normalized URL on the client and skipped with `skipped_duplicate`;
  `--keep-duplicates` disables that check. Uploads are batched to at most 100
  rows per request.
- `export` writes a plaintext JSON file (`format: "liteprivatenav"`); warn the
  user explicitly and never commit or upload that file.
- A migration in progress blocks normal writes (server returns 40004); reads
  and exports still work, and mixed rows are decoded per-row by their
  `encryption` field.

## Python API

When running `liteprivatenav.py` as a script, Python puts the skill directory
on `sys.path`, so `import lite_crypto` works. When importing from another
directory, add the skill directory first:

```python
import sys
sys.path.insert(0, "/absolute/path/to/skills/liteprivatenav")

from liteprivatenav import LitePrivateNavClient, LitePrivateNavError

client = LitePrivateNavClient()          # reads ~/.lite-lake/lite-private-nav
client.login()                           # once per configuration / key change
client.categories()
client.links(limit=100)
client.create_link("https://example.com", category_id="<id>")
client.move_link("<link-id>", None)      # None = uncategorized
client.snapshot()
client.export_to_file("~/nav-backup.json")
```

Every return value is JSON-serializable. Business errors raise
`LitePrivateNavError` with `.code`, `.message`, `.http_status`, `.data` and
`.exit_code`.

## Error codes

| Code | Meaning | Agent action |
| --- | --- | --- |
| 40001 | Master password incorrect | Ask the user to check `master.key`; do not retry |
| 40002 | Vault not initialized | Ask the user to create the vault in the web app |
| 40003 | Version conflict | Re-read the row and retry once |
| 40004 | Migration in progress / mode invalid | Ask the user to finish the migration in the web app |
| 40005 | Quota exceeded | Report usage; suggest deleting data or upgrading |
| 40006 | Master password changed | Ask the user to update `master.key`, then `login` |
| 40007 | Busy / rate limited | Wait and retry later |
| 40008 | Forbidden | Report insufficient permission |
| 40009 | Invalid URL | Ask for a valid http(s) URL |
| 40010 | Metadata fetch rejected/failed | Continue with `--no-fetch` and a manual title |
| 40011 | Category not empty | Move or delete its links explicitly |
| 40012 | Import rejected / all skipped | Inspect `skipped_quota` / `skipped_duplicate` |
| 40101 | API key invalid or revoked | Ask the user to create a new key |
| 40102 | Scope insufficient | Write operations need a `read_write` key |
| 40103 | API key limit | Delete an old key in the web app |

Exit codes: `0` success; `2` usage/config error; `3` auth/config failure;
`4` quota/conflict/business rule; `5` network or server error.

## Security rules

- Never `cat`, echo, print or log `master.key`, the API key, the KEK, the DEK
  or `wrapped_dek`. Never place them in a model context or a chat message.
- Pass secrets only as file paths or stdin. Prefer `--api-key-stdin` and
  `--master-password-file`.
- The master password file is owned by the user: do not create it for them
  unless they explicitly ask, and never write the password into a command line.
- Destructive actions (`categories delete`, `links delete`, bulk changes)
  require explicit user confirmation and the `--yes` flag.
- Export files are plaintext. Warn before writing and do not upload them.
- `lite_crypto.py` uses table-based AES which is **not** strictly
  constant-time. The threat model is a trusted local machine; do not run the
  skill on a shared or untrusted host.
- Always use HTTPS for `--base-url` (plain http is refused unless the host is
  localhost).

## Update check

```bash
python3 liteprivatenav.py --version
curl -fsSL https://nav.litelake.cn/docs/skill.md | head -20
```

The guide shows `Current version: 1.0.0` and the sha256 of the three files.
If the published version is newer, re-run the three `curl` commands; config
and state are preserved. `doctor` also compares the local version with
`https://nav.litelake.cn/api/open/version` (`min_skill_version` / `protocol_version`) and
fails loudly instead of silently degrading.
