mindyard 0.1.4__tar.gz → 0.2.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.
- {mindyard-0.1.4 → mindyard-0.2.0}/.github/workflows/ci.yml +2 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/PKG-INFO +39 -2
- {mindyard-0.1.4 → mindyard-0.2.0}/README.md +38 -1
- {mindyard-0.1.4 → mindyard-0.2.0}/server.json +2 -2
- {mindyard-0.1.4 → mindyard-0.2.0}/skills/mindyard/SKILL.md +5 -2
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/__init__.py +1 -1
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/auth/backends.py +5 -1
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/auth/gate.py +13 -2
- mindyard-0.2.0/src/mindyard/cli.py +261 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/core/errors.py +78 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/core/git.py +49 -9
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/core/operations.py +77 -9
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/core/render.py +20 -9
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/core/search.py +27 -12
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/mcp/app.py +33 -4
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/mcp/server.py +45 -9
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/schema/manifest.py +6 -1
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/settings.py +11 -4
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/blank/wiki.yaml +3 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/tenancy/__init__.py +12 -0
- mindyard-0.2.0/src/mindyard/tenancy/registry.py +322 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/tenancy/tenant.py +17 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/auth/test_gate.py +13 -1
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/core/test_render.py +20 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/core/test_search.py +49 -1
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/core/test_write_batch.py +42 -0
- mindyard-0.2.0/tests/core/test_write_limits.py +134 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/mcp/test_app.py +54 -2
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/mcp/test_server.py +123 -1
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/schema/test_manifest.py +26 -0
- mindyard-0.2.0/tests/tenancy/test_registry.py +261 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/test_cli.py +29 -1
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/test_settings.py +5 -2
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/test_waitlist.py +33 -20
- mindyard-0.1.4/src/mindyard/cli.py +0 -137
- {mindyard-0.1.4 → mindyard-0.2.0}/.dockerignore +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/.github/workflows/release.yml +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/.gitignore +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/CLA.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/CONTRIBUTING.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/Dockerfile +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/LICENSE +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/SECURITY.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/compose.example.yaml +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/docs/deploy-vps.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/glama.json +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/pyproject.toml +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/scripts/check-provenance.sh +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/auth/__init__.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/auth/consent.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/auth/policy.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/auth/tokens.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/core/config.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/core/paths.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/identity.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/init.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/lint/__init__.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/lint/checks.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/lint/markdown.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/lint/runner.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/mcp/__init__.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/mcp/accesslog.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/mcp/middleware.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/mcp/telemetry.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/schema/__init__.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/schema/discovery.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/static/icon-96.png +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/static/icon.svg +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/blank/.gitignore +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/blank/index.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/blank/log.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/blank/raw/.gitkeep +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/blank/schema.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/blank/wiki/.gitkeep +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/demo/.gitignore +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/demo/index.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/demo/log.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/demo/raw/2026-03-seed-swap-notes.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/demo/schema.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/demo/wiki/concepts/companion-planting.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/demo/wiki/events/spring-seed-swap.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/demo/wiki/plants/basil.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/demo/wiki/plants/tomato.md +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/templates/demo/wiki.yaml +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/tenancy/context.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/src/mindyard/tenancy/resolver.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/__init__.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/auth/__init__.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/auth/test_auth.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/auth/test_consent.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/conftest.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/core/__init__.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/core/test_git_ops.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/core/test_normalize.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/core/test_paths.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/core/test_read_tools.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/lint/__init__.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/lint/test_lint.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/mcp/__init__.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/mcp/test_accesslog.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/mcp/test_http.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/schema/__init__.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/tenancy/__init__.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/tenancy/test_tenancy.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/test_identity.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/tests/test_package.py +0 -0
- {mindyard-0.1.4 → mindyard-0.2.0}/uv.lock +0 -0
|
@@ -16,6 +16,8 @@ jobs:
|
|
|
16
16
|
- uses: astral-sh/setup-uv@v10.3.0
|
|
17
17
|
with:
|
|
18
18
|
python-version: "3.12"
|
|
19
|
+
# Regex search runs only through ripgrep (linear-time engine, no ReDoS).
|
|
20
|
+
- run: sudo apt-get install -y ripgrep
|
|
19
21
|
- run: uv sync --frozen
|
|
20
22
|
- run: uv run ruff check
|
|
21
23
|
- run: uv run ruff format --check
|
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
Metadata-Version: 2.5
|
|
2
2
|
Name: mindyard
|
|
3
|
-
Version: 0.
|
|
3
|
+
Version: 0.2.0
|
|
4
4
|
Summary: Your personal LLM wiki: a git-versioned Markdown vault served over MCP
|
|
5
5
|
Project-URL: Homepage, https://mindyard.dev
|
|
6
6
|
Project-URL: Repository, https://github.com/floriantriclin/mindyard
|
|
@@ -42,6 +42,12 @@ Status: early release (0.1). Website: [mindyard.dev](https://mindyard.dev).
|
|
|
42
42
|
|
|
43
43
|
## Quickstart
|
|
44
44
|
|
|
45
|
+
You need [uv](https://docs.astral.sh/uv/) (it fetches Python 3.12 if needed) and
|
|
46
|
+
**git**: every write is a commit. On Windows, install Git for Windows from
|
|
47
|
+
[git-scm.com](https://git-scm.com/download/win) first; macOS and Linux usually ship it.
|
|
48
|
+
Optional, **ripgrep** (`rg`): searches run faster with it, and a search by regular
|
|
49
|
+
expression needs it; without it, search matches text literally.
|
|
50
|
+
|
|
45
51
|
```bash
|
|
46
52
|
uv tool install mindyard # or prefix each command with `uvx`, or `pip install mindyard`
|
|
47
53
|
mindyard init ./data/vaults/garden --demo
|
|
@@ -65,6 +71,10 @@ vaults of the user who runs it. Claude Desktop takes the same command in
|
|
|
65
71
|
}
|
|
66
72
|
```
|
|
67
73
|
|
|
74
|
+
If the same account also has a remote mindyard connector, give the two servers
|
|
75
|
+
distinct names (here `mindyard` and, say, `mindyard-cloud`) and keep one of them off
|
|
76
|
+
while testing the other: they expose the same tools, and the model may pick either.
|
|
77
|
+
|
|
68
78
|
Over HTTP instead, `MINDYARD_DATA_ROOT=./data mindyard serve` listens on
|
|
69
79
|
`http://127.0.0.1:8787/mcp`, without auth and on loopback only; authentication
|
|
70
80
|
below opens it to Claude.ai and remote clients.
|
|
@@ -88,6 +98,10 @@ garden/
|
|
|
88
98
|
wiki/ # distilled pages, linked with [[wikilinks]] (Obsidian-compatible)
|
|
89
99
|
```
|
|
90
100
|
|
|
101
|
+
A vault is a git repository: every write is a commit. `mindyard export garden
|
|
102
|
+
garden.bundle` writes it with its whole history to one file, and `git clone
|
|
103
|
+
garden.bundle garden` restores it anywhere.
|
|
104
|
+
|
|
91
105
|
## Authentication
|
|
92
106
|
|
|
93
107
|
Set `MINDYARD_AUTH`:
|
|
@@ -114,10 +128,11 @@ Claude.ai custom connectors accept static headers for some accounts only; OAuth
|
|
|
114
128
|
|---|---|---|
|
|
115
129
|
| `MINDYARD_DATA_ROOT` | (required) | holds `vaults/`, `tokens.yaml`, `state/` |
|
|
116
130
|
| `MINDYARD_AUTH` | `none` | `none`, `bearer`, `google` |
|
|
117
|
-
| `MINDYARD_TENANCY` | `single` | `mapped`: several tenants, see below |
|
|
131
|
+
| `MINDYARD_TENANCY` | `single` | `mapped` or `registry`: several tenants, see below |
|
|
118
132
|
| `MINDYARD_HOST`, `MINDYARD_PORT`, `MINDYARD_PATH` | `127.0.0.1`, `8787`, `/mcp` | |
|
|
119
133
|
| `MINDYARD_BASE_URL` | | public URL, for OAuth |
|
|
120
134
|
| `MINDYARD_ALLOWED_EMAILS` | | comma-separated, verified emails only |
|
|
135
|
+
| `MINDYARD_SIGNUP_URL` | | https page a refused Google account is pointed to |
|
|
121
136
|
| `MINDYARD_TELEMETRY` | `1` | one log line per tool call; argument values are never logged |
|
|
122
137
|
|
|
123
138
|
`state/` holds the OAuth proxy's client registrations and tokens. It is not a
|
|
@@ -128,6 +143,28 @@ cache: deleting it signs every client out.
|
|
|
128
143
|
`tenants/<tenant>/`. A caller only ever sees its own tenant's wikis; no tool
|
|
129
144
|
takes a tenant argument.
|
|
130
145
|
|
|
146
|
+
With `MINDYARD_TENANCY=registry`, the same mapping lives in `registry.sqlite`,
|
|
147
|
+
which can change while the server runs: no restart to add a tenant, a member or a
|
|
148
|
+
vault. The server only reads it; manage it with `mindyard tenant`:
|
|
149
|
+
|
|
150
|
+
```bash
|
|
151
|
+
mindyard tenant init
|
|
152
|
+
mindyard tenant add alice
|
|
153
|
+
mindyard tenant member-add alice https://accounts.google.com 1234567890
|
|
154
|
+
mindyard init "$MINDYARD_DATA_ROOT/tenants/alice/notes"
|
|
155
|
+
mindyard tenant touch alice # reload alice's vaults in the running server
|
|
156
|
+
mindyard tenant state alice read_only # suspend writes; reads go on
|
|
157
|
+
mindyard tenant quota alice --max-bytes 200M --max-file-bytes 2M
|
|
158
|
+
```
|
|
159
|
+
|
|
160
|
+
A storage cap counts every vault of the tenant with its git history. Every byte a
|
|
161
|
+
batch writes counts against it, since git keeps the previous versions; once the
|
|
162
|
+
cap is reached, only deletions pass.
|
|
163
|
+
|
|
164
|
+
A refused caller's issuer and subject are logged, for the operator to map. With
|
|
165
|
+
Google, an account that maps to no tenant is refused at sign-in, before it holds a
|
|
166
|
+
token; `MINDYARD_SIGNUP_URL` names where it can get access.
|
|
167
|
+
|
|
131
168
|
## Docker
|
|
132
169
|
|
|
133
170
|
```bash
|
|
@@ -25,6 +25,12 @@ Status: early release (0.1). Website: [mindyard.dev](https://mindyard.dev).
|
|
|
25
25
|
|
|
26
26
|
## Quickstart
|
|
27
27
|
|
|
28
|
+
You need [uv](https://docs.astral.sh/uv/) (it fetches Python 3.12 if needed) and
|
|
29
|
+
**git**: every write is a commit. On Windows, install Git for Windows from
|
|
30
|
+
[git-scm.com](https://git-scm.com/download/win) first; macOS and Linux usually ship it.
|
|
31
|
+
Optional, **ripgrep** (`rg`): searches run faster with it, and a search by regular
|
|
32
|
+
expression needs it; without it, search matches text literally.
|
|
33
|
+
|
|
28
34
|
```bash
|
|
29
35
|
uv tool install mindyard # or prefix each command with `uvx`, or `pip install mindyard`
|
|
30
36
|
mindyard init ./data/vaults/garden --demo
|
|
@@ -48,6 +54,10 @@ vaults of the user who runs it. Claude Desktop takes the same command in
|
|
|
48
54
|
}
|
|
49
55
|
```
|
|
50
56
|
|
|
57
|
+
If the same account also has a remote mindyard connector, give the two servers
|
|
58
|
+
distinct names (here `mindyard` and, say, `mindyard-cloud`) and keep one of them off
|
|
59
|
+
while testing the other: they expose the same tools, and the model may pick either.
|
|
60
|
+
|
|
51
61
|
Over HTTP instead, `MINDYARD_DATA_ROOT=./data mindyard serve` listens on
|
|
52
62
|
`http://127.0.0.1:8787/mcp`, without auth and on loopback only; authentication
|
|
53
63
|
below opens it to Claude.ai and remote clients.
|
|
@@ -71,6 +81,10 @@ garden/
|
|
|
71
81
|
wiki/ # distilled pages, linked with [[wikilinks]] (Obsidian-compatible)
|
|
72
82
|
```
|
|
73
83
|
|
|
84
|
+
A vault is a git repository: every write is a commit. `mindyard export garden
|
|
85
|
+
garden.bundle` writes it with its whole history to one file, and `git clone
|
|
86
|
+
garden.bundle garden` restores it anywhere.
|
|
87
|
+
|
|
74
88
|
## Authentication
|
|
75
89
|
|
|
76
90
|
Set `MINDYARD_AUTH`:
|
|
@@ -97,10 +111,11 @@ Claude.ai custom connectors accept static headers for some accounts only; OAuth
|
|
|
97
111
|
|---|---|---|
|
|
98
112
|
| `MINDYARD_DATA_ROOT` | (required) | holds `vaults/`, `tokens.yaml`, `state/` |
|
|
99
113
|
| `MINDYARD_AUTH` | `none` | `none`, `bearer`, `google` |
|
|
100
|
-
| `MINDYARD_TENANCY` | `single` | `mapped`: several tenants, see below |
|
|
114
|
+
| `MINDYARD_TENANCY` | `single` | `mapped` or `registry`: several tenants, see below |
|
|
101
115
|
| `MINDYARD_HOST`, `MINDYARD_PORT`, `MINDYARD_PATH` | `127.0.0.1`, `8787`, `/mcp` | |
|
|
102
116
|
| `MINDYARD_BASE_URL` | | public URL, for OAuth |
|
|
103
117
|
| `MINDYARD_ALLOWED_EMAILS` | | comma-separated, verified emails only |
|
|
118
|
+
| `MINDYARD_SIGNUP_URL` | | https page a refused Google account is pointed to |
|
|
104
119
|
| `MINDYARD_TELEMETRY` | `1` | one log line per tool call; argument values are never logged |
|
|
105
120
|
|
|
106
121
|
`state/` holds the OAuth proxy's client registrations and tokens. It is not a
|
|
@@ -111,6 +126,28 @@ cache: deleting it signs every client out.
|
|
|
111
126
|
`tenants/<tenant>/`. A caller only ever sees its own tenant's wikis; no tool
|
|
112
127
|
takes a tenant argument.
|
|
113
128
|
|
|
129
|
+
With `MINDYARD_TENANCY=registry`, the same mapping lives in `registry.sqlite`,
|
|
130
|
+
which can change while the server runs: no restart to add a tenant, a member or a
|
|
131
|
+
vault. The server only reads it; manage it with `mindyard tenant`:
|
|
132
|
+
|
|
133
|
+
```bash
|
|
134
|
+
mindyard tenant init
|
|
135
|
+
mindyard tenant add alice
|
|
136
|
+
mindyard tenant member-add alice https://accounts.google.com 1234567890
|
|
137
|
+
mindyard init "$MINDYARD_DATA_ROOT/tenants/alice/notes"
|
|
138
|
+
mindyard tenant touch alice # reload alice's vaults in the running server
|
|
139
|
+
mindyard tenant state alice read_only # suspend writes; reads go on
|
|
140
|
+
mindyard tenant quota alice --max-bytes 200M --max-file-bytes 2M
|
|
141
|
+
```
|
|
142
|
+
|
|
143
|
+
A storage cap counts every vault of the tenant with its git history. Every byte a
|
|
144
|
+
batch writes counts against it, since git keeps the previous versions; once the
|
|
145
|
+
cap is reached, only deletions pass.
|
|
146
|
+
|
|
147
|
+
A refused caller's issuer and subject are logged, for the operator to map. With
|
|
148
|
+
Google, an account that maps to no tenant is refused at sign-in, before it holds a
|
|
149
|
+
token; `MINDYARD_SIGNUP_URL` names where it can get access.
|
|
150
|
+
|
|
114
151
|
## Docker
|
|
115
152
|
|
|
116
153
|
```bash
|
|
@@ -8,13 +8,13 @@
|
|
|
8
8
|
"url": "https://github.com/floriantriclin/mindyard",
|
|
9
9
|
"source": "github"
|
|
10
10
|
},
|
|
11
|
-
"version": "0.
|
|
11
|
+
"version": "0.2.0",
|
|
12
12
|
"packages": [
|
|
13
13
|
{
|
|
14
14
|
"registryType": "pypi",
|
|
15
15
|
"registryBaseUrl": "https://pypi.org",
|
|
16
16
|
"identifier": "mindyard",
|
|
17
|
-
"version": "0.
|
|
17
|
+
"version": "0.2.0",
|
|
18
18
|
"runtimeHint": "uvx",
|
|
19
19
|
"transport": {
|
|
20
20
|
"type": "stdio"
|
|
@@ -31,8 +31,11 @@ server instructions, but less well.
|
|
|
31
31
|
- Prefer `replace` over `overwrite`. `raw/` is create-only. `wiki.yaml` is
|
|
32
32
|
read-only for you; propose changes to the user instead. One exception: in a
|
|
33
33
|
new vault whose `wiki.yaml` still holds the `# mindyard:bootstrap` line, define
|
|
34
|
-
it with the user
|
|
35
|
-
overwrite it once, without that line, in the same batch
|
|
34
|
+
it with the user: ask its purpose, propose a small first draft (two to four
|
|
35
|
+
kinds of pages), then overwrite it once, without that line, in the same batch
|
|
36
|
+
as `schema.md`. The owner adds kinds later by hand: start small.
|
|
37
|
+
- If a batch is refused and fixing it changes the agreed plan, present the new
|
|
38
|
+
plan and wait for agreement again.
|
|
36
39
|
|
|
37
40
|
## Operations
|
|
38
41
|
|
|
@@ -143,12 +143,14 @@ class GoogleAuth:
|
|
|
143
143
|
base_url: str,
|
|
144
144
|
redirect_path: str = "/auth/callback",
|
|
145
145
|
policy: AccessPolicy | None = None,
|
|
146
|
+
denied_uri: str | None = None,
|
|
146
147
|
) -> None:
|
|
147
148
|
self._client_id = client_id
|
|
148
149
|
self._client_secret = client_secret
|
|
149
150
|
self._base_url = base_url
|
|
150
151
|
self._redirect_path = redirect_path
|
|
151
152
|
self._policy = policy
|
|
153
|
+
self._denied_uri = denied_uri
|
|
152
154
|
|
|
153
155
|
def provider(self) -> AuthProvider | None:
|
|
154
156
|
options: dict[str, Any] = {
|
|
@@ -162,7 +164,9 @@ class GoogleAuth:
|
|
|
162
164
|
if policy is None:
|
|
163
165
|
return StableConsentGoogleProvider(**options)
|
|
164
166
|
return GatedGoogleProvider(
|
|
165
|
-
admit=lambda token: policy.allows(self.identity(token)),
|
|
167
|
+
admit=lambda token: policy.allows(self.identity(token)),
|
|
168
|
+
denied_uri=self._denied_uri,
|
|
169
|
+
**options,
|
|
166
170
|
)
|
|
167
171
|
|
|
168
172
|
def identity(self, token: AccessToken | None) -> Identity | None:
|
|
@@ -10,6 +10,8 @@ This mixin checks the identity as soon as Google's tokens are in hand. A refused
|
|
|
10
10
|
identity gets no code: its code is deleted and the client is redirected with
|
|
11
11
|
``error=access_denied`` (RFC 6749, section 4.1.2.1), so it never stores a token.
|
|
12
12
|
The per-request gate stays the authority; this is the early, friendly refusal.
|
|
13
|
+
Given a ``denied_uri`` (a sign-up page, for a hosted service), the refusal points
|
|
14
|
+
there, as ``error_uri`` and in the description.
|
|
13
15
|
|
|
14
16
|
Like the consent mixin, it post-processes FastMCP's response instead of copying
|
|
15
17
|
its handler. It depends on the code store, the ``idp_tokens`` of a stored code
|
|
@@ -23,6 +25,7 @@ from collections.abc import Awaitable, Callable
|
|
|
23
25
|
from typing import Any
|
|
24
26
|
from urllib.parse import parse_qs, urlencode, urlparse
|
|
25
27
|
|
|
28
|
+
import anyio
|
|
26
29
|
from fastmcp.server.auth import AccessToken
|
|
27
30
|
from starlette.requests import Request
|
|
28
31
|
from starlette.responses import HTMLResponse, RedirectResponse
|
|
@@ -35,9 +38,12 @@ DENIED_DESCRIPTION = "This account is not allowed on this server."
|
|
|
35
38
|
class CallbackGateMixin:
|
|
36
39
|
"""Mix into an ``OAuthProxy`` subclass, before it in the bases."""
|
|
37
40
|
|
|
38
|
-
def __init__(
|
|
41
|
+
def __init__(
|
|
42
|
+
self, *args: Any, admit: Admit, denied_uri: str | None = None, **kwargs: Any
|
|
43
|
+
) -> None:
|
|
39
44
|
super().__init__(*args, **kwargs)
|
|
40
45
|
self._admit = admit
|
|
46
|
+
self._denied_uri = denied_uri
|
|
41
47
|
|
|
42
48
|
async def _handle_idp_callback(self, request: Request) -> HTMLResponse | RedirectResponse:
|
|
43
49
|
proxy: Any = self
|
|
@@ -52,11 +58,16 @@ class CallbackGateMixin:
|
|
|
52
58
|
if not code:
|
|
53
59
|
return response
|
|
54
60
|
stored = await proxy._code_store.get(key=code)
|
|
55
|
-
|
|
61
|
+
# The verdict may read a database or the disk: keep it off the event loop.
|
|
62
|
+
verified = await self._verify(stored.idp_tokens) if stored is not None else None
|
|
63
|
+
if stored is not None and await anyio.to_thread.run_sync(self._admit, verified):
|
|
56
64
|
return response
|
|
57
65
|
|
|
58
66
|
await proxy._code_store.delete(key=code)
|
|
59
67
|
denied = {"error": "access_denied", "error_description": DENIED_DESCRIPTION}
|
|
68
|
+
if self._denied_uri:
|
|
69
|
+
denied["error_description"] = f"{DENIED_DESCRIPTION} Get access at {self._denied_uri}"
|
|
70
|
+
denied["error_uri"] = self._denied_uri
|
|
60
71
|
if "state" in params:
|
|
61
72
|
denied["state"] = params["state"][0]
|
|
62
73
|
kept = [(k, v) for k, vs in params.items() if k not in ("code", "state") for v in vs]
|
|
@@ -0,0 +1,261 @@
|
|
|
1
|
+
# SPDX-License-Identifier: AGPL-3.0-or-later
|
|
2
|
+
"""The ``mindyard`` command line: init, serve, lint, export, token, tenant."""
|
|
3
|
+
|
|
4
|
+
from __future__ import annotations
|
|
5
|
+
|
|
6
|
+
import argparse
|
|
7
|
+
import contextlib
|
|
8
|
+
import os
|
|
9
|
+
import sys
|
|
10
|
+
import warnings
|
|
11
|
+
from collections.abc import Sequence
|
|
12
|
+
from pathlib import Path
|
|
13
|
+
|
|
14
|
+
from mindyard import __version__
|
|
15
|
+
|
|
16
|
+
|
|
17
|
+
def _cmd_init(args: argparse.Namespace) -> int:
|
|
18
|
+
from mindyard.init import InitError, init_vault
|
|
19
|
+
|
|
20
|
+
target = Path(args.directory)
|
|
21
|
+
label = args.label or target.name.replace("-", " ").capitalize()
|
|
22
|
+
try:
|
|
23
|
+
init_vault(target, label, "demo" if args.demo else "blank")
|
|
24
|
+
except InitError as exc:
|
|
25
|
+
print(f"mindyard init: {exc}", file=sys.stderr)
|
|
26
|
+
return 2
|
|
27
|
+
print(f"Vault created in {target}. Edit wiki.yaml and schema.md to make it yours.")
|
|
28
|
+
return 0
|
|
29
|
+
|
|
30
|
+
|
|
31
|
+
def _cmd_serve(args: argparse.Namespace) -> int:
|
|
32
|
+
from mindyard.mcp import run
|
|
33
|
+
from mindyard.settings import Settings, SettingsError
|
|
34
|
+
from mindyard.tenancy import RegistryError, TenantConfigError
|
|
35
|
+
|
|
36
|
+
env = dict(os.environ)
|
|
37
|
+
for flag, name in (
|
|
38
|
+
("data_root", "MINDYARD_DATA_ROOT"),
|
|
39
|
+
("host", "MINDYARD_HOST"),
|
|
40
|
+
("port", "MINDYARD_PORT"),
|
|
41
|
+
):
|
|
42
|
+
value = getattr(args, flag)
|
|
43
|
+
if value is not None:
|
|
44
|
+
env[name] = str(value)
|
|
45
|
+
try:
|
|
46
|
+
run(Settings.from_env(env), "stdio" if args.stdio else "http")
|
|
47
|
+
except (SettingsError, TenantConfigError, RegistryError) as exc:
|
|
48
|
+
print(f"mindyard serve: {exc}", file=sys.stderr)
|
|
49
|
+
return 2
|
|
50
|
+
return 0
|
|
51
|
+
|
|
52
|
+
|
|
53
|
+
def _cmd_lint(args: argparse.Namespace) -> int:
|
|
54
|
+
from mindyard.core.config import CONFIG_FILE
|
|
55
|
+
from mindyard.lint import fix_table_pipes, lint_wiki, write_report
|
|
56
|
+
from mindyard.schema import ManifestError, Wiki, load_manifest
|
|
57
|
+
|
|
58
|
+
root = Path(args.vault).resolve()
|
|
59
|
+
if not (root / CONFIG_FILE).is_file():
|
|
60
|
+
print(f"mindyard lint: no {CONFIG_FILE} in {root}", file=sys.stderr)
|
|
61
|
+
return 2
|
|
62
|
+
try:
|
|
63
|
+
manifest = load_manifest(root)
|
|
64
|
+
except ManifestError as exc:
|
|
65
|
+
print(f"mindyard lint: {exc}", file=sys.stderr)
|
|
66
|
+
return 2
|
|
67
|
+
wiki = Wiki(manifest.to_config(root.name, root), manifest)
|
|
68
|
+
if args.fix:
|
|
69
|
+
for page, count in fix_table_pipes(wiki):
|
|
70
|
+
print(f"fixed {count} table pipe(s) in {page}")
|
|
71
|
+
findings = lint_wiki(wiki)
|
|
72
|
+
report = write_report(wiki, findings)
|
|
73
|
+
print(f"{findings.total} issue(s), {len(findings.items) - findings.total} notice(s): {report}")
|
|
74
|
+
return 1 if findings.total else 0
|
|
75
|
+
|
|
76
|
+
|
|
77
|
+
def _cmd_export(args: argparse.Namespace) -> int:
|
|
78
|
+
from mindyard.core.errors import GitError
|
|
79
|
+
from mindyard.core.git import export_bundle, is_repo
|
|
80
|
+
|
|
81
|
+
root = Path(args.vault)
|
|
82
|
+
if not is_repo(root):
|
|
83
|
+
print(f"mindyard export: {root} is not a vault (no git repository)", file=sys.stderr)
|
|
84
|
+
return 2
|
|
85
|
+
try:
|
|
86
|
+
target = export_bundle(root, Path(args.output))
|
|
87
|
+
except GitError as exc:
|
|
88
|
+
print(f"mindyard export: {exc}", file=sys.stderr)
|
|
89
|
+
return 2
|
|
90
|
+
print(target)
|
|
91
|
+
print(f"Restore with: git clone {target} <directory>", file=sys.stderr)
|
|
92
|
+
return 0
|
|
93
|
+
|
|
94
|
+
|
|
95
|
+
def _cmd_token(args: argparse.Namespace) -> int:
|
|
96
|
+
from mindyard.auth import TokenStoreError, add_token
|
|
97
|
+
|
|
98
|
+
data_root = args.data_root or os.environ.get("MINDYARD_DATA_ROOT")
|
|
99
|
+
if not data_root:
|
|
100
|
+
print("mindyard token: set MINDYARD_DATA_ROOT or pass --data-root", file=sys.stderr)
|
|
101
|
+
return 2
|
|
102
|
+
try:
|
|
103
|
+
token = add_token(Path(data_root) / "tokens.yaml", args.name)
|
|
104
|
+
except TokenStoreError as exc:
|
|
105
|
+
print(f"mindyard token: {exc}", file=sys.stderr)
|
|
106
|
+
return 2
|
|
107
|
+
print(token)
|
|
108
|
+
print(
|
|
109
|
+
"Shown once: only its digest is stored. Restart the server to load it.",
|
|
110
|
+
file=sys.stderr,
|
|
111
|
+
)
|
|
112
|
+
return 0
|
|
113
|
+
|
|
114
|
+
|
|
115
|
+
def _cmd_tenant(args: argparse.Namespace) -> int:
|
|
116
|
+
from mindyard.tenancy import REGISTRY_FILE, Registry, RegistryError
|
|
117
|
+
|
|
118
|
+
data_root = args.data_root or os.environ.get("MINDYARD_DATA_ROOT")
|
|
119
|
+
if not data_root:
|
|
120
|
+
print("mindyard tenant: set MINDYARD_DATA_ROOT or pass --data-root", file=sys.stderr)
|
|
121
|
+
return 2
|
|
122
|
+
path = Path(data_root) / REGISTRY_FILE
|
|
123
|
+
try:
|
|
124
|
+
if args.action == "init":
|
|
125
|
+
Registry.create(path)
|
|
126
|
+
print(f"Registry created: {path}")
|
|
127
|
+
return 0
|
|
128
|
+
registry = Registry.open(path)
|
|
129
|
+
if args.action == "list":
|
|
130
|
+
for record in registry.tenants():
|
|
131
|
+
print(
|
|
132
|
+
f"{record.id}\t{record.state}\tgeneration {record.generation}"
|
|
133
|
+
f"\tmax {record.max_bytes or '-'} B, {record.max_file_bytes or '-'} B/file"
|
|
134
|
+
f"\tcreated {record.created_at}"
|
|
135
|
+
)
|
|
136
|
+
for issuer, subject in record.members:
|
|
137
|
+
print(f" {issuer} {subject}")
|
|
138
|
+
elif args.action == "add":
|
|
139
|
+
registry.add_tenant(args.tenant, existing_vaults=args.existing_vaults)
|
|
140
|
+
elif args.action == "remove":
|
|
141
|
+
registry.remove_tenant(args.tenant)
|
|
142
|
+
print(f"Vaults under tenants/{args.tenant}/ were left on disk.", file=sys.stderr)
|
|
143
|
+
elif args.action == "member-add":
|
|
144
|
+
registry.add_member(args.tenant, args.issuer, args.subject)
|
|
145
|
+
elif args.action == "member-remove":
|
|
146
|
+
registry.remove_member(args.issuer, args.subject)
|
|
147
|
+
elif args.action == "touch":
|
|
148
|
+
registry.touch(args.tenant)
|
|
149
|
+
elif args.action == "state":
|
|
150
|
+
registry.set_state(args.tenant, args.state)
|
|
151
|
+
elif args.action == "quota":
|
|
152
|
+
registry.set_quota(args.tenant, args.max_bytes, args.max_file_bytes)
|
|
153
|
+
except RegistryError as exc:
|
|
154
|
+
print(f"mindyard tenant: {exc}", file=sys.stderr)
|
|
155
|
+
return 2
|
|
156
|
+
return 0
|
|
157
|
+
|
|
158
|
+
|
|
159
|
+
def _size(text: str) -> int:
|
|
160
|
+
"""A byte count, with an optional K, M or G suffix (powers of 1000)."""
|
|
161
|
+
units = {"K": 1000, "M": 1000**2, "G": 1000**3}
|
|
162
|
+
text = text.strip().upper().removesuffix("B")
|
|
163
|
+
factor = units.get(text[-1:], 1)
|
|
164
|
+
digits = text[:-1] if text[-1:] in units else text
|
|
165
|
+
try:
|
|
166
|
+
value = int(digits) * factor
|
|
167
|
+
except ValueError:
|
|
168
|
+
raise argparse.ArgumentTypeError(f"not a size: {text!r}") from None
|
|
169
|
+
if value <= 0:
|
|
170
|
+
raise argparse.ArgumentTypeError("a size must be positive")
|
|
171
|
+
return value
|
|
172
|
+
|
|
173
|
+
|
|
174
|
+
def build_parser() -> argparse.ArgumentParser:
|
|
175
|
+
parser = argparse.ArgumentParser(prog="mindyard", description=__doc__)
|
|
176
|
+
parser.add_argument("--version", action="version", version=f"mindyard {__version__}")
|
|
177
|
+
sub = parser.add_subparsers(dest="command", required=True)
|
|
178
|
+
|
|
179
|
+
p = sub.add_parser("init", help="create a vault")
|
|
180
|
+
p.add_argument("directory")
|
|
181
|
+
p.add_argument("--label", help="display name (default: from the directory name)")
|
|
182
|
+
p.add_argument("--demo", action="store_true", help="start from the demo garden vault")
|
|
183
|
+
p.set_defaults(func=_cmd_init)
|
|
184
|
+
|
|
185
|
+
p = sub.add_parser("serve", help="run the MCP server (configured by MINDYARD_* variables)")
|
|
186
|
+
p.add_argument("--data-root")
|
|
187
|
+
p.add_argument("--host")
|
|
188
|
+
p.add_argument("--port", type=int)
|
|
189
|
+
p.add_argument(
|
|
190
|
+
"--stdio",
|
|
191
|
+
action="store_true",
|
|
192
|
+
help="serve over stdin/stdout for a local client (no auth, ignores host and port)",
|
|
193
|
+
)
|
|
194
|
+
p.set_defaults(func=_cmd_serve)
|
|
195
|
+
|
|
196
|
+
p = sub.add_parser("lint", help="lint one vault and write its LINT_REPORT.md")
|
|
197
|
+
p.add_argument("vault")
|
|
198
|
+
p.add_argument("--fix", action="store_true", help="escape table-cell wikilink pipes first")
|
|
199
|
+
p.set_defaults(func=_cmd_lint)
|
|
200
|
+
|
|
201
|
+
p = sub.add_parser("export", help="write a vault and its whole history to a git bundle")
|
|
202
|
+
p.add_argument("vault")
|
|
203
|
+
p.add_argument("output", help="file to create, e.g. notes.bundle")
|
|
204
|
+
p.set_defaults(func=_cmd_export)
|
|
205
|
+
|
|
206
|
+
p = sub.add_parser("token", help="mint a bearer token")
|
|
207
|
+
p.add_argument("action", choices=["new"])
|
|
208
|
+
p.add_argument("name", help="principal name, e.g. laptop")
|
|
209
|
+
p.add_argument("--data-root")
|
|
210
|
+
p.set_defaults(func=_cmd_token)
|
|
211
|
+
|
|
212
|
+
p = sub.add_parser("tenant", help="manage the tenant registry (MINDYARD_TENANCY=registry)")
|
|
213
|
+
p.add_argument("--data-root")
|
|
214
|
+
actions = p.add_subparsers(dest="action", required=True)
|
|
215
|
+
actions.add_parser("init", help="create an empty registry")
|
|
216
|
+
actions.add_parser("list", help="list tenants and their members")
|
|
217
|
+
a = actions.add_parser("add", help="add a tenant")
|
|
218
|
+
a.add_argument("tenant")
|
|
219
|
+
a.add_argument(
|
|
220
|
+
"--existing-vaults",
|
|
221
|
+
action="store_true",
|
|
222
|
+
help="its directory already exists and belongs to it (a rebuilt registry)",
|
|
223
|
+
)
|
|
224
|
+
for name, text in (
|
|
225
|
+
("remove", "remove a tenant and its members (its vaults stay on disk)"),
|
|
226
|
+
("touch", "make the running server reload a tenant's vaults"),
|
|
227
|
+
):
|
|
228
|
+
a = actions.add_parser(name, help=text)
|
|
229
|
+
a.add_argument("tenant")
|
|
230
|
+
a = actions.add_parser("state", help="suspend writes (read_only) or restore them (active)")
|
|
231
|
+
a.add_argument("tenant")
|
|
232
|
+
a.add_argument("state", choices=["active", "read_only"])
|
|
233
|
+
a = actions.add_parser("quota", help="cap storage and file size (omit a cap to lift it)")
|
|
234
|
+
a.add_argument("tenant")
|
|
235
|
+
a.add_argument("--max-bytes", type=_size, help="all vaults with history, e.g. 200M")
|
|
236
|
+
a.add_argument("--max-file-bytes", type=_size, help="any single file, e.g. 2M")
|
|
237
|
+
a = actions.add_parser("member-add", help="map an identity (issuer, subject) to a tenant")
|
|
238
|
+
a.add_argument("tenant")
|
|
239
|
+
a.add_argument("issuer")
|
|
240
|
+
a.add_argument("subject")
|
|
241
|
+
a = actions.add_parser("member-remove", help="unmap an identity")
|
|
242
|
+
a.add_argument("issuer")
|
|
243
|
+
a.add_argument("subject")
|
|
244
|
+
p.set_defaults(func=_cmd_tenant)
|
|
245
|
+
return parser
|
|
246
|
+
|
|
247
|
+
|
|
248
|
+
def main(argv: Sequence[str] | None = None) -> int:
|
|
249
|
+
# A dependency of FastMCP's OAuth support announces a future change on import;
|
|
250
|
+
# it says nothing about mindyard and alarms people reading the server log.
|
|
251
|
+
# authlib installs an "always" filter when loaded, so load it first.
|
|
252
|
+
with contextlib.suppress(ImportError):
|
|
253
|
+
import authlib.deprecate # type: ignore[import-untyped] # noqa: F401
|
|
254
|
+
warnings.filterwarnings("ignore", message="The httpx module is deprecated")
|
|
255
|
+
args = build_parser().parse_args(argv)
|
|
256
|
+
code: int = args.func(args)
|
|
257
|
+
return code
|
|
258
|
+
|
|
259
|
+
|
|
260
|
+
if __name__ == "__main__":
|
|
261
|
+
raise SystemExit(main())
|
|
@@ -132,6 +132,17 @@ class ReplaceNotFoundError(MindyardError):
|
|
|
132
132
|
)
|
|
133
133
|
|
|
134
134
|
|
|
135
|
+
class ReplaceEmptyOldError(MindyardError):
|
|
136
|
+
"""Raised when a ``replace`` op's ``old`` string is empty."""
|
|
137
|
+
|
|
138
|
+
def __init__(self, user_path: str) -> None:
|
|
139
|
+
self.user_path = user_path
|
|
140
|
+
super().__init__(
|
|
141
|
+
f"The 'old' text is empty in the replace on '{user_path}'. Give the exact "
|
|
142
|
+
"text to change, or use overwrite to rewrite the whole page."
|
|
143
|
+
)
|
|
144
|
+
|
|
145
|
+
|
|
135
146
|
class ReplaceAmbiguousError(MindyardError):
|
|
136
147
|
"""Raised when a ``replace`` op's ``old`` matches more than once."""
|
|
137
148
|
|
|
@@ -251,5 +262,72 @@ class InvalidRegexError(MindyardError):
|
|
|
251
262
|
super().__init__(f"Invalid regular expression: '{pattern}'.")
|
|
252
263
|
|
|
253
264
|
|
|
265
|
+
class RegexUnavailableError(MindyardError):
|
|
266
|
+
"""Raised when ``search_wiki(regex=True)`` runs without ripgrep.
|
|
267
|
+
|
|
268
|
+
Python's backtracking engine has no time limit: a crafted pattern such as
|
|
269
|
+
``(a+)+$`` could stall the whole server. ripgrep's engine runs in linear time.
|
|
270
|
+
"""
|
|
271
|
+
|
|
272
|
+
def __init__(self) -> None:
|
|
273
|
+
super().__init__(
|
|
274
|
+
"Regular-expression search is not available on this server (it needs "
|
|
275
|
+
"ripgrep). Search again with regex=false: a literal, case-insensitive match."
|
|
276
|
+
)
|
|
277
|
+
|
|
278
|
+
|
|
279
|
+
class SearchTimeoutError(MindyardError):
|
|
280
|
+
"""Raised when a search runs past its time limit."""
|
|
281
|
+
|
|
282
|
+
def __init__(self) -> None:
|
|
283
|
+
super().__init__(
|
|
284
|
+
"The search took too long and was stopped. Narrow it: a longer or more "
|
|
285
|
+
"specific query, or a smaller scope."
|
|
286
|
+
)
|
|
287
|
+
|
|
288
|
+
|
|
254
289
|
class GitError(MindyardError):
|
|
255
290
|
"""Raised when a git operation fails (commit, rollback, etc.)."""
|
|
291
|
+
|
|
292
|
+
|
|
293
|
+
def human_size(size: int) -> str:
|
|
294
|
+
"""Bytes as a short reading for a message: 980 B, 12.5 kB, 3.2 MB."""
|
|
295
|
+
value = float(size)
|
|
296
|
+
for unit in ("B", "kB", "MB"):
|
|
297
|
+
if value < 1000:
|
|
298
|
+
return f"{value:.0f} {unit}" if unit == "B" else f"{value:.1f} {unit}"
|
|
299
|
+
value /= 1000
|
|
300
|
+
return f"{value:.1f} GB"
|
|
301
|
+
|
|
302
|
+
|
|
303
|
+
class FileTooLargeError(MindyardError):
|
|
304
|
+
"""Raised when a batch would write a file over the per-file size limit."""
|
|
305
|
+
|
|
306
|
+
def __init__(self, user_path: str, size: int, limit: int) -> None:
|
|
307
|
+
self.user_path = user_path
|
|
308
|
+
super().__init__(
|
|
309
|
+
f"'{user_path}' would be {human_size(size)}, over the limit of "
|
|
310
|
+
f"{human_size(limit)} per file; nothing was written. Split the content."
|
|
311
|
+
)
|
|
312
|
+
|
|
313
|
+
|
|
314
|
+
class QuotaExceededError(MindyardError):
|
|
315
|
+
"""Raised when a batch would write more than the caller's storage has left."""
|
|
316
|
+
|
|
317
|
+
def __init__(self, written: int, available: int) -> None:
|
|
318
|
+
super().__init__(
|
|
319
|
+
f"Storage limit reached: this batch writes {human_size(written)}, only "
|
|
320
|
+
f"{human_size(max(available, 0))} left for this account; nothing was written. "
|
|
321
|
+
"The limit counts every wiki with its full history, so deleting pages does "
|
|
322
|
+
"not free space: the account owner can raise the limit."
|
|
323
|
+
)
|
|
324
|
+
|
|
325
|
+
|
|
326
|
+
class WritesSuspendedError(MindyardError):
|
|
327
|
+
"""Raised when the caller's vaults are read-only for now (a suspended account)."""
|
|
328
|
+
|
|
329
|
+
def __init__(self) -> None:
|
|
330
|
+
super().__init__(
|
|
331
|
+
"Writes are suspended for this account: its wikis are read-only for now, "
|
|
332
|
+
"nothing was written. Reading, searching and linting still work."
|
|
333
|
+
)
|