@zhoujinandrew/te-cli 1.0.0 → 1.0.2

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/README.md CHANGED
@@ -4,14 +4,25 @@ CLI tool for ThinkingEngine (TE) analytics platform. Designed for both AI Agent
4
4
 
5
5
  ## Installation
6
6
 
7
+ **Step 1: Install te-cli**
8
+
7
9
  ```bash
8
10
  npm install -g @zhoujinandrew/te-cli
9
11
  ```
10
12
 
11
- To update to the latest version:
13
+ **Step 2: Install AI Agent Skills**
14
+
15
+ ```bash
16
+ npx skills add zjandrew/te-cli -g -y
17
+ ```
18
+
19
+ This installs 5 skill packages into your AI coding agent (Claude Code, Trae, Cursor, etc.), enabling the agent to understand and call te-cli commands.
20
+
21
+ To update:
12
22
 
13
23
  ```bash
14
24
  npm update -g @zhoujinandrew/te-cli
25
+ npx skills add zjandrew/te-cli -g -y
15
26
  ```
16
27
 
17
28
  ## Quick Start
@@ -90,6 +101,24 @@ te-cli auth logout
90
101
  | `--dry-run` | Preview request | false |
91
102
  | `--yes` | Skip confirmation | false |
92
103
 
104
+ ## Skills
105
+
106
+ 5 AI Agent skill packages are included in the `skills/` directory:
107
+
108
+ | Skill | Description |
109
+ |-------|-------------|
110
+ | `te-shared` | Authentication, configuration, global options |
111
+ | `te-meta` | Metadata: events, properties, entities, metrics, tables |
112
+ | `te-analysis` | Reports, dashboards, SQL queries, report data |
113
+ | `te-audience` | Tags, clusters, audience events/properties |
114
+ | `te-operation` | Tasks, flows, channels, space navigation |
115
+
116
+ Install them with:
117
+
118
+ ```bash
119
+ npx skills add zjandrew/te-cli -g -y
120
+ ```
121
+
93
122
  ## Development
94
123
 
95
124
  ```bash
@@ -98,12 +127,3 @@ cd te-cli
98
127
  npm install
99
128
  npx tsx src/index.ts --help
100
129
  ```
