@thinkingai/ae-cli 1.0.15 → 1.0.20

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 (43) hide show
  1. package/README.md +23 -24
  2. package/README.zh.md +21 -22
  3. package/dist/auth-A4NV2VHD.js +153 -0
  4. package/dist/{auth-4GAHTBVH.js → auth-T3ILGJKW.js} +6 -4
  5. package/dist/{chunk-TJIMDNAU.js → chunk-5CCFSPAF.js} +79 -3
  6. package/dist/{chunk-UK6HO5O5.js → chunk-OVMQFFC2.js} +13 -1
  7. package/dist/{chunk-EBFUVWIZ.js → chunk-TMMUBSKW.js} +52 -0
  8. package/dist/{chunk-OQ4XEG77.js → chunk-TOXRLDUP.js} +2 -2
  9. package/dist/{client-HU63573O.js → client-FPA76DGY.js} +3 -3
  10. package/dist/{config-OLF7RBPM.js → config-QZIEYXQZ.js} +20 -5
  11. package/dist/index.js +18 -13
  12. package/dist/{raw-GDO4IWNW.js → raw-MZIKHQH4.js} +3 -3
  13. package/dist/{te-analysis-ZDJXMWZY.js → te-analysis-CFQBXUCO.js} +93 -7
  14. package/dist/{te-audience-T5B52EEB.js → te-audience-WPBBWADL.js} +3 -3
  15. package/dist/{te-common-BPTXXTHQ.js → te-common-GL3KBZPD.js} +3 -3
  16. package/dist/{te-community-FPB5LH56.js → te-community-3XEJNSQL.js} +3 -3
  17. package/dist/{te-dataops-2NUJVG47.js → te-dataops-H4WSMCG5.js} +3 -3
  18. package/dist/{te-engage-K3EANZ5P.js → te-engage-2VFM37ZM.js} +3 -3
  19. package/dist/te-kb-U6SQUJVC.js +41 -0
  20. package/dist/{te-meta-JJMV75KB.js → te-meta-BO45GW32.js} +10 -8
  21. package/package.json +2 -1
  22. package/skills/ae-analysis/SKILL.md +119 -29
  23. package/skills/ae-analysis/references/build_event_analysis_qp.md +132 -0
  24. package/skills/ae-analysis/references/build_funnel_analysis_qp.md +143 -0
  25. package/skills/ae-analysis/references/build_prop_analysis_qp.md +122 -0
  26. package/skills/ae-analysis/references/build_retention_analysis_qp.md +141 -0
  27. package/skills/ae-analysis/references/generate_track_program.md +8 -8
  28. package/skills/ae-analysis/references/get_analysis_query_schema.md +22 -11
  29. package/skills/ae-analysis/references/get_metric.md +7 -1
  30. package/skills/ae-analysis/references/get_report_definition.md +4 -0
  31. package/skills/ae-analysis/references/list_alerts.md +4 -0
  32. package/skills/ae-analysis/references/list_clusters.md +4 -0
  33. package/skills/ae-analysis/references/list_dashboards.md +6 -0
  34. package/skills/ae-analysis/references/list_events.md +8 -1
  35. package/skills/ae-analysis/references/list_metrics.md +9 -0
  36. package/skills/ae-analysis/references/list_properties.md +6 -1
  37. package/skills/ae-analysis/references/list_reports.md +6 -0
  38. package/skills/ae-analysis/references/list_tags.md +4 -0
  39. package/skills/ae-analysis/references/query_adhoc.md +80 -30
  40. package/skills/ae-community/SKILL.md +14 -101
  41. package/skills/ae-dataops/SKILL.md +13 -58
  42. package/skills/ae-engage/SKILL.md +15 -98
  43. package/dist/auth-U2GHFMFY.js +0 -81
@@ -2,10 +2,6 @@
2
2
  name: ae-analysis
3
3
  version: 3.0.0
4
4
  description: "AE/TE/ThinkingEngine/ThinkingAI ae-cli manual for analysis-side tasks in the AE system or analysis platform: reports, dashboards, alerts, ad hoc analysis, drilldown, audience clusters, tags, tag members, metrics and metric definitions, events, properties, virtual events, virtual properties, metadata, project configuration, tracking plans, event tracking, mark times, project lists, and resource links. Use when the user asks to query, create, update, refresh, inspect, troubleshoot, govern, or manage these AE analysis assets. Must use ae-cli, read the matching references/<tool_name>.md command manual before composing commands, and never guess command names, flags, JSON payloads, project_id, resource IDs, or parameter formats."
5
- metadata:
6
- requires:
7
- bins: ["ae-cli"]
8
- cliHelp: "ae-cli --help"
9
5
  ---
10
6
 
11
7
  # ae-analysis
@@ -19,39 +15,22 @@ metadata:
19
15
 
20
16
  AE CLI (`ae-cli`) is the command-line tool for the AE / TE / ThinkingEngine analysis platform. For AE analysis-side requests, prefer `ae-cli` and this skill's reference docs over model memory.
21
17
 
22
- Authentication priority:
23
- 1. `TE_TOKEN` environment variable.
24
- 2. Cached token in `~/.ae-cli/tokens.json`, usually valid for 20 hours.
25
- 3. macOS Chrome token extraction via `ae-cli auth login`.
26
-
27
- Useful authentication commands:
28
-
29
- ```bash
30
- ae-cli auth login
31
- ae-cli auth status
32
- ae-cli auth logout
33
- ```
34
-
35
18
  Global parameters:
36
19
 
37
20
  | Parameter | Description |
38
21
  |---|---|
