From e82781ca7dbda655a00f805e8e9a94e068094ae6 Mon Sep 17 00:00:00 2001 From: mkorwel Date: Thu, 19 Mar 2026 00:25:25 -0700 Subject: [PATCH] scdript --- scripts/workspace.ts | 78 ++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 78 insertions(+) create mode 100644 scripts/workspace.ts diff --git a/scripts/workspace.ts b/scripts/workspace.ts new file mode 100644 index 0000000000..389b661d12 --- /dev/null +++ b/scripts/workspace.ts @@ -0,0 +1,78 @@ +#!/usr/bin/env npx tsx +/** + * @license + * Copyright 2026 Google LLC + * SPDX-License-Identifier: Apache-2.0 + */ +import { spawnSync } from 'node:child_process'; +import path from 'node:path'; +import { fileURLToPath } from 'node:url'; + +const __dirname = path.dirname(fileURLToPath(import.meta.url)); +const REPO_ROOT = path.resolve(__dirname, '..'); + +const commands: Record = { + setup: '.gemini/skills/workspaces/scripts/setup.ts', + shell: '.gemini/skills/workspaces/scripts/orchestrator.ts shell', + check: '.gemini/skills/workspaces/scripts/check.ts', + 'clean-all': '.gemini/skills/workspaces/scripts/clean.ts', + kill: '.gemini/skills/workspaces/scripts/clean.ts', + fleet: '.gemini/skills/workspaces/scripts/fleet.ts', + status: '.gemini/skills/workspaces/scripts/status.ts', + attach: '.gemini/skills/workspaces/scripts/attach.ts', +}; + +function printUsage() { + console.log('Gemini Workspace Management CLI'); + console.log( + '\nUsage: scripts/workspace.ts [args] [--open foreground|tab|window]', + ); + console.log('\nCommands:'); + console.log( + ' setup Initialize or reconfigure your remote worker', + ); + console.log(' [action] Launch a PR task (review, fix, ready)'); + console.log(' shell [id] Open an ad-hoc interactive session'); + console.log(' status See worker and session overview'); + console.log(' check Deep-dive into PR logs'); + console.log(' kill Surgical removal of a task'); + console.log(' clean-all Full remote cleanup'); + console.log(' fleet Manage VM life cycle (stop, provision)'); + process.exit(1); +} + +async function main() { + const args = process.argv.slice(2); + const cmd = args[0]; + + if (!cmd || cmd === '--help' || cmd === '-h') { + printUsage(); + } + + let scriptPath = commands[cmd]; + let finalArgs = args.slice(1); + + // Default: If it's a number, it's a PR orchestrator task + if (!scriptPath && /^\d+$/.test(cmd)) { + scriptPath = '.gemini/skills/workspaces/scripts/orchestrator.ts'; + finalArgs = args; // Pass the PR number as the first arg + } + + if (!scriptPath) { + console.error(`❌ Unknown command: ${cmd}`); + printUsage(); + } + + const [realScript, ...internalArgs] = scriptPath.split(' '); + const fullScriptPath = path.join(REPO_ROOT, realScript); + + const result = spawnSync( + 'npx', + ['tsx', fullScriptPath, ...internalArgs, ...finalArgs], + { stdio: 'inherit' }, + ); + + process.exit(result.status ?? 0); +} + +main().catch(console.error);