101
-
102
- ## Skills
103
-
104
- AI Agent skill documentation is in the `skills/` directory:
105
- - `te-shared` — Authentication, configuration, global options
106
- - `te-meta` — Metadata queries
107
- - `te-analysis` — Analysis and reporting
108
- - `te-audience` — Audience management
109
- - `te-operation` — Operations management
@@ -0,0 +1,218 @@
1
+ // src/commands/analysis/list-reports.ts
2
+ var listReports = {
3
+ service: "analysis",
4
+ command: "+list-reports",
5
+ description: "List all analysis reports for a project",
6
+ flags: [
7
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
8
+ ],
9
+ risk: "read",
10
+ execute: async (ctx) => {
11
+ return ctx.api("POST", "/v1/ta/event/listAll", {
12
+ projectId: ctx.num("project-id")
13
+ });
14
+ }
15
+ };
16
+
17
+ // src/commands/analysis/get-report.ts
18
+ var getReport = {
19
+ service: "analysis",
20
+ command: "+get-report",
21
+ description: "Get full report definition by ID",
22
+ flags: [
23
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
24
+ { name: "report-id", type: "number", required: true, desc: "Report ID" }
25
+ ],
26
+ risk: "read",
27
+ execute: async (ctx) => {
28
+ return ctx.api("GET", "/v1/ta/event/reportsearch", {
29
+ projectId: ctx.num("project-id"),
30
+ reportId: ctx.num("report-id")
31
+ });
32
+ }
33
+ };
34
+
35
+ // src/commands/analysis/save-report.ts
36
+ var saveReport = {
37
+ service: "analysis",
38
+ command: "+save-report",
39
+ description: "Save (create/update) an analysis report",
40
+ flags: [
41
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
42
+ { name: "report-name", type: "string", required: true, desc: "Report name" },
43
+ { name: "report-model", type: "number", required: true, desc: "0=Event, 1=Retention, 2=Funnel, 10=Distribution" },
44
+ { name: "events", type: "json", required: true, desc: "Events configuration array" },
45
+ { name: "event-view", type: "json", required: true, desc: "Event view configuration" }
46
+ ],
47
+ risk: "write",
48
+ execute: async (ctx) => {
49
+ return ctx.api("POST", "/v1/ta/event/reportsave", {
50
+ projectId: ctx.num("project-id")
51
+ }, {
52
+ reportName: ctx.str("report-name"),
53
+ reportModel: ctx.num("report-model"),
54
+ events: ctx.json("events"),
55
+ eventView: ctx.json("event-view")
56
+ });
57
+ }
58
+ };
59
+
60
+ // src/commands/analysis/list-dashboards.ts
61
+ var listDashboards = {
62
+ service: "analysis",
63
+ command: "+list-dashboards",
64
+ description: "List all dashboards for a project",
65
+ flags: [
66
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
67
+ ],
68
+ risk: "read",
69
+ execute: async (ctx) => {
70
+ return ctx.api("GET", "/v1/ta/dashboard/all-dashboards", {
71
+ projectId: ctx.num("project-id")
72
+ });
73
+ }
74
+ };
75
+
76
+ // src/commands/analysis/get-dashboard.ts
77
+ var getDashboard = {
78
+ service: "analysis",
79
+ command: "+get-dashboard",
80
+ description: "Get dashboard details by ID",
81
+ flags: [
82
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
83
+ { name: "dashboard-id", type: "number", required: true, desc: "Dashboard ID" }
84
+ ],
85
+ risk: "read",
86
+ execute: async (ctx) => {
87
+ return ctx.api("POST", "/v1/ta/dashboard/search-dashboard", {
88
+ projectId: ctx.num("project-id")
89
+ }, {
90
+ dashboardId: ctx.num("dashboard-id")
91
+ });
92
+ }
93
+ };
94
+
95
+ // src/commands/analysis/create-dashboard.ts
96
+ var createDashboard = {
97
+ service: "analysis",
98
+ command: "+create-dashboard",
99
+ description: "Create a new dashboard",
100
+ flags: [
101
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
102
+ { name: "dashboard-name", type: "string", required: true, desc: "Dashboard name" }
103
+ ],
104
+ risk: "write",
105
+ execute: async (ctx) => {
106
+ return ctx.api("POST", "/v1/ta/dashboard/create-dashboard", {
107
+ projectId: ctx.num("project-id")
108
+ }, {
109
+ dashboardName: ctx.str("dashboard-name")
110
+ });
111
+ }
112
+ };
113
+
114
+ // src/commands/analysis/update-dashboard.ts
115
+ var updateDashboard = {
116
+ service: "analysis",
117
+ command: "+update-dashboard",
118
+ description: "Update dashboard report layout",
119
+ flags: [
120
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
121
+ { name: "dashboard-id", type: "number", required: true, desc: "Dashboard ID" },
122
+ { name: "reports", type: "json", required: true, desc: "[{reportId, reportWidth?, indexOrder}]" }
123
+ ],
124
+ risk: "write",
125
+ execute: async (ctx) => {
126
+ return ctx.api("POST", "/v1/ta/dashboard/update-dashboard", {
127
+ projectId: ctx.num("project-id")
128
+ }, {
129
+ dashbordId: ctx.num("dashboard-id"),
130
+ reports: ctx.json("reports")
131
+ });
132
+ }
133
+ };
134
+
135
+ // src/commands/analysis/list-dashboard-reports.ts
136
+ var listDashboardReports = {
137
+ service: "analysis",
138
+ command: "+list-dashboard-reports",
139
+ description: "List reports within a dashboard",
140
+ flags: [
141
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
142
+ { name: "dashboard-id", type: "number", required: true, desc: "Dashboard ID" }
143
+ ],
144
+ risk: "read",
145
+ execute: async (ctx) => {
146
+ const result = await ctx.api("POST", "/v1/ta/dashboard/search-dashboard", {
147
+ projectId: ctx.num("project-id")
148
+ }, {
149
+ dashboardId: ctx.num("dashboard-id")
150
+ });
151
+ return result?.eventReportList ?? result;
152
+ }
153
+ };
154
+
155
+ // src/commands/analysis/query-report-data.ts
156
+ var queryReportData = {
157
+ service: "analysis",
158
+ command: "+query-report-data",
159
+ description: "Query report data by report ID",
160
+ flags: [
161
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
162
+ { name: "report-id", type: "number", required: true, desc: "Report ID" },
163
+ { name: "dashboard-id", type: "number", desc: "Dashboard ID (optional)" },
164
+ { name: "start-time", type: "string", desc: "Start time (YYYY-MM-DD HH:mm:ss)" },
165
+ { name: "end-time", type: "string", desc: "End time (YYYY-MM-DD HH:mm:ss)" }
166
+ ],
167
+ risk: "read",
168
+ execute: async (ctx) => {
169
+ const projectId = ctx.num("project-id");
170
+ const reportId = ctx.num("report-id");
171
+ const report = await ctx.api("GET", "/v1/ta/event/reportsearch", {
172
+ projectId,
173
+ reportId
174
+ });
175
+ const qp = {
176
+ events: report.events,
177
+ eventView: report.eventView
178
+ };
179
+ const startTime = ctx.str("start-time");
180
+ const endTime = ctx.str("end-time");
181
+ if (startTime) qp.eventView = { ...qp.eventView, startTime };
182
+ if (endTime) qp.eventView = { ...qp.eventView, endTime };
183
+ return ctx.queryReportData(projectId, reportId, qp, report.reportModel || 0);
184
+ }
185
+ };
186
+
187
+ // src/commands/analysis/query-sql.ts
188
+ var querySql = {
189
+ service: "analysis",
190
+ command: "+query-sql",
191
+ description: "Execute a SQL query against the project",
192
+ flags: [
193
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
194
+ { name: "sql", type: "string", required: true, desc: "SQL query string" }
195
+ ],
196
+ risk: "read",
197
+ execute: async (ctx) => {
198
+ return ctx.querySql(ctx.num("project-id"), ctx.str("sql"));
199
+ }
200
+ };
201
+
202
+ // src/commands/analysis/index.ts
203
+ var commands = [
204
+ listReports,
205
+ getReport,
206
+ saveReport,
207
+ listDashboards,
208
+ getDashboard,
209
+ createDashboard,
210
+ updateDashboard,
211
+ listDashboardReports,
212
+ queryReportData,
213
+ querySql
214
+ ];
215
+ var analysis_default = commands;
216
+ export {
217
+ analysis_default as default
218
+ };
@@ -0,0 +1,216 @@
1
+ // src/commands/analysis/list-reports.ts
2
+ var listReports = {
3
+ service: "analysis",
4
+ command: "+list-reports",
5
+ description: "List all analysis reports for a project",
6
+ flags: [
7
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
8
+ ],
9
+ risk: "read",
10
+ execute: async (ctx) => {
11
+ return ctx.api("POST", "/v1/ta/event/listAll", {
12
+ projectId: ctx.num("project-id")
13
+ });
14
+ }
15
+ };
16
+
17
+ // src/commands/analysis/get-report.ts
18
+ var getReport = {
19
+ service: "analysis",
20
+ command: "+get-report",
21
+ description: "Get full report definition by ID",
22
+ flags: [
23
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
24
+ { name: "report-id", type: "number", required: true, desc: "Report ID" }
25
+ ],
26
+ risk: "read",
27
+ execute: async (ctx) => {
28
+ return ctx.api("GET", "/v1/ta/event/reportsearch", {
29
+ projectId: ctx.num("project-id"),
30
+ reportId: ctx.num("report-id")
31
+ });
32
+ }
33
+ };
34
+
35
+ // src/commands/analysis/save-report.ts
36
+ var saveReport = {
37
+ service: "analysis",
38
+ command: "+save-report",
39
+ description: "Save (create/update) an analysis report",
40
+ flags: [
41
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
42
+ { name: "report-name", type: "string", required: true, desc: "Report name" },
43
+ { name: "report-model", type: "number", required: true, desc: "0=Event, 1=Retention, 2=Funnel, 10=Distribution" },
44
+ { name: "events", type: "json", required: true, desc: "Events configuration array" },
45
+ { name: "event-view", type: "json", required: true, desc: "Event view configuration" }
46
+ ],
47
+ risk: "write",
48
+ execute: async (ctx) => {
49
+ return ctx.api("POST", "/v1/ta/event/reportsave", {
50
+ projectId: ctx.num("project-id")
51
+ }, {
52
+ reportName: ctx.str("report-name"),
53
+ reportModel: ctx.num("report-model"),
54
+ events: ctx.json("events"),
55
+ eventView: ctx.json("event-view")
56
+ });
57
+ }
58
+ };
59
+
60
+ // src/commands/analysis/list-dashboards.ts
61
+ var listDashboards = {
62
+ service: "analysis",
63
+ command: "+list-dashboards",
64
+ description: "List all dashboards for a project",
65
+ flags: [
66
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
67
+ ],
68
+ risk: "read",
69
+ execute: async (ctx) => {
70
+ return ctx.api("GET", "/v1/ta/dashboard/all-dashboards", {
71
+ projectId: ctx.num("project-id")
72
+ });
73
+ }
74
+ };
75
+
76
+ // src/commands/analysis/get-dashboard.ts
77
+ var getDashboard = {
78
+ service: "analysis",
79
+ command: "+get-dashboard",
80
+ description: "Get dashboard details by ID",
81
+ flags: [
82
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
83
+ { name: "dashboard-id", type: "number", required: true, desc: "Dashboard ID" }
84
+ ],
85
+ risk: "read",
86
+ execute: async (ctx) => {
87
+ return ctx.api("POST", "/v1/ta/dashboard/search-dashboard", {
88
+ projectId: ctx.num("project-id"),
89
+ dashbordId: ctx.num("dashboard-id")
90
+ });
91
+ }
92
+ };
93
+
94
+ // src/commands/analysis/create-dashboard.ts
95
+ var createDashboard = {
96
+ service: "analysis",
97
+ command: "+create-dashboard",
98
+ description: "Create a new dashboard",
99
+ flags: [
100
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
101
+ { name: "dashboard-name", type: "string", required: true, desc: "Dashboard name" }
102
+ ],
103
+ risk: "write",
104
+ execute: async (ctx) => {
105
+ return ctx.api("POST", "/v1/ta/dashboard/create-dashboard", {
106
+ projectId: ctx.num("project-id")
107
+ }, {
108
+ dashboardName: ctx.str("dashboard-name")
109
+ });
110
+ }
111
+ };
112
+
113
+ // src/commands/analysis/update-dashboard.ts
114
+ var updateDashboard = {
115
+ service: "analysis",
116
+ command: "+update-dashboard",
117
+ description: "Update dashboard report layout",
118
+ flags: [
119
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
120
+ { name: "dashboard-id", type: "number", required: true, desc: "Dashboard ID" },
121
+ { name: "reports", type: "json", required: true, desc: "[{reportId, reportWidth?, indexOrder}]" }
122
+ ],
123
+ risk: "write",
124
+ execute: async (ctx) => {
125
+ return ctx.api("POST", "/v1/ta/dashboard/update-dashboard", {
126
+ projectId: ctx.num("project-id")
127
+ }, {
128
+ dashbordId: ctx.num("dashboard-id"),
129
+ reports: ctx.json("reports")
130
+ });
131
+ }
132
+ };
133
+
134
+ // src/commands/analysis/list-dashboard-reports.ts
135
+ var listDashboardReports = {
136
+ service: "analysis",
137
+ command: "+list-dashboard-reports",
138
+ description: "List reports within a dashboard",
139
+ flags: [
140
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
141
+ { name: "dashboard-id", type: "number", required: true, desc: "Dashboard ID" }
142
+ ],
143
+ risk: "read",
144
+ execute: async (ctx) => {
145
+ const result = await ctx.api("POST", "/v1/ta/dashboard/search-dashboard", {
146
+ projectId: ctx.num("project-id"),
147
+ dashbordId: ctx.num("dashboard-id")
148
+ });
149
+ return result?.eventReportList ?? result;
150
+ }
151
+ };
152
+
153
+ // src/commands/analysis/query-report-data.ts
154
+ var queryReportData = {
155
+ service: "analysis",
156
+ command: "+query-report-data",
157
+ description: "Query report data by report ID",
158
+ flags: [
159
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
160
+ { name: "report-id", type: "number", required: true, desc: "Report ID" },
161
+ { name: "dashboard-id", type: "number", desc: "Dashboard ID (optional)" },
162
+ { name: "start-time", type: "string", desc: "Start time (YYYY-MM-DD HH:mm:ss)" },
163
+ { name: "end-time", type: "string", desc: "End time (YYYY-MM-DD HH:mm:ss)" }
164
+ ],
165
+ risk: "read",
166
+ execute: async (ctx) => {
167
+ const projectId = ctx.num("project-id");
168
+ const reportId = ctx.num("report-id");
169
+ const report = await ctx.api("GET", "/v1/ta/event/reportsearch", {
170
+ projectId,
171
+ reportId
172
+ });
173
+ const qp = {
174
+ events: report.events,
175
+ eventView: report.eventView
176
+ };
177
+ const startTime = ctx.str("start-time");
178
+ const endTime = ctx.str("end-time");
179
+ if (startTime) qp.eventView = { ...qp.eventView, startTime };
180
+ if (endTime) qp.eventView = { ...qp.eventView, endTime };
181
+ return ctx.queryReportData(projectId, reportId, qp, report.reportModel || 0);
182
+ }
183
+ };
184
+
185
+ // src/commands/analysis/query-sql.ts
186
+ var querySql = {
187
+ service: "analysis",
188
+ command: "+query-sql",
189
+ description: "Execute a SQL query against the project",
190
+ flags: [
191
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
192
+ { name: "sql", type: "string", required: true, desc: "SQL query string" }
193
+ ],
194
+ risk: "read",
195
+ execute: async (ctx) => {
196
+ return ctx.querySql(ctx.num("project-id"), ctx.str("sql"));
197
+ }
198
+ };
199
+
200
+ // src/commands/analysis/index.ts
201
+ var commands = [
202
+ listReports,
203
+ getReport,
204
+ saveReport,
205
+ listDashboards,
206
+ getDashboard,
207
+ createDashboard,
208
+ updateDashboard,
209
+ listDashboardReports,
210
+ queryReportData,
211
+ querySql
212
+ ];
213
+ var analysis_default = commands;
214
+ export {
215
+ analysis_default as default
216
+ };