@thinkingai/ae-cli 6.1.24 → 6.1.26

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 (195) hide show
  1. package/README.md +35 -10
  2. package/README.zh.md +32 -10
  3. package/bin/ae-cli.js +6 -1
  4. package/cli-installation-guide.md +91 -0
  5. package/dist/{auth-XZNXFRJS.js → auth-YHMC3GDH.js} +168 -10
  6. package/dist/automation-NWWVLWG2.js +459 -0
  7. package/dist/{capability-FYTU3X6L.js → capability-3QLLIVFB.js} +11 -6
  8. package/dist/chunk-4655PUNX.js +43 -0
  9. package/dist/{chunk-4NRCTUZJ.js → chunk-5XJYLEVC.js} +4 -4
  10. package/dist/{chunk-JOCDD4ON.js → chunk-7QXISROD.js} +1 -1
  11. package/dist/{chunk-EQ255HKO.js → chunk-AP7YP2NX.js} +2 -2
  12. package/dist/{chunk-DVMLWQD4.js → chunk-CT7QDJS6.js} +2 -2
  13. package/dist/chunk-D6ACFILC.js +56 -0
  14. package/dist/{chunk-HFGZGYCG.js → chunk-EOYSKMXN.js} +264 -10
  15. package/dist/{chunk-57RRFUEZ.js → chunk-FMNNGNYO.js} +43 -8
  16. package/dist/{chunk-7XGFSUOM.js → chunk-GIK6EDUG.js} +291 -84
  17. package/dist/chunk-HVHR4SCP.js +133 -0
  18. package/dist/{chunk-CCS66K4K.js → chunk-KAEHZZH4.js} +3 -3
  19. package/dist/{chunk-DX5CDO34.js → chunk-KFNMQTZI.js} +580 -214
  20. package/dist/{chunk-HBGADCKA.js → chunk-PLE722AJ.js} +28 -11
  21. package/dist/chunk-RK6GLDGI.js +27 -0
  22. package/dist/{chunk-V2NUHPXF.js → chunk-S6M42KND.js} +1 -1
  23. package/dist/{chunk-7FTTULED.js → chunk-UQ77JXYH.js} +7 -3
  24. package/dist/{chunk-MAPZ7VB6.js → chunk-WNGFSIOB.js} +20 -1
  25. package/dist/{chunk-VYXXOKYS.js → chunk-XCHAYMSF.js} +7 -4
  26. package/dist/{community-report-client-CU22W53K.js → community-report-client-PEERQCX2.js} +1 -1
  27. package/dist/{config-XO3LI3SA.js → config-AHPMEW5A.js} +25 -6
  28. package/dist/context-YAE3QXP3.js +136 -0
  29. package/dist/{data-integration-HNGUKFIC.js → data-integration-HESZET7E.js} +6 -6
  30. package/dist/index.js +167 -53
  31. package/dist/{local-data-upload-client-GTRIT64F.js → local-data-upload-client-TWMHFLUA.js} +1 -1
  32. package/dist/memory-62BJOULV.js +580 -0
  33. package/dist/{metadata-DI5BMYFU.js → metadata-C7CEDHOJ.js} +7 -7
  34. package/dist/{model-RNPQXIBI.js → model-SBV2JFJI.js} +9 -5
  35. package/dist/{personal-semantic-preference-5C3WUXFI.js → personal-semantic-preference-QECDPHND.js} +119 -11
  36. package/dist/project-semantic-Z4QAMBWF.js +356 -0
  37. package/dist/{sync-O45NXEQY.js → sync-SU33KYX7.js} +12 -8
  38. package/dist/{te-agent-K5MSPNHJ.js → te-agent-F5QBZSQA.js} +423 -494
  39. package/dist/{te-analysis-AISWCOOZ.js → te-analysis-2ECAAIFK.js} +1227 -154
  40. package/dist/{te-community-4OYU3BDA.js → te-community-PFLDLPP4.js} +3 -3
  41. package/dist/{te-dataops-NFIPB6FX.js → te-dataops-FOQSRIAZ.js} +644 -276
  42. package/dist/{te-engage-BAM3GBFX.js → te-engage-QKUGIWSR.js} +6 -6
  43. package/dist/{te-experiment-GUTZXZ5Z.js → te-experiment-26PXR2UO.js} +6 -6
  44. package/dist/{te-kb-3TS73NO6.js → te-kb-MHDOST62.js} +666 -244
  45. package/dist/{te-system-STMHLS5J.js → te-system-J2FQF5ER.js} +6 -6
  46. package/dist/{te-team-3I5AOX3N.js → te-team-5UOZPTU3.js} +6 -6
  47. package/dist/things-VPPXXLHB.js +1091 -0
  48. package/dist/{update-RZXLPCRH.js → update-EEUTEI6R.js} +59 -51
  49. package/dist/workspace-O3EEIYQM.js +554 -0
  50. package/package.json +30 -11
  51. package/skills/ae-agent/SKILL.md +95 -140
  52. package/skills/ae-agent/references/add-model.md +1 -1
  53. package/skills/ae-agent/references/create-agent.md +1 -1
  54. package/skills/ae-agent/references/find-archived-conversations.md +12 -5
  55. package/skills/ae-agent/references/get-agent.md +1 -1
  56. package/skills/ae-agent/references/list-agents.md +2 -2
  57. package/skills/ae-agent/references/list-models.md +2 -2
  58. package/skills/ae-agent/references/notification.md +40 -0
  59. package/skills/ae-agent/references/restore-conversation.md +3 -1
  60. package/skills/ae-analysis/SKILL.md +55 -23
  61. package/skills/ae-analysis/references/adhoc_export.md +1 -1
  62. package/skills/ae-analysis/references/adhoc_run.md +1 -1
  63. package/skills/ae-analysis/references/agent_review_submit_to_page.md +2 -0
  64. package/skills/ae-analysis/references/ai_models/event.md +6 -1
  65. package/skills/ae-analysis/references/ai_models/funnel.md +12 -4
  66. package/skills/ae-analysis/references/ai_models/heat_map.md +23 -0
  67. package/skills/ae-analysis/references/ai_models/interval.md +24 -0
  68. package/skills/ae-analysis/references/ai_models/path.md +20 -0
  69. package/skills/ae-analysis/references/ai_models/prop_analysis.md +2 -0
  70. package/skills/ae-analysis/references/ai_models/rank_list.md +30 -0
  71. package/skills/ae-analysis/references/ai_models/retention.md +45 -1
  72. package/skills/ae-analysis/references/ai_models/revenue.md +20 -2
  73. package/skills/ae-analysis/references/ai_models/session.md +76 -0
  74. package/skills/ae-analysis/references/ai_models/tag.md +2 -0
  75. package/skills/ae-analysis/references/ai_models.md +100 -3
  76. package/skills/ae-analysis/references/analysis_data_retrieval.md +4 -0
  77. package/skills/ae-analysis/references/analysis_drilldown_contract.md +4 -1
  78. package/skills/ae-analysis/references/asset_batch_info_export.md +10 -0
  79. package/skills/ae-analysis/references/asset_batch_sql_export.md +13 -1
  80. package/skills/ae-analysis/references/asset_export.md +12 -1
  81. package/skills/ae-analysis/references/asset_list.md +1 -0
  82. package/skills/ae-analysis/references/asset_search.md +11 -5
  83. package/skills/ae-analysis/references/bi_panel_list.md +1 -1
  84. package/skills/ae-analysis/references/catalog_list.md +1 -1
  85. package/skills/ae-analysis/references/collaboration.md +48 -0
  86. package/skills/ae-analysis/references/command_index.md +29 -19
  87. package/skills/ae-analysis/references/dashboard_list.md +4 -4
  88. package/skills/ae-analysis/references/dashboard_move.md +21 -0
  89. package/skills/ae-analysis/references/dashboard_report_add.md +2 -0
  90. package/skills/ae-analysis/references/dashboard_report_data_export.md +2 -0
  91. package/skills/ae-analysis/references/dashboard_report_get.md +19 -0
  92. package/skills/ae-analysis/references/dashboard_report_update.md +27 -0
  93. package/skills/ae-analysis/references/dashboard_update.md +1 -1
  94. package/skills/ae-analysis/references/drilldown_session_details_run.md +41 -0
  95. package/skills/ae-analysis/references/event_export.md +3 -1
  96. package/skills/ae-analysis/references/event_report_presentation.md +76 -0
  97. package/skills/ae-analysis/references/feedback_submit.md +37 -0
  98. package/skills/ae-analysis/references/governance_recommendation_auto_review.md +77 -0
  99. package/skills/ae-analysis/references/governance_recommendation_export.md +11 -0
  100. package/skills/ae-analysis/references/metadata_resolution.md +18 -3
  101. package/skills/ae-analysis/references/metric_export.md +3 -1
  102. package/skills/ae-analysis/references/metric_list.md +1 -1
  103. package/skills/ae-analysis/references/operation_record_export.md +10 -0
  104. package/skills/ae-analysis/references/personal_semantic_preference_add.md +2 -2
  105. package/skills/ae-analysis/references/personal_semantic_preference_get.md +4 -4
  106. package/skills/ae-analysis/references/personal_semantic_preference_list.md +4 -4
  107. package/skills/ae-analysis/references/personal_semantic_preference_review.md +9 -0
  108. package/skills/ae-analysis/references/personal_semantic_preference_review_list.md +7 -0
  109. package/skills/ae-analysis/references/personal_semantic_preference_submit.md +7 -0
  110. package/skills/ae-analysis/references/project_semantic_knowledge_wiki.md +91 -32
  111. package/skills/ae-analysis/references/project_semantic_knowledge_wiki_plan_schema.md +99 -1
  112. package/skills/ae-analysis/references/property_export.md +3 -1
  113. package/skills/ae-analysis/references/report_create.md +18 -4
  114. package/skills/ae-analysis/references/report_data_export.md +6 -0
  115. package/skills/ae-analysis/references/report_get.md +7 -1
  116. package/skills/ae-analysis/references/report_list.md +5 -5
  117. package/skills/ae-analysis/references/report_update.md +21 -4
  118. package/skills/ae-analysis/references/sql_table_columns.md +4 -4
  119. package/skills/ae-analysis/references/sql_table_list.md +5 -5
  120. package/skills/ae-analysis/references/system_query_monitor_overview.md +2 -0
  121. package/skills/ae-analysis/references/system_query_task_cancel.md +2 -0
  122. package/skills/ae-analysis/references/system_query_task_export.md +6 -2
  123. package/skills/ae-analysis/references/system_query_task_get.md +2 -0
  124. package/skills/ae-analysis/references/system_query_task_list.md +7 -3
  125. package/skills/ae-analysis/references/system_query_task_options.md +2 -2
  126. package/skills/ae-analysis/references/system_query_task_realtime_list.md +15 -0
  127. package/skills/ae-analysis/references/user_cluster_models.md +8 -0
  128. package/skills/ae-analysis/references/user_tag_create.md +7 -1
  129. package/skills/ae-analysis/references/user_tag_get.md +1 -1
  130. package/skills/ae-analysis/references/user_tag_models.md +20 -2
  131. package/skills/ae-analysis/references/user_tag_refresh.md +1 -1
  132. package/skills/ae-analysis/references/user_tag_update.md +2 -2
  133. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-empty-skeleton.mjs +105 -0
  134. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/build-project-semantic-wiki.mjs +669 -29
  135. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/company-kb.mjs +21 -8
  136. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-rules.md +28 -10
  137. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/default-compile-schema.md +66 -0
  138. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/generate-build-ir.mjs +285 -24
  139. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/package-wiki-source-zip.mjs +262 -30
  140. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/plan-kb-source-sync.mjs +1 -1
  141. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/precompiled-source.mjs +46 -2
  142. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/prepare-compile-schema.mjs +64 -0
  143. package/skills/ae-analysis/scripts/project-semantic-knowledge-wiki/refresh-state-parts.mjs +91 -0
  144. package/skills/ae-automation/SKILL.md +16 -0
  145. package/skills/ae-automation/references/cli.md +53 -0
  146. package/skills/ae-automation/references/command_index.md +17 -0
  147. package/skills/ae-capability/SKILL.md +73 -2
  148. package/skills/ae-capability/references/collaboration.md +48 -0
  149. package/skills/ae-community/SKILL.md +5 -1
  150. package/skills/ae-community/references/collaboration.md +48 -0
  151. package/skills/ae-current-context/SKILL.md +3 -2
  152. package/skills/ae-data-integration/SKILL.md +4 -0
  153. package/skills/ae-data-integration/references/collaboration.md +48 -0
  154. package/skills/ae-dataops/SKILL.md +54 -74
  155. package/skills/ae-dataops/references/collaboration.md +48 -0
  156. package/skills/ae-dataops/references/dataops-backfill.md +23 -18
  157. package/skills/ae-dataops/references/dataops-flow-create.md +74 -23
  158. package/skills/ae-dataops/references/dataops-flow-monitor.md +45 -13
  159. package/skills/ae-dataops/references/dataops-integration.md +57 -30
  160. package/skills/ae-dataops/references/dataops-query.md +21 -4
  161. package/skills/ae-dataops/references/dataops-table.md +143 -11
  162. package/skills/ae-engage/SKILL.md +21 -6
  163. package/skills/ae-engage/references/channel-mgmt.md +3 -3
  164. package/skills/ae-engage/references/collaboration.md +48 -0
  165. package/skills/ae-engage/references/scene-config-channel.md +4 -4
  166. package/skills/ae-generate-tracking-plan/SKILL.md +4 -0
  167. package/skills/ae-generate-tracking-plan/references/collaboration.md +48 -0
  168. package/skills/ae-kb/SKILL.md +70 -12
  169. package/skills/ae-kb/references/analysis-workflow.md +73 -36
  170. package/skills/ae-kb/references/collaboration.md +48 -0
  171. package/skills/ae-kb/references/query-workflow.md +67 -33
  172. package/skills/ae-kb/references/schema-import.md +32 -0
  173. package/skills/ae-kb/references/source-mutations.md +6 -4
  174. package/skills/ae-kb/references/text-sources.md +53 -0
  175. package/skills/ae-kb-discovery/SKILL.md +8 -3
  176. package/skills/ae-kb-discovery/references/collaboration.md +48 -0
  177. package/skills/ae-metadata/SKILL.md +20 -12
  178. package/skills/ae-metadata/references/collaboration.md +48 -0
  179. package/skills/ae-team/SKILL.md +23 -17
  180. package/skills/ae-things/SKILL.md +85 -0
  181. package/skills/ae-things/references/cli.md +103 -0
  182. package/skills/ae-things-progress/SKILL.md +43 -0
  183. package/skills/ae-things-review/SKILL.md +42 -0
  184. package/skills/ae-workspace/SKILL.md +43 -0
  185. package/skills/ae-workspace/references/commands.md +51 -0
  186. package/dist/chunk-E2JKXMVO.js +0 -29
  187. package/dist/context-IFJI3LIT.js +0 -46
  188. package/dist/memory-QGPSNCQS.js +0 -892
  189. package/dist/project-semantic-3LF6Q6JZ.js +0 -1119
  190. package/skills/ae-agent/references/create-automation.md +0 -125
  191. package/skills/ae-agent/references/list-automations.md +0 -56
  192. package/skills/ae-agent/references/update-automation.md +0 -107
  193. package/skills/ae-project-semantic/SKILL.md +0 -193
  194. package/skills/ae-project-semantic/references/query-routing-v5.md +0 -165
  195. package/skills/ae-project-semantic/references/recommendation-quality.md +0 -68