39
- | `--host <host>` | Target AE host. Use when the environment is not the default host. |
40
- | `--format <json|table>` | Output format. Default is JSON. |
22
+ | `--format <json\|table>` | Output format. Default is JSON. |
41
23
  | `--jq <expr>` | jq filter expression for JSON output. |
42
- | `--dry-run` | Preview the request without executing it. |
43
- | `--yes` | Skip confirmation for write operations. Use only when the user intent is explicit or automation requires it. |
44
24
 
45
25
  Output and errors:
46
26
  - Successful commands return machine-readable JSON by default.
47
27
  - Failed commands return `{ "ok": false, "error": { "type": "...", "message": "...", "hint": "..." } }` and exit non-zero.
48
- - On auth/config errors, check `ae-cli auth status`, host configuration, and the target environment before retrying.
49
28
 
50
29
  Safety constraints:
51
30
  - Read commands can execute directly after required IDs and references are verified.
52
31
  - Write commands require explicit user intent and normally keep the confirmation prompt.
53
- - Use `--dry-run` before risky or complex writes.
54
- - Never invent command names, flags, JSON payloads, `project_id`, resource IDs, field names, event names, property names, metric definitions, or date formats. Read the matching command reference and discover real project metadata first.
32
+ - Never invent command names, flags, JSON payloads, `project_id`, resource IDs, field names, event names, property names, metric definitions, or date formats. For builder-supported ad-hoc models (`event`, `retention`, `funnel`, `prop_analysis`), do not pre-discover metadata; pass the user's event/property/metric wording to the matching QP builder and let the builder resolve metadata or return clarification. For non-builder/manual workflows, read the matching command reference and discover real project metadata first.
33
+ - **NEVER fabricate or guess resource names** (reports, dashboards, events, properties, metrics, clusters, tags, alerts). Always use list commands to discover real resources first. If a resource is not found after fuzzy search and full list fallback, explicitly tell the user "resource not found" and stop - do not proceed with fabricated names.
55
34
 
56
35
  ## When to Use
57
36
 
@@ -109,9 +88,116 @@ Closed-loop check (must be explicit in result):
109
88
  - `+get_resource_url` called or skipped (no ID)
110
89
  - Link completion status
111
90
 
