@thinkingai/ae-cli 6.0.18 → 6.0.22

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 (110) hide show
  1. package/README.md +8 -10
  2. package/README.zh.md +9 -11
  3. package/dist/{auth-DYC2BGLM.js → auth-I2G7OAU2.js} +2 -4
  4. package/dist/{auth-GHBMJ5ZR.js → auth-RDN6D5HU.js} +32 -104
  5. package/dist/{chunk-5OC7CYCG.js → chunk-2W7HULUD.js} +14 -14
  6. package/dist/chunk-4EUZRJPO.js +163 -0
  7. package/dist/{chunk-DMMEPCST.js → chunk-5FBLRSMU.js} +25 -115
  8. package/dist/{chunk-BJX3GXWC.js → chunk-E34XH4GW.js} +2 -2
  9. package/dist/chunk-FPE5LGVU.js +105 -0
  10. package/dist/{chunk-I5CRVM2S.js → chunk-H52CSLJW.js} +44 -17
  11. package/dist/{chunk-RSHMZ3LG.js → chunk-U6QPKCN3.js} +6 -20
  12. package/dist/{chunk-6W4QOZAL.js → chunk-WPXHCP4A.js} +23 -13
  13. package/dist/{chunk-PN3OS34E.js → chunk-XE2PI5DS.js} +1 -1
  14. package/dist/{chunk-2DUEAXV3.js → chunk-YACCPUNQ.js} +1 -1
  15. package/dist/cli-token-6AGEDJF4.js +14 -0
  16. package/dist/{client-2UJ63MVQ.js → client-VTJMUZ4O.js} +3 -3
  17. package/dist/{config-NCUGK6NS.js → config-2SDTLGOC.js} +3 -3
  18. package/dist/index.js +314 -197
  19. package/dist/metadata-JZ2OTWBK.js +420 -0
  20. package/dist/{model-SJSOZTRS.js → model-ZYMRN4VS.js} +2 -2
  21. package/dist/{raw-7NVWSVJP.js → raw-NGYHAL3F.js} +4 -4
  22. package/dist/{sync-GRVO4K3U.js → sync-JVLX6TGW.js} +3 -3
  23. package/dist/{te-agent-KZRIEN4N.js → te-agent-QPZTLHPH.js} +545 -21
  24. package/dist/{te-analysis-VAR4KUOK.js → te-analysis-WWX3Z6RP.js} +352 -52
  25. package/dist/te-audience-UXGHUVBB.js +599 -0
  26. package/dist/{te-common-WNCZB7R7.js → te-common-7XXH73MF.js} +5 -4
  27. package/dist/{te-community-JEEFXPB3.js → te-community-QKE67HR2.js} +5 -4
  28. package/dist/te-dataops-6W7NNYST.js +1841 -0
  29. package/dist/{te-engage-4XHCTS6I.js → te-engage-NCFAQFX3.js} +5 -4
  30. package/dist/{te-kb-B62KFP2A.js → te-kb-K5BQYUCM.js} +50 -26
  31. package/dist/{te-meta-EPZGQN56.js → te-meta-LJZBOSMO.js} +48 -24
  32. package/dist/{te-team-YY24VORI.js → te-team-DHK5R7MV.js} +5 -6
  33. package/package.json +3 -2
  34. package/skills/ae-agent/SKILL.md +103 -4
  35. package/skills/ae-analysis/SKILL.md +75 -21
  36. package/skills/ae-analysis/references/build_attribution_analysis_qp.md +62 -0
  37. package/skills/ae-analysis/references/build_cluster_definition.md +62 -0
  38. package/skills/ae-analysis/references/build_distribution_analysis_qp.md +67 -0
  39. package/skills/ae-analysis/references/build_event_analysis_qp.md +2 -0
  40. package/skills/ae-analysis/references/build_funnel_analysis_qp.md +2 -0
  41. package/skills/ae-analysis/references/build_heat_map_analysis_qp.md +54 -0
  42. package/skills/ae-analysis/references/build_interval_analysis_qp.md +60 -0
  43. package/skills/ae-analysis/references/build_path_analysis_qp.md +53 -0
  44. package/skills/ae-analysis/references/build_prop_analysis_qp.md +2 -0
  45. package/skills/ae-analysis/references/build_rank_list_analysis_qp.md +63 -0
  46. package/skills/ae-analysis/references/build_retention_analysis_qp.md +2 -0
  47. package/skills/ae-analysis/references/build_tag_definition.md +65 -0
  48. package/skills/ae-analysis/references/cancel_query.md +2 -3
  49. package/skills/ae-analysis/references/copy_dashboard.md +33 -0
  50. package/skills/ae-analysis/references/create_id_cluster.md +40 -0
  51. package/skills/ae-analysis/references/create_id_tag.md +39 -0
  52. package/skills/ae-analysis/references/delete_alert.md +27 -0
  53. package/skills/ae-analysis/references/delete_cluster.md +27 -0
  54. package/skills/ae-analysis/references/delete_dashboard.md +30 -0
  55. package/skills/ae-analysis/references/delete_metric.md +27 -0
  56. package/skills/ae-analysis/references/delete_report.md +27 -0
  57. package/skills/ae-analysis/references/delete_tag.md +27 -0
  58. package/skills/ae-analysis/references/drilldown_user_events.md +4 -4
  59. package/skills/ae-analysis/references/drilldown_users.md +3 -3
  60. package/skills/ae-analysis/references/freeze_dashboards.md +29 -0
  61. package/skills/ae-analysis/references/get_table_columns.md +11 -12
  62. package/skills/ae-analysis/references/list_cluster_members.md +4 -4
  63. package/skills/ae-analysis/references/list_clusters.md +5 -3
  64. package/skills/ae-analysis/references/list_dashboards.md +3 -3
  65. package/skills/ae-analysis/references/list_entities.md +1 -1
  66. package/skills/ae-analysis/references/list_events.md +7 -4
  67. package/skills/ae-analysis/references/list_metrics.md +5 -3
  68. package/skills/ae-analysis/references/list_properties.md +6 -4
  69. package/skills/ae-analysis/references/list_reports.md +3 -3
  70. package/skills/ae-analysis/references/list_spaces.md +27 -0
  71. package/skills/ae-analysis/references/list_tag_members.md +4 -4
  72. package/skills/ae-analysis/references/list_tags.md +4 -2
  73. package/skills/ae-analysis/references/move_dashboard.md +33 -0
  74. package/skills/ae-analysis/references/query_adhoc.md +2 -2
  75. package/skills/ae-analysis/references/query_bi_panel_data.md +2 -2
  76. package/skills/ae-analysis/references/query_dashboard_report_data.md +4 -4
  77. package/skills/ae-analysis/references/query_entity_details.md +4 -4
  78. package/skills/ae-analysis/references/query_event_details.md +3 -3
  79. package/skills/ae-analysis/references/query_report_data.md +37 -3
  80. package/skills/ae-analysis/references/update_id_cluster.md +36 -0
  81. package/skills/ae-analysis/references/update_id_tag.md +37 -0
  82. package/skills/ae-analysis/references/update_report.md +35 -0
  83. package/skills/ae-analysis-intent/SKILL.md +1 -1
  84. package/skills/ae-dataops/SKILL.md +54 -522
  85. package/skills/ae-dataops/references/dataops-flow-create.md +78 -75
  86. package/skills/ae-dataops/references/dataops-flow-monitor.md +58 -51
  87. package/skills/ae-dataops/references/dataops-integration.md +80 -41
  88. package/skills/ae-dataops/references/dataops-query.md +54 -53
  89. package/skills/ae-dataops/references/dataops-table.md +28 -59
  90. package/skills/ae-generate-tracking-code/SKILL.md +68 -31
  91. package/skills/ae-generate-tracking-code/references/snippet-delivery.md +26 -1
  92. package/skills/ae-generate-tracking-code/references/te-api.md +47 -164
  93. package/skills/ae-generate-tracking-plan/SKILL.md +109 -32
  94. package/skills/ae-generate-tracking-plan/references/te-api.md +57 -27
  95. package/skills/ae-metadata/SKILL.md +90 -0
  96. package/skills/ae-metadata/references/metadata_data_table_csv_delete.md +15 -0
  97. package/skills/ae-metadata/references/metadata_data_table_csv_write.md +29 -0
  98. package/skills/ae-metadata/references/metadata_data_table_download.md +17 -0
  99. package/skills/ae-metadata/references/metadata_data_table_get.md +24 -0
  100. package/skills/ae-metadata/references/metadata_data_table_list.md +27 -0
  101. package/skills/ae-metadata/references/metadata_data_table_property_bindings_update.md +17 -0
  102. package/skills/ae-metadata/references/metadata_data_table_sql_delete.md +15 -0
  103. package/skills/ae-metadata/references/metadata_data_table_sql_write.md +31 -0
  104. package/skills/ae-metadata/references/metadata_event_get.md +52 -0
  105. package/skills/ae-metadata/references/metadata_input_file_upload.md +29 -0
  106. package/skills/ae-metadata/references/metadata_property_dimension_table_bind_existing.md +27 -0
  107. package/skills/ae-metadata/references/metadata_property_dimension_table_create_and_bind_csv.md +30 -0
  108. package/skills/ae-metadata/references/metadata_property_get.md +54 -0
  109. package/dist/te-audience-KMKYI2YJ.js +0 -400
  110. package/dist/te-dataops-GD3XBYCS.js +0 -1830