@@ -1,23 +1,36 @@
1
1
  # analysis report update
2
2
 
3
- Use when the user explicitly wants to update saved report metadata or replace its AI QP definition.
3
+ Use when the user explicitly wants to update saved report metadata, replace its AI QP definition, or change an event report's chart/result-table layout.
4
4
 
5
5
  Do not use raw QP, `qp`, `report_model`, or `analysis_query`. When changing the definition, pass `model_type` and AI QP `definition` together.
6
6
 
7
- Read [`ai_models.md`](ai_models.md) for the single AI-facing model registry. Report update supports the 12 analysis models plus `tag` for saved tag report data.
7
+ Read [`ai_models.md`](ai_models.md) for the single AI-facing model registry. Report update supports the 13 analysis models plus `tag` for saved tag report data.
8
8
 
9
9
  Command:
10
10
 
11
11
  ```bash
12
12
  ae-cli analysis report update --project-id <project_id> --report-id <report_id> --report-version <version> --report-name "New name"
13
13
  ae-cli analysis report update --project-id <project_id> --report-id <report_id> --report-version <version> --model-type event --definition '{...}' [--resolutions '<confirmed_resolution_json>']
14
+ ae-cli analysis report update --project-id <project_id> --report-id <report_id> --report-version <version> --presentation '{"table_layout":"event"}'
14
15
  ```
