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
22 changes: 11 additions & 11 deletions .claude/hooks/session-start.php
Original file line number Diff line number Diff line change
Expand Up @@ -3,36 +3,36 @@

declare(strict_types=1);







/**
* SessionStart Hook
*
* Updates the lock file with Claude's session_id for statusline matching.
* Reads session_id from stdin JSON and writes to lock file specified in LARACODE_LOCK_FILE env var.
*/
$input = file_get_contents('php://stdin');
$data = $input ? json_decode($input, true) : [];

$sessionId = $data['session_id'] ?? null;
$lockFile = getenv('LARACODE_LOCK_FILE');

if (! $sessionId || ! $lockFile || ! file_exists($lockFile)) {
exit(0);
exit(0);
}

$lockContent = file_get_contents($lockFile);
if ($lockContent === false) {
exit(0);
exit(0);
}

$lockData = json_decode($lockContent, true);
if (! is_array($lockData)) {
exit(0);
exit(0);
}

$lockData['session_id'] = $sessionId;

$result = file_put_contents($lockFile, json_encode($lockData, JSON_PRETTY_PRINT | JSON_UNESCAPED_SLASHES));
if ($result === false) {
fwrite(STDERR, "Failed to write session_id to lock file: {$lockFile}\n");
exit(1);
fwrite(STDERR, "Failed to write session_id to lock file: {$lockFile}\n");
exit(1);
}
45 changes: 41 additions & 4 deletions .claude/scripts/statusline.php
Original file line number Diff line number Diff line change
Expand Up @@ -29,6 +29,9 @@

$status = $input ? json_decode($input, true) : [];

// Extract session_id for lock file matching
$sessionId = $status['session_id'] ?? null;

// Extract model - handle both nested format and simple string
$model = 'Unknown';
if (isset($status['model'])) {
Expand All @@ -52,8 +55,11 @@
}
}

// Find active build lock file
$lockFile = findActiveLock();
// Get current git branch
$gitBranch = getCurrentBranch();

// Find active build lock file (matching session_id if available)
$lockFile = findActiveLock($sessionId);
$taskInfo = '';

if ($lockFile && file_exists($lockFile)) {
Expand All @@ -78,6 +84,10 @@
// Build the status line with ANSI colors
$statusLine = '';

if ($gitBranch) {
$statusLine .= "\033[35m[{$gitBranch}]\033[0m "; // Magenta for branch
}

if ($taskInfo) {
$statusLine .= "\033[36m{$taskInfo}\033[0m"; // Cyan for task info
}
Expand All @@ -91,9 +101,19 @@
echo $statusLine;

/**
* Find the active lock file in .laracode/specs/
* Get current git branch name
*/
function getCurrentBranch(): ?string
{
$result = exec('git rev-parse --abbrev-ref HEAD 2>/dev/null', $output, $returnCode);

return $returnCode === 0 && $result ? trim($result) : null;
}

/**
* Find the active lock file in .laracode/specs/ matching the session_id
*/
function findActiveLock(): ?string
function findActiveLock(?string $sessionId): ?string
{
$cwd = getcwd();
if ($cwd === false) {
Expand All @@ -110,6 +130,23 @@ function findActiveLock(): ?string
return null;
}

// First pass: try to match by session_id
if ($sessionId !== null) {
foreach ($dirs as $dir) {
$lockPath = $dir.'/index.lock';
if (file_exists($lockPath)) {
$content = file_get_contents($lockPath);
if ($content !== false) {
$data = json_decode($content, true);
if (isset($data['session_id']) && $data['session_id'] === $sessionId) {
return $lockPath;
}
}
}
}
}

// Fallback: return first lock file (backward compatibility)
foreach ($dirs as $dir) {
$lockPath = $dir.'/index.lock';
if (file_exists($lockPath)) {
Expand Down
25 changes: 21 additions & 4 deletions .laracode/settings.json
Original file line number Diff line number Diff line change
@@ -1,9 +1,10 @@
{
"watch": {
"paths": [
"app/",
"routes/",
"resources/"
"app",
"config",
"resources",
"tests"
],
"searchWord": "@claude",
"stopWord": "claude!",
Expand All @@ -19,5 +20,21 @@
"**/*.log",
"**/.DS_Store"
]
}
},
"testing": {
"commands": [
"composer test",
"composer checks"
]
},
"linting": {
"commands": [
"composer lint",
"composer phpstan"
]
},
"worktrees": {
"defaultSourceBranch": "master"
},
"defaultMode": "yolo"
}
Loading