Metadata-Version: 2.4
Name: mycelium-network
Version: 0.3.1
Summary: Biological AI core (semantic drag, ATP, neurochemistry, SomaticBudget, Halcyon memory) and specialized fruiting bodies (Lichen, Muscaria, Spore).
Author-email: Gordon Knot <a.edmark@gmail.com>
License-Expression: MIT
Project-URL: Homepage, https://github.com/aedmark/Mycelium
Project-URL: Repository, https://github.com/aedmark/Mycelium
Project-URL: Issues, https://github.com/aedmark/Mycelium/issues
Keywords: ai,ollama,llm,fastapi,sqlite,agent,interactive-fiction
Classifier: Development Status :: 4 - Beta
Classifier: Environment :: Web Environment
Classifier: Framework :: FastAPI
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.10
Classifier: Programming Language :: Python :: 3.11
Classifier: Programming Language :: Python :: 3.12
Classifier: Topic :: Scientific/Engineering :: Artificial Intelligence
Requires-Python: >=3.10
Description-Content-Type: text/markdown
License-File: LICENSE
Requires-Dist: fastapi
Requires-Dist: uvicorn
Requires-Dist: pydantic
Requires-Dist: pyyaml
Requires-Dist: numpy
Requires-Dist: ordvec>=0.5.0
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Dynamic: license-file

# 🍄 Mycelium Network

The extracted biological core and its specialized fruiting bodies, grown from the BoneAmanita monolith.

- **New here?** Follow the step-by-step [Live Trial Guide](docs/LIVE_TRIAL_GUIDE.md) to try every mode in ~15 minutes.
- **Want the architecture & rationale?** Open the [3x project manual](docs/manual.html) or the [documentation map](docs/README.md).

## Architecture
- **Mycelium (Core Chat · `/chat/`):** The shared biological core library—semantic physics with homeostasis, `SomaticBudget` & `PartnerState`, Lexical Firewall with 0 ms inline repairs and soft-crime salvage, `StageArbiter`, private bounded `/checkin`, 3-tier Memory Zones (`/remember`, `/consolidate`), `ordvec` semantic recall, credential intake screening, `ReceiptLedger` (`/api/diag`), Substrate Doctor, and Halcyon SQLite persistence.
- **Lichen (Adventure · `/lichen/`):** Text Adventure & Free Adventure with Cartographer mapping, single-custody containers, deterministic verbatim **Journal**, hidden Core-6 inline narrator tags, story-safe puzzle passwords (`in_story=True`), two-pass continuity + `/review`, and shared Stamina/Cortisol/Dopamine pacing.
- **Muscaria (Creative · `/muscaria/`):** Exploratory vs. directive creative posture, inline steering micro-tags (`[!r]`, `[!k]`, `[!l]`, `[!s]`), multi-modal image prompts (upload or `Ctrl+V` paste up to 4 images), soft-crime salvage, and Halcyon persistence.
- **Spore (Technical Kernel · `/spore/`):** Strict technical & code generation with prose-only code firewall, code-fence-safe low-ATP trimming, `POINT_OF_NO_RETURN` `/confirm` gate for irreversible commands, and opt-in jailed local workspace tooling (`SPORE_WORKSPACE`: `/ls`, `/read`, `/grep`, `/git status`, `/git diff`, `/patch` → `/confirm` with auto-rollback).

## Quick Start