15
16
 
16
17
  When the caller supplies an existing snapshot, optional `--intent-snapshot` accepts `schema_version: 1`, non-empty `requirement`, `definition` and `model_type`. The CLI checks that its definition and model match the submitted values locally; the snapshot is never sent to Gateway. Metadata-only updates use no definition snapshot.
17
18
 
18
- Input sends `project_id`, `report_id`, `version` from CLI `--report-version`, and at least one of `report_name`, `report_desc`, or `definition`. Read `version` from `analysis report get` before updating. `model_type` is required when `definition` is provided; `resolutions` is allowed only when a definition is provided and is not supported with `model_type=tag`.
19
+ Input sends `project_id`, `report_id`, `version` from CLI `--report-version`, and at least one of `report_name`, `report_desc`, `definition`, or top-level `presentation`. Read `version` from `analysis report get` before updating. `model_type` is required when `definition` is provided; `resolutions` is allowed only when a definition is provided and is not supported with `model_type=tag`.
19
20
 
20
- Output is the gateway envelope. `data` contains update status, `report_id`, and the normalized AI QP definition when a definition was updated.
21
+ ## Preserve display settings
22
+
23
+ For same-model definition updates, omit `presentation` to preserve the saved event-report chart and result-table layout. For a display-only change, send `--presentation` without `--definition` or `--model-type`, using the current version. Only supplied presentation fields change; omitted fields are retained. Supported only for event reports: `chart_type=line|combo|bar|stacked|cumulative|pie`, `table_layout=date|event|group`, and report-level `series`. The gateway validates the effective presentation against the saved definition; pie always requires grouping without time comparison. Total-time reports support bar, or pie only when those grouping/comparison conditions hold. A model change uses the target model's display defaults unless an allowed event presentation is supplied.
24
+
25
+ For combination styles/axes, read [event-report presentation](event_report_presentation.md) before updating. Series is a subset patch; `[]` is an explicit reset, and `chart_type=line` resets all series to primary-axis lines. Metric positions are tied to the current returned `definition.metrics` and report version. Changing source series also affects its other trend (`L0`) cards; card updates cannot override series locally. During definition changes, the server preserves uniquely matched technical metrics and rejects unsafe non-default series loss with `SERIES_PRESERVATION_CONFLICT`; follow its reset guidance instead of silently carrying old indexes into new metrics.
26
+
27
+ Non-empty series-only updates require an existing compatible trend. Empty `series: []` also clears retained series on a compatible non-trend chart without changing that chart type. When changing from another chart, use explicit `chart_type=combo` with non-empty series; do not attach non-empty series to an explicit bar/pie/cumulative/line choice. If a definition change invalidates a previously valid chart, implicit preservation fails before writing; follow its compatible-chart guidance rather than promising an unchanged invalid display.
28
+
29
+ To change a table card on an analysis board, use [`dashboard-report update`](dashboard_report_update.md) with `--chart-type table`, not report presentation. The source report, the analysis page's result table, and a dashboard card are separate display scopes. Raw `graphShape`, `byType`, `reportGraphShape`, `tableFormat`, and `dateOutside` are not authoring fields.
30
+
31
+ Definition replacement follows the filter write boundary in [`ai_models.md`](ai_models.md): one compound group level with leaf-only, non-empty `items`. A deeper historical tree remains readable, but a deeper tree or empty group submitted for writing is rejected by the capability schema as `INVALID_CAPABILITY_INPUT`; use the returned field path or schema keyword to correct it. Omit `definition` for metadata-only changes and never flatten it.
32
+
33
+ Output is the gateway envelope. `data` contains update status, `report_id`, and the normalized AI QP definition when a definition was updated, plus event-report `presentation`. It does not represent any dashboard card's display.
21
34
 
22
35
  When a definition is supplied, update and its `--validate` / `--dry-run` paths use the same compiler contract. `AI_QP_COMPILE_FAILED` preserves the full structured error array. The report is not changed on this failure; follow [`metadata_resolution.md`](metadata_resolution.md), keep each bound field's path and original wording, fill confirmed model parameters, and retry with `--resolutions` only after confirmation.
23
36
 
@@ -26,3 +39,7 @@ For the shortest safe update, read the current `version` exactly once with `anal
26
39
  For a SQL `part_date` parameter, `use_timezone` is a boolean saved definition field with default `false`. Change it only by submitting the complete updated `definition`; report-data `--sql-params` is value-only and must not contain `use_timezone`.
27
40
 
28
41
  After a successful update, call `analysis-meta asset url-get` with the updated `report_id` and output its `markdown_link`.
42
+
43
+ The capability schema includes model-specific nested definition validation. Unknown fields, including nested filter/time-range fields and diagnostic backing fields, are rejected instead of silently ignored. Use canonical snake_case keys and aggregation names such as `user_count`; event report metrics and funnel `steps[]` may additionally carry `display_name`. When replacing a funnel definition, preserve every step's returned `display_name` so custom labels survive the round trip. Inspect the report capability itself for the full saved-report definition schema.
44
+
45
+ Use `--report-desc ""` to clear an existing description. Omitting `--report-desc` preserves the saved description. Clearing only the description is a valid metadata-only update.
@@ -2,18 +2,18 @@
2
2
 
3
3
  List queryable columns for one server-authorized SQL table.
4
4
 
5
- For an unknown table, first call `analysis sql-table list --project-id <project_id>`, then copy an exact returned `table_ref`. Reuse an already verified authorized table reference in the same scope. Do not guess table or column names.
5
+ For an unknown table, first call `analysis sql-table list --project-id <project_id>`, then copy the returned `sql_reference` (or legacy `table_ref`). Reuse an already verified authorized table reference in the same scope. Do not guess table or column names.
6
6
 
7
7
  ```bash
