@thinkingai/ae-cli 1.0.18 → 1.0.21

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 (36) hide show
  1. package/dist/{auth-ECD46NBA.js → auth-T3ILGJKW.js} +2 -2
  2. package/dist/{auth-2UTBG5U3.js → auth-ZPA6O5KO.js} +25 -6
  3. package/dist/{chunk-7QBNU44L.js → chunk-5CCFSPAF.js} +8 -30
  4. package/dist/{chunk-LAAS6ITR.js → chunk-7G2F7IVO.js} +32 -2
  5. package/dist/{chunk-4KQ7H7DY.js → chunk-OVMQFFC2.js} +1 -1
  6. package/dist/{chunk-MR57UIKC.js → chunk-TMMUBSKW.js} +10 -0
  7. package/dist/{client-O56G2SNJ.js → client-NYAEJDQZ.js} +7 -3
  8. package/dist/{config-BU5FHGGE.js → config-QZIEYXQZ.js} +2 -2
  9. package/dist/index.js +18 -13
  10. package/dist/{raw-A3VN2B6I.js → raw-6ZPW3YII.js} +3 -3
  11. package/dist/{te-analysis-UGKESPBE.js → te-analysis-CFQBXUCO.js} +93 -7
  12. package/dist/{te-audience-THZNVHYB.js → te-audience-WPBBWADL.js} +3 -3
  13. package/dist/{te-common-QZOUME3S.js → te-common-GL3KBZPD.js} +3 -3
  14. package/dist/{te-community-AZVW3NFX.js → te-community-3XEJNSQL.js} +3 -3
  15. package/dist/{te-dataops-OE5PX2K6.js → te-dataops-H4WSMCG5.js} +3 -3
  16. package/dist/{te-engage-RYGEQTYK.js → te-engage-2VFM37ZM.js} +3 -3
  17. package/dist/te-kb-EHHYPYBN.js +407 -0
  18. package/dist/{te-meta-MGO5BCMG.js → te-meta-BO45GW32.js} +7 -7
  19. package/package.json +4 -1
  20. package/skills/ae-analysis/SKILL.md +69 -37
  21. package/skills/ae-analysis/references/build_event_analysis_qp.md +132 -0
  22. package/skills/ae-analysis/references/build_funnel_analysis_qp.md +143 -0
  23. package/skills/ae-analysis/references/build_prop_analysis_qp.md +122 -0
  24. package/skills/ae-analysis/references/build_retention_analysis_qp.md +141 -0
  25. package/skills/ae-analysis/references/get_analysis_query_schema.md +22 -11
  26. package/skills/ae-analysis/references/get_metric.md +7 -1
  27. package/skills/ae-analysis/references/get_report_definition.md +4 -0
  28. package/skills/ae-analysis/references/list_dashboards.md +2 -0
  29. package/skills/ae-analysis/references/list_events.md +4 -1
  30. package/skills/ae-analysis/references/list_metrics.md +5 -0
  31. package/skills/ae-analysis/references/list_properties.md +6 -1
  32. package/skills/ae-analysis/references/list_reports.md +2 -0
  33. package/skills/ae-analysis/references/query_adhoc.md +71 -31
  34. package/skills/ae-community/SKILL.md +14 -101
  35. package/skills/ae-dataops/SKILL.md +13 -58
  36. package/skills/ae-engage/SKILL.md +15 -98
