diff --git a/package.json b/package.json index 0f0c849..25756ca 100644 --- a/package.json +++ b/package.json @@ -6,7 +6,7 @@ "main": "dist/index.js", "types": "dist/index.d.ts", "bin": { - "tigris-shell": "dist/cli.js" + "tigris-agent-shell": "dist/cli.js" }, "exports": { ".": { diff --git a/playground/src/welcome.ts b/playground/src/welcome.ts index 7a200a4..aa4ac88 100644 --- a/playground/src/welcome.ts +++ b/playground/src/welcome.ts @@ -7,7 +7,9 @@ const RESET = "\x1b[0m"; export function showWelcome(terminal: Terminal) { terminal.writeln(`${GREEN}Tigris Agent Shell${RESET}`); - terminal.writeln(`${DIM}Persistent sandboxed storage for AI agents${RESET}`); + terminal.writeln( + `${DIM}A virtual bash environment with a persistent filesystem backed by Tigris object storage${RESET}`, + ); terminal.writeln(""); terminal.writeln( `${YELLOW}WARNING: This is a browser-based shell. Credentials you enter${RESET}`, @@ -20,7 +22,10 @@ export function showWelcome(terminal: Terminal) { ); terminal.writeln(""); terminal.writeln(`${DIM}Connect to Tigris:${RESET}`); - terminal.writeln(`${DIM} configure --key --secret Set credentials${RESET}`); + terminal.writeln( + `${DIM} login Login with your Tigris account${RESET}`, + ); + terminal.writeln(`${DIM} configure --key --secret Set credentials manually${RESET}`); terminal.writeln(""); terminal.writeln(`${DIM}Type 'help' for all commands.${RESET}`); } diff --git a/src/cli.ts b/src/cli.ts index ae174d0..a2896df 100644 --- a/src/cli.ts +++ b/src/cli.ts @@ -33,8 +33,41 @@ function parseArgs(args: string[]): { return result; } +function printHelp() { + process.stdout.write(`Tigris Agent Shell — A virtual bash environment with a persistent filesystem backed by Tigris object storage + +Usage: + tigris-agent-shell [options] + +Options: + --key Access key ID + --secret Secret access key + --bucket Bucket to mount + --endpoint Tigris endpoint + --help Show this help + --version Show version + +Inside the shell, type 'help' for available commands. +`); +} + async function main() { - const args = parseArgs(process.argv.slice(2)); + const rawArgs = process.argv.slice(2); + + if (rawArgs.includes("--help") || rawArgs.includes("-h")) { + printHelp(); + return; + } + + if (rawArgs.includes("--version") || rawArgs.includes("-v")) { + const { createRequire } = await import("node:module"); + const require = createRequire(import.meta.url); + const pkg = require("../package.json") as { version: string }; + process.stdout.write(`${pkg.version}\n`); + return; + } + + const args = parseArgs(rawArgs); const session = new ReplSession({ loginFn: deviceLogin }); const rl = readline.createInterface({ diff --git a/src/repl/session.ts b/src/repl/session.ts index 6de7b98..9a5554d 100644 --- a/src/repl/session.ts +++ b/src/repl/session.ts @@ -58,6 +58,9 @@ export class ReplSession { case "flush": await this.handleFlush(parts.slice(1), io); return; + case "whoami": + this.handleWhoami(io); + return; case "help": this.handleHelp(io); return; @@ -373,6 +376,29 @@ export class ReplSession { } } + private handleWhoami(io: ReplIO): void { + if (!this.config) { + io.write("Not logged in.\n"); + return; + } + + if (this.authMethod === "oauth") { + io.write(`Logged in as ${this.email ?? "unknown"} (OAuth)\n`); + } else { + io.write( + `Access key: ${this.config.accessKeyId ? this.config.accessKeyId.slice(0, 8) : "unknown"}...\n`, + ); + } + + const mounts = this.shell?.listMounts() ?? []; + if (mounts.length > 0) { + io.write("Mounts:\n"); + for (const m of mounts) { + io.write(` ${m.bucket} → ${m.mountPoint}\n`); + } + } + } + private handleLogout(io: ReplIO): void { this.shell = null; this.config = null; @@ -384,15 +410,14 @@ export class ReplSession { private handleHelp(io: ReplIO): void { io.write("Commands:\n"); - io.write( - " login Login via browser (OAuth)\n", - ); + io.write(" login Login (OAuth)\n"); io.write(" configure --key --secret [--bucket ] [--endpoint ]\n"); io.write(" mount Mount a bucket\n"); io.write(" mount List mounts\n"); io.write(" umount Unmount a path\n"); io.write(" df List mounts\n"); io.write(" flush [path] Flush to Tigris\n"); + io.write(" whoami Show current session\n"); io.write(" logout Clear session\n"); io.write(" clear Clear screen\n"); io.write(" help Show this help\n");