8
8
  ae-cli analysis sql-table columns \
9
9
  --project-id <project_id> \
10
10
  --table-ref <table_ref> \
11
- [--usage analysis|tag_cluster]
11
+ [--usage analysis|tag_cluster|sql_datatable]
12
12
  ```
13
13
 
14
- The result identifies the resolved catalog/schema/table and returns its columns with machine names, types, and available descriptions. A unique table-only reference is accepted; ambiguous references fail with candidate tables instead of selecting one arbitrarily.
14
+ The result includes `table_ref`, quoted `sql_reference`, `table_type`, nullable `source_type` and `repo_table_type`, and the resolved catalog/schema/table, and returns its columns with machine names, types, and available descriptions. A unique table-only reference is accepted; ambiguous references fail with authorized `candidate_tables` with quoted `sql_reference` values instead of selecting one arbitrarily. Quote the entire shell argument, for example `--table-ref '"hive"."space.name"."orders"'`. Double quotes inside an identifier are doubled. One to three identifier segments are supported; a two-segment reference uses the `hive` catalog.
15
15
 
16
- Pass the same `usage` used for `sql-table list`. For SQL tags and SQL clusters this must be `--usage tag_cluster`; the default is `analysis`.
16
+ Pass the same `usage` used for `sql-table list`. For SQL tags and SQL clusters this must be `--usage tag_cluster`; use `--usage sql_datatable` for SQL-built data tables; the default is `analysis`. Do not fall back to another usage if the server rejects it.
17
17
 
18
18
  When copying returned columns into Trino SQL, delimit identifiers containing `#`, `$`, `@`, spaces, or punctuation with double quotes, for example `"#user_id"` or `"$part_event"`. Single quotes are string literals. The CLI does not auto-rewrite SQL.
19
19
 
@@ -10,16 +10,16 @@ ae-cli analysis sql-table list \
10
10
  [--queries '["user","event"]'] \
11
11
  [--limit <1-200>] \
12
12
  [--offset <next_offset>] \
13
- [--usage analysis|tag_cluster]
13
+ [--usage analysis|tag_cluster|sql_datatable]
14
14
  ```
15
15
 
16
16
  ## Contract
17
17
 
18
18
  - Use this command before writing SQL when the table is not already known. Do not ask the customer to supply the fixed project event/user table name and do not guess `v_event_<id>` or `v_user_<id>`.
19
- - `table_ref` is the exact server-authorized reference to copy into SQL and into `analysis sql-table columns --table-ref`.
19
+ - Use `sql_reference` (quoted catalog/schema/table with escaped double quotes) when copying a table into SQL or `analysis sql-table columns --table-ref`. The legacy `table_ref` remains accepted; do not split it on dots because identifier segments can contain dots.
20
20
  - `queries` accepts 1 to 20 non-empty strings with OR semantics. Matching rows include `matched_queries` and `matched_fields`; singular `query` is not accepted.
21
- - Each item also returns `catalog`, `schema`, `table`, `table_type`, and `description`.
22
- - `usage=analysis` is the default table set for SQL analysis and reports. Use `usage=tag_cluster` for SQL tags or SQL clusters. These server-authorized sets differ, and the same usage must be passed to `sql-table columns`.
21
+ - Each item also returns `catalog`, `schema`, `table`, `table_type`, `description`, `usage`, `source_type`, `repo_table_type`, and `sql_reference`. `source_type=gaia` identifies space tables; source/type metadata may be null for ordinary tables. Do not infer a space table from `table_type=customTable`.
22
+ - `usage=analysis` is the default table set for SQL analysis and reports. Use `usage=tag_cluster` for SQL tags or SQL clusters, and `usage=sql_datatable` for SQL-built data tables. Lists are flat; these usages select authorized sets rather than UI categories. Do not silently retry a rejected usage with `analysis`. These server-authorized sets differ, and the same usage must be passed to `sql-table columns`.
23
23
  - When `has_more=true`, continue only with the returned `next_offset`. Stop when `has_more=false`.
24
24
  - An empty list means the current identity has no queryable SQL tables in that project; do not fabricate a table name.
25
25
 
@@ -31,4 +31,4 @@ ae-cli analysis sql-table columns --project-id 1 --table-ref hive.ta.v_user_1
31
31
  ae-cli analysis adhoc run --project-id 1 --model-type sql --definition '{"sql":"select * from hive.ta.v_user_1 limit 10"}'
32
32
  ```
33
33
 
34
- Use the exact `table_ref` returned by the first command; the example reference is illustrative only.
34
+ Use the exact `sql_reference` returned by the first command when writing SQL; the example reference is illustrative only.
@@ -12,6 +12,8 @@ ae-cli system query-monitor overview --company-id <company-id> --cluster-names '
12
12
 
13
13
  Capability id: `system.query_monitor.overview`.
14
14
 
15
+ Selected project IDs and space codes must belong to the supplied company. A different company's scope is rejected before chart data is read.
16
+
15
17
  The response uses `ok`, `data`, and `meta`. Treat empty `data` as success when `ok=true`; preserve `request_id` and `invocation_id` when present.
16
18
 
17
19
  ## Parameters
@@ -13,6 +13,8 @@ ae-cli system query-task cancel --company-id <company-id> --task-id <task-id> --
13
13
 
14
14
  Capability id: `system.query_task.cancel`.
15
15
 
16
+ The task must belong to `--company-id` by project or workspace. A foreign-company or missing task ID is rejected before cancellation.
17
+
16
18
  Run `--dry-run` first, summarize the affected target and impact, then wait for explicit user confirmation before rerunning the unchanged command with global `--yes`.
17
19
 
18
20
  The response uses `ok`, `data`, and `meta`. Treat empty `data` as success when `ok=true`; preserve `request_id` and `invocation_id` when present.
@@ -12,6 +12,10 @@ ae-cli system query-task export --company-id <company_id> --start-time '2026-07-
12
12
 
13
13
  Capability id: `system.query_task.export`.
14
14
 
15
+ Selected project IDs and space codes must belong to the supplied company. A different company's scope is rejected before an export is submitted.
16
+
17
+ The time range has the same completion-time semantics as [`query-task list`](system_query_task_list.md): inclusive boundary seconds, including milliseconds within the end second, and a maximum 31-day window. The CSV `start_time` is task initiation time, not the timestamp used for range filtering.
18
+
15
19
  If the required filter mappings are unknown, call `ae-cli system query-task options --company-id <company_id>` once. Reuse verified mappings within the same company/project scope; do not guess filter codes or cluster names.
16
20
 
17
21
  Use `--output` to wait and download the completed artifact. If interrupted, resume with `ae-cli analysis run wait --run-id <run_id> --output <file>` using the same export response. See [`run_wait.md`](run_wait.md).