@@ -92,14 +92,44 @@ After user responds, record to `meta.scenario` and generate `meta.plan_name`.
92
92
 
93
93
  ### Item 2 — Source Material + Business Dimension (combined)
94
94
 
95
- Ask: **"Choose your source material (up to 2):"**
95
+ Before asking, decide whether the current runtime is an agent sandbox. The agent may judge this from runtime context such as sandbox-provisioned `cli-token.json`, restricted filesystem access, or absence of the user's local files. Do not ask the user just to decide sandbox visibility.
96
96
 
97
- User can multi-select (max 2):
97
+ Product document and Codebase are local-material options. **Hide both options in sandbox environments**. When options are hidden, renumber the visible list contiguously from 1; never show skipped numbers.
98
98
 
99
- 1. **Product document** (local path, image file, or folder) — Extract events and properties from product docs; supports md/pdf/docx/URL/images (png/jpg/jpeg/webp)
100
- 2. **Detailed description** (conversational) — Describe app business flow, core features, user behaviors, monetization model, etc.
101
- 3. **Codebase** (local project path) — Analyze source code to extract events and properties
102
- 4. **Pre-built template** (built-in industry and game genre templates) — Select a built-in template (run `AE_LANG=<user_lang> ae-cli tracking plan list-templates` to see available templates)
99
+ If **not** in a sandbox environment, ask exactly:
100
+
101
+ ```text
102
+ Choose your source material (up to 2):
103
+
104
+ 1 - Product document (local path, image file, or folder; hidden in sandbox) — Extract events and properties from product docs; supports md/pdf/docx/URL/images (png/jpg/jpeg/webp)
105
+ 2 - Detailed description (conversational) — Describe app business flow, core features, user behaviors, monetization model, etc.
106
+ 3 - Codebase (local project path; hidden in sandbox) — Analyze source code to extract events and properties
107
+ 4 - Pre-built template (built-in industry and game genre templates) — Select a built-in template
108
+
109
+ Reply with number(s), e.g. 1 or 1,4. Select up to 2.
110
+ ```
111
+
112
+ If in a sandbox environment, ask exactly:
113
+
114
+ ```text
115
+ Choose your source material (up to 2):
116
+
117
+ 1 - Detailed description (conversational) — Describe app business flow, core features, user behaviors, monetization model, etc.
118
+ 2 - Pre-built template (built-in industry and game genre templates) — Select a built-in template
119
+
120
+ Reply with number(s), e.g. 1 or 1,2. Select up to 2.
121
+ ```
122
+
123
+ Do not rewrite this source material list as unnumbered bullets, cards, or prose. The user must be able to reply with the visible numbers.
124
+
125
+ User can multi-select (max 2). Interpret numbers by the **visible list shown to the user**, not by the non-sandbox canonical list.
126
+
127
+ Canonical source material options:
128
+
129
+ - **Product document** (local path, image file, or folder; hidden in sandbox) — Extract events and properties from product docs; supports md/pdf/docx/URL/images (png/jpg/jpeg/webp)
130
+ - **Detailed description** (conversational) — Describe app business flow, core features, user behaviors, monetization model, etc.
131
+ - **Codebase** (local project path; hidden in sandbox) — Analyze source code to extract events and properties
132
+ - **Pre-built template** (built-in industry and game genre templates) — Select a built-in template (run `AE_LANG=<user_lang> ae-cli tracking plan list-templates --json` to see available templates)
103
133
 
