@zhoujinandrew/te-cli 1.0.0

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 (72) hide show
  1. package/README.md +109 -0
  2. package/bin/te-cli.js +2 -0
  3. package/dist/analysis-SFPXKD3E.js +218 -0
  4. package/dist/audience-AZ72TU5F.js +119 -0
  5. package/dist/auth-2OVPSXHK.js +19 -0
  6. package/dist/auth-6QCDAUYV.js +67 -0
  7. package/dist/auth-CFVQVVQN.js +51 -0
  8. package/dist/auth-QNSRS5ZR.js +19 -0
  9. package/dist/auth-V4MDYFHU.js +67 -0
  10. package/dist/auth-Z652VWDK.js +19 -0
  11. package/dist/chunk-4YPCK7T5.js +217 -0
  12. package/dist/chunk-C3VJLU5Y.js +206 -0
  13. package/dist/chunk-CFCHSAMQ.js +108 -0
  14. package/dist/chunk-KA66K7EL.js +144 -0
  15. package/dist/chunk-KAWQCMDL.js +44 -0
  16. package/dist/chunk-KM57HI5B.js +107 -0
  17. package/dist/chunk-KNKRSOCY.js +144 -0
  18. package/dist/chunk-P7NQZGSZ.js +217 -0
  19. package/dist/chunk-STTYG7WN.js +91 -0
  20. package/dist/chunk-V3D6XL5Z.js +134 -0
  21. package/dist/client-CSJ3XBC4.js +16 -0
  22. package/dist/client-EZSKQFIH.js +16 -0
  23. package/dist/client-OT7PTMI2.js +16 -0
  24. package/dist/config-53KUB7OG.js +146 -0
  25. package/dist/config-QQE7LMPZ.js +40 -0
  26. package/dist/config-S53L4MQK.js +242 -0
  27. package/dist/index.js +239 -0
  28. package/dist/meta-ZXBX5RER.js +135 -0
  29. package/dist/operation-6POPVVIZ.js +214 -0
  30. package/dist/raw-76GSW4Q4.js +59 -0
  31. package/dist/raw-K2FR7QAI.js +55 -0
  32. package/dist/raw-YVFTDHSI.js +59 -0
  33. package/package.json +40 -0
  34. package/skills/te-analysis/SKILL.md +93 -0
  35. package/skills/te-analysis/references/create-dashboard.md +30 -0
  36. package/skills/te-analysis/references/get-dashboard.md +24 -0
  37. package/skills/te-analysis/references/get-report.md +24 -0
  38. package/skills/te-analysis/references/list-dashboard-reports.md +24 -0
  39. package/skills/te-analysis/references/list-dashboards.md +23 -0
  40. package/skills/te-analysis/references/list-reports.md +26 -0
  41. package/skills/te-analysis/references/query-report-data.md +34 -0
  42. package/skills/te-analysis/references/query-sql.md +31 -0
  43. package/skills/te-analysis/references/save-report.md +42 -0
  44. package/skills/te-analysis/references/update-dashboard.md +33 -0
  45. package/skills/te-audience/SKILL.md +60 -0
  46. package/skills/te-audience/references/te-audience-get-tag.md +21 -0
  47. package/skills/te-audience/references/te-audience-list-audience-events.md +20 -0
  48. package/skills/te-audience/references/te-audience-list-clusters.md +20 -0
  49. package/skills/te-audience/references/te-audience-list-tags.md +23 -0
  50. package/skills/te-audience/references/te-audience-load-audience-props.md +25 -0
  51. package/skills/te-audience/references/te-audience-predict-cluster-count.md +22 -0
  52. package/skills/te-meta/SKILL.md +80 -0
  53. package/skills/te-meta/references/get-table-columns.md +29 -0
  54. package/skills/te-meta/references/list-entities.md +26 -0
  55. package/skills/te-meta/references/list-events.md +29 -0
  56. package/skills/te-meta/references/list-metrics.md +26 -0
  57. package/skills/te-meta/references/list-tables.md +26 -0
  58. package/skills/te-meta/references/load-event-props.md +27 -0
  59. package/skills/te-meta/references/load-measure-props.md +24 -0
  60. package/skills/te-operation/SKILL.md +75 -0
  61. package/skills/te-operation/references/te-operation-create-task.md +29 -0
  62. package/skills/te-operation/references/te-operation-get-channel.md +20 -0
  63. package/skills/te-operation/references/te-operation-get-flow.md +20 -0
  64. package/skills/te-operation/references/te-operation-get-space-tree.md +19 -0
  65. package/skills/te-operation/references/te-operation-get-task-stats.md +20 -0
  66. package/skills/te-operation/references/te-operation-get-timezone.md +19 -0
  67. package/skills/te-operation/references/te-operation-list-channels.md +19 -0
  68. package/skills/te-operation/references/te-operation-list-flows.md +19 -0
  69. package/skills/te-operation/references/te-operation-list-mark-times.md +19 -0
  70. package/skills/te-operation/references/te-operation-list-tasks.md +25 -0
  71. package/skills/te-operation/references/te-operation-save-flow.md +29 -0
  72. package/skills/te-shared/SKILL.md +115 -0