@@ -25,8 +29,8 @@ The response uses `ok`, `data`, and `meta`. Empty task data is a successful expo
25
29
  | Parameter | Required | Description |
26
30
  |---|---|---|
27
31
  | `--company-id` | Yes | Company ID. |
28
- | `--start-time` | Yes | Inclusive range start in `yyyy-MM-dd HH:mm:ss`. |
29
- | `--end-time` | Yes | Inclusive range end in `yyyy-MM-dd HH:mm:ss`. |
32
+ | `--start-time` | Yes | Inclusive completion-time range start in `yyyy-MM-dd HH:mm:ss`. |
33
+ | `--end-time` | Yes | Inclusive completion-time range end, including the entire second, in `yyyy-MM-dd HH:mm:ss`. |
30
34
  | `--status-codes` | Yes | Non-empty task status-code JSON array. |
31
35
  | `--content-codes` | Yes | Non-empty query content-code JSON array. |
32
36
  | `--task-type-codes` | Yes | Non-empty query task-type-code JSON array. |
@@ -12,6 +12,8 @@ ae-cli system query-task get --company-id <company-id> --task-id <task-id>
12
12
 
13
13
  Capability id: `system.query_task.get`.
14
14
 
15
+ The task must belong to `--company-id` by project or workspace. A foreign-company or missing task ID is rejected before details are read.
16
+
15
17
  The response uses `ok`, `data`, and `meta`. Treat empty `data` as success when `ok=true`; preserve `request_id` and `invocation_id` when present.
16
18
 
17
19
  ## Parameters
@@ -1,6 +1,6 @@
1
1
  # system query-task list
2
2
 
3
- Use when the user needs to list query-monitor tasks within a mandatory bounded time range.
3
+ Use when the user needs historical query logs within a mandatory bounded time range. For the realtime monitoring tab, use `ae-cli system query-task realtime-list` instead.
4
4
 
5
5
  Do not use it outside the system query-task operation or with fields absent from the inspected capability schema.
6
6
 
@@ -14,6 +14,10 @@ Capability id: `system.query_task.list`.
14
14
 
15
15
  If the required filter mappings are unknown, call `ae-cli system query-task options --company-id <company_id>` once. Reuse verified mappings within the same company/project scope; do not guess filter codes or cluster names.
16
16
 
17
+ Project IDs and workspace codes must belong to `--company-id`; foreign-company values are rejected before querying. The global system-project ID `-1` cannot be selected as a company-scoped project.
18
+
19
+ The range filters query **completion time**, not the returned `start_time` (task initiation time). Both boundary seconds are inclusive, including milliseconds within the end second. A task started before the window can appear if it completed inside it. Compare list and export using the same completion-time window; do not reject rows solely because `start_time` is outside it. The range must not exceed 31 days.
20
+
17
21
  The response uses `ok`, `data`, and `meta`. Treat empty `data` as success when `ok=true`; preserve `request_id` and `invocation_id` when present.
18
22
 
19
23
  ## Parameters
@@ -21,8 +25,8 @@ The response uses `ok`, `data`, and `meta`. Treat empty `data` as success when `
21
25
  | Parameter | Required | Description |
22
26
  |---|---|---|
23
27
  | `--company-id` | Yes | Company ID. |
24
- | `--start-time` | Yes | Inclusive lower bound in `yyyy-MM-dd HH:mm:ss`. |
25
- | `--end-time` | Yes | Inclusive upper bound in `yyyy-MM-dd HH:mm:ss`. |
28
+ | `--start-time` | Yes | Inclusive completion-time lower bound in `yyyy-MM-dd HH:mm:ss`. |
29
+ | `--end-time` | Yes | Inclusive completion-time upper bound, including the entire second, in `yyyy-MM-dd HH:mm:ss`. |
26
30
  | `--project-ids` | Conditional | Non-empty project IDs or space codes are required. |
27
31
  | `--space-codes` | Conditional | Non-empty space codes or project IDs are required. |
28
32
  | `--status-codes` | Yes | Task status-code JSON array. |
@@ -1,6 +1,6 @@
1
1
  # system query-task options
2
2
 
3
- Use before query-task list or export to discover every valid filter value exposed by the current environment.
3
+ Use before query-task list, realtime-list, or export to discover valid filter values exposed by the current environment.
4
4
 
5
5
  Command:
6
6
 
@@ -18,7 +18,7 @@ The response maps:
18
18
  - `projects[].project_id` and `workspaces[].space_code` to display names.
19
19
  - `clusters[].cluster_name` to its query engine metadata.
20
20
 
21
- Use the returned codes and names unchanged in `query-task list` or `query-task export`. Do not infer codes from UI labels or examples.
21
+ Project and workspace options are limited to `--company-id`; status, content, task type, and cluster codes remain discoverable. Use the returned codes and names unchanged in `query-task list`, `query-task realtime-list`, or `query-task export`. Discovery does not authorize a project or workspace; execution still checks company ownership. Do not infer codes from UI labels or examples.
22
22
 
23
23
  ## Parameters
24
24
 
@@ -0,0 +1,15 @@
1
+ # system query-task realtime-list
2
+
3
+ Use for a one-time snapshot of the Query Monitor **Realtime Query** tab. The existing `query-task list` command is for historical **Query Logs** and requires a fixed start/end range. Do not substitute one for the other.
4
+
5
+ ```bash
6
+ ae-cli system query-task realtime-list --company-id <company_id> --project-ids '[123]' --cluster-names '["cluster-a"]' --duration-minutes 30 --limit 100
7
+ ```
8
+
9
+ Capability ID: `system.query_task.realtime_list`. Run `ae-cli system query-task options --company-id <company_id>` first if IDs, status codes, or cluster names are unknown. Discovery does not grant access; a project or workspace outside the company is rejected during execution.
10
+
11
+ The global system-project ID `-1` cannot be selected as a company-scoped project. System tasks tied to a company workspace remain visible through that workspace where applicable.
12
+
13
+ Provide at least one non-empty `--project-ids` or `--space-codes` JSON array, and a non-empty `--cluster-names` JSON array. `--duration-minutes` defaults to 30 (range 1–30). Optional `--status-codes` filters task states. `--limit` defaults to 100 (maximum 200). This command does not poll or cancel tasks.
14
+
15
+ The response contains `items`, `limit`, `has_more`, and `snapshot_at`. `has_more` means the bounded snapshot has additional matching rows, not a full historical count. Task rows omit credentials, user identity tokens, internal SQL gateway selection, and SQL text. To inspect one task, use `query-task get`; cancel remains a separate high-risk operation requiring confirmation.
@@ -16,6 +16,12 @@ If a SQL cluster reads an event table, include a predicate on the quoted `"$part
16
16
  SQL clusters support only `${PartDate:name}` dynamic placeholders. Each placeholder requires a matching `params` item with `type=part_date` and either `recent_day` or `start_time` plus `end_time`. General SQL parameter types (`text`, `number`, `variable`, `time`, and `selector`) are rejected for SQL clusters.
17
17
  For `recent_day`, `0-7` means 最近7天 and includes today; `1-7` means 过去7天 and excludes today.
18
18
 
