@tokscale/cli 1.4.3 → 2.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 (188) hide show
  1. package/dist/index.d.ts +3 -0
  2. package/dist/index.d.ts.map +1 -0
  3. package/dist/index.js +128 -0
  4. package/dist/index.js.map +1 -0
  5. package/package.json +19 -26
  6. package/dist/auth.d.ts +0 -17
  7. package/dist/auth.d.ts.map +0 -1
  8. package/dist/auth.js +0 -162
  9. package/dist/auth.js.map +0 -1
  10. package/dist/cli.d.ts +0 -9
  11. package/dist/cli.d.ts.map +0 -1
  12. package/dist/cli.js +0 -1550
  13. package/dist/cli.js.map +0 -1
  14. package/dist/credentials.d.ts +0 -50
  15. package/dist/credentials.d.ts.map +0 -1
  16. package/dist/credentials.js +0 -151
  17. package/dist/credentials.js.map +0 -1
  18. package/dist/cursor.d.ts +0 -167
  19. package/dist/cursor.d.ts.map +0 -1
  20. package/dist/cursor.js +0 -906
  21. package/dist/cursor.js.map +0 -1
  22. package/dist/date-utils.d.ts +0 -10
  23. package/dist/date-utils.d.ts.map +0 -1
  24. package/dist/date-utils.js +0 -47
  25. package/dist/date-utils.js.map +0 -1
  26. package/dist/graph-types.d.ts +0 -142
  27. package/dist/graph-types.d.ts.map +0 -1
  28. package/dist/graph-types.js +0 -6
  29. package/dist/graph-types.js.map +0 -1
  30. package/dist/native-runner.d.ts +0 -11
  31. package/dist/native-runner.d.ts.map +0 -1
  32. package/dist/native-runner.js +0 -77
  33. package/dist/native-runner.js.map +0 -1
  34. package/dist/native.d.ts +0 -106
  35. package/dist/native.d.ts.map +0 -1
  36. package/dist/native.js +0 -302
  37. package/dist/native.js.map +0 -1
  38. package/dist/sessions/types.d.ts +0 -28
  39. package/dist/sessions/types.d.ts.map +0 -1
  40. package/dist/sessions/types.js +0 -27
  41. package/dist/sessions/types.js.map +0 -1
  42. package/dist/spinner.d.ts +0 -75
  43. package/dist/spinner.d.ts.map +0 -1
  44. package/dist/spinner.js +0 -203
  45. package/dist/spinner.js.map +0 -1
  46. package/dist/submit.d.ts +0 -23
  47. package/dist/submit.d.ts.map +0 -1
  48. package/dist/submit.js +0 -294
  49. package/dist/submit.js.map +0 -1
  50. package/dist/table.d.ts +0 -42
  51. package/dist/table.d.ts.map +0 -1
  52. package/dist/table.js +0 -181
  53. package/dist/table.js.map +0 -1
  54. package/dist/tui/App.d.ts +0 -4
  55. package/dist/tui/App.d.ts.map +0 -1
  56. package/dist/tui/App.js +0 -333
  57. package/dist/tui/App.js.map +0 -1
  58. package/dist/tui/components/BarChart.d.ts +0 -17
  59. package/dist/tui/components/BarChart.d.ts.map +0 -1
  60. package/dist/tui/components/BarChart.js +0 -146
  61. package/dist/tui/components/BarChart.js.map +0 -1
  62. package/dist/tui/components/DailyView.d.ts +0 -13
  63. package/dist/tui/components/DailyView.d.ts.map +0 -1
  64. package/dist/tui/components/DailyView.js +0 -86
  65. package/dist/tui/components/DailyView.js.map +0 -1
  66. package/dist/tui/components/DateBreakdownPanel.d.ts +0 -7
  67. package/dist/tui/components/DateBreakdownPanel.d.ts.map +0 -1
  68. package/dist/tui/components/DateBreakdownPanel.js +0 -36
  69. package/dist/tui/components/DateBreakdownPanel.js.map +0 -1
  70. package/dist/tui/components/Footer.d.ts +0 -28
  71. package/dist/tui/components/Footer.d.ts.map +0 -1
  72. package/dist/tui/components/Footer.js +0 -130
  73. package/dist/tui/components/Footer.js.map +0 -1
  74. package/dist/tui/components/Header.d.ts +0 -9
  75. package/dist/tui/components/Header.d.ts.map +0 -1
  76. package/dist/tui/components/Header.js +0 -20
  77. package/dist/tui/components/Header.js.map +0 -1
  78. package/dist/tui/components/Legend.d.ts +0 -7
  79. package/dist/tui/components/Legend.d.ts.map +0 -1
  80. package/dist/tui/components/Legend.js +0 -16
  81. package/dist/tui/components/Legend.js.map +0 -1
  82. package/dist/tui/components/LoadingSpinner.d.ts +0 -8
  83. package/dist/tui/components/LoadingSpinner.d.ts.map +0 -1
  84. package/dist/tui/components/LoadingSpinner.js +0 -55
  85. package/dist/tui/components/LoadingSpinner.js.map +0 -1
  86. package/dist/tui/components/ModelRow.d.ts +0 -13
  87. package/dist/tui/components/ModelRow.d.ts.map +0 -1
  88. package/dist/tui/components/ModelRow.js +0 -15
  89. package/dist/tui/components/ModelRow.js.map +0 -1
  90. package/dist/tui/components/ModelView.d.ts +0 -13
  91. package/dist/tui/components/ModelView.d.ts.map +0 -1
  92. package/dist/tui/components/ModelView.js +0 -96
  93. package/dist/tui/components/ModelView.js.map +0 -1
  94. package/dist/tui/components/OverviewView.d.ts +0 -14
  95. package/dist/tui/components/OverviewView.d.ts.map +0 -1
  96. package/dist/tui/components/OverviewView.js +0 -65
  97. package/dist/tui/components/OverviewView.js.map +0 -1
  98. package/dist/tui/components/StatsView.d.ts +0 -14
  99. package/dist/tui/components/StatsView.d.ts.map +0 -1
  100. package/dist/tui/components/StatsView.js +0 -102
  101. package/dist/tui/components/StatsView.js.map +0 -1
  102. package/dist/tui/components/TokenBreakdown.d.ts +0 -14
  103. package/dist/tui/components/TokenBreakdown.d.ts.map +0 -1
  104. package/dist/tui/components/TokenBreakdown.js +0 -10
  105. package/dist/tui/components/TokenBreakdown.js.map +0 -1
  106. package/dist/tui/components/index.d.ts +0 -16
  107. package/dist/tui/components/index.d.ts.map +0 -1
  108. package/dist/tui/components/index.js +0 -13
  109. package/dist/tui/components/index.js.map +0 -1
  110. package/dist/tui/config/settings.d.ts +0 -15
  111. package/dist/tui/config/settings.d.ts.map +0 -1
  112. package/dist/tui/config/settings.js +0 -147
  113. package/dist/tui/config/settings.js.map +0 -1
  114. package/dist/tui/config/themes.d.ts +0 -15
  115. package/dist/tui/config/themes.d.ts.map +0 -1
  116. package/dist/tui/config/themes.js +0 -82
  117. package/dist/tui/config/themes.js.map +0 -1
  118. package/dist/tui/hooks/useData.d.ts +0 -19
  119. package/dist/tui/hooks/useData.d.ts.map +0 -1
  120. package/dist/tui/hooks/useData.js +0 -468
  121. package/dist/tui/hooks/useData.js.map +0 -1
  122. package/dist/tui/index.d.ts +0 -4
  123. package/dist/tui/index.d.ts.map +0 -1
  124. package/dist/tui/index.js +0 -36
  125. package/dist/tui/index.js.map +0 -1
  126. package/dist/tui/types/index.d.ts +0 -137
  127. package/dist/tui/types/index.d.ts.map +0 -1
  128. package/dist/tui/types/index.js +0 -26
  129. package/dist/tui/types/index.js.map +0 -1
  130. package/dist/tui/utils/cleanup.d.ts +0 -22
  131. package/dist/tui/utils/cleanup.d.ts.map +0 -1
  132. package/dist/tui/utils/cleanup.js +0 -59
  133. package/dist/tui/utils/cleanup.js.map +0 -1
  134. package/dist/tui/utils/colors.d.ts +0 -19
  135. package/dist/tui/utils/colors.d.ts.map +0 -1
  136. package/dist/tui/utils/colors.js +0 -71
  137. package/dist/tui/utils/colors.js.map +0 -1
  138. package/dist/tui/utils/format.d.ts +0 -7
  139. package/dist/tui/utils/format.d.ts.map +0 -1
  140. package/dist/tui/utils/format.js +0 -45
  141. package/dist/tui/utils/format.js.map +0 -1
  142. package/dist/tui/utils/responsive.d.ts +0 -5
  143. package/dist/tui/utils/responsive.d.ts.map +0 -1
  144. package/dist/tui/utils/responsive.js +0 -5
  145. package/dist/tui/utils/responsive.js.map +0 -1
  146. package/dist/wrapped.d.ts +0 -43
  147. package/dist/wrapped.d.ts.map +0 -1
  148. package/dist/wrapped.js +0 -719
  149. package/dist/wrapped.js.map +0 -1
  150. package/src/auth.ts +0 -211
  151. package/src/cli.ts +0 -1892
  152. package/src/credentials.ts +0 -176
  153. package/src/cursor.ts +0 -1044
  154. package/src/date-utils.ts +0 -51
  155. package/src/graph-types.ts +0 -175
  156. package/src/native-runner.js +0 -4
  157. package/src/native-runner.ts +0 -91
  158. package/src/native.ts +0 -633
  159. package/src/sessions/types.ts +0 -59
  160. package/src/spinner.ts +0 -283
  161. package/src/submit.ts +0 -360
  162. package/src/table.ts +0 -233
  163. package/src/tui/App.tsx +0 -453
  164. package/src/tui/components/BarChart.tsx +0 -205
  165. package/src/tui/components/DailyView.tsx +0 -132
  166. package/src/tui/components/DateBreakdownPanel.tsx +0 -79
  167. package/src/tui/components/Footer.tsx +0 -380
  168. package/src/tui/components/Header.tsx +0 -68
  169. package/src/tui/components/Legend.tsx +0 -39
  170. package/src/tui/components/LoadingSpinner.tsx +0 -81
  171. package/src/tui/components/ModelRow.tsx +0 -47
  172. package/src/tui/components/ModelView.tsx +0 -147
  173. package/src/tui/components/OverviewView.tsx +0 -121
  174. package/src/tui/components/StatsView.tsx +0 -249
  175. package/src/tui/components/TokenBreakdown.tsx +0 -46
  176. package/src/tui/components/index.ts +0 -15
  177. package/src/tui/config/settings.ts +0 -183
  178. package/src/tui/config/themes.ts +0 -115
  179. package/src/tui/hooks/useData.ts +0 -558
  180. package/src/tui/index.tsx +0 -44
  181. package/src/tui/opentui.d.ts +0 -166
  182. package/src/tui/types/index.ts +0 -173
  183. package/src/tui/utils/cleanup.ts +0 -65
  184. package/src/tui/utils/colors.ts +0 -78
  185. package/src/tui/utils/format.ts +0 -36
  186. package/src/tui/utils/responsive.ts +0 -8
  187. package/src/types.d.ts +0 -28
  188. package/src/wrapped.ts +0 -848
