Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 23 additions & 2 deletions scripts/postinstall.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,9 +6,10 @@
*/

import { execSync } from 'child_process';
import { existsSync } from 'fs';
import { chmodSync, existsSync } from 'fs';
import { homedir, platform } from 'os';
import { join } from 'path';
import { join, dirname } from 'path';
import { fileURLToPath } from 'url';

// ============================================================================
// Configuration
Expand Down Expand Up @@ -96,6 +97,26 @@ function getTmuxInstallInstructions() {
console.log(colors.bold('Claudeman postinstall check...'));
console.log('');

// ----------------------------------------------------------------------------
// 0. Fix node-pty spawn-helper permissions (required on macOS/Linux)
// ----------------------------------------------------------------------------

const __dirname = dirname(fileURLToPath(import.meta.url));
const spawnHelperPaths = [
join(__dirname, '..', 'node_modules', 'node-pty', 'prebuilds', 'darwin-arm64', 'spawn-helper'),
join(__dirname, '..', 'node_modules', 'node-pty', 'prebuilds', 'darwin-x64', 'spawn-helper'),
];

for (const helperPath of spawnHelperPaths) {
if (existsSync(helperPath)) {
try {
chmodSync(helperPath, 0o755);
} catch {
// Non-critical on platforms where this path doesn't apply
}
}
}

let hasWarnings = false;
let hasErrors = false;

Expand Down
25 changes: 14 additions & 11 deletions src/session.ts
Original file line number Diff line number Diff line change
Expand Up @@ -868,7 +868,7 @@ export class Session extends EventEmitter {
cols: 120,
rows: 40,
cwd: this.workingDir,
env: { ...process.env, TERM: 'xterm-256color' },
env: (() => { const e: Record<string, string | undefined> = { ...process.env, TERM: 'xterm-256color' }; delete e.CLAUDECODE; return e; })(),
});

// Set claudeSessionId immediately since we passed --session-id to Claude
Expand Down Expand Up @@ -934,15 +934,18 @@ export class Session extends EventEmitter {
cols: 120,
rows: 40,
cwd: this.workingDir,
env: {
...process.env,
PATH: getAugmentedPath(),
TERM: 'xterm-256color',
// Inform Claude it's running within Claudeman (helps prevent self-termination)
CLAUDEMAN_SCREEN: '1',
CLAUDEMAN_SESSION_ID: this.id,
CLAUDEMAN_API_URL: process.env.CLAUDEMAN_API_URL || 'http://localhost:3000',
},
env: (() => {
const env: Record<string, string | undefined> = {
...process.env,
PATH: getAugmentedPath(),
TERM: 'xterm-256color',
CLAUDEMAN_SCREEN: '1',
CLAUDEMAN_SESSION_ID: this.id,
CLAUDEMAN_API_URL: process.env.CLAUDEMAN_API_URL || 'http://localhost:3000',
};
delete env.CLAUDECODE;
return env;
})(),
});
} catch (spawnErr) {
console.error('[Session] Failed to spawn Claude PTY:', spawnErr);
Expand Down Expand Up @@ -1146,7 +1149,7 @@ export class Session extends EventEmitter {
cols: 120,
rows: 40,
cwd: this.workingDir,
env: { ...process.env, TERM: 'xterm-256color' },
env: (() => { const e: Record<string, string | undefined> = { ...process.env, TERM: 'xterm-256color' }; delete e.CLAUDECODE; return e; })(),
});
} catch (spawnErr) {
console.error('[Session] Failed to spawn PTY for shell mux attachment:', spawnErr);
Expand Down
1 change: 1 addition & 0 deletions src/tmux-manager.ts
Original file line number Diff line number Diff line change
Expand Up @@ -256,6 +256,7 @@ export class TmuxManager extends EventEmitter implements TerminalMultiplexer {
const pathExport = claudeDir ? `export PATH="${claudeDir}:$PATH" && ` : '';

const envExports = [
'unset CLAUDECODE',
'export CLAUDEMAN_SCREEN=1',
`export CLAUDEMAN_SESSION_ID=${sessionId}`,
`export CLAUDEMAN_SCREEN_NAME=${muxName}`,
Expand Down