19
+ `${base_date}` is a separate built-in computation-date macro, not a user-configurable dynamic placeholder. SQL clusters may use `${base_date}`, a formatted value such as `${base_date:yyyy-MM-dd}`, or a server-supported offset such as `${base_date:yyyy-MM-dd-1*day}`. Keep the macro in `sql` and do not add it to `params`; it is expanded when the cluster is calculated. Expansion produces plain text, so quote the macro when the SQL expression expects a string or date literal:
20
+
21
+ ```json
22
+ {"type":"sql","sql":"SELECT \"#user_id\" FROM v_event_1 WHERE \"$part_date\"='${base_date:yyyy-MM-dd}'"}
23
+ ```
24
+
19
25
  Discover tables with `analysis sql-table list --project-id <project_id> --usage tag_cluster`, then inspect columns with the same `--usage tag_cluster`. This table set is server-authorized specifically for SQL tags/clusters and differs from the default analysis SQL set.
20
26
 
21
27
  Optional `include_filter` and `exclude_filter` use the shared filter-group shape.
@@ -87,3 +93,5 @@ Required: `type=behavior_sequence`, `completed`, `steps`. Each step requires `ev
87
93
  ]}
88
94
  }
89
95
  ```
96
+
97
+ For space tables, use the returned `sql_reference` when writing SQL and loading columns. `source_type=gaia` identifies a space table; keep `--usage tag_cluster` for both discovery commands.
@@ -10,7 +10,7 @@ Flags: `--project-id`, `--tag-name`, `--display-name`, `--definition-request` re
10
10
 
11
11
  `tag_name` is a machine identifier: 1-80 characters, starts with a letter, and contains only letters, digits, or underscores. `display_name` is 1-80 characters. The CLI rejects violations before dispatch.
12
12
 
13
- Read `user_tag_models.md` before constructing `--definition-request`. Dynamic first/last ranges use semantic `time_range` values such as `{"mode":"recent","unit":"month","value":1}` for this month or `{"mode":"start_to_today","start_time":"2026-07-01"}` for a fixed start date through today. Create does not accept `--remark`; set it later with `user-tag update` when needed.
13
+ Read `user_tag_models.md` before constructing `--definition-request`. Every metric tag requires `metric.time_range`; never omit it. Dynamic first/last ranges use semantic `time_range` values such as `{"mode":"recent","unit":"month","value":1}` for this month or `{"mode":"start_to_today","start_time":"2026-07-01"}` for a fixed start date through today. Create does not accept `--remark`; set it later with `user-tag update` when needed.
14
14
 
15
15
  The backend validates and compiles the definition inside the create operation; if metadata is ambiguous or missing, creation fails without creating the tag.
16
16
 
@@ -18,6 +18,12 @@ The backend validates and compiles the definition inside the create operation; i
18
18
  ae-cli analysis user-tag create --project-id <project_id> --tag-name high_value --display-name "High Value" --definition-request '{"type":"condition","condition_values":[{"value":"high","events":[{"event":"pay","operator":"gte","value":3,"aggregation":"count","time_range":{"mode":"recent","unit":"day","value":30}}]}]}'
19
19
  ```
20
20
 
21
+ Median metric tag for the previous 30 days:
22
+
23
+ ```bash
24
+ ae-cli analysis user-tag create --project-id <project_id> --tag-name median_payment --display-name "Median Payment" --definition-request '{"type":"metric","metric":{"event":"pay","aggregation":"median","property":"amount","time_range":{"mode":"previous","unit":"day","value":30}}}'
25
+ ```
26
+
21
27
  First/last tag for this month:
22
28
 
23
29
  ```bash
@@ -4,7 +4,7 @@ Get exact user tag details after discovery.
4
4
 
5
5
  Do not use it for fuzzy discovery, member data, or history statistics. Output contains saved tag metadata/definition for the requested names.
6
6
 
7
- After `user-tag create` or an update containing `--definition-request`, use this command to observe the automatically started computation; do not trigger `user-tag refresh`. For create, wait until `progress=100` and `refresh_time` is present. For a definition update, record the previous `refresh_time` first and wait until `progress=100` and `refresh_time` advances. Until then, `users_num` and member queries may still reflect the previous successful computation; treat that as stale data, not as evidence that the new definition was compiled or calculated incorrectly.
7
+ After `user-tag create` or an update reporting `computation.triggered_automatically=true`, use this command to observe the automatically started computation; do not trigger `user-tag refresh`. For create, wait until `progress=100` and `refresh_time` is present. For a changed definition, record the previous `refresh_time` first and wait until `progress=100` and `refresh_time` advances. Until then, `users_num` and member queries may still reflect the previous successful computation; treat that as stale data, not as evidence that the new definition was compiled or calculated incorrectly. An identical definition is not recomputed; when update returns `not_triggered` and `next_action=none`, do not wait for a new refresh timestamp.
8
8
 
9
9
  The raw backend value is returned under `result`. The response also provides aggregate and per-tag `computation`, `result_freshness`, and `next_action`. `poll_get` includes an exact capability/input pair; `none` means the latest result is usable. `potentially_stale` with `is_stale=null` means `refresh_time` predates `update_time`, but the update may have changed metadata only; inspect the latest update instead of refreshing automatically.
10
10
 
@@ -24,7 +24,9 @@ Top-level `type` is exactly one of `condition`, `metric`, `first_last`, or `sql`
24
24
 
25
25
  ## Metric tag
26
26
 
27
- Required: `event`, `aggregation`. `property`, `percentile`, `time_range`, and `filters` are optional. Filters support only event properties and user properties. A string `field` is an event property; use `{name,type:"user_property"}` for a user property.
27
+ Required: `event`, `aggregation`, and `time_range`. `property`, `percentile`, and `filters` are optional. Filters support only event properties and user properties. A string `field` is an event property; use `{name,type:"user_property"}` for a user property. Use the semantic time mappings in [`audience_models.md`](audience_models.md); never omit `time_range` from a metric tag.
28
+
29
+ Supported aggregations are `count`, `active_days`, `sum`, `avg`, `max`, `min`, `median`, and `percentile`. `median` is a dedicated aggregation for a numeric event `property`; do not represent it as `percentile=50`.
28
30
 
29
31
  Use `aggregation=percentile` with a numeric event `property` and pass `percentile`. Supported percentile values match the page controls: `5`, `10`, `20`, `25`, `30`, `40`, `60`, `70`, `75`, `80`, `90`, `95`, and `99`. The `percentile` field is required for percentile aggregation and is rejected for every other aggregation.
30
32
 
@@ -32,10 +34,16 @@ Use `aggregation=percentile` with a numeric event `property` and pass `percentil
32
34
  {"type":"metric","metric":{"event":"pay","aggregation":"sum","property":"amount","time_range":{"mode":"previous","unit":"day","value":30},"filters":{"relation":"and","items":[{"field":"channel","operator":"eq","values":["app"]},{"field":{"name":"country","type":"user_property"},"operator":"eq","values":["US"]}]}}}
33
35
  ```
34
36
 
37
+ Median example:
38
+
39
+ ```json
40
+ {"type":"metric","metric":{"event":"pay","aggregation":"median","property":"amount","time_range":{"mode":"previous","unit":"day","value":30}}}
41
+ ```
42
+
35
43
  Percentile example:
36
44
 
37
45
  ```json
38
- {"type":"metric","metric":{"event":"pay","aggregation":"percentile","property":"amount","percentile":90}}
46
+ {"type":"metric","metric":{"event":"pay","aggregation":"percentile","property":"amount","percentile":90,"time_range":{"mode":"previous","unit":"day","value":30}}}
39
47
  ```
