Skip to main content

Visual Intent Contract Orchestrator: freeze project slices, evolve capsules, verify intent contracts.

Project description

Nexu

AI Cost Tracking

PyPI Version Python License AI Cost Human Time Model

  • 🤖 LLM usage: $2.1769 (20 commits)
  • 👤 Human dev: ~$840 (8.4h @ $100/h, 30min dedup)

Generated on 2026-05-31 using openrouter/qwen/qwen3-coder-next


NexuVisual Intent Contract Orchestrator.

Nexu is a Python package and CLI for creating small, isolated project capsules from a large codebase. It helps you freeze a baseline, extract a slice of code/data/contracts, evolve that slice through multiple LLM or human iterations, and verify the result against formal intent contracts before promoting it back.

The core workflow is:

freeze → capsule create → plan → blueprint → iterate → runtime → export-prompt → verify → report → promote

Nexu is designed to work with Intract-style intent contracts, but it can run as a standalone prototype. The goal is not to make an LLM magically correct. The goal is to keep the LLM inside a small, versioned, contract-bound sandbox and detect when its output diverges from declared intent.

Current status

The 0.5.x line includes capsule orchestration, MCP tools, live Cinema UI evolution and dynamic Intract validation:

  • capsule orchestrate creates an offline or optional LLM-assisted step-by-step capsule evolution plan,
  • orchestration writes orchestration.yaml, orchestration.md, orchestration-prompt.md and context YAML,
  • nexu mcp tools lists tools available to IDE/agent clients,
  • nexu mcp serve exposes Nexu operations through a conservative MCP-compatible stdio JSON-RPC service,
  • MCP exposes both dry-run promotion planning and an explicit apply tool,
  • Cinema assets are generated from package templates under src/nexu/templates/cinema/,
  • LLM network calls remain disabled unless explicitly allowed in nexu.yaml.

Why Nexu?

Long-running IDE prompting has a common failure mode:

large repo + vague task + many steps = context drift and hallucinated implementation

Nexu changes the operating model:

large repo
  ↓ freeze baseline
small capsule
  ↓ evolve only this capsule
verified result
  ↓ promote to the real project

Install locally

python -m venv .venv
. .venv/bin/activate
pip install -e .[dev]
nexu --help

First run

nexu init .
nexu freeze . --name baseline
nexu capsule create . --name menu-icons --domain menu --include "examples/frontend_view/src/**" --route /menu-icons
nexu capsule plan menu-icons --steps 10 --goal "Add preview, confidence and reason fields"
nexu capsule blueprint menu-icons --print
nexu capsule iterate menu-icons --steps 3 --goal "Add preview, confidence and reason fields"
nexu capsule runtime menu-icons
nexu capsule orchestrate menu-icons --steps 10 --goal "Add preview, confidence and reason fields"
nexu capsule export-prompt menu-icons
nexu capsule verify menu-icons
nexu capsule review menu-icons
nexu capsule report menu-icons
nexu capsule bundle menu-icons
nexu capsule diff menu-icons
nexu capsule drift menu-icons
nexu capsule promote menu-icons --dry-run

Key Features Added Recently

  • Secure Workspace Promotion: Support for applying capsule changes to the source workspace via the nexu capsule promote --apply command (and via the nexu_capsule_promote_apply MCP tool).
  • Dynamic Intract Policy Engine Integration: Runs the actual sibling intract package validations (including AST verification and contract compliance) during the capsule verify step to guarantee correctness.
  • Web App Dashboard Evolution Example: Fully details multi-stage sandbox visualization and evolution under examples/web_app_dashboard.
  • Web App Calculator Mock Example: Compares a simple arithmetic layout (S0) and a scientific layout (S2) under examples/web_app_calculator (evolving the calc capsule).
  • Web App Database Analytics Example: Showcases transition from raw SQL/NoSQL table logs to glassmorphic visual charts under examples/web_app_analytics.

Important folders

src/nexu/       Python package
docs/           documentation
examples/       runnable example projects
tests/          unit tests

Documentation

Start here:

Main commands

nexu init .
nexu freeze . --name baseline
nexu capsule create . --name my-slice --include "src/my_module/**"
nexu capsule list
nexu capsule status my-slice
nexu capsule blueprint my-slice
nexu capsule iterate my-slice --steps 10 --goal "Evolve final screen"
nexu capsule orchestrate my-slice --steps 10 --goal "Evolve final screen"
nexu capsule export-prompt my-slice
nexu capsule diff my-slice
nexu capsule review my-slice
nexu capsule bundle my-slice
nexu capsule drift my-slice
nexu capsule verify my-slice
nexu capsule review my-slice
nexu capsule bundle my-slice
nexu capsule promote my-slice --dry-run
nexu mcp tools
nexu mcp serve --path .

