rb-clidocs 0.1.6__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.
- rb_clidocs-0.1.6/.gitignore +20 -0
- rb_clidocs-0.1.6/LICENSE +21 -0
- rb_clidocs-0.1.6/PKG-INFO +136 -0
- rb_clidocs-0.1.6/README.md +119 -0
- rb_clidocs-0.1.6/pyproject.toml +169 -0
- rb_clidocs-0.1.6/src/rb_clidocs/__init__.py +1 -0
- rb_clidocs-0.1.6/src/rb_clidocs/_distribution.py +24 -0
- rb_clidocs-0.1.6/src/rb_clidocs/cli.py +70 -0
- rb_clidocs-0.1.6/src/rb_clidocs/commands/__init__.py +1 -0
- rb_clidocs-0.1.6/src/rb_clidocs/commands/auth.py +66 -0
- rb_clidocs-0.1.6/src/rb_clidocs/commands/config.py +87 -0
- rb_clidocs-0.1.6/src/rb_clidocs/commands/describe.py +34 -0
- rb_clidocs-0.1.6/src/rb_clidocs/commands/docs.py +33 -0
- rb_clidocs-0.1.6/src/rb_clidocs/commands/doctor.py +43 -0
- rb_clidocs-0.1.6/src/rb_clidocs/commands/init.py +48 -0
- rb_clidocs-0.1.6/src/rb_clidocs/commands/project.py +55 -0
- rb_clidocs-0.1.6/src/rb_clidocs/commands/render.py +38 -0
- rb_clidocs-0.1.6/src/rb_clidocs/commands/skill.py +138 -0
- rb_clidocs-0.1.6/src/rb_clidocs/commands/status.py +35 -0
- rb_clidocs-0.1.6/src/rb_clidocs/core/__init__.py +1 -0
- rb_clidocs-0.1.6/src/rb_clidocs/core/data_files.py +20 -0
- rb_clidocs-0.1.6/src/rb_clidocs/core/deps.py +165 -0
- rb_clidocs-0.1.6/src/rb_clidocs/core/docs.py +222 -0
- rb_clidocs-0.1.6/src/rb_clidocs/core/errors.py +215 -0
- rb_clidocs-0.1.6/src/rb_clidocs/core/models.py +25 -0
- rb_clidocs-0.1.6/src/rb_clidocs/core/normalize.py +52 -0
- rb_clidocs-0.1.6/src/rb_clidocs/core/opencli.py +285 -0
- rb_clidocs-0.1.6/src/rb_clidocs/core/render.py +130 -0
- rb_clidocs-0.1.6/src/rb_clidocs/core/services.py +82 -0
- rb_clidocs-0.1.6/src/rb_clidocs/core/skills.py +64 -0
- rb_clidocs-0.1.6/src/rb_clidocs/core/version.py +89 -0
- rb_clidocs-0.1.6/src/rb_clidocs/data/SKILL.md +68 -0
- rb_clidocs-0.1.6/src/rb_clidocs/data/__init__.py +1 -0
- rb_clidocs-0.1.6/src/rb_clidocs/output/__init__.py +279 -0
- rb_clidocs-0.1.6/src/rb_clidocs/output/human.py +34 -0
- rb_clidocs-0.1.6/src/rb_clidocs/output/json.py +11 -0
- rb_clidocs-0.1.6/tests/__init__.py +1 -0
- rb_clidocs-0.1.6/tests/conftest.py +29 -0
- rb_clidocs-0.1.6/tests/contracts/fixtures.yaml +11 -0
- rb_clidocs-0.1.6/tests/contracts/schema.json +89 -0
- rb_clidocs-0.1.6/tests/contracts/tools-catalog/clidocs.yaml +20 -0
- rb_clidocs-0.1.6/tests/data/contracts/windmill-serp.yaml +106 -0
- rb_clidocs-0.1.6/tests/data/opencli.schema.json +350 -0
- rb_clidocs-0.1.6/tests/help_allowlist.txt +3 -0
- rb_clidocs-0.1.6/tests/snapshots/describe.json +1008 -0
- rb_clidocs-0.1.6/tests/snapshots/help/auth-status.txt +26 -0
- rb_clidocs-0.1.6/tests/snapshots/help/auth.txt +13 -0
- rb_clidocs-0.1.6/tests/snapshots/help/config-get.txt +16 -0
- rb_clidocs-0.1.6/tests/snapshots/help/config-list.txt +13 -0
- rb_clidocs-0.1.6/tests/snapshots/help/config-set.txt +17 -0
- rb_clidocs-0.1.6/tests/snapshots/help/config.txt +14 -0
- rb_clidocs-0.1.6/tests/snapshots/help/describe.txt +18 -0
- rb_clidocs-0.1.6/tests/snapshots/help/docs.txt +20 -0
- rb_clidocs-0.1.6/tests/snapshots/help/doctor.txt +17 -0
- rb_clidocs-0.1.6/tests/snapshots/help/init.txt +16 -0
- rb_clidocs-0.1.6/tests/snapshots/help/render.txt +22 -0
- rb_clidocs-0.1.6/tests/snapshots/help/skill-install.txt +18 -0
- rb_clidocs-0.1.6/tests/snapshots/help/skill-list.txt +13 -0
- rb_clidocs-0.1.6/tests/snapshots/help/skill.txt +13 -0
- rb_clidocs-0.1.6/tests/snapshots/help/status.txt +14 -0
- rb_clidocs-0.1.6/tests/test_cli.py +307 -0
- rb_clidocs-0.1.6/tests/test_contract_runner.py +257 -0
- rb_clidocs-0.1.6/tests/test_contracts.py +389 -0
- rb_clidocs-0.1.6/tests/test_deps.py +150 -0
- rb_clidocs-0.1.6/tests/test_describe.py +181 -0
- rb_clidocs-0.1.6/tests/test_detach.py +161 -0
- rb_clidocs-0.1.6/tests/test_docs.py +245 -0
- rb_clidocs-0.1.6/tests/test_help.py +495 -0
- rb_clidocs-0.1.6/tests/test_normalize.py +44 -0
- rb_clidocs-0.1.6/tests/test_project.py +155 -0
- rb_clidocs-0.1.6/tests/test_render.py +183 -0
- rb_clidocs-0.1.6/tests/test_scripts.py +54 -0
- rb_clidocs-0.1.6/tests/test_services.py +50 -0
- rb_clidocs-0.1.6/tests/test_skills.py +181 -0
|
@@ -0,0 +1,20 @@
|
|
|
1
|
+
__pycache__/
|
|
2
|
+
*.py[cod]
|
|
3
|
+
.venv/
|
|
4
|
+
.pytest_cache/
|
|
5
|
+
.ruff_cache/
|
|
6
|
+
dist/
|
|
7
|
+
*.egg-info/
|
|
8
|
+
.python-version
|
|
9
|
+
.coverage
|
|
10
|
+
htmlcov/
|
|
11
|
+
# mutmut's working copy and results (uv run --group mutation mutmut run)
|
|
12
|
+
mutants/
|
|
13
|
+
# Local env files hold keys: keys never go into the repo (the gate's secret scan)
|
|
14
|
+
.env
|
|
15
|
+
.env.*
|
|
16
|
+
# The root lines Antagor adds
|
|
17
|
+
.DS_Store
|
|
18
|
+
Thumbs.db
|
|
19
|
+
.pdm-build/
|
|
20
|
+
.cache/
|
rb_clidocs-0.1.6/LICENSE
ADDED
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Roman Bolandau
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,136 @@
|
|
|
1
|
+
Metadata-Version: 2.5
|
|
2
|
+
Name: rb-clidocs
|
|
3
|
+
Version: 0.1.6
|
|
4
|
+
Summary: Human-readable CLI help in the browser: renders a tool's docs with InSpectra.
|
|
5
|
+
Project-URL: Repository, https://github.com/bolandeu/clidocs
|
|
6
|
+
Author: Roman Bolandau
|
|
7
|
+
License-Expression: MIT
|
|
8
|
+
License-File: LICENSE
|
|
9
|
+
Requires-Python: >=3.14
|
|
10
|
+
Requires-Dist: packaging>=24.0
|
|
11
|
+
Requires-Dist: platformdirs>=4.2
|
|
12
|
+
Requires-Dist: pydantic>=2.6
|
|
13
|
+
Requires-Dist: rich>=13.7
|
|
14
|
+
Requires-Dist: tomli-w>=1.0
|
|
15
|
+
Requires-Dist: typer<0.29,>=0.27
|
|
16
|
+
Description-Content-Type: text/markdown
|
|
17
|
+
|
|
18
|
+
# clidocs
|
|
19
|
+
|
|
20
|
+
Human CLI help in the browser: renders a tool's docs with InSpectra
|
|
21
|
+
|
|
22
|
+
## Usage
|
|
23
|
+
|
|
24
|
+
```bash
|
|
25
|
+
clidocs render semkit # ~/Work/tools/docs/semkit/index.html, opened in the browser
|
|
26
|
+
clidocs render serp --no-open # a tool without `docs` is rendered from `describe`
|
|
27
|
+
```
|
|
28
|
+
|
|
29
|
+
Mac only: needs dotnet (`brew install dotnet`) and InSpectra
|
|
30
|
+
(`dotnet tool install -g InSpectra.Gen`; found on PATH or in `~/.dotnet/tools`).
|
|
31
|
+
`DOTNET_ROOT` defaults to Homebrew's `/opt/homebrew/opt/dotnet/libexec`. The tool
|
|
32
|
+
is asked for `describe --json` first and for `docs` only when describe lists it, in
|
|
33
|
+
an empty working directory — never a blind `TOOL docs`.
|
|
34
|
+
|
|
35
|
+
## Development
|
|
36
|
+
|
|
37
|
+
```bash
|
|
38
|
+
uv sync
|
|
39
|
+
uv run clidocs --help
|
|
40
|
+
gate check # the full gate (run before every commit, on this machine)
|
|
41
|
+
uv run pytest --snapshot-update # after changing a command's help; review tests/snapshots/help/
|
|
42
|
+
```
|
|
43
|
+
|
|
44
|
+
`pytest` fails below the coverage floor in `pyproject.toml`; `ruff` includes
|
|
45
|
+
the security (`S`) rules; the gate also scans `uv.lock` for known
|
|
46
|
+
vulnerabilities when `osv-scanner` is installed (`brew install osv-scanner`),
|
|
47
|
+
and says it skipped the scan otherwise. The gate runs locally: `[publish]
|
|
48
|
+
gate_command` in `.agents/antagor/antagor.toml`; no workflow runs it.
|
|
49
|
+
|
|
50
|
+
## Release
|
|
51
|
+
|
|
52
|
+
The version is the git tag (`vX.Y.Z`) — `pyproject.toml` has no `version =`.
|
|
53
|
+
Work goes through Antagor tickets (`.agents/antagor/`); a release (run by the Human) is
|
|
54
|
+
|
|
55
|
+
```bash
|
|
56
|
+
antagor publish --bump # SemVer; at 0.x: patch = fix/feature, minor = breaking
|
|
57
|
+
```
|
|
58
|
+
|
|
59
|
+
It tags the release, builds `CHANGELOG.md` from the ticket titles and runs
|
|
60
|
+
`scripts/deploy.sh`: push `main` with tags to `origin`. Nobody tags or
|
|
61
|
+
pushes by hand.
|
|
62
|
+
|
|
63
|
+
## Install
|
|
64
|
+
|
|
65
|
+
**On this machine, from a local checkout:**
|
|
66
|
+
|
|
67
|
+
```bash
|
|
68
|
+
uv tool install .
|
|
69
|
+
```
|
|
70
|
+
|
|
71
|
+
**On any other machine (any OS), once this repo is pushed to GitHub — no
|
|
72
|
+
PyPI publish needed:**
|
|
73
|
+
|
|
74
|
+
```bash
|
|
75
|
+
uv tool install "rb-clidocs @ git+https://github.com/bolandeu/clidocs.git@vX.Y.Z"
|
|
76
|
+
```
|
|
77
|
+
|
|
78
|
+
Replace `vX.Y.Z` with the latest release tag (a tag cut by
|
|
79
|
+
`antagor publish`; never install a branch). This is also how an AI agent
|
|
80
|
+
bootstraps this CLI on a fresh machine/sandbox where it isn't installed
|
|
81
|
+
yet — see `src/rb_clidocs/data/SKILL.md`.
|
|
82
|
+
|
|
83
|
+
**Private repo?** The command above is unchanged — `uv` runs git under the
|
|
84
|
+
hood, so it authenticates the same way `git clone` does. On a machine
|
|
85
|
+
where the install is refused with an auth error, do one of these once:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
gh auth login # interactive login also sets up git's credential helper
|
|
89
|
+
gh auth setup-git # only needed if gh was logged in with --with-token / in CI
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
or use the SSH form instead of HTTPS:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
uv tool install "rb-clidocs @ git+ssh://git@github.com/bolandeu/clidocs.git@vX.Y.Z"
|
|
96
|
+
```
|
|
97
|
+
|
|
98
|
+
**Update** an installed copy to the latest commit:
|
|
99
|
+
|
|
100
|
+
```bash
|
|
101
|
+
uv tool upgrade rb-clidocs
|
|
102
|
+
```
|
|
103
|
+
|
|
104
|
+
After install, the command `clidocs` is available globally, on
|
|
105
|
+
macOS, Linux and Windows alike (see `architecture.md` in the cli-generator
|
|
106
|
+
plugin for why: no shelling out, no hardcoded POSIX paths).
|
|
107
|
+
|
|
108
|
+
To pick up later architecture changes from the `cli-generator` template
|
|
109
|
+
itself, run `copier update` in this repo (requires this repo and the
|
|
110
|
+
template to both be git repos; see the `cli-generator` plugin's README).
|
|
111
|
+
|
|
112
|
+
## Architecture
|
|
113
|
+
|
|
114
|
+
This project follows a fixed CLI architecture:
|
|
115
|
+
|
|
116
|
+
- `src/rb_clidocs/commands/` — argument parsing only, no business logic.
|
|
117
|
+
- `src/rb_clidocs/core/` — services, models, errors: the real logic.
|
|
118
|
+
- `src/rb_clidocs/providers/` — external APIs/integrations.
|
|
119
|
+
- `src/rb_clidocs/credentials/` — secrets via the OS keychain (`keyring`)
|
|
120
|
+
and environment variables. Secrets never live in `.rb_clidocs/config.toml`.
|
|
121
|
+
- `src/rb_clidocs/output/` — human (`rich`) and `--json` rendering.
|
|
122
|
+
|
|
123
|
+
Run `clidocs doctor` to check environment/config/auth readiness, and
|
|
124
|
+
`clidocs --help` for the full command surface. Every command supports
|
|
125
|
+
`--json` for machine/agent consumption; errors are structured (`error.code`,
|
|
126
|
+
fixed exit codes, `error.action` telling you what to do next) and go to
|
|
127
|
+
stderr in human mode, so stdout is always safe to pipe.
|
|
128
|
+
|
|
129
|
+
A project can require a minimum CLI version in its `.rb_clidocs/config.toml`
|
|
130
|
+
(`[cli] min_version = "..."`); an older install refuses with exit 6 and
|
|
131
|
+
`uv tool upgrade rb-clidocs` fixes it.
|
|
132
|
+
|
|
133
|
+
See `src/rb_clidocs/data/SKILL.md` for the agent-facing usage guide
|
|
134
|
+
bundled with this package — install it into an AI tool with
|
|
135
|
+
`clidocs skill install`, or get it as plain text with
|
|
136
|
+
`clidocs --ai` (works even without file access).
|
|
@@ -0,0 +1,119 @@
|
|
|
1
|
+
# clidocs
|
|
2
|
+
|
|
3
|
+
Human CLI help in the browser: renders a tool's docs with InSpectra
|
|
4
|
+
|
|
5
|
+
## Usage
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
clidocs render semkit # ~/Work/tools/docs/semkit/index.html, opened in the browser
|
|
9
|
+
clidocs render serp --no-open # a tool without `docs` is rendered from `describe`
|
|
10
|
+
```
|
|
11
|
+
|
|
12
|
+
Mac only: needs dotnet (`brew install dotnet`) and InSpectra
|
|
13
|
+
(`dotnet tool install -g InSpectra.Gen`; found on PATH or in `~/.dotnet/tools`).
|
|
14
|
+
`DOTNET_ROOT` defaults to Homebrew's `/opt/homebrew/opt/dotnet/libexec`. The tool
|
|
15
|
+
is asked for `describe --json` first and for `docs` only when describe lists it, in
|
|
16
|
+
an empty working directory — never a blind `TOOL docs`.
|
|
17
|
+
|
|
18
|
+
## Development
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
uv sync
|
|
22
|
+
uv run clidocs --help
|
|
23
|
+
gate check # the full gate (run before every commit, on this machine)
|
|
24
|
+
uv run pytest --snapshot-update # after changing a command's help; review tests/snapshots/help/
|
|
25
|
+
```
|
|
26
|
+
|
|
27
|
+
`pytest` fails below the coverage floor in `pyproject.toml`; `ruff` includes
|
|
28
|
+
the security (`S`) rules; the gate also scans `uv.lock` for known
|
|
29
|
+
vulnerabilities when `osv-scanner` is installed (`brew install osv-scanner`),
|
|
30
|
+
and says it skipped the scan otherwise. The gate runs locally: `[publish]
|
|
31
|
+
gate_command` in `.agents/antagor/antagor.toml`; no workflow runs it.
|
|
32
|
+
|
|
33
|
+
## Release
|
|
34
|
+
|
|
35
|
+
The version is the git tag (`vX.Y.Z`) — `pyproject.toml` has no `version =`.
|
|
36
|
+
Work goes through Antagor tickets (`.agents/antagor/`); a release (run by the Human) is
|
|
37
|
+
|
|
38
|
+
```bash
|
|
39
|
+
antagor publish --bump # SemVer; at 0.x: patch = fix/feature, minor = breaking
|
|
40
|
+
```
|
|
41
|
+
|
|
42
|
+
It tags the release, builds `CHANGELOG.md` from the ticket titles and runs
|
|
43
|
+
`scripts/deploy.sh`: push `main` with tags to `origin`. Nobody tags or
|
|
44
|
+
pushes by hand.
|
|
45
|
+
|
|
46
|
+
## Install
|
|
47
|
+
|
|
48
|
+
**On this machine, from a local checkout:**
|
|
49
|
+
|
|
50
|
+
```bash
|
|
51
|
+
uv tool install .
|
|
52
|
+
```
|
|
53
|
+
|
|
54
|
+
**On any other machine (any OS), once this repo is pushed to GitHub — no
|
|
55
|
+
PyPI publish needed:**
|
|
56
|
+
|
|
57
|
+
```bash
|
|
58
|
+
uv tool install "rb-clidocs @ git+https://github.com/bolandeu/clidocs.git@vX.Y.Z"
|
|
59
|
+
```
|
|
60
|
+
|
|
61
|
+
Replace `vX.Y.Z` with the latest release tag (a tag cut by
|
|
62
|
+
`antagor publish`; never install a branch). This is also how an AI agent
|
|
63
|
+
bootstraps this CLI on a fresh machine/sandbox where it isn't installed
|
|
64
|
+
yet — see `src/rb_clidocs/data/SKILL.md`.
|
|
65
|
+
|
|
66
|
+
**Private repo?** The command above is unchanged — `uv` runs git under the
|
|
67
|
+
hood, so it authenticates the same way `git clone` does. On a machine
|
|
68
|
+
where the install is refused with an auth error, do one of these once:
|
|
69
|
+
|
|
70
|
+
```bash
|
|
71
|
+
gh auth login # interactive login also sets up git's credential helper
|
|
72
|
+
gh auth setup-git # only needed if gh was logged in with --with-token / in CI
|
|
73
|
+
```
|
|
74
|
+
|
|
75
|
+
or use the SSH form instead of HTTPS:
|
|
76
|
+
|
|
77
|
+
```bash
|
|
78
|
+
uv tool install "rb-clidocs @ git+ssh://git@github.com/bolandeu/clidocs.git@vX.Y.Z"
|
|
79
|
+
```
|
|
80
|
+
|
|
81
|
+
**Update** an installed copy to the latest commit:
|
|
82
|
+
|
|
83
|
+
```bash
|
|
84
|
+
uv tool upgrade rb-clidocs
|
|
85
|
+
```
|
|
86
|
+
|
|
87
|
+
After install, the command `clidocs` is available globally, on
|
|
88
|
+
macOS, Linux and Windows alike (see `architecture.md` in the cli-generator
|
|
89
|
+
plugin for why: no shelling out, no hardcoded POSIX paths).
|
|
90
|
+
|
|
91
|
+
To pick up later architecture changes from the `cli-generator` template
|
|
92
|
+
itself, run `copier update` in this repo (requires this repo and the
|
|
93
|
+
template to both be git repos; see the `cli-generator` plugin's README).
|
|
94
|
+
|
|
95
|
+
## Architecture
|
|
96
|
+
|
|
97
|
+
This project follows a fixed CLI architecture:
|
|
98
|
+
|
|
99
|
+
- `src/rb_clidocs/commands/` — argument parsing only, no business logic.
|
|
100
|
+
- `src/rb_clidocs/core/` — services, models, errors: the real logic.
|
|
101
|
+
- `src/rb_clidocs/providers/` — external APIs/integrations.
|
|
102
|
+
- `src/rb_clidocs/credentials/` — secrets via the OS keychain (`keyring`)
|
|
103
|
+
and environment variables. Secrets never live in `.rb_clidocs/config.toml`.
|
|
104
|
+
- `src/rb_clidocs/output/` — human (`rich`) and `--json` rendering.
|
|
105
|
+
|
|
106
|
+
Run `clidocs doctor` to check environment/config/auth readiness, and
|
|
107
|
+
`clidocs --help` for the full command surface. Every command supports
|
|
108
|
+
`--json` for machine/agent consumption; errors are structured (`error.code`,
|
|
109
|
+
fixed exit codes, `error.action` telling you what to do next) and go to
|
|
110
|
+
stderr in human mode, so stdout is always safe to pipe.
|
|
111
|
+
|
|
112
|
+
A project can require a minimum CLI version in its `.rb_clidocs/config.toml`
|
|
113
|
+
(`[cli] min_version = "..."`); an older install refuses with exit 6 and
|
|
114
|
+
`uv tool upgrade rb-clidocs` fixes it.
|
|
115
|
+
|
|
116
|
+
See `src/rb_clidocs/data/SKILL.md` for the agent-facing usage guide
|
|
117
|
+
bundled with this package — install it into an AI tool with
|
|
118
|
+
`clidocs skill install`, or get it as plain text with
|
|
119
|
+
`clidocs --ai` (works even without file access).
|
|
@@ -0,0 +1,169 @@
|
|
|
1
|
+
[project]
|
|
2
|
+
name = "rb-clidocs"
|
|
3
|
+
# Version comes from the git tag vX.Y.Z (uv-dynamic-versioning) — never add `version =`.
|
|
4
|
+
dynamic = ["version"]
|
|
5
|
+
description = "Human-readable CLI help in the browser: renders a tool's docs with InSpectra."
|
|
6
|
+
readme = "README.md"
|
|
7
|
+
license = "MIT"
|
|
8
|
+
license-files = ["LICENSE"]
|
|
9
|
+
authors = [{ name = "Roman Bolandau" }]
|
|
10
|
+
requires-python = ">=3.14"
|
|
11
|
+
dependencies = [
|
|
12
|
+
"typer>=0.27,<0.29",
|
|
13
|
+
"rich>=13.7",
|
|
14
|
+
"pydantic>=2.6",
|
|
15
|
+
"tomli-w>=1.0",
|
|
16
|
+
"platformdirs>=4.2",
|
|
17
|
+
"packaging>=24.0",
|
|
18
|
+
]
|
|
19
|
+
|
|
20
|
+
[project.scripts]
|
|
21
|
+
clidocs = "rb_clidocs.cli:main"
|
|
22
|
+
|
|
23
|
+
[project.urls]
|
|
24
|
+
Repository = "https://github.com/bolandeu/clidocs"
|
|
25
|
+
|
|
26
|
+
[build-system]
|
|
27
|
+
requires = ["hatchling", "uv-dynamic-versioning"]
|
|
28
|
+
build-backend = "hatchling.build"
|
|
29
|
+
|
|
30
|
+
[tool.hatch.version]
|
|
31
|
+
source = "uv-dynamic-versioning"
|
|
32
|
+
|
|
33
|
+
[tool.uv-dynamic-versioning]
|
|
34
|
+
vcs = "git"
|
|
35
|
+
style = "pep440"
|
|
36
|
+
fallback-version = "0.0.0"
|
|
37
|
+
|
|
38
|
+
[tool.uv]
|
|
39
|
+
# Rebuild the editable install when a commit or tag moves, so `--version` follows the tag.
|
|
40
|
+
cache-keys = [{ file = "pyproject.toml" }, { git = { commit = true, tags = true } }]
|
|
41
|
+
|
|
42
|
+
[tool.hatch.build.targets.sdist]
|
|
43
|
+
# What a release must not carry: the agent's own files, the forge configs and the dev tooling. The wheel is
|
|
44
|
+
# narrow already (`packages = ["src/<pkg>"]`); this is about the sdist, which is otherwise a copy of the repo.
|
|
45
|
+
exclude = [
|
|
46
|
+
"/.agents",
|
|
47
|
+
"/.claude",
|
|
48
|
+
"/.claude-plugin",
|
|
49
|
+
"/.gitea",
|
|
50
|
+
"/.github",
|
|
51
|
+
"/docs",
|
|
52
|
+
"/scripts",
|
|
53
|
+
"/uv.lock",
|
|
54
|
+
"/AGENTS.md",
|
|
55
|
+
"/CLAUDE.md",
|
|
56
|
+
"/CODING_STANDARDS.md",
|
|
57
|
+
"/CONTEXT.md",
|
|
58
|
+
"/.copier-answers.yml",
|
|
59
|
+
"^\\.gitignore$",
|
|
60
|
+
"/.gitleaks.toml",
|
|
61
|
+
]
|
|
62
|
+
|
|
63
|
+
[tool.hatch.build.targets.wheel]
|
|
64
|
+
packages = ["src/rb_clidocs"]
|
|
65
|
+
|
|
66
|
+
[tool.hatch.build.targets.wheel.force-include]
|
|
67
|
+
# The installed CLI reads [[tool.rb.external]] from here (core/deps.py).
|
|
68
|
+
"pyproject.toml" = "rb_clidocs/_pyproject.toml"
|
|
69
|
+
|
|
70
|
+
[dependency-groups]
|
|
71
|
+
# Mutation testing, run now and then and before big releases — not in the gate:
|
|
72
|
+
# `uv run --group mutation mutmut run`, then `mutmut results` / `mutmut browse`.
|
|
73
|
+
# Needs fork(): macOS/Linux (WSL on Windows). Settings: [tool.mutmut] below.
|
|
74
|
+
mutation = ["mutmut>=3.3"]
|
|
75
|
+
dev = [
|
|
76
|
+
"jsonschema>=4.23",
|
|
77
|
+
"pytest>=8.0",
|
|
78
|
+
"pyyaml>=6.0", # .copier-answers.yml, the CI workflow, tests/contracts/*.yaml
|
|
79
|
+
"pytest-cov>=5.0",
|
|
80
|
+
"ruff>=0.6",
|
|
81
|
+
"syrupy>=4.8",
|
|
82
|
+
"ty>=0.0.80",
|
|
83
|
+
]
|
|
84
|
+
|
|
85
|
+
# External (non-Python) dependencies — every CLI this tool runs (require_cli,
|
|
86
|
+
# shutil.which, subprocess with a literal program, npx). The gate checks this
|
|
87
|
+
# list against the code both ways; doctor and require_cli read it at runtime;
|
|
88
|
+
# the tools catalog reads it (the Standard, Technology).
|
|
89
|
+
[[tool.rb.external]]
|
|
90
|
+
name = "inspectra"
|
|
91
|
+
required = true
|
|
92
|
+
check = "inspectra --version"
|
|
93
|
+
why = "renders the help document as HTML (dotnet tool InSpectra.Gen; needs dotnet, Mac only)"
|
|
94
|
+
detect = false # run by absolute path (PATH or ~/.dotnet/tools)
|
|
95
|
+
|
|
96
|
+
# [[tool.rb.external]]
|
|
97
|
+
# name = "ffmpeg"
|
|
98
|
+
# required = true # false: the tool works without it (doctor stays healthy)
|
|
99
|
+
# min_version = "6.0" # optional
|
|
100
|
+
# check = "ffmpeg -version" # prints the version; default "<name> --version"
|
|
101
|
+
# why = "transcodes the downloaded videos"
|
|
102
|
+
# detect = false # run via an injected runner / absolute path the gate can't see
|
|
103
|
+
# dist = "rb-serp" # for one of our CLIs: its distribution (default rb-<name>)
|
|
104
|
+
# url = "https://github.com/bolandeu/serp" # its repo: DEPENDENCY_TOO_OLD then prints a pinned install
|
|
105
|
+
|
|
106
|
+
# Where sysadmin's tool-updater installs this tool after its first tag. The
|
|
107
|
+
# installation is sysadmin's; this section only says where. homeserver: users
|
|
108
|
+
# to install for (empty = build and publish only); mac: install on the Mac.
|
|
109
|
+
# extras (optional): the extras to install with, e.g. extras = ["browser"].
|
|
110
|
+
[tool.rb.install]
|
|
111
|
+
homeserver = ["rbtools"]
|
|
112
|
+
mac = true
|
|
113
|
+
|
|
114
|
+
[tool.cli-generator]
|
|
115
|
+
# Where scripts/check_command_docstrings.py (called by the project's checks)
|
|
116
|
+
# looks for commands: a glob or a list of globs, relative to the repo root.
|
|
117
|
+
commands = ["src/rb_clidocs/commands/*.py"]
|
|
118
|
+
# gate check (the gate): extras to install before ruff/ty/pytest.
|
|
119
|
+
# gate_extras = ["browser"]
|
|
120
|
+
|
|
121
|
+
[tool.pytest.ini_options]
|
|
122
|
+
# Only tests/: mutmut leaves a copy of the tree in mutants/.
|
|
123
|
+
testpaths = ["tests"]
|
|
124
|
+
addopts = "--cov --cov-report=term-missing:skip-covered"
|
|
125
|
+
# tests/test_help.py keeps help snapshots at tests/snapshots/help/<command>.txt
|
|
126
|
+
# (the Standard, Commands), not in syrupy's own `__snapshots__/<test file>/` layout, so
|
|
127
|
+
# syrupy warns it "can not relate" each file to its test. It can — by name.
|
|
128
|
+
filterwarnings = ["ignore:(?s).*Can not relate snapshot:UserWarning"]
|
|
129
|
+
|
|
130
|
+
[tool.mutmut]
|
|
131
|
+
source_paths = ["src/rb_clidocs"]
|
|
132
|
+
also_copy = ["scripts/", "pyproject.toml"] # tests read them (test_scripts.py, the distribution checks)
|
|
133
|
+
pytest_add_cli_args = ["--no-cov"] # fail_under would kill every mutant
|
|
134
|
+
# only_mutate = ["*/core/normalize.py"] # one module at a time on a big tool
|
|
135
|
+
|
|
136
|
+
[tool.coverage.run]
|
|
137
|
+
source = ["src"]
|
|
138
|
+
# sysmon (default on 3.14) keeps a record per recompiled code object; Typer recompiles annotations on every invoke, so memory grows.
|
|
139
|
+
core = "ctrace"
|
|
140
|
+
|
|
141
|
+
[tool.coverage.report]
|
|
142
|
+
# The template ships at ~94%; keep the bar where it is instead of letting
|
|
143
|
+
# new commands land untested. Raise it, never lower it.
|
|
144
|
+
fail_under = 90
|
|
145
|
+
show_missing = true
|
|
146
|
+
|
|
147
|
+
[tool.ty.terminal]
|
|
148
|
+
# Only errors fail the gate; recent ty (>= 0.0.84) otherwise exits 1 on warnings too.
|
|
149
|
+
# Legacy code that can't be fixed yet: downgrade specific rules instead of
|
|
150
|
+
# ignoring them, e.g. [tool.ty.rules] possibly-unbound-attribute = "warn".
|
|
151
|
+
error-on-warning = false
|
|
152
|
+
|
|
153
|
+
[tool.ruff]
|
|
154
|
+
line-length = 120
|
|
155
|
+
|
|
156
|
+
[tool.ruff.lint]
|
|
157
|
+
select = ["E4", "E7", "E9", "F", "I", "UP", "B", "SIM", "RUF", "S", "T20", "TID251"]
|
|
158
|
+
|
|
159
|
+
[tool.ruff.lint.per-file-ignores]
|
|
160
|
+
"tests/*" = ["S101", "T201", "TID251"] # assert is the point of a test; print in code strings; httpx for mocks
|
|
161
|
+
"scripts/*" = ["S603", "S607", "T201"] # subprocess with fixed argv lists (git, uv), no shell; scripts print to the console
|
|
162
|
+
"src/*/providers/*" = ["TID251"] # external APIs live here
|
|
163
|
+
|
|
164
|
+
[tool.ruff.lint.flake8-tidy-imports.banned-api]
|
|
165
|
+
"httpx".msg = "Call external APIs through providers/ (subclass providers.HttpProvider)."
|
|
166
|
+
|
|
167
|
+
[tool.ruff.lint.flake8-bugbear]
|
|
168
|
+
# Typer's `param: T = typer.Option(...)` style is a call in a default on purpose.
|
|
169
|
+
extend-immutable-calls = ["typer.Option", "typer.Argument"]
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""The package: its modules are the CLI (`cli`), its commands, the output and the core they share."""
|
|
@@ -0,0 +1,24 @@
|
|
|
1
|
+
"""The distribution name and the tool namespace copier writes from its answers, because an editable install cannot map
|
|
2
|
+
this import package to its distribution at runtime.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
# Rendered by copier from the `dist_name` answer: the [project] name in
|
|
6
|
+
# pyproject.toml (`rb-<slug>`, the Standard, Technology), which may differ from this
|
|
7
|
+
# import package's name. importlib.metadata finds this package's version,
|
|
8
|
+
# summary and console script by it; an editable install (`uv sync`) can't be
|
|
9
|
+
# mapped from package to distribution at runtime, so it is written down here.
|
|
10
|
+
# tests/test_cli.py fails if it drifts from pyproject.toml.
|
|
11
|
+
DIST_NAME = "rb-clidocs"
|
|
12
|
+
# The previous distribution name during a rename: an install made
|
|
13
|
+
# under it (not yet reinstalled) still finds its own version. Drop it once
|
|
14
|
+
# every machine has the new name.
|
|
15
|
+
DIST_NAME_LEGACY: str | None = None
|
|
16
|
+
# The command name (`cli_name`) as an identifier: the namespace of this tool's
|
|
17
|
+
# shared-database names (core/db.py) — table prefix `<TOOL>_`, env var
|
|
18
|
+
# `<TOOL>_DATABASE_URL`, Alembic table `alembic_version_<TOOL>`. Written down,
|
|
19
|
+
# not derived at runtime: a bare source run falls back to the package name,
|
|
20
|
+
# and a table name must never depend on how the tool was started.
|
|
21
|
+
TOOL = "clidocs"
|
|
22
|
+
# The cli-generator release this project was generated or last updated from
|
|
23
|
+
# (copier's `_commit`), for `describe --json`; None for a project not made by copier.
|
|
24
|
+
TEMPLATE_VERSION: str | None = "v1.27.3"
|
|
@@ -0,0 +1,70 @@
|
|
|
1
|
+
"""The root Typer app: global options, the command groups and the optional commands a generated package has, wired
|
|
2
|
+
together, and the console-script entry point.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import typer
|
|
8
|
+
|
|
9
|
+
from . import output
|
|
10
|
+
from .commands import auth, docs, doctor, render
|
|
11
|
+
from .core.version import DEV_VERSION, cli_name, installed_version, optional_module, package_summary
|
|
12
|
+
|
|
13
|
+
_PACKAGE_NAME = __name__.split(".")[0]
|
|
14
|
+
# Optional parts (copier questions, dropped by _exclude): each one ships a module that registers its
|
|
15
|
+
# commands and global options. Probed at runtime, so this file needs no template logic.
|
|
16
|
+
PARTS = ("project", "skill", "describe", "db")
|
|
17
|
+
|
|
18
|
+
# A bare `<cli>` is the discovery entry point for humans and agents alike:
|
|
19
|
+
# name + version + description, then every command with the first line of
|
|
20
|
+
# its docstring. No `no_args_is_help` (that exits 2) — main_options() below
|
|
21
|
+
# prints this and exits 0. Shell completion stays enabled.
|
|
22
|
+
app = typer.Typer(
|
|
23
|
+
cls=output.RootGroup, # a usage error under --json is the error envelope
|
|
24
|
+
help=f"{cli_name()} {installed_version() or DEV_VERSION} — {package_summary() or 'project-aware automation CLI'}",
|
|
25
|
+
)
|
|
26
|
+
|
|
27
|
+
app.add_typer(auth.app, name="auth") # `auth status` in every CLI; login/logout only with credentials
|
|
28
|
+
app.command(name="doctor")(doctor.doctor)
|
|
29
|
+
app.command(name="render")(render.render) # the package's own commands, in place of the template's example `run`
|
|
30
|
+
app.command(name="docs")(docs.docs)
|
|
31
|
+
for part in PARTS:
|
|
32
|
+
if module := optional_module(f"{_PACKAGE_NAME}.commands.{part}"):
|
|
33
|
+
module.register(app)
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
def _version_callback(value: bool) -> None:
|
|
37
|
+
if not value:
|
|
38
|
+
return
|
|
39
|
+
typer.echo(installed_version() or DEV_VERSION)
|
|
40
|
+
raise typer.Exit()
|
|
41
|
+
|
|
42
|
+
|
|
43
|
+
@app.callback(invoke_without_command=True)
|
|
44
|
+
def main_options(
|
|
45
|
+
ctx: typer.Context,
|
|
46
|
+
json_output: bool = typer.Option(False, "--json", help="Emit machine-readable JSON output."),
|
|
47
|
+
quiet: bool = typer.Option(False, "--quiet", help="Suppress non-essential output."),
|
|
48
|
+
verbose: bool = typer.Option(False, "--verbose", help="Emit extra diagnostic output."),
|
|
49
|
+
non_interactive: bool = typer.Option(False, "--non-interactive", help="Never prompt; fail instead."),
|
|
50
|
+
dry_run: bool = typer.Option(False, "--dry-run", help="Show what would happen without making changes."),
|
|
51
|
+
version: bool = typer.Option(
|
|
52
|
+
False, "--version", callback=_version_callback, is_eager=True, help="Show the version and exit."
|
|
53
|
+
),
|
|
54
|
+
) -> None:
|
|
55
|
+
ctx.ensure_object(dict) # a part's global option (--project) may have put its value here already
|
|
56
|
+
ctx.obj["json"] = json_output
|
|
57
|
+
ctx.obj["quiet"] = quiet
|
|
58
|
+
ctx.obj["verbose"] = verbose
|
|
59
|
+
ctx.obj["non_interactive"] = non_interactive
|
|
60
|
+
ctx.obj["dry_run"] = dry_run
|
|
61
|
+
output.configure_logging(verbose)
|
|
62
|
+
output.help_if_no_command(ctx)
|
|
63
|
+
|
|
64
|
+
|
|
65
|
+
def main() -> None:
|
|
66
|
+
app()
|
|
67
|
+
|
|
68
|
+
|
|
69
|
+
if __name__ == "__main__":
|
|
70
|
+
main()
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
"""The commands of the CLI, one module per command or command group."""
|
|
@@ -0,0 +1,66 @@
|
|
|
1
|
+
"""The `auth` command group: `status` reports the health of the credentials of every provider, or an empty report when
|
|
2
|
+
the package has none.
|
|
3
|
+
"""
|
|
4
|
+
|
|
5
|
+
from __future__ import annotations
|
|
6
|
+
|
|
7
|
+
import importlib
|
|
8
|
+
from datetime import UTC, datetime
|
|
9
|
+
|
|
10
|
+
import typer
|
|
11
|
+
|
|
12
|
+
from .. import output
|
|
13
|
+
from ..core.errors import InvalidArguments
|
|
14
|
+
from ..core.version import DEV_VERSION, cli_name, installed_version, module_exists, optional_module
|
|
15
|
+
|
|
16
|
+
# `auth status` exists in every CLI (the Standard, Health); a CLI
|
|
17
|
+
# generated without credentials (no credentials/ package, no commands/login.py)
|
|
18
|
+
# reports an empty `credentials` list and exits 0. Detected at runtime so this
|
|
19
|
+
# file needs no template logic — same approach as doctor.py.
|
|
20
|
+
_PACKAGE_NAME = __name__.split(".")[0]
|
|
21
|
+
_HAS_CREDENTIALS = module_exists(f"{_PACKAGE_NAME}.credentials.manager")
|
|
22
|
+
|
|
23
|
+
app = output.group("Credentials: report their health (and store them, if this CLI has any).")
|
|
24
|
+
|
|
25
|
+
|
|
26
|
+
@app.command("status")
|
|
27
|
+
@output.guard
|
|
28
|
+
def auth_status(
|
|
29
|
+
ctx: typer.Context,
|
|
30
|
+
check: bool = typer.Option(
|
|
31
|
+
False, "--check", help="Also make one cheap read-only call per provider (10 s timeout) to prove each works."
|
|
32
|
+
),
|
|
33
|
+
provider: str | None = typer.Option(
|
|
34
|
+
None, "--provider", help="Report only this provider, or one target as <kind>:<target> (default: all)."
|
|
35
|
+
),
|
|
36
|
+
json_output: bool = output.JsonOption,
|
|
37
|
+
quiet: bool = output.QuietOption,
|
|
38
|
+
) -> None:
|
|
39
|
+
"""Report every provider's credential: where it comes from and whether it works. Never prints values.
|
|
40
|
+
|
|
41
|
+
Without --check only presence is reported (status `unchecked` or `missing`).
|
|
42
|
+
Exits 0 when every required provider is ok/unchecked (an optional one may be
|
|
43
|
+
missing), 3 when any required provider has a problem or any credential is
|
|
44
|
+
invalid/expired, 2 on a usage error. A per-target provider (one credential per
|
|
45
|
+
site/host/account) gets one entry per stored target, named `<kind>:<target>`. The --json shape is a cross-tool contract:
|
|
46
|
+
`tool`, `version`, `checked_at`, `credentials[]` with `provider`, `required`,
|
|
47
|
+
`fields`, `source`, `source_ref`, `status`, `expires_at`, `quota`, `message`.
|
|
48
|
+
|
|
49
|
+
Example: {cli} auth status --check --json
|
|
50
|
+
"""
|
|
51
|
+
tool, version = cli_name(), installed_version() or DEV_VERSION
|
|
52
|
+
if not _HAS_CREDENTIALS:
|
|
53
|
+
if provider is not None:
|
|
54
|
+
raise InvalidArguments(f"Unknown provider '{provider}' ({tool} stores no credentials).")
|
|
55
|
+
checked_at = datetime.now(UTC).replace(microsecond=0).isoformat().replace("+00:00", "Z")
|
|
56
|
+
payload = {"tool": tool, "version": version, "checked_at": checked_at, "credentials": []}
|
|
57
|
+
output.emit_report(ctx, payload, lambda _: output.human.echo(f"{tool} stores no credentials."), None)
|
|
58
|
+
return
|
|
59
|
+
health = importlib.import_module(f"{_PACKAGE_NAME}.credentials.health")
|
|
60
|
+
payload, problem = health.status(tool, version, check=check, only=provider)
|
|
61
|
+
output.emit_report(ctx, payload, health.render, problem)
|
|
62
|
+
|
|
63
|
+
|
|
64
|
+
if _login := optional_module(f"{_PACKAGE_NAME}.commands.login"):
|
|
65
|
+
app.command("login")(_login.login)
|
|
66
|
+
app.command("logout")(_login.logout)
|