40
48
 
41
49
  ## First/last tag
@@ -54,6 +62,8 @@ From a fixed date through today:
54
62
 
55
63
  ## SQL tag
56
64
 
65
+ Return one row per distinct analysis-subject ID, with the tag value in the second column; a list tag requires a native SQL `ARRAY(varchar)` value, not a JSON string or repeated scalar rows. The server infers the tag type from that column, so do not add `selectType`; aggregate repeated subjects in the SQL itself, for example with `array_agg(DISTINCT CAST(value AS varchar))` and `GROUP BY` the subject ID.
66
+
57
67
  ```json
58
68
  {"type":"sql","sql":"SELECT \"#user_id\", 'payer' AS tag_value FROM hive.ta.v_event_1 WHERE ${PartDate:partdate} AND \"$part_event\"='pay'","params":[{"name":"partdate","type":"part_date","recent_day":"1-7"}]}
59
69
  ```
@@ -61,8 +71,16 @@ From a fixed date through today:
61
71
  SQL tags support only `${PartDate:name}` dynamic placeholders. Every placeholder requires one `params` item with `type=part_date` and either `recent_day` or `start_time` plus `end_time`. `Text`, `Number`, `Variable`, `Time`, and `Selector` parameters are valid for general SQL analysis but are not valid for SQL tags.
62
72
  For `recent_day`, `0-7` means 最近7天 and includes today; `1-7` means 过去7天 and excludes today.
63
73
 
74
+ `${base_date}` is a separate built-in computation-date macro, not a user-configurable dynamic placeholder. SQL tags may use `${base_date}`, a formatted value such as `${base_date:yyyy-MM-dd}`, or a server-supported offset such as `${base_date:yyyy-MM-dd-1*day}`. Keep the macro in `sql` and do not add it to `params`; it is expanded when the tag is calculated. Expansion produces plain text, so quote the macro when the SQL expression expects a string or date literal:
75
+
76
+ ```json
77
+ {"type":"sql","sql":"SELECT \"#user_id\", 'payer' AS tag_value FROM hive.ta.v_event_1 WHERE \"$part_date\"='${base_date:yyyy-MM-dd}' AND \"$part_event\"='pay'"}
78
+ ```
79
+
64
80
  Before writing a SQL tag, use `analysis sql-table list --project-id <project_id> --usage tag_cluster`, then call `analysis sql-table columns --project-id <project_id> --table-ref <table_ref> --usage tag_cluster`. The `tag_cluster` authorized table set is intentionally different from the general analysis SQL table set; do not reuse a table discovered with the default `usage=analysis`.
65
81
 
66
82
  `#user_id`, `$part_event`, and any other Trino identifier containing `#`, `$`, `@`, spaces, or punctuation must be delimited with double quotes. Single quotes are only for values.
67
83
 
68
84
  When the SQL reads an event table, it must also filter the quoted `"$part_date"` date-partition column; the backend rejects event-table SQL without that predicate.
85
+
86
+ For space tables, use the returned `sql_reference` when writing SQL and loading columns. `source_type=gaia` identifies a space table; keep `--usage tag_cluster` for both discovery commands.
@@ -2,7 +2,7 @@
2
2
 
3
3
  Explicitly recompute an existing user tag by exact `tag_name` without changing its definition.
4
4
 
5
- Use this only when an unchanged definition must be run again, such as an explicit retry or a recomputation against changed source data. Do not call it after `user-tag create` or an update containing `--definition-request`; those commands already start computation automatically. Do not use it to refresh one history snapshot. Output means recomputation was submitted, not completed. Poll `user-tag get` and verify the new computation before using `users_num` or querying members.
5
+ Use this only when an unchanged definition must be run again, such as an explicit retry or a recomputation against changed source data. Do not call it after `user-tag create` or an update reporting `computation.triggered_automatically=true`; those commands already start computation. An identical definition update does not trigger computation and does not by itself authorize a separate refresh. Do not use this command to refresh one history snapshot. Output means recomputation was submitted, not completed. Poll `user-tag get` and verify the new computation before using `users_num` or querying members.
6
6
 
7
7
  The response marks this as an explicit trigger: `computation.triggered_by_command=true`, `computation.triggered_automatically=false`, `computation.status=submitted`, and `result_freshness.is_stale=true`. Follow the returned `next_action`, `next_capability_id`, and `next_input` to poll.
8
8
 
@@ -2,9 +2,9 @@
2
2
 
3
3
  Update a user tag. Discover the exact `tag_name` first.
4
4
 
5
- Do not use it for ID-file value replacement or to create a missing tag. Supplying `--definition-request` automatically starts recomputation after the definition is updated; do not call `user-tag refresh` afterward. Updating only `--display-name` or `--remark` does not recompute. A schedule-only update changes periodic refresh without starting immediate recomputation. `--auto-refresh-cron` or `--auto-refresh-schedule` can enable periodic refresh directly, including on a previously disabled tag. A successful update means the definition was saved, not that the new result is complete. Record the current `refresh_time` before updating, then poll `user-tag get` until `progress=100` and `refresh_time` advances before using `users_num` or querying members.
5
+ Do not use it for ID-file value replacement or to create a missing tag. A changed `--definition-request` automatically starts recomputation; the native service skips recomputation when the normalized definition and timezone are unchanged. Follow the returned `computation.triggered_automatically` and `next_action`; do not call `user-tag refresh` afterward. Updating only `--display-name` or `--remark` does not recompute. A schedule-only update changes periodic refresh without starting immediate recomputation. `--auto-refresh-cron` or `--auto-refresh-schedule` can enable periodic refresh directly, including on a previously disabled tag. A successful update means the definition was saved, not that a triggered computation is complete. When computation was triggered, poll `user-tag get` until `progress=100` and `refresh_time` advances from the value recorded before the update. An unchanged definition returns `not_triggered` and `next_action=none`; do not wait for its refresh timestamp to change.
6
6
 
7
- The response distinguishes both paths. A definition update returns `computation.triggered_automatically=true`, `result_freshness.is_stale=true`, and normally `next_action=poll_get` with an exact capability/input pair. A display-name/remark-only update returns `computation.status=not_triggered`, `result_freshness.status=fresh`, and `next_action=none`.
7
+ The response distinguishes both paths. An update that triggers recomputation returns `computation.triggered_automatically=true`, `result_freshness.is_stale=true`, and `next_action=poll_get` with an exact capability/input pair. An unchanged definition or display-name/remark-only update returns `computation.status=not_triggered`, `result_freshness.status=fresh`, and `next_action=none`.
8
8
 
9
9
  Flags: `--project-id`, `--tag-name` required. Optional: `--display-name`, `--definition-request`, `--authenticated-only`, `--remark`, `--zone-offset`, `--enable-auto-refresh`, `--auto-refresh-schedule`, `--auto-refresh-cron`. The tag type comes from `definition_request.type` when the definition changes.
10
10
 
