@optima-chat/bi-cli 0.3.4 → 0.3.5
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.
- package/dist/commands/analytics.d.ts.map +1 -1
- package/dist/commands/analytics.js +89 -14
- package/dist/commands/analytics.js.map +1 -1
- package/dist/commands/auth.d.ts.map +1 -1
- package/dist/commands/auth.js +14 -6
- package/dist/commands/auth.js.map +1 -1
- package/dist/commands/product.d.ts.map +1 -1
- package/dist/commands/product.js +77 -13
- package/dist/commands/product.js.map +1 -1
- package/dist/commands/sales.d.ts.map +1 -1
- package/dist/commands/sales.js +24 -4
- package/dist/commands/sales.js.map +1 -1
- package/dist/commands/traffic.d.ts.map +1 -1
- package/dist/commands/traffic.js +110 -22
- package/dist/commands/traffic.js.map +1 -1
- package/dist/commands/trends.d.ts.map +1 -1
- package/dist/commands/trends.js +80 -13
- package/dist/commands/trends.js.map +1 -1
- package/dist/index.js +19 -9
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
- package/src/commands/analytics.ts +98 -17
- package/src/commands/auth.ts +18 -6
- package/src/commands/product.ts +87 -13
- package/src/commands/sales.ts +28 -4
- package/src/commands/traffic.ts +122 -22
- package/src/commands/trends.ts +90 -13
- package/src/index.ts +21 -9
package/src/commands/auth.ts
CHANGED
|
@@ -38,13 +38,25 @@ interface UserInfo {
|
|
|
38
38
|
}
|
|
39
39
|
|
|
40
40
|
export function createAuthCommand(): Command {
|
|
41
|
-
const auth = new Command('auth').description(
|
|
41
|
+
const auth = new Command('auth').description(
|
|
42
|
+
`Authentication commands.
|
|
43
|
+
|
|
44
|
+
You must login before using other commands. Tokens are saved to ~/.optima/token.json.`
|
|
45
|
+
);
|
|
42
46
|
|
|
43
47
|
// auth login
|
|
44
48
|
auth
|
|
45
49
|
.command('login')
|
|
46
|
-
.description(
|
|
47
|
-
|
|
50
|
+
.description(
|
|
51
|
+
`Login using OAuth 2.0 Device Flow.
|
|
52
|
+
|
|
53
|
+
Opens browser automatically for authorization. Token is saved after successful auth.
|
|
54
|
+
|
|
55
|
+
Examples:
|
|
56
|
+
bi-cli auth login # Login to production (default)
|
|
57
|
+
bi-cli auth login --env stage # Login to staging environment`
|
|
58
|
+
)
|
|
59
|
+
.option('--env <environment>', 'Environment: production | stage | development', 'production')
|
|
48
60
|
.action(async (options) => {
|
|
49
61
|
const env = options.env as Environment;
|
|
50
62
|
|
|
@@ -206,7 +218,7 @@ export function createAuthCommand(): Command {
|
|
|
206
218
|
// auth logout
|
|
207
219
|
auth
|
|
208
220
|
.command('logout')
|
|
209
|
-
.description('Logout and delete ~/.optima/token.json')
|
|
221
|
+
.description('Logout and delete local token file (~/.optima/token.json)')
|
|
210
222
|
.action(() => {
|
|
211
223
|
clearAuth();
|
|
212
224
|
success('Logged out successfully');
|
|
@@ -216,7 +228,7 @@ export function createAuthCommand(): Command {
|
|
|
216
228
|
// auth whoami
|
|
217
229
|
auth
|
|
218
230
|
.command('whoami')
|
|
219
|
-
.description('Show current user
|
|
231
|
+
.description('Show current user info (email, role, merchant ID)')
|
|
220
232
|
.action(async () => {
|
|
221
233
|
const cfg = getConfig();
|
|
222
234
|
|
|
@@ -260,7 +272,7 @@ export function createAuthCommand(): Command {
|
|
|
260
272
|
// auth status
|
|
261
273
|
auth
|
|
262
274
|
.command('status')
|
|
263
|
-
.description('Show authentication status')
|
|
275
|
+
.description('Show authentication status (environment, login state, config path)')
|
|
264
276
|
.action(() => {
|
|
265
277
|
const cfg = getConfig();
|
|
266
278
|
|
package/src/commands/product.ts
CHANGED
|
@@ -88,15 +88,36 @@ interface PerformanceResponse {
|
|
|
88
88
|
}
|
|
89
89
|
|
|
90
90
|
export function createProductCommand(): Command {
|
|
91
|
-
const product = new Command('product').description(
|
|
91
|
+
const product = new Command('product').description(
|
|
92
|
+
`Product analytics.
|
|
93
|
+
|
|
94
|
+
Analyze product performance, price distribution, ABC classification.`
|
|
95
|
+
);
|
|
92
96
|
|
|
93
97
|
// product best-sellers
|
|
94
98
|
product
|
|
95
99
|
.command('best-sellers')
|
|
96
|
-
.description(
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
|
|
100
|
+
.description(
|
|
101
|
+
`Get best selling products ranking.
|
|
102
|
+
|
|
103
|
+
Returns products sorted by revenue/quantity/orders with rank, revenue, units sold, revenue share.
|
|
104
|
+
|
|
105
|
+
Returns JSON:
|
|
106
|
+
{
|
|
107
|
+
"products": [
|
|
108
|
+
{ "rank": 1, "title": "Product Name", "revenue": 1000, "units_sold": 50, "orders": 30, "revenue_share": 15.5 }
|
|
109
|
+
],
|
|
110
|
+
"total_revenue": number
|
|
111
|
+
}
|
|
112
|
+
|
|
113
|
+
Examples:
|
|
114
|
+
bi-cli product best-sellers # Top 10 by revenue
|
|
115
|
+
bi-cli product best-sellers --limit 5 # Top 5
|
|
116
|
+
bi-cli product best-sellers --sort quantity # Sort by quantity`
|
|
117
|
+
)
|
|
118
|
+
.option('--limit <number>', 'Number of products to return (default: 10)', '10')
|
|
119
|
+
.option('--sort <field>', 'Sort by: revenue | quantity | orders', 'revenue')
|
|
120
|
+
.option('--pretty', 'Output as table')
|
|
100
121
|
.action(async (options) => {
|
|
101
122
|
const cfg = getConfig();
|
|
102
123
|
if (!cfg.accessToken) {
|
|
@@ -147,8 +168,23 @@ export function createProductCommand(): Command {
|
|
|
147
168
|
// product abc-analysis
|
|
148
169
|
product
|
|
149
170
|
.command('abc-analysis')
|
|
150
|
-
.description(
|
|
151
|
-
|
|
171
|
+
.description(
|
|
172
|
+
`ABC inventory analysis (Pareto analysis).
|
|
173
|
+
|
|
174
|
+
Classifies products by revenue contribution:
|
|
175
|
+
- A: High-value products contributing 70% of revenue (typically ~20% of products)
|
|
176
|
+
- B: Medium-value products contributing 20% of revenue
|
|
177
|
+
- C: Low-value products contributing 10% of revenue
|
|
178
|
+
|
|
179
|
+
Use case: Identify core products, optimize inventory and purchasing strategy.
|
|
180
|
+
|
|
181
|
+
Returns JSON:
|
|
182
|
+
{
|
|
183
|
+
"summary": { "A": {...}, "B": {...}, "C": {...} },
|
|
184
|
+
"products": [ { "title": "Product Name", "category": "A", "revenue": number, ... } ]
|
|
185
|
+
}`
|
|
186
|
+
)
|
|
187
|
+
.option('--pretty', 'Output as table')
|
|
152
188
|
.action(async (options) => {
|
|
153
189
|
const cfg = getConfig();
|
|
154
190
|
if (!cfg.accessToken) {
|
|
@@ -205,8 +241,20 @@ export function createProductCommand(): Command {
|
|
|
205
241
|
// product price-analysis
|
|
206
242
|
product
|
|
207
243
|
.command('price-analysis')
|
|
208
|
-
.description(
|
|
209
|
-
|
|
244
|
+
.description(
|
|
245
|
+
`Price range analysis.
|
|
246
|
+
|
|
247
|
+
Analyze product count, revenue, and sales by price ranges.
|
|
248
|
+
|
|
249
|
+
Returns JSON:
|
|
250
|
+
{
|
|
251
|
+
"price_ranges": [
|
|
252
|
+
{ "range": "¥0-50", "products": 10, "revenue": 5000, "units": 200, "revenue_share": 15.5 }
|
|
253
|
+
],
|
|
254
|
+
"totals": { "revenue": number, "units": number }
|
|
255
|
+
}`
|
|
256
|
+
)
|
|
257
|
+
.option('--pretty', 'Output as table')
|
|
210
258
|
.action(async (options) => {
|
|
211
259
|
const cfg = getConfig();
|
|
212
260
|
if (!cfg.accessToken) {
|
|
@@ -256,10 +304,36 @@ export function createProductCommand(): Command {
|
|
|
256
304
|
// product performance
|
|
257
305
|
product
|
|
258
306
|
.command('performance')
|
|
259
|
-
.description(
|
|
260
|
-
|
|
261
|
-
|
|
262
|
-
|
|
307
|
+
.description(
|
|
308
|
+
`Product performance metrics.
|
|
309
|
+
|
|
310
|
+
Get sales, inventory, and margin metrics for each product.
|
|
311
|
+
|
|
312
|
+
Returns JSON:
|
|
313
|
+
{
|
|
314
|
+
"products": [
|
|
315
|
+
{
|
|
316
|
+
"title": "Product Name",
|
|
317
|
+
"price": 99.00, // Selling price
|
|
318
|
+
"inventory": 50, // Current stock
|
|
319
|
+
"sales": { "units": 100, "revenue": 9900, "orders": 80 },
|
|
320
|
+
"metrics": {
|
|
321
|
+
"margin_percent": 30.5, // Profit margin (%)
|
|
322
|
+
"days_of_stock": 15, // Estimated days of stock
|
|
323
|
+
"velocity": 6.7 // Daily sales rate
|
|
324
|
+
}
|
|
325
|
+
}
|
|
326
|
+
]
|
|
327
|
+
}
|
|
328
|
+
|
|
329
|
+
Examples:
|
|
330
|
+
bi-cli product performance # Last 30 days, top 20 products
|
|
331
|
+
bi-cli product performance --days 7 # Last 7 days
|
|
332
|
+
bi-cli product performance --limit 50 # Top 50 products`
|
|
333
|
+
)
|
|
334
|
+
.option('--days <number>', 'Number of days (default: 30)', '30')
|
|
335
|
+
.option('--limit <number>', 'Number of products (default: 20)', '20')
|
|
336
|
+
.option('--pretty', 'Output as table')
|
|
263
337
|
.action(async (options) => {
|
|
264
338
|
const cfg = getConfig();
|
|
265
339
|
if (!cfg.accessToken) {
|
package/src/commands/sales.ts
CHANGED
|
@@ -33,14 +33,38 @@ interface SalesResponse {
|
|
|
33
33
|
}
|
|
34
34
|
|
|
35
35
|
export function createSalesCommand(): Command {
|
|
36
|
-
const sales = new Command('sales').description(
|
|
36
|
+
const sales = new Command('sales').description(
|
|
37
|
+
`Sales analytics.
|
|
38
|
+
|
|
39
|
+
Get sales summary and daily breakdown data.`
|
|
40
|
+
);
|
|
37
41
|
|
|
38
42
|
// sales get
|
|
39
43
|
sales
|
|
40
44
|
.command('get')
|
|
41
|
-
.description(
|
|
42
|
-
|
|
43
|
-
|
|
45
|
+
.description(
|
|
46
|
+
`Get sales summary and daily breakdown.
|
|
47
|
+
|
|
48
|
+
Returns JSON:
|
|
49
|
+
{
|
|
50
|
+
"summary": {
|
|
51
|
+
"total_revenue": number, // Total revenue (CNY)
|
|
52
|
+
"total_orders": number, // Total order count
|
|
53
|
+
"avg_order_value": number, // Average order value (CNY)
|
|
54
|
+
"unique_customers": number // Unique customer count
|
|
55
|
+
},
|
|
56
|
+
"daily": [ // Daily breakdown array
|
|
57
|
+
{ "date": "YYYY-MM-DD", "total_revenue": number, "order_count": number, ... }
|
|
58
|
+
]
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
Examples:
|
|
62
|
+
bi-cli sales get # Get last 7 days
|
|
63
|
+
bi-cli sales get --days 30 # Get last 30 days
|
|
64
|
+
bi-cli sales get --days 7 --pretty # Output as table`
|
|
65
|
+
)
|
|
66
|
+
.option('--days <number>', 'Number of days from today (range: 1-365)', '7')
|
|
67
|
+
.option('--pretty', 'Output as table (default: JSON)')
|
|
44
68
|
.action(async (options) => {
|
|
45
69
|
const cfg = getConfig();
|
|
46
70
|
|
package/src/commands/traffic.ts
CHANGED
|
@@ -69,15 +69,44 @@ function formatDuration(seconds: number): string {
|
|
|
69
69
|
}
|
|
70
70
|
|
|
71
71
|
export function createTrafficCommand(): Command {
|
|
72
|
-
const traffic = new Command('traffic').description(
|
|
72
|
+
const traffic = new Command('traffic').description(
|
|
73
|
+
`Traffic analytics.
|
|
74
|
+
|
|
75
|
+
Analyze website visits, traffic sources, conversion funnels, search keywords.`
|
|
76
|
+
);
|
|
73
77
|
|
|
74
78
|
// traffic overview
|
|
75
79
|
traffic
|
|
76
80
|
.command('overview')
|
|
77
|
-
.description(
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
+
.description(
|
|
82
|
+
`Traffic overview.
|
|
83
|
+
|
|
84
|
+
Get page views, unique visitors, sessions, and comparison with previous period.
|
|
85
|
+
|
|
86
|
+
Returns JSON:
|
|
87
|
+
{
|
|
88
|
+
"period": { "start": "2024-01-01", "end": "2024-01-30", "days": 30 },
|
|
89
|
+
"summary": {
|
|
90
|
+
"page_views": 10000,
|
|
91
|
+
"unique_visitors": 3000,
|
|
92
|
+
"sessions": 5000,
|
|
93
|
+
"avg_session_duration": 180, // seconds
|
|
94
|
+
"bounce_rate": 0.35 // 35%
|
|
95
|
+
},
|
|
96
|
+
"comparison": {
|
|
97
|
+
"page_views_change": 0.15, // +15%
|
|
98
|
+
"unique_visitors_change": 0.10
|
|
99
|
+
}
|
|
100
|
+
}
|
|
101
|
+
|
|
102
|
+
Examples:
|
|
103
|
+
bi-cli traffic overview # Last 30 days, all pages
|
|
104
|
+
bi-cli traffic overview --days 7 # Last 7 days
|
|
105
|
+
bi-cli traffic overview --product <uuid> # Filter by product`
|
|
106
|
+
)
|
|
107
|
+
.option('--days <number>', 'Number of days (range: 1-365, default: 30)', '30')
|
|
108
|
+
.option('--product <id>', 'Filter by product ID (UUID format)')
|
|
109
|
+
.option('--pretty', 'Output as table (default: JSON)')
|
|
81
110
|
.action(async (options) => {
|
|
82
111
|
const cfg = getConfig();
|
|
83
112
|
|
|
@@ -129,10 +158,29 @@ export function createTrafficCommand(): Command {
|
|
|
129
158
|
// traffic sources
|
|
130
159
|
traffic
|
|
131
160
|
.command('sources')
|
|
132
|
-
.description(
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
161
|
+
.description(
|
|
162
|
+
`Traffic source analysis.
|
|
163
|
+
|
|
164
|
+
Analyze visitor sources (Google, WeChat, direct, etc.).
|
|
165
|
+
|
|
166
|
+
Returns JSON:
|
|
167
|
+
{
|
|
168
|
+
"sources": [
|
|
169
|
+
{
|
|
170
|
+
"source": "google",
|
|
171
|
+
"medium": "organic",
|
|
172
|
+
"visitors": 1000,
|
|
173
|
+
"page_views": 3000,
|
|
174
|
+
"percentage": 0.35 // 35%
|
|
175
|
+
}
|
|
176
|
+
]
|
|
177
|
+
}
|
|
178
|
+
|
|
179
|
+
Use case: Evaluate channel effectiveness, optimize marketing spend.`
|
|
180
|
+
)
|
|
181
|
+
.option('--days <number>', 'Number of days (default: 30)', '30')
|
|
182
|
+
.option('--limit <number>', 'Number of results (default: 10)', '10')
|
|
183
|
+
.option('--pretty', 'Output as table (default: JSON)')
|
|
136
184
|
.action(async (options) => {
|
|
137
185
|
const cfg = getConfig();
|
|
138
186
|
|
|
@@ -179,10 +227,28 @@ export function createTrafficCommand(): Command {
|
|
|
179
227
|
// traffic funnel
|
|
180
228
|
traffic
|
|
181
229
|
.command('funnel')
|
|
182
|
-
.description(
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
230
|
+
.description(
|
|
231
|
+
`Conversion funnel analysis.
|
|
232
|
+
|
|
233
|
+
Analyze user journey from visit to purchase:
|
|
234
|
+
Visit → View Product → Add to Cart → Checkout → Purchase
|
|
235
|
+
|
|
236
|
+
Returns JSON:
|
|
237
|
+
{
|
|
238
|
+
"funnel": [
|
|
239
|
+
{ "step": "page_view", "count": 10000, "rate": 1.0, "conversion": 1.0 },
|
|
240
|
+
{ "step": "product_view", "count": 5000, "rate": 0.5, "conversion": 0.5 },
|
|
241
|
+
{ "step": "add_to_cart", "count": 1000, "rate": 0.1, "conversion": 0.2 },
|
|
242
|
+
{ "step": "checkout", "count": 500, "rate": 0.05, "conversion": 0.5 },
|
|
243
|
+
{ "step": "purchase", "count": 300, "rate": 0.03, "conversion": 0.6 }
|
|
244
|
+
]
|
|
245
|
+
}
|
|
246
|
+
|
|
247
|
+
Note: rate = ratio from start, conversion = conversion from previous step.`
|
|
248
|
+
)
|
|
249
|
+
.option('--days <number>', 'Number of days (default: 30)', '30')
|
|
250
|
+
.option('--product <id>', 'Filter by product ID (UUID format)')
|
|
251
|
+
.option('--pretty', 'Output as table (default: JSON)')
|
|
186
252
|
.action(async (options) => {
|
|
187
253
|
const cfg = getConfig();
|
|
188
254
|
|
|
@@ -227,11 +293,27 @@ export function createTrafficCommand(): Command {
|
|
|
227
293
|
// traffic search
|
|
228
294
|
traffic
|
|
229
295
|
.command('search')
|
|
230
|
-
.description(
|
|
231
|
-
|
|
232
|
-
|
|
233
|
-
|
|
234
|
-
|
|
296
|
+
.description(
|
|
297
|
+
`Site search analytics.
|
|
298
|
+
|
|
299
|
+
Analyze search keywords, result counts, and click-through rates.
|
|
300
|
+
|
|
301
|
+
Returns JSON:
|
|
302
|
+
{
|
|
303
|
+
"searches": [
|
|
304
|
+
{ "query": "dress", "count": 500, "avg_results": 25, "click_rate": 0.65 }
|
|
305
|
+
],
|
|
306
|
+
"zero_results": [
|
|
307
|
+
{ "query": "nonexistent product", "count": 10 }
|
|
308
|
+
]
|
|
309
|
+
}
|
|
310
|
+
|
|
311
|
+
Use case: Optimize product titles, add missing products, improve search.`
|
|
312
|
+
)
|
|
313
|
+
.option('--days <number>', 'Number of days (default: 30)', '30')
|
|
314
|
+
.option('--limit <number>', 'Number of results (default: 20)', '20')
|
|
315
|
+
.option('--zero-results', 'Show only zero-result queries')
|
|
316
|
+
.option('--pretty', 'Output as table (default: JSON)')
|
|
235
317
|
.action(async (options) => {
|
|
236
318
|
const cfg = getConfig();
|
|
237
319
|
|
|
@@ -288,10 +370,28 @@ export function createTrafficCommand(): Command {
|
|
|
288
370
|
// traffic pages
|
|
289
371
|
traffic
|
|
290
372
|
.command('pages')
|
|
291
|
-
.description(
|
|
292
|
-
|
|
293
|
-
|
|
294
|
-
|
|
373
|
+
.description(
|
|
374
|
+
`Top pages analysis.
|
|
375
|
+
|
|
376
|
+
View most popular pages sorted by page views.
|
|
377
|
+
|
|
378
|
+
Returns JSON:
|
|
379
|
+
{
|
|
380
|
+
"pages": [
|
|
381
|
+
{
|
|
382
|
+
"path": "/products/xxx",
|
|
383
|
+
"page_views": 5000,
|
|
384
|
+
"unique_visitors": 2000,
|
|
385
|
+
"sessions": 3000
|
|
386
|
+
}
|
|
387
|
+
]
|
|
388
|
+
}
|
|
389
|
+
|
|
390
|
+
Use case: Understand browsing patterns, optimize popular page experience.`
|
|
391
|
+
)
|
|
392
|
+
.option('--days <number>', 'Number of days (default: 30)', '30')
|
|
393
|
+
.option('--limit <number>', 'Number of results (default: 20)', '20')
|
|
394
|
+
.option('--pretty', 'Output as table (default: JSON)')
|
|
295
395
|
.action(async (options) => {
|
|
296
396
|
const cfg = getConfig();
|
|
297
397
|
|
package/src/commands/trends.ts
CHANGED
|
@@ -78,15 +78,39 @@ interface ForecastResponse {
|
|
|
78
78
|
}
|
|
79
79
|
|
|
80
80
|
export function createTrendsCommand(): Command {
|
|
81
|
-
const trends = new Command('trends').description(
|
|
81
|
+
const trends = new Command('trends').description(
|
|
82
|
+
`Trend analytics.
|
|
83
|
+
|
|
84
|
+
Analyze revenue trends, order heatmaps, seasonality, and forecasts.`
|
|
85
|
+
);
|
|
82
86
|
|
|
83
87
|
// trends revenue
|
|
84
88
|
trends
|
|
85
89
|
.command('revenue')
|
|
86
|
-
.description(
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
+
.description(
|
|
91
|
+
`Revenue trend analysis.
|
|
92
|
+
|
|
93
|
+
View revenue over time with hourly/daily/weekly aggregation and 7-day moving average.
|
|
94
|
+
|
|
95
|
+
Returns JSON:
|
|
96
|
+
{
|
|
97
|
+
"statistics": {
|
|
98
|
+
"total_revenue": number,
|
|
99
|
+
"avg_revenue": number,
|
|
100
|
+
"trend_direction": "up" | "down" | "stable"
|
|
101
|
+
},
|
|
102
|
+
"trend": [
|
|
103
|
+
{ "period": "2024-01-01", "revenue": 1000, "orders": 50, "moving_avg_7": 950 }
|
|
104
|
+
]
|
|
105
|
+
}
|
|
106
|
+
|
|
107
|
+
Examples:
|
|
108
|
+
bi-cli trends revenue # Last 30 days, daily
|
|
109
|
+
bi-cli trends revenue --days 7 --granularity hourly # Last 7 days, hourly`
|
|
110
|
+
)
|
|
111
|
+
.option('--days <number>', 'Number of days (default: 30)', '30')
|
|
112
|
+
.option('--granularity <type>', 'Time granularity: hourly | daily | weekly', 'daily')
|
|
113
|
+
.option('--pretty', 'Output as table')
|
|
90
114
|
.action(async (options) => {
|
|
91
115
|
const cfg = getConfig();
|
|
92
116
|
if (!cfg.accessToken) {
|
|
@@ -152,9 +176,25 @@ export function createTrendsCommand(): Command {
|
|
|
152
176
|
// trends heatmap
|
|
153
177
|
trends
|
|
154
178
|
.command('heatmap')
|
|
155
|
-
.description(
|
|
156
|
-
|
|
157
|
-
|
|
179
|
+
.description(
|
|
180
|
+
`Orders heatmap by day and hour.
|
|
181
|
+
|
|
182
|
+
Analyze order distribution by day of week and hour to find peak times.
|
|
183
|
+
|
|
184
|
+
Returns JSON:
|
|
185
|
+
{
|
|
186
|
+
"heatmap": [
|
|
187
|
+
{ "day": "Monday", "hours": [ { "hour": 10, "orders": 15, "revenue": 500 }, ... ] }
|
|
188
|
+
],
|
|
189
|
+
"peak_times": [
|
|
190
|
+
{ "day": "Saturday", "hour": "14:00-15:00", "orders": 25 }
|
|
191
|
+
]
|
|
192
|
+
}
|
|
193
|
+
|
|
194
|
+
Use case: Optimize marketing timing, schedule customer service staff.`
|
|
195
|
+
)
|
|
196
|
+
.option('--days <number>', 'Number of days (default: 30)', '30')
|
|
197
|
+
.option('--pretty', 'Output as table')
|
|
158
198
|
.action(async (options) => {
|
|
159
199
|
const cfg = getConfig();
|
|
160
200
|
if (!cfg.accessToken) {
|
|
@@ -221,8 +261,26 @@ export function createTrendsCommand(): Command {
|
|
|
221
261
|
// trends seasonality
|
|
222
262
|
trends
|
|
223
263
|
.command('seasonality')
|
|
224
|
-
.description(
|
|
225
|
-
|
|
264
|
+
.description(
|
|
265
|
+
`Monthly/seasonal pattern analysis.
|
|
266
|
+
|
|
267
|
+
Analyze sales by month to identify peak and low seasons.
|
|
268
|
+
|
|
269
|
+
Returns JSON:
|
|
270
|
+
{
|
|
271
|
+
"monthly_pattern": [
|
|
272
|
+
{ "month": 1, "month_name": "January", "revenue": 50000, "orders": 500, "index": 120 }
|
|
273
|
+
],
|
|
274
|
+
"insights": {
|
|
275
|
+
"peak_months": ["December", "November"],
|
|
276
|
+
"low_months": ["February"],
|
|
277
|
+
"avg_monthly_revenue": 45000
|
|
278
|
+
}
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
Note: index is percentage relative to average (>100 = above average).`
|
|
282
|
+
)
|
|
283
|
+
.option('--pretty', 'Output as table')
|
|
226
284
|
.action(async (options) => {
|
|
227
285
|
const cfg = getConfig();
|
|
228
286
|
if (!cfg.accessToken) {
|
|
@@ -277,9 +335,28 @@ export function createTrendsCommand(): Command {
|
|
|
277
335
|
// trends forecast
|
|
278
336
|
trends
|
|
279
337
|
.command('forecast')
|
|
280
|
-
.description(
|
|
281
|
-
|
|
282
|
-
|
|
338
|
+
.description(
|
|
339
|
+
`Revenue forecast.
|
|
340
|
+
|
|
341
|
+
Predict future revenue based on historical data, considering trends and day-of-week patterns.
|
|
342
|
+
|
|
343
|
+
Returns JSON:
|
|
344
|
+
{
|
|
345
|
+
"trend": { "direction": "up", "daily_change": 50.5 },
|
|
346
|
+
"forecast": [
|
|
347
|
+
{ "date": "2024-01-15", "day_of_week": "Monday", "predicted_revenue": 5000, "confidence": "medium" }
|
|
348
|
+
],
|
|
349
|
+
"disclaimer": "For reference only..."
|
|
350
|
+
}
|
|
351
|
+
|
|
352
|
+
Note: Forecast based on simple linear model, for reference only.
|
|
353
|
+
|
|
354
|
+
Examples:
|
|
355
|
+
bi-cli trends forecast # Forecast next 7 days
|
|
356
|
+
bi-cli trends forecast --days 14 # Forecast next 14 days`
|
|
357
|
+
)
|
|
358
|
+
.option('--days <number>', 'Days to forecast (default: 7)', '7')
|
|
359
|
+
.option('--pretty', 'Output as table')
|
|
283
360
|
.action(async (options) => {
|
|
284
361
|
const cfg = getConfig();
|
|
285
362
|
if (!cfg.accessToken) {
|
package/src/index.ts
CHANGED
|
@@ -20,7 +20,19 @@ const program = new Command();
|
|
|
20
20
|
|
|
21
21
|
program
|
|
22
22
|
.name('bi-cli')
|
|
23
|
-
.description(
|
|
23
|
+
.description(
|
|
24
|
+
`Optima BI CLI - E-commerce business intelligence tool for LLM agents.
|
|
25
|
+
|
|
26
|
+
IMPORTANT: Run 'bi-cli auth login' first to authenticate before using other commands.
|
|
27
|
+
|
|
28
|
+
Output: All commands output JSON by default (for programmatic parsing). Use --pretty for human-readable tables.
|
|
29
|
+
|
|
30
|
+
Common use cases:
|
|
31
|
+
- Get sales data → bi-cli sales get --days 7
|
|
32
|
+
- Top selling products → bi-cli product best-sellers --limit 10
|
|
33
|
+
- Revenue trends → bi-cli trends revenue --days 30
|
|
34
|
+
- Compare periods → bi-cli analytics compare --days 7`
|
|
35
|
+
)
|
|
24
36
|
.version(pkg.version);
|
|
25
37
|
|
|
26
38
|
// Auth commands
|
|
@@ -44,33 +56,33 @@ program.addCommand(createTrafficCommand());
|
|
|
44
56
|
// Config commands (placeholder)
|
|
45
57
|
program
|
|
46
58
|
.command('config')
|
|
47
|
-
.description('
|
|
59
|
+
.description('[NOT IMPLEMENTED] Configuration management')
|
|
48
60
|
.action(() => {
|
|
49
|
-
console.log('
|
|
61
|
+
console.log('This feature is not yet implemented');
|
|
50
62
|
});
|
|
51
63
|
|
|
52
64
|
// Customer commands (placeholder)
|
|
53
65
|
program
|
|
54
66
|
.command('customer')
|
|
55
|
-
.description('Customer analytics')
|
|
67
|
+
.description('[NOT IMPLEMENTED] Customer analytics')
|
|
56
68
|
.action(() => {
|
|
57
|
-
console.log('
|
|
69
|
+
console.log('This feature is not yet implemented');
|
|
58
70
|
});
|
|
59
71
|
|
|
60
72
|
// Inventory commands (placeholder)
|
|
61
73
|
program
|
|
62
74
|
.command('inventory')
|
|
63
|
-
.description('Inventory analytics')
|
|
75
|
+
.description('[NOT IMPLEMENTED] Inventory analytics')
|
|
64
76
|
.action(() => {
|
|
65
|
-
console.log('
|
|
77
|
+
console.log('This feature is not yet implemented');
|
|
66
78
|
});
|
|
67
79
|
|
|
68
80
|
// Platform commands (admin only - placeholder)
|
|
69
81
|
program
|
|
70
82
|
.command('platform')
|
|
71
|
-
.description('Platform analytics (admin only)')
|
|
83
|
+
.description('[NOT IMPLEMENTED] Platform analytics (admin only)')
|
|
72
84
|
.action(() => {
|
|
73
|
-
console.log('
|
|
85
|
+
console.log('This feature is not yet implemented');
|
|
74
86
|
});
|
|
75
87
|
|
|
76
88
|
program.parse();
|