@orcapt/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.
package/bin/orca.js ADDED
@@ -0,0 +1,406 @@
1
+ #!/usr/bin/env node
2
+
3
+ /**
4
+ * Orca CLI - Command Line Interface
5
+ * Entry point for the Orca CLI tool
6
+ */
7
+
8
+ const { program } = require('commander');
9
+ const chalk = require('chalk');
10
+ const path = require('path');
11
+ const fs = require('fs');
12
+ const kickstartPython = require('../src/commands/kickstart-python');
13
+ const kickstartNode = require('../src/commands/kickstart-node');
14
+ const { login, isLoggedIn, getCredentials, clearCredentials } = require('../src/commands/login');
15
+ const { uiInit, uiStart, uiRemove } = require('../src/commands/ui');
16
+ const { dbCreate, dbList, dbRemove } = require('../src/commands/db');
17
+ const fetchDoc = require('../src/commands/fetch-doc');
18
+ const {
19
+ bucketCreate,
20
+ bucketList,
21
+ bucketInfo,
22
+ bucketDelete,
23
+ fileUpload,
24
+ fileDownload,
25
+ fileList,
26
+ fileDelete,
27
+ permissionAdd,
28
+ permissionList
29
+ } = require('../src/commands/storage');
30
+ const { lambdaDeploy, lambdaList, lambdaInvoke, lambdaLogs, lambdaRemove, lambdaInfo } = require('../src/commands/lambda');
31
+
32
+ // Read version from package.json
33
+ const packageJson = JSON.parse(
34
+ fs.readFileSync(path.join(__dirname, '../package.json'), 'utf8')
35
+ );
36
+
37
+ program
38
+ .name('orca')
39
+ .description('CLI tool for managing Orca projects')
40
+ .version(packageJson.version);
41
+
42
+ // Middleware to check if user is logged in
43
+ function requireAuth(commandName) {
44
+ if (!isLoggedIn()) {
45
+ console.log(chalk.red('\n✗ You must be logged in to use this command'));
46
+ console.log(chalk.cyan('Please run:'), chalk.yellow('orca login'), chalk.cyan('first\n'));
47
+ process.exit(1);
48
+ }
49
+ }
50
+
51
+ // Login command
52
+ program
53
+ .command('login')
54
+ .description('Authenticate with Orca')
55
+ .action(login);
56
+
57
+ // Logout command
58
+ program
59
+ .command('logout')
60
+ .description('Clear stored credentials')
61
+ .action(() => {
62
+ if (clearCredentials()) {
63
+ console.log(chalk.green('\n✓ Successfully logged out\n'));
64
+ } else {
65
+ console.log(chalk.yellow('\n⚠ No credentials found\n'));
66
+ }
67
+ });
68
+
69
+ // Status command
70
+ program
71
+ .command('status')
72
+ .description('Check authentication status')
73
+ .action(() => {
74
+ const credentials = getCredentials();
75
+ if (credentials) {
76
+ console.log(chalk.cyan('\n============================================================'));
77
+ console.log(chalk.green('✓ Authenticated'));
78
+ console.log(chalk.cyan('============================================================'));
79
+ console.log(chalk.white('Mode: '), chalk.yellow(credentials.mode === 'dev' ? 'Sandbox/Pro' : 'Team'));
80
+ console.log(chalk.white('Workspace:'), chalk.yellow(credentials.workspace));
81
+ console.log(chalk.white('Since: '), chalk.yellow(new Date(credentials.timestamp).toLocaleString()));
82
+ console.log(chalk.cyan('============================================================\n'));
83
+ } else {
84
+ console.log(chalk.red('\n✗ Not authenticated'));
85
+ console.log(chalk.cyan('Run:'), chalk.yellow('orca login'), chalk.cyan('to authenticate\n'));
86
+ }
87
+ });
88
+
89
+ // UI commands
90
+ const uiCmd = program
91
+ .command('ui')
92
+ .description('Manage Orca UI installation and execution');
93
+
94
+ uiCmd
95
+ .command('init')
96
+ .description('Install Orca UI globally')
97
+ .action(() => {
98
+ requireAuth('ui init');
99
+ uiInit();
100
+ });
101
+
102
+ uiCmd
103
+ .command('start')
104
+ .description('Start the Orca UI')
105
+ .option('-p, --port <number>', 'Port for the frontend UI', '3000')
106
+ .option('-a, --agent-port <number>', 'Port for the agent backend', '5001')
107
+ .action((options) => {
108
+ requireAuth('ui start');
109
+ uiStart(options);
110
+ });
111
+
112
+ uiCmd
113
+ .command('remove')
114
+ .description('Uninstall Orca UI')
115
+ .action(() => {
116
+ requireAuth('ui remove');
117
+ uiRemove();
118
+ });
119
+
120
+ // Database commands
121
+ const dbCmd = program
122
+ .command('db')
123
+ .description('Manage PostgreSQL databases');
124
+
125
+ dbCmd
126
+ .command('create')
127
+ .description('Create a new PostgreSQL database')
128
+ .option('--postgres', 'Create PostgreSQL database (default)', true)
129
+ .action((options) => {
130
+ requireAuth('db create');
131
+ dbCreate(options);
132
+ });
133
+
134
+ dbCmd
135
+ .command('list')
136
+ .description('List all databases for your workspace')
137
+ .action(() => {
138
+ requireAuth('db list');
139
+ dbList();
140
+ });
141
+
142
+ dbCmd
143
+ .command('remove <database-name>')
144
+ .description('Delete a database')
145
+ .action((databaseName) => {
146
+ requireAuth('db remove');
147
+ dbRemove(databaseName);
148
+ });
149
+
150
+ // Kickstart command with subcommands for different languages
151
+ const kickstartCmd = program
152
+ .command('kickstart')
153
+ .description('Quick setup for a new Orca project')
154
+ .action(() => {
155
+ requireAuth('kickstart');
156
+ console.log(chalk.cyan('\n📚 Usage:'), chalk.white('orca kickstart <language> [options]\n'));
157
+ console.log(chalk.cyan('Available languages:\n'));
158
+ console.log(chalk.green(' python'), ' - Python-based agent (FastAPI + OpenAI)', chalk.green('✓ Available'));
159
+ console.log(chalk.green(' node'), ' - Node.js-based agent (Express + OpenAI)', chalk.green('✓ Available'));
160
+ console.log(chalk.yellow(' go'), ' - Go-based agent', chalk.yellow('🚧 Coming soon'));
161
+ console.log();
162
+ console.log(chalk.cyan('Examples:'));
163
+ console.log(chalk.white(' orca kickstart python'));
164
+ console.log(chalk.white(' orca kickstart node'));
165
+ console.log();
166
+ console.log(chalk.cyan('Help:'), chalk.white('orca kickstart <language> --help\n'));
167
+ });
168
+
169
+ // Python starter kit
170
+ kickstartCmd
171
+ .command('python')
172
+ .description('Set up a Python-based Orca agent (FastAPI + OpenAI)')
173
+ .option('-d, --directory <name>', 'Directory name for the project', 'orca-kickstart')
174
+ .option('-p, --port <number>', 'Port for the frontend UI', '3000')
175
+ .option('-a, --agent-port <number>', 'Port for the agent backend', '5001')
176
+ .option('--no-start', 'Skip starting the servers after setup')
177
+ .action((options) => {
178
+ requireAuth('kickstart python');
179
+ kickstartPython(options);
180
+ });
181
+
182
+ // Node.js starter kit
183
+ kickstartCmd
184
+ .command('node')
185
+ .description('Set up a Node.js-based Orca agent (Express + OpenAI)')
186
+ .option('-d, --directory <name>', 'Directory name for the project', 'orca-kickstart')
187
+ .option('-p, --port <number>', 'Port for the frontend UI', '3000')
188
+ .option('-a, --agent-port <number>', 'Port for the agent backend', '5001')
189
+ .option('--no-start', 'Skip starting the servers after setup')
190
+ .action((options) => {
191
+ requireAuth('kickstart node');
192
+ kickstartNode(options);
193
+ });
194
+
195
+ kickstartCmd
196
+ .command('go')
197
+ .description('Set up a Go-based Orca agent (Coming soon)')
198
+ .action(() => {
199
+ console.log(chalk.yellow('\n⚠ Go starter kit is coming soon!'));
200
+ console.log(chalk.cyan('For now, use:'), chalk.white('orca kickstart python\n'));
201
+ });
202
+
203
+ // Fetch commands
204
+ const fetchCmd = program
205
+ .command('fetch')
206
+ .description('Fetch resources and documentation');
207
+
208
+ fetchCmd
209
+ .command('doc')
210
+ .description('Download Orca SDK documentation')
211
+ .action(fetchDoc);
212
+
213
+ // Storage commands
214
+ const storageCmd = program
215
+ .command('storage')
216
+ .description('Manage S3-like storage buckets and files');
217
+
218
+ // Bucket subcommands
219
+ const bucketCmd = storageCmd
220
+ .command('bucket')
221
+ .description('Manage storage buckets');
222
+
223
+ bucketCmd
224
+ .command('create <name>')
225
+ .description('Create a new storage bucket')
226
+ .option('--public', 'Make bucket public', false)
227
+ .option('--versioning', 'Enable versioning', false)
228
+ .option('--no-encryption', 'Disable encryption')
229
+ .option('--encryption-type <type>', 'Encryption type (AES256 or aws:kms)', 'AES256')
230
+ .option('--description <text>', 'Bucket description')
231
+ .action((name, options) => {
232
+ requireAuth('storage bucket create');
233
+ bucketCreate(name, options);
234
+ });
235
+
236
+ bucketCmd
237
+ .command('list')
238
+ .description('List all storage buckets')
239
+ .action(() => {
240
+ requireAuth('storage bucket list');
241
+ bucketList();
242
+ });
243
+
244
+ bucketCmd
245
+ .command('info <name>')
246
+ .description('Get bucket information')
247
+ .action((name) => {
248
+ requireAuth('storage bucket info');
249
+ bucketInfo(name);
250
+ });
251
+
252
+ bucketCmd
253
+ .command('delete <name>')
254
+ .description('Delete a storage bucket')
255
+ .option('--force', 'Force delete (remove all files)', false)
256
+ .action((name, options) => {
257
+ requireAuth('storage bucket delete');
258
+ bucketDelete(name, options);
259
+ });
260
+
261
+ // File commands
262
+ storageCmd
263
+ .command('upload <bucket> <file-path>')
264
+ .description('Upload file to bucket')
265
+ .option('--folder <path>', 'Remote folder path')
266
+ .option('--public', 'Make file public', false)
267
+ .action((bucket, filePath, options) => {
268
+ requireAuth('storage upload');
269
+ fileUpload(bucket, filePath, options);
270
+ });
271
+
272
+ storageCmd
273
+ .command('download <bucket> <file-key> [local-path]')
274
+ .description('Download file from bucket')
275
+ .action((bucket, fileKey, localPath) => {
276
+ requireAuth('storage download');
277
+ fileDownload(bucket, fileKey, localPath);
278
+ });
279
+
280
+ storageCmd
281
+ .command('files <bucket>')
282
+ .description('List files in bucket')
283
+ .option('--folder <path>', 'Filter by folder path')
284
+ .option('--page <number>', 'Page number', '1')
285
+ .option('--per-page <number>', 'Items per page', '50')
286
+ .action((bucket, options) => {
287
+ requireAuth('storage files');
288
+ fileList(bucket, options);
289
+ });
290
+
291
+ storageCmd
292
+ .command('delete <bucket> <file-key>')
293
+ .description('Delete file from bucket')
294
+ .action((bucket, fileKey) => {
295
+ requireAuth('storage delete');
296
+ fileDelete(bucket, fileKey);
297
+ });
298
+
299
+ // Permission commands
300
+ const permissionCmd = storageCmd
301
+ .command('permission')
302
+ .description('Manage bucket permissions');
303
+
304
+ permissionCmd
305
+ .command('add <bucket>')
306
+ .description('Add permission to bucket')
307
+ .option('--target-type <type>', 'Target type (user, workspace, public, api_key)', 'user')
308
+ .option('--target-id <id>', 'Target ID (user ID, workspace ID, etc.)')
309
+ .option('--resource-type <type>', 'Resource type (bucket, folder, file)', 'bucket')
310
+ .option('--resource-path <path>', 'Resource path (for folder/file permissions)')
311
+ .option('--read', 'Grant read permission', false)
312
+ .option('--write', 'Grant write permission', false)
313
+ .option('--delete', 'Grant delete permission', false)
314
+ .option('--list', 'Grant list permission', false)
315
+ .option('--valid-until <date>', 'Permission expiry date (ISO 8601)')
316
+ .option('--reason <text>', 'Reason for granting permission')
317
+ .action((bucket, options) => {
318
+ requireAuth('storage permission add');
319
+ permissionAdd(bucket, options);
320
+ });
321
+
322
+ permissionCmd
323
+ .command('list <bucket>')
324
+ .description('List bucket permissions')
325
+ .action((bucket) => {
326
+ requireAuth('storage permission list');
327
+ permissionList(bucket);
328
+ });
329
+
330
+ // Ship command - Deploy Docker images to Lambda
331
+ program
332
+ .command('ship <function-name>')
333
+ .description('🚀 Deploy Docker image to AWS Lambda')
334
+ .option('--image <image>', 'Docker image (registry/image:tag)')
335
+ .option('--memory <mb>', 'Memory in MB', '512')
336
+ .option('--timeout <seconds>', 'Timeout in seconds', '30')
337
+ .option('--env <key=value>', 'Environment variable (can be repeated)', (val, memo) => { memo.push(val); return memo; }, [])
338
+ .option('--env-file <path>', 'Path to .env file')
339
+ .action((functionName, options) => {
340
+ requireAuth('ship');
341
+ lambdaDeploy(functionName, options);
342
+ });
343
+
344
+ // Lambda commands (alias for backward compatibility)
345
+ const lambdaCmd = program
346
+ .command('lambda')
347
+ .description('Manage AWS Lambda functions');
348
+
349
+ lambdaCmd
350
+ .command('list')
351
+ .description('List Lambda functions')
352
+ .action(() => {
353
+ requireAuth('lambda list');
354
+ lambdaList();
355
+ });
356
+
357
+ lambdaCmd
358
+ .command('info <function-name>')
359
+ .description('Get Lambda function details')
360
+ .action((functionName) => {
361
+ requireAuth('lambda info');
362
+ lambdaInfo(functionName);
363
+ });
364
+
365
+ lambdaCmd
366
+ .command('invoke <function-name>')
367
+ .description('Invoke Lambda function')
368
+ .option('--payload <json>', 'JSON payload')
369
+ .action((functionName, options) => {
370
+ requireAuth('lambda invoke');
371
+ lambdaInvoke(functionName, options);
372
+ });
373
+
374
+ lambdaCmd
375
+ .command('logs <function-name>')
376
+ .description('Get Lambda function logs')
377
+ .option('--tail', 'Stream logs in real-time')
378
+ .option('--since <time>', 'Show logs since (e.g., 1h, 30m)', '10m')
379
+ .action((functionName, options) => {
380
+ requireAuth('lambda logs');
381
+ lambdaLogs(functionName, options);
382
+ });
383
+
384
+ lambdaCmd
385
+ .command('remove <function-name>')
386
+ .description('Remove Lambda function')
387
+ .action((functionName) => {
388
+ requireAuth('lambda remove');
389
+ lambdaRemove(functionName);
390
+ });
391
+
392
+ // Handle unknown commands
393
+ program.on('command:*', () => {
394
+ console.error(chalk.red(`\n✗ Invalid command: ${program.args.join(' ')}\n`));
395
+ console.log(chalk.cyan('Run'), chalk.yellow('orca --help'), chalk.cyan('to see available commands\n'));
396
+ process.exit(1);
397
+ });
398
+
399
+ // Parse arguments
400
+ program.parse(process.argv);
401
+
402
+ // Show help if no command provided
403
+ if (!process.argv.slice(2).length) {
404
+ program.outputHelp();
405
+ }
406
+
package/package.json ADDED
@@ -0,0 +1,58 @@
1
+ {
2
+ "name": "@orcapt/cli",
3
+ "version": "v1.0.0",
4
+ "description": "CLI tool for managing Orca projects - Quick setup and deployment",
5
+ "main": "src/index.js",
6
+ "bin": {
7
+ "orcapt": "bin/orca.js"
8
+ },
9
+ "scripts": {
10
+ "test": "echo \"Error: no test specified\" && exit 1",
11
+ "dev": "node bin/orca.js",
12
+ "link": "npm link",
13
+ "unlink": "npm unlink -g @orcapt/cli",
14
+ "dev:help": "node bin/orca.js --help",
15
+ "dev:login": "node bin/orca.js login",
16
+ "dev:db": "node bin/orca.js db list"
17
+ },
18
+ "keywords": [
19
+ "orca",
20
+ "cli",
21
+ "ai",
22
+ "chatbot",
23
+ "agent",
24
+ "development"
25
+ ],
26
+ "author": "Orcapt",
27
+ "license": "MIT",
28
+ "engines": {
29
+ "node": ">=14.0.0"
30
+ },
31
+ "dependencies": {
32
+ "chalk": "^4.1.2",
33
+ "commander": "^11.0.0",
34
+ "cross-spawn": "^7.0.3",
35
+ "inquirer": "^8.2.5",
36
+ "ora": "^5.4.1",
37
+ "simple-git": "^3.19.1"
38
+ },
39
+ "repository": {
40
+ "type": "git",
41
+ "url": "git+https://github.com/Orcapt/orca-cli.git"
42
+ },
43
+ "bugs": {
44
+ "url": "https://github.com/Orcapt/orca-cli/issues"
45
+ },
46
+ "homepage": "https://github.com/Orcapt/orca-cli#readme",
47
+ "files": [
48
+ "bin/",
49
+ "src/",
50
+ "orca-kickstart/",
51
+ "README.md",
52
+ "LICENSE",
53
+ "QUICK_START.md"
54
+ ],
55
+ "publishConfig": {
56
+ "access": "public"
57
+ }
58
+ }