@@ -0,0 +1,105 @@
1
+ #!/usr/bin/env node
2
+ import { createHash } from 'node:crypto';
3
+ import { execFileSync } from 'node:child_process';
4
+ import fs from 'node:fs';
5
+ import path from 'node:path';
6
+ import { normalizeSourceForHash } from './precompiled-source.mjs';
7
+
8
+ const args = Object.fromEntries(process.argv.slice(2).reduce((pairs, part, index, all) => {
9
+ if (part.startsWith('--') && all[index + 1] && !all[index + 1].startsWith('--')) {
10
+ pairs.push([part.slice(2), all[index + 1]]);
11
+ }
12
+ return pairs;
13
+ }, []));
14
+ const packageRoot = path.resolve(required('asset-package'));
15
+ const outputRoot = path.resolve(required('output'));
16
+ const descriptor = readJson(path.join(packageRoot, '.asset-package.json'));
17
+ const manifest = readJson(path.join(packageRoot, 'manifest.json'));
18
+ const projectId = Number(descriptor.project_id ?? manifest.project_id);
19
+ const projectName = String(args['project-name'] || descriptor.project_name || manifest.project_name || '')
20
+ .replace(/\s+/g, ' ').trim();
21
+ const snapshotHash = String(descriptor.snapshot_hash ?? manifest.snapshot_hash ?? '');
22
+ const scope = String(descriptor.asset_scope ?? manifest.asset_scope ?? '');
23
+ const policy = descriptor.filter_policy ?? manifest.filter_policy ?? {};
24
+ if (String(descriptor.schema_version ?? manifest.schema_version) !== '3.0'
25
+ || descriptor.truncated === true || manifest.truncated === true
26
+ || scope !== 'governed' || policy.authenticated_entry_assets_only !== true
27
+ || policy.dependency_closure !== true || !Number.isSafeInteger(projectId) || projectId < 1
28
+ || !projectName || !/^[0-9a-f]{64}$/i.test(snapshotHash)) {
29
+ throw new Error('A complete governed schema 3.0 package with valid project identity is required.');
30
+ }
31
+ for (const name of ['dashboard-catalog', 'report-catalog', 'metric-catalog']) {
32
+ if (readJsonl(path.join(packageRoot, 'indexes', `${name}.jsonl`)).length) {
33
+ throw new Error(`The ${name} is not empty; use the normal semantic Wiki builder.`);
34
+ }
35
+ }
36
+ if (readJsonl(path.join(packageRoot, 'sources', 'adopted-personal-semantics.jsonl')).length) {
37
+ throw new Error('Adopted personal semantics are present; the empty skeleton is not applicable.');
38
+ }
39
+ if (fs.existsSync(outputRoot)) throw new Error('Output already exists.');
40
+ const flatRoot = path.join(outputRoot, 'flat');
41
+ fs.mkdirSync(flatRoot, { recursive: true });
42
+ const namespace = `pskb-p${projectId}`;
43
+ const facts = [
44
+ ['index', 'index', 'index.md', `# ${projectName} project semantic knowledge base\n\n- Project overview: project identity and current evidence boundary.\n- Shared project knowledge: no verified shared facts yet.\n- Business domains: none established from governed sources yet.\n- Event and asset catalog: no certified entry assets yet.\n- Governance and provenance: source scope and update policy.\n\nThis is an empty knowledge skeleton. It does not establish business facts or authorize use of uncertified assets.\n`],
45
+ ['wiki-project-overview', 'wiki-page', 'wiki/project-overview.md', `# Project overview\n\nProject: ${projectName} (ID ${projectId}). Business positioning, audience, objects, relationships, and decision paths are not established by the current governed sources. Add verified project material before using this knowledge base for business conclusions.\n`],
46
+ ['common-index', 'common', 'wiki/common/index.md', '# Shared project knowledge\n\nNo verified project-wide knowledge is available yet. Human-authored material may be added under the project and business source directories with provenance and scope.\n'],
47
+ ['domain-index', 'domain', 'wiki/domains/index.md', '# Business domains\n\nNo business domain is established by the current governed sources. Do not infer domains from project names or unverified assets.\n'],
48
+ ['asset-index-index', 'asset-index', 'wiki/asset-index/index.md', '# Event and asset catalog\n\nNo certified entry asset is available in this governed snapshot. Do not switch to all visible assets without an explicit user request.\n'],
49
+ ['governance-index', 'governance', 'wiki/governance/index.md', `# Governance and provenance\n\nProject ID: ${projectId}. Source scope: governed. Certified entry assets: 0. Adopted personal semantics: 0. Business facts remain unknown until verified sources are added. A later refresh must replace this empty-source state when governed evidence becomes available and preserve unrelated human sources.\n`],
50
+ ];
51
+ const refreshState = {
52
+ schema_version: '1.0',
53
+ empty_skeleton: true,
54
+ semantic_project_id: projectId,
55
+ source_snapshot_hash: snapshotHash,
56
+ };
57
+ facts.push(['refresh-state', 'refresh-state', 'refresh-state.md',
58
+ `# Project semantic refresh state\n\n<!-- pskb_refresh_state_base64\n${Buffer.from(JSON.stringify(refreshState)).toString('base64url')}\n-->\n`]);
59
+ const sources = facts.map(([stem, sourceKind, sourcePath, content]) => {
60
+ const file = `${namespace}-${stem}.md`;
61
+ fs.writeFileSync(path.join(flatRoot, file), content);
62
+ return {
63
+ display_name: file, file, namespace, snapshot_hash: snapshotHash,
64
+ source_kind: sourceKind, asset_type: null, asset_key: null,
65
+ title: content.split('\n')[0].replace(/^# /, ''), source_path: sourcePath,
66
+ content_hash: createHash('sha256').update(normalizeSourceForHash(content)).digest('hex'),
67
+ semantic_plan_fragment_refs: [],
68
+ };
69
+ });
70
+ fs.writeFileSync(path.join(flatRoot, 'kb-upload-manifest.json'), JSON.stringify({
71
+ schema_version: '1.0',
72
+ manifest_kind: 'ae_project_semantic_kb_upload_sources',
73
+ navigation_taxonomy_version: 'empty-skeleton-1.0',
74
+ namespace,
75
+ semantic_project_id: projectId,
76
+ project_name: projectName,
77
+ snapshot_hash: snapshotHash,
78
+ semantic_plan_state: { schema_version: null, plan_hash: null, fragment_count: 0, fragments: [] },
79
+ source_count: sources.length,
80
+ sources,
81
+ }, null, 2));
82
+ const packager = path.join(import.meta.dirname, 'package-wiki-source-zip.mjs');
83
+ const archive = path.join(outputRoot, 'empty-skeleton.zip');
84
+ const tree = path.join(outputRoot, 'source-tree');
85
+ const sourceManifest = path.join(outputRoot, 'source-tree-manifest.json');
86
+ execFileSync(process.execPath, [packager, '--source-dir', flatRoot, '--tree-output', tree,
87
+ '--manifest-output', sourceManifest, '--output', archive, '--embed-refresh-state-baseline'], {
88
+ stdio: 'pipe',
89
+ });
90
+ process.stdout.write(JSON.stringify({
91
+ project_id: projectId, project_name: projectName, archive,
92
+ source_tree: tree, manifest: sourceManifest, source_count: sources.length,
93
+ }, null, 2) + '\n');
94
+
95
+ function required(name) {
96
+ if (!args[name]) throw new Error(`--${name} is required.`);
97
+ return args[name];
98
+ }
99
+ function readJson(file) {
100
+ return JSON.parse(fs.readFileSync(file, 'utf8'));
101
+ }
102
+ function readJsonl(file) {
103
+ const rows = fs.readFileSync(file, 'utf8').split(/\r?\n/).filter(Boolean).map((line) => JSON.parse(line));
104
+ return rows.filter((row) => row.record_type !== 'header');
105
+ }