Skip to content

Commit 12231ab

Browse files
1 parent 94bb390 commit 12231ab

22 files changed

Lines changed: 1385 additions & 181 deletions

.github/workflows/ci.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -36,5 +36,8 @@ jobs:
3636
- name: Run lint
3737
run: ruff check .
3838

39+
- name: Verify release version
40+
run: python tools/verify_release_version.py
41+
3942
- name: Build package
4043
run: python -m build

.github/workflows/publish-python-cli.yml

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -43,12 +43,57 @@ jobs:
4343
- name: Run tests
4444
run: python -m pytest
4545

46+
- name: Verify release version
47+
run: |
48+
if [[ "$GITHUB_REF" == refs/tags/* ]]; then
49+
python tools/verify_release_version.py --tag "$GITHUB_REF_NAME"
50+
else
51+
python tools/verify_release_version.py
52+
fi
53+
4654
- name: Build CLI distribution
4755
run: |
4856
rm -rf dist
4957
python -m build
5058
python -m twine check dist/*
5159
60+
- name: Verify clean wheel installation
61+
run: |
62+
smoke_dir="$RUNNER_TEMP/polygres-cli-wheel-smoke"
63+
python -m venv "$smoke_dir"
64+
"$smoke_dir/bin/python" -m pip install dist/*.whl
65+
"$smoke_dir/bin/python" - <<'PY'
66+
import importlib.metadata
67+
import os
68+
from pathlib import Path
69+
import subprocess
70+
import sys
71+
from polygres_cli import __version__
72+
73+
expected = importlib.metadata.version("polygres-cli")
74+
assert __version__ == expected
75+
result = subprocess.run(
76+
[str(Path(sys.executable).with_name("polygres")), "--version"],
77+
check=True,
78+
capture_output=True,
79+
env={**os.environ, "POLYGRES_API_BASE_URL": "http://127.0.0.1:9/v1"},
80+
text=True,
81+
)
82+
assert result.stdout.splitlines()[0] == f"polygres {expected}"
83+
PY
84+
85+
- name: Verify clean source distribution installation
86+
run: |
87+
smoke_dir="$RUNNER_TEMP/polygres-cli-sdist-smoke"
88+
python -m venv "$smoke_dir"
89+
"$smoke_dir/bin/python" -m pip install dist/*.tar.gz
90+
"$smoke_dir/bin/python" - <<'PY'
91+
import importlib.metadata
92+
from polygres_cli import __version__
93+
94+
assert __version__ == importlib.metadata.version("polygres-cli")
95+
PY
96+
5297
- name: Upload CLI distributions
5398
uses: actions/upload-artifact@v4
5499
with:

CHANGELOG.md

Lines changed: 13 additions & 44 deletions
Original file line numberDiff line numberDiff line change
@@ -2,68 +2,37 @@
22

33
All notable changes to `polygres-cli` are documented in this file.
44

5-
## 0.2.0 - 2026-07-31
5+
## 0.2.0 - 2026-08-06
66

77
### Added
88

9-
- Added the complete `polygres context` namespace for pgContext capabilities,
10-
discovery, preflight, collection lifecycle, filters, points, durable
11-
operations, aggregates, dense retrieval, text hybrid, graph composition,
12-
rank fusion, coupled Joint retrieval, grouping, and recall checks.
13-
- Added strict shared-contract validation, file and standard-input request
14-
handling, mutation idempotency, adaptive durable-operation waiting, exact
15-
JSON envelopes, and Context-specific human output.
16-
- Added `polygres api routes` and `polygres api request` with a bundled,
17-
versioned OpenAPI snapshot, strict route and method selection, declared
18-
parameters, JSON-schema body validation, schema inspection, dry runs, and
19-
JSON output.
20-
- Added FastAPI schema generation and drift validation for the bundled CLI
21-
OpenAPI snapshot.
22-
- Added server-controlled CLI notices with a public API endpoint, 10-hour local
23-
cache, ETag revalidation, version and platform targeting, safe plain-text
24-
stderr rendering, `once`/`daily`/`always` display policies, and the static
25-
`polygres notices` command.
26-
- Added `polygres vector configs set-default <config-id>` for selecting the
27-
default vector configuration without using the web console.
28-
- Added direct Runtime API graph access support for graph discovery,
29-
configuration, builds, and status checks when
30-
`CLI_DIRECT_RUNTIME_GRAPH_ENABLED` is enabled and the control plane grants
31-
access.
9+
- Added `polygres context` commands for configuring, managing, and querying pgContext collections.
10+
- Added `polygres api routes` and `polygres api request` for exploring and calling supported Runtime API routes.
11+
- Added CLI notices for product updates and important service information.
12+
- Added `polygres vector configs set-default <config-id>` for selecting the default vector configuration from the CLI.
3213

3314
### Changed
3415

35-
- Graph status output now includes activation failure reasons and a concise
36-
summary of configuration differences.
37-
- Graph configuration export and apply flows now canonicalize table identifiers
38-
as `id_columns`, while continuing to accept legacy `id_column` input.
39-
- Authentication contracts are vendored into the package so standalone CLI
40-
exports do not depend on an external `polygres-lib` installation.
16+
- Graph status now explains activation failures and configuration differences.
17+
- Graph configuration now uses `id_columns` while remaining compatible with existing `id_column` configurations.
4118

4219
### Fixed
4320

44-
- Graph and vector activation verification failures now return nonzero CLI exit
45-
codes instead of appearing successful to automation.
46-
- Authentication errors no longer expose internal identity-provider details.
21+
- Graph and vector activation failures now return nonzero exit codes.
22+
- Authentication errors no longer expose internal service details.
23+
- CSV imports now work with destination tables protected by row-level security.
24+
- Project status commands now consistently honor the global `--project` option.
4725

4826
## 0.1.2 - 2026-07-14
4927

5028
### Changed
5129

5230
- CSV imports now upload directly to blob staging for improved reliability.
53-
- CSV upload limits now follow the storage allowance of the selected project
54-
tier.
55-
56-
## 0.1.1 - 2026-07-14
57-
58-
### Changed
59-
60-
- Added Python 3.10 to release validation for the standalone CLI package.
31+
- CSV upload limits now follow the storage allowance of the selected project tier.
6132

6233
## 0.1.0 - 2026-07-09
6334

6435
### Added
6536

6637
- Initial standalone `polygres-cli` package.
67-
- Added browser authentication, project management, connection information,
68-
Runtime API key management, CSV imports, migrations, graph/vector/text
69-
configuration, readiness checks, JSON output, and stable exit codes.
38+
- Added browser authentication, project management, connection information, Runtime API key management, CSV imports, migrations, graph/vector/text configuration, readiness checks, JSON output, and stable exit codes.

CONTRIBUTING.md

Lines changed: 9 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -46,17 +46,19 @@ Publishing uses GitHub Actions Trusted Publishing. Validate first through
4646
TestPyPI, then publish a matching `python-cli-vX.Y.Z` tag from the public CLI
4747
repository. Do not add PyPI API tokens to GitHub secrets.
4848

49-
Before syncing a release to the public CLI repository:
49+
`pyproject.toml` is the only release-version source. The installed CLI reads
50+
that distribution metadata for `polygres --version`, login metadata, notices,
51+
and request headers. Before syncing a release to the public CLI repository:
5052

5153
1. Add the release notes and date to `CHANGELOG.md`.
52-
2. Update the version in `pyproject.toml` and
53-
`src/polygres_cli/cli_client.py`.
54-
3. Update version assertions in the test suite and public installation
55-
documentation.
56-
4. Run `pytest`, `ruff check .`, `python -m build`, and
54+
2. Update the version in `pyproject.toml`.
55+
3. Update public installation documentation that names the released version.
56+
4. Run `pytest`, `ruff check .`, `python tools/verify_release_version.py`,
57+
`python -m build`, and
5758
`python -m twine check dist/*`.
5859
5. Validate the release through TestPyPI before creating the matching
59-
production tag.
60+
`python-cli-vX.Y.Z` production tag. The release workflow rejects a tag that
61+
does not exactly match the package version.
6062

6163
## Scope
6264

README.md

Lines changed: 34 additions & 108 deletions
Original file line numberDiff line numberDiff line change
@@ -1,153 +1,79 @@
11
# Polygres CLI
22

3-
The Polygres CLI manages Polygres projects from the terminal. It authenticates
4-
with the control plane and supports project setup, imports, migrations, and
5-
retrieval configuration. It does not expose database passwords.
3+
Use the Polygres CLI to manage projects, load data, apply migrations, and configure retrieval from your terminal.
4+
5+
The CLI signs in through the Polygres dashboard. It does not expose database passwords.
6+
7+
- [Documentation](https://docs.polygres.com/cli)
8+
- [Polygres](https://polygres.com)
69

710
## Install
811

12+
Install the CLI with pip:
13+
914
```bash
1015
pip install polygres-cli
1116
```
1217

13-
For an isolated global installation:
18+
For an isolated global installation, use pipx:
1419

1520
```bash
1621
pipx install polygres-cli
1722
```
1823

19-
From the repository root, create an isolated development environment and
20-
install the CLI in editable mode:
24+
The installed command is `polygres`.
2125

22-
```bash
23-
python3 -m venv .venv
24-
source .venv/bin/activate
25-
sfw pip install -e packages/python-cli
26-
polygres context capabilities --help
27-
```
26+
## Get started
2827

29-
The command remains `polygres`:
28+
Sign in, choose a project, and check that it is ready:
3029

3130
```bash
3231
polygres login
3332
polygres whoami
3433
polygres projects list
3534
polygres projects use <project-id-or-exact-name>
36-
polygres env
3735
polygres ready
3836
```
3937

40-
`polygres login` opens the Polygres dashboard for approval and prints a URL for
41-
headless terminals. Credentials are stored at
42-
`~/.config/polygres/config.json` with owner-only permissions on POSIX systems.
43-
Run `polygres logout` to revoke the refresh token and remove local credentials.
38+
`polygres login` opens the dashboard for approval. On a headless terminal, it prints a URL that you can open in another browser. Run `polygres logout` when you want to revoke the session and remove the local credentials.
39+
40+
## Common workflows
4441

45-
Common project operations:
42+
### Load data and apply migrations
4643

4744
```bash
4845
polygres import csv ./documents.csv --table documents --wait
4946
polygres migrations apply --file ./001_create_documents.sql
47+
```
48+
49+
### Configure retrieval
50+
51+
```bash
5052
polygres graph discover --json > graph.json
5153
polygres graph config apply --file graph.json
5254
polygres vector configs list
53-
polygres vector configs set-default <config-id>
5455
polygres text configs list
55-
polygres context capabilities
56-
polygres context collections list
57-
polygres api routes
58-
polygres notices
5956
```
6057

61-
AI Search commands use the existing login and selected-project workflow:
58+
## Version and support
59+
60+
The current published CLI release is [`0.1.2`](https://github.com/Evokoa/polygres-cli/releases/tag/python-cli-v0.1.2).
61+
62+
Useful commands:
6263

6364
```bash
64-
polygres login
65-
polygres projects use <project-id-or-exact-name>
66-
polygres context sources discover
67-
polygres context collections create support_docs \
68-
--source new-table \
69-
--table support_docs \
70-
--dimensions 768
71-
polygres context search support_docs --embedding-file query-embedding.json
72-
polygres context joint support_docs \
73-
--embedding-file query-embedding.json \
74-
--query "current guidance" \
75-
--semantic-weight 0.6 \
76-
--lexical-weight 0.1 \
77-
--graph-weight 0.3
65+
polygres --version
66+
polygres --help
7867
```
7968

80-
Context is the pgContext-backed collection namespace. It does not reuse
81-
pgvector configurations. Mutations send an idempotency key and wait for their
82-
durable operation by default; use `--no-wait` to return after acceptance.
83-
Global `--json`, `--project`, `--quiet`, and `--verbose` flags must precede
84-
`context`.
69+
Exit codes distinguish validation (`2`), authentication (`3`), permission (`4`), not found (`5`), conflict (`6`), rate limiting (`7`), service availability (`8`), and missing local tools such as `psql` (`9`).
8570

86-
## Generic API routes
71+
## CLI and SDK
8772

88-
The `api` namespace exposes control-plane routes from the versioned OpenAPI
89-
snapshot bundled with the CLI. It supplements the stable high-level commands;
90-
those commands and their handlers remain registered in Python.
73+
Install `polygres-cli` for terminal workflows. Install `polygres-sdk` in an application that needs graph, vector, text, or hybrid retrieval. The two packages are independent.
9174

92-
List routes, inspect one operation, validate a dry run, and execute it:
75+
Users of the former combined `polygres` package should install both packages separately when they need both interfaces.
9376

94-
```bash
95-
polygres api routes
96-
polygres --json api routes --method GET
97-
polygres --json api request /projects/{project_id} --method GET --schema
98-
polygres --json --project <project-id> api request /projects/{project_id} \
99-
--method GET \
100-
--dry-run
101-
polygres --json api request /projects \
102-
--method POST \
103-
--body '{"name":"Support Search"}'
104-
```
77+
## Changelog
10578

106-
Use repeatable `--param NAME=VALUE` options for declared path and query
107-
parameters. Prefix an ambiguous name with `path:`, `query:`, or `header:`.
108-
Use `--body-file <path>` for a UTF-8 JSON document, or `--body-file -` to read
109-
one from standard input.
110-
111-
Only route templates and HTTP methods in the bundled snapshot can execute.
112-
Full URLs, query strings in the route argument, undeclared parameters,
113-
unsupported methods, unsafe path values, and bodies that do not satisfy the
114-
declared JSON schema are rejected before a request is sent.
115-
116-
## CLI notices
117-
118-
After a command succeeds, the CLI checks the configured Polygres API for
119-
applicable service and release notices. Notice text is written only to standard
120-
error, so standard output and `--json` remain safe for automation. The response
121-
is cached for up to 10 hours at `~/.config/polygres/notices.json`. Running
122-
`polygres --version` forces a conditional refresh, and `polygres notices`
123-
refreshes and displays all currently applicable notices regardless of their
124-
normal `once` or `daily` display policy.
125-
126-
The check uses a two-second timeout and never changes a command's exit status.
127-
Network failures, offline operation, malformed responses, and an unavailable
128-
notice service are silent. Requests go only to the fixed `/cli/notices` path at
129-
the configured Polygres API origin. The CLI sends its version, derived release
130-
channel, operating system, and architecture for targeting. It does not send
131-
command arguments or command output.
132-
133-
Remote notices are plain text. The CLI strips control and ANSI characters,
134-
limits title and message lengths, accepts only validated HTTPS links, and uses
135-
a fixed local renderer. Notices cannot define commands, handlers, formatting,
136-
or endpoints.
137-
138-
Run `polygres --help` for the full command reference. Exit codes distinguish
139-
validation (`2`), authentication (`3`), permission (`4`), not found (`5`),
140-
conflict (`6`), rate limiting (`7`), remote availability (`8`), and missing
141-
local tools such as `psql` (`9`).
142-
143-
## Relationship to the Python SDK
144-
145-
The CLI is distributed separately from the Python SDK. Install `polygres-sdk` when
146-
your application needs Runtime API retrieval methods, and install
147-
`polygres-cli` when you need the terminal command. The CLI has its own
148-
control-plane client and does not require the SDK.
149-
150-
Users of the former combined `polygres` package should install `polygres-cli`
151-
and `polygres-sdk` separately.
152-
153-
See [CHANGELOG.md](CHANGELOG.md) for release notes.
79+
See the [CLI 0.1.2 release notes](https://github.com/Evokoa/polygres-cli/releases/tag/python-cli-v0.1.2) for published changes.

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ polygres = "polygres_cli.cli:main"
3333

3434
[project.urls]
3535
Homepage = "https://polygres.com"
36-
Documentation = "https://docs.evokoa.com/polygres"
36+
Documentation = "https://docs.polygres.com/cli"
3737
Repository = "https://github.com/Evokoa/polygres-cli"
3838
Changelog = "https://github.com/Evokoa/polygres-cli/blob/main/CHANGELOG.md"
3939
Issues = "https://github.com/Evokoa/polygres-cli/issues"

src/polygres_cli/__init__.py

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,5 @@
11
"""Polygres command-line client package."""
2+
3+
from polygres_cli._version import __version__
4+
5+
__all__ = ["__version__"]

0 commit comments

Comments
 (0)