104
134
  Based on user selection, determine source material type and record to `meta.source_type`:
105
135
 
@@ -168,7 +198,7 @@ Platform validation: Use `business-dimension-mapping.md` Chapter 5 decision rule
168
198
 
169
199
  After business dimension confirmation, auto-detect matching templates based on app type:
170
200
  ```bash
171
- AE_LANG=<user_lang> ae-cli tracking plan list-templates
201
+ AE_LANG=<user_lang> ae-cli tracking plan list-templates --json
172
202
  ```
173
203
 
174
204
  Show matching templates to user for confirmation. Confirmed templates serve as baseline and participate in Phase 1 event merging.
@@ -189,6 +219,8 @@ Show matching templates to user for confirmation. Confirmed templates serve as b
189
219
 
190
220
  Ask: **"What is your client platform? (multi-select OK, e.g. Android + iOS) Will you integrate a server-side SDK?"**
191
221
 
222
+ After asking this Item 3 question, **stop and wait for the user's answer**. Do not display Item 4 in the same response.
223
+
192
224
  > **Language filter**: The following SDKs have Chinese-only documentation and are **visible to Chinese users only**: `Mini-program`, `Mini-game`, `OpenHarmony`, `LayaAir`, `Egret`, `Cocos2d-Lua`. Do not show these to non-Chinese users.
193
225
 
194
226
  **Client integration** (multi-select OK):
@@ -270,6 +302,14 @@ Record to `client_platform_languages`:
270
302
 
271
303
  `none` mode: Suitable for historical data import, batch data sync, third-party system integration, etc. Refine phase does not inject SDK auto-track events.
272
304
 
305
+ **Item 3 confirmation gate**:
306
+
307
+ After the user answers Item 3, normalize the SDK configuration and ask only the missing follow-up questions (for Android/iOS programming language or `Other` server language).
308
+
309
+ Then summarize the normalized SDK config and ask: **"Confirm this SDK integration config? Reply ok to continue to Item 4, or describe changes."**
310
+
311
+ Do not display Item 4 or ask identity questions until the user explicitly confirms this SDK integration config.
312
+
273
313
  ### Item 4 — User Identity System (visitor ID + account ID combined)
274
314
 
275
315
  Ask: **"What is the visitor ID generation strategy?"**
@@ -426,8 +466,8 @@ Draft
426
466
  Priority from low to high: **template → codebase → prd → chat → autotrack**
427
467
 
428
468
  - **template**: User-selected industry template (see "Template Lookup Convention" below) as baseline; each item marked `source: "template"`
429
- - Templates prefer `.md` distilled files (`tracking-plan-template/*.md`), fall back to `.xlsx`
430
- - Import command: `AE_LANG=<user_lang> ae-cli tracking code import-template --template <path> --out .ae-cli/draft.json`
469
+ - Templates are resolved by ae-cli from the ae-cli package root and user template directory
470
+ - Import command: `AE_LANG=<user_lang> ae-cli tracking code import-template --template-name "<template name>" --out .ae-cli/draft.json`
431
471
  - ⚠️ **Must validate immediately after template import** (see Phase 1.6); template content may not be fully correct
432
472
  - ⚠️ **Template content is in Chinese; must translate after import**: Read draft.json, translate `display_name`, `event_desc`, `event_tag`, and property `display_name`/`desc` to user's language, then write back. Only `event_name`, property `name`, `type` identifiers remain as-is.
433
473
  - ⚠️ **event_tag also needs translation**: `业务事件`→user's language (e.g. EN: `Business Event`), `系统事件`→user's language (e.g. EN: `System Event`; autotrack events are handled automatically by CLI, no need to re-translate)
@@ -601,21 +641,23 @@ Next: Phase 2 — Refine to confirm the plan.
601
641
  Run the following command to dynamically discover available templates:
602
642
 
603
643
  ```bash
604
- AE_LANG=<user_lang> ae-cli tracking plan list-templates
644
+ AE_LANG=<user_lang> ae-cli tracking plan list-templates --json
605
645
  ```
606
646
 
607
647
  **Language rules**: Template file names are in Chinese. When displaying to users, **must translate to user's current language**; **do NOT** include the original Chinese name (e.g. show only "Card Game v1", not "Card Game (卡牌游戏) v1").
608
648
 
649
+ Built-in templates are resolved by ae-cli from the ae-cli package root. User templates are resolved from the ae-cli user template directory. Do **not** manually construct `./tracking-plan-template/...` paths from the user's current workspace.
650
+
609
651
  Search directories in order:
610
652
 
