cli-market-world 1.9.5__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.
Files changed (32) hide show
  1. cli_market_world-1.9.5/PKG-INFO +219 -0
  2. cli_market_world-1.9.5/README.md +193 -0
  3. cli_market_world-1.9.5/account_service.py +199 -0
  4. cli_market_world-1.9.5/backend_interface.py +129 -0
  5. cli_market_world-1.9.5/cli_market_world.egg-info/PKG-INFO +219 -0
  6. cli_market_world-1.9.5/cli_market_world.egg-info/SOURCES.txt +30 -0
  7. cli_market_world-1.9.5/cli_market_world.egg-info/dependency_links.txt +1 -0
  8. cli_market_world-1.9.5/cli_market_world.egg-info/entry_points.txt +4 -0
  9. cli_market_world-1.9.5/cli_market_world.egg-info/requires.txt +13 -0
  10. cli_market_world-1.9.5/cli_market_world.egg-info/top_level.txt +9 -0
  11. cli_market_world-1.9.5/collect_prices.py +1002 -0
  12. cli_market_world-1.9.5/market_cli.py +2040 -0
  13. cli_market_world-1.9.5/market_funnel.py +231 -0
  14. cli_market_world-1.9.5/market_security.py +78 -0
  15. cli_market_world-1.9.5/market_server.py +180 -0
  16. cli_market_world-1.9.5/market_ui.py +801 -0
  17. cli_market_world-1.9.5/pyproject.toml +67 -0
  18. cli_market_world-1.9.5/server_deps.py +206 -0
  19. cli_market_world-1.9.5/setup.cfg +4 -0
  20. cli_market_world-1.9.5/tests/test_adoption.py +125 -0
  21. cli_market_world-1.9.5/tests/test_auth_register.py +26 -0
  22. cli_market_world-1.9.5/tests/test_cli_activation.py +82 -0
  23. cli_market_world-1.9.5/tests/test_cli_install.py +50 -0
  24. cli_market_world-1.9.5/tests/test_cli_session.py +61 -0
  25. cli_market_world-1.9.5/tests/test_daily_briefing_paths.py +61 -0
  26. cli_market_world-1.9.5/tests/test_funnel.py +92 -0
  27. cli_market_world-1.9.5/tests/test_golive.py +152 -0
  28. cli_market_world-1.9.5/tests/test_pepy.py +59 -0
  29. cli_market_world-1.9.5/tests/test_regression.py +31 -0
  30. cli_market_world-1.9.5/tests/test_security.py +78 -0
  31. cli_market_world-1.9.5/tests/test_server.py +880 -0
  32. cli_market_world-1.9.5/tests/test_sync_content_template.py +50 -0
