mirror of
https://github.com/google-gemini/gemini-cli.git
synced 2026-06-08 18:12:52 -07:00
feat(workspaces): transform workspaces feature into a distributable extension
This commit is contained in:
@@ -0,0 +1,51 @@
|
||||
/**
|
||||
* Workspace Log Tailer (Local)
|
||||
*
|
||||
* Tails the latest remote logs for a specific job.
|
||||
*/
|
||||
import { spawnSync } from 'child_process';
|
||||
import path from 'path';
|
||||
import fs from 'fs';
|
||||
import { fileURLToPath } from 'url';
|
||||
|
||||
const __dirname = path.dirname(fileURLToPath(import.meta.url));
|
||||
const REPO_ROOT = path.resolve(__dirname, '../../../..');
|
||||
|
||||
export async function runLogs(args: string[]) {
|
||||
const prNumber = args[0];
|
||||
const action = args[1] || 'review';
|
||||
|
||||
if (!prNumber) {
|
||||
console.error('Usage: npm run workspace:logs <PR_NUMBER> [action]');
|
||||
return 1;
|
||||
}
|
||||
|
||||
const settingsPath = path.join(REPO_ROOT, '.gemini/settings.json');
|
||||
const settings = JSON.parse(fs.readFileSync(settingsPath, 'utf8'));
|
||||
const config = settings.maintainer?.workspace;
|
||||
const { remoteHost, remoteHome } = config;
|
||||
const sshConfigPath = path.join(REPO_ROOT, '.gemini/workspace_ssh_config');
|
||||
|
||||
const jobDir = `${remoteHome}/dev/worktrees/workspace-${prNumber}-${action}`;
|
||||
const logDir = `${jobDir}/.gemini/logs`;
|
||||
|
||||
console.log(`📋 Tailing latest logs for job ${prNumber}-${action}...`);
|
||||
|
||||
// Remote command to find the latest log file and tail it
|
||||
const tailCmd = `
|
||||
latest_log=$(ls -t ${logDir}/*.log 2>/dev/null | head -n 1)
|
||||
if [ -z "$latest_log" ]; then
|
||||
echo "❌ No logs found for this job yet."
|
||||
exit 1
|
||||
fi
|
||||
echo "📄 Tailing: $latest_log"
|
||||
tail -f "$latest_log"
|
||||
`;
|
||||
|
||||
spawnSync(`ssh -F ${sshConfigPath} ${remoteHost} ${JSON.stringify(tailCmd)}`, { stdio: 'inherit', shell: true });
|
||||
return 0;
|
||||
}
|
||||
|
||||
if (import.meta.url === `file://${process.argv[1]}`) {
|
||||
runLogs(process.argv.slice(2)).catch(console.error);
|
||||
}
|
||||
Reference in New Issue
Block a user