fix(session-start): scope summary lookup to repository identity (#3160)

This commit is contained in:
Affaan Mustafa
2026-09-18 18:59:41 -04:00
parent b15f7d8171
commit f5f1f6b45b
4 changed files with 229 additions and 13 deletions
+23
View File
@@ -135,6 +135,28 @@ function getGitRepoName() {
return path.basename(result.output);
}
/**
* Get the repository identity for a directory: the canonical (real) path of
* the repository's common git dir, which is the main worktree's .git
* directory. Every linked worktree of one repository resolves to the same
* identity, while unrelated repositories never share one.
*
* @param {string} [dir] - Directory to resolve from (defaults to process.cwd()).
* @returns {string|null} The canonical common git dir, or null when dir is
* not inside a git repository or does not exist.
*/
function getRepoIdentity(dir) {
const target = dir || process.cwd();
const result = runCommand('git rev-parse --git-common-dir', { cwd: target });
if (!result.success || !result.output) return null;
const commonDir = path.resolve(target, result.output);
try {
return fs.realpathSync(commonDir);
} catch {
return commonDir;
}
}
/**
* Get project name from git repo or current directory
*/
@@ -642,6 +664,7 @@ module.exports = {
sanitizeSessionId,
getSessionIdShort,
getGitRepoName,
getRepoIdentity,
getProjectName,
// File operations