@@ -0,0 +1,219 @@
1
+ Metadata-Version: 2.4
2
+ Name: cli-market-world
3
+ Version: 1.9.5
4
+ Summary: mcp-name: io.github.Treevu-ai/cli-market-world - CLI Market: commerce API for AI agents. 43 MCP tools, 34 indicators, 38 verified retailers in 8 countries. MIT.
5
+ Author-email: CLI Market <hello@cli-market.dev>
6
+ License-Expression: MIT
7
+ Keywords: vtex,mcp,ai-agents,ecommerce,cli,retail,commerce,infrastructure
8
+ Classifier: Development Status :: 4 - Beta
9
+ Classifier: Intended Audience :: Developers
10
+ Classifier: Programming Language :: Python :: 3
11
+ Classifier: Topic :: Internet :: WWW/HTTP :: Indexing/Search
12
+ Requires-Python: >=3.10
13
+ Description-Content-Type: text/markdown
14
+ Requires-Dist: cli-market-core>=1.9.5
15
+ Requires-Dist: httpx>=0.27
16
+ Requires-Dist: rich>=13.0
17
+ Requires-Dist: fastapi>=0.115
18
+ Requires-Dist: uvicorn>=0.30
19
+ Requires-Dist: pydantic>=2.0
20
+ Requires-Dist: python-multipart>=0.0.9
21
+ Requires-Dist: psycopg2-binary>=2.9
22
+ Requires-Dist: asyncpg>=0.29
23
+ Requires-Dist: playwright>=1.45.0
24
+ Provides-Extra: playwright
25
+ Requires-Dist: playwright>=1.45.0; extra == "playwright"
26
+
27
+ mcp-name: io.github.Treevu-ai/cli-market-world
28
+
29
+ # 🛒 CLI Market
30
+
31
+ [![PyPI Downloads](https://static.pepy.tech/personalized-badge/cli-market-world?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/cli-market-world)
32
+ [![PyPI](https://img.shields.io/pypi/v/cli-market-world.svg)](https://pypi.org/project/cli-market-world/)
33
+
34
+ **🌐 [Español](#-español) · [English](#-english)**
35
+
36
+ ---
37
+
38
+ ## 🇪🇸 Español
39
+
40
+ ### Infraestructura de comercio para agentes de IA — un solo `pip install`, una API, cero scraping.
41
+
42
+ > **Stripe convirtió los pagos en APIs. CLI Market convierte el comercio en una.**
43
+
44
+ Los agentes de IA todavía no pueden comprar en el mundo real. Cada retailer exige su propia autenticación, su propia lógica de búsqueda y no comparten carrito — así que los agentes fallan antes de la primera consulta.
45
+
46
+ **CLI Market lo resuelve.** Un solo `pip install`. Una llamada a la API que cubre **68 retailers (38 verificados activos)** en **8 países**. Un único esquema JSON.
47
+
48
+ - 🌍 **68 retailers (38 verificados activos) · 8 países · 4 plataformas · 43 herramientas MCP · 34 indicadores**
49
+ - 💰 **Más de 49,000+ precios de góndola verificados**, normalizados por kg/L, actualizados cada 4 horas
50
+ - 💳 **Pago con PayPal + Mercado Pago + QR (Yape/Plin)** integrado
51
+
52
+ #### ✨ ¿Por qué CLI Market?
53
+
54
+ - 🔎 **Busca** cualquier producto en 68 retailers (38 verificados activos) de 8 países
55
+ - 📊 **Compara** precios transfronterizos — PEN, ARS, BRL, MXN, COP, CLP, EUR, USD — normalizados por kg/L cuando es posible
56
+ - 🧺 **Canasta** — compara tu carrito completo entre retailers (p. ej. Carrefour vs Jumbo vs Vea en AR)
57
+ - 📈 **Inflación** — sigue cambios reales de precios desde la góndola, actualizados cada 4 horas
58
+ - 🧠 **Enriquecimiento** — 34 indicadores de mercado a partir de datos de góndola + APIs públicas (OFF, Wikimedia, IMF, Eurostat, BCB, Banco Mundial)
59
+ - 🛍️ **Compra** — checkout con PayPal o QR (Yape / Plin)
60
+ - 🏗️ **Construye** — foso de datos con spreads filtrados por calidad, matching de canasta y dashboard en vivo
61
+
62
+ 🌐 [cli-market.dev](https://cli-market.dev) · 📚 [Docs de API](https://cli-market-production.up.railway.app/docs) · 📊 [Dashboard](https://cli-market-production.up.railway.app/dashboard)
63
+
64
+ #### 🚀 Inicio rápido
65
+
66
+ ```bash
67
+ pip install cli-market-world
68
+ market hello # post-instalación: estadísticas + próximos pasos (API prod por defecto)
69
+
70
+ # Solo para servidor local: export MARKET_API_URL=http://127.0.0.1:8765
71
+ market login
72
+ market search "leche" --country PE
73
+ market compare "aceite de girasol 900ml" --country AR
74
+ market basket "arroz:1 aceite:1 leche:1" --country AR
75
+ market checkout --payment yape
76
+ market ask "compra arroz al mejor precio"
77
+ market indicators --country PE
78
+ market enrichment --refresh -c PE
79
+ ```
80
+
81
+ #### 💵 Planes (simplificado — foco en 1 ICP principal: AI Agent Builders)
82
+
83
+ | Plan | Free | Pro | Enterprise |
84
+ |------|------|-----|------------|
85
+ | **Precio** | $0 | $39/mes | A medida |
86
+ | **Solicitudes/día** | 1,000 | 10,000 | Ilimitadas (negociado) |
87
+ | **Solicitudes/min** | 60 | 300 | Ilimitadas |
88
+ | **API keys** | 1 | 10 | Ilimitadas |
89
+ | **Agente intel** | — | Ilimitado | Ilimitado + white-label |
90
+ | **Alertas de precio** | — | ✅ Hasta 10 (email) | Ilimitadas (email + webhook) |
91
+ | **Historial de precios** | 7 días | 12 meses | Completo |
92
+ | **Exportar datos** | — | CSV ilimitado + cron | Feed directo S3/webhook |
93
+ | **Checkout** | — | ✅ PayPal / Yape / Plin | ✅ |
94
+ | **Soporte** | Comunidad | Email 4h | 24/7 + SLA escrito |
95
+ | **Anual** | — | $390/año | — |
96
+
97
+ ---
98
+
99
+ ## 🇬🇧 English
100
+
101
+ ### Commerce infrastructure for AI agents — one `pip install`, one API, zero scraping.
102
+
103
+ > **Stripe turned payments into APIs. CLI Market turns commerce into one.**
104
+
105
+ AI agents still can't shop in the real world. Every retailer means separate auth, separate search logic, no shared cart — so agents fail before the first query.
106
+
107
+ **CLI Market fixes that.** One `pip install`. One API call across **66 retailers (38 verified active)** in **8 countries**. One JSON schema.
108
+
109
+ - 🌍 **66 retailers (38 verified active) · 8 countries · 3 platforms · 43 MCP tools · 34 indicators**
110
+ - 💰 **49,000+ verified shelf prices**, normalized per kg/L, refreshed every 4 hours
111
+ - 💳 **PayPal + Mercado Pago + QR (Yape/Plin)** checkout built in
112
+
113
+ #### ✨ Why CLI Market?
114
+
115
+ - 🔎 **Search** any product across 66 retailers (38 verified active) in 8 countries
116
+ - 📊 **Compare** cross-border prices — PEN, ARS, BRL, MXN, COP, CLP, EUR, USD — normalized per kg/L where parseable
117
+ - 🧺 **Basket** — compare your full cart across retailers (e.g. Carrefour vs Jumbo vs Vea in AR)
118
+ - 📈 **Inflation** — track real shelf-price changes, updated every 4 hours
119
+ - 🧠 **Enrichment** — 34 market indicators from shelf data + public APIs (OFF, Wikimedia, IMF, Eurostat, BCB, World Bank)
120
+ - 🛍️ **Buy** — checkout with PayPal or QR (Yape / Plin)
121
+ - 🏗️ **Build** — data moat with quality-filtered spreads, basket matching, and live dashboard
122
+
123
+ 🌐 [cli-market.dev](https://cli-market.dev) · 📚 [API docs](https://cli-market-production.up.railway.app/docs) · 📊 [Dashboard](https://cli-market-production.up.railway.app/dashboard)
124
+
125
+ #### 🚀 Quick start
126
+
127
+ ```bash
128
+ pip install cli-market-world
129
+ market hello # post-install: stats + next steps (production API by default)
130
+
131
+ # Local server only: export MARKET_API_URL=http://127.0.0.1:8765
132
+ market login
133
+ market search "leche" --country PE
134
+ market compare "aceite de girasol 900ml" --country AR
135
+ market basket "arroz:1 aceite:1 leche:1" --country AR
136
+ market checkout --payment yape
137
+ market ask "buy rice at the best price"
138
+ market indicators --country PE
139
+ market enrichment --refresh -c PE
140
+ ```
141
+
142
+ #### 💵 Pricing (simplified — focus on 1 primary ICP: AI Agent Builders)
143
+
144
+ | Plan | Free | Pro | Enterprise |
145
+ |------|------|-----|------------|
146
+ | **Price** | $0 | $39/mo | Custom |
147
+ | **Requests/day** | 1,000 | 10,000 | Unlimited (negotiated) |
148
+ | **Requests/min** | 60 | 300 | Unlimited |
149
+ | **API keys** | 1 | 10 | Unlimited |
150
+ | **Intel agent** | — | Unlimited | Unlimited + white-label |
151
+ | **Price alerts** | — | ✅ Up to 10 (email) | Unlimited (email + webhook) |
152
+ | **Price history** | 7 days | 12 months | Full dataset |
153
+ | **Export** | — | CSV unlimited + cron | Direct S3/webhook feed |
154
+ | **Checkout** | — | ✅ PayPal / Yape / Plin | ✅ |
155
+ | **Support** | Community | Email 4h | 24/7 + written SLA |
156
+ | **Annual** | — | $390/yr | — |
157
+
158
+ ---
159
+
160
+ ## 📖 Learn more
161
+
162
+ - **[Use Cases](docs/use-cases.md)** — AI agent builders, data scientists, retailers. Who is this for?
163
+ - **[Terminal Demo](docs/demo-walkthrough.md)** — 8-command walkthrough: search → compare → basket → checkout.
164
+
165
+ ---
166
+
167
+ ## 🏗️ Ecosystem architecture
168
+
169
+ ![Ecosystem Pipeline](docs/assets/ecosystem-pipeline.svg)
170
+
171
+ CLI Market is composed of 4 specialized repositories, each with a single responsibility:
172
+
173
+ ```
174
+ cli-market-backend Data ingestion — VTEX scrapers, FastAPI server, 66 retailers, 45k prices
175
+ |
176
+ v raw snapshots
177
+ cli-market-index Semantic Refinery — entity resolution, Golden Records (prod_ IDs)
178
+ |
179
+ v canonical identities
180
+ cli-market-core Intelligence — indicators, stats, billing, connectors, 43 MCP tools
181
+ |
182
+ v structured intelligence
183
+ cli-market-world Exposure — landing, docs, MCP registry, deployment configs (THIS REPO)
184
+ ```
185
+
186
+ | Repo | Visibility | Role |
187
+ |---|---|---|
188
+ | `cli-market-backend` | Private | Scrapers + FastAPI API |
189
+ | `cli-market-index` | Private | Entity resolution engine |
190
+ | `cli-market-core` | Public | Intelligence + MCP tools |
191
+ | `cli-market-world` | Private | Landing + docs (this repo) |
192
+ | `cli-market-content` | Private | GTM + content calendar |
193
+
194
+ ---
195
+
196
+ ## 📊 Dashboard auditability
197
+
198
+ Every price in CLI Market is traceable and verifiable. The [live dashboard](https://cli-market-production.up.railway.app/dashboard) exposes:
199
+
200
+ - **Cobertura 7 días** — `coverage_7d_pct` per retailer: what % of each store's catalog refreshed in the last week
201
+ - **Normalización por kg/L** — unit price visible next to shelf price (e.g. `PEN 4.20/kg`), with counter of non-parseable names
202
+ - **Confianza por snapshot** — `ok` vs `suspect` distribution from scrape-quality heuristics
203
+ - **Percentiles P25/P50/P75** — median replaces mean in category comparisons; eliminates outlier distortion (e.g. ARS 230K in departamentales)
204
+ - **Trazabilidad de outliers** — group size, band (`median ± k·IQR`), acceptable bounds, scraper health state, capture timestamp
205
+ - **Foso de datos** — `inventory_daily[]` time series + growth stats (total snapshots, daily avg, days tracked)
206
+
207
+ All six capabilities are backed by the same 46,000+, refreshed every 4 hours by the collector daemon.
208
+
209
+ ---
210
+
211
+ ## 🔧 43 MCP tools · 34 indicators
212
+
213
+ `market_login` `market_lines` `market_search` `market_compare` `market_add` `market_cart` `market_cart_update` `market_cart_remove` `market_checkout` `market_orders` `market_reorder` `market_ask` `market_basket` `market_inflation` `market_indicators` `market_scores` `market_intel_refresh` `market_enrichment` `market_enrichment_subcategories` `market_enrichment_refresh` `market_analytics_indicators` `market_categories` `market_barcode` `market_enrich` `market_stores` `market_countries` `market_ticket` `market_voice` `market_price_history` `market_stats` `market_alerts` `market_whoami` `market_preferences` `market_subscription` `market_export` `market_trending` `market_scan` `market_stock` `market_notify` `market_brands` `market_favorites` `market_exchange` `market_delivery`
214
+
215
+
216
+ ---
217
+
218
+ **SINAPSIS INNOVADORA S.A.C.** — RUC 20613045563 — Lima, Peru
219
+ MIT License · [cli-market.dev](https://cli-market.dev)
@@ -0,0 +1,193 @@
1
+ mcp-name: io.github.Treevu-ai/cli-market-world
2
+
3
+ # 🛒 CLI Market
4
+
5
+ [![PyPI Downloads](https://static.pepy.tech/personalized-badge/cli-market-world?period=total&units=INTERNATIONAL_SYSTEM&left_color=BLACK&right_color=GREEN&left_text=downloads)](https://pepy.tech/projects/cli-market-world)
6
+ [![PyPI](https://img.shields.io/pypi/v/cli-market-world.svg)](https://pypi.org/project/cli-market-world/)
7
+
8
+ **🌐 [Español](#-español) · [English](#-english)**
9
+
10
+ ---
11
+
12
+ ## 🇪🇸 Español
13
+
14
+ ### Infraestructura de comercio para agentes de IA — un solo `pip install`, una API, cero scraping.
15
+
16
+ > **Stripe convirtió los pagos en APIs. CLI Market convierte el comercio en una.**
17
+
18
+ Los agentes de IA todavía no pueden comprar en el mundo real. Cada retailer exige su propia autenticación, su propia lógica de búsqueda y no comparten carrito — así que los agentes fallan antes de la primera consulta.
19
+
20
+ **CLI Market lo resuelve.** Un solo `pip install`. Una llamada a la API que cubre **68 retailers (38 verificados activos)** en **8 países**. Un único esquema JSON.
21
+
22
+ - 🌍 **68 retailers (38 verificados activos) · 8 países · 4 plataformas · 43 herramientas MCP · 34 indicadores**
23
+ - 💰 **Más de 49,000+ precios de góndola verificados**, normalizados por kg/L, actualizados cada 4 horas
24
+ - 💳 **Pago con PayPal + Mercado Pago + QR (Yape/Plin)** integrado
25
+
26
+ #### ✨ ¿Por qué CLI Market?
27
+
28
+ - 🔎 **Busca** cualquier producto en 68 retailers (38 verificados activos) de 8 países
29
+ - 📊 **Compara** precios transfronterizos — PEN, ARS, BRL, MXN, COP, CLP, EUR, USD — normalizados por kg/L cuando es posible
30
+ - 🧺 **Canasta** — compara tu carrito completo entre retailers (p. ej. Carrefour vs Jumbo vs Vea en AR)
31
+ - 📈 **Inflación** — sigue cambios reales de precios desde la góndola, actualizados cada 4 horas
32
+ - 🧠 **Enriquecimiento** — 34 indicadores de mercado a partir de datos de góndola + APIs públicas (OFF, Wikimedia, IMF, Eurostat, BCB, Banco Mundial)
33
+ - 🛍️ **Compra** — checkout con PayPal o QR (Yape / Plin)
34
+ - 🏗️ **Construye** — foso de datos con spreads filtrados por calidad, matching de canasta y dashboard en vivo
35
+
36
+ 🌐 [cli-market.dev](https://cli-market.dev) · 📚 [Docs de API](https://cli-market-production.up.railway.app/docs) · 📊 [Dashboard](https://cli-market-production.up.railway.app/dashboard)
37
+
38
+ #### 🚀 Inicio rápido
39
+
40
+ ```bash
41
+ pip install cli-market-world
42
+ market hello # post-instalación: estadísticas + próximos pasos (API prod por defecto)
43
+
44
+ # Solo para servidor local: export MARKET_API_URL=http://127.0.0.1:8765
45
+ market login
46
+ market search "leche" --country PE
47
+ market compare "aceite de girasol 900ml" --country AR
48
+ market basket "arroz:1 aceite:1 leche:1" --country AR
49
+ market checkout --payment yape
50
+ market ask "compra arroz al mejor precio"
51
+ market indicators --country PE
52
+ market enrichment --refresh -c PE
53
+ ```
54
+
55
+ #### 💵 Planes (simplificado — foco en 1 ICP principal: AI Agent Builders)
56
+
57
+ | Plan | Free | Pro | Enterprise |
58
+ |------|------|-----|------------|
59
+ | **Precio** | $0 | $39/mes | A medida |
60
+ | **Solicitudes/día** | 1,000 | 10,000 | Ilimitadas (negociado) |
61
+ | **Solicitudes/min** | 60 | 300 | Ilimitadas |
62
+ | **API keys** | 1 | 10 | Ilimitadas |
63
+ | **Agente intel** | — | Ilimitado | Ilimitado + white-label |
64
+ | **Alertas de precio** | — | ✅ Hasta 10 (email) | Ilimitadas (email + webhook) |
65
+ | **Historial de precios** | 7 días | 12 meses | Completo |
66
+ | **Exportar datos** | — | CSV ilimitado + cron | Feed directo S3/webhook |
67
+ | **Checkout** | — | ✅ PayPal / Yape / Plin | ✅ |
68
+ | **Soporte** | Comunidad | Email 4h | 24/7 + SLA escrito |
69
+ | **Anual** | — | $390/año | — |
70
+
71
+ ---
72
+
73
+ ## 🇬🇧 English
74
+
75
+ ### Commerce infrastructure for AI agents — one `pip install`, one API, zero scraping.
76
+
77
+ > **Stripe turned payments into APIs. CLI Market turns commerce into one.**
78
+
79
+ AI agents still can't shop in the real world. Every retailer means separate auth, separate search logic, no shared cart — so agents fail before the first query.
80
+
81
+ **CLI Market fixes that.** One `pip install`. One API call across **66 retailers (38 verified active)** in **8 countries**. One JSON schema.
82
+
83
+ - 🌍 **66 retailers (38 verified active) · 8 countries · 3 platforms · 43 MCP tools · 34 indicators**
84
+ - 💰 **49,000+ verified shelf prices**, normalized per kg/L, refreshed every 4 hours
85
+ - 💳 **PayPal + Mercado Pago + QR (Yape/Plin)** checkout built in
86
+
87
+ #### ✨ Why CLI Market?
88
+
89
+ - 🔎 **Search** any product across 66 retailers (38 verified active) in 8 countries
90
+ - 📊 **Compare** cross-border prices — PEN, ARS, BRL, MXN, COP, CLP, EUR, USD — normalized per kg/L where parseable
91
+ - 🧺 **Basket** — compare your full cart across retailers (e.g. Carrefour vs Jumbo vs Vea in AR)
92
+ - 📈 **Inflation** — track real shelf-price changes, updated every 4 hours
93
+ - 🧠 **Enrichment** — 34 market indicators from shelf data + public APIs (OFF, Wikimedia, IMF, Eurostat, BCB, World Bank)
94
+ - 🛍️ **Buy** — checkout with PayPal or QR (Yape / Plin)
95
+ - 🏗️ **Build** — data moat with quality-filtered spreads, basket matching, and live dashboard
96
+
97
+ 🌐 [cli-market.dev](https://cli-market.dev) · 📚 [API docs](https://cli-market-production.up.railway.app/docs) · 📊 [Dashboard](https://cli-market-production.up.railway.app/dashboard)
98
+
99
+ #### 🚀 Quick start
100
+
101
+ ```bash
102
+ pip install cli-market-world
103
+ market hello # post-install: stats + next steps (production API by default)
104
+
105
+ # Local server only: export MARKET_API_URL=http://127.0.0.1:8765
106
+ market login
107
+ market search "leche" --country PE
108
+ market compare "aceite de girasol 900ml" --country AR
109
+ market basket "arroz:1 aceite:1 leche:1" --country AR
110
+ market checkout --payment yape
111
+ market ask "buy rice at the best price"
112
+ market indicators --country PE
113
+ market enrichment --refresh -c PE
114
+ ```
115
+
116
+ #### 💵 Pricing (simplified — focus on 1 primary ICP: AI Agent Builders)
117
+
118
+ | Plan | Free | Pro | Enterprise |
119
+ |------|------|-----|------------|
120
+ | **Price** | $0 | $39/mo | Custom |
121
+ | **Requests/day** | 1,000 | 10,000 | Unlimited (negotiated) |
122
+ | **Requests/min** | 60 | 300 | Unlimited |
123
+ | **API keys** | 1 | 10 | Unlimited |
124
+ | **Intel agent** | — | Unlimited | Unlimited + white-label |
125
+ | **Price alerts** | — | ✅ Up to 10 (email) | Unlimited (email + webhook) |
126
+ | **Price history** | 7 days | 12 months | Full dataset |
127
+ | **Export** | — | CSV unlimited + cron | Direct S3/webhook feed |
128
+ | **Checkout** | — | ✅ PayPal / Yape / Plin | ✅ |
129
+ | **Support** | Community | Email 4h | 24/7 + written SLA |
130
+ | **Annual** | — | $390/yr | — |
131
+
132
+ ---
133
+
134
+ ## 📖 Learn more
135
+
136
+ - **[Use Cases](docs/use-cases.md)** — AI agent builders, data scientists, retailers. Who is this for?
137
+ - **[Terminal Demo](docs/demo-walkthrough.md)** — 8-command walkthrough: search → compare → basket → checkout.
138
+
139
+ ---
140
+
141
+ ## 🏗️ Ecosystem architecture
142
+
143
+ ![Ecosystem Pipeline](docs/assets/ecosystem-pipeline.svg)
144
+
145
+ CLI Market is composed of 4 specialized repositories, each with a single responsibility:
146
+
147
+ ```
148
+ cli-market-backend Data ingestion — VTEX scrapers, FastAPI server, 66 retailers, 45k prices
149
+ |
150
+ v raw snapshots
151
+ cli-market-index Semantic Refinery — entity resolution, Golden Records (prod_ IDs)
152
+ |
153
+ v canonical identities
154
+ cli-market-core Intelligence — indicators, stats, billing, connectors, 43 MCP tools
155
+ |
156
+ v structured intelligence
157
+ cli-market-world Exposure — landing, docs, MCP registry, deployment configs (THIS REPO)
158
+ ```
159
+
160
+ | Repo | Visibility | Role |
161
+ |---|---|---|
162
+ | `cli-market-backend` | Private | Scrapers + FastAPI API |
163
+ | `cli-market-index` | Private | Entity resolution engine |
164
+ | `cli-market-core` | Public | Intelligence + MCP tools |
165
+ | `cli-market-world` | Private | Landing + docs (this repo) |
166
+ | `cli-market-content` | Private | GTM + content calendar |
167
+
168
+ ---
169
+
170
+ ## 📊 Dashboard auditability
171
+
172
+ Every price in CLI Market is traceable and verifiable. The [live dashboard](https://cli-market-production.up.railway.app/dashboard) exposes:
173
+
174
+ - **Cobertura 7 días** — `coverage_7d_pct` per retailer: what % of each store's catalog refreshed in the last week
175
+ - **Normalización por kg/L** — unit price visible next to shelf price (e.g. `PEN 4.20/kg`), with counter of non-parseable names
176
+ - **Confianza por snapshot** — `ok` vs `suspect` distribution from scrape-quality heuristics
177
+ - **Percentiles P25/P50/P75** — median replaces mean in category comparisons; eliminates outlier distortion (e.g. ARS 230K in departamentales)
178
+ - **Trazabilidad de outliers** — group size, band (`median ± k·IQR`), acceptable bounds, scraper health state, capture timestamp
179
+ - **Foso de datos** — `inventory_daily[]` time series + growth stats (total snapshots, daily avg, days tracked)
180
+
181
+ All six capabilities are backed by the same 46,000+, refreshed every 4 hours by the collector daemon.
182
+
183
+ ---
184
+
185
+ ## 🔧 43 MCP tools · 34 indicators
186
+
187
+ `market_login` `market_lines` `market_search` `market_compare` `market_add` `market_cart` `market_cart_update` `market_cart_remove` `market_checkout` `market_orders` `market_reorder` `market_ask` `market_basket` `market_inflation` `market_indicators` `market_scores` `market_intel_refresh` `market_enrichment` `market_enrichment_subcategories` `market_enrichment_refresh` `market_analytics_indicators` `market_categories` `market_barcode` `market_enrich` `market_stores` `market_countries` `market_ticket` `market_voice` `market_price_history` `market_stats` `market_alerts` `market_whoami` `market_preferences` `market_subscription` `market_export` `market_trending` `market_scan` `market_stock` `market_notify` `market_brands` `market_favorites` `market_exchange` `market_delivery`
188
+
189
+
190
+ ---
191
+
192
+ **SINAPSIS INNOVADORA S.A.C.** — RUC 20613045563 — Lima, Peru
193
+ MIT License · [cli-market.dev](https://cli-market.dev)
@@ -0,0 +1,199 @@
1
+ """Account summary for customer dashboard (CLI + landing + API)."""
2
+
3
+ from __future__ import annotations
4
+
5
+ import time
6
+ from typing import Any
7
+
8
+ from market_core import (
9
+ TIERS,
10
+ db_find_subscription_request,
11
+ db_get_subscription,
12
+ db_get_user_email,
13
+ db_list_api_keys,
14
+ get_db,
15
+ )
16
+
17
+
18
+ def _rate_count(db, key: str, window_start: float) -> int:
19
+ row = db.execute(
20
+ "SELECT SUM(counter) as n FROM rate_limits WHERE key=? AND window_start >= ?",
21
+ (key, window_start),
22
+ ).fetchone()
23
+ return int(row["n"] or 0)
24
+
25
+
26
+ def _daily_window_start() -> float:
27
+ now = time.time()
28
+ return time.mktime(time.strptime(time.strftime("%Y-%m-%d", time.gmtime(now)), "%Y-%m-%d"))
29
+
30
+
31
+ def upgrade_next_step(tier: str, *, lang: str = "es") -> dict[str, Any]:
32
+ tier_l = (tier or "free").lower()
33
+ es = lang == "es"
34
+ steps = {
35
+ "free": {
36
+ "next_tier": "starter",
37
+ "title_es": "Pro — alertas, checkout y full MCP (foco principal para Agent Builders)",
38
+ "title_en": "Pro — alerts, checkout and full MCP (primary for AI Agent Builders)",
39
+ "cli_es": "market register → Pro en cli-market.dev/#pro-checkout",
40
+ "cli_en": "market register → Pro at cli-market.dev/#pro-checkout",
41
+ "url": "https://cli-market.dev/#pro-checkout",
42
+ "cta_es": "Activar Pro (PayPal)",
43
+ "cta_en": "Activate Pro (PayPal)",
44
+ },
45
+ "starter": {
46
+ "next_tier": "pro",
47
+ "title_es": "Pro — checkout y 10k req/día",
48
+ "title_en": "Pro — checkout and 10k req/day",
49
+ "cli_es": "market upgrade",
50
+ "cli_en": "market upgrade",
51
+ "url": "https://cli-market.dev/#pro-checkout",
52
+ "cta_es": "Activar Pro (PayPal)",
53
+ "cta_en": "Activate Pro (PayPal)",
54
+ },
55
+ "pro": {
56
+ "next_tier": "builder",
57
+ "title_es": "Builder — Intelligence API completa",
58
+ "title_en": "Builder — full Intelligence API",
59
+ "cli_es": "cli-market.dev/#pricing-build",
60
+ "cli_en": "cli-market.dev/#pricing-build",
61
+ "url": "https://cli-market.dev/#pricing-build",
62
+ "cta_es": "Contactar ventas",
63
+ "cta_en": "Contact sales",
64
+ },
65
+ }
66
+ if tier_l in ("builder", "enterprise"):
67
+ return {
68
+ "next_tier": None,
69
+ "title": "Plan máximo" if es else "Top tier",
70
+ "cli": "market doctor",
71
+ "url": None,
72
+ "cta": None,
73
+ }
74
+ step = steps.get(tier_l, steps["free"])
75
+ return {
76
+ "next_tier": step["next_tier"],
77
+ "title": step["title_es"] if es else step["title_en"],
78
+ "cli": step["cli_es"] if es else step["cli_en"],
79
+ "url": step["url"],
80
+ "cta": step["cta_es"] if es else step["cta_en"],
81
+ }
82
+
83
+
84
+ def _is_auto_activate_link(payment_link: str) -> bool:
85
+ link = (payment_link or "").lower()
86
+ return "billing/subscriptions" in link or "/subscriptions?" in link
87
+
88
+
89
+ def _billing_status(username: str, tier: str, *, lang: str = "es") -> dict[str, Any]:
90
+ es = lang == "es"
91
+ if tier in ("pro", "builder", "enterprise"):
92
+ return {
93
+ "state": "active",
94
+ "activation": None,
95
+ "request_id": None,
96
+ "message": None,
97
+ }
98
+
99
+ email = db_get_user_email(username) or ""
100
+ pending = db_find_subscription_request(email=email) if email else None
101
+ if not pending or pending.get("status") != "pending":
102
+ return {"state": "none", "activation": None, "request_id": None, "message": None}
103
+
104
+ req_id = pending.get("id") or ""
105
+ is_starter = req_id.startswith("STR-")
106
+ auto = _is_auto_activate_link(pending.get("payment_link") or "")
107
+ if auto:
108
+ if is_starter:
109
+ return {
110
+ "state": "starter_pending_auto",
111
+ "activation": "auto",
112
+ "request_id": req_id,
113
+ "approve_url": pending.get("payment_link"),
114
+ "message": (
115
+ "Pro pendiente: confirme en PayPal — activación en segundos."
116
+ if es
117
+ else "Pro pending: confirm on PayPal — activates in seconds."
118
+ ),
119
+ }
120
+ return {
121
+ "state": "pro_pending_auto",
122
+ "activation": "auto",
123
+ "request_id": req_id,
124
+ "approve_url": pending.get("payment_link"),
125
+ "message": (
126
+ "Pro pendiente: confirme en PayPal — activación en segundos."
127
+ if es
128
+ else "Pro pending: confirm on PayPal — activates in seconds."
129
+ ),
130
+ }
131
+ if is_starter:
132
+ return {
133
+ "state": "starter_pending_manual",
134
+ "activation": "manual",
135
+ "request_id": pending.get("id"),
136
+ "approve_url": pending.get("payment_link"),
137
+ "message": (
138
+ "Pro pendiente: complete el checkout en la landing (enlace por email)."
139
+ if es
140
+ else "Pro pending: complete checkout on the landing (link emailed)."
141
+ ),
142
+ }
143
+ return {
144
+ "state": "pro_pending_manual",
145
+ "activation": "manual",
146
+ "request_id": pending.get("id"),
147
+ "approve_url": pending.get("payment_link"),
148
+ "message": (
149
+ "Pro pendiente: activación manual ≤24 h hábiles tras confirmar pago."
150
+ if es
151
+ else "Pro pending: manual activation within 24 business hours after payment."
152
+ ),
153
+ }
154
+
155
+
156
+ def build_account_summary(username: str, *, lang: str = "es") -> dict[str, Any]:
157
+ sub = db_get_subscription(username)
158
+ tier = sub.get("tier", "free")
159
+ tier_cfg = TIERS.get(tier, TIERS["free"])
160
+ keys = db_list_api_keys(username)
161
+ keys_limit = tier_cfg.get("api_keys", 1)
162
+
163
+ now = time.time()
164
+ today_start = _daily_window_start()
165
+ db = get_db()
166
+ daily_used = _rate_count(db, f"{username}:daily", today_start)
167
+ minute_used = _rate_count(db, f"{username}:min", now - 60)
168
+ db.close()
169
+
170
+ day_limit = sub.get("req_limit_day", tier_cfg["req_day"])
171
+ min_limit = sub.get("req_limit_min", tier_cfg["req_min"])
172
+
173
+ def pct(used: int, limit: int) -> float | None:
174
+ if limit is None or limit < 0:
175
+ return None
176
+ return round(min(used / limit, 1.0) * 100, 1) if limit else 0.0
177
+
178
+ return {
179
+ "username": username,
180
+ "tier": tier,
181
+ "limits": {
182
+ "req_day": day_limit if day_limit != -1 else "unlimited",
183
+ "req_min": min_limit if min_limit != -1 else "unlimited",
184
+ "api_keys": keys_limit if keys_limit != -1 else "unlimited",
185
+ "checkout": bool(tier_cfg.get("checkout")),
186
+ "alerts": tier_cfg.get("alerts", 0),
187
+ "export": bool(tier_cfg.get("export")),
188
+ "history_days": tier_cfg.get("history_days", 7),
189
+ },
190
+ "usage": {
191
+ "requests_today": daily_used,
192
+ "requests_last_minute": minute_used,
193
+ "api_keys_used": len(keys),
194
+ "daily_pct": pct(daily_used, day_limit if day_limit != -1 else 0),
195
+ "minute_pct": pct(minute_used, min_limit if min_limit != -1 else 0),
196
+ },
197
+ "upgrade": upgrade_next_step(tier, lang=lang),
198
+ "billing": _billing_status(username, tier, lang=lang),
199
+ }