divinatory 0.1.0__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- divinatory-0.1.0/.gitattributes +16 -0
- divinatory-0.1.0/.gitignore +39 -0
- divinatory-0.1.0/CHANGELOG.md +28 -0
- divinatory-0.1.0/LICENSE +9 -0
- divinatory-0.1.0/PKG-INFO +87 -0
- divinatory-0.1.0/README.md +59 -0
- divinatory-0.1.0/conftest.py +26 -0
- divinatory-0.1.0/docs/Makefile +80 -0
- divinatory-0.1.0/docs/cli.md +59 -0
- divinatory-0.1.0/docs/reference/cli.md +18 -0
- divinatory-0.1.0/docs/reference/draws.md +82 -0
- divinatory-0.1.0/docs/reference/engine.md +185 -0
- divinatory-0.1.0/docs/reference/errors.md +59 -0
- divinatory-0.1.0/docs/reference/install.md +296 -0
- divinatory-0.1.0/docs/reference/messages.md +17 -0
- divinatory-0.1.0/docs/reference/server.md +106 -0
- divinatory-0.1.0/docs/reference.md +43 -0
- divinatory-0.1.0/docs/sphinx/api/cli.rst +4 -0
- divinatory-0.1.0/docs/sphinx/api/draws.rst +4 -0
- divinatory-0.1.0/docs/sphinx/api/engine.rst +4 -0
- divinatory-0.1.0/docs/sphinx/api/errors.rst +4 -0
- divinatory-0.1.0/docs/sphinx/api/index.rst +48 -0
- divinatory-0.1.0/docs/sphinx/api/install.rst +4 -0
- divinatory-0.1.0/docs/sphinx/api/messages.rst +4 -0
- divinatory-0.1.0/docs/sphinx/api/server.rst +4 -0
- divinatory-0.1.0/docs/sphinx/conf.py +115 -0
- divinatory-0.1.0/docs/sphinx/index.rst +20 -0
- divinatory-0.1.0/docs/sphinx/python_objects.inv +0 -0
- divinatory-0.1.0/docs/tools.md +99 -0
- divinatory-0.1.0/environment.yml +5 -0
- divinatory-0.1.0/pyproject.toml +74 -0
- divinatory-0.1.0/src/divinatory/__init__.py +3 -0
- divinatory-0.1.0/src/divinatory/__main__.py +6 -0
- divinatory-0.1.0/src/divinatory/cli.py +134 -0
- divinatory-0.1.0/src/divinatory/draws.py +294 -0
- divinatory-0.1.0/src/divinatory/engine.py +345 -0
- divinatory-0.1.0/src/divinatory/errors.py +75 -0
- divinatory-0.1.0/src/divinatory/install.py +605 -0
- divinatory-0.1.0/src/divinatory/messages.py +69 -0
- divinatory-0.1.0/src/divinatory/server.py +269 -0
- divinatory-0.1.0/tests/test_cli_docs.py +27 -0
- divinatory-0.1.0/tests/test_draws.py +282 -0
- divinatory-0.1.0/tests/test_engine.py +291 -0
- divinatory-0.1.0/tests/test_install.py +183 -0
- divinatory-0.1.0/tests/test_messages.py +19 -0
- divinatory-0.1.0/tests/test_packaging.py +184 -0
- divinatory-0.1.0/tests/test_reference.py +124 -0
- divinatory-0.1.0/tests/test_server.py +198 -0
- divinatory-0.1.0/tests/test_tool_docs.py +33 -0
- divinatory-0.1.0/tools/render_cli.py +155 -0
- divinatory-0.1.0/tools/render_reference.py +86 -0
- divinatory-0.1.0/tools/render_tools.py +172 -0
|
@@ -0,0 +1,16 @@
|
|
|
1
|
+
# Line endings are preserved, never converted.
|
|
2
|
+
#
|
|
3
|
+
# `-text` turns off git's newline translation in both directions: a file is
|
|
4
|
+
# committed and checked out with the bytes it has. So a tree checked out on
|
|
5
|
+
# Windows holds LF, as it does everywhere else, and a file that deliberately
|
|
6
|
+
# holds CRLF -- a fixture for `issues/3` and `plans/line-endings` -- survives a
|
|
7
|
+
# round trip through the repository instead of being normalised on the way in.
|
|
8
|
+
#
|
|
9
|
+
# The alternative, `text=auto eol=lf`, also gives LF on Windows, but by
|
|
10
|
+
# *converting*: it would make a CRLF fixture impossible to commit, and it is
|
|
11
|
+
# the opposite of the rule this project applies to a document's line endings.
|
|
12
|
+
#
|
|
13
|
+
# The cost, stated: nothing normalises a CRLF file somebody commits by
|
|
14
|
+
# accident. `git ls-files --eol` is what shows one; every tracked file was
|
|
15
|
+
# `i/lf w/lf` when this was written.
|
|
16
|
+
* -text
|
|
@@ -0,0 +1,39 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
.pytest_cache/
|
|
4
|
+
.ruff_cache/
|
|
5
|
+
*.egg-info/
|
|
6
|
+
build/
|
|
7
|
+
dist/
|
|
8
|
+
docs/_build/
|
|
9
|
+
.venv/
|
|
10
|
+
.env
|
|
11
|
+
*.sqlite
|
|
12
|
+
*.sqlite3
|
|
13
|
+
*.db
|
|
14
|
+
.DS_Store
|
|
15
|
+
|
|
16
|
+
# The Outrage store is machine local.
|
|
17
|
+
.outrage/
|
|
18
|
+
.outrage-*/
|
|
19
|
+
|
|
20
|
+
# Harness configuration written by `outrage init`. Every command in it is an
|
|
21
|
+
# absolute path into one machine's environment, and the skills and agents are
|
|
22
|
+
# rendered from the installed Outrage, so all of it is recreated with
|
|
23
|
+
# `outrage init` rather than committed. A skill or agent of this project's own
|
|
24
|
+
# would be committed instead: name it in a `!` exception below.
|
|
25
|
+
.mcp.json
|
|
26
|
+
.claude/
|
|
27
|
+
.codex/
|
|
28
|
+
.cursor/mcp.json
|
|
29
|
+
.cursor/hooks.json
|
|
30
|
+
.agents/
|
|
31
|
+
.github/hooks/outrage.json
|
|
32
|
+
.github/agents/
|
|
33
|
+
.github/.outrage.json
|
|
34
|
+
|
|
35
|
+
# The store's readme is the record of the conventions, delivered by the
|
|
36
|
+
# SessionStart hook; a root CLAUDE.md or AGENTS.md would be a third copy to go
|
|
37
|
+
# stale. Anchored to the root because git matches case-insensitively on macOS.
|
|
38
|
+
/CLAUDE.md
|
|
39
|
+
/AGENTS.md
|
|
@@ -0,0 +1,28 @@
|
|
|
1
|
+
# Changelog
|
|
2
|
+
|
|
3
|
+
Notable changes to `divinatory`. This project follows [semantic versioning](https://semver.org).
|
|
4
|
+
|
|
5
|
+
## 0.1.0 - 2026-11-29
|
|
6
|
+
|
|
7
|
+
First release: an MCP server giving AI agents an entropy source, in two
|
|
8
|
+
halves.
|
|
9
|
+
|
|
10
|
+
The secure source is the operating system's. `secure_seed` returns a fresh
|
|
11
|
+
128-bit seed as hex, and `secure_random` gives one-off integers, floats,
|
|
12
|
+
choices from a list (optionally weighted), or a deal without repeats.
|
|
13
|
+
|
|
14
|
+
The seeded tools are repeatable and keep no state between calls. `random`
|
|
15
|
+
draws integers, floats or choices with replacement, and `deal` shuffles a
|
|
16
|
+
deck, either a list or the integers `low` to `high`, and deals it without
|
|
17
|
+
repeats; each seed deals a deck once. The same seed, offset and arguments
|
|
18
|
+
always give the same values, and a stream continues across calls from the
|
|
19
|
+
`next_offset` each result returns. Results name their algorithm, `v1`, which
|
|
20
|
+
is built on `getrandbits` alone so that it does not move with the Python
|
|
21
|
+
version; a change to any seeded value will come with a new algorithm version.
|
|
22
|
+
|
|
23
|
+
Integers beyond 2^53 travel intact: bounds and offsets are taken as decimal
|
|
24
|
+
strings, and values that may exceed 2^53 are returned as strings.
|
|
25
|
+
|
|
26
|
+
`divinatory init` registers the server with Claude Code and GitHub Copilot
|
|
27
|
+
CLI (`.mcp.json`), Codex (`.codex/config.toml`) and Cursor
|
|
28
|
+
(`.cursor/mcp.json`), and `divinatory uninit` takes the entries out again.
|
divinatory-0.1.0/LICENSE
ADDED
|
@@ -0,0 +1,9 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 John M Reynolds
|
|
4
|
+
|
|
5
|
+
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:
|
|
6
|
+
|
|
7
|
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
|
|
8
|
+
|
|
9
|
+
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.
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: divinatory
|
|
3
|
+
Version: 0.1.0
|
|
4
|
+
Summary: An MCP server providing AI agents with an entropy source modelled on traditional divination
|
|
5
|
+
Project-URL: Homepage, https://github.com/ZandevOxford/divinatory
|
|
6
|
+
Project-URL: Issues, https://github.com/ZandevOxford/divinatory/issues
|
|
7
|
+
Author-email: John M Reynolds <zandev@gmail.com>
|
|
8
|
+
License-Expression: MIT
|
|
9
|
+
License-File: LICENSE
|
|
10
|
+
Classifier: Operating System :: OS Independent
|
|
11
|
+
Classifier: Programming Language :: Python :: 3
|
|
12
|
+
Requires-Python: >=3.12
|
|
13
|
+
Requires-Dist: mcp>=2.1
|
|
14
|
+
Requires-Dist: pydantic>=2
|
|
15
|
+
Requires-Dist: tomlkit>=0.13
|
|
16
|
+
Provides-Extra: dev
|
|
17
|
+
Requires-Dist: build>=1; extra == 'dev'
|
|
18
|
+
Requires-Dist: hatchling; extra == 'dev'
|
|
19
|
+
Requires-Dist: omnidep>=0.4; extra == 'dev'
|
|
20
|
+
Requires-Dist: pytest>=8; extra == 'dev'
|
|
21
|
+
Requires-Dist: ruff>=0.6; extra == 'dev'
|
|
22
|
+
Requires-Dist: twine>=5; extra == 'dev'
|
|
23
|
+
Provides-Extra: docs
|
|
24
|
+
Requires-Dist: furo; extra == 'docs'
|
|
25
|
+
Requires-Dist: sphinx-markdown-builder>=0.6.11; extra == 'docs'
|
|
26
|
+
Requires-Dist: sphinx>=8; extra == 'docs'
|
|
27
|
+
Description-Content-Type: text/markdown
|
|
28
|
+
|
|
29
|
+
# divinatory
|
|
30
|
+
|
|
31
|
+
An MCP server providing AI agents with an entropy source modelled on
|
|
32
|
+
traditional divination.
|
|
33
|
+
|
|
34
|
+
## Getting started
|
|
35
|
+
|
|
36
|
+
Set up a 3.12 or later Python environment, then:
|
|
37
|
+
|
|
38
|
+
`pip install divinatory`
|
|
39
|
+
|
|
40
|
+
Then, from the root of a project:
|
|
41
|
+
|
|
42
|
+
`divinatory init`
|
|
43
|
+
|
|
44
|
+
That registers the server with Claude Code and GitHub Copilot CLI
|
|
45
|
+
(`.mcp.json`), Codex (`.codex/config.toml`) and Cursor (`.cursor/mcp.json`),
|
|
46
|
+
using an absolute path into the environment it was installed in. Only the
|
|
47
|
+
server's own entry is written. Re-run it after moving or rebuilding the
|
|
48
|
+
environment; `--dry-run` shows what would change. `divinatory uninit`
|
|
49
|
+
takes the entries out again.
|
|
50
|
+
|
|
51
|
+
## Tools
|
|
52
|
+
|
|
53
|
+
* `secure_seed`: a fresh 128-bit seed, as hex.
|
|
54
|
+
* `secure_random`: one-off integers, floats, choices from a list, or a deal
|
|
55
|
+
without repeats, from the operating system's secure source.
|
|
56
|
+
* `random`: integers, floats or choices from a seed and offset, with
|
|
57
|
+
replacement. Repeatable, and continued across calls from the `next_offset`
|
|
58
|
+
each result gives.
|
|
59
|
+
* `deal`: a deck (a list, or the integers `low` to `high`) shuffled by a seed
|
|
60
|
+
and dealt without repeats, continued the same way.
|
|
61
|
+
|
|
62
|
+
## Documentation
|
|
63
|
+
|
|
64
|
+
* **[The MCP tools](https://github.com/ZandevOxford/divinatory/blob/main/docs/tools.md)**: every tool's parameters, defaults and
|
|
65
|
+
results, and the instructions the server gives a client.
|
|
66
|
+
* **[The command line](https://github.com/ZandevOxford/divinatory/blob/main/docs/cli.md)**: `divinatory init` and `uninit`.
|
|
67
|
+
* **[The API reference](https://github.com/ZandevOxford/divinatory/blob/main/docs/reference.md)**: the Python package, module by
|
|
68
|
+
module.
|
|
69
|
+
|
|
70
|
+
All three are generated from the source and committed. After changing a
|
|
71
|
+
docstring, a tool or the command line, regenerate them; the tests fail until
|
|
72
|
+
they match:
|
|
73
|
+
|
|
74
|
+
```sh
|
|
75
|
+
pip install -e ".[docs]"
|
|
76
|
+
make -C docs documents
|
|
77
|
+
```
|
|
78
|
+
|
|
79
|
+
## Development
|
|
80
|
+
|
|
81
|
+
```sh
|
|
82
|
+
conda env create -f environment.yml
|
|
83
|
+
conda activate divinatory
|
|
84
|
+
pip install -e ".[dev]"
|
|
85
|
+
pytest
|
|
86
|
+
ruff check . && ruff format --check .
|
|
87
|
+
```
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
# divinatory
|
|
2
|
+
|
|
3
|
+
An MCP server providing AI agents with an entropy source modelled on
|
|
4
|
+
traditional divination.
|
|
5
|
+
|
|
6
|
+
## Getting started
|
|
7
|
+
|
|
8
|
+
Set up a 3.12 or later Python environment, then:
|
|
9
|
+
|
|
10
|
+
`pip install divinatory`
|
|
11
|
+
|
|
12
|
+
Then, from the root of a project:
|
|
13
|
+
|
|
14
|
+
`divinatory init`
|
|
15
|
+
|
|
16
|
+
That registers the server with Claude Code and GitHub Copilot CLI
|
|
17
|
+
(`.mcp.json`), Codex (`.codex/config.toml`) and Cursor (`.cursor/mcp.json`),
|
|
18
|
+
using an absolute path into the environment it was installed in. Only the
|
|
19
|
+
server's own entry is written. Re-run it after moving or rebuilding the
|
|
20
|
+
environment; `--dry-run` shows what would change. `divinatory uninit`
|
|
21
|
+
takes the entries out again.
|
|
22
|
+
|
|
23
|
+
## Tools
|
|
24
|
+
|
|
25
|
+
* `secure_seed`: a fresh 128-bit seed, as hex.
|
|
26
|
+
* `secure_random`: one-off integers, floats, choices from a list, or a deal
|
|
27
|
+
without repeats, from the operating system's secure source.
|
|
28
|
+
* `random`: integers, floats or choices from a seed and offset, with
|
|
29
|
+
replacement. Repeatable, and continued across calls from the `next_offset`
|
|
30
|
+
each result gives.
|
|
31
|
+
* `deal`: a deck (a list, or the integers `low` to `high`) shuffled by a seed
|
|
32
|
+
and dealt without repeats, continued the same way.
|
|
33
|
+
|
|
34
|
+
## Documentation
|
|
35
|
+
|
|
36
|
+
* **[The MCP tools](https://github.com/ZandevOxford/divinatory/blob/main/docs/tools.md)**: every tool's parameters, defaults and
|
|
37
|
+
results, and the instructions the server gives a client.
|
|
38
|
+
* **[The command line](https://github.com/ZandevOxford/divinatory/blob/main/docs/cli.md)**: `divinatory init` and `uninit`.
|
|
39
|
+
* **[The API reference](https://github.com/ZandevOxford/divinatory/blob/main/docs/reference.md)**: the Python package, module by
|
|
40
|
+
module.
|
|
41
|
+
|
|
42
|
+
All three are generated from the source and committed. After changing a
|
|
43
|
+
docstring, a tool or the command line, regenerate them; the tests fail until
|
|
44
|
+
they match:
|
|
45
|
+
|
|
46
|
+
```sh
|
|
47
|
+
pip install -e ".[docs]"
|
|
48
|
+
make -C docs documents
|
|
49
|
+
```
|
|
50
|
+
|
|
51
|
+
## Development
|
|
52
|
+
|
|
53
|
+
```sh
|
|
54
|
+
conda env create -f environment.yml
|
|
55
|
+
conda activate divinatory
|
|
56
|
+
pip install -e ".[dev]"
|
|
57
|
+
pytest
|
|
58
|
+
ruff check . && ruff format --check .
|
|
59
|
+
```
|
|
@@ -0,0 +1,26 @@
|
|
|
1
|
+
"""Decide which copy of ``divinatory`` the suite tests, before anything imports it.
|
|
2
|
+
|
|
3
|
+
By default the suite tests **this checkout**: ``src`` goes to the front of the
|
|
4
|
+
path, ahead of any installed copy, so a run in an environment holding a
|
|
5
|
+
released build cannot report that build's result as the checkout's. Set
|
|
6
|
+
``DIVINATORY_TEST_INSTALLED=1`` to test the installed copy instead, which
|
|
7
|
+
is worth doing against a release candidate.
|
|
8
|
+
|
|
9
|
+
This has to be at the repository root: pytest loads a ``conftest.py`` from the
|
|
10
|
+
rootdir before any test module, and anywhere else it would run too late or not
|
|
11
|
+
at all. It cannot be ``pythonpath = ["src"]`` in ``pyproject.toml``, which is
|
|
12
|
+
static and so has no switch.
|
|
13
|
+
"""
|
|
14
|
+
|
|
15
|
+
from __future__ import annotations
|
|
16
|
+
|
|
17
|
+
import os
|
|
18
|
+
import sys
|
|
19
|
+
from pathlib import Path
|
|
20
|
+
|
|
21
|
+
SRC = Path(__file__).resolve().parent / "src"
|
|
22
|
+
|
|
23
|
+
TEST_INSTALLED = bool(os.environ.get("DIVINATORY_TEST_INSTALLED"))
|
|
24
|
+
|
|
25
|
+
if not TEST_INSTALLED:
|
|
26
|
+
sys.path.insert(0, str(SRC))
|
|
@@ -0,0 +1,80 @@
|
|
|
1
|
+
# Builds the documentation in this directory, as markdown that GitHub serves.
|
|
2
|
+
#
|
|
3
|
+
# make documents regenerate everything committed here (what you want)
|
|
4
|
+
# make strict the HTML build with warnings as errors, for checking
|
|
5
|
+
# make inventory refetch the committed Python intersphinx inventory
|
|
6
|
+
#
|
|
7
|
+
# **Run this in an environment that has the project's `docs` extra installed**:
|
|
8
|
+
# `pip install -e '.[docs]'`. Every target but `inventory` needs `sphinx` and
|
|
9
|
+
# `sphinx-markdown-builder`, and `check-env` says so when they are missing,
|
|
10
|
+
# rather than leaving Make to report an import error naming neither.
|
|
11
|
+
#
|
|
12
|
+
# PYTHON is whatever the activated environment resolves, and can be overridden:
|
|
13
|
+
# make documents PYTHON=/path/to/python
|
|
14
|
+
# Never a path to a particular interpreter here: this file is committed.
|
|
15
|
+
|
|
16
|
+
PYTHON ?= python
|
|
17
|
+
SPHINXOPTS ?=
|
|
18
|
+
SPHINXBUILD ?= $(PYTHON) -m sphinx
|
|
19
|
+
SOURCEDIR = sphinx
|
|
20
|
+
BUILDDIR = _build
|
|
21
|
+
|
|
22
|
+
.PHONY: help check-env strict markdown documents inventory clean Makefile
|
|
23
|
+
|
|
24
|
+
help:
|
|
25
|
+
@$(SPHINXBUILD) -M help "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
26
|
+
|
|
27
|
+
# Both packages are checked because only one of them is the obvious one: with
|
|
28
|
+
# `sphinx` and no `sphinx-markdown-builder`, the build fails on an unknown
|
|
29
|
+
# builder name several screens in.
|
|
30
|
+
check-env:
|
|
31
|
+
@$(PYTHON) -c 'import sphinx, sphinx_markdown_builder' 2>/dev/null || { \
|
|
32
|
+
echo "$(PYTHON) has no sphinx and sphinx-markdown-builder."; \
|
|
33
|
+
echo "Activate the project environment, or install the extra: pip install -e '.[docs]'"; \
|
|
34
|
+
echo "Or name an interpreter: make $(MAKECMDGOALS) PYTHON=/path/to/python"; \
|
|
35
|
+
exit 1; }
|
|
36
|
+
|
|
37
|
+
# Warnings are errors, and every page is rebuilt.
|
|
38
|
+
strict: check-env
|
|
39
|
+
@$(SPHINXBUILD) -M html "$(SOURCEDIR)" "$(BUILDDIR)" -W --keep-going -a -E $(SPHINXOPTS) $(O)
|
|
40
|
+
|
|
41
|
+
# The API pages as markdown, left in `$(BUILDDIR)`; `documents` moves them here.
|
|
42
|
+
#
|
|
43
|
+
# **Its own doctree cache.** `-M` gives every builder one `_build/doctrees`, and
|
|
44
|
+
# smartquotes are applied at parse time, so a doctree cached by the HTML build
|
|
45
|
+
# would carry en dashes into the markdown despite `smartquotes_excludes` in
|
|
46
|
+
# conf.py.
|
|
47
|
+
#
|
|
48
|
+
# **Warnings are errors**: a node type the builder does not handle is dropped
|
|
49
|
+
# from the output with only a warning to say so.
|
|
50
|
+
#
|
|
51
|
+
# **The output directory goes first.** `-a -E` rebuilds every page Sphinx
|
|
52
|
+
# renders but says nothing about one it has stopped rendering, so a removed
|
|
53
|
+
# module's page would otherwise be copied back in as a live one.
|
|
54
|
+
markdown: check-env
|
|
55
|
+
@rm -rf "$(BUILDDIR)/markdown"
|
|
56
|
+
@$(SPHINXBUILD) -b markdown "$(SOURCEDIR)" "$(BUILDDIR)/markdown" \
|
|
57
|
+
-d "$(BUILDDIR)/doctrees-markdown" -W --keep-going -a -E $(SPHINXOPTS) $(O)
|
|
58
|
+
|
|
59
|
+
# Every committed document here, from its source. Three generators: Sphinx
|
|
60
|
+
# renders `reference.md` and `reference/` from the docstrings, `render_cli.py`
|
|
61
|
+
# renders `cli.md` from the argument parser, and `render_tools.py` renders
|
|
62
|
+
# `tools.md` from the built MCP server. `tests/test_reference.py`,
|
|
63
|
+
# `tests/test_cli_docs.py` and `tests/test_tool_docs.py` fail when a source
|
|
64
|
+
# changes without its document following it.
|
|
65
|
+
documents: check-env markdown
|
|
66
|
+
@$(PYTHON) ../tools/render_reference.py "$(BUILDDIR)/markdown" .
|
|
67
|
+
@$(PYTHON) ../tools/render_cli.py cli.md
|
|
68
|
+
@$(PYTHON) ../tools/render_tools.py tools.md
|
|
69
|
+
|
|
70
|
+
# Refetch the committed intersphinx inventory, the only target that touches the
|
|
71
|
+
# network and the only thing that can move where the reference's links to the
|
|
72
|
+
# Python documentation point. Run `documents` after it and review the diff.
|
|
73
|
+
inventory:
|
|
74
|
+
@curl -fsS -o "$(SOURCEDIR)/python_objects.inv" https://docs.python.org/3/objects.inv
|
|
75
|
+
|
|
76
|
+
clean:
|
|
77
|
+
@rm -rf "$(BUILDDIR)"
|
|
78
|
+
|
|
79
|
+
%: Makefile
|
|
80
|
+
@$(SPHINXBUILD) -M $@ "$(SOURCEDIR)" "$(BUILDDIR)" $(SPHINXOPTS) $(O)
|
|
@@ -0,0 +1,59 @@
|
|
|
1
|
+
<!-- Generated by tools/render_cli.py; do not edit by hand. -->
|
|
2
|
+
|
|
3
|
+
# The divinatory command line
|
|
4
|
+
|
|
5
|
+
Set a project up to use the divinatory server.
|
|
6
|
+
|
|
7
|
+
## Usage
|
|
8
|
+
|
|
9
|
+
```text
|
|
10
|
+
divinatory [-h] [--version] {init,uninit} ...
|
|
11
|
+
```
|
|
12
|
+
|
|
13
|
+
### Arguments
|
|
14
|
+
|
|
15
|
+
- `-h, --help` - show this help message and exit
|
|
16
|
+
- `--version` - show program's version number and exit
|
|
17
|
+
|
|
18
|
+
## Commands
|
|
19
|
+
|
|
20
|
+
- [`init`](#init) - register the MCP server with the project's coding harnesses
|
|
21
|
+
- [`uninit`](#uninit) - remove the MCP server from the project's coding harnesses
|
|
22
|
+
|
|
23
|
+
## `init`
|
|
24
|
+
|
|
25
|
+
Register the server in .mcp.json (Claude Code and Copilot CLI), .codex/config.toml (Codex) and
|
|
26
|
+
.cursor/mcp.json (Cursor), with an absolute path into this environment. Only the server's own entry
|
|
27
|
+
is written; the rest of each file is left as it was. Safe to re-run, which is how a project is
|
|
28
|
+
repaired after the environment moves.
|
|
29
|
+
|
|
30
|
+
### Usage
|
|
31
|
+
|
|
32
|
+
```text
|
|
33
|
+
divinatory init [-h] [--project-dir PATH] [--dry-run]
|
|
34
|
+
```
|
|
35
|
+
|
|
36
|
+
### Arguments
|
|
37
|
+
|
|
38
|
+
- `-h, --help` - show this help message and exit
|
|
39
|
+
- `--project-dir PATH` - Project to set up. Defaults to the cwd.
|
|
40
|
+
- `--dry-run` - Report what would change without writing.
|
|
41
|
+
|
|
42
|
+
## `uninit`
|
|
43
|
+
|
|
44
|
+
Remove the server entries 'init' writes. Refuses, writing nothing, when an entry holds something
|
|
45
|
+
init did not write; every reason is reported at once, and --force removes them anyway. Files left
|
|
46
|
+
empty are not deleted.
|
|
47
|
+
|
|
48
|
+
### Usage
|
|
49
|
+
|
|
50
|
+
```text
|
|
51
|
+
divinatory uninit [-h] [--project-dir PATH] [--dry-run] [--force]
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
### Arguments
|
|
55
|
+
|
|
56
|
+
- `-h, --help` - show this help message and exit
|
|
57
|
+
- `--project-dir PATH` - Project to remove the server from.
|
|
58
|
+
- `--dry-run` - Report what would change without writing.
|
|
59
|
+
- `--force` - Remove entries holding hand-added fields, arguments or Codex keys. Does not reach a file that cannot be read.
|
|
@@ -0,0 +1,18 @@
|
|
|
1
|
+
<a id="module-divinatory.cli"></a>
|
|
2
|
+
|
|
3
|
+
<a id="divinatory-cli"></a>
|
|
4
|
+
|
|
5
|
+
# divinatory.cli
|
|
6
|
+
|
|
7
|
+
The `divinatory` command line: setting a project up for the server.
|
|
8
|
+
|
|
9
|
+
Argument shaping and printing only; everything it does is in
|
|
10
|
+
[`divinatory.install`](install.md#module-divinatory.install).
|
|
11
|
+
|
|
12
|
+
<a id="divinatory.cli.build_parser"></a>
|
|
13
|
+
|
|
14
|
+
### divinatory.cli.build_parser() → [ArgumentParser](https://docs.python.org/3/library/argparse.html#argparse.ArgumentParser)
|
|
15
|
+
|
|
16
|
+
<a id="divinatory.cli.main"></a>
|
|
17
|
+
|
|
18
|
+
### divinatory.cli.main(argv: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[str](https://docs.python.org/3/builtins/stdtypes.html#str)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None, out: [TextIO](https://docs.python.org/3/library/typing.html#typing.TextIO) | [None](https://docs.python.org/3/builtins/constants.html#None) = None) → [int](https://docs.python.org/3/builtins/functions.html#int)
|
|
@@ -0,0 +1,82 @@
|
|
|
1
|
+
<a id="module-divinatory.draws"></a>
|
|
2
|
+
|
|
3
|
+
<a id="divinatory-draws"></a>
|
|
4
|
+
|
|
5
|
+
# divinatory.draws
|
|
6
|
+
|
|
7
|
+
The requests the tools answer, checked and drawn, with JSON-ready results.
|
|
8
|
+
|
|
9
|
+
Between the MCP server and [`divinatory.engine`](engine.md#module-divinatory.engine), with no MCP in it, so
|
|
10
|
+
that what a tool does can be tested without a server. The server's job is only
|
|
11
|
+
to declare the arguments and render a `DivinationError` as a sentence.
|
|
12
|
+
|
|
13
|
+
A request names a *kind* of draw and the arguments that kind takes:
|
|
14
|
+
|
|
15
|
+
* `integer`: `low` and `high`, both included.
|
|
16
|
+
* `float`: nothing; a float in `[0, 1)`.
|
|
17
|
+
* `choice`: `items`, and optionally integer `weights`, one per item.
|
|
18
|
+
* `deal`: a deck, either `items` or the integers `low` to `high`, dealt
|
|
19
|
+
without repeats. Seeded deals are their own tool, so this kind is only for
|
|
20
|
+
the secure source.
|
|
21
|
+
|
|
22
|
+
An argument that does not belong to the kind is refused rather than ignored: a
|
|
23
|
+
caller who sent one meant something by it, and silently dropping it would
|
|
24
|
+
answer a different question from the one asked.
|
|
25
|
+
|
|
26
|
+
Integers in JSON lose precision above 2\*\*53 in some clients, so a bound or an
|
|
27
|
+
offset may be given as a string of decimal digits, and one given as a JSON
|
|
28
|
+
integer beyond 2\*\*53 - 1 is refused: it may already have been rounded on the
|
|
29
|
+
way, and nothing here could tell. When a range reaches
|
|
30
|
+
beyond that a result gives *every* value in it as a string, along with a
|
|
31
|
+
deck's size, remaining count and offsets: the type of a result depends on the
|
|
32
|
+
request, never on the luck of the draw. Bounds are limited to
|
|
33
|
+
[`BOUND_LIMIT`](#divinatory.draws.BOUND_LIMIT), which keeps every value writable as a string.
|
|
34
|
+
|
|
35
|
+
<a id="divinatory.draws.BOUND_LIMIT"></a>
|
|
36
|
+
|
|
37
|
+
### divinatory.draws.BOUND_LIMIT *= 179769313486231590772930519078902473361797697894230657273430081157732675805500963132708477322407536021120113879871393357658789768814416622492847430639474124377767893424865485276302219601246094119453082952085005768838150682342462881473913110540827237163350510684586298239947245938479716304835356329624224137216*
|
|
38
|
+
|
|
39
|
+
The largest magnitude of a bound. Far beyond any real use, and well inside
|
|
40
|
+
the digits Python will convert to and from a string.
|
|
41
|
+
|
|
42
|
+
<a id="divinatory.draws.MAX_COUNT"></a>
|
|
43
|
+
|
|
44
|
+
### divinatory.draws.MAX_COUNT *= 1000*
|
|
45
|
+
|
|
46
|
+
The most values one call returns: a result lands in a context window.
|
|
47
|
+
|
|
48
|
+
<a id="divinatory.draws.SAFE_INTEGER"></a>
|
|
49
|
+
|
|
50
|
+
### divinatory.draws.SAFE_INTEGER *= 9007199254740991*
|
|
51
|
+
|
|
52
|
+
The largest integer every JSON client reads exactly.
|
|
53
|
+
|
|
54
|
+
<a id="divinatory.draws.STREAM_KINDS"></a>
|
|
55
|
+
|
|
56
|
+
### divinatory.draws.STREAM_KINDS *: [tuple](https://docs.python.org/3/builtins/stdtypes.html#tuple)[[Literal](https://docs.python.org/3/library/typing.html#typing.Literal)['integer', 'float', 'choice', 'deal'], ...]* *= ('integer', 'float', 'choice')*
|
|
57
|
+
|
|
58
|
+
The kinds a random stream draws; a seeded deal is the `deal` tool instead.
|
|
59
|
+
|
|
60
|
+
<a id="divinatory.draws.deal"></a>
|
|
61
|
+
|
|
62
|
+
### divinatory.draws.deal(seed: [str](https://docs.python.org/3/builtins/stdtypes.html#str), \*, offset: [int](https://docs.python.org/3/builtins/functions.html#int) | [str](https://docs.python.org/3/builtins/stdtypes.html#str) = 0, count: [int](https://docs.python.org/3/builtins/functions.html#int) = 1, items: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[Any](https://docs.python.org/3/library/typing.html#typing.Any)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None, low: [int](https://docs.python.org/3/builtins/functions.html#int) | [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None, high: [int](https://docs.python.org/3/builtins/functions.html#int) | [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None) → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)]
|
|
63
|
+
|
|
64
|
+
Positions `offset` onwards of the deck shuffled by `seed`, without repeats.
|
|
65
|
+
|
|
66
|
+
<a id="divinatory.draws.secure_random"></a>
|
|
67
|
+
|
|
68
|
+
### divinatory.draws.secure_random(kind: [Literal](https://docs.python.org/3/library/typing.html#typing.Literal)['integer', 'float', 'choice', 'deal'], \*, count: [int](https://docs.python.org/3/builtins/functions.html#int) = 1, low: [int](https://docs.python.org/3/builtins/functions.html#int) | [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None, high: [int](https://docs.python.org/3/builtins/functions.html#int) | [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None, items: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[Any](https://docs.python.org/3/library/typing.html#typing.Any)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None, weights: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[int](https://docs.python.org/3/builtins/functions.html#int)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None) → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)]
|
|
69
|
+
|
|
70
|
+
`count` one-off values of `kind` from the secure source.
|
|
71
|
+
|
|
72
|
+
<a id="divinatory.draws.secure_seed"></a>
|
|
73
|
+
|
|
74
|
+
### divinatory.draws.secure_seed() → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)]
|
|
75
|
+
|
|
76
|
+
A new seed for the seeded tools.
|
|
77
|
+
|
|
78
|
+
<a id="divinatory.draws.seeded_random"></a>
|
|
79
|
+
|
|
80
|
+
### divinatory.draws.seeded_random(seed: [str](https://docs.python.org/3/builtins/stdtypes.html#str), kind: [Literal](https://docs.python.org/3/library/typing.html#typing.Literal)['integer', 'float', 'choice', 'deal'], \*, offset: [int](https://docs.python.org/3/builtins/functions.html#int) | [str](https://docs.python.org/3/builtins/stdtypes.html#str) = 0, count: [int](https://docs.python.org/3/builtins/functions.html#int) = 1, low: [int](https://docs.python.org/3/builtins/functions.html#int) | [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None, high: [int](https://docs.python.org/3/builtins/functions.html#int) | [str](https://docs.python.org/3/builtins/stdtypes.html#str) | [None](https://docs.python.org/3/builtins/constants.html#None) = None, items: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[Any](https://docs.python.org/3/library/typing.html#typing.Any)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None, weights: [Sequence](https://docs.python.org/3/library/collections.abc.html#collections.abc.Sequence)[[int](https://docs.python.org/3/builtins/functions.html#int)] | [None](https://docs.python.org/3/builtins/constants.html#None) = None) → [dict](https://docs.python.org/3/builtins/stdtypes.html#dict)[[str](https://docs.python.org/3/builtins/stdtypes.html#str), [Any](https://docs.python.org/3/library/typing.html#typing.Any)]
|
|
81
|
+
|
|
82
|
+
Positions `offset` onwards of the random stream of `seed`, with replacement.
|