22 KiB
AGENTS.md — Relicario (OpenCode-native)
This is the OpenCode-native root guide. Sections 2–11 mirror
CLAUDE.md's project-context sections and are kept in sync with it (see the AGENTS.md↔CLAUDE.md sync rule under "Living docs — update discipline"). The "Execution layer" section below replaces the Claude-native release workflow with OpenCodeulwworkstreams.
Working with the user
- Default to "yes" / the recommended option. When asking the user a multiple-choice or yes/no decision, pick the recommended answer and proceed without prompting. Optional follow-ups in checklists: do them. Subagent dispatch / running tests / writing code: proceed without checking.
- Always pause and ask before:
rm,rm -rf,git push --force,git reset --hard,git branch -D, deleting files via Bash, dropping tables, force-pushing to main. The system-prompt's "executing actions with care" guidance still applies — this preference does not override that. - This rule does not override genuine intent-discovery: brainstorming-skill clarifying questions about what to build still need user input, because picking a default would mean designing the wrong product.
- Sprinkle Mexican Spanish into replies. Drop 1–2 Spanish words, slang, exclamations, or idioms per reply (replies only — never in code, file contents, commit messages, or other project artifacts), each followed by
[translation]in square brackets. Mexican flavor is preferred: ¡órale! [alright!], ¡híjole! [yikes!], ¿qué onda? [what's up?], chido [cool], ahorita [right now / in a bit], no manches [no way], ni modo [oh well], no hay bronca [no problem], ¡ya estuvo! [it's done], etc. Skip in one-word acknowledgements where the flourish would feel awkward. - Finishing a development branch: default to push and create a Pull Request. This is the user's preferred integration path; offer it as the recommended option without requiring re-confirmation each time.
What is this
Relicario is a git-backed, self-hostable password manager with a Rust core. Two-factor vault decryption: passphrase + a reference JPEG carrying a 256-bit secret embedded via DCT steganography. The server only ever sees opaque ciphertext. The second factor is pluggable — a reference image (stego JPEG) or a plain armored .relkey key file — both deliver the same 32-byte secret to the KDF.
Build and test
cargo build # build everything
cargo test # run all tests (unit + integration)
cargo test -p relicario-core # core library tests only
cargo test -p relicario-cli --test basic_flows # CLI integration tests
cargo build -p relicario-wasm --target wasm32-unknown-unknown # WASM target
cargo run -p relicario-cli -- --help # CLI help
cargo run -p relicario-cli -- generate --length 32 # quick smoke test
Project structure
crates/
├── relicario-core/ # Platform-agnostic library (no filesystem, no git, no network)
│ ├── src/
│ │ ├── lib.rs # Re-exports public API
│ │ ├── error.rs # RelicarioError enum (thiserror)
│ │ ├── crypto.rs # Argon2id KDF (length-prefixed, Zeroizing) + XChaCha20-Poly1305
│ │ ├── ids.rs # ItemId, FieldId, content-addressed AttachmentId
│ │ ├── time.rs # now_unix, MonthYear
│ │ ├── base32.rs # RFC 4648 base32 codec (no-padding, lenient input) for recovery-QR
│ │ ├── mime.rs # Tiny extension → MIME map for attachment types
│ │ ├── item_types/ # per-type cores + ItemType/ItemCore enums (login, card, identity, document, secure_note, key, totp)
│ │ ├── item.rs # Item envelope, Field, FieldKind, FieldValue, Section
│ │ ├── attachment.rs # AttachmentRef, EncryptedAttachment, encrypt/decrypt helpers
│ │ ├── manifest.rs # Browse-without-decrypt index (schema_version 2)
│ │ ├── settings.rs # VaultSettings: retention, generator defaults, caps
│ │ ├── generators.rs # CSPRNG password + BIP39 + zxcvbn gate
│ │ ├── vault.rs # JSON ↔ AEAD wrappers for Item/Manifest/VaultSettings
│ │ ├── imgsecret.rs # DCT steganography (MAX_DIMENSION cap)
│ │ ├── keyfile.rs # .relkey armor for the pluggable second factor (32-byte secret)
│ │ ├── recovery_qr.rs # Recovery-QR envelope (XChaCha20-Poly1305 over second-factor secret)
│ │ ├── device.rs # Device identity: ed25519 keypairs in OpenSSH format, signing/verification
│ │ ├── org.rs # Org vault types, crypto, and schema for multi-user self-hosted deployments
│ │ ├── backup.rs # Encrypted, compressed single-file vault archive (.relbak container)
│ │ ├── tar_safe.rs # Safe tar unpacking for backup restore (path-traversal guards)
│ │ └── import_lastpass.rs # LastPass CSV importer
│ └── tests/ # integration, attachments, generators, format_v2, field_history, org, backup, recovery_qr, import_lastpass, safe_unpack
├── relicario-cli/ # `relicario` binary
│ ├── src/main.rs # clap surface + dispatcher (handlers live under src/commands/)
│ ├── src/helpers.rs # vault_dir, git_command, iso8601
│ ├── src/session.rs # UnlockedVault (master key in Zeroizing)
│ ├── src/device.rs # Local device key storage and git signing configuration
│ ├── src/gitea.rs # Gitea API client for deploy key management
│ ├── src/org_session.rs # Unlocked org vault session (org master key for one CLI invocation)
│ ├── src/parse.rs # Thin shims over migrated core parsers (time, base32, mime)
│ ├── src/prompt.rs # Interactive prompt helpers (prompt_secret, prompt_keep, prompt_yesno)
│ ├── src/commands/ # Per-command modules — one file per top-level subcommand
│ │ ├── mod.rs # Command module root; main.rs dispatches into the subcommands here
│ │ ├── init.rs # relicario init — bootstrap a fresh vault
│ │ ├── add.rs # relicario add <kind> — create a new typed item
│ │ ├── edit.rs # relicario edit <query> — interactive per-type field editing with history
│ │ ├── get.rs # relicario get — print one item, masking secrets unless --show
│ │ ├── list.rs # relicario list + relicario history — read-only browse paths
│ │ ├── generate.rs # relicario generate — fresh password or BIP39 passphrase
│ │ ├── rate.rs # relicario rate — zxcvbn passphrase scoring
│ │ ├── trash.rs # trash umbrella: rm, restore, purge, list, empty
│ │ ├── attach.rs # relicario attach / attachments / extract / detach — per-attachment ops
│ │ ├── sync.rs # relicario sync — git pull --rebase + push
│ │ ├── status.rs # relicario status — vault summary (counts, last commit, last backup)
│ │ ├── settings.rs # relicario settings {show, trash-retention, history-retention, attachment-cap, generator-defaults}
│ │ ├── backup.rs # relicario backup export / restore — .relbak envelope
│ │ ├── recovery_qr.rs # relicario recovery-qr {generate,unwrap} — last-resort escape hatch
│ │ ├── device.rs # relicario device {add, revoke, list} — device key management
│ │ ├── org.rs # relicario org subcommands — multi-user org vault management
│ │ ├── import.rs # relicario import — currently LastPass CSV only
│ │ └── item_build.rs # Shared per-type item construction + interactive editing (add/edit/org)
│ └── tests/ # basic_flows, edit_and_history, attachments, settings, vault_detection, keyfile_flows, smart_inputs, backup, import_lastpass, org_items, org_authz, org_init, org_init_signing, org_lifecycle + common/mod.rs
├── relicario-wasm/ # WASM bindings for the extension
│ ├── src/lib.rs # #[wasm_bindgen] surface
│ ├── src/session.rs # opaque SessionHandle → Zeroizing<[u8;32]>
│ └── src/device.rs # WASM device key management — private keys never cross to JS
└── relicario-server/ # `relicario-server` binary (pre-receive Git hook)
├── src/main.rs # verify-commit + generate-hook subcommands
└── src/lib.rs # Pure helpers (path classification etc.) for hook unit tests
Key design decisions
- relicario-core is bytes-in/bytes-out. No filesystem, no network, no git operations. Makes it portable to WASM, Android, iOS.
- XChaCha20-Poly1305 over AES-GCM — 192-bit nonce eliminates collision risk, fast in WASM/ARM without AES-NI.
- Single master_key (no per-entry subkeys) — simpler, sufficient for family vault sizes.
- imgsecret uses central-embed DCT — embeds only in the middle 70% of the image (15% crumple zone for crop tolerance), with majority voting across 5-50 redundant copies.
- QUANT_STEP = 50.0 — higher than typical (25) to survive JPEG recompression down to Q85.
- Device ed25519 keys are separate from the KDF. Revoking a device doesn't require rotating the passphrase or reference image.
Crypto pipeline
passphrase (UTF-8 bytes) || image_secret (32 bytes from reference JPEG)
→ Argon2id(salt=vault_salt, m=64MiB, t=3, p=4)
→ master_key (32 bytes)
→ XChaCha20-Poly1305(nonce=random 24 bytes)
→ encrypted Item/Manifest/VaultSettings
Conventions
- Tests use fast Argon2id params (m=256, t=1, p=1) so they don't take forever.
- Test JPEGs are generated synthetically via
make_test_jpeg()— no binary test fixtures. - Item IDs and Field IDs are random 16-char hex strings (64 bits of OsRng entropy). AttachmentIds are content-addressed: first 32 hex chars of SHA-256 over the plaintext (128 bits).
- Git history is preserved as an audit log — no squashing.
- The CLI shells out to
gitfor sync — no libgit2/gitoxide dependency.
Remote
Source code: ssh://git@git.adlee.work:2222/alee/relicario.git
Planning & design specs
Before starting any planning or implementation task, search docs/superpowers/specs/ for a spec covering the feature area, and docs/superpowers/plans/ for any existing implementation plan. The specs are the authoritative design record; plans track per-milestone implementation details. Once a plan exists, execute it via the OpenCode execution layer (see Execution layer below).
Product gate. After brainstorming a new release spec — before handing it to planning — run /product-expert review <spec-path> for a product/market-fit gut-check (PROCEED / RESCOPE / CUT / PIVOT). The product-expert skill also runs standalone (/product-expert) any time you want to audit the whole roadmap and get PM-ready directives for modifications or pivots; add deep for live competitive web research. It only advises — you stay the decision-maker.
Core references (read before touching crypto, data model, or architecture):
docs/superpowers/specs/2026-04-11-relicario-design.md— threat model, entropy analysis, crypto pipeline, crate layoutdocs/superpowers/specs/2026-04-18-relicario-typed-items-design.md— typed-item data model and envelopedocs/superpowers/specs/2026-04-30-relicario-fullscreen-ux-redesign-design.md— fullscreen UX phase plan
After completing any dev iteration, update STATUS.md to reflect what shipped and what's now in flight. Update the component doc for any area you changed (see table below).
Execution layer (OpenCode ulw workstreams)
This section replaces the Claude-native release workflow referenced in CLAUDE.md (the legacy .claude/workflows/release.js + multi-agent relay in tools/relay/). OpenCode agents MUST NOT attempt to invoke the Claude release.js workflow or the relay mechanism — those are Claude-Code-specific assets and are not wired into OpenCode. Use the OpenCode skills below instead.
Activity → OpenCode tooling map
| Activity | OpenCode skill | Notes |
|---|---|---|
| Plan before coding (explorer-grounded, decision-complete) | /ulw-plan |
Prometheus planning consultant; produces ONE work plan a worker executes with zero further interview. Triggers: "plan this", "plan before coding", interview me, break this down. |
| Maximum-saturation deep research | /ulw-research (alias /ultraresearch) |
Parallel explore+librarian swarms across codebase, web, docs, OSS. Only activates on explicit user demand for research. |
| Execute a single plan (sequential) | /start-work |
Sisyphus execution from a Prometheus plan; Boulder state, evidence ledger, worktree discipline. Also /ulw-loop for the ultrawork loop variant that continues until completion. |
| Parallel streams (PM + devs) | /multi-agent-kickoff |
Generates kickoff prompts for PM + 2+ senior-dev sessions, each in its own feature branch + worktree, coordinating via user-relayed status/directive/question blocks. This is the OpenCode equivalent of the old multi-mode relay. |
| Post-implementation review | /review-work |
5 parallel background sub-agents: goal/constraint verify, code quality, security, hands-on QA, context mining. All must pass for review to pass. MUST USE after any significant implementation work. |
| Git operations (commits, rebase, squash, history search) | /git-master |
Atomic commits, blame, bisect, git log -S/-G. Use for ANY git work — do not hand-roll commits. |
| Debugging (crashes, silent failures, stuck processes, reverse engineering) | /debugging |
Hypothesis-driven loop: ≥3 hypotheses, parallel investigation, Oracle escalation after 2 failed rounds, root-cause lock with failing test, minimal fix. The HOW lives in references/. |
| Security review / vulnerability audit | /security-research (alias /security-review) |
3 vulnerability hunters + 2 PoC engineers; proves exploitability, classifies root causes, calibrates severity. |
| Frontend / UI / UX / visual polish | /frontend |
Design-taste router, brand references, Playwright/Lighthouse/Core Web Vitals, accessibility. Use for any work in extension/ or other web UI. |
| Visual QA after UI changes | /visual-qa |
Screenshot/TUI evidence + diff scripts; design-system + visual-fidelity reviewer passes. |
| LSP setup for a language | /lsp-setup |
Wires diagnostics, go-to-definition, find-references, rename. Run when "no LSP server configured". |
| Code cleanup (AI slop removal) | /remove-ai-slops |
Locks behavior with regression tests first, then categorized cleanup in batches of 5. |
Execution defaults
- Single-plan work →
/start-work(or/ulw-loopfor the long-running ultrawork variant). One agent works through tasks sequentially; updatesSTATUS.mdon completion. - Multi-plan or multi-phase work →
/multi-agent-kickoff. Generates the PM/Senior-Dev kickoff prompts with branch + worktree setup. Run the kickoff in parallel terminal windows; PM supervises devs. - Before planning → search
docs/superpowers/specs/+docs/superpowers/plans/first (see Planning section above); spot-checkgit log --oneline --all --grep <distinctive-name>or grep for a distinctive symbol/file the plan would create before re-executing a plan whose checkboxes are all unchecked. A plan whose work already merged is the worst kind of plan to re-execute. - Debugging → always
/debugging. Never hand-fix without at least trying the debug loop first. - After implementation → always
/review-workbefore declaring a task done. - Frontend / extension UI work → always
/frontendwhile building and/visual-qaafter.
Roadmap & status
Current in-flight work: STATUS.md. Full roadmap with release targets: ROADMAP.md. User-facing release history: CHANGELOG.md. Wire format reference: docs/FORMATS.md.
Living docs — update discipline
| File | What it documents | Update when... |
|---|---|---|
AGENTS.md |
OpenCode-native root guide; mirrors CLAUDE.md sections 2–11 + OpenCode execution layer |
When CLAUDE.md project-context sections change (sync both in same commit), or when OpenCode execution tooling changes |
CLAUDE.md |
Claude-Code-native root guide; project context + Claude release workflow | When project context changes — if the change is project-context (sections 2–11), mirror to AGENTS.md in the same commit |
DESIGN.md |
Cross-codebase structure: four codebases, contracts, secrets map, build matrix, test strategy | Adding a codebase, changing inter-codebase contracts, new build targets |
docs/CRYPTO.md |
Crypto pipeline diagrams, vault creation/unlock flows, DCT embedding, encrypted file format | Changing crypto primitives, format version byte, or file format |
crates/relicario-core/ARCHITECTURE.md |
Module map, invariants, key flows, test architecture for relicario-core |
Adding/changing modules, item types, or crypto invariants in core |
crates/relicario-cli/ARCHITECTURE.md |
Module map, invariants, key flows (init, unlock, all commands) for relicario-cli |
Adding/changing CLI commands, helpers, or session behavior |
extension/ARCHITECTURE.md |
Bundle structure, SW↔popup contract, component architecture | Adding bundles, changing the SW message protocol, or major UI flows |
docs/SECURITY.md |
Threat model, device auth, env-var trust surface | Adding env vars, changing auth model, new security-relevant config |
docs/FORMATS.md |
Wire formats: .enc blobs, params.json, devices.json, manifest schema |
Changing any serialized format, version number, or on-disk layout |
STATUS.md |
In-flight work, recent landings, what's next | End of every dev iteration |
ROADMAP.md |
Full roadmap with release targets | When milestones shift or new work is scoped |
CHANGELOG.md |
User-facing release history | When tagging a release |
Discipline rules
Six rules to prevent the kind of drift the 2026-05-30 audits found:
-
Scope-boundary check. When editing a tour doc, verify the change fits the doc's scope header. If it doesn't, the change belongs in a different doc — move it instead of stretching the scope. Concretely: a sentence about crypto added to
DESIGN.mdbelongs indocs/CRYPTO.md; a wire-format table added todocs/CRYPTO.mdbelongs indocs/FORMATS.md. -
Code-constant pinning. When a tour doc cites a code constant (
VERSION_BYTE = 0x02,QUANT_STEP = 50.0,MIN_COPIES = 5,MANIFEST_SCHEMA_VERSION = 2, etc.), the doc must cite the source file + line. When the underlying constant changes, grep for the citation pattern and update the docs together with the code change in the same commit. Most drift the audit found was code-constant drift — this rule attacks it at the source. -
New-doc rule. When adding a tour doc, also update (a)
DESIGN.md's code-map, (b) the reading-order sequence (the "Next:" footer chain), and (c) the living-docs table above. A new doc that doesn't appear in all three is not done. -
Plan-state hygiene. Plan checkboxes and
STATUS.md/ROADMAP.mdmust reflect what's actually shipped. Two halves:- Ship side: when a commit lands work that maps to a plan task, tick that plan's checkboxes in the same commit (or the immediately-following docs commit). Same for
STATUS.md— the "Up next" list does not get to lag the actual state ofmainby weeks. - Execute side: before starting execution of a plan whose checkboxes are all unchecked, spot-check git log (
git log --oneline --all --grep <distinctive-name>) or grep for a distinctive symbol/file the plan would create. A plan whose work already merged is the worst kind of plan to re-execute. The 2026-05-30 status-audit found Phase 2B, v0.5.1 Streams A/B/C, and 1C-γ all stealth-shipped two-to-three weeks earlier because nobody ran this check.
- Ship side: when a commit lands work that maps to a plan task, tick that plan's checkboxes in the same commit (or the immediately-following docs commit). Same for
-
Pre-flight before execution. Before running
/start-work(or/ulw-loop) on any plan, confirm the baseline is green:cargo build && cargo testpasses, and the working tree is clean. If the baseline is red or there's an uncommitted WIP, fix that first. Orphaned worktrees or partially-done plans require a judgement call — acknowledge them explicitly before proceeding. -
Cleanup after every lift. Once all PRs for a release are merged into main, remove the lift's worktrees and feature branches (use
/git-masterfor the branch deletion). Stale worktrees accumulate silently and create confusion for the next lift's branch-collision check.
AGENTS.md ↔ CLAUDE.md sync rule
AGENTS.md mirrors CLAUDE.md's sections 2–11 (project-context). When those sections change in either file, update BOTH in the same commit. The two root docs share the same project-context spine — Working with the user, What is this, Build and test, Project structure, Key design decisions, Crypto pipeline, Conventions, Remote, Planning & design specs, Roadmap & status, Living docs discipline. They diverge only in execution-layer terminology: CLAUDE.md documents the Claude-Code-native release workflow (.claude/workflows/release.js + tools/relay/), while AGENTS.md documents the OpenCode ulw workstreams (see Execution layer above). A change to any shared section that lands in one file without a matching change in the other is the exact drift pattern the 2026-05-30 audits found — and the exact failure pattern Stream A of the refactor-docs-tests task fixed. Do not let them diverge.