MCPcopy Create free account
hub / github.com/Noumena-Network/code / execIntoTmuxWorktree

Function execIntoTmuxWorktree

src/utils/worktree.ts:1194–1533  ·  view source on GitHub ↗
(args: string[])

Source from the content-addressed store, hash-verified

1192 * This is called early in cli.tsx before loading the full CLI.
1193 */
1194export async function execIntoTmuxWorktree(args: string[]): Promise<{
1195 handled: boolean
1196 error?: string
1197}> {
1198 // Check platform - tmux doesn't work on Windows
1199 if (process.platform === 'win32') {
1200 return {
1201 handled: false,
1202 error: 'Error: --tmux is not supported on Windows',
1203 }
1204 }
1205
1206 // Check if tmux is available
1207 const tmuxCheck = spawnSync('tmux', ['-V'], { encoding: 'utf-8' })
1208 if (tmuxCheck.status !== 0) {
1209 const installHint =
1210 process.platform === 'darwin'
1211 ? 'Install tmux with: brew install tmux'
1212 : 'Install tmux with: sudo apt install tmux'
1213 return {
1214 handled: false,
1215 error: `Error: tmux is not installed. ${installHint}`,
1216 }
1217 }
1218
1219 // Parse worktree name and tmux mode from args
1220 let worktreeName: string | undefined
1221 let forceClassicTmux = false
1222 for (let i = 0; i < args.length; i++) {
1223 const arg = args[i]
1224 if (!arg) continue
1225 if (arg === '-w' || arg === '--worktree') {
1226 // Check if next arg exists and isn't another flag
1227 const next = args[i + 1]
1228 if (next && !next.startsWith('-')) {
1229 worktreeName = next
1230 }
1231 } else if (arg.startsWith('--worktree=')) {
1232 worktreeName = arg.slice('--worktree='.length)
1233 } else if (arg === '--tmux=classic') {
1234 forceClassicTmux = true
1235 }
1236 }
1237
1238 // Check if worktree name is a PR reference
1239 let prNumber: number | null = null
1240 if (worktreeName) {
1241 prNumber = parsePRReference(worktreeName)
1242 if (prNumber !== null) {
1243 worktreeName = `pr-${prNumber}`
1244 }
1245 }
1246
1247 // Generate a slug if no name provided
1248 if (!worktreeName) {
1249 const adjectives = ['swift', 'bright', 'calm', 'keen', 'bold']
1250 const nouns = ['fox', 'owl', 'elm', 'oak', 'ray']
1251 const adj = adjectives[Math.floor(Math.random() * adjectives.length)]

Callers 1

mainFunction · 0.85

Calls 13

parsePRReferenceFunction · 0.85
validateWorktreeSlugFunction · 0.85
hasWorktreeCreateHookFunction · 0.85
getCwdFunction · 0.85
worktreePathForFunction · 0.85
getOrCreateWorktreeFunction · 0.85
performPostCreationSetupFunction · 0.85
worktreeBranchNameFunction · 0.85
isInITerm2Function · 0.85
isInternalBuildFunction · 0.85
errorMessageFunction · 0.70

Tested by

no test coverage detected