Skip to main content

PersonaSpec toolkit for LLM agents

Project description

larva

PersonaSpec toolkit for LLM agents. Validate, assemble, normalize, register, and resolve canonical persona specifications.

What larva Does

larva manages PersonaSpec — structured JSON definitions for AI agent personas. It provides:

  • Validate — schema + semantic checks on PersonaSpec JSON
  • Assemble — compose personas from reusable components (prompts, toolsets, constraints, models)
  • Register / Resolve — store and retrieve personas from a global registry (~/.larva/)
  • Clone / Update / Delete — full lifecycle management
  • Export — bulk export for integrations
  • MCP server — programmatic access for other tools

Install

pip install larva

Quick Start

# Register a persona
cat <<'EOF' > my-agent.json
{
  "spec_version": "0.1.0",
  "id": "code-reviewer",
  "description": "Reviews code for correctness and style",
  "prompt": "You are a senior code reviewer...",
  "model": "openai/gpt-5.4",
  "can_spawn": false,
  "side_effect_policy": "read_only"
}
EOF

larva validate my-agent.json
larva register my-agent.json
larva resolve code-reviewer

# List all personas
larva list

# Clone and experiment
larva clone code-reviewer code-reviewer-exp
larva update code-reviewer-exp --set model=openai/gpt-5.4-pro

# Export all
larva export --all --json

Interfaces

MCP Server (primary)

larva.validate(spec)              → ValidationReport
larva.assemble(components)        → PersonaSpec
larva.register(spec)              → {id, registered}
larva.resolve(id, overrides?)     → PersonaSpec
larva.list()                      → [{id, spec_digest, model}]
larva.update(id, patches)         → PersonaSpec
larva.clone(source_id, new_id)    → PersonaSpec
larva.delete(id)                  → {id, deleted}
larva.clear(confirm)              → {cleared, count}
larva.export(all?, ids?)          → [PersonaSpec, ...]
larva.component_list()            → {prompts, toolsets, constraints, models}
larva.component_show(type, name)  → component content

CLI

larva validate <spec.json> [--json]
larva register <spec.json> [--json]
larva resolve <id> [--override key=value]... [--json]
larva list [--json]
larva update <id> --set key=value [--set ...]  [--json]
larva clone <source-id> <new-id> [--json]
larva delete <id> [--json]
larva clear --confirm "CLEAR REGISTRY" [--json]
larva export --all [--json]
larva export --id <id> [--id <id>]... [--json]
larva assemble --id <id> [--prompt <name>]... [--toolset <name>]... [--constraints <name>]... [--model <name>] [--override key=value]... [--var key=value]... [-o output.json]
larva component list [--json]
larva component show <type>/<name> [--json]

Python Library

from larva.shell.python_api import (
    validate, assemble, register, resolve, list,
    update, clone, delete, clear,
    export_all, export_ids,
    component_list, component_show,
)

# Register
result = validate({"id": "my-agent", "spec_version": "0.1.0", "prompt": "..."})
register({"id": "my-agent", "spec_version": "0.1.0", "prompt": "..."})

# Resolve
spec = resolve("my-agent")

# Clone + update
clone("my-agent", "my-agent-exp")
updated = update("my-agent-exp", {"model": "openai/gpt-5.4-pro"})

# Export all
all_specs = export_all()

Component Library

~/.larva/
  components/
    prompts/           # Prompt text fragments (.md files)
    toolsets/           # Tool permission maps (.yaml)
    constraints/        # can_spawn + side_effect_policy (.yaml)
    models/             # Model + inference params (.yaml)
  registry/             # Registered PersonaSpec JSON files
# Assemble from components
larva assemble --id code-reviewer \
  --prompt code-reviewer --prompt careful-reasoning \
  --toolset read-only \
  --constraints strict \
  --model claude-opus

# Browse components
larva component list
larva component show prompts/code-reviewer

Web UI

A browser-based persona manager is included in contrib/web/:

pip install fastapi uvicorn
python contrib/web/server.py
# → opens http://localhost:7400

OpenCode Plugin

An OpenCode plugin that registers larva personas as agents:

// .opencode/opencode.json
{
  "plugin": ["file:///path/to/larva/contrib/opencode-plugin/larva.ts"]
}

See contrib/opencode-plugin/README.md for details.

Architecture

larva follows a strict layered architecture enforced by Invar:

Layer Path Rules
Core src/larva/core/ Pure logic, @pre/@post contracts, no I/O
Shell src/larva/shell/ I/O adapters, returns Result[T, E]
App src/larva/app/ Orchestration facade

Key Design Decisions

  • Composition, not inheritance. No base: field. Components are orthogonal building blocks.
  • Error-on-conflict. Two components setting the same scalar field → assembly fails. Use overrides.
  • Authority, not runtime. larva owns persona definitions; execution belongs elsewhere.
  • No cross-run mutable state. Persona changes require explicit register.

License

AGPL-3.0-or-later

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

larva-0.4.0.tar.gz (452.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

larva-0.4.0-py3-none-any.whl (80.7 kB view details)

Uploaded Python 3

File details

Details for the file larva-0.4.0.tar.gz.

File metadata

  • Download URL: larva-0.4.0.tar.gz
  • Upload date:
  • Size: 452.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for larva-0.4.0.tar.gz
Algorithm Hash digest
SHA256 089f60836a656dd0f7ddc0c9a1b8762cdd3d401d4e461d9e40bbf44cf867c6c7
MD5 9a7b5788e102281eb385e622fefe4af3
BLAKE2b-256 450cc0fdfd84b5c6db6b479debc430c996eb50db3bd32f436dd6500c4624c295

See more details on using hashes here.

Provenance

The following attestation bundles were made for larva-0.4.0.tar.gz:

Publisher: publish.yml on Tefx/larva

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

File details

Details for the file larva-0.4.0-py3-none-any.whl.

File metadata

  • Download URL: larva-0.4.0-py3-none-any.whl
  • Upload date:
  • Size: 80.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? Yes
  • Uploaded via: twine/6.1.0 CPython/3.13.7

File hashes

Hashes for larva-0.4.0-py3-none-any.whl
Algorithm Hash digest
SHA256 1561d8f03afeb388ed890f779e92e62c85c28caa3d4c79dc59906653aa0e28c7
MD5 4e92d1bc4ccbb64cd8f9a2340bdd8f43
BLAKE2b-256 a120222a8b1290dd741035beb42ea15cda1a0ce425ea83b64e770668a6aaa05a

See more details on using hashes here.

Provenance

The following attestation bundles were made for larva-0.4.0-py3-none-any.whl:

Publisher: publish.yml on Tefx/larva

Attestations: Values shown here reflect the state when the release was signed and may no longer be current.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page