112
- ## Tool Groups (69)
113
-
114
- ### analysis (31)
91
+ ### C. FUZZY_SEARCH_FALLBACK
92
+
93
+ For list commands with `--query` parameter (list_reports, list_dashboards, list_events, list_clusters, list_tags, list_alerts, list_metrics):
94
+
95
+ 1. **First attempt**: Use `--query` with user-provided keyword for fuzzy search
96
+ 2. **If no results found**, retry up to 2 more times with:
97
+ - Broader keywords (remove modifiers, use root words)
98
+ - Alternative terms or synonyms
99
+ 3. **After 3 failed fuzzy attempts**, fall back to full list (omit `--query`)
100
+ 4. **Present full list** to user and ask them to identify the target resource
101
+ 5. **Never proceed** with operations on non-existent resources
102
+
103
+ **Example workflow:**
104
+ - User asks: "Find active user report"
105
+ - Attempt 1: `--query "active user"` → no results
106
+ - Attempt 2: `--query "active"` → no results
107
+ - Attempt 3: `--query "user"` → no results
108
+ - Fallback: list all reports, show to user, ask for selection
109
+
110
+ ### D. QUERY_EXISTING_FIRST
111
+
112
+ Before executing ad-hoc queries (`query_adhoc`), MUST check for existing reports/dashboards first:
113
+
114
+ **Mandatory workflow for data queries:**
115
+
116
+ 1. **Identify user intent** - Extract what metrics/dimensions/filters the user wants
117
+ 2. **Search existing reports** - Use `list_reports --query <keyword>` to find matching reports
118
+ 3. **Search existing dashboards** - Use `list_dashboards --query <keyword>` to find matching dashboards
119
+ 4. **If found** - Use `query_report_data` or `query_dashboard_report_data` to get data from existing assets
120
+ 5. **If not found** - For QP builder-supported models (`event`, `retention`, `funnel`, `prop_analysis`), call the matching builder first and then call `query_adhoc` with builder `qp`; do not call schema or metadata tools between the report/dashboard miss and the builder. For all other `query_adhoc` models, use the legacy schema/metadata path.
121
+
122
+ **Rationale:**
123
+ - **Performance**: Existing reports are pre-computed and faster
124
+ - **Consistency**: Reports have business-defined metrics and calibrated logic
125
+ - **Resource efficiency**: Avoid redundant computation
126
+ - **Permissions**: Users may have report access but not ad-hoc query permissions
127
+
128
+ **Example:**
129
+ - User: "Query active users in last 7 days"
130
+ - Step 1: `list_reports --query "active user"` → found "DAU Active Users Report"
131
+ - Step 2: `query_report_data --report_id <id>` → return data
132
+ - ❌ WRONG: Directly use `query_adhoc` without checking existing reports
133
+
134
+ **Exceptions (when ad-hoc is acceptable):**
135
+ - User explicitly requests "ad-hoc query" or "ad-hoc analysis"
136
+ - User wants custom filters/groupings not available in existing reports
137
+ - User is exploring data for new insights (exploratory analysis)
138
+ - No matching reports found after search + fallback
139
+
140
+ ### E. QP_BUILDER_SUPPORTED_MODELS_ONLY
141
+
142
+ QP builder supports exactly four ad-hoc model types: `event`, `retention`, `funnel`, and `prop_analysis`.
143
+
144
+ For these four model types, QP builder is mandatory before `query_adhoc`. Do not handcraft QP from `get_analysis_query_schema`, examples, or prior knowledge.
145
+
146
+ 1. `event` -> `+build_event_analysis_qp`
147
+ 2. `retention` -> `+build_retention_analysis_qp`
148
+ 3. `funnel` -> `+build_funnel_analysis_qp`
149
+ 4. `prop_analysis` -> `+build_prop_analysis_qp`
150
+
151
+ Builder-supported model routing is:
152
+ 1. Search existing reports/dashboards if `QUERY_EXISTING_FIRST` applies.
153
+ 2. If no existing asset is used, read the matching builder reference.
154
+ 3. Call the matching builder with complete required parameters.
155
+ 4. Call `query_adhoc` only when builder returns `status=generated`.
156
+
157
+ Do not insert metadata/schema calls between steps 2 and 3 for builder-supported models. Specifically, do not call `get_analysis_query_schema`, `list_events`, `list_properties`, `list_metrics`, `get_metric`, or `get_report_definition` to prepare the builder payload. The builder resolves event/property/metric metadata internally and returns `need_clarification` when it cannot.
158
+
159
+ Event metric shortcut:
160
+ - If the user asks to query a saved/business metric through event analysis, pass the metric name/display name/remark directly as an event metric target: `--metrics '[{"event":"<metric name>"}]'`.
161
+ - Do not call `analysis_meta +list_metrics` or `analysis_meta +get_metric` first just to expand the metric definition.
162
+ - If the user provides an explicit formula, pass the formula and dependencies to `+build_event_analysis_qp`; do not convert it by reading schema or metric metadata first.
163
+
164
+ Metric result vs metric metadata:
165
+ - "Query metric result/value/trend over a time range" is an ad-hoc analysis request. Use report/dashboard search first when applicable, then builder -> `query_adhoc`.
166
+ - "Inspect/search/update/create metric definition" is metadata/governance. Only then use `analysis_meta +list_metrics`, `+get_metric`, `+create_metric`, or `+update_metric`.
167
+
168
+ For all other `query_adhoc` model types (`distribution`, `attribution`, `heat_map`, `interval`, `path`, `rank_list`, `sql`), QP builder is not supported. Use the legacy path: read `query_adhoc.md`, fetch schema/metadata as required, then construct QP manually according to the relevant schema.
169
+
170
+ Execution rule:
171
+ - If builder result `status=generated`, call `+query_adhoc` with the same `model_type` and the returned `qp`.
172
+ - If builder returns non-generated status (`need_clarification`, `invalid_argument`, `unsupported_feature`, `validation_error`), stop and ask the user for clarification instead of calling `query_adhoc`.
173
+ - Never bypass a failed builder by manually assembling QP for `event`, `retention`, `funnel`, or `prop_analysis`.
174
+
175
+ Builder payload rules:
176
+ - Before composing any builder JSON, read the matching builder reference doc. The builder references contain the required JSON shape and model-specific field differences.
177
+ - CLI flag names use snake_case, but nested JSON keys use the service DTO field names in camelCase. Correct: `startTime`, `endTime`, `relationEventPropertyName`, `eventPropertyName`. Wrong: `start_date`, `start_time`, `relation_property`, `fieldName`.
178
+ - Builder dry-run still requires the normal required flags. Do not run builder dry-run by itself.
179
+ - Do not pass placeholder `{}` or `[]` for required nested structures except when intentionally checking CLI validation. Fill required inner fields before calling the command.
180
+ - Use enum values exactly as documented. Examples: `mode=start_to_yesterday`, `operator=exists`, `relation=or`, `field.type=event_property`.
181
+ - For `exists`, `not_exists`, `is_true`, and `is_false`, omit `values`. For `between`, provide exactly two values. For other value-based operators, provide a non-empty `values` array.
182
+ - Builder tools do not execute the query and do not take `zone_offset`. Pass time zone to `+query_adhoc` with `--zone_offset` after the builder returns `status=generated`.
183
+ - If the user's request lacks a required business element such as time range, event, metric, funnel window, property, or relation field, stop and ask for clarification. If the request supplies a name but it may be a metadata ambiguity, call the builder and let it return candidates. Do not invent names or handcraft QP.
184
+
185
+ Supported builder chain:
186
+ 1. Read the builder reference for the target model.
187
+ 2. Build structured JSON from the user's request. Use user-provided event/property/metric names as-is; do not pre-query metadata for these names.
188
+ 3. Run the matching `+build_*_analysis_qp` command.
189
+ 4. If `status=generated`, call `+query_adhoc --model_type <same_model> --qp '<response.qp>'`.
190
+ 5. If status is not `generated`, report the structured error or ask the user for the missing information; do not continue to `query_adhoc`.
191
+
192
+ Legacy query_adhoc chain:
193
+ 1. Use only for `distribution`, `attribution`, `heat_map`, `interval`, `path`, `rank_list`, or `sql`.
194
+ 2. Read `references/query_adhoc.md` and required schema/metadata references.
195
+ 3. Build QP manually from the documented schema and verified project metadata.
196
+ 4. Call `+query_adhoc`.
197
+
198
+ ## Tool Groups (73)
199
+
200
+ ### analysis (35)
115
201
 
116
202
  Alerts (5):
117
203
  - `+get_alert_definition_schema` ([doc](references/get_alert_definition_schema.md))
@@ -135,7 +221,11 @@ Reports and Dashboards (13):
135
221
  - `+create_public_access_link` ([doc](references/create_public_access_link.md))
136
222
  - `+update_public_access_link` ([doc](references/update_public_access_link.md))
137
223
 