611
- 1. `./tracking-plan-template/` — Project root (development)
612
- 2. `~/.ae-cli/templates/` — `ae-cli tracking` CLI user directory after installation (future default)
653
+ 1. `<ae-cli package root>/tracking-plan-template/` — bundled templates
654
+ 2. `~/.ae-cli/templates/` — user-provided template directory
613
655
 
614
656
  Each template prefers `.md` distilled file (if same-name `.md` exists, return md path; otherwise return xlsx path).
615
- Auto-detect format on import:
657
+ Display translated template names to the user, but keep the original `name` from the JSON result for import. Auto-detect format on import:
616
658
 
617
659
  ```bash
618
- AE_LANG=<user_lang> ae-cli tracking code import-template --template <path> --out .ae-cli/draft.json
660
+ AE_LANG=<user_lang> ae-cli tracking code import-template --template-name "<template name>" --out .ae-cli/draft.json
619
661
  ```
620
662
 
621
663
  ---
@@ -633,13 +675,22 @@ In order, one conversation round per segment:
633
675
  Per-segment flow:
634
676
 
635
677
  1. Display corresponding section of current draft
636
- 2. Ask **"Does this look correct? `ok` to proceed to next segment, or describe what to change"**
678
+ 2. Ask a segment-specific confirmation question. Always include the current segment number, current segment key, and next segment key:
679
+ ```text
680
+ Segment <n>/5 <segment_key> confirmed? Reply ok to continue to Segment <n+1>/5 <next_segment_key>, or describe changes.
681
+ ```
682
+ For Segment 5:
683
+ ```text
684
+ Segment 5/5 props confirmed? Reply ok to archive the plan and continue to Phase 3, or describe changes.
685
+ ```
637
686
  3. User gives natural language instructions → update `.ae-cli/draft.json` → re-run:
638
687
  ```bash
639
688
  AE_LANG=<user_lang> ae-cli tracking plan draft --in .ae-cli/draft.json --out .ae-cli/draft.xlsx
640
689
  ```
641
690
  4. User `ok` → proceed to next segment
642
691
 
692
+ `ok` is a refine state-machine input, not a repeated-message error. If the user replies `ok` multiple times in a row, advance exactly one segment per `ok` in order. Before each confirmation prompt, print the new segment heading first, so consecutive confirmations do not look like the same question repeated.
693
+
643
694
  User may say **"Go back to segment N"** at any time to jump to any segment (N = 1-5).
644
695
 
645
696
  ---
@@ -849,33 +900,59 @@ At the start of Phase 3, tell user:
849
900
  ```
850
901
  ## Phase 3 — Upload Preparation
851
902
  Next steps:
852
- 1. AE web address
853
- 2. Login to AE to get token
903
+ 1. Check active AE host and login status
904
+ 2. Login to AE to get token if needed
854
905
  3. AE project ID
855
906
  ```
856
907
 
857
- ### 3.1 Get AE Web Address
908
+ ### 3.1 Check Active AE Host and Login Status
858
909
 
859
- ❌ **Do NOT provide unconfirmed example URLs here.** Simply ask the user directly.
910
+ Do not ask for the AE web address first. ae-cli stores an active AE host, and auth commands can use it directly.
860
911
 
861
- Ask user: **"What is the AE web address?"**
912
+ First check current auth/host status:
862
913
 
863
- After user responds, save to `.ae-cli/draft.json` `meta.host` field.
914
+ ```bash
915
+ ae-cli auth status
916
+ ```
917
+
918
+ If an active host is configured, save that host to `.ae-cli/draft.json` `meta.host`. If `auth status` reports `authenticated: true`, skip login and continue to project ID.
919
+
920
+ Only if ae-cli reports no active host / no AE host configured, ask the user:
921
+
922
+ **"What is the AE web address?"**
923
+
924
+ After user responds, configure it and save the same value to `.ae-cli/draft.json` `meta.host`:
925
+
926
+ ```bash
927
+ ae-cli config set-host <host>
928
+ ```
929
+
930
+ If `auth status` reports unauthenticated, use the agent split-flow. Do **not** run blocking `ae-cli auth login` directly from an AI agent.
864
931
 
865
- Guide getting and saving token based on AE web address:
932
+ Step 1 request an authorization URL and return control to the user:
866
933
 
867
934
  ```bash
868
- ae-cli auth login --host <host>
935
+ ae-cli auth login --no-wait
936
+ ```
937
+
938
+ Show the returned `verification_url` to the user and ask them to complete authorization. Keep the returned `device_code` for the next step.
939
+
940
+ Step 2 — after the user says authorization is complete, finish login:
941
+
942
+ ```bash
943
+ ae-cli auth login --device-code <device_code>
869
944
  ae-cli auth status
870
945
  ```
871
946
 
947
+ Do not retry with `ae-cli auth login --host <host>` unless the previous command explicitly failed because no active host was configured. In that case, configure the host first, then restart the split-flow with `--no-wait`.
948
+
872
949
  Common error tips and self-recovery:
873
950
 
874
951
  | Error | Cause | What to Tell the User |
875
952
  |---|---|---|
876
- | `Chrome JS-from-AppleEvents disabled` | Chrome disabled AppleScript JS execution | Chrome menu View Developer Allow JavaScript from Apple Events, then retry |
877
- | `not_mac` | Not macOS | Manually set `export AE_TOKEN=<uuid>` (get from DevTools Application Local Storage `ACCESS_TOKEN`, strip quotes) |
878
- | `NO_TAB_FOUND` | Not logged into AE in Chrome | Open and login to TE in Chrome first, then retry |
953
+ | `Device authorize request failed` | The agent runtime cannot reach the authorization service | Report that no device code was created and include the exact error |
954
+ | `not_mac` | A legacy browser-token flow was attempted | Retry the split-flow device-code login; do not ask the user for browser tokens |
955
+ | `NO_TAB_FOUND` | A legacy browser-token flow was attempted | Retry the split-flow device-code login; do not ask the user to open Chrome |
879
956
 