@@ -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>'`
@@ -0,0 +1,141 @@
1
+ # analysis +build_retention_analysis_qp (build retention 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 retention-analysis QP from structured intent.
9
+ - Use in the mandatory builder flow before `+query_adhoc --model_type retention`.
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 retention ad hoc requests; do not manually build retention 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: `initialEvent`, `returnEvent`, `unitNum`, `rtnRateOrNum`, `relationEventPropertyName`, `initialFilters`, `returnFilters`, `initialFilterRelation`, `returnFilterRelation`.
17
+ - Initial/return event filters are event-property-only and use `eventPropertyName`; they do not use the generic `field` object.
18
+ - Retention global filters and groups use the generic `field` object.
19
+ - Do not run syntax examples with placeholder JSON. Fill `time_range` and `retention` 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 `--retention`.
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, initial event, return event, or retention interval, stop and ask the user to clarify.
24
+
25
+ ## Command Syntax
26
+ ```bash
27
+ ae-cli analysis +build_retention_analysis_qp --project_id <project_id> --time_range '<valid_time_range_json>' --retention '<valid_retention_json>'
28
+ ae-cli analysis +build_retention_analysis_qp --project_id <project_id> --time_range '<valid_time_range_json>' --retention '<valid_retention_json>' --relation and --time_particle_size day
29
+ ae-cli analysis +build_retention_analysis_qp --project_id <project_id> --time_range '<valid_time_range_json>' --retention '<valid_retention_json>' --dry-run
30
+ ```
31
+
32
+ ## Parameters
33
+ | Parameter | Required | Description |
34
+ |---|---|---|
35
+ | `--project_id` / `-p` | Yes | Project ID |
36
+ | `--time_range` | Yes | Retention analysis time range JSON |
37
+ | `--retention` | Yes | Retention intent JSON |
38
+ | `--relation` | No | Top-level retention 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
+ `--retention` object:
57
+ ```json
58
+ {
59
+ "initialEvent":"注册",
60
+ "returnEvent":"商品购买",
61
+ "unitNum":7,
62
+ "statType":"retention",
63
+ "rtnRateOrNum":"R0",
64
+ "relationEventPropertyName":"账户ID",
65
+ "initialFilters":[{"eventPropertyName":"账户ID","operator":"exists"}],
66
+ "returnFilters":[{"eventPropertyName":"账户ID","operator":"exists"}],
67
+ "filters":[{"field":{"name":"城市","type":"event_property"},"operator":"exists"}],
68
+ "groups":[{"field":{"name":"渠道","type":"user_property"}}]
69
+ }
70
+ ```
71
+
72
+ Retention fields:
73
+ | Field | Required | Description |
74
+ |---|---|---|
75
+ | `initialEvent` | Yes | Initial event display name, technical name, or remark |
76
+ | `returnEvent` | Yes | Return event display name, technical name, or remark |
77
+ | `unitNum` | Yes | Retention interval count, such as `1` for day-1 or `7` for day-7 |
78
+ | `statType` | No | `retention` for retained users or `lost` for lost users |
79
+ | `rtnRateOrNum` | No | `R0`, `rate`, or `retention` for rate; `R1`, `number`, or `count` for user count. Default: `R0`. |
80
+ | `relationEventPropertyName` | No | Event property shared by initial event, return event, and simultaneous metrics |
81
+ | `simultaneousMetrics` | No | Extra retention display metrics |
82
+ | `groups` | No | Generic group-by dimensions |
83
+ | `filters` | No | Generic retention filters |
84
+ | `initialFilters` | No | Event-property-only filters for initial event |
85
+ | `initialFilterRelation` | No | Relation for `initialFilters`: `and` or `or` |
86
+ | `returnFilters` | No | Event-property-only filters for return event |
87
+ | `returnFilterRelation` | No | Relation for `returnFilters`: `and` or `or` |
88
+
89
+ Initial/return event filter object:
90
+ ```json
91
+ {"eventPropertyName":"账户ID","operator":"exists"}
92
+ ```
93
+
94
+ Generic filter object for `retention.filters`:
95
+ ```json
96
+ {"field":{"name":"城市","type":"event_property"},"operator":"exists"}
97
+ ```
98
+
99
+ Group object:
100
+ ```json
101
+ {"field":{"name":"渠道","type":"user_property"}}
102
+ ```
103
+
104
+ Metric object for `simultaneousMetrics`:
105
+ ```json
106
+ {"event":"商品购买","aggregation":"user_count"}
107
+ ```
108
+
109
+ Supported aggregations:
110
+ `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`.
111
+
112
+ Filter operator rules:
113
+ | Operator | Values |
114
+ |---|---|
115
+ | `exists`, `not_exists`, `is_true`, `is_false` | Omit `values` |
116
+ | `between` | Exactly two values |
117
+ | `eq`, `neq`, `lt`, `lte`, `gt`, `gte`, `contains`, `not_contains`, `regex`, `not_regex` | Non-empty `values` array |
118
+ | `in_cluster`, `not_in_cluster` | Cluster operator; values are not required by builder validation |
119
+
120
+ ## Examples
121
+ Minimal day-7 retention:
122
+ ```bash
123
+ ae-cli analysis +build_retention_analysis_qp --project_id 3137 --time_range '{"mode":"previous","unit":"day","value":7}' --retention '{"initialEvent":"注册","returnEvent":"商品购买","unitNum":7}'
124
+ ```
125
+
126
+ Retention with relation property and event-level filters:
127
+ ```bash
128
+ ae-cli analysis +build_retention_analysis_qp --project_id 3137 --time_range '{"mode":"start_to_yesterday","startTime":"2021-05-18"}' --retention '{"initialEvent":"special_data","returnEvent":"商品购买","unitNum":7,"relationEventPropertyName":"账户ID","initialFilters":[{"eventPropertyName":"账户ID","operator":"exists"}],"returnFilters":[{"eventPropertyName":"账户ID","operator":"exists"},{"eventPropertyName":"城市","operator":"exists"}],"returnFilterRelation":"or","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 --time_particle_size day
129
+ ```
130
+
131
+ ## Decision Rules
132
+ - After successful build, call `+query_adhoc --model_type retention --qp '<response.qp>'`.
133
+ - If build returns non-generated status, stop and ask user to clarify; do not call `+query_adhoc`.
134
+ - Wrap JSON parameters in single quotes to avoid shell escaping issues.
135
+ - Do not pre-query metrics or metadata. Pass user-provided event/property names to the builder and let it resolve them.
136
+ - Do not put global filter relation inside `retention`; pass it as top-level CLI flag `--relation`.
137
+ - For overall/totals retention, omit `--time_particle_size`; only set it when user asks for day/week/month breakdown.
138
+ - If the user gave a time zone, keep it for `+query_adhoc --zone_offset`; do not put it in the builder JSON.
139
+
140
+ ## Recommended Chaining
141
+ - `+build_retention_analysis_qp` -> if `status=generated` -> `+query_adhoc --model_type retention --qp '<response.qp>'`
@@ -4,13 +4,22 @@
4
4
 
