@ian2018cs/agenthub 0.1.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 (136) hide show
  1. package/LICENSE +675 -0
  2. package/README.md +330 -0
  3. package/dist/assets/KaTeX_AMS-Regular-BQhdFMY1.woff2 +0 -0
  4. package/dist/assets/KaTeX_AMS-Regular-DMm9YOAa.woff +0 -0
  5. package/dist/assets/KaTeX_AMS-Regular-DRggAlZN.ttf +0 -0
  6. package/dist/assets/KaTeX_Caligraphic-Bold-ATXxdsX0.ttf +0 -0
  7. package/dist/assets/KaTeX_Caligraphic-Bold-BEiXGLvX.woff +0 -0
  8. package/dist/assets/KaTeX_Caligraphic-Bold-Dq_IR9rO.woff2 +0 -0
  9. package/dist/assets/KaTeX_Caligraphic-Regular-CTRA-rTL.woff +0 -0
  10. package/dist/assets/KaTeX_Caligraphic-Regular-Di6jR-x-.woff2 +0 -0
  11. package/dist/assets/KaTeX_Caligraphic-Regular-wX97UBjC.ttf +0 -0
  12. package/dist/assets/KaTeX_Fraktur-Bold-BdnERNNW.ttf +0 -0
  13. package/dist/assets/KaTeX_Fraktur-Bold-BsDP51OF.woff +0 -0
  14. package/dist/assets/KaTeX_Fraktur-Bold-CL6g_b3V.woff2 +0 -0
  15. package/dist/assets/KaTeX_Fraktur-Regular-CB_wures.ttf +0 -0
  16. package/dist/assets/KaTeX_Fraktur-Regular-CTYiF6lA.woff2 +0 -0
  17. package/dist/assets/KaTeX_Fraktur-Regular-Dxdc4cR9.woff +0 -0
  18. package/dist/assets/KaTeX_Main-Bold-Cx986IdX.woff2 +0 -0
  19. package/dist/assets/KaTeX_Main-Bold-Jm3AIy58.woff +0 -0
  20. package/dist/assets/KaTeX_Main-Bold-waoOVXN0.ttf +0 -0
  21. package/dist/assets/KaTeX_Main-BoldItalic-DxDJ3AOS.woff2 +0 -0
  22. package/dist/assets/KaTeX_Main-BoldItalic-DzxPMmG6.ttf +0 -0
  23. package/dist/assets/KaTeX_Main-BoldItalic-SpSLRI95.woff +0 -0
  24. package/dist/assets/KaTeX_Main-Italic-3WenGoN9.ttf +0 -0
  25. package/dist/assets/KaTeX_Main-Italic-BMLOBm91.woff +0 -0
  26. package/dist/assets/KaTeX_Main-Italic-NWA7e6Wa.woff2 +0 -0
  27. package/dist/assets/KaTeX_Main-Regular-B22Nviop.woff2 +0 -0
  28. package/dist/assets/KaTeX_Main-Regular-Dr94JaBh.woff +0 -0
  29. package/dist/assets/KaTeX_Main-Regular-ypZvNtVU.ttf +0 -0
  30. package/dist/assets/KaTeX_Math-BoldItalic-B3XSjfu4.ttf +0 -0
  31. package/dist/assets/KaTeX_Math-BoldItalic-CZnvNsCZ.woff2 +0 -0
  32. package/dist/assets/KaTeX_Math-BoldItalic-iY-2wyZ7.woff +0 -0
  33. package/dist/assets/KaTeX_Math-Italic-DA0__PXp.woff +0 -0
  34. package/dist/assets/KaTeX_Math-Italic-flOr_0UB.ttf +0 -0
  35. package/dist/assets/KaTeX_Math-Italic-t53AETM-.woff2 +0 -0
  36. package/dist/assets/KaTeX_SansSerif-Bold-CFMepnvq.ttf +0 -0
  37. package/dist/assets/KaTeX_SansSerif-Bold-D1sUS0GD.woff2 +0 -0
  38. package/dist/assets/KaTeX_SansSerif-Bold-DbIhKOiC.woff +0 -0
  39. package/dist/assets/KaTeX_SansSerif-Italic-C3H0VqGB.woff2 +0 -0
  40. package/dist/assets/KaTeX_SansSerif-Italic-DN2j7dab.woff +0 -0
  41. package/dist/assets/KaTeX_SansSerif-Italic-YYjJ1zSn.ttf +0 -0
  42. package/dist/assets/KaTeX_SansSerif-Regular-BNo7hRIc.ttf +0 -0
  43. package/dist/assets/KaTeX_SansSerif-Regular-CS6fqUqJ.woff +0 -0
  44. package/dist/assets/KaTeX_SansSerif-Regular-DDBCnlJ7.woff2 +0 -0
  45. package/dist/assets/KaTeX_Script-Regular-C5JkGWo-.ttf +0 -0
  46. package/dist/assets/KaTeX_Script-Regular-D3wIWfF6.woff2 +0 -0
  47. package/dist/assets/KaTeX_Script-Regular-D5yQViql.woff +0 -0
  48. package/dist/assets/KaTeX_Size1-Regular-C195tn64.woff +0 -0
  49. package/dist/assets/KaTeX_Size1-Regular-Dbsnue_I.ttf +0 -0
  50. package/dist/assets/KaTeX_Size1-Regular-mCD8mA8B.woff2 +0 -0
  51. package/dist/assets/KaTeX_Size2-Regular-B7gKUWhC.ttf +0 -0
  52. package/dist/assets/KaTeX_Size2-Regular-Dy4dx90m.woff2 +0 -0
  53. package/dist/assets/KaTeX_Size2-Regular-oD1tc_U0.woff +0 -0
  54. package/dist/assets/KaTeX_Size3-Regular-CTq5MqoE.woff +0 -0
  55. package/dist/assets/KaTeX_Size3-Regular-DgpXs0kz.ttf +0 -0
  56. package/dist/assets/KaTeX_Size4-Regular-BF-4gkZK.woff +0 -0
  57. package/dist/assets/KaTeX_Size4-Regular-DWFBv043.ttf +0 -0
  58. package/dist/assets/KaTeX_Size4-Regular-Dl5lxZxV.woff2 +0 -0
  59. package/dist/assets/KaTeX_Typewriter-Regular-C0xS9mPB.woff +0 -0
  60. package/dist/assets/KaTeX_Typewriter-Regular-CO6r4hn1.woff2 +0 -0
  61. package/dist/assets/KaTeX_Typewriter-Regular-D3Ib7_Hf.ttf +0 -0
  62. package/dist/assets/index-B4ru3EJb.css +32 -0
  63. package/dist/assets/index-DDFuyrpY.js +154 -0
  64. package/dist/assets/vendor-codemirror-C_VWDoZS.js +39 -0
  65. package/dist/assets/vendor-icons-CJV4dnDL.js +326 -0
  66. package/dist/assets/vendor-katex-DK8hFnhL.js +261 -0
  67. package/dist/assets/vendor-markdown-VwNYkg_0.js +35 -0
  68. package/dist/assets/vendor-react-BeVl62c0.js +59 -0
  69. package/dist/assets/vendor-syntax-CdGaPJRS.js +16 -0
  70. package/dist/assets/vendor-utils-00TdZexr.js +1 -0
  71. package/dist/assets/vendor-xterm-CvdiG4-n.js +66 -0
  72. package/dist/clear-cache.html +85 -0
  73. package/dist/convert-icons.md +53 -0
  74. package/dist/favicon.png +0 -0
  75. package/dist/favicon.svg +9 -0
  76. package/dist/generate-icons.js +49 -0
  77. package/dist/icons/claude-ai-icon.svg +1 -0
  78. package/dist/icons/codex-white.svg +3 -0
  79. package/dist/icons/codex.svg +3 -0
  80. package/dist/icons/cursor-white.svg +12 -0
  81. package/dist/icons/cursor.svg +1 -0
  82. package/dist/icons/generate-icons.md +19 -0
  83. package/dist/icons/icon-128x128.png +0 -0
  84. package/dist/icons/icon-128x128.svg +12 -0
  85. package/dist/icons/icon-144x144.png +0 -0
  86. package/dist/icons/icon-144x144.svg +12 -0
  87. package/dist/icons/icon-152x152.png +0 -0
  88. package/dist/icons/icon-152x152.svg +12 -0
  89. package/dist/icons/icon-192x192.png +0 -0
  90. package/dist/icons/icon-192x192.svg +12 -0
  91. package/dist/icons/icon-384x384.png +0 -0
  92. package/dist/icons/icon-384x384.svg +12 -0
  93. package/dist/icons/icon-512x512.png +0 -0
  94. package/dist/icons/icon-512x512.svg +12 -0
  95. package/dist/icons/icon-72x72.png +0 -0
  96. package/dist/icons/icon-72x72.svg +12 -0
  97. package/dist/icons/icon-96x96.png +0 -0
  98. package/dist/icons/icon-96x96.svg +12 -0
  99. package/dist/icons/icon-template.svg +12 -0
  100. package/dist/index.html +57 -0
  101. package/dist/logo-128.png +0 -0
  102. package/dist/logo-256.png +0 -0
  103. package/dist/logo-32.png +0 -0
  104. package/dist/logo-512.png +0 -0
  105. package/dist/logo-64.png +0 -0
  106. package/dist/logo.svg +17 -0
  107. package/dist/manifest.json +61 -0
  108. package/dist/screenshots/cli-selection.png +0 -0
  109. package/dist/screenshots/desktop-main.png +0 -0
  110. package/dist/screenshots/mobile-chat.png +0 -0
  111. package/dist/screenshots/tools-modal.png +0 -0
  112. package/dist/sw.js +49 -0
  113. package/package.json +113 -0
  114. package/server/claude-sdk.js +791 -0
  115. package/server/cli.js +330 -0
  116. package/server/database/auth.db +0 -0
  117. package/server/database/db.js +523 -0
  118. package/server/database/init.sql +23 -0
  119. package/server/index.js +1678 -0
  120. package/server/load-env.js +27 -0
  121. package/server/middleware/auth.js +118 -0
  122. package/server/projects.js +899 -0
  123. package/server/routes/admin.js +89 -0
  124. package/server/routes/auth.js +144 -0
  125. package/server/routes/commands.js +570 -0
  126. package/server/routes/mcp-utils.js +37 -0
  127. package/server/routes/mcp.js +593 -0
  128. package/server/routes/projects.js +216 -0
  129. package/server/routes/skills.js +891 -0
  130. package/server/routes/usage.js +206 -0
  131. package/server/services/pricing.js +196 -0
  132. package/server/services/usage-scanner.js +283 -0
  133. package/server/services/user-directories.js +123 -0
  134. package/server/utils/commandParser.js +303 -0
  135. package/server/utils/mcp-detector.js +73 -0
  136. package/shared/modelConstants.js +23 -0
