@tonk/cli 0.2.5 → 0.2.7

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 (67) hide show
  1. package/dist/commands/create.d.ts.map +1 -1
  2. package/dist/commands/create.js +8 -6
  3. package/dist/commands/create.js.map +1 -1
  4. package/dist/commands/hello.d.ts.map +1 -1
  5. package/dist/commands/hello.js +12 -0
  6. package/dist/commands/hello.js.map +1 -1
  7. package/dist/commands/kill.d.ts.map +1 -1
  8. package/dist/commands/kill.js +24 -0
  9. package/dist/commands/kill.js.map +1 -1
  10. package/dist/commands/ls.d.ts.map +1 -1
  11. package/dist/commands/ls.js +18 -0
  12. package/dist/commands/ls.js.map +1 -1
  13. package/dist/commands/proxy.d.ts.map +1 -1
  14. package/dist/commands/proxy.js +18 -0
  15. package/dist/commands/proxy.js.map +1 -1
  16. package/dist/commands/ps.d.ts.map +1 -1
  17. package/dist/commands/ps.js +18 -0
  18. package/dist/commands/ps.js.map +1 -1
  19. package/dist/commands/push.d.ts.map +1 -1
  20. package/dist/commands/push.js +25 -1
  21. package/dist/commands/push.js.map +1 -1
  22. package/dist/commands/start.d.ts.map +1 -1
  23. package/dist/commands/start.js +19 -0
  24. package/dist/commands/start.js.map +1 -1
  25. package/dist/commands/worker/commands.d.ts +42 -0
  26. package/dist/commands/worker/commands.d.ts.map +1 -0
  27. package/dist/commands/worker/commands.js +906 -0
  28. package/dist/commands/worker/commands.js.map +1 -0
  29. package/dist/commands/worker/index.d.ts +7 -0
  30. package/dist/commands/worker/index.d.ts.map +1 -0
  31. package/dist/commands/worker/index.js +30 -0
  32. package/dist/commands/worker/index.js.map +1 -0
  33. package/dist/commands/worker/utils/config.d.ts +26 -0
  34. package/dist/commands/worker/utils/config.d.ts.map +1 -0
  35. package/dist/commands/worker/utils/config.js +197 -0
  36. package/dist/commands/worker/utils/config.js.map +1 -0
  37. package/dist/commands/worker/utils/display.d.ts +6 -0
  38. package/dist/commands/worker/utils/display.d.ts.map +1 -0
  39. package/dist/commands/worker/utils/display.js +32 -0
  40. package/dist/commands/worker/utils/display.js.map +1 -0
  41. package/dist/commands/worker/utils/finder.d.ts +12 -0
  42. package/dist/commands/worker/utils/finder.d.ts.map +1 -0
  43. package/dist/commands/worker/utils/finder.js +60 -0
  44. package/dist/commands/worker/utils/finder.js.map +1 -0
  45. package/dist/commands/worker.d.ts +3 -0
  46. package/dist/commands/worker.d.ts.map +1 -0
  47. package/dist/commands/worker.js +527 -0
  48. package/dist/commands/worker.js.map +1 -0
  49. package/dist/lib/workerManager.d.ts +60 -0
  50. package/dist/lib/workerManager.d.ts.map +1 -0
  51. package/dist/lib/workerManager.js +406 -0
  52. package/dist/lib/workerManager.js.map +1 -0
  53. package/dist/tonk.js +10 -0
  54. package/dist/tonk.js.map +1 -1
  55. package/dist/types/worker.d.ts +102 -0
  56. package/dist/types/worker.d.ts.map +1 -0
  57. package/dist/types/worker.js +7 -0
  58. package/dist/types/worker.js.map +1 -0
  59. package/dist/types/workerConfig.d.ts +164 -0
  60. package/dist/types/workerConfig.d.ts.map +1 -0
  61. package/dist/types/workerConfig.js +80 -0
  62. package/dist/types/workerConfig.js.map +1 -0
  63. package/dist/utils/analytics.d.ts +26 -0
  64. package/dist/utils/analytics.d.ts.map +1 -0
  65. package/dist/utils/analytics.js +155 -0
  66. package/dist/utils/analytics.js.map +1 -0
  67. package/package.json +4 -1