5
5
  Domain: **Model schema queries**
6
6
 
7
+ > **CRITICAL - Builder-supported ad hoc models**
8
+ >
9
+ > Do **not** use this tool for natural-language ad hoc requests whose target model is `event`, `retention`, `funnel`, or `prop_analysis`.
10
+ > For those four models, use the matching QP builder first:
11
+ > `+build_event_analysis_qp`, `+build_retention_analysis_qp`, `+build_funnel_analysis_qp`, or `+build_prop_analysis_qp`, then `+query_adhoc`.
12
+ >
13
+ > If a builder returns `need_clarification`, `invalid_argument`, `unsupported_feature`, or `validation_error`, stop and ask the user or report the structured error. Do not fall back to this schema tool.
14
+
7
15
  > **CRITICAL - Step-by-Step Execution (BLOCKING)**
8
16
  >
17
+ > This blocking sequence applies only to non-builder/manual model paths such as `distribution`, `attribution`, `heat_map`, `interval`, `path`, `rank_list`, or `sql`.
9
18
  > **You MUST execute these steps in order. Do NOT skip any step.**
10
19
  >
11
20
  > | Step | Command | When to proceed |
12
21
  > |------|---------|-----------------|
13
- > | **Step 1 (MANDATORY)** | `--model_type <type>` **without `--segments`** | Always execute first. Review result. |
22
+ > | **Step 1 (MANUAL PATH ONLY)** | `--model_type <type>` **without `--segments`** | Execute first only for non-builder/manual models. Review result. |
14
23
  > | **Step 2 (OPTIONAL)** | Add `--segments 'filter_group'` | Only if Step 1 result lacks filter/groupBy structures AND you need them |
15
24
  > | **Step 3 (OPTIONAL)** | Add `--segments 'examples'` | Only if Step 1+2 insufficient for multi-metric, time comparison, formulas |
16
25
  >
@@ -19,26 +28,27 @@ Domain: **Model schema queries**
19
28
 
20
29
  ## Pre-call Checklist (Execute in Order)
21
30
 
31
+ 0. ✓ **Builder-supported model?** → If `event`/`retention`/`funnel`/`prop_analysis`, stop using this tool and use the matching builder.
22
32
  1. ✓ **Step 1 completed?** → Review core schema
23
33
  2. ✓ **Gap identified?** → Justify need (e.g., "need filter_group structure")
24
34
  3. ✓ **Justified?** → Call again with specific segment
25
35
 
26
- **Rule**: Uncertain → execute Step 1 first.
36
+ **Rule**: For non-builder/manual models, uncertain → execute Step 1 first. For `event`, `retention`, `funnel`, or `prop_analysis`, uncertain → read the matching builder reference first.
27
37
 
28
38
  ## Command (Execute in Order)
29
39
 
