mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-03-30 13:43:26 +08:00
fix: remove dead export, harden session-aliases, sync .cursor scripts
- Remove duplicate getAliasesPath() from utils.js (only used in session-aliases.js which has its own copy) - session-aliases.js: validate cleanupAliases param is a function, check saveAliases return value, guard resolveAlias against empty input - Sync .cursor/skills/strategic-compact/suggest-compact.sh with the fixed main version (CLAUDE_SESSION_ID instead of $$)
This commit is contained in:
@@ -28,7 +28,9 @@
|
|||||||
# - Plan has been finalized
|
# - Plan has been finalized
|
||||||
|
|
||||||
# Track tool call count (increment in a temp file)
|
# Track tool call count (increment in a temp file)
|
||||||
COUNTER_FILE="/tmp/claude-tool-count-$$"
|
# Use CLAUDE_SESSION_ID for session-specific counter (not $$ which changes per invocation)
|
||||||
|
SESSION_ID="${CLAUDE_SESSION_ID:-${PPID:-default}}"
|
||||||
|
COUNTER_FILE="/tmp/claude-tool-count-${SESSION_ID}"
|
||||||
THRESHOLD=${COMPACT_THRESHOLD:-50}
|
THRESHOLD=${COMPACT_THRESHOLD:-50}
|
||||||
|
|
||||||
# Initialize or increment counter
|
# Initialize or increment counter
|
||||||
|
|||||||
@@ -154,6 +154,8 @@ function saveAliases(aliases) {
|
|||||||
* @returns {object|null} Alias data or null if not found
|
* @returns {object|null} Alias data or null if not found
|
||||||
*/
|
*/
|
||||||
function resolveAlias(alias) {
|
function resolveAlias(alias) {
|
||||||
|
if (!alias) return null;
|
||||||
|
|
||||||
// Validate alias name (alphanumeric, dash, underscore)
|
// Validate alias name (alphanumeric, dash, underscore)
|
||||||
if (!/^[a-zA-Z0-9_-]+$/.test(alias)) {
|
if (!/^[a-zA-Z0-9_-]+$/.test(alias)) {
|
||||||
return null;
|
return null;
|
||||||
@@ -399,6 +401,10 @@ function getAliasesForSession(sessionPath) {
|
|||||||
* @returns {object} Cleanup result
|
* @returns {object} Cleanup result
|
||||||
*/
|
*/
|
||||||
function cleanupAliases(sessionExists) {
|
function cleanupAliases(sessionExists) {
|
||||||
|
if (typeof sessionExists !== 'function') {
|
||||||
|
return { totalChecked: 0, removed: 0, removedAliases: [], error: 'sessionExists must be a function' };
|
||||||
|
}
|
||||||
|
|
||||||
const data = loadAliases();
|
const data = loadAliases();
|
||||||
const removed = [];
|
const removed = [];
|
||||||
|
|
||||||
@@ -409,8 +415,8 @@ function cleanupAliases(sessionExists) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (removed.length > 0) {
|
if (removed.length > 0 && !saveAliases(data)) {
|
||||||
saveAliases(data);
|
log('[Aliases] Failed to save after cleanup');
|
||||||
}
|
}
|
||||||
|
|
||||||
return {
|
return {
|
||||||
|
|||||||
@@ -34,13 +34,6 @@ function getSessionsDir() {
|
|||||||
return path.join(getClaudeDir(), 'sessions');
|
return path.join(getClaudeDir(), 'sessions');
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Get the session aliases file path
|
|
||||||
*/
|
|
||||||
function getAliasesPath() {
|
|
||||||
return path.join(getClaudeDir(), 'session-aliases.json');
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Get the learned skills directory
|
* Get the learned skills directory
|
||||||
*/
|
*/
|
||||||
@@ -447,7 +440,6 @@ module.exports = {
|
|||||||
getHomeDir,
|
getHomeDir,
|
||||||
getClaudeDir,
|
getClaudeDir,
|
||||||
getSessionsDir,
|
getSessionsDir,
|
||||||
getAliasesPath,
|
|
||||||
getLearnedSkillsDir,
|
getLearnedSkillsDir,
|
||||||
getTempDir,
|
getTempDir,
|
||||||
ensureDir,
|
ensureDir,
|
||||||
|
|||||||
Reference in New Issue
Block a user