138
- Model Analysis (6):
224
+ Model Analysis (10):
225
+ - `+build_event_analysis_qp` ([doc](references/build_event_analysis_qp.md))
226
+ - `+build_retention_analysis_qp` ([doc](references/build_retention_analysis_qp.md))
227
+ - `+build_funnel_analysis_qp` ([doc](references/build_funnel_analysis_qp.md))
228
+ - `+build_prop_analysis_qp` ([doc](references/build_prop_analysis_qp.md))
139
229
  - `+query_adhoc` ([doc](references/query_adhoc.md))
140
230
  - `+drilldown_users` ([doc](references/drilldown_users.md))
141
231
  - `+drilldown_user_events` ([doc](references/drilldown_user_events.md))
@@ -226,4 +316,4 @@ npm run verify:analysis-common-tools
226
316
 
227
317
  ## Reference Docs
228
318
 
229
- See the unified `references/` directory (69 command docs total).
319
+ See the unified `references/` directory (73 command docs total).
@@ -0,0 +1,132 @@
1
+ # analysis +build_event_analysis_qp (build event analysis qp)
2
+
3
+ > **Prerequisite:** Follow the Global AE CLI Rules in [`../SKILL.md`](../SKILL.md).
4
+
5
+ Domain: **Model Analysis**
6
+
7
+ ## Use Cases
8
+ - Build a validated event-analysis QP from structured intent.
9
+ - Use in the mandatory builder flow before `+query_adhoc --model_type event`.
10
+ - This command builds QP only and does not execute the analysis query.
11
+ - This is one of exactly four QP builders: `event`, `retention`, `funnel`, `prop_analysis`.
12
+ - Use this builder for event-analysis ad hoc requests; do not manually build event QP through `+get_analysis_query_schema`.
13
+
14
+ ## JSON Rules
15
+ - CLI flags use snake_case, but JSON object keys use camelCase DTO names.
16
+ - Correct nested keys: `startTime`, `endTime`, `timeRange`, `timeParticleSize`.
17
+ - Wrong nested keys: `start_date`, `start_time`, `startDate` inside examples copied from other APIs.
18
+ - Wrap JSON in single quotes in shell commands.
19
+ - Do not run syntax examples with placeholder JSON. Fill `time_range` and `metrics` with valid nested fields before calling this command.
20
+ - `--dry-run` still requires the same required flags as a real builder call. Never run this command as dry-run without `--project_id`, `--time_range`, and `--metrics`.
21
+ - Do not call `get_analysis_query_schema`, `list_events`, `list_properties`, `list_metrics`, or `get_metric` before this builder for normal ad-hoc analysis. The builder resolves events, properties, and saved metric names internally.
22
+ - Builder commands do not accept `zone_offset`; pass `--zone_offset` to `+query_adhoc` after the builder succeeds.
23
+ - If the request misses `time_range` or `metrics`, stop and ask the user to clarify.
24
+
25
+ ## Command Syntax
26
+ ```bash
27
+ ae-cli analysis +build_event_analysis_qp --project_id <project_id> --time_range '<valid_time_range_json>' --metrics '<valid_metrics_json_array>'
28
+ ae-cli analysis +build_event_analysis_qp --project_id <project_id> --time_range '<valid_time_range_json>' --metrics '<valid_metrics_json_array>' --time_particle_size day --groups '<valid_groups_json_array>' --filters '<valid_filters_json_array>' --relation and
29
+ ae-cli analysis +build_event_analysis_qp --project_id <project_id> --time_range '<valid_time_range_json>' --metrics '<valid_metrics_json_array>' --dry-run
30
+ ```
31
+
32
+ ## Parameters
33
+ | Parameter | Required | Description |
34
+ |---|---|---|
35
+ | `--project_id` / `-p` | Yes | Project ID |
36
+ | `--time_range` | Yes | Event analysis time range JSON |
37
+ | `--metrics` | Yes | Event metrics JSON array |
38
+ | `--time_particle_size` | No | Time granularity. Default: total |
39
+ | `--groups` | No | Group-by dimensions JSON array |
40
+ | `--filters` | No | Global filters JSON array |
41
+ | `--relation` | No | Filter relation. Supported values: and, or. Default: and |
42
+
43
+ ## JSON Shape
44
+ `--time_range` object:
45
+ ```json
46
+ {"mode":"start_to_yesterday","startTime":"2021-05-18"}
47
+ ```
48
+
49
+ Time range fields:
50
+ | Field | Required | Description |
51
+ |---|---|---|
52
+ | `mode` | Yes | `recent`, `previous`, `custom`, `start_to_today`, `start_to_yesterday` |
53
+ | `unit` | For `recent`/`previous` | `day`, `week`, `month`, `quarter`, `year` |
54
+ | `value` | For `recent`/`previous` | Unit count. `{"mode":"previous","unit":"day","value":1}` means yesterday. |
55
+ | `startTime` | For `custom`/`start_to_*` | `yyyy-MM-dd` or `yyyy-MM-dd HH:mm:ss` |
56
+ | `endTime` | For `custom` only | `yyyy-MM-dd` or `yyyy-MM-dd HH:mm:ss` |
57
+
58
+ `--metrics` array:
59
+ ```json
60
+ [{"event":"special_data","aggregation":"user_count"}]
61
+ ```
62
+
63
+ Metric fields:
64
+ | Field | Required | Description |
65
+ |---|---|---|
66
+ | `event` | Yes for regular metrics | Event display name, technical name, or remark |
67
+ | `aggregation` | Yes for regular metrics | `total_count`, `user_count`, `per_user_count`, `sum`, `avg`, `avg_per_user`, `max`, `min`, `distinct_count`, `true_count`, `false_count`, `not_empty_count`, `empty_count`, `median`, `percentile`, `variance`, `stddev` |
68
+ | `property` | Required for property aggregations | Required except for `total_count`, `user_count`, and `per_user_count` |
69
+ | `percentile` | Required for `percentile` | Number such as `90` |
70
+ | `filters` | No | Metric-level `FilterRequest[]` |
71
+ | `relation` | No | Relation between metric filters: `and` or `or` |
72
+ | `formula` | For formula metrics | Formula expression. Omit `aggregation` when using formula. |
73
+ | `dependencies` | For formula metrics | Formula dependency array |
74
+
75
+ Saved metric reference:
76
+ - Event analysis builder can resolve a saved metric by name/display name/remark through the metric target field.
77
+ - If the user asks to query an existing metric such as "战斗失败率" or gives a metric identifier/name that should be used as a saved metric, pass it as `{"event":"战斗失败率"}` and omit `aggregation`, `property`, `formula`, and `dependencies`.
78
+ - Do not call `list_metrics` or `get_metric` first only to expand that saved metric. If the builder cannot resolve it, it will return `need_clarification` with candidates.
79
+
80
+ Formula dependency object:
81
+ ```json
82
+ {"alias":"starts","event":"battle_start","aggregation":"total_count"}
83
+ ```
84
+
85
+ `--groups` array:
86
+ ```json
87
+ [{"field":{"name":"账户ID","type":"event_property"}}]
88
+ ```
89
+
90
+ `--filters` array:
91
+ ```json
92
+ [{"field":{"name":"账户ID","type":"event_property"},"operator":"exists"}]
93
+ ```
94
+
95
+ Filter fields:
96
+ | Field | Required | Description |
97
+ |---|---|---|
98
+ | `field.name` | Yes | Field display name, technical name, or remark |
99
+ | `field.type` | Recommended | `event_property`, `user_property`, `cluster`, `tag`; omit only when metadata is unambiguous |
100
+ | `operator` | Yes | `eq`, `neq`, `lt`, `lte`, `gt`, `gte`, `exists`, `not_exists`, `between`, `contains`, `not_contains`, `is_true`, `is_false`, `regex`, `not_regex`, `in_cluster`, `not_in_cluster` |
101
+ | `values` | Depends | Omit for `exists`/`not_exists`/`is_true`/`is_false`; exactly two values for `between`; non-empty array for other value operators |
102
+
103
+ ## Examples
104
+ Minimal event user count:
105
+ ```bash
106
+ ae-cli analysis +build_event_analysis_qp --project_id 3137 --time_range '{"mode":"previous","unit":"day","value":1}' --metrics '[{"event":"special_data","aggregation":"user_count"}]'
107
+ ```
108
+
109
+ Formula metric example:
110
+ ```bash
111
+ ae-cli analysis +build_event_analysis_qp --project_id 3137 --time_range '{"mode":"start_to_yesterday","startTime":"2021-05-20"}' --metrics '[{"formula":"battle_lost.A100 / battle_start.A100","dependencies":[{"alias":"battle_lost","event":"battle_lose_rate","aggregation":"total_count"},{"alias":"battle_start","event":"battle_start","aggregation":"total_count"}]}]'
112
+ ```
113
+
114
+ Saved metric by name:
115
+ ```bash
116
+ ae-cli analysis +build_event_analysis_qp --project_id 3137 --time_range '{"mode":"custom","startTime":"2021-05-20","endTime":"2026-05-26"}' --metrics '[{"event":"战斗失败率"}]'
117
+ ```
118
+
119
+ Global OR filters and event-property group:
120
+ ```bash
121
+ ae-cli analysis +build_event_analysis_qp --project_id 3137 --time_range '{"mode":"start_to_yesterday","startTime":"2021-05-18"}' --metrics '[{"event":"special_data","aggregation":"user_count"}]' --filters '[{"field":{"name":"账户ID","type":"event_property"},"operator":"exists"},{"field":{"name":"城市","type":"event_property"},"operator":"exists"}]' --relation or --groups '[{"field":{"name":"账户ID","type":"event_property"}}]'
122
+ ```
123
+
124
+ ## Decision Rules
125
+ - After successful build, call `+query_adhoc --model_type event --qp '<response.qp>'`.
126
+ - If build returns non-generated status, stop and ask user to clarify; do not call `+query_adhoc`.
127
+ - Wrap JSON parameters in single quotes to avoid shell escaping issues.
128
+ - Do not pre-query metrics or metadata. If the user provides a metric name, event name, property name, or formula, pass that structured intent to the builder and let it resolve.
129
+ - If the user gave a time zone, keep it for `+query_adhoc --zone_offset`; do not put it in the builder JSON.
130
+
131
+ ## Recommended Chaining
132
+ - `+build_event_analysis_qp` -> if `status=generated` -> `+query_adhoc --model_type event --qp '<response.qp>'`
@@ -0,0 +1,143 @@
1
+ # analysis +build_funnel_analysis_qp (build funnel analysis qp)
2
+
3
+ > **Prerequisite:** Follow the Global AE CLI Rules in [`../SKILL.md`](../SKILL.md).
4
+
5
+ Domain: **Model Analysis**
6
+
7
+ ## Use Cases
8
+ - Build a validated funnel-analysis QP from structured intent.
9
+ - Use in the mandatory builder flow before `+query_adhoc --model_type funnel`.
10
+ - This command builds QP only and does not execute the analysis query.
11
+ - This is one of exactly four QP builders: `event`, `retention`, `funnel`, `prop_analysis`.
12
+ - Use this builder for funnel ad hoc requests; do not manually build funnel QP through `+get_analysis_query_schema`.
13
+
14
+ ## JSON Rules
15
+ - CLI flags use snake_case, but JSON object keys use camelCase DTO names.
16
+ - Correct nested keys: `startTime`, `endTime`, `relationEventPropertyName`, `eventPropertyName`.
17
+ - Funnel step filters are event-property-only and use `eventPropertyName`; they do not use the generic `field` object.
18
+ - Funnel global filters and groups use the generic `field` object.
19
+ - Do not run syntax examples with placeholder JSON. Fill `time_range` and `funnel` with valid nested fields before calling this command.
20
+ - `--dry-run` still requires the same required flags as a real builder call. Never run this command as dry-run without `--project_id`, `--time_range`, and `--funnel`.
21
+ - Do not call `get_analysis_query_schema`, `list_events`, `list_properties`, `list_metrics`, or `get_metric` before this builder for normal ad-hoc analysis. The builder resolves events and properties internally.
22
+ - Builder commands do not accept `zone_offset`; pass `--zone_offset` to `+query_adhoc` after the builder succeeds.
23
+ - If the request misses time range, at least two steps, or conversion window, stop and ask the user to clarify.
24
+
25
+ ## Command Syntax
26
+ ```bash
27
+ ae-cli analysis +build_funnel_analysis_qp --project_id <project_id> --time_range '<valid_time_range_json>' --funnel '<valid_funnel_json>'
28
+ ae-cli analysis +build_funnel_analysis_qp --project_id <project_id> --time_range '<valid_time_range_json>' --funnel '<valid_funnel_json>' --relation and --time_particle_size day
29
+ ae-cli analysis +build_funnel_analysis_qp --project_id <project_id> --time_range '<valid_time_range_json>' --funnel '<valid_funnel_json>' --dry-run
30
+ ```
31
+
32
+ ## Parameters
33
+ | Parameter | Required | Description |
34
+ |---|---|---|
35
+ | `--project_id` / `-p` | Yes | Project ID |
36
+ | `--time_range` | Yes | Funnel analysis time range JSON |
37
+ | `--funnel` | Yes | Funnel intent JSON |
38
+ | `--relation` | No | Top-level funnel filter relation. Supported values: and, or. Default: and |
39
+ | `--time_particle_size` | No | Time granularity. Supported values: day, week, month |
40
+
41
+ ## JSON Shape
42
+ `--time_range` object:
43
+ ```json
44
+ {"mode":"start_to_yesterday","startTime":"2021-05-18"}
45
+ ```
46
+
47
+ Time range fields:
48
+ | Field | Required | Description |
49
+ |---|---|---|
50
+ | `mode` | Yes | `recent`, `previous`, `custom`, `start_to_today`, `start_to_yesterday` |
51
+ | `unit` | For `recent`/`previous` | `day`, `week`, `month`, `quarter`, `year` |
52
+ | `value` | For `recent`/`previous` | Unit count. `{"mode":"previous","unit":"day","value":1}` means yesterday. |
53
+ | `startTime` | For `custom`/`start_to_*` | `yyyy-MM-dd` or `yyyy-MM-dd HH:mm:ss` |
54
+ | `endTime` | For `custom` only | `yyyy-MM-dd` or `yyyy-MM-dd HH:mm:ss` |
55
+
56
+ `--funnel` object:
57
+ ```json
58
+ {
59
+ "steps":[
60
+ {"event":"special_data","filters":[{"eventPropertyName":"账户ID","operator":"exists"}]},
61
+ {"event":"商品购买","filters":[{"eventPropertyName":"账户ID","operator":"exists"},{"eventPropertyName":"城市","operator":"exists"}],"relation":"or"}
62
+ ],
63
+ "window":{"value":180,"unit":"day"},
64
+ "relationEventPropertyName":"账户ID",
65
+ "filters":[
66
+ {"field":{"name":"账户ID","type":"event_property"},"operator":"exists"},
67
+ {"field":{"name":"城市","type":"event_property"},"operator":"exists"}
68
+ ],
69
+ "groups":[{"field":{"name":"账户ID","type":"event_property"}}]
70
+ }
71
+ ```
72
+
73
+ Funnel fields:
74
+ | Field | Required | Description |
75
+ |---|---|---|
76
+ | `steps` | Yes | At least two step objects |
77
+ | `steps[].event` | Yes | Event display name, technical name, or remark |
78
+ | `steps[].filters` | No | Step-level event-property filters. Use `eventPropertyName`, not `field`. |
79
+ | `steps[].relation` | No | Relation between filters in this step: `and` or `or`. Default: `and`. |
80
+ | `window.value` | Yes | Conversion window size. Must be greater than 0. |
81
+ | `window.unit` | No | `second`, `minute`, `hour`, `day`, `week`, `month`. Default: `day`. |
82
+ | `relationEventPropertyName` | No | Event property used as common relation property across all steps. Must resolve compatibly in every step event. |
83
+ | `filters` | No | Global funnel filters using generic `FilterRequest[]` |
84
+ | `groups` | No | Global group-by dimensions using generic `DimensionRequest[]` |
85
+
86
+ Generic filter object for `funnel.filters`:
87
+ ```json
88
+ {"field":{"name":"账户ID","type":"event_property"},"operator":"exists"}
89
+ ```
90
+
91
+ Step filter object for `steps[].filters`:
92
+ ```json
93
+ {"eventPropertyName":"账户ID","operator":"exists"}
94
+ ```
95
+
96
+ Group object:
97
+ ```json
98
+ {"field":{"name":"账户ID","type":"event_property"}}
99
+ ```
100
+
101
+ Field types for `funnel.filters` and `funnel.groups`:
102
+ | Type | Meaning |
103
+ |---|---|
104
+ | `event_property` | Event property |
105
+ | `user_property` | User property |
106
+ | `cluster` | User cluster |
107
+ | `tag` | User tag |
108
+
109
+ Filter operator rules:
110
+ | Operator | Values |
111
+ |---|---|
112
+ | `exists`, `not_exists`, `is_true`, `is_false` | Omit `values` |
113
+ | `between` | Exactly two values |
114
+ | `eq`, `neq`, `lt`, `lte`, `gt`, `gte`, `contains`, `not_contains`, `regex`, `not_regex` | Non-empty `values` array |
115
+ | `in_cluster`, `not_in_cluster` | Cluster operator; values are not required by builder validation |
116
+
117
+ ## Examples
118
+ Minimal two-step funnel:
119
+ ```bash
120
+ ae-cli analysis +build_funnel_analysis_qp --project_id 3137 --time_range '{"mode":"previous","unit":"day","value":1}' --funnel '{"steps":[{"event":"special_data"},{"event":"商品购买"}],"window":{"value":180,"unit":"day"}}'
121
+ ```
122
+
123
+ Complex funnel with relation property, step filters, global OR filters, and group:
124
+ ```bash
125
+ ae-cli analysis +build_funnel_analysis_qp --project_id 3137 --time_range '{"mode":"start_to_yesterday","startTime":"2021-05-18"}' --funnel '{"steps":[{"event":"special_data","filters":[{"eventPropertyName":"账户ID","operator":"exists"}]},{"event":"商品购买","filters":[{"eventPropertyName":"账户ID","operator":"exists"},{"eventPropertyName":"城市","operator":"exists"}],"relation":"or"}],"window":{"value":180,"unit":"day"},"relationEventPropertyName":"账户ID","filters":[{"field":{"name":"账户ID","type":"event_property"},"operator":"exists"},{"field":{"name":"城市","type":"event_property"},"operator":"exists"}],"groups":[{"field":{"name":"账户ID","type":"event_property"}}]}' --relation or
126
+ ```
127
+
128
+ Then execute with UTC-11 after builder returns `status=generated`:
129
+ ```bash
130
+ ae-cli analysis +query_adhoc --project_id 3137 --model_type funnel --qp '<response.qp>' --zone_offset -11
131
+ ```
132
+
133
+ ## Decision Rules
134
+ - After successful build, call `+query_adhoc --model_type funnel --qp '<response.qp>'`.
135
+ - If build returns non-generated status, stop and ask user to clarify; do not call `+query_adhoc`.
136
+ - Wrap JSON parameters in single quotes to avoid shell escaping issues.
137
+ - Do not pre-query metrics or metadata. Pass user-provided event/property names to the builder and let it resolve them.
138
+ - Do not put global filter relation inside `funnel`; pass it as top-level CLI flag `--relation`.
139
+ - If the user says "step 1 account ID group", builder cannot take a step index for groups; express it as `groups:[{"field":{"name":"账户ID","type":"event_property"}}]` and ask for clarification if that is ambiguous.
140
+ - If the user gave a time zone, keep it for `+query_adhoc --zone_offset`; do not put it in the builder JSON.
141
+
142
+ ## Recommended Chaining
143
+ - `+build_funnel_analysis_qp` -> if `status=generated` -> `+query_adhoc --model_type funnel --qp '<response.qp>'`
@@ -0,0 +1,122 @@
1
+ # analysis +build_prop_analysis_qp (build property analysis qp)
2
+
3
+ > **Prerequisite:** Follow the Global AE CLI Rules in [`../SKILL.md`](../SKILL.md).
4
+
5
+ Domain: **Model Analysis**
6
+
7
+ ## Use Cases
8
+ - Build a validated `prop_analysis` QP from structured intent.
9
+ - Use in the mandatory builder flow before `+query_adhoc --model_type prop_analysis`.
10
+ - This command builds QP only and does not execute the analysis query.
11
+ - This is one of exactly four QP builders: `event`, `retention`, `funnel`, `prop_analysis`.
12
+ - Use this builder for property-analysis ad hoc requests; do not manually build prop_analysis QP through `+get_analysis_query_schema`.
13
+
14
+ ## JSON Rules
15
+ - CLI flags use snake_case, but JSON object keys use camelCase DTO names.
16
+ - `prop_analysis` does not use `time_range`; do not pass time range to this command.
17
+ - `event_property` is not supported anywhere in `prop_analysis` fields.
18
+ - Field types for `groups`, `filters`, and `userCrowds[].filters` are limited to `user_property`, `cluster`, and `tag`.
19
+ - Do not run syntax examples with placeholder JSON. Fill `prop_analysis` with a valid metric and optional filters/groups before calling this command.
20
+ - `--dry-run` still requires the same required flags as a real builder call. Never run this command as dry-run without `--project_id` and `--prop_analysis`.
21
+ - Do not call `get_analysis_query_schema`, `list_properties`, `list_metrics`, or `get_metric` before this builder for normal ad-hoc analysis. The builder resolves user properties internally.
22
+ - Builder commands do not accept `zone_offset`; pass `--zone_offset` to `+query_adhoc` after the builder succeeds if needed.
23
+ - If the request misses the metric or asks for event properties, stop and ask the user to clarify.
24
+
25
+ ## Command Syntax
26
+ ```bash
27
+ ae-cli analysis +build_prop_analysis_qp --project_id <project_id> --prop_analysis '<valid_prop_analysis_json>'
28
+ ae-cli analysis +build_prop_analysis_qp --project_id <project_id> --prop_analysis '<valid_prop_analysis_json>' --dry-run
29
+ ```
30
+
31
+ ## Parameters
32
+ | Parameter | Required | Description |
33
+ |---|---|---|
34
+ | `--project_id` / `-p` | Yes | Project ID |
35
+ | `--prop_analysis` | Yes | User property analysis intent JSON |
36
+
37
+ ## JSON Shape
38
+ `--prop_analysis` object:
39
+ ```json
40
+ {
41
+ "metric":{"aggregation":"user_count"},
42
+ "groups":[{"field":{"name":"城市","type":"user_property"}}],
43
+ "filters":[{"field":{"name":"账户ID","type":"user_property"},"operator":"exists"}],
44
+ "relation":"and",
45
+ "userCrowds":[
46
+ {"name":"账户ID有值用户","filters":[{"field":{"name":"账户ID","type":"user_property"},"operator":"exists"}]}
47
+ ]
48
+ }
49
+ ```
50
+
51
+ Prop analysis fields:
52
+ | Field | Required | Description |
53
+ |---|---|---|
54
+ | `metric` | Yes | Single metric object |
55
+ | `groups` | No | User property / cluster / tag group-by fields |
56
+ | `filters` | No | User property / cluster / tag filters |
57
+ | `relation` | No | Relation between top-level filters: `and` or `or`. Default: `and`. |
58
+ | `userCrowds` | No | Optional user crowd comparisons |
59
+
60
+ Metric fields:
61
+ | Field | Required | Description |
62
+ |---|---|---|
63
+ | `aggregation` | Yes | `user_count`, `sum`, `avg`, `max`, `min`, `distinct_count`, `true_count`, `false_count`, `not_empty_count`, `empty_count`, `median`, `percentile`, `variance`, `stddev` |
64
+ | `property` | Required except `user_count` | User property display name, technical name, or remark |
65
+
66
+ Field object:
67
+ ```json
68
+ {"name":"城市","type":"user_property"}
69
+ ```
70
+
71
+ Allowed field types:
72
+ | Type | Meaning |
73
+ |---|---|
74
+ | `user_property` | User property |
75
+ | `cluster` | User cluster |
76
+ | `tag` | User tag |
77
+
78
+ Filter object:
79
+ ```json
80
+ {"field":{"name":"账户ID","type":"user_property"},"operator":"exists"}
81
+ ```
82
+
83
+ User crowd object:
84
+ ```json
85
+ {"name":"付费用户","filters":[{"field":{"name":"是否付费","type":"user_property"},"operator":"is_true"}],"relation":"and"}
86
+ ```
87
+
88
+ Filter operator rules:
89
+ | Operator | Values |
90
+ |---|---|
91
+ | `exists`, `not_exists`, `is_true`, `is_false` | Omit `values` |
92
+ | `between` | Exactly two values |
93
+ | `eq`, `neq`, `lt`, `lte`, `gt`, `gte`, `contains`, `not_contains`, `regex`, `not_regex` | Non-empty `values` array |
94
+ | `in_cluster`, `not_in_cluster` | Cluster operator; values are not required by builder validation |
95
+
96
+ ## Examples
97
+ Minimal user count:
98
+ ```bash
99
+ ae-cli analysis +build_prop_analysis_qp --project_id 3137 --prop_analysis '{"metric":{"aggregation":"user_count"}}'
100
+ ```
101
+
102
+ User property average grouped by city:
103
+ ```bash
104
+ ae-cli analysis +build_prop_analysis_qp --project_id 3137 --prop_analysis '{"metric":{"aggregation":"avg","property":"余额"},"groups":[{"field":{"name":"城市","type":"user_property"}}],"filters":[{"field":{"name":"账户ID","type":"user_property"},"operator":"exists"}]}'
105
+ ```
106
+
107
+ User crowds with OR filter:
108
+ ```bash
109
+ ae-cli analysis +build_prop_analysis_qp --project_id 3137 --prop_analysis '{"metric":{"aggregation":"user_count"},"filters":[{"field":{"name":"账户ID","type":"user_property"},"operator":"exists"},{"field":{"name":"城市","type":"user_property"},"operator":"exists"}],"relation":"or","userCrowds":[{"name":"账户或城市有值","filters":[{"field":{"name":"账户ID","type":"user_property"},"operator":"exists"},{"field":{"name":"城市","type":"user_property"},"operator":"exists"}],"relation":"or"}]}'
110
+ ```
111
+
112
+ ## Decision Rules
113
+ - After successful build, call `+query_adhoc --model_type prop_analysis --qp '<response.qp>'`.
114
+ - If build returns non-generated status, stop and ask user to clarify; do not call `+query_adhoc`.
115
+ - Wrap JSON parameters in single quotes to avoid shell escaping issues.
116
+ - Do not pre-query metrics or metadata. Pass user-provided property names to the builder and let it resolve them.
117
+ - Do not use `event_property` in prop_analysis. If the user asks for event property analysis, switch to event/funnel/retention builder or ask for clarification.
118
+ - If `userCrowds` is used, at most one group dimension is supported.
119
+ - If the user gave a time zone, keep it for `+query_adhoc --zone_offset`; do not put it in the builder JSON.
120
+
121
+ ## Recommended Chaining
122
+ - `+build_prop_analysis_qp` -> if `status=generated` -> `+query_adhoc --model_type prop_analysis --qp '<response.qp>'`