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

@@ -52,7 +52,7 @@ process.stdin.on('end', () => {
if (hasConsole) {
console.error('[Hook] Remove console.log statements before committing');
}
} catch (error) {
} catch (_error) {
// Silently ignore errors (git might not be available, etc.)
}

View File

@@ -16,7 +16,6 @@ const {
getTimeString,
getSessionIdShort,
ensureDir,
readFile,
writeFile,
replaceInFile,
log

View File

@@ -8,7 +8,6 @@
* files and notifies Claude of available context to load.
*/
const path = require('path');
const {
getSessionsDir,
getLearnedSkillsDir,

View File

@@ -14,7 +14,6 @@
*/
const path = require('path');
const fs = require('fs');
const {
getTempDir,
readFile,

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,

View File

@@ -19,10 +19,8 @@ const {
setProjectPackageManager,
getAvailablePackageManagers,
detectFromLockFile,
detectFromPackageJson,
getSelectionPrompt
detectFromPackageJson
} = require('./lib/package-manager');
const { log } = require('./lib/utils');
function showHelp() {
console.log(`