Skip to main content
Pre-release

This release is a pre-release and may not be stable for production use.

Moiryx Code

Moiryx Code is a terminal interface for applications built with Moiryx. It provides the conversation UI, persistent sessions, context limits, compaction, cancellation, and JSONL output. Your handler decides which agents and tools to run.

This is an alpha release. Expect small API and configuration changes before the first stable version.

Install

Moiryx Code requires Python 3.11 or newer.

python -m pip install --pre moiryx-code

Try it without a model

The offline example uses a deterministic handler. It needs no API key, model, or network connection after installation.

git clone https://github.com/kamilsz713/moiryx-code.git
cd moiryx-code
python -m venv .venv

Activate .venv with source .venv/bin/activate on macOS or Linux, or with .venv\Scripts\Activate.ps1 in PowerShell. Then run:

python -m pip install -e .
python -m moiryx_code --cwd examples/offline_project

On Windows, run-offline.cmd can replace the last command.

Add it to a Moiryx project

Moiryx Code loads a handler from the extensions.code section of moiryx.yaml:

providers:
  local:
    type: openai_compatible
    base_url: http://127.0.0.1:8080/v1

models:
  chat:
    provider: local
    model: local-model

extensions:
  code:
    handler: app:handler
    state_dir: .moiryx/code
    session:
      context_budget_tokens: 32768
      auto_compact: false

The handler receives the current request and active conversation context. It returns an async stream of runtime events and must finish with Final.

from moiryx import Agent
from moiryx.messages import AssistantMessage, UserMessage
from moiryx_code import Context, Final, Request, Status


class Handler:
    def __init__(self) -> None:
        self.agent = Agent("agents/chat.md")

    async def __call__(self, request: Request, context: Context):
        history = [
            UserMessage(message.content)
            if message.role == "user"
            else AssistantMessage(message.content)
            for message in context.messages
        ]
        if context.summary:
            summary = UserMessage(f"Conversation summary:\n{context.summary}")
            history.insert(0, summary)

        yield Status(message="Thinking")
        answer = await self.agent(request.prompt, history=history)
        yield Final(content=str(answer))

    async def aclose(self) -> None:
        await self.agent.aclose()


handler = Handler()

Agent and tool lifecycle events emitted by Moiryx appear in the same event stream. Final is reserved for the handler response.

Sessions and context

Sessions are stored in SQLite under the configured state_dir. Raw messages are retained when context is cleared or compacted.

Automatic compaction requires a separate Moiryx agent:

extensions:
  code:
    handler: app:handler
    session:
      auto_compact: true
      context_budget_tokens: 32768
      compact_at: 0.72
      keep_recent_tokens: 12000
      compact_agent: agents/compact.md

Compaction runs before the next turn after the active context reaches the configured threshold. The recent tail remains verbatim; older messages are replaced in the active context by the summary.

Commands

Command Action
/new Start a new session
/resume ID Open a stored session
/sessions List stored sessions
/compact Compact the current context
/clear Clear active context without deleting history
/context Show estimated context use
/help Show the command list
/quit Exit

Typing / opens the command picker. Use the arrow keys to select an entry and Tab to complete it. Ctrl+C cancels a running turn and exits when idle.

For scripts and CI, run one prompt without the TUI:

moiryx-code --cwd path/to/project run "Inspect this repository" --jsonl

Development

python -m pip install -e ".[dev]"
python scripts/check.py
python -m build
python scripts/audit_artifacts.py dist

The shell tool provided by Moiryx is not a security sandbox. Only enable it for agents and workspaces you trust.

License

MIT

Release files for moiryx-code 0.1.0a1

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for moiryx-code 0.1.0a1
File Size Uploaded
moiryx_code-0.1.0a1.tar.gz 30.9 kB Details

Built distribution (wheel)

Table of built distributions (wheels) for moiryx-code 0.1.0a1
File Interpreter ABI Platform
moiryx_code-0.1.0a1-py3-none-any.whl Python 3 none any Details

Total release size: 57.5 kB

Release files / moiryx_code-0.1.0a1.tar.gz

Download URL moiryx_code-0.1.0a1.tar.gz
Size 30.9 kB
Tags Source
SHA-256 checksum
How to use checksums
b579b4c3354fdeede282b3131cf768dd69dd81855de4c2907eb2cf932b74dd0d
BLAKE2b-256 checksum
How to use checksums
80f45ad66c0f6ef763c8729399be33071bf58d407aad87ded75deee307ab2b00
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release files / moiryx_code-0.1.0a1-py3-none-any.whl

Download URL moiryx_code-0.1.0a1-py3-none-any.whl
Size 26.6 kB
Tags Python 3
SHA-256 checksum
How to use checksums
0bf3723bc04d7f0a55dd54e24406cce7a4c630e335a7990015726cdc10677700
BLAKE2b-256 checksum
How to use checksums
a3a12cb135b0d3c8201678553713d5e11eba69ed9714f2206142960d2ddee632
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
Yes
Uploaded via twine/7.0.0 CPython/3.13.14

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

PyPI Publish Attestation

PyPI verified that this artifact, at this checksum, originated from the publisher listed below.

Signed by GitHub Actions, verified by PyPI on Sep 26, 2026.

Transparency log

Release history Release notifications | RSS feed

This release

0.1.0a1 This release

2 release files

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page