@restoai/resto-datacli 0.1.12 → 0.2.1
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/.agents/skills/resto-datacli/SKILL.md +21 -2
- package/README.md +44 -8
- package/dist/cli.js +2 -0
- package/dist/commands/auth.js +366 -99
- package/dist/commands/knowledge.js +32 -13
- package/dist/commands/order.js +109 -0
- package/dist/commands/public-records.js +32 -0
- package/dist/commands/query.js +22 -4
- package/dist/commands/shop.js +66 -14
- package/dist/config/profile.js +1 -0
- package/dist/knowledge/local-store.js +2 -0
- package/dist/knowledge/manifest-client.js +52 -3
- package/dist/knowledge/schema.js +2 -0
- package/dist/knowledge/search-index.js +46 -0
- package/dist/report-api/query-plan.js +20 -4
- package/dist/report-api/report-api-client.js +105 -15
- package/docs/installation.md +44 -14
- package/package.json +1 -1
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
---
|
|
2
2
|
name: resto-datacli
|
|
3
|
-
description: Use deterministic local/remote resto-datacli commands to discover reports, inspect fields, validate query plans, execute report queries, and transform saved snapshots.
|
|
3
|
+
description: Use deterministic local/remote resto-datacli commands to discover reports, inspect fields, validate query plans, execute report queries, drill into order details, and transform saved snapshots.
|
|
4
4
|
---
|
|
5
5
|
|
|
6
6
|
# resto-datacli Skill
|
|
@@ -38,13 +38,31 @@ At the start of a Resto data task or a new Agent session, check tool and knowled
|
|
|
38
38
|
## Discovery Workflow
|
|
39
39
|
|
|
40
40
|
1. Search candidate reports with `resto report search`.
|
|
41
|
-
2. Inspect promising reports with `resto report inspect` to confirm report metadata and
|
|
41
|
+
2. Inspect promising reports with `resto report inspect` to confirm report metadata, composition, row-pivot rules, and merged-head evidence.
|
|
42
42
|
3. Search fields with `resto field search` when a metric, dimension, filter, currency, or time grain is unclear.
|
|
43
43
|
4. Review reusable references with `resto playbook list` and `resto playbook inspect`. Playbooks are reference material, not automatic intent resolution.
|
|
44
44
|
5. Build an explicit JSON query plan containing `reportId`, `selectFields`, `filters`, optional `orderBy`, paging, proportions, and additional dimension strategies.
|
|
45
45
|
6. Validate before executing with `resto query validate`.
|
|
46
46
|
7. Execute only validated plans with `resto query execute`.
|
|
47
47
|
|
|
48
|
+
## Composite And Row-Pivot Reports
|
|
49
|
+
|
|
50
|
+
- When `report inspect` returns `composition`, keep `reportId` / `queryReportId` as the executable report and use `basicReportId` plus merged fields as field evidence. Do not replace the executable report id with the basic report id.
|
|
51
|
+
- Treat `metricsByDim` as an explicit dimension-to-metric allowlist. Use `metricFieldNames` for available metrics and prefer `defaultMetricFieldNames` only when they match the user's requested measure.
|
|
52
|
+
- Do not generate row-pivot plans for entries where `disableMetricsByDim=true`.
|
|
53
|
+
- Use `mergedHeads` to understand static versus dynamic sub-heads, subtotal behavior, and the dimension that generates dynamic columns. Do not invent possible dynamic values from metadata alone.
|
|
54
|
+
- Hidden fields are omitted from normal field discovery. Use `resto field list --include-hidden` or `resto field search --include-hidden` only when technical validation, required filters, or drilldown needs them. A hidden field may be valid in a query plan even though it should not appear in a customer-facing field list.
|
|
55
|
+
|
|
56
|
+
## Order Detail Drilldown
|
|
57
|
+
|
|
58
|
+
- Treat the账单明细表 page (`reportId=888002`, `basicReportId=3`) and an individual order detail as different operations.
|
|
59
|
+
- Use a normal validated query plan on `reportId=888002` to list or locate orders by date, shop, POS order id, and other fields.
|
|
60
|
+
- Once an exact POS order id is known, retrieve the rendered multi-entity detail with `resto order detail --report-id 888002 --pos-order-id <id> --business-date-start <YYYY-MM-DD> --business-date-end <YYYY-MM-DD>`.
|
|
61
|
+
- POS order drilldown requires both business-date options. The inclusive range must be at most 31 days; use the date range that was used to locate the order. The logged-in profile supplies the trusted corporation context.
|
|
62
|
+
- Use `--order-id` only for a known internal order id, and never pass both order identifiers.
|
|
63
|
+
- Do not emulate order detail by selecting many fields from report 3 or by directly calling BO/report-api. The dedicated command preserves server-side auth, report permission, shop scope, flow control, Sentinel, audit, and alerting.
|
|
64
|
+
- The detail response is dynamic JSON produced by report-api order-type templates. Cite the executable main `reportId`, returned `shopId`, order identifier, and the dedicated detail command as evidence.
|
|
65
|
+
|
|
48
66
|
## Fast Report Catalog Workflow
|
|
49
67
|
|
|
50
68
|
Use these shortcuts before slower exploratory analysis when the user asks for report counts, report names, or report identity:
|
|
@@ -71,6 +89,7 @@ Always cite the evidence used in the final answer:
|
|
|
71
89
|
- selected fields and filter fields
|
|
72
90
|
- filters and time range
|
|
73
91
|
- currency, or state that no currency field/value was present
|
|
92
|
+
- for row-pivot queries, cite the dimension and metric relationship from `metricsByDim`
|
|
74
93
|
- `resultId` from `resto query execute`
|
|
75
94
|
- for snapshot transforms, cite the source query `resultId`
|
|
76
95
|
- for `resto analysis topn`, cite the transform command and parameters: transform name, dimension, metric, limit
|
package/README.md
CHANGED
|
@@ -36,33 +36,69 @@ Customer-facing installation steps are documented in [`docs/installation.md`](do
|
|
|
36
36
|
|
|
37
37
|
## Auth
|
|
38
38
|
|
|
39
|
-
Interactive login prompts for the
|
|
39
|
+
Interactive login prompts for the CLI auth gateway URL, corporation id, auth method, and secret values. Phone dynamic codes and passwords are hidden while you paste them:
|
|
40
40
|
|
|
41
41
|
```bash
|
|
42
42
|
resto auth login --interactive
|
|
43
43
|
```
|
|
44
44
|
|
|
45
|
-
|
|
45
|
+
Phone login uses the CLI auth gateway to send a dynamic verification code, then exchanges the phone number and code for a CLI-platform token:
|
|
46
46
|
|
|
47
47
|
```bash
|
|
48
48
|
resto auth login \
|
|
49
|
-
--base-url https://
|
|
50
|
-
--
|
|
51
|
-
--corporation-id 302
|
|
49
|
+
--base-url https://cli.test.restosuite.ai \
|
|
50
|
+
--plat cli \
|
|
51
|
+
--corporation-id 302 \
|
|
52
|
+
--phone-number <phone-number> \
|
|
53
|
+
--dynamic-code <verification-code>
|
|
52
54
|
```
|
|
53
55
|
|
|
54
|
-
Password login follows the
|
|
56
|
+
Password login follows the auth gateway login step flow, encrypts the password with the gateway-compatible RSA-OAEP/SHA-256 public key, and stores the returned token in the same local auth profile:
|
|
55
57
|
|
|
56
58
|
```bash
|
|
57
59
|
resto auth login \
|
|
58
|
-
--base-url https://
|
|
60
|
+
--base-url https://cli.test.restosuite.ai \
|
|
61
|
+
--plat cli \
|
|
59
62
|
--username <account> \
|
|
60
63
|
--password <password>
|
|
61
64
|
```
|
|
62
65
|
|
|
63
|
-
`--base-url` is the
|
|
66
|
+
`--base-url` is the CLI auth gateway host used for login and token acquisition, and `--plat` defaults to `cli`. Knowledge manifest sync/check, report query execution, and shop filter lookup go through `report-cli-service`; configure `--report-cli-url` or `RESTO_REPORT_CLI_URL` when using a non-default service endpoint. `language-code` and `timezone` default to `zh_CN` and `Asia/Shanghai`. For phone login, `--phone-area-code` defaults to `+86` and `--phone-region` defaults to `CN` when omitted. If the gateway password flow requires an explicit tenant or flow step, pass `--corporation-id`, `--login-flow-code`, and optionally `--login-step-name`.
|
|
64
67
|
For normal email/password login, `--login-flow-code` is not required; it is kept only as a troubleshooting escape hatch.
|
|
65
68
|
|
|
69
|
+
## Query Backend
|
|
70
|
+
|
|
71
|
+
`resto query execute` sends query requests to `report-cli-service`:
|
|
72
|
+
|
|
73
|
+
```bash
|
|
74
|
+
resto query execute --plan ./plan.json
|
|
75
|
+
```
|
|
76
|
+
|
|
77
|
+
For local report CLI chain testing, start `report-api` and `report-cli-service` locally, then point the CLI at the local service:
|
|
78
|
+
|
|
79
|
+
```bash
|
|
80
|
+
resto query execute \
|
|
81
|
+
--plan ./plan.json \
|
|
82
|
+
--report-cli-url http://127.0.0.1:18081
|
|
83
|
+
```
|
|
84
|
+
|
|
85
|
+
The same service URL can be selected with an environment variable:
|
|
86
|
+
|
|
87
|
+
```bash
|
|
88
|
+
RESTO_REPORT_CLI_URL=http://127.0.0.1:18081 \
|
|
89
|
+
resto query execute --plan ./plan.json
|
|
90
|
+
```
|
|
91
|
+
|
|
92
|
+
`resto shop search` also sends shop filter requests to `report-cli-service`:
|
|
93
|
+
|
|
94
|
+
```bash
|
|
95
|
+
resto shop search zn线上店铺 \
|
|
96
|
+
--report-id 888001 \
|
|
97
|
+
--organization-type 1 \
|
|
98
|
+
--org-type-list 1,2 \
|
|
99
|
+
--report-cli-url http://127.0.0.1:18081
|
|
100
|
+
```
|
|
101
|
+
|
|
66
102
|
## Fixture Mode
|
|
67
103
|
|
|
68
104
|
Fixture mode uses bundled local knowledge and does not require remote services or auth:
|
package/dist/cli.js
CHANGED
|
@@ -7,6 +7,7 @@ import { createAuthCommand } from "./commands/auth.js";
|
|
|
7
7
|
import { createFieldCommand } from "./commands/field.js";
|
|
8
8
|
import { createInstallSkillCommand } from "./commands/install-skill.js";
|
|
9
9
|
import { createKnowledgeCommand } from "./commands/knowledge.js";
|
|
10
|
+
import { createOrderCommand } from "./commands/order.js";
|
|
10
11
|
import { configureJsonParseErrors, JsonCommandError } from "./commands/json-command.js";
|
|
11
12
|
import { createPlaybookCommand } from "./commands/playbook.js";
|
|
12
13
|
import { createQueryCommand } from "./commands/query.js";
|
|
@@ -49,6 +50,7 @@ The CLI does not infer user intent. Agents choose reports, fields, filters, and
|
|
|
49
50
|
program.addCommand(createQueryCommand(options));
|
|
50
51
|
program.addCommand(createSnapshotCommand(options));
|
|
51
52
|
program.addCommand(createAnalysisCommand(options));
|
|
53
|
+
program.addCommand(createOrderCommand(options));
|
|
52
54
|
program.addCommand(createShopCommand(options));
|
|
53
55
|
program.addCommand(createInstallSkillCommand(options));
|
|
54
56
|
program.addCommand(createUninstallCommand(options));
|