feat: use project name as session filename fallback

Fixes #99. Falls back to git repo name or directory name when CLAUDE_SESSION_ID is unavailable.
This commit is contained in:
tchoudhary74
2026-01-29 01:01:19 -06:00
committed by GitHub
parent 899630341b
commit 81003b1ca6
2 changed files with 51 additions and 36 deletions

View File

@@ -79,17 +79,34 @@ function getTimeString() {
return `${hours}:${minutes}`;
}
/**
* Get the git repository name
*/
function getGitRepoName() {
const result = runCommand('git rev-parse --show-toplevel');
if (!result.success) return null;
return path.basename(result.output);
}
/**
* Get project name from git repo or current directory
*/
function getProjectName() {
const repoName = getGitRepoName();
if (repoName) return repoName;
return path.basename(process.cwd()) || null;
}
/**
* Get short session ID from CLAUDE_SESSION_ID environment variable
* Returns the last 8 characters for uniqueness with brevity
* @param {string} fallback - Fallback value if no session ID (default: 'default')
* Returns last 8 characters, falls back to project name then 'default'
*/
function getSessionIdShort(fallback = 'default') {
const sessionId = process.env.CLAUDE_SESSION_ID;
if (!sessionId || sessionId.length === 0) {
return fallback;
if (sessionId && sessionId.length > 0) {
return sessionId.slice(-8);
}
return sessionId.slice(-8);
return getProjectName() || fallback;
}
/**
@@ -373,7 +390,11 @@ module.exports = {
getDateString,
getTimeString,
getDateTimeString,
// Session/Project
getSessionIdShort,
getGitRepoName,
getProjectName,
// File operations
findFiles,