Metadata-Version: 2.4
Name: hyjinx
Version: 1.2.5
Summary: A minimal Hy utility library, using mostly the standard libraries.
Author-email: Ati Sharma <ati+hyjinx@agalmic.ltd>
License: MIT License
        
        Copyright (c) 2024 the authors.
        
        Permission is hereby granted, free of charge, to any person obtaining a
        copy of this software and associated documentation files (the "Software"),
        to deal in the Software without restriction, including without limitation
        the rights to use, copy, modify, merge, publish, distribute, sublicense,
        and/or sell copies of the Software, and to permit persons to whom the
        Software is furnished to do so, subject to the following conditions:
        
        The above copyright notice and this permission notice shall be included in
        all copies or substantial portions of the Software.
        
        THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
        IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
        FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT.  IN NO EVENT SHALL
        THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
        LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING
        FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER
        DEALINGS IN THE SOFTWARE.
        
Project-URL: Repository, https://github.com/atisharma/hyjinx
Keywords: hy,hylang,utilities,zeromq,llm,openai,anthropic
Classifier: License :: OSI Approved :: MIT License
Classifier: Programming Language :: Python :: 3
Classifier: Programming Language :: Python :: 3.13
Classifier: Programming Language :: Python :: 3.14
Classifier: Programming Language :: Lisp
Classifier: Programming Language :: Hy
Classifier: Topic :: Software Development :: Libraries
Classifier: Topic :: Utilities
Requires-Python: >=3.13
Description-Content-Type: text/markdown
License-File: LICENSE
License-File: AUTHORS
Requires-Dist: ansi-escapes
Requires-Dist: beautifhy>=1.1.4
Requires-Dist: click
Requires-Dist: colorist
Requires-Dist: hy>=1.2.0
Requires-Dist: hyrule
Requires-Dist: json-repair
Requires-Dist: more-itertools
Requires-Dist: multimethod
Requires-Dist: platformdirs
Requires-Dist: python-magic
Requires-Dist: toolz
Provides-Extra: zmq
Requires-Dist: ecdsa; extra == "zmq"
Requires-Dist: pyzmq; extra == "zmq"
Requires-Dist: zstandard; extra == "zmq"
Requires-Dist: msgpack; extra == "zmq"
Provides-Extra: llm
Requires-Dist: openai; extra == "llm"
Requires-Dist: anthropic; extra == "llm"
Provides-Extra: dev
Requires-Dist: pytest; extra == "dev"
Requires-Dist: ecdsa; extra == "dev"
Requires-Dist: pyzmq; extra == "dev"
Requires-Dist: zstandard; extra == "dev"
Requires-Dist: msgpack; extra == "dev"
Requires-Dist: openai; extra == "dev"
Requires-Dist: anthropic; extra == "dev"
Dynamic: license-file

## 🦑 Hyjinx 🔬

*Functions and macros for modern living in the [Hy](http://hylang.org) REPL.*

Compatible with Hy ≥ 1.2.0 · Python ≥ 3.13

Hyjinx is a utility library for Hy. When a module stabilises, it gets spun out into its own package (e.g. [beautifhy](https://github.com/atisharma/beautifhy)).


### Modules

| Module | Description | Dependencies |
|--------|-------------|--------------|
| `lib` | String/file/OS utilities, JSON I/O, hashing | toolz |
| `result` | Result type (`ok`/`err`) with threading macros | — |
| `macros` | `defmethod`, `defstruct`, `when-let`, `lmap`, etc. | toolz |
| `actors` | Async actor model with `defactor` macro | — |
| `api` | Static API surface inspection (no imports, no side effects) | — |
| `source` | Code inspection, display, and editing | pygments, beautifhy |
| `hjx_inspect` | Hy-aware `inspect` module | multimethod |
| `crypto` | ECDSA signing and password hashing | ecdsa |
| `mat` | NumPy pretty-printing for humans | numpy, colorist |
| `llm` | Discuss code with LLMs (OpenAI, Anthropic, TabbyAPI) | openai, anthropic |
| `wire` | ZMQ message framing | zmq, msgpack, zstandard |
| `zmq_client` | Lazy Pirate ZMQ client | zmq |
| `zmq_server` | Lazy Pirate ZMQ server | zmq |
| `screen` | ncurses wrapper | — |
| `docs` | Offline Hy/Hyrule/Toolz documentation | — |
| `hyrc` | REPL startup configuration | — |
| `mail` | Email sending | — |
| `cli` | Command-line interface | click, pygments |


### CLI

```bash
$ hyjinx where hyjinx.macros.defmethod
/path/to/hyjinx/macros.hy:94

$ hyjinx where json.dumps --json
{"line": 184, "module": "json", "file": "...", "language": "python", "extension": "py"}

$ hyjinx dir hyjinx.result
hyjinx/result.hy  [14 definitions]
  defn ok(value)
  defn err(error-type, message, context)
  defn as-result(x)
  mac  result->(expr, forms)
  mac  result->>(expr, forms)
  mac  let-result(bindings, body)
  mac  match-result(result, ok-sym, ok-body, err-sym, err-body)
  mac  try-result(body)
  defn raise-if-err(result)
  defn unwrap(result)
  defn unwrap-or(result, default)
  defn map-ok(f, result)
  defn map-err(f, result)
  defn collect-results(results)

$ hyjinx dir hyjinx.lib --kind defn --no-params
hyjinx/lib.hy  [60 definitions]
  defn mreload
  defn sync-await
  defn compose
  ...

$ hyjinx source hyjinx.api.format-surface --no-highlight
(defn format-surface [defs * [show-params True] [show-line False]]
  ...)

$ hyjinx doc hyjinx.api.api-surface
Return a list of definition dicts for a source file.
Each dict has keys: kind, name, params, line.
No imports are performed — purely static analysis.
```

The `dir` command uses **static analysis** — it parses source files without importing them, so it never triggers side effects (DB connections, GPU init, etc.).


### Install

```bash
pip install hyjinx
```

Optional dependencies:

```bash
pip install hyjinx[zmq]   # ecdsa, pyzmq, zstandard, msgpack
pip install hyjinx[llm]   # openai, anthropic
pip install hyjinx[dev]   # pytest + all optional dependencies
```

For offline Hy/Hyrule/Toolz documentation:

```bash
hy -m hyjinx.docs
```

For in-terminal sixel rendering of LaTeX in LLM replies, install `pdflatex`, `dvipng`, and `img2sixel`, and use a sixel-capable terminal.


### Hylights

- **`defmethod`** — polymorphic type dispatch via `multimethod`
- **Result type** — `ok`/`err` with `result->`, `let-result`, `match-result`, `try-result`
- **`defstruct`** — frozen dict-like records
- **Static API inspection** — `api-surface` parses Hy/Python source without importing
- **Hy-aware `inspect`** — `getsource`, `getsourcefile` that handle macros and multimethods
- **LLM integration** — discuss code with ChatGPT, Claude, or local models
- **ZMQ lazy pirate** — reliable RPC client/server with automatic retries
