silpo-agent-cli 0.2.0__py3-none-any.whl

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.
@@ -0,0 +1,271 @@
1
+ Metadata-Version: 2.4
2
+ Name: silpo-agent-cli
3
+ Version: 0.2.0
4
+ Summary: Personal CLI wrapper over the Silpo MCP server
5
+ Author-email: "d.bilukcha" <3037823+MIt9@users.noreply.github.com>
6
+ License-Expression: MIT
7
+ License-File: LICENSE
8
+ Requires-Python: >=3.11
9
+ Requires-Dist: keyring>=25.7.0
10
+ Description-Content-Type: text/markdown
11
+
12
+ # silpo-agent-cli
13
+
14
+ [![Tests](https://github.com/MIt9/silpo-agent-cli/actions/workflows/test.yml/badge.svg)](https://github.com/MIt9/silpo-agent-cli/actions/workflows/test.yml)
15
+ [![License: MIT](https://img.shields.io/badge/License-MIT-yellow.svg)](LICENSE)
16
+ [![Python 3.11+](https://img.shields.io/badge/python-3.11+-blue.svg)](pyproject.toml)
17
+
18
+ CLI wrapper over the Silpo MCP server (`https://mcp.silpo.ua/mcp`) for
19
+ grocery shopping: rebuild your cart from what you typically buy, check and
20
+ edit what's actually in it, and see what's on sale — without leaving the
21
+ terminal.
22
+
23
+ **Primary use case: pair it with an AI agent.** This is a plain,
24
+ scriptable CLI on purpose — every command has a stable `--help`, flags do
25
+ one thing, and output carries the product slugs needed for follow-up calls.
26
+ Point an agent (e.g. Claude Code) at `.claude/skills/silpo-cli-usage/` and
27
+ it can turn "reorder my usual groceries, budget 1500" into the right
28
+ invocation, read the result, and handle prompts — you don't have to
29
+ memorize flags or babysit the terminal yourself. See
30
+ [Claude Code skills](#claude-code-skills) below.
31
+
32
+ ## Setup
33
+
34
+ ```bash
35
+ uv sync
36
+ ```
37
+
38
+ First run of any command that talks to the MCP server opens a browser for a
39
+ one-time OAuth2.1+PKCE login; the token is cached in the OS keyring
40
+ afterward, so you won't be re-prompted until it expires.
41
+
42
+ ## Commands
43
+
44
+ Run `uv run silpo-agent --help` for the full list, or `<command> --help`
45
+ for a command's flags and examples. Every command is interactive where it
46
+ matters (address/item confirmation) — run them somewhere you're watching,
47
+ not backgrounded.
48
+
49
+ ### `reorder` — rebuild the cart from your typical items
50
+
51
+ ```bash
52
+ uv run silpo-agent reorder --last 10 --threshold 0.5
53
+ ```
54
+
55
+ Looks at your recent online orders, works out which products you buy
56
+ consistently, checks they're still in stock, handles substitutions and
57
+ (optionally) loyalty bonuses, and fills your real Silpo cart.
58
+
59
+ - `--last N` — how many of your most recent online orders to consider.
60
+ - `--threshold T` — minimum share of those orders a product must appear in
61
+ to count as a "typical item" (e.g. `0.5` = bought in at least half).
62
+ - `--budget UAH` — optional spend cap; trims your least-frequently-bought
63
+ items first until the total fits. Omit it to add everything and just see
64
+ the total.
65
+ - `--optimize promos` — opt-in; applies any available loyalty bonuses to
66
+ the cart. Omitting this flag makes zero promo-related calls.
67
+ - `--yes` / `-y` — non-interactive: auto-confirms the proposed delivery
68
+ address, auto-confirms adding to a non-empty cart, and auto-picks the
69
+ first candidate on any substitution with multiple replacements. Every
70
+ auto-answered prompt is still printed, and the report still lists the
71
+ address used, substitutions made, and items added.
72
+
73
+ Confirms your delivery address, warns and asks before proceeding if your
74
+ cart's delivery context has a real error (e.g. a stale timeslot), warns
75
+ before touching a non-empty cart, and asks which replacement you want when
76
+ an out-of-stock item has more than one candidate. `--budget` counts what's
77
+ already in the cart (its own payable total) against the cap, not just the
78
+ new items, so reordering onto a non-empty cart can't blow past budget.
79
+
80
+ ### `smart-cart` — typical items, discounted favorites, and norm top-up
81
+
82
+ ```bash
83
+ uv run silpo-agent smart-cart --last 10 --threshold 0.5
84
+ uv run silpo-agent smart-cart --people 5 --basket-type premium --budget 1500
85
+ ```
86
+
87
+ Runs the same typical-items pipeline as `reorder` (address confirmation,
88
+ substitution, non-empty-cart guard), then layers on two more sources:
89
+
90
+ 1. Any of your favorited products currently on discount that aren't already
91
+ in the resulting cart — deduplicated by product id, so a favorite that's
92
+ also a typical item is never added twice.
93
+ 2. A **norm top-up**: for any grocery category (vegetables, fruits, protein,
94
+ dairy, grains, pantry) with no real product-id overlap with what's
95
+ already going into the cart, proposes an addition sized to
96
+ `--people N` and `--basket-type basic|eco|premium`, shown as its own list
97
+ with a separate `[y/N]` confirmation before joining the cart (typical
98
+ items and favorites-deals don't get this extra gate — they're known
99
+ purchases, norms are a guess).
100
+
101
+ - `--last N` / `--threshold T` — same as `reorder`.
102
+ - `--people N` — household size the norm top-up scales to (default `1`).
103
+ - `--basket-type basic|eco|premium` — norm generosity (default `eco`).
104
+ - `--budget N` — like `reorder --budget`, but trims across all three
105
+ sources in priority order when over budget: norm items drop first, then
106
+ favorited deals, then typical items as a last resort.
107
+ - `--yes` / `-y` — same as `reorder`: non-interactive, every auto-answered
108
+ prompt (including the norm top-up confirmation) still printed.
109
+
110
+ The report lists all three sources separately ("Added N typical item(s)" /
111
+ "Added M favorited deal(s)" / "Added K norm item(s)"), and a `--budget`
112
+ trim's "Trimmed" section is labeled by which source each dropped item came
113
+ from.
114
+
115
+ ### `cart` — view, edit, and check promos on your current cart
116
+
117
+ ```bash
118
+ uv run silpo-agent cart # read-only: items, payable total, bonus balance, validations
119
+ uv run silpo-agent cart promos # read-only: real promo alternatives for every item in the cart
120
+ uv run silpo-agent cart edit # interactive: replace one item (free-text search or promo browse)
121
+ uv run silpo-agent cart edit --replace <old-slug> <new-slug> # non-interactive swap
122
+ uv run silpo-agent cart edit --add <new-slug> [--quantity N] # non-interactive add, no swap
123
+ uv run silpo-agent cart edit --qty <slug> <num> # set an existing line's quantity (absolute, not a delta)
124
+ uv run silpo-agent cart edit --remove <slug> # delete a line, nothing added back
125
+ ```
126
+
127
+ Running `silpo-agent` with no subcommand at all is the same as `cart` — it
128
+ shows the current real cart (delivery address/type/timeslot, items, payable
129
+ total, bonus balance) instead of just printing help.
130
+
131
+ `cart edit` is the only command besides `reorder` that mutates the real
132
+ cart. `--replace` is a remove-then-add swap (Silpo has no in-place
133
+ quantity/item update); `--quantity` and `--qty`'s `<num>` both accept a
134
+ fractional number (e.g. `0.5`) for weighted products sold by kg. It
135
+ validates the replacement is resolvable, or the slug is actually a cart
136
+ line, before mutating anything, so a failed lookup or bad slug never leaves
137
+ the cart missing an item.
138
+
139
+ **Products are addressed by slug.** Every read-only command prints each
140
+ product's slug at the end of its line, and that is exactly what `--replace`
141
+ takes — copy one straight across:
142
+
143
+ ```
144
+ - Молоко «Ферма» ультрапастеризоване 2,5% x2 @ 49.9 (stock: 189) moloko-ferma-ultrapasteryzovane-2-5-576829
145
+ ```
146
+
147
+ Slugs are generated by Silpo and cannot be derived from a product name, so
148
+ always copy a printed one rather than constructing it. The old slug is
149
+ matched against your cart locally; the new one is resolved through
150
+ `silpo_get_product_details`.
151
+
152
+ ### `deals` — best current discounts store-wide
153
+
154
+ ```bash
155
+ uv run silpo-agent deals --limit 10 # default 10
156
+ uv run silpo-agent deals --category "Овочі" # scope to one category
157
+ uv run silpo-agent deals --list-categories # list every real category title
158
+ ```
159
+
160
+ Independent of your cart — scans active promotion categories and shows the
161
+ top discounts by percentage off. `--category` is matched against real
162
+ category titles (exact match preferred, else the shortest title containing
163
+ it) — if it falls back to that fuzzy match, the actual matched title is
164
+ printed before results so a near-miss (e.g. "Вино" matching "Виноград") is
165
+ never silent. `--list-categories` shows every real title to pick from,
166
+ read-only, no deals fetched.
167
+
168
+ ### `favorites-deals` — your favorites that are currently discounted
169
+
170
+ ```bash
171
+ uv run silpo-agent favorites-deals
172
+ ```
173
+
174
+ ### `coupons` — your active loyalty coupons
175
+
176
+ ```bash
177
+ uv run silpo-agent coupons
178
+ ```
179
+
180
+ Read-only list of what's active and what buying-condition triggers each
181
+ one. Coupons apply automatically server-side when their condition is met —
182
+ there's no "activate" step this tool can perform.
183
+
184
+ ### `delivery` — set address, delivery type, and timeslot
185
+
186
+ ```bash
187
+ uv run silpo-agent delivery
188
+ ```
189
+
190
+ Interactive: address (existing saved address, pick a different one, or
191
+ enter a new one) → delivery type (`DeliveryHome`, `SelfPickup`, or
192
+ `NovaPoshta`) → timeslot, applied in one real update to your account. Prints
193
+ which of your current cart items are now unavailable in the new context
194
+ afterward — informational only, nothing gets swapped automatically.
195
+
196
+ ### `clear-context` — wipe local reorder history, substitution memory, and cached login
197
+
198
+ ```bash
199
+ uv run silpo-agent clear-context # asks for confirmation first
200
+ uv run silpo-agent clear-context --yes # skip the confirmation prompt
201
+ ```
202
+
203
+ Wipes the local Reorder Log and Substitution Memory, and clears the cached
204
+ OAuth token from your OS keyring — a full reset that also logs you out. The
205
+ next command needing a token triggers a fresh browser login. Never touches
206
+ your real Silpo cart or calls the MCP server.
207
+
208
+ ## Claude Code skills
209
+
210
+ - `.claude/skills/silpo-cli-usage/` (this repo) — **the intended way to
211
+ drive this tool day to day.** Mirrors every command's `--help` output so
212
+ an agent can turn a plain-language ask ("reorder my usual groceries,
213
+ budget 1500", "what's in my cart", "swap the milk for something on
214
+ promo") into the right invocation, handle the interactive prompts, and
215
+ know this tool's quirks (cart-only scope in `reorder`, slugs vs. product
216
+ names, where local history lives). Ships portable — no machine-specific
217
+ paths — so it works from wherever you clone this repo.
218
+
219
+ See [CONTRIBUTING.md](CONTRIBUTING.md) if you're extending the tool itself
220
+ (TDD-first, test seams, PR expectations).
221
+
222
+ ## Local state
223
+
224
+ Past `reorder` runs (items added, substitutions, confirmed address, total,
225
+ timestamp) and remembered substitution choices are logged to
226
+ `~/.silpo-agent/reorder_log.json`, append-only. Nothing here feeds back into
227
+ what counts as a "typical item" — only your confirmed online orders do.
228
+ `clear-context` wipes this file.
229
+
230
+ ## Tests
231
+
232
+ ```bash
233
+ uv run pytest
234
+ ```
235
+
236
+ ## Project docs
237
+
238
+ - `CONTEXT.md` — domain glossary (Typical item, Substitution decision,
239
+ Cart Editor, Promo Scanner, etc.) — read this before the code if a term
240
+ is unclear.
241
+ - The original PRDs and live-verified MCP schema notes this project was
242
+ built from aren't in this public repo — they're working notes, not
243
+ reference docs, and may contain incidental account details. Ask in an
244
+ issue if you need context beyond `CONTEXT.md` and the code itself.
245
+ - Build status lives in the repo's GitHub issues (`MIt9/silpo-agent-cli`),
246
+ not a local TODO file — every ticket that shipped is closed there, with
247
+ the PR that implemented it linked.
248
+
249
+ ## Known limitations
250
+
251
+ - Substitution Resolver's availability check searches by the typical item's
252
+ name when known, otherwise falls back to a raw product-id UUID as the
253
+ search query — which usually returns nothing useful. A `reorder` run
254
+ reporting every item "unavailable" is likely this gap, not genuine
255
+ across-the-board out-of-stock. See `docs/mcp_schema.md` (issue #18).
256
+ - `reorder --optimize promos` only applies loyalty bonuses — swapping an
257
+ item for a cheaper promo equivalent automatically was dropped there (no
258
+ reliable per-product "find the promo version of X" tool exists). Manual
259
+ promo discovery is still possible via `cart promos` / `cart edit`'s
260
+ promo-browse path, which use Silpo's own similar-products engine instead
261
+ of a name-matching guess.
262
+ - `week` (recipe-plan-based cart) from the original idea list was never
263
+ built — the MCP server has no recipe/meal-planning tool.
264
+ - `delivery`'s NovaPoshta branch resolution assumes exactly one servicing
265
+ branch nationwide (true for every account tested so far); if that's ever
266
+ false for an account, the first one found is used, with a printed note
267
+ rather than a picker.
268
+
269
+ ## License
270
+
271
+ MIT — see [LICENSE](LICENSE).
@@ -0,0 +1,25 @@
1
+ silpo_agent/__init__.py,sha256=47DEQpj8HBSa-_TImW-5JCeuQeRkm5NMpJWZG3hSuFU,0
2
+ silpo_agent/address_resolver.py,sha256=DcnzTSkXJsElTtMzi2Qmeb6FYFurXZyQBXGGSo3tRYc,6352
3
+ silpo_agent/auth.py,sha256=_UYXC25mHhlwRSZ2ufkCpO-XrreN90iRh1jeICErjXo,9424
4
+ silpo_agent/cart_context.py,sha256=tJhEi4FXekFG74KqrqDK1hLTFLJ0lWJXVKZC3aZIghE,9302
5
+ silpo_agent/cart_editor.py,sha256=DOtYiqeCzUVdnLV3OmPr9dhO8x6A41jTJ7v6Ox1shKQ,15249
6
+ silpo_agent/cart_viewer.py,sha256=lvg58SgX3ZI3B3xcgGSaD6-9uUaTWlK9xUf9y34bUaY,4907
7
+ silpo_agent/cart_writer.py,sha256=Y1BkD1pfqsk57EXZs-lqTHpFALCpvG5T7UwVCTdK2BM,9509
8
+ silpo_agent/cli.py,sha256=awEGMywmYEVDxSPWX-QRjTS7yzeMSMw-ZcA0cdzvxEU,50099
9
+ silpo_agent/coupons_lister.py,sha256=dKGy38TseGabYV7q0GN9yeDuE5on0pqzj44Elgd_my4,2693
10
+ silpo_agent/delivery_settings.py,sha256=cDF0R6Ea89C5lB9YvQDG4CaWNdVE0CO8RAEXyfsbosQ,20370
11
+ silpo_agent/favorites_deals.py,sha256=Q6eZU7zUZF4aKP0gJT1JZP-yBRj1EHknvMc5oP6G9p4,4160
12
+ silpo_agent/log_store.py,sha256=f7Bz4b4kn9mcYYYt5SWmJ4cu4RfrE90XIROv0amj0qQ,2838
13
+ silpo_agent/norm_dataset.py,sha256=J3m-Z9nafzyUQA5qiownVJKgdVi3MbuIwfPU_Tm5DNY,2073
14
+ silpo_agent/norm_top_up.py,sha256=CUFXG8mVMXszhikzDd1z6-46fv0s_FIw0hrhLgGIbAs,9887
15
+ silpo_agent/order_aggregator.py,sha256=Hd51cyJPJkEMJFnYh16Iw7wRAyaL_LEuwFn4UNOqnf4,3029
16
+ silpo_agent/promo_finder.py,sha256=yJpRqGoqx6EjsRV281qxUUdxjTf4D_bUbFUBIoYCWUA,3833
17
+ silpo_agent/promo_optimizer.py,sha256=Npexwhb8KQcc_k1S5_7WYIiCBDY40EZRd3cQDF4GZRI,4221
18
+ silpo_agent/promo_scanner.py,sha256=K7bMWRdLa3PZSPDXy1NXvzKJfwDiZm4ur-c6rrPfxNA,10551
19
+ silpo_agent/substitution_resolver.py,sha256=5Kc4SrU67cvbdFfbXd9Bh7UAZg9h0HusmrB-0Uvlebo,11320
20
+ silpo_agent/timeslot_format.py,sha256=8nom3dK4grnIQ6GR1PgL-aagTf7YBujZFU-slKeltKA,937
21
+ silpo_agent_cli-0.2.0.dist-info/METADATA,sha256=64Jx0XlGxHnQdtw5jCC5CoFf_efGuzisM-l4Mp5-2Tg,12496
22
+ silpo_agent_cli-0.2.0.dist-info/WHEEL,sha256=lCkmxWfQsSc9CfIClYeavTdQeEX2toPqufh9gI35EQA,87
23
+ silpo_agent_cli-0.2.0.dist-info/entry_points.txt,sha256=SumFX1jndXB1WpURqjr2ertw3nCkwQ_2P2_6uVAa7GQ,53
24
+ silpo_agent_cli-0.2.0.dist-info/licenses/LICENSE,sha256=3F8k499rrw70ZiSvC4jZUMY0ZzTcQdyw7DbvfsbOga4,1067
25
+ silpo_agent_cli-0.2.0.dist-info/RECORD,,
@@ -0,0 +1,4 @@
1
+ Wheel-Version: 1.0
2
+ Generator: hatchling 1.31.0
3
+ Root-Is-Purelib: true
4
+ Tag: py3-none-any
@@ -0,0 +1,2 @@
1
+ [console_scripts]
2
+ silpo-agent = silpo_agent.cli:main
@@ -0,0 +1,21 @@
1
+ MIT License
2
+
3
+ Copyright (c) 2026 d.bilukcha
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.