880
957
  Token cached for 20 hours; same host avoids re-auth.
881
958
 
@@ -901,9 +978,11 @@ Checking project's existing plan...
901
978
  Before uploading, check if the project already has a tracking plan:
902
979
 
903
980
  ```bash
904
- AE_LANG=<user_lang> ae-cli tracking plan fetch --project <projectId> --host <host> > .ae-cli/existing-plan.json
981
+ AE_LANG=<user_lang> ae-cli tracking plan fetch --project <projectId> > .ae-cli/existing-plan.json
905
982
  ```
906
983
 
984
+ Do not add `--host` here unless the user explicitly provides a reachable override for this command. In agent sandboxes, ae-cli can resolve the request host from the sandbox-provisioned `cli-token.json`; passing a stale Kubernetes internal host can bypass that fallback.
985
+
907
986
  **Result assessment**:
908
987
  - File empty or command error `404` → project has no plan; upload directly
909
988
  - File has content → project has an existing plan; show summary + **conflict detection**
@@ -1008,12 +1087,10 @@ AE_LANG=<user_lang> ae-cli tracking plan upload --project <projectId> --xlsx .ae
1008
1087
  - **With `--replace`**: Delete existing project plan first then upload (when user chooses "Replace", or severe conflict switches to replace)
1009
1088
  - **Without `--replace`**: AE merge-by-name merge (no conflicts, or advisory only with user confirmation to append)
1010
1089
 
1011
- If CLI returns exit code 13 (language mismatch), the AE project language differs from xlsx language. Do NOT silently retry; must prompt user:
1012
- > "AE project language is {aeLang}, but current xlsx is {xlsxLang}. Switch AE language?"
1013
-
1014
- After user confirms, re-upload with `--switch-lang`:
1090
+ Upload language is controlled locally by `AE_LANG`, `--lang`, or `draft.meta.lang`. Do not call AE user language config APIs and do not use `--switch-lang`. If the xlsx language is wrong, regenerate the xlsx with the intended language before uploading:
1015
1091
  ```bash
1016
- AE_LANG=<user_lang> ae-cli tracking plan upload --project <projectId> --xlsx .ae-cli/draft.xlsx --draft .ae-cli/draft.json --switch-lang [--replace]
1092
+ AE_LANG=<user_lang> ae-cli tracking plan draft --in .ae-cli/draft.json --out .ae-cli/draft.xlsx
1093
+ AE_LANG=<user_lang> ae-cli tracking plan upload --project <projectId> --xlsx .ae-cli/draft.xlsx --draft .ae-cli/draft.json [--replace]
1017
1094
  ```
1018
1095
 
1019
1096
  On successful upload, prompt user to verify in AE Admin. **Provide the full URL** (tracking plan page URL format: `https://<host>/#/data/plan`).
@@ -1,23 +1,22 @@
1
- # AE Backend API (internal reference)
1
+ # AE Tracking Capability API (internal reference)
2
2
 
3
- > **Terminology**: 认证 = authentication | Token = bearer token from localStorage `ACCESS_TOKEN` | 端点 = endpoint | 抓包 = traffic capture | 埋点方案 = tracking plan | 上传 = upload | 删除 = delete | 查询 = query/fetch
3
+ > **Terminology**: authentication = CLI token | capability = gateway-registered operation | tracking plan = program | upload = save xlsx | delete = clear program | query/fetch = read program
4
4
 
5
- > This file is the implementation basis for `src/client.ts`, maintained for internal contributors.
5
+ > This file is the implementation basis for `src/core/tracking-client.ts`, maintained for internal contributors.
6
6
  > **Skill body should not reference this document** — skill users interact via CLI commands and do not need to know underlying endpoints.
7
7
  > xlsx format contract is in `xlsx-schema.md`, not here.
8
8
 
9
- Capture environment: `https://web-ta-demo.thinkingdata.cn`. If endpoints change, re-run the
10
- chrome-devtools capture flow from `docs/superpowers/plans/2026-04-15-ae-tracking-skill.md` Task 3.
9
+ The AE CLI must call common-service through capability gateway URLs under `/api/cli/`.
10
+ The legacy common-service endpoints are wrapped server-side by these capabilities and must not be
11
+ called directly from `ae-cli`.
11
12
 
12
- ## 认证
13
+ ## Authentication
13
14
 
14
- ### Token
15
- - localStorage key:`ACCESS_TOKEN`
16
- - 存储形态:**JSON 编码字符串**(带双引号),使用前须 `replace(/^["']|["']$/g, '')`
15
+ All capability requests use the CLI token chain:
17
16
 
18
- ### 两种传 token 方式(按端点区分)
19
- - **GET/JSON 类接口**:Header `authorization: bearer <token>`(全小写)
20
- - **Excel 上传接口**:**form field `access_token`**,裸 UUID,**不用** Authorization header
17
+ - Header: `cli-token: <token>`
18
+ - Do not send `authorization: bearer ...`.
19
+ - Do not send `access_token` form fields.
21
20
 
22
21
  ## 响应统一包装
23
22
 
@@ -25,16 +24,22 @@ chrome-devtools capture flow from `docs/superpowers/plans/2026-04-15-ae-tracking
25
24
  { "return_code": 0, "return_message": "success", "showStackMessage": false, "data": ... }
26
25
  ```
27
26
  - `return_code === 0` 为成功;非 0 抛错,取 `return_message`
28
- - 某些端点(如 `excel-save` / 空项目 `query`)成功时无 `data`
27
+ - Empty project query may return no `data`.
29
28
 
30
- ## 端点
29
+ ## Capabilities
31
30
 
