|
1 | 1 | # Polygres CLI |
2 | 2 |
|
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) |
6 | 9 |
|
7 | 10 | ## Install |
8 | 11 |
|
| 12 | +Install the CLI with pip: |
| 13 | + |
9 | 14 | ```bash |
10 | 15 | pip install polygres-cli |
11 | 16 | ``` |
12 | 17 |
|
13 | | -For an isolated global installation: |
| 18 | +For an isolated global installation, use pipx: |
14 | 19 |
|
15 | 20 | ```bash |
16 | 21 | pipx install polygres-cli |
17 | 22 | ``` |
18 | 23 |
|
19 | | -From the repository root, create an isolated development environment and |
20 | | -install the CLI in editable mode: |
| 24 | +The installed command is `polygres`. |
21 | 25 |
|
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 |
28 | 27 |
|
29 | | -The command remains `polygres`: |
| 28 | +Sign in, choose a project, and check that it is ready: |
30 | 29 |
|
31 | 30 | ```bash |
32 | 31 | polygres login |
33 | 32 | polygres whoami |
34 | 33 | polygres projects list |
35 | 34 | polygres projects use <project-id-or-exact-name> |
36 | | -polygres env |
37 | 35 | polygres ready |
38 | 36 | ``` |
39 | 37 |
|
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 |
44 | 41 |
|
45 | | -Common project operations: |
| 42 | +### Load data and apply migrations |
46 | 43 |
|
47 | 44 | ```bash |
48 | 45 | polygres import csv ./documents.csv --table documents --wait |
49 | 46 | polygres migrations apply --file ./001_create_documents.sql |
| 47 | +``` |
| 48 | + |
| 49 | +### Configure retrieval |
| 50 | + |
| 51 | +```bash |
50 | 52 | polygres graph discover --json > graph.json |
51 | 53 | polygres graph config apply --file graph.json |
52 | 54 | polygres vector configs list |
53 | | -polygres vector configs set-default <config-id> |
54 | 55 | polygres text configs list |
55 | | -polygres context capabilities |
56 | | -polygres context collections list |
57 | | -polygres api routes |
58 | | -polygres notices |
59 | 56 | ``` |
60 | 57 |
|
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: |
62 | 63 |
|
63 | 64 | ```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 |
78 | 67 | ``` |
79 | 68 |
|
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`). |
85 | 70 |
|
86 | | -## Generic API routes |
| 71 | +## CLI and SDK |
87 | 72 |
|
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. |
91 | 74 |
|
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. |
93 | 76 |
|
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 |
105 | 78 |
|
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. |
0 commit comments