Metadata-Version: 2.5
Name: dryv-jinja
Version: 0.1.0
Summary: Jinja rendering plugin for Dryv
License: Apache-2.0
Requires-Python: >=3.11
Requires-Dist: aiohttp<4,>=3.11
Requires-Dist: dryv-api==0.1.0
Requires-Dist: jinja2<4,>=3.1
Description-Content-Type: text/markdown

# Dryv Jinja Plugin

The Jinja plugin is the first runnable implementation of Dryv's shared template-server contract.

It uses the shared typed contract shapes under `engine/python/api/src/dryv_api/contracts/plugins/templates/`; it does not define a Jinja-specific competing contract.

## Analysis and context

Analysed: the server derives exact context requirements from a template snapshot, including `set` aliases, loops and includes. It reads the same context vocabulary as every analysed renderer; see `../_conformance/` for the shared proof.

## Structure

```text
src/dryv_jinja/
├── rendering/
│   ├── context.py
│   ├── configuration.py
│   └── renderer.py
├── server/
│   ├── app.py
│   ├── sessions/
│   ├── protocol/
│   └── transport/
└── cli/
    └── serve.py
```

`rendering/` owns Jinja execution only. `server/sessions/` owns explicit retained session/template state. `server/protocol/` is the only place raw network JSON is parsed or encoded. `server/transport/` exposes the HTTP and WebSocket endpoints. The CLI is only a small process entry point.

## Bootstrap descriptor

```yaml
apiVersion: dryv.server/v1alpha1
servers:
  - kind: TEMPLATE_SERVER
    name: jinja
    url: http://127.0.0.1:8765
    command:
      - dryv-jinja
      - serve
```

The running server reports its runtime identity, version, protocol version, readiness, capabilities, session URL, and WebSocket URL from `GET /`.

## Run

From this package after installing/syncing its dependencies:

```bash
dryv-jinja serve
```

The lightweight command also accepts `--host` and `--port`. The Dryv API can execute the descriptor's `command` when the configured local server is not already reachable.

## Protocol flow

```text
GET /
  ↓
POST /sessions with client_id
  ↓
server creates session_id
  ↓
WebSocket /ws
  ↓
session.attach
  ↓
template.put
  ↓
render.file
  ↓
file.started
file.chunk ...
file.completed | file.failed
  ↓
session.close
  ↓
retained templates/session state removed
```

Templates are retained only inside their explicit session. A `file_id` is correlation identity, never an output path. The server does not choose templates, construct Dryv semantic context, decide output paths, inspect projects, or write user files.

## Jinja configuration

Per-file `configuration` currently supports only explicit Jinja runtime options:

- `undefined`: `default` or `strict`
- `autoescape`: boolean
- `trimBlocks`: boolean
- `lstripBlocks`: boolean
- `keepTrailingNewline`: boolean

Unknown configuration fields fail the render instead of being silently guessed or ignored. When an option is omitted, the corresponding native Jinja default is preserved.
