How tene-ai/tene works
1. Repo shape: two major products in one monorepo.
The core product is a Go CLI (cmd/tene, internal, pkg) that manages encrypted secrets locally. In parallel, apps/web is a Next.js/TypeScript marketing and documentation site with blog, comparison pages, SEO/AI-discoverability assets, and interactive product content.
2. CLI entrypoint and command boundary.
cmd/tene/main.go is the executable entrypoint. The CLI is built around Cobra-style command dispatch in internal/cli, where each command maps to a user-facing operation such as init, set, get, run, list, delete, import, export, passwd, recover, env, audit, and permissions.
3. Core secret storage pipeline.
The storage path is: command input → CLI layer → vault/crypto layer → local encrypted vault.
Secret data is stored in a local SQLite-backed vault (internal/vault, internal/encfile) and encrypted with the crypto primitives in pkg/crypto. The README and code layout indicate the vault is local-first and offline by default, with no server required for the CLI.
4. Crypto and key-management subsystem.
pkg/crypto contains the cryptographic boundary: encryption/decryption, key derivation, key rotation, X25519/team-key helpers, and memory zeroing. The design centers on a master password → Argon2id-derived key → XChaCha20-Poly1305-encrypted vault. This is the main security boundary in the repository.
5. OS keychain and recovery flow.
The master key is cached in the native OS keychain via internal/keychain / go-keyring, with a fallback/null-store path for non-interactive or unsupported environments. Recovery is handled by internal/recovery, which uses a 12-word mnemonic to restore access if the master password is lost.
6. Runtime injection is the key “AI-safe” workflow.
The most important execution path is tene run -- <cmd>: secrets are decrypted only long enough to be injected into the child process as environment variables, then the AI/editor process runs without seeing plaintext in the repo context. This is the product’s core differentiation: secrets are used at runtime, not exposed to the assistant or file system.
7. Environment and multi-vault separation.
The CLI supports named environments (dev, staging, prod, etc.) through internal/vaultcfg and environment-aware command handling in internal/cli. That means the same secret name can exist in multiple isolated environments, and command behavior is scoped by the active or explicitly selected environment.
8. Permissions and safety gates.
internal/auth and the CLI permission tables classify commands into tiers such as metadata-only, secret-write, and secret-read. The repo enforces this as an architectural guardrail: some commands can run without unlocking, while value-revealing actions require explicit trust/password handling. There are also safety checks around stdout leakage and delete/get behavior.
9. Audit, sync, and cloud are present but partially gated.
The codebase includes internal/audit, internal/sync, and internal/auth, plus command files for login, push, pull, sync, team, and billing. However, the README says these cloud features are currently disabled in the released CLI, so architecturally they form a latent cloud subsystem rather than the active local-first path. That boundary matters when diagramming what is live versus planned.
10. Generated AI-editor context files are a first-class output.
tene init does more than create a vault: it generates editor-specific guidance files such as CLAUDE.md, .cursor/rules/tene.mdc, .windsurfrules, GEMINI.md, and AGENTS.md. This is an important output boundary because it bridges the CLI with AI coding tools and affects how the product is discovered and used by agents.
11. Web app is a separate presentation/runtime stack.
apps/web is a Next.js app that serves the public site, blog, comparison pages, CLI docs, RSS/sitemap/robots, and structured SEO metadata. It is largely content-driven: MDX blog posts, static data modules, and reusable UI components. It has its own runtime, build pipeline, and asset set, independent of the Go CLI.
12. Discoverability and agent-facing content extend beyond the app.
The repo contains llms.txt, .well-known/ai.json, skills/tene-cli, and a large examples/demo tree. These are not product runtime paths, but they are part of the architecture because they shape how AI agents and humans learn, validate, and adopt the CLI. They act as documentation, evaluation, and onboarding layers.
13. Build, release, and distribution are standard but important.
The repo uses GitHub Actions (.github/workflows), Go tooling (golangci-lint, goreleaser, Makefile), and a Dockerfile. For the CLI, distribution is via Go binaries and GitHub Releases; for the website, deployment is a separate Node/Next.js concern. The architecture is therefore split across two deployable surfaces: a CLI binary and a web frontend.
14. Overall data-flow summary.
The main flow is: user command → CLI orchestration → permission check → key retrieval/derivation → vault read/write → output or subprocess injection. The web side flows separately from content/data modules → Next.js rendering → static/interactive site output. There is no default backend service in the active CLI path; the repository’s architecture is intentionally centered on local execution, encrypted storage, and AI-safe runtime injection.
Main entry points: cli User commands · vault.go Vault store · root.go CLI dispatch · run.go Runtime inject
Components 21
Go CLI
Local-first secret manager and runtime injection product.
- tene · Go CLI executable entrypoint.
cmd/tene/main.go - CLI dispatch · Cobra-style root command and shared command wiring.
internal/cli/root.go - User commands · Core user actions such as init, set, get, run, list, delete, import, export, passwd, recover, env, audit, and permissions.
internal/cli - Runtime inject · Decrypts secrets briefly and injects them into child process environment variables.
internal/cli/run.go - Init flow · Initializes vault and generates AI/editor guidance files.
internal/cli/init.go - Permissions · Command tiering and unlock requirements for metadata, write, and read operations.
internal/auth/permissions.go - Environments · Named environment selection and multi-vault scoping.
internal/vaultcfg/vaultcfg.go
Security core
Crypto, vault, keychain, and recovery boundaries.
- Vault store · Local encrypted vault persistence and schema/migration layer.
internal/vault/vault.go - Encfile · Encrypted local vault file handling.
internal/encfile/encfile.go - Crypto · Encryption, decryption, KDF, rotation, team keys, X25519, and memory zeroing.
pkg/crypto - Keychain · Native OS keychain cache with fallback and null-store paths.
internal/keychain/keychain.go - Recovery · 12-word mnemonic based account recovery path.
internal/recovery/recover.go
Cloud latent
Disabled or gated sync and account features.
- Audit log · Audit collection and reading for secret activity and events.
internal/audit/manager.go - Sync engine · Conflict handling, merging, envelopes, and queueing for latent cloud features.
internal/sync/engine.go - Cloud commands · Login, push, pull, sync, team, billing, and related cloud surfaces that are currently disabled or gated.
internal/cli/cloud_disabled.go
Web app
Next.js marketing, docs, blog, and comparison site.
- Web site · Public marketing, docs, blog, comparison pages, and SEO routes.
apps/web/src/app - Content data · Blog posts, comparison data, FAQs, pricing, and static content modules.
apps/web/content - UI components · Reusable site, blog, comparison, SEO, and interactive UI components.
apps/web/src/components - SEO assets · robots, sitemap, RSS, llms.txt, ai.json, and structured metadata outputs.
apps/web/public
AI onboarding
Repo-wide agent guidance, discoverability, and demos.
- Agent docs · Repo guidance, skills, examples, and generated editor instructions for AI tools.
skills/tene-cli - Demo flows · End-to-end scripted demos showing setup, recovery, multi-env, and AI-safe usage.
examples/demo
Connections 23
- tene → CLI dispatch: starts · Executable enters CLI command dispatch.
- CLI dispatch → User commands: routes · Root command exposes user-facing operations.
- User commands → Permissions: checks · Commands are classified by permission tier and unlock requirements.
- User commands → Environments: scopes · Commands resolve the active named environment.
- User commands → Vault store: reads/writes · Secret operations flow into the local vault layer.
- Vault store → Encfile: persists · Vault data is stored through encrypted file handling.
- Encfile → Crypto: encrypts · Encrypted vault content depends on crypto primitives.
- Vault store → Keychain: caches · Master key material is cached in the OS keychain when available.
- Keychain → Crypto: unwraps · Cached key material is tied to derived crypto keys.
- User commands → Recovery: restores · Recovery command path rebuilds access from mnemonic.
- Recovery → Crypto: derives · Recovery reconstitutes access keys used by the crypto boundary.
- Runtime inject → Vault store: loads · Run path retrieves secrets just before execution.
- Runtime inject → Permissions: guards · Runtime injection requires the appropriate read permission.
- Runtime inject → CLI dispatch: spawns · After injection, the child process executes outside the CLI.
- Init flow → Agent docs: generates · Init creates editor guidance and agent-facing files.
- Cloud commands → Audit log: includes · Cloud surface contains audit-related functionality.
- Cloud commands → Sync engine: includes · Cloud surface contains sync-related functionality.
- Cloud commands → CLI dispatch: registered by · Cloud commands are part of CLI dispatch but are gated or disabled.
- Web site → Content data: renders · Next.js routes are driven by content and data modules.
- Web site → UI components: composes · Pages are assembled from reusable UI components.
- Web site → SEO assets: publishes · Site output includes discoverability and indexing assets.
- Agent docs → Demo flows: documents · Skill and repo guidance are reinforced by scripted demos.
- SEO assets → Agent docs: supports · Discoverability assets help humans and agents find and use the CLI.