chore: sync with upstream ae2c063 + update zh translations

This commit is contained in:
xuxiang
2026-01-31 18:22:06 +08:00
parent 6c531eb17b
commit b1d03833b9
30 changed files with 1694 additions and 516 deletions

View File

@@ -7,7 +7,7 @@
const fs = require('fs');
const path = require('path');
const { commandExists, getClaudeDir, readFile, writeFile, log, runCommand } = require('./utils');
const { commandExists, getClaudeDir, readFile, writeFile } = require('./utils');
// Package manager definitions
const PACKAGE_MANAGERS = {

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;
}
/**
@@ -148,7 +165,7 @@ function findFiles(dir, pattern, options = {}) {
searchDir(fullPath);
}
}
} catch (err) {
} catch (_err) {
// Ignore permission errors
}
}
@@ -373,7 +390,11 @@ module.exports = {
getDateString,
getTimeString,
getDateTimeString,
// Session/Project
getSessionIdShort,
getGitRepoName,
getProjectName,
// File operations
findFiles,