30
40
  ```bash
31
- # Step 1: ALWAYS START HERE (no segments)
32
- ae-cli analysis +get_analysis_query_schema --model_type event
41
+ # Step 1: start here only for non-builder/manual models (no segments)
42
+ ae-cli analysis +get_analysis_query_schema --model_type distribution
33
43
 
34
44
  # Step 2: Only after Step 1, if filter/groupBy needed
35
- ae-cli analysis +get_analysis_query_schema --model_type event --segments 'filter_group' --include_core false
45
+ ae-cli analysis +get_analysis_query_schema --model_type distribution --segments 'filter_group' --include_core false
36
46
 
37
47
  # Step 3: Only after Step 1/2, for complex scenarios
38
- ae-cli analysis +get_analysis_query_schema --model_type event --segments 'examples' --include_core false
48
+ ae-cli analysis +get_analysis_query_schema --model_type distribution --segments 'examples' --include_core false
39
49
 
40
50
  # Follow-up request (already have core from earlier step in same session)
41
- ae-cli analysis +get_analysis_query_schema --model_type event --segments 'examples' --include_core false
51
+ ae-cli analysis +get_analysis_query_schema --model_type distribution --segments 'examples' --include_core false
42
52
  ```
43
53
 
44
54
  ## Parameters
@@ -53,9 +63,10 @@ ae-cli analysis +get_analysis_query_schema --model_type event --segments 'exampl
53
63
 
54
64
  | 场景 | 参数 | 执行顺序 |
55
65
  |---|---|---|
56
- | 简单 | 不传 `--segments` | **Step 1** - 单事件、单指标、无过滤、无分组 |
57
- | 中等 | `--segments 'filter_group'` | **Step 2** - 有过滤或分组,需先完成 Step 1 |
58
- | 复杂 | `--segments 'examples'` | **Step 3** - 多指标、时间对比、自定义公式,需先完成 Step 1 |
66
+ | Builder 支持模型 | 不适用 | `event`/`retention`/`funnel`/`prop_analysis` 禁止用此工具作为 QP 准备步骤,改用 builder |
67
+ | 简单 | 不传 `--segments` | **Step 1** - 非 builder/manual 模型 |
68
+ | 中等 | `--segments 'filter_group'` | **Step 2** - 非 builder/manual 模型,有过滤或分组,需先完成 Step 1 |
69
+ | 复杂 | `--segments 'examples'` | **Step 3** - 非 builder/manual 模型,需先完成 Step 1 |
59
70
 
60
71
  ## Next Steps on Failure
61
- - Verify model type and segment compatibility (e.g., aggregatetype not for funnel/path/interval/sql)
72
+ - Verify model type and segment compatibility (e.g., aggregatetype not for funnel/path/interval/sql)
@@ -4,9 +4,13 @@
4
4
 
5
5
  Domain: **Metadata Query**
6
6
 
7
+ ## Constraints
8
+
9
+ **Not a builder pre-step:** Do not call `+get_metric` before `+build_event_analysis_qp` for normal ad-hoc analysis. If the user asks to query a saved metric, pass the metric display/name/remark directly as `metrics:[{"event":"<metric name>"}]` to `+build_event_analysis_qp`. The builder resolves saved metrics internally. If it cannot resolve the metric, stop on the builder's structured error and ask for clarification.
10
+
7
11
  ## Use Cases
8
12
  - Get the definition details of a single metric. Returns the metric name, display name, remark, model type, linked events, and parameter definition without executing metric calculation.
9
- - Get the definition details of a single metric.
13
+ - Use this command for metric metadata inspection, metric editing, auditing, or when the user explicitly asks for metric definition details. Do not use it merely to expand a saved metric before a builder-supported ad-hoc query.
10
14
 
11
15
  ## Commands
12
16
  ```bash
@@ -22,6 +26,7 @@ ae-cli analysis_meta +get_metric --dry-run
22
26
 
23
27
  ## Decision Rules
24
28
  - For the first run, pass only the required parameters (`--project_id` and `--metric_id`) to confirm the path works, then add optional parameters.
29
+ - For builder-supported ad-hoc analysis, do not read metric details first. Call the matching builder with the user's metric/event/property wording.
25
30
  - For cross-project troubleshooting, first confirm whether `--project_id` matches the current permissions and target environment.
26
31
 
27
32
  ## Next Steps After Failure
@@ -30,3 +35,4 @@ ae-cli analysis_meta +get_metric --dry-run
30
35
 
31
36
  ## Recommended Chaining
32
37
  - +get_metric -> +update_metric
38
+ - For ad-hoc saved metric query: +build_event_analysis_qp -> +query_adhoc