32
- ### 1. GET `/v1/ta/bury/manage/program/query`
31
+ ### 1. `track.program.query`
33
32
 
34
33
  获取项目唯一的埋点方案。
35
34
 
36
- - Query:`projectId` 必填 number
37
- - Header:`authorization: bearer <token>`
35
+ - Method: `POST`
36
+ - URL: `/api/cli/analysis/v1/capabilities/track.program.query/execute`
37
+ - Input:
38
+
39
+ ```json
40
+ { "project_id": 1603 }
41
+ ```
42
+
38
43
  - Response `data` 结构(事件池 / 事件属性池 / 公共属性 / 用户属性):
39
44
 
40
45
  ```jsonc
@@ -55,21 +60,46 @@ chrome-devtools capture flow from `docs/superpowers/plans/2026-04-15-ae-tracking
55
60
 
56
61
  空项目:`data` 不存在,直接 `{ return_code: 0, return_message: "success" }`。
57
62
 
58
- ### 2. GET `/v1/ta/bury/manage/program/delete?projectId=<id>`
63
+ ### 2. `track.program.delete`
59
64
 
60
65
  一次清空整个项目的方案(事件 / 事件属性 / 公共属性 / 用户属性)。
61
66
 
62
- ### 3. POST `/v1/ta/bury/manage/program/excel-save`
67
+ - Method: `POST`
68
+ - URL: `/api/cli/analysis/v1/capabilities/track.program.delete/execute`
69
+ - Input:
70
+
71
+ ```json
72
+ { "project_id": 1603 }
73
+ ```
74
+
75
+ ### 3. `track.program.excel_save`
63
76
 
64
77
  批量上传 xlsx。
65
78
 