Verified examples

The local example smoke runner covers frontend_view, backend_service, vertical_slice and mcp_service:

python examples/run_examples.py

The calculator and dashboard examples can be run directly:

python examples/web_app_calculator/run.py
python examples/web_app_dashboard/run.py

The Pactown examples require uv, pactown and local ports to be free:

python examples/web_app_pactown_ecosystem/run.py
python examples/web_app_event_monitor/run.py
docker compose -f examples/web_app_event_monitor/docker/docker-compose.yml config --quiet

Quality checks

Use the lightweight local quality profile before changing release-facing code:

make quality

It runs tests, local Markdown link validation, source-level Intract checks, duplication scanning and the lint subset that is currently clean. For a full backlog-oriented report, use:

make quality-strict

The same fast profile is described in pyqual.yaml for tools that prefer declarative pipelines.

Cinema (LLM live mode)

To run Cinema with real LLM evolution:

  1. Add API key to .env in repo root:
OPENROUTER_API_KEY=...
  1. Enable network calls in workspace config (examples/web_app_calculator/workspace/nexu.yaml):
llm:
  allow_network_calls: true
  api_key_env: OPENROUTER_API_KEY
  1. Run Cinema iteration:
make cinema

Use the URL printed in the log (Live HTTP Server started for Nexu: http://127.0.0.1:…) — not a fixed port (8080 may be taken by another service).

Stop stale cinema servers before restarting:

make cinema-stop
make cinema

Useful helpers:

make cinema-open      # run and open current player URL
make cinema-restart   # stop old server and start fresh player
make cinema-repair    # re-inject runtime scripts into generated HTML files
NEXU_CINEMA_NO_OPEN=1 make cinema

Simple iteration flow (3 steps):

  1. Goal — type what you want (e.g. chemical calculator) → Add goalGenerate Options A–C.
  2. Compare — review Options A, B, C (workspace on the left stays unchanged).
  3. Promote & refine — click an option to save it to the workspace → drag on buttons (left = keep, right = remove) → Apply marks to workspace.

History & policy (bottom row, two columns): left — Change history with Restore UI + policy (rewinds HTML, ledger, and merges contracts into manifests); right — Policy contracts (baseline + active ledger lines, manifest actions). Use the URL from make cinema output, not a fixed port.

  1. Run tests:
make test
make ci-cinema-smoke   # nexu + sibling intract + cinema policy dry-run

You can override defaults from Makefile inline:

make cinema CINEMA_CAPSULE=scientific_calc CINEMA_PATH=examples/web_app_calculator/workspace

Model override (otherwise LLM_MODEL from workspace .env):

make cinema CINEMA_MODEL=openrouter/google/gemini-3.1-flash-lite-preview

License

Licensed under Apache-2.0.

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

nexu-0.5.14.tar.gz (3.1 MB view details)

Uploaded Source

Built Distribution

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

nexu-0.5.14-py3-none-any.whl (107.0 kB view details)

Uploaded Python 3

File details

Details for the file nexu-0.5.14.tar.gz.

File metadata

  • Download URL: nexu-0.5.14.tar.gz
  • Upload date:
  • Size: 3.1 MB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for nexu-0.5.14.tar.gz
Algorithm Hash digest
SHA256 f743bcfcc4bb8a6ffeb58e1766d00ccfaffa71c04bfea4f07ce79e1ec93eddcc
MD5 ce203d1469dbc6102d881dadaaaa63cc
BLAKE2b-256 24d05fba385550e4e2041f200272a68e3d3f9c15fdc29abe1df3dce0c2a73230

See more details on using hashes here.

File details

Details for the file nexu-0.5.14-py3-none-any.whl.

File metadata

  • Download URL: nexu-0.5.14-py3-none-any.whl
  • Upload date:
  • Size: 107.0 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.7

File hashes

Hashes for nexu-0.5.14-py3-none-any.whl
Algorithm Hash digest
SHA256 33a1540e9e8257cc7ff5acb4296a01a841cc583235078461f097e88e8a085c64
MD5 0f1bae78fa0bc911fc6842f903fbad4c
BLAKE2b-256 6821fa98b0b6f3cc4c3283e6f843b6f5a6d18b57d11ee0dc93cab670c5de3199

See more details on using hashes here.

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