@@ -0,0 +1,164 @@
1
+ /**
2
+ * Worker YAML Configuration Schema
3
+ *
4
+ * This file defines the standard format for worker configuration YAML files in Tonk.
5
+ */
6
+ import { z } from 'zod';
7
+ /**
8
+ * Zod schema for worker health check configuration
9
+ */
10
+ export declare const WorkerHealthCheckSchema: z.ZodObject<{
11
+ endpoint: z.ZodOptional<z.ZodString>;
12
+ method: z.ZodDefault<z.ZodString>;
13
+ interval: z.ZodDefault<z.ZodNumber>;
14
+ timeout: z.ZodDefault<z.ZodNumber>;
15
+ }, "strip", z.ZodTypeAny, {
16
+ method: string;
17
+ timeout: number;
18
+ interval: number;
19
+ endpoint?: string | undefined;
20
+ }, {
21
+ method?: string | undefined;
22
+ endpoint?: string | undefined;
23
+ timeout?: number | undefined;
24
+ interval?: number | undefined;
25
+ }>;
26
+ /**
27
+ * Zod schema for worker configuration
28
+ */
29
+ export declare const WorkerConfigSchema: z.ZodObject<{
30
+ name: z.ZodString;
31
+ description: z.ZodOptional<z.ZodString>;
32
+ version: z.ZodOptional<z.ZodString>;
33
+ endpoint: z.ZodString;
34
+ protocol: z.ZodDefault<z.ZodString>;
35
+ healthCheck: z.ZodOptional<z.ZodObject<{
36
+ endpoint: z.ZodOptional<z.ZodString>;
37
+ method: z.ZodDefault<z.ZodString>;
38
+ interval: z.ZodDefault<z.ZodNumber>;
39
+ timeout: z.ZodDefault<z.ZodNumber>;
40
+ }, "strip", z.ZodTypeAny, {
41
+ method: string;
42
+ timeout: number;
43
+ interval: number;
44
+ endpoint?: string | undefined;
45
+ }, {
46
+ method?: string | undefined;
47
+ endpoint?: string | undefined;
48
+ timeout?: number | undefined;
49
+ interval?: number | undefined;
50
+ }>>;
51
+ process: z.ZodObject<{
52
+ script: z.ZodString;
53
+ cwd: z.ZodOptional<z.ZodString>;
54
+ instances: z.ZodDefault<z.ZodNumber>;
55
+ autorestart: z.ZodDefault<z.ZodBoolean>;
56
+ watch: z.ZodDefault<z.ZodBoolean>;
57
+ max_memory_restart: z.ZodOptional<z.ZodString>;
58
+ env: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodString>>;
59
+ }, "strip", z.ZodTypeAny, {
60
+ script: string;
61
+ instances: number;
62
+ autorestart: boolean;
63
+ watch: boolean;
64
+ env?: Record<string, string> | undefined;
65
+ cwd?: string | undefined;
66
+ max_memory_restart?: string | undefined;
67
+ }, {
68
+ script: string;
69
+ env?: Record<string, string> | undefined;
70
+ cwd?: string | undefined;
71
+ instances?: number | undefined;
72
+ autorestart?: boolean | undefined;
73
+ watch?: boolean | undefined;
74
+ max_memory_restart?: string | undefined;
75
+ }>;
76
+ config: z.ZodOptional<z.ZodRecord<z.ZodString, z.ZodAny>>;
77
+ }, "strip", z.ZodTypeAny, {
78
+ name: string;
79
+ process: {
80
+ script: string;
81
+ instances: number;
82
+ autorestart: boolean;
83
+ watch: boolean;
84
+ env?: Record<string, string> | undefined;
85
+ cwd?: string | undefined;
86
+ max_memory_restart?: string | undefined;
87
+ };
88
+ endpoint: string;
89
+ protocol: string;
90
+ healthCheck?: {
91
+ method: string;
92
+ timeout: number;
93
+ interval: number;
94
+ endpoint?: string | undefined;
95
+ } | undefined;
96
+ version?: string | undefined;
97
+ description?: string | undefined;
98
+ config?: Record<string, any> | undefined;
99
+ }, {
100
+ name: string;
101
+ process: {
102
+ script: string;
103
+ env?: Record<string, string> | undefined;
104
+ cwd?: string | undefined;
105
+ instances?: number | undefined;
106
+ autorestart?: boolean | undefined;
107
+ watch?: boolean | undefined;
108
+ max_memory_restart?: string | undefined;
109
+ };
110
+ endpoint: string;
111
+ healthCheck?: {
112
+ method?: string | undefined;
113
+ endpoint?: string | undefined;
114
+ timeout?: number | undefined;
115
+ interval?: number | undefined;
116
+ } | undefined;
117
+ version?: string | undefined;
118
+ description?: string | undefined;
119
+ protocol?: string | undefined;
120
+ config?: Record<string, any> | undefined;
121
+ }>;
122
+ /**
123
+ * Type for worker configuration
124
+ */
125
+ export type WorkerConfig = z.infer<typeof WorkerConfigSchema>;
126
+ /**
127
+ * Example YAML configuration:
128
+ *
129
+ * ```yaml
130
+ * # Worker Information
131
+ * name: obsidian-worker
132
+ * description: Tonk worker for Obsidian integration
133
+ * version: 1.0.0
134
+ *
135
+ * # Connection Details
136
+ * endpoint: http://localhost:5555/tonk
137
+ * protocol: http
138
+ *
139
+ * # Health Check Configuration
140
+ * healthCheck:
141
+ * endpoint: http://localhost:5555/health
142
+ * method: GET
143
+ * interval: 30000
144
+ * timeout: 5000
145
+ *
146
+ * # Process Management
147
+ * process:
148
+ * script: ./dist/index.js
149
+ * cwd: ./
150
+ * instances: 1
151
+ * autorestart: true
152
+ * watch: false
153
+ * max_memory_restart: 500M
154
+ * env:
155
+ * NODE_ENV: production
156
+ * CHROMA_URL: http://localhost:8888
157
+ *
158
+ * # Additional Configuration
159
+ * config:
160
+ * syncDirectory: notes
161
+ * embedModel: all-MiniLM-L6-v2
162
+ * ```
163
+ */
164
+ //# sourceMappingURL=workerConfig.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workerConfig.d.ts","sourceRoot":"","sources":["../../src/types/workerConfig.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB;;GAEG;AACH,eAAO,MAAM,uBAAuB;;;;;;;;;;;;;;;EAKlC,CAAC;AAEH;;GAEG;AACH,eAAO,MAAM,kBAAkB;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;EA0B7B,CAAC;AAEH;;GAEG;AACH,MAAM,MAAM,YAAY,GAAG,CAAC,CAAC,KAAK,CAAC,OAAO,kBAAkB,CAAC,CAAC;AAE9D;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG"}
@@ -0,0 +1,80 @@
1
+ /**
2
+ * Worker YAML Configuration Schema
3
+ *
4
+ * This file defines the standard format for worker configuration YAML files in Tonk.
5
+ */
6
+ import { z } from 'zod';
7
+ /**
8
+ * Zod schema for worker health check configuration
9
+ */
10
+ export const WorkerHealthCheckSchema = z.object({
11
+ endpoint: z.string().optional(),
12
+ method: z.string().default('GET'),
13
+ interval: z.number().default(30000),
14
+ timeout: z.number().default(5000),
15
+ });
16
+ /**
17
+ * Zod schema for worker configuration
18
+ */
19
+ export const WorkerConfigSchema = z.object({
20
+ // Basic worker information
21
+ name: z.string(),
22
+ description: z.string().optional(),
23
+ version: z.string().optional(),
24
+ // Connection details
25
+ endpoint: z.string(),
26
+ protocol: z.string().default('http'),
27
+ // Health check configuration
28
+ healthCheck: WorkerHealthCheckSchema.optional(),
29
+ // Process management
30
+ process: z.object({
31
+ script: z.string(),
32
+ cwd: z.string().optional(),
33
+ instances: z.number().default(1),
34
+ autorestart: z.boolean().default(true),
35
+ watch: z.boolean().default(false),
36
+ max_memory_restart: z.string().optional(),
37
+ env: z.record(z.string()).optional(),
38
+ }),
39
+ // Additional custom configuration
40
+ config: z.record(z.any()).optional(),
41
+ });
42
+ /**
43
+ * Example YAML configuration:
44
+ *
45
+ * ```yaml
46
+ * # Worker Information
47
+ * name: obsidian-worker
48
+ * description: Tonk worker for Obsidian integration
49
+ * version: 1.0.0
50
+ *
51
+ * # Connection Details
52
+ * endpoint: http://localhost:5555/tonk
53
+ * protocol: http
54
+ *
55
+ * # Health Check Configuration
56
+ * healthCheck:
57
+ * endpoint: http://localhost:5555/health
58
+ * method: GET
59
+ * interval: 30000
60
+ * timeout: 5000
61
+ *
62
+ * # Process Management
63
+ * process:
64
+ * script: ./dist/index.js
65
+ * cwd: ./
66
+ * instances: 1
67
+ * autorestart: true
68
+ * watch: false
69
+ * max_memory_restart: 500M
70
+ * env:
71
+ * NODE_ENV: production
72
+ * CHROMA_URL: http://localhost:8888
73
+ *
74
+ * # Additional Configuration
75
+ * config:
76
+ * syncDirectory: notes
77
+ * embedModel: all-MiniLM-L6-v2
78
+ * ```
79
+ */
80
+ //# sourceMappingURL=workerConfig.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"workerConfig.js","sourceRoot":"","sources":["../../src/types/workerConfig.ts"],"names":[],"mappings":"AAAA;;;;GAIG;AACH,OAAO,EAAC,CAAC,EAAC,MAAM,KAAK,CAAC;AAEtB;;GAEG;AACH,MAAM,CAAC,MAAM,uBAAuB,GAAG,CAAC,CAAC,MAAM,CAAC;IAC9C,QAAQ,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,QAAQ,EAAE;IAC/B,MAAM,EAAE,CAAC,CAAC,MAAM,EAAE,CAAC,OAA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AAC,CAAC,CAAC,GAAG,EAAE,CAAC,CAAC,QAAQ,EAAE;CACrC,CAAC,CAAC;AAOH;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;GAqCG"}
@@ -0,0 +1,26 @@
1
+ import { PostHog } from 'posthog-node';
2
+ /**
3
+ * Initialize PostHog analytics
4
+ */
5
+ export declare function initAnalytics(): PostHog;
6
+ /**
7
+ * Track a command execution
8
+ */
9
+ export declare function trackCommand(commandName: string, options?: Record<string, any>, additionalProps?: Record<string, any>): void;
10
+ /**
11
+ * Track command success
12
+ */
13
+ export declare function trackCommandSuccess(commandName: string, duration?: number, additionalProps?: Record<string, any>): void;
14
+ /**
15
+ * Track command error
16
+ */
17
+ export declare function trackCommandError(commandName: string, error: Error | string, duration?: number, additionalProps?: Record<string, any>): void;
18
+ /**
19
+ * Shutdown analytics and flush any pending events
20
+ */
21
+ export declare function shutdownAnalytics(): Promise<void>;
22
+ /**
23
+ * Wrapper function to track command execution with timing
24
+ */
25
+ export declare function withAnalytics<T extends any[], R>(commandName: string, fn: (...args: T) => R | Promise<R>, optionsExtractor?: (...args: T) => Record<string, any>): (...args: T) => Promise<R>;
26
+ //# sourceMappingURL=analytics.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.d.ts","sourceRoot":"","sources":["../../src/utils/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AAwBrC;;GAEG;AACH,wBAAgB,aAAa,IAAI,OAAO,CAOvC;AAgBD;;GAEG;AACH,wBAAgB,YAAY,CAC1B,WAAW,EAAE,MAAM,EACnB,OAAO,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,EACjC,eAAe,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GACxC,IAAI,CAqBN;AAED;;GAEG;AACH,wBAAgB,mBAAmB,CACjC,WAAW,EAAE,MAAM,EACnB,QAAQ,CAAC,EAAE,MAAM,EACjB,eAAe,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GACxC,IAAI,CAoBN;AAED;;GAEG;AACH,wBAAgB,iBAAiB,CAC/B,WAAW,EAAE,MAAM,EACnB,KAAK,EAAE,KAAK,GAAG,MAAM,EACrB,QAAQ,CAAC,EAAE,MAAM,EACjB,eAAe,GAAE,MAAM,CAAC,MAAM,EAAE,GAAG,CAAM,GACxC,IAAI,CAsBN;AAED;;GAEG;AACH,wBAAsB,iBAAiB,IAAI,OAAO,CAAC,IAAI,CAAC,CAQvD;AAED;;GAEG;AACH,wBAAgB,aAAa,CAAC,CAAC,SAAS,GAAG,EAAE,EAAE,CAAC,EAC9C,WAAW,EAAE,MAAM,EACnB,EAAE,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,CAAC,GAAG,OAAO,CAAC,CAAC,CAAC,EAClC,gBAAgB,CAAC,EAAE,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,MAAM,CAAC,MAAM,EAAE,GAAG,CAAC,GACrD,CAAC,GAAG,IAAI,EAAE,CAAC,KAAK,OAAO,CAAC,CAAC,CAAC,CAiB5B"}
@@ -0,0 +1,155 @@
1
+ import { PostHog } from 'posthog-node';
2
+ import os from 'os';
3
+ // Fallback machine ID generation if node-machine-id is not available
4
+ function generateFallbackMachineId() {
5
+ const hostname = os.hostname();
6
+ const platform = os.platform();
7
+ const arch = os.arch();
8
+ const userInfo = os.userInfo();
9
+ // Create a simple hash from system info
10
+ const info = `${hostname}-${platform}-${arch}-${userInfo.username}`;
11
+ let hash = 0;
12
+ for (let i = 0; i < info.length; i++) {
13
+ const char = info.charCodeAt(i);
14
+ hash = (hash << 5) - hash + char;
15
+ hash = hash & hash; // Convert to 32-bit integer
16
+ }
17
+ return Math.abs(hash).toString(16);
18
+ }
19
+ // Singleton PostHog instance
20
+ let posthog = null;
21
+ /**
22
+ * Initialize PostHog analytics
23
+ */
24
+ export function initAnalytics() {
25
+ if (!posthog) {
26
+ posthog = new PostHog('phc_8w3fpFuLkY7Agheficdo7GKPpg4XlXg4irucXhhXXTw', {
27
+ host: 'https://eu.i.posthog.com',
28
+ });
29
+ }
30
+ return posthog;
31
+ }
32
+ /**
33
+ * Get a unique machine identifier for analytics
34
+ */
35
+ function getMachineId() {
36
+ try {
37
+ // Try to use node-machine-id if available
38
+ const { machineIdSync } = require('node-machine-id');
39
+ return machineIdSync();
40
+ }
41
+ catch (error) {
42
+ // Fallback to system-based ID
43
+ return generateFallbackMachineId();
44
+ }
45
+ }
46
+ /**
47
+ * Track a command execution
48
+ */
49
+ export function trackCommand(commandName, options = {}, additionalProps = {}) {
50
+ try {
51
+ const analytics = initAnalytics();
52
+ const machineId = getMachineId();
53
+ analytics.capture({
54
+ distinctId: machineId,
55
+ event: 'command_executed',
56
+ properties: {
57
+ command: commandName,
58
+ options,
59
+ platform: os.platform(),
60
+ arch: os.arch(),
61
+ nodeVersion: process.version,
62
+ ...additionalProps,
63
+ },
64
+ });
65
+ }
66
+ catch (error) {
67
+ // Silently fail analytics to not interrupt CLI functionality
68
+ console.debug('Analytics tracking failed:', error);
69
+ }
70
+ }
71
+ /**
72
+ * Track command success
73
+ */
74
+ export function trackCommandSuccess(commandName, duration, additionalProps = {}) {
75
+ try {
76
+ const analytics = initAnalytics();
77
+ const machineId = getMachineId();
78
+ analytics.capture({
79
+ distinctId: machineId,
80
+ event: 'command_success',
81
+ properties: {
82
+ command: commandName,
83
+ duration_ms: duration,
84
+ platform: os.platform(),
85
+ arch: os.arch(),
86
+ nodeVersion: process.version,
87
+ ...additionalProps,
88
+ },
89
+ });
90
+ }
91
+ catch (error) {
92
+ console.debug('Analytics tracking failed:', error);
93
+ }
94
+ }
95
+ /**
96
+ * Track command error
97
+ */
98
+ export function trackCommandError(commandName, error, duration, additionalProps = {}) {
99
+ try {
100
+ const analytics = initAnalytics();
101
+ const machineId = getMachineId();
102
+ analytics.capture({
103
+ distinctId: machineId,
104
+ event: 'command_error',
105
+ properties: {
106
+ command: commandName,
107
+ error: error instanceof Error ? error.message : error,
108
+ error_type: error instanceof Error ? error.constructor.name : 'string',
109
+ duration_ms: duration,
110
+ platform: os.platform(),
111
+ arch: os.arch(),
112
+ nodeVersion: process.version,
113
+ ...additionalProps,
114
+ },
115
+ });
116
+ }
117
+ catch (analyticsError) {
118
+ console.debug('Analytics tracking failed:', analyticsError);
119
+ }
120
+ }
121
+ /**
122
+ * Shutdown analytics and flush any pending events
123
+ */
124
+ export async function shutdownAnalytics() {
125
+ if (posthog) {
126
+ try {
127
+ await posthog.shutdown();
128
+ }
129
+ catch (error) {
130
+ console.debug('Analytics shutdown failed:', error);
131
+ }
132
+ }
133
+ }
134
+ /**
135
+ * Wrapper function to track command execution with timing
136
+ */
137
+ export function withAnalytics(commandName, fn, optionsExtractor) {
138
+ return async (...args) => {
139
+ const startTime = Date.now();
140
+ const options = optionsExtractor ? optionsExtractor(...args) : {};
141
+ try {
142
+ trackCommand(commandName, options);
143
+ const result = await fn(...args);
144
+ const duration = Date.now() - startTime;
145
+ trackCommandSuccess(commandName, duration);
146
+ return result;
147
+ }
148
+ catch (error) {
149
+ const duration = Date.now() - startTime;
150
+ trackCommandError(commandName, error, duration);
151
+ throw error;
152
+ }
153
+ };
154
+ }
155
+ //# sourceMappingURL=analytics.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"analytics.js","sourceRoot":"","sources":["../../src/utils/analytics.ts"],"names":[],"mappings":"AAAA,OAAO,EAAC,OAAO,EAAC,MAAM,cAAc,CAAC;AACrC,OAAO,EAAE,MAAM,IAAI,CAAC;AAEpB,qEAAqE;AACrE,SAAS,yBAAyB;IAChC,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC/B,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAC/B,MAAM,IAAI,GAAG,EAAE,CAAC,IAAI,EAAE,CAAC;IACvB,MAAM,QAAQ,GAAG,EAAE,CAAC,QAAQ,EAAE,CAAC;IAE/B,wCAAwC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B,CAAC,CAAC,CAAC,gBAAgB,CAAC,GAAG,IAAI,CAAC,CAAC,CAAC,CAAC,EAAE,CAAC;QAElE,IAAI,CAAC;YACH,YAAY,CAAC,WAAW,EAAE,OAAO,CAAC,CAAC;YACnC,MAAM,MAAM,GAAG,MAAM,EAAE,CAAC,GAAG,IAAI,CAAC,CAAC;YACjC,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;YACxC,mBAAmB,CAAC,WAAW,EAAE,QAAQ,CAAC,CAAC;YAC3C,OAAO,MAAM,CAAC;QAChB,CAAC;QAAC,OAAO,KAAK,EAAE,CAAC;YACf,MAAM,QAAQ,GAAG,IAAI,CAAC,GAAG,EAAE,GAAG,SAAS,CAAC;YACxC,iBAAiB,CAAC,WAAW,EAAE,KAAc,EAAE,QAAQ,CAAC,CAAC;YACzD,MAAM,KAAK,CAAC;QACd,CAAC;IACH,CAAC,CAAC;AACJ,CAAC"}
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tonk/cli",
3
- "version": "0.2.5",
3
+ "version": "0.2.7",
4
4
  "description": "The Tonk stack command line utility",
5
5
  "type": "module",
6
6
  "bin": {
@@ -38,6 +38,7 @@
38
38
  "dependencies": {
39
39
  "@tonk/server": "^0.2.4",
40
40
  "chalk": "^5.3.0",
41
+ "cli-table3": "^0.6.5",
41
42
  "commander": "^11.1.0",
42
43
  "dotenv": "^16.4.7",
43
44
  "env-paths": "^3.0.0",
@@ -53,8 +54,10 @@
53
54
  "node-fetch": "^3.3.2",
54
55
  "open": "^10.1.0",
55
56
  "ora": "^7.0.1",
57
+ "posthog-node": "^4.18.0",
56
58
  "react": "18",
57
59
  "tar": "^6.2.1",
60
+ "yaml": "^2.3.4",
58
61
  "zod": "^3.24.2"
59
62
  },
60
63
  "devDependencies": {