package/server/cli.js ADDED
@@ -0,0 +1,330 @@
1
+ #!/usr/bin/env node
2
+ /**
3
+ * Claude Code UI CLI
4
+ *
5
+ * Provides command-line utilities for managing Claude Code UI
6
+ *
7
+ * Commands:
8
+ * (no args) - Start the server (default)
9
+ * start - Start the server
10
+ * status - Show configuration and data locations
11
+ * help - Show help information
12
+ * version - Show version information
13
+ */
14
+
15
+ import fs from 'fs';
16
+ import path from 'path';
17
+ import os from 'os';
18
+ import { fileURLToPath } from 'url';
19
+ import { dirname } from 'path';
20
+
21
+ const __filename = fileURLToPath(import.meta.url);
22
+ const __dirname = dirname(__filename);
23
+
24
+ // ANSI color codes for terminal output
25
+ const colors = {
26
+ reset: '\x1b[0m',
27
+ bright: '\x1b[1m',
28
+ dim: '\x1b[2m',
29
+
30
+ // Foreground colors
31
+ cyan: '\x1b[36m',
32
+ green: '\x1b[32m',
33
+ yellow: '\x1b[33m',
34
+ blue: '\x1b[34m',
35
+ magenta: '\x1b[35m',
36
+ white: '\x1b[37m',
37
+ gray: '\x1b[90m',
38
+ };
39
+
40
+ // Helper to colorize text
41
+ const c = {
42
+ info: (text) => `${colors.cyan}${text}${colors.reset}`,
43
+ ok: (text) => `${colors.green}${text}${colors.reset}`,
44
+ warn: (text) => `${colors.yellow}${text}${colors.reset}`,
45
+ error: (text) => `${colors.yellow}${text}${colors.reset}`,
46
+ tip: (text) => `${colors.blue}${text}${colors.reset}`,
47
+ bright: (text) => `${colors.bright}${text}${colors.reset}`,
48
+ dim: (text) => `${colors.dim}${text}${colors.reset}`,
49
+ };
50
+
51
+ // Load package.json for version info
52
+ const packageJsonPath = path.join(__dirname, '../package.json');
53
+ const packageJson = JSON.parse(fs.readFileSync(packageJsonPath, 'utf8'));
54
+
55
+ // Load environment variables from .env file if it exists
56
+ function loadEnvFile() {
57
+ try {
58
+ const envPath = path.join(__dirname, '../.env');
59
+ const envFile = fs.readFileSync(envPath, 'utf8');
60
+ envFile.split('\n').forEach(line => {
61
+ const trimmedLine = line.trim();
62
+ if (trimmedLine && !trimmedLine.startsWith('#')) {
63
+ const [key, ...valueParts] = trimmedLine.split('=');
64
+ if (key && valueParts.length > 0 && !process.env[key]) {
65
+ process.env[key] = valueParts.join('=').trim();
66
+ }
67
+ }
68
+ });
69
+ } catch (e) {
70
+ // .env file is optional
71
+ }
72
+ }
73
+
74
+ // Get the database path (same logic as db.js)
75
+ function getDatabasePath() {
76
+ loadEnvFile();
77
+ // Resolve relative paths from project root (one level up from server/)
78
+ return process.env.DATABASE_PATH
79
+ ? path.resolve(path.join(__dirname, '..'), process.env.DATABASE_PATH)
80
+ : path.join(__dirname, 'database', 'auth.db');
81
+ }
82
+
83
+ // Get the installation directory
84
+ function getInstallDir() {
85
+ return path.join(__dirname, '..');
86
+ }
87
+
88
+ // Show status command
89
+ function showStatus() {
90
+ console.log(`\n${c.bright('Claude Code UI - Status')}\n`);
91
+ console.log(c.dim('═'.repeat(60)));
92
+
93
+ // Version info
94
+ console.log(`\n${c.info('[INFO]')} Version: ${c.bright(packageJson.version)}`);
95
+
96
+ // Installation location
97
+ const installDir = getInstallDir();
98
+ console.log(`\n${c.info('[INFO]')} Installation Directory:`);
99
+ console.log(` ${c.dim(installDir)}`);
100
+
101
+ // Database location
102
+ const dbPath = getDatabasePath();
103
+ const dbExists = fs.existsSync(dbPath);
104
+ console.log(`\n${c.info('[INFO]')} Database Location:`);
105
+ console.log(` ${c.dim(dbPath)}`);
106
+ console.log(` Status: ${dbExists ? c.ok('[OK] Exists') : c.warn('[WARN] Not created yet (will be created on first run)')}`);
107
+
108
+ if (dbExists) {
109
+ const stats = fs.statSync(dbPath);
110
+ console.log(` Size: ${c.dim((stats.size / 1024).toFixed(2) + ' KB')}`);
111
+ console.log(` Modified: ${c.dim(stats.mtime.toLocaleString())}`);
112
+ }
113
+
114
+ // Environment variables
115
+ console.log(`\n${c.info('[INFO]')} Configuration:`);
116
+ console.log(` PORT: ${c.bright(process.env.PORT || '3001')} ${c.dim(process.env.PORT ? '' : '(default)')}`);
117
+ console.log(` DATABASE_PATH: ${c.dim(process.env.DATABASE_PATH || '(using default location)')}`);
118
+ console.log(` CLAUDE_CLI_PATH: ${c.dim(process.env.CLAUDE_CLI_PATH || 'claude (default)')}`);
119
+ console.log(` CONTEXT_WINDOW: ${c.dim(process.env.CONTEXT_WINDOW || '160000 (default)')}`);
120
+
121
+ // Claude projects folder
122
+ const claudeProjectsPath = path.join(os.homedir(), '.claude', 'projects');
123
+ const projectsExists = fs.existsSync(claudeProjectsPath);
124
+ console.log(`\n${c.info('[INFO]')} Claude Projects Folder:`);
125
+ console.log(` ${c.dim(claudeProjectsPath)}`);
126
+ console.log(` Status: ${projectsExists ? c.ok('[OK] Exists') : c.warn('[WARN] Not found')}`);
127
+
128
+ // Config file location
129
+ const envFilePath = path.join(__dirname, '../.env');
130
+ const envExists = fs.existsSync(envFilePath);
131
+ console.log(`\n${c.info('[INFO]')} Configuration File:`);
132
+ console.log(` ${c.dim(envFilePath)}`);
133
+ console.log(` Status: ${envExists ? c.ok('[OK] Exists') : c.warn('[WARN] Not found (using defaults)')}`);
134
+
135
+ console.log('\n' + c.dim('═'.repeat(60)));
136
+ console.log(`\n${c.tip('[TIP]')} Hints:`);
137
+ console.log(` ${c.dim('>')} Use ${c.bright('cloudcli --port 8080')} to run on a custom port`);
138
+ console.log(` ${c.dim('>')} Use ${c.bright('cloudcli --database-path /path/to/db')} for custom database`);
139
+ console.log(` ${c.dim('>')} Run ${c.bright('cloudcli help')} for all options`);
140
+ console.log(` ${c.dim('>')} Access the UI at http://localhost:${process.env.PORT || '3001'}\n`);
141
+ }
142
+
143
+ // Show help
144
+ function showHelp() {
145
+ console.log(`
146
+ ╔═══════════════════════════════════════════════════════════════╗
147
+ ║ Claude Code UI - Command Line Tool ║
148
+ ╚═══════════════════════════════════════════════════════════════╝
149
+
150
+ Usage:
151
+ claude-code-ui [command] [options]
152
+ cloudcli [command] [options]
153
+
154
+ Commands:
155
+ start Start the Claude Code UI server (default)
156
+ status Show configuration and data locations
157
+ update Update to the latest version
158
+ help Show this help information
159
+ version Show version information
160
+
161
+ Options:
162
+ -p, --port <port> Set server port (default: 3001)
163
+ --database-path <path> Set custom database location
164
+ -h, --help Show this help information
165
+ -v, --version Show version information
166
+
167
+ Examples:
168
+ $ cloudcli # Start with defaults
169
+ $ cloudcli --port 8080 # Start on port 8080
170
+ $ cloudcli -p 3000 # Short form for port
171
+ $ cloudcli start --port 4000 # Explicit start command
172
+ $ cloudcli status # Show configuration
173
+
174
+ Environment Variables:
175
+ PORT Set server port (default: 3001)
176
+ DATABASE_PATH Set custom database location
177
+ CLAUDE_CLI_PATH Set custom Claude CLI path
178
+ CONTEXT_WINDOW Set context window size (default: 160000)
179
+
180
+ Documentation:
181
+ ${packageJson.homepage || 'https://github.com/siteboon/claudecodeui'}
182
+
183
+ Report Issues:
184
+ ${packageJson.bugs?.url || 'https://github.com/siteboon/claudecodeui/issues'}
185
+ `);
186
+ }
187
+
188
+ // Show version
189
+ function showVersion() {
190
+ console.log(`${packageJson.version}`);
191
+ }
192
+
193
+ // Compare semver versions, returns true if v1 > v2
194
+ function isNewerVersion(v1, v2) {
195
+ const parts1 = v1.split('.').map(Number);
196
+ const parts2 = v2.split('.').map(Number);
197
+ for (let i = 0; i < 3; i++) {
198
+ if (parts1[i] > parts2[i]) return true;
199
+ if (parts1[i] < parts2[i]) return false;
200
+ }
201
+ return false;
202
+ }
203
+
204
+ // Check for updates
205
+ async function checkForUpdates(silent = false) {
206
+ try {
207
+ const { execSync } = await import('child_process');
208
+ const latestVersion = execSync('npm show @siteboon/claude-code-ui version', { encoding: 'utf8' }).trim();
209
+ const currentVersion = packageJson.version;
210
+
211
+ if (isNewerVersion(latestVersion, currentVersion)) {
212
+ console.log(`\n${c.warn('[UPDATE]')} New version available: ${c.bright(latestVersion)} (current: ${currentVersion})`);
213
+ console.log(` Run ${c.bright('cloudcli update')} to update\n`);
214
+ return { hasUpdate: true, latestVersion, currentVersion };
215
+ } else if (!silent) {
216
+ console.log(`${c.ok('[OK]')} You are on the latest version (${currentVersion})`);
217
+ }
218
+ return { hasUpdate: false, latestVersion, currentVersion };
219
+ } catch (e) {
220
+ if (!silent) {
221
+ console.log(`${c.warn('[WARN]')} Could not check for updates`);
222
+ }
223
+ return { hasUpdate: false, error: e.message };
224
+ }
225
+ }
226
+
227
+ // Update the package
228
+ async function updatePackage() {
229
+ try {
230
+ const { execSync } = await import('child_process');
231
+ console.log(`${c.info('[INFO]')} Checking for updates...`);
232
+
233
+ const { hasUpdate, latestVersion, currentVersion } = await checkForUpdates(true);
234
+
235
+ if (!hasUpdate) {
236
+ console.log(`${c.ok('[OK]')} Already on the latest version (${currentVersion})`);
237
+ return;
238
+ }
239
+
240
+ console.log(`${c.info('[INFO]')} Updating from ${currentVersion} to ${latestVersion}...`);
241
+ execSync('npm update -g @siteboon/claude-code-ui', { stdio: 'inherit' });
242
+ console.log(`${c.ok('[OK]')} Update complete! Restart cloudcli to use the new version.`);
243
+ } catch (e) {
244
+ console.error(`${c.error('[ERROR]')} Update failed: ${e.message}`);
245
+ console.log(`${c.tip('[TIP]')} Try running manually: npm update -g @siteboon/claude-code-ui`);
246
+ }
247
+ }
248
+
249
+ // Start the server
250
+ async function startServer() {
251
+ // Check for updates silently on startup
252
+ checkForUpdates(true);
253
+
254
+ // Import and run the server
255
+ await import('./index.js');
256
+ }
257
+
258
+ // Parse CLI arguments
259
+ function parseArgs(args) {
260
+ const parsed = { command: 'start', options: {} };
261
+
262
+ for (let i = 0; i < args.length; i++) {
263
+ const arg = args[i];
264
+
265
+ if (arg === '--port' || arg === '-p') {
266
+ parsed.options.port = args[++i];
267
+ } else if (arg.startsWith('--port=')) {
268
+ parsed.options.port = arg.split('=')[1];
269
+ } else if (arg === '--database-path') {
270
+ parsed.options.databasePath = args[++i];
271
+ } else if (arg.startsWith('--database-path=')) {
272
+ parsed.options.databasePath = arg.split('=')[1];
273
+ } else if (arg === '--help' || arg === '-h') {
274
+ parsed.command = 'help';
275
+ } else if (arg === '--version' || arg === '-v') {
276
+ parsed.command = 'version';
277
+ } else if (!arg.startsWith('-')) {
278
+ parsed.command = arg;
279
+ }
280
+ }
281
+
282
+ return parsed;
283
+ }
284
+
285
+ // Main CLI handler
286
+ async function main() {
287
+ const args = process.argv.slice(2);
288
+ const { command, options } = parseArgs(args);
289
+
290
+ // Apply CLI options to environment variables
291
+ if (options.port) {
292
+ process.env.PORT = options.port;
293
+ }
294
+ if (options.databasePath) {
295
+ process.env.DATABASE_PATH = options.databasePath;
296
+ }
297
+
298
+ switch (command) {
299
+ case 'start':
300
+ await startServer();
301
+ break;
302
+ case 'status':
303
+ case 'info':
304
+ showStatus();
305
+ break;
306
+ case 'help':
307
+ case '-h':
308
+ case '--help':
309
+ showHelp();
310
+ break;
311
+ case 'version':
312
+ case '-v':
313
+ case '--version':
314
+ showVersion();
315
+ break;
316
+ case 'update':
317
+ await updatePackage();
318
+ break;
319
+ default:
320
+ console.error(`\n❌ Unknown command: ${command}`);
321
+ console.log(' Run "cloudcli help" for usage information.\n');
322
+ process.exit(1);
323
+ }
324
+ }
325
+
326
+ // Run the CLI
327
+ main().catch(error => {
328
+ console.error('\n❌ Error:', error.message);
329
+ process.exit(1);
330
+ });
Binary file