@@ -1,176 +0,0 @@
1
- /**
2
- * Tokscale CLI Credentials Manager
3
- * Stores and retrieves API tokens for authenticated CLI operations
4
- */
5
-
6
- import * as fs from "node:fs";
7
- import * as path from "node:path";
8
- import * as os from "node:os";
9
-
10
- export interface Credentials {
11
- token: string;
12
- username: string;
13
- avatarUrl?: string;
14
- createdAt: string;
15
- }
16
-
17
- export interface StarCache {
18
- username: string;
19
- hasStarred: boolean;
20
- checkedAt: string;
21
- }
22
-
23
- const OLD_CONFIG_DIR = path.join(os.homedir(), ".tokscale");
24
- const CONFIG_DIR = path.join(os.homedir(), ".config", "tokscale");
25
- const OLD_CREDENTIALS_FILE = path.join(OLD_CONFIG_DIR, "credentials.json");
26
- const CREDENTIALS_FILE = path.join(CONFIG_DIR, "credentials.json");
27
- const STAR_CACHE_FILE = path.join(CONFIG_DIR, "star-cache.json");
28
-
29
- /**
30
- * Ensure the config directory exists
31
- */
32
- function ensureConfigDir(): void {
33
- if (!fs.existsSync(CONFIG_DIR)) {
34
- fs.mkdirSync(CONFIG_DIR, { recursive: true, mode: 0o700 });
35
- }
36
- }
37
-
38
- /**
39
- * Migrate credentials from old path (~/.token-tracker) to new XDG path (~/.config/token-tracker)
40
- */
41
- function migrateFromOldPath(): void {
42
- try {
43
- if (!fs.existsSync(CREDENTIALS_FILE) && fs.existsSync(OLD_CREDENTIALS_FILE)) {
44
- ensureConfigDir();
45
- fs.copyFileSync(OLD_CREDENTIALS_FILE, CREDENTIALS_FILE);
46
- fs.chmodSync(CREDENTIALS_FILE, 0o600);
47
- // Delete old file after successful migration
48
- fs.unlinkSync(OLD_CREDENTIALS_FILE);
49
- // Try to remove old directory if empty
50
- try {
51
- fs.rmdirSync(OLD_CONFIG_DIR);
52
- } catch {
53
- // Directory not empty (cursor files may exist) - ignore
54
- }
55
- }
56
- } catch {
57
- // Migration failed - continue with normal operation (old path may still work)
58
- }
59
- }
60
-
61
- /**
62
- * Save credentials to disk
63
- */
64
- export function saveCredentials(credentials: Credentials): void {
65
- ensureConfigDir();
66
- fs.writeFileSync(CREDENTIALS_FILE, JSON.stringify(credentials, null, 2), {
67
- encoding: "utf-8",
68
- mode: 0o600, // Read/write for owner only
69
- });
70
- }
71
-
72
- /**
73
- * Load credentials from disk
74
- * Returns null if no credentials are stored or file is invalid
75
- */
76
- export function loadCredentials(): Credentials | null {
77
- migrateFromOldPath();
78
- try {
79
- if (!fs.existsSync(CREDENTIALS_FILE)) {
80
- return null;
81
- }
82
- const data = fs.readFileSync(CREDENTIALS_FILE, "utf-8");
83
- const parsed = JSON.parse(data);
84
-
85
- // Validate structure
86
- if (!parsed.token || !parsed.username) {
87
- return null;
88
- }
89
-
90
- return parsed as Credentials;
91
- } catch {
92
- return null;
93
- }
94
- }
95
-
96
- /**
97
- * Clear stored credentials
98
- */
99
- export function clearCredentials(): boolean {
100
- try {
101
- if (fs.existsSync(CREDENTIALS_FILE)) {
102
- fs.unlinkSync(CREDENTIALS_FILE);
103
- return true;
104
- }
105
- return false;
106
- } catch {
107
- return false;
108
- }
109
- }
110
-
111
- /**
112
- * Check if user is logged in
113
- */
114
- export function isLoggedIn(): boolean {
115
- return loadCredentials() !== null;
116
- }
117
-
118
- /**
119
- * Get the API base URL
120
- */
121
- export function getApiBaseUrl(): string {
122
- return process.env.TOKSCALE_API_URL || "https://tokscale.ai";
123
- }
124
-
125
- /**
126
- * Get the credentials file path (for debugging)
127
- */
128
- export function getCredentialsPath(): string {
129
- return CREDENTIALS_FILE;
130
- }
131
-
132
- /**
133
- * Load star cache for a specific username
134
- * Returns null if no cache exists or file is invalid
135
- */
136
- export function loadStarCache(username: string): StarCache | null {
137
- try {
138
- if (!fs.existsSync(STAR_CACHE_FILE)) {
139
- return null;
140
- }
141
- const data = fs.readFileSync(STAR_CACHE_FILE, "utf-8");
142
- const parsed = JSON.parse(data);
143
-
144
- if (!parsed.username || typeof parsed.hasStarred !== "boolean" || !parsed.checkedAt) {
145
- return null;
146
- }
147
-
148
- if (parsed.username !== username) {
149
- return null;
150
- }
151
-
152
- if (!parsed.hasStarred) {
153
- return null;
154
- }
155
-
156
- return parsed as StarCache;
157
- } catch {
158
- return null;
159
- }
160
- }
161
-
162
- /**
163
- * Save star cache to disk
164
- */
165
- export function saveStarCache(cache: StarCache): void {
166
- try {
167
- ensureConfigDir();
168
- fs.writeFileSync(STAR_CACHE_FILE, JSON.stringify(cache, null, 2), {
169
- encoding: "utf-8",
170
- mode: 0o600,
171
- });
172
- } catch {
173
- // Silent fail - cache is optional, don't block submission
174
- }
175
- }
176
-