Requires **Python 3.10+** and a local **[Ollama](https://ollama.com/)** instance listening on port `11434`.

### Install globally without cloning (recommended on Linux/Arch/macOS)

```sh
# Pull local models (+ optional embeddings for ordvec semantic recall)
ollama pull gemma4:12b
ollama pull nomic-embed-text

# Install isolated with uv (or pipx) — avoids PEP 668 system-Python conflicts
uv tool install mycelium-network
mycelium doctor
mycelium
```

*(Or install directly from `main`: `uv tool install "git+https://github.com/aedmark/Mycelium.git"`.)*

### Or run from a local git clone (development)

```sh
# 1. Create and activate a virtual environment, then install editable package + CLI
python3 -m venv .venv
source .venv/bin/activate
pip install -e .

# 2. Verify your local setup (Python, packages, SQLite, Ollama, models, embeddings)
mycelium doctor

# 3. Boot the Unified Hub (all 4 apps under one local server; add --workspace . for Spore sandbox)
mycelium --workspace .
```

*(You can also install with `pip install -r requirements.txt` and run `uvicorn hub:app --host 127.0.0.1 --port 8000` directly, or launch any single mode via `mycelium core`, `mycelium lichen`, `mycelium muscaria`, or `mycelium spore`.)*

Open [http://127.0.0.1:8000](http://127.0.0.1:8000). On first launch, the Hub checks Ollama, lets you assign installed models per app (check **Disable reasoning (`think: false`)** for Gemma 4), and saves your choices to `~/.config/mycelium/config.json`. You can switch models live from any app's sidebar dropdown, override via env vars (`MYCELIUM_MODEL`, `LICHEN_MODEL`, `MUSCARIA_MODEL`, `SPORE_MODEL`), or inspect health anytime via **Diagnostics** in the Hub topbar.

You can also run any single app standalone:
- Core Chat: `uvicorn mycelium.api:app --host 127.0.0.1 --port 8000`
- Lichen: `uvicorn lichen.api:app --host 127.0.0.1 --port 8000`
- Muscaria: `uvicorn muscaria.api:app --host 127.0.0.1 --port 8000`
- Spore: `uvicorn spore.api:app --host 127.0.0.1 --port 8000`

## Mode Highlights

- **Core Chat (`/chat/`):** Conversations save locally in `mycelium-chat.db` and resume across refresh or restart; **New chat** keeps older threads in **Saved chats**. Click **Check-in** (or `/checkin [2-12]`) for an ephemeral, low-pressure check-in that stays out of SQLite unless you explicitly click **Keep check-in** (`/checkin keep`). Click **Memories** (or use `/remember`, `/remember --global`, `/consolidate`, `/forget`) to inspect, pin, or delete distilled one-sentence sūtras.
- **Lichen (`/lichen/`):** Choose **Text Adventure** or **Free Adventure** in the browser. Both share Stamina, Cortisol, and Dopamine pacing and save locally in `lichen.db` (set `LICHEN_DB=other.db` for a separate campaign). Free Adventure keeps a verbatim **Journal** (`DOCS` / `QUOTES` / `CLUES` / `PACTS`) plus an optional **Show tagged spans** audit toggle. Use **Download chat snapshot** in any mapped room and **Attach Lichen snapshot** inside Core Chat (`/chat/`) to discuss your adventure with Core Chat.
- **Muscaria (`/muscaria/`):** Persists exchanges and vitals in `muscaria.db` (**New Session** resets cleanly). Prefix prompts with `[!r]` (riff), `[!k]` (tighten), `[!l]` (darker/stranger), or `[!s]` (sensory) to steer prose, and click **+ Image** or press `Ctrl+V` to attach up to four PNG, JPEG, WebP, or GIF images on vision-capable models like `gemma4:12b`.
- **Spore (`/spore/`):** Persists history and vitals in `spore.db`. Guards destructive operations (`git push --force`, `DROP TABLE`, `rm -rf`, `terraform destroy`, `deploy to prod`) behind `/confirm`. With `SPORE_WORKSPACE` set, inspects code strictly inside the jail (blocking traversal, symlink escapes, `.env*`, keys, `.db`, and credential dot-dirs) and stages surgical diffs in memory with `/patch` before applying on `/confirm` (with automatic rollback on failed `SPORE_VERIFY_CMD`).

## Quick Command Reference

| App | Commands |
| --- | --- |
| **Core Chat** | `/checkin [2-12]`, `/checkin end`, `/checkin keep`, `/remember [--global] <fact>`, `/memories`, `/forget <id\|all>`, `/consolidate` |
| **Lichen** | `look`, `inventory`, `take <item>`, `put <item> in <container>`, `set <item> down`, `/review`, `/pause` |
| **Muscaria** | `[!r]` (riff), `[!k]` (tighten), `[!l]` (darker), `[!s]` (sensory), `/remember`, `/memories`, `/forget`, `/consolidate`, `/rest` |
| **Spore** | `/ls [path]`, `/read <path> [start-end]`, `/grep <pat> [path]`, `/git status`, `/git diff [path]`, `/context clear`, `/patch <desc>`, `/confirm`, `/discard`, `/remember`, `/memories`, `/rest` |

## Testing & Diagnostics

```sh
pytest                           # 292 offline deterministic tests (no Ollama required)
python -m mycelium.doctor        # Live substrate check against local Ollama
python3 tools/check_docs.py      # Repository documentation & link verification
```