package/README.md ADDED
@@ -0,0 +1,109 @@
1
+ # te-cli
2
+
3
+ CLI tool for ThinkingEngine (TE) analytics platform. Designed for both AI Agent and human use.
4
+
5
+ ## Installation
6
+
7
+ ```bash
8
+ npm install -g @zhoujinandrew/te-cli
9
+ ```
10
+
11
+ To update to the latest version:
12
+
13
+ ```bash
14
+ npm update -g @zhoujinandrew/te-cli
15
+ ```
16
+
17
+ ## Quick Start
18
+
19
+ ```bash
20
+ # First run — interactive host setup + auto-login
21
+ te-cli config
22
+ ```
23
+
24
+ The `config` command opens an interactive terminal UI:
25
+ - First run: prompts you to add a TE host URL and label, then auto-authenticates
26
+ - Subsequent runs: shows all configured hosts, lets you switch, edit, delete, or add new ones
27
+
28
+ ```
29
+ TE Host Manager (↑↓ select · Enter switch · e edit label · d delete · a add · q quit)
30
+
31
+ ❯ ● Production https://ta.thinkingdata.cn ✓
32
+ ○ Staging https://ta-staging.example.com:8080 ✗
33
+ + Add new host...
34
+ ```
35
+
36
+ After selecting a host, te-cli automatically checks if the token is valid. If not, it triggers `auth login` for you.
37
+
38
+ ## Usage
39
+
40
+ ```bash
41
+ # List events
42
+ te-cli meta +list-events --project-id 1
43
+
44
+ # Execute SQL
45
+ te-cli analysis +query-sql --project-id 1 --sql "SELECT * FROM ta.v_event_1 LIMIT 10"
46
+
47
+ # Table output
48
+ te-cli meta +list-events -p 1 --format table
49
+
50
+ # Raw API call
51
+ te-cli api GET /v1/ta/event/catalog/listEvent --params '{"projectId": 1}'
52
+ ```
53
+
54
+ ## Authentication
55
+
56
+ Authentication is handled per-host. Each TE host URL maintains its own token.
57
+
58
+ ```bash
59
+ # Auto-login for active host (macOS, extracts token from Chrome)
60
+ te-cli auth login
61
+
62
+ # Manually set token
63
+ te-cli auth set-token <your-token>
64
+
65
+ # Check status
66
+ te-cli auth status
67
+
68
+ # Logout
69
+ te-cli auth logout
70
+ ```
71
+
72
+ ## Commands
73
+
74
+ ### Domains
75
+
76
+ | Domain | Commands | Description |
77
+ |--------|----------|-------------|
78
+ | `meta` | 7 | Event catalog, properties, entities, metrics, tables |
79
+ | `analysis` | 10 | Reports, dashboards, SQL queries, report data |
80
+ | `audience` | 6 | Tags, clusters, audience events/properties |
81
+ | `operation` | 11 | Tasks, flows, channels, space navigation |
82
+
83
+ ### Global Options
84
+
85
+ | Option | Description | Default |
86
+ |--------|-------------|---------|
87
+ | `--host <url>` | Override active TE host URL | from config |
88
+ | `--format <json\|table>` | Output format | json |
89
+ | `--jq <expr>` | Filter expression | - |
90
+ | `--dry-run` | Preview request | false |
91
+ | `--yes` | Skip confirmation | false |
92
+
93
+ ## Development
94
+
95
+ ```bash
96
+ git clone https://github.com/zjandrew/te-cli.git
97
+ cd te-cli
98
+ npm install
99
+ npx tsx src/index.ts --help
100
+ ```
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
package/bin/te-cli.js ADDED
@@ -0,0 +1,2 @@
1
+ #!/usr/bin/env node
2
+ import '../dist/index.js';
@@ -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
+ dashbordId: 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
+ dashbordId: 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,119 @@
1
+ // src/commands/audience/list-tags.ts
2
+ var listTags = {
3
+ service: "audience",
4
+ command: "+list-tags",
5
+ description: "List user tags 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/user/tag/list", {
12
+ projectId: ctx.num("project-id")
13
+ }, {});
14
+ }
15
+ };
16
+
17
+ // src/commands/audience/get-tag.ts
18
+ var getTag = {
19
+ service: "audience",
20
+ command: "+get-tag",
21
+ description: "Get details for a specific user tag",
22
+ flags: [
23
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
24
+ { name: "tag-id", type: "number", required: true, desc: "Tag ID" }
25
+ ],
26
+ risk: "read",
27
+ execute: async (ctx) => {
28
+ return ctx.api("GET", "/v1/ta/user/tag/query", {
29
+ projectId: ctx.num("project-id"),
30
+ tagId: ctx.num("tag-id")
31
+ });
32
+ }
33
+ };
34
+
35
+ // src/commands/audience/list-clusters.ts
36
+ var listClusters = {
37
+ service: "audience",
38
+ command: "+list-clusters",
39
+ description: "List clusters for a project",
40
+ flags: [
41
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
42
+ ],
43
+ risk: "read",
44
+ execute: async (ctx) => {
45
+ return ctx.api("GET", "/v1/ta/cluster/console/listProjectClusters", {
46
+ projectId: ctx.num("project-id")
47
+ });
48
+ }
49
+ };
50
+
51
+ // src/commands/audience/predict-cluster-count.ts
52
+ var predictClusterCount = {
53
+ service: "audience",
54
+ command: "+predict-cluster-count",
55
+ description: "Predict entity count for a cluster with given conditions",
56
+ flags: [
57
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
58
+ { name: "conditions", type: "json", required: true, desc: "Cluster conditions object" }
59
+ ],
60
+ risk: "read",
61
+ execute: async (ctx) => {
62
+ return ctx.api("POST", "/v1/hermes/cluster/predictEntityCount", {}, {
63
+ projectId: ctx.num("project-id"),
64
+ ...ctx.json("conditions")
65
+ });
66
+ }
67
+ };
68
+
69
+ // src/commands/audience/list-audience-events.ts
70
+ var listAudienceEvents = {
71
+ service: "audience",
72
+ command: "+list-audience-events",
73
+ description: "List supported events for audience analysis",
74
+ flags: [
75
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" }
76
+ ],
77
+ risk: "read",
78
+ execute: async (ctx) => {
79
+ return ctx.api("POST", "/v1/hermes/common/support/meta/listEvent", {}, {
80
+ projectId: ctx.num("project-id")
81
+ });
82
+ }
83
+ };
84
+
85
+ // src/commands/audience/load-audience-props.ts
86
+ var loadAudienceProps = {
87
+ service: "audience",
88
+ command: "+load-audience-props",
89
+ description: "Load filterable props, prop quotas, and entity props in parallel",
90
+ flags: [
91
+ { name: "project-id", type: "number", required: true, alias: "p", desc: "Project ID" },
92
+ { name: "events", type: "json", desc: "[{eventName}]" }
93
+ ],
94
+ risk: "read",
95
+ execute: async (ctx) => {
96
+ const projectId = ctx.num("project-id");
97
+ const events = ctx.json("events") || [];
98
+ const [filtProps, quotaProps, entityProps] = await Promise.all([
99
+ ctx.api("POST", "/v1/hermes/common/support/meta/loadFiltProps", {}, { projectId, events }),
100
+ ctx.api("POST", "/v1/hermes/common/support/meta/loadPropQuotas", {}, { projectId, events }),
101
+ ctx.api("GET", "/v1/hermes/common/support/entity/props/list", { projectId })
102
+ ]);
103
+ return { filtProps, quotaProps, entityProps };
104
+ }
105
+ };
106
+
107
+ // src/commands/audience/index.ts
108
+ var commands = [
109
+ listTags,
110
+ getTag,
111
+ listClusters,
112
+ predictClusterCount,
113
+ listAudienceEvents,
114
+ loadAudienceProps
115
+ ];
116
+ var audience_default = commands;
117
+ export {
118
+ audience_default as default
119
+ };
@@ -0,0 +1,19 @@
1
+ import {
2
+ clearToken,
3
+ getAuthStatus,
4
+ getToken,
5
+ loadToken,
6
+ resolveHost,
7
+ saveToken,
8
+ setTokenManual
9
+ } from "./chunk-C3VJLU5Y.js";
10
+ import "./chunk-KAWQCMDL.js";
11
+ export {
12
+ clearToken,
13
+ getAuthStatus,
14
+ getToken,
15
+ loadToken,
16
+ resolveHost,
17
+ saveToken,
18
+ setTokenManual
19
+ };
@@ -0,0 +1,67 @@
1
+ import {
2
+ printError,
3
+ printOutput
4
+ } from "./chunk-KM57HI5B.js";
5
+ import {
6
+ clearToken,
7
+ getAuthStatus,
8
+ getToken,
9
+ resolveHost,
10
+ setTokenManual
11
+ } from "./chunk-4YPCK7T5.js";
12
+ import "./chunk-STTYG7WN.js";
13
+
14
+ // src/commands/auth.ts
15
+ function registerAuth(program) {
16
+ const auth = program.command("auth").description("Authentication management");
17
+ auth.command("login").description("Login to TE (auto-extract token from Chrome on macOS)").action(async () => {
18
+ const host = resolveHost(program.opts().host);
19
+ if (!host) {
20
+ printError("config", "No TE host configured.", "Run: te-cli config set-host");
21
+ process.exit(1);
22
+ }
23
+ try {
24
+ const token = await getToken(host);
25
+ process.stderr.write(`[te-cli] Authenticated to ${host}
26
+ `);
27
+ printOutput({ authenticated: true, host, token: token.slice(0, 8) + "..." }, program.opts().format || "json");
28
+ } catch (err) {
29
+ printError("auth", err.message);
30
+ process.exit(1);
31
+ }
32
+ });
33
+ auth.command("set-token <token>").description("Manually set authentication token for active host").action((token) => {
34
+ const host = resolveHost(program.opts().host);
35
+ if (!host) {
36
+ printError("config", "No TE host configured.", "Run: te-cli config set-host");
37
+ process.exit(1);
38
+ }
39
+ setTokenManual(token, host);
40
+ process.stderr.write(`[te-cli] Token saved for ${host}
41
+ `);
42
+ printOutput({ saved: true, host }, program.opts().format || "json");
43
+ });
44
+ auth.command("status").description("Show current authentication status").action(() => {
45
+ const host = resolveHost(program.opts().host);
46
+ if (!host) {
47
+ printOutput({ authenticated: false, host: "(none)", hint: "Run: te-cli config set-host" }, program.opts().format || "json");
48
+ return;
49
+ }
50
+ const status = getAuthStatus(host);
51
+ printOutput(status, program.opts().format || "json");
52
+ });
53
+ auth.command("logout").description("Clear stored token for active host").action(() => {
54
+ const host = resolveHost(program.opts().host);
55
+ if (!host) {
56
+ printError("config", "No TE host configured.", "Run: te-cli config set-host");
57
+ process.exit(1);
58
+ }
59
+ clearToken(host);
60
+ process.stderr.write(`[te-cli] Token cleared for ${host}
61
+ `);
62
+ printOutput({ cleared: true, host }, program.opts().format || "json");
63
+ });
64
+ }
65
+ export {
66
+ registerAuth
67
+ };
@@ -0,0 +1,51 @@
1
+ import {
2
+ printError,
3
+ printOutput
4
+ } from "./chunk-KM57HI5B.js";
5
+ import {
6
+ clearToken,
7
+ getAuthStatus,
8
+ getToken,
9
+ resolveHost,
10
+ setTokenManual
11
+ } from "./chunk-C3VJLU5Y.js";
12
+ import "./chunk-KAWQCMDL.js";
13
+
14
+ // src/commands/auth.ts
15
+ function registerAuth(program) {
16
+ const auth = program.command("auth").description("Authentication management");
17
+ auth.command("login").description("Login to TE (auto-extract token from Chrome on macOS)").action(async () => {
18
+ const host = resolveHost(program.opts().host);
19
+ try {
20
+ const token = await getToken(host);
21
+ process.stderr.write(`[te-cli] Authenticated to ${host}
22
+ `);
23
+ printOutput({ authenticated: true, host, token: token.slice(0, 8) + "..." }, program.opts().format || "json");
24
+ } catch (err) {
25
+ printError("auth", err.message);
26
+ process.exit(1);
27
+ }
28
+ });
29
+ auth.command("set-token <token>").description("Manually set authentication token").action((token) => {
30
+ const host = resolveHost(program.opts().host);
31
+ setTokenManual(token, host);
32
+ process.stderr.write(`[te-cli] Token saved for ${host}
33
+ `);
34
+ printOutput({ saved: true, host }, program.opts().format || "json");
35
+ });
36
+ auth.command("status").description("Show current authentication status").action(() => {
37
+ const host = resolveHost(program.opts().host);
38
+ const status = getAuthStatus(host);
39
+ printOutput(status, program.opts().format || "json");
40
+ });
41
+ auth.command("logout").description("Clear stored token").action(() => {
42
+ const host = resolveHost(program.opts().host);
43
+ clearToken(host);
44
+ process.stderr.write(`[te-cli] Token cleared for ${host}
45
+ `);
46
+ printOutput({ cleared: true, host }, program.opts().format || "json");
47
+ });
48
+ }
49
+ export {
50
+ registerAuth
51
+ };
@@ -0,0 +1,19 @@
1
+ import {
2
+ clearToken,
3
+ getAuthStatus,
4
+ getToken,
5
+ loadToken,
6
+ resolveHost,
7
+ saveToken,
8
+ setTokenManual
9
+ } from "./chunk-4YPCK7T5.js";
10
+ import "./chunk-STTYG7WN.js";
11
+ export {
12
+ clearToken,
13
+ getAuthStatus,
14
+ getToken,
15
+ loadToken,
16
+ resolveHost,
17
+ saveToken,
18
+ setTokenManual
19
+ };
@@ -0,0 +1,67 @@
1
+ import {
2
+ printError,
3
+ printOutput
4
+ } from "./chunk-KM57HI5B.js";
5
+ import {
6
+ clearToken,
7
+ getAuthStatus,
8
+ getToken,
9
+ resolveHost,
10
+ setTokenManual
11
+ } from "./chunk-P7NQZGSZ.js";
12
+ import "./chunk-CFCHSAMQ.js";
13
+
14
+ // src/commands/auth.ts
15
+ function registerAuth(program) {
16
+ const auth = program.command("auth").description("Authentication management");
17
+ auth.command("login").description("Login to TE (auto-extract token from Chrome on macOS)").action(async () => {
18
+ const host = resolveHost(program.opts().host);
19
+ if (!host) {
20
+ printError("config", "No TE host configured.", "Run: te-cli config set-host");
21
+ process.exit(1);
22
+ }
23
+ try {
24
+ const token = await getToken(host);
25
+ process.stderr.write(`[te-cli] Authenticated to ${host}
26
+ `);
27
+ printOutput({ authenticated: true, host, token: token.slice(0, 8) + "..." }, program.opts().format || "json");
28
+ } catch (err) {
29
+ printError("auth", err.message);
30
+ process.exit(1);
31
+ }
32
+ });
33
+ auth.command("set-token <token>").description("Manually set authentication token for active host").action((token) => {
34
+ const host = resolveHost(program.opts().host);
35
+ if (!host) {
36
+ printError("config", "No TE host configured.", "Run: te-cli config set-host");
37
+ process.exit(1);
38
+ }
39
+ setTokenManual(token, host);
40
+ process.stderr.write(`[te-cli] Token saved for ${host}
41
+ `);
42
+ printOutput({ saved: true, host }, program.opts().format || "json");
43
+ });
44
+ auth.command("status").description("Show current authentication status").action(() => {
45
+ const host = resolveHost(program.opts().host);
46
+ if (!host) {
47
+ printOutput({ authenticated: false, host: "(none)", hint: "Run: te-cli config set-host" }, program.opts().format || "json");
48
+ return;
49
+ }
50
+ const status = getAuthStatus(host);
51
+ printOutput(status, program.opts().format || "json");
52
+ });
53
+ auth.command("logout").description("Clear stored token for active host").action(() => {
54
+ const host = resolveHost(program.opts().host);
55
+ if (!host) {
56
+ printError("config", "No TE host configured.", "Run: te-cli config set-host");
57
+ process.exit(1);
58
+ }
59
+ clearToken(host);
60
+ process.stderr.write(`[te-cli] Token cleared for ${host}
61
+ `);
62
+ printOutput({ cleared: true, host }, program.opts().format || "json");
63
+ });
64
+ }
65
+ export {
66
+ registerAuth
67
+ };
@@ -0,0 +1,19 @@
1
+ import {
2
+ clearToken,
3
+ getAuthStatus,
4
+ getToken,
5
+ loadToken,
6
+ resolveHost,
7
+ saveToken,
8
+ setTokenManual
9
+ } from "./chunk-P7NQZGSZ.js";
10
+ import "./chunk-CFCHSAMQ.js";
11
+ export {
12
+ clearToken,
13
+ getAuthStatus,
14
+ getToken,
15
+ loadToken,
16
+ resolveHost,
17
+ saveToken,
18
+ setTokenManual
19
+ };