66
- - Content-Type:`multipart/form-data`
67
- - Form fields(全必填):
68
- - `file` xlsx 二进制
69
- - `projectId` — 文本
70
- - `access_token` — 文本,裸 UUID
71
- - **无** Authorization header
72
- - Response:`{ return_code: 0, return_message: "success" }`(无 data
79
+ Upload is a two-step capability-gateway flow:
80
+
81
+ 1. Upload the xlsx as an input file.
82
+
83
+ - Method: `POST`
84
+ - URL: `/api/cli/analysis/v1/input-files`
85
+ - Content-Type: `multipart/form-data`
86
+ - Form fields:
87
+ - `project_id`
88
+ - `purpose`: `track.program.xlsx`
89
+ - `file`: xlsx binary
90
+ - Response includes `input_file_id`.
91
+
92
+ 2. Execute the save capability.
93
+
94
+ - Method: `POST`
95
+ - URL: `/api/cli/analysis/v1/capabilities/track.program.excel_save/execute`
96
+ - Input:
97
+
98
+ ```json
99
+ { "project_id": 1603, "input_file_id": "..." }
100
+ ```
101
+
102
+ - Response: `{ return_code: 0, return_message: "success" }` on success.
73
103
 
74
104
  **合并语义**:对事件走 **merge-by-name**(同名不覆盖、新名新增)。若要完全替换,
75
105
  必须先调 `delete` 端点清空再上传。
@@ -96,5 +126,5 @@ chrome-devtools capture flow from `docs/superpowers/plans/2026-04-15-ae-tracking
96
126
 
97
127
  ## v2(暂未实现)
98
128
 
99
- - UI「逐个添加」通向单事件 CRUD 接口(`POST /v1/ta/bury/manage/event/*` 族),v1 excel-save 统一入口
129
+ - UI「逐个添加」通向单事件 CRUD 接口,v1 走 `track.program.excel_save` 统一入口
100
130
  - 列项目、校验错误响应等见 plan 文档的"未抓端点"清单
@@ -0,0 +1,90 @@
1
+ ---
2
+ name: ae-metadata
3
+ version: 1.0.0
4
+ description: "AE/TE metadata capability-gateway CLI: metadata event/property detail, metadata data-table management, input-file upload, and property dimension-table binding. Use for ae-cli metadata commands backed by /api/cli/metadata/v1. Must read references before composing commands; command/flags use kebab-case while gateway input keeps snake_case. Never guess project_id, event/property names, input_file_id, or data_table_id."
5
+ ---
6
+
7
+ # ae-metadata
8
+
9
+ Capability-gateway domain **`metadata`** — REST via `/api/cli/metadata/v1/...`, auth header **`cli-token`**.
10
+
11
+ Parallel to **`ae-analysis`** (MCP `analysis_meta` for metadata lists/governance). Use **this skill** for gateway-backed metadata detail and data-table/dimension-table operations; use **`ae-analysis`** for MCP metadata list/search, metrics, virtual create, and batch edit.
12
+
13
+ ## Global AE CLI Rules
14
+
15
+ | Parameter | Description |
16
+ |---|---|
17
+ | `--format <json\|table>` | Output format. Default JSON. |
18
+ | `--jq <expr>` | jq filter on JSON output. |
19
+ | `--host <url>` | Override active AE host, e.g. `ae-cli metadata event get --host <url> ...`. |
20
+ | `--dry-run` | Validate input against gateway schema without executing. |
21
+
22
+ Output and errors:
23
+ - Success: JSON envelope (default).
24
+ - Failure: `{ "ok": false, "error": { "type", "message", "hint" } }`, non-zero exit.
25
+
26
+ Safety:
27
+ - Read-only commands can run directly after IDs/names are verified.
28
+ - Write commands (`data-table *-write`, `*-delete`, `property-bindings-update`, dimension-table bind/create, `input-file upload`) require `--yes` for non-dry-run execution.
29
+ - **Before any command**, read the matching `references/<name>.md` (filename = command with spaces → underscores, e.g. `metadata event get` → `metadata_event_get.md`).
30
+ - Never invent `project_id`, event/property names, `input_file_id`, or `data_table_id`. Discover names via `ae-analysis` and data table IDs via `metadata data-table list`.
31
+
32
+ ## When to Use
33
+
34
+ Switch to **`ae-metadata`** when the user needs:
35
+
36
+ - Full detail for **one** super-event (incl. virtual event `definition`)
37
+ - Full detail for **one** super-property (incl. virtual property `definition`)
38
+ - Metadata data-table list/get/create/update/delete/download
39
+ - Upload a local file to get `input_file_id`
40
+ - Bind an existing data table to a property, or create a CSV dimension table and bind it
41
+
42
+ Stay on **`ae-analysis`** for: metadata event/property/metric list/search, metric CRUD, batch metadata, virtual create, project config, tracking plans.
43
+
44
+ ## Command Format
45
+
46
+ ```bash
47
+ ae-cli metadata <resource> <action> [options]
48
+ ae-cli metadata property <dimension-table-action> [options]
49
+ ```
50
+
51
+ - Commands and flags use **kebab-case**: `data-table`, `input-file`, `dimension-table`, `--project-id`, `--data-table-id`.
52
+ - Gateway `input` body fields remain **snake_case** (`project_id`, `event_name`, …); ae-cli maps flags automatically.
53
+
54
+ ## PROJECT_ID_GATE
55
+
56
+ Same rules as `ae-analysis`: reuse verified project context in one conversation; otherwise `ae-cli analysis_common +list_projects` (or `ae-analysis` skill) to resolve `project_id`.
57
+
58
+ ## Commands (13)
59
+
60
+ | User command | Capability id | Reference |
61
+ |---|---|---|
62
+ | `metadata event get` | `metadata.event.get` | [metadata_event_get.md](references/metadata_event_get.md) |
63
+ | `metadata property get` | `metadata.property.get` | [metadata_property_get.md](references/metadata_property_get.md) |
64
+ | `metadata input-file upload` | `POST /input-files` | [metadata_input_file_upload.md](references/metadata_input_file_upload.md) |
65
+ | `metadata data-table list` | `metadata.data_table.list` | [metadata_data_table_list.md](references/metadata_data_table_list.md) |
66
+ | `metadata data-table get` | `metadata.data_table.get` | [metadata_data_table_get.md](references/metadata_data_table_get.md) |
67
+ | `metadata data-table csv-write` | `metadata.data_table.csv_write` | [metadata_data_table_csv_write.md](references/metadata_data_table_csv_write.md) |
68
+ | `metadata data-table sql-write` | `metadata.data_table.sql_write` | [metadata_data_table_sql_write.md](references/metadata_data_table_sql_write.md) |
69
+ | `metadata data-table csv-delete` | `metadata.data_table.csv_delete` | [metadata_data_table_csv_delete.md](references/metadata_data_table_csv_delete.md) |
70
+ | `metadata data-table sql-delete` | `metadata.data_table.sql_delete` | [metadata_data_table_sql_delete.md](references/metadata_data_table_sql_delete.md) |
71
+ | `metadata data-table download` | `metadata.data_table.download` | [metadata_data_table_download.md](references/metadata_data_table_download.md) |
72
+ | `metadata data-table property-bindings-update` | `metadata.data_table.property_bindings_update` | [metadata_data_table_property_bindings_update.md](references/metadata_data_table_property_bindings_update.md) |
73
+ | `metadata property bind-existing-dimension-table` | `metadata.property.bind_existing_dimension_table` | [metadata_property_dimension_table_bind_existing.md](references/metadata_property_dimension_table_bind_existing.md) |
74
+ | `metadata property create-and-bind-csv-dimension-table` | `metadata.property.create_and_bind_csv_dimension_table` | [metadata_property_dimension_table_create_and_bind_csv.md](references/metadata_property_dimension_table_create_and_bind_csv.md) |
75
+
76
+ ## Quick Verification
77
+
78
+ ```bash
79
+ ae-cli metadata --help
80
+ ae-cli metadata event get --help
81
+ ae-cli metadata property get --help
82
+ ae-cli metadata data-table list --help
83
+ ae-cli metadata event get --project-id 1 --event-name <name> --dry-run
84
+ ae-cli metadata data-table list --project-id 1 --dry-run
85
+ ```
86
+
87
+ ## Related Skills
88
+
89
+ - **`ae-analysis`**: `analysis_meta +list_events` / `+list_properties` to discover names before detail get.
90
+ - **Dev workflow**: `.cursor/skills/te-cli-capability-gateway` — inspect gateway schema when adding new metadata capabilities.
@@ -0,0 +1,15 @@
1
+ # metadata data-table csv-delete
2
+
3
+ > Capability id: `metadata.data_table.csv_delete` · Domain: `metadata`.
4
+
5
+ ```bash
6
+ ae-cli metadata data-table csv-delete --project-id <project_id> --data-table-id <id> --yes
7
+ ae-cli metadata data-table csv-delete --project-id <project_id> --data-table-id <id> --dry-run
8
+ ```
9
+
10
+ | Parameter | Required | Description |
11
+ |---|---|---|
12
+ | `--project-id` / `-p` | Yes | Numeric project ID. |
13
+ | `--data-table-id` | Yes | CSV-backed data table ID. |
14
+
15
+ This is a write command. Confirm the table with `metadata data-table get` before deleting.
@@ -0,0 +1,29 @@
1
+ # metadata data-table csv-write
2
+
3
+ > Capability id: `metadata.data_table.csv_write` · Domain: `metadata`.
4
+
5
+ ## Command
6
+
7
+ ```bash
8
+ ae-cli metadata data-table csv-write --project-id <project_id> --operation create --input-file-id <input_file_id> --data-table-name <name> --columns '<columns_json>' --yes
9
+ ae-cli metadata data-table csv-write --project-id <project_id> --operation incremental_update --data-table-id <id> --input-file-id <input_file_id> --yes
10
+ ae-cli metadata data-table csv-write --project-id <project_id> --operation replace_update --data-table-id <id> --input-file-id <input_file_id> --yes
11
+ ```
12
+
13
+ ## Parameters
14
+
15
+ | Parameter | Required | Description |
16
+ |---|---|---|
17
+ | `--project-id` / `-p` | Yes | Numeric project ID. |
18
+ | `--operation` | Yes | `create`, `incremental_update`, or `replace_update`. |
19
+ | `--input-file-id` | Yes | ID returned by `metadata input-file upload`. |
20
+ | `--data-table-id` | For updates | Existing data table ID. |
21
+ | `--data-table-name` | For create | Technical data table name. |
22
+ | `--display-name` | No | Human-readable table name. |
23
+ | `--description` | No | Table description. |
24
+ | `--columns` | No | Column definitions JSON array. |
25
+
26
+ ## Decision Rules
27
+
28
+ - Upload the CSV first with `metadata input-file upload --purpose data_table.csv`.
29
+ - This is a write command; use `--dry-run` before non-dry-run and pass `--yes` when executing.
@@ -0,0 +1,17 @@
1
+ # metadata data-table download
2
+
3
+ > Capability id: `metadata.data_table.download` · Domain: `metadata`.
4
+
5
+ ```bash
6
+ ae-cli metadata data-table download --project-id <project_id> --data-table-id <id>
7
+ ae-cli metadata data-table download --project-id <project_id> --data-table-id <id> --request-id cli_0123456789abcdef0123456789abcdef --timeout-seconds 120
8
+ ```
9
+
10
+ | Parameter | Required | Description |
11
+ |---|---|---|
12
+ | `--project-id` / `-p` | Yes | Numeric project ID. |
13
+ | `--data-table-id` | Yes | Data table ID. |
14
+ | `--request-id` | No | Optional `cli_<32 lowercase hex>` request ID. |
15
+ | `--timeout-seconds` | No | Timeout in seconds, 1 to 7200. |
16
+
17
+ Use this command when the user needs an exported data-table artifact.
@@ -0,0 +1,24 @@
1
+ # metadata data-table get
2
+
3
+ > Capability id: `metadata.data_table.get` · Domain: `metadata`.
4
+
5
+ ## Command
6
+
7
+ ```bash
8
+ ae-cli metadata data-table get --project-id <project_id> --data-table-id <id>
9
+ ae-cli metadata data-table get --project-id <project_id> --data-table-id <id> --include-preview true
10
+ ```
11
+
12
+ ## Parameters
13
+
14
+ | Parameter | Required | Description |
15
+ |---|---|---|
16
+ | `--project-id` / `-p` | Yes | Numeric project ID. |
17
+ | `--data-table-id` | Yes | Data table ID from `metadata data-table list`. |
18
+ | `--include-preview` | No | Include preview rows when true. |
19
+
20
+ ## Request Body
21
+
22
+ ```json
23
+ { "project_id": 1, "data_table_id": 42, "include_preview": true }
24
+ ```
@@ -0,0 +1,27 @@
1
+ # metadata data-table list
2
+
3
+ > Capability id: `metadata.data_table.list` · Domain: `metadata`.
4
+
5
+ ## Command
6
+
7
+ ```bash
8
+ ae-cli metadata data-table list --project-id <project_id>
9
+ ae-cli metadata data-table list --project-id <project_id> --dry-run
10
+ ```
11
+
12
+ ## Parameters
13
+
14
+ | Parameter | Required | Description |
15
+ |---|---|---|
16
+ | `--project-id` / `-p` | Yes | Numeric project ID. |
17
+
18
+ ## Request Body
19
+
20
+ ```json
21
+ { "project_id": 1 }
22
+ ```
23
+
24
+ ## Decision Rules
25
+
26
+ - Use this command to discover `data_table_id` before get, delete, download, or property binding.
27
+ - If the list is empty, do not invent IDs; create/upload a table first or ask for the target table.
@@ -0,0 +1,17 @@
1
+ # metadata data-table property-bindings-update
2
+
3
+ > Capability id: `metadata.data_table.property_bindings_update` · Domain: `metadata`.
4
+
5
+ ```bash
6
+ ae-cli metadata data-table property-bindings-update --project-id <project_id> --data-table-id <id> --bind-properties '<bind_json>' --yes
7
+ ae-cli metadata data-table property-bindings-update --project-id <project_id> --data-table-id <id> --unbind-properties '<unbind_json>' --yes
8
+ ```
9
+
10
+ | Parameter | Required | Description |
11
+ |---|---|---|
12
+ | `--project-id` / `-p` | Yes | Numeric project ID. |
13
+ | `--data-table-id` | Yes | Data table ID. |
14
+ | `--bind-properties` | No | Properties to bind JSON array. Each item includes `property_name` and `property_scope`. |
15
+ | `--unbind-properties` | No | Properties to unbind JSON array. Each item includes `property_name` and `property_scope`. |
16
+
17
+ This is a write command. Use the direct property dimension-table commands when binding a single property is the user-facing goal.
@@ -0,0 +1,15 @@
1
+ # metadata data-table sql-delete
2
+
3
+ > Capability id: `metadata.data_table.sql_delete` · Domain: `metadata`.
4
+
5
+ ```bash
6
+ ae-cli metadata data-table sql-delete --project-id <project_id> --data-table-id <id> --yes
7
+ ae-cli metadata data-table sql-delete --project-id <project_id> --data-table-id <id> --dry-run
8
+ ```
9
+
10
+ | Parameter | Required | Description |
11
+ |---|---|---|
12
+ | `--project-id` / `-p` | Yes | Numeric project ID. |
13
+ | `--data-table-id` | Yes | SQL-backed data table ID. |
14
+
15
+ This is a write command. Confirm the table with `metadata data-table get` before deleting.