mirror of
https://github.com/affaan-m/everything-claude-code.git
synced 2026-06-11 02:33:10 +08:00
* feat: auto-isolate ECC memory data for Cursor via ECC_AGENT_DATA_HOME Add ECC_AGENT_DATA_HOME (defaults to ~/.claude) with Cursor-aware resolution, sessionStart env injection, install scaffolds, and hook bootstrap so memory hooks do not collide with Claude Code when both harnesses are used. Closes #2065 Co-authored-by: Cursor <cursoragent@cursor.com> * fix: log agent-data config errors and ship cursor sessionStart deps Address CodeRabbit review: log invalid .cursor/ecc-agent-data.json parse failures, and copy cursor-session-env.js plus lib deps on legacy Cursor install so sessionStart hook path exists without hooks-runtime alone. Co-authored-by: Cursor <cursoragent@cursor.com> * fix: resolve relative agentDataHome paths from project root Project config values like ".ecc-data" now resolve against the repository root (parent of .cursor/), not process.cwd(), so Cursor hooks persist memory in the intended directory regardless of hook cwd. Addresses cubic review on PR #2066. Co-authored-by: Cursor <cursoragent@cursor.com> * docs: explain getHomeDir duplicate and docstring policy Document why agent-data-home keeps a local home-dir helper (circular require with utils.js) and list consolidation options for maintainers. Note that CodeRabbit JSDoc coverage warnings are informational relative to ECC's usual script documentation style. Addresses cubic P2 context on PR #2066. Co-authored-by: Cursor <cursoragent@cursor.com> * test: isolate agent-data-home tests from dogfooded .cursor config Use isolated temp cwd for default-resolution cases and assert resolveAgentDataHome({ projectDir }) reads ecc-agent-data.json. Document cwd/project caveats in the test file header. Co-authored-by: Cursor <cursoragent@cursor.com> --------- Co-authored-by: Cursor <cursoragent@cursor.com>
137 lines
3.9 KiB
TypeScript
137 lines
3.9 KiB
TypeScript
/**
|
|
* Session Aliases Library for Claude Code.
|
|
* Manages named aliases for session files, stored in $ECC_AGENT_DATA_HOME/session-aliases.json (default ~/.claude).
|
|
*/
|
|
|
|
/** Internal alias storage entry */
|
|
export interface AliasEntry {
|
|
sessionPath: string;
|
|
createdAt: string;
|
|
updatedAt?: string;
|
|
title: string | null;
|
|
}
|
|
|
|
/** Alias data structure stored on disk */
|
|
export interface AliasStore {
|
|
version: string;
|
|
aliases: Record<string, AliasEntry>;
|
|
metadata: {
|
|
totalCount: number;
|
|
lastUpdated: string;
|
|
};
|
|
}
|
|
|
|
/** Resolved alias information returned by resolveAlias */
|
|
export interface ResolvedAlias {
|
|
alias: string;
|
|
sessionPath: string;
|
|
createdAt: string;
|
|
title: string | null;
|
|
}
|
|
|
|
/** Alias entry returned by listAliases */
|
|
export interface AliasListItem {
|
|
name: string;
|
|
sessionPath: string;
|
|
createdAt: string;
|
|
updatedAt?: string;
|
|
title: string | null;
|
|
}
|
|
|
|
/** Result from mutation operations (set, delete, rename, update, cleanup) */
|
|
export interface AliasResult {
|
|
success: boolean;
|
|
error?: string;
|
|
[key: string]: unknown;
|
|
}
|
|
|
|
export interface SetAliasResult extends AliasResult {
|
|
isNew?: boolean;
|
|
alias?: string;
|
|
sessionPath?: string;
|
|
title?: string | null;
|
|
}
|
|
|
|
export interface DeleteAliasResult extends AliasResult {
|
|
alias?: string;
|
|
deletedSessionPath?: string;
|
|
}
|
|
|
|
export interface RenameAliasResult extends AliasResult {
|
|
oldAlias?: string;
|
|
newAlias?: string;
|
|
sessionPath?: string;
|
|
}
|
|
|
|
export interface CleanupResult {
|
|
totalChecked: number;
|
|
removed: number;
|
|
removedAliases: Array<{ name: string; sessionPath: string }>;
|
|
error?: string;
|
|
}
|
|
|
|
export interface ListAliasesOptions {
|
|
/** Filter aliases by name or title (partial match, case-insensitive) */
|
|
search?: string | null;
|
|
/** Maximum number of aliases to return */
|
|
limit?: number | null;
|
|
}
|
|
|
|
/** Get the path to the aliases JSON file */
|
|
export function getAliasesPath(): string;
|
|
|
|
/** Load all aliases from disk. Returns default structure if file doesn't exist. */
|
|
export function loadAliases(): AliasStore;
|
|
|
|
/**
|
|
* Save aliases to disk with atomic write (temp file + rename).
|
|
* Creates backup before writing; restores on failure.
|
|
*/
|
|
export function saveAliases(aliases: AliasStore): boolean;
|
|
|
|
/**
|
|
* Resolve an alias name to its session data.
|
|
* @returns Alias data, or null if not found or invalid name
|
|
*/
|
|
export function resolveAlias(alias: string): ResolvedAlias | null;
|
|
|
|
/**
|
|
* Create or update an alias for a session.
|
|
* Alias names must be alphanumeric with dashes/underscores.
|
|
* Reserved names (list, help, remove, delete, create, set) are rejected.
|
|
*/
|
|
export function setAlias(alias: string, sessionPath: string, title?: string | null): SetAliasResult;
|
|
|
|
/**
|
|
* List all aliases, optionally filtered and limited.
|
|
* Results are sorted by updated time (newest first).
|
|
*/
|
|
export function listAliases(options?: ListAliasesOptions): AliasListItem[];
|
|
|
|
/** Delete an alias by name */
|
|
export function deleteAlias(alias: string): DeleteAliasResult;
|
|
|
|
/**
|
|
* Rename an alias. Fails if old alias doesn't exist or new alias already exists.
|
|
* New alias name must be alphanumeric with dashes/underscores.
|
|
*/
|
|
export function renameAlias(oldAlias: string, newAlias: string): RenameAliasResult;
|
|
|
|
/**
|
|
* Resolve an alias or pass through a session path.
|
|
* First tries to resolve as alias; if not found, returns the input as-is.
|
|
*/
|
|
export function resolveSessionAlias(aliasOrId: string): string;
|
|
|
|
/** Update the title of an existing alias. Pass null to clear. */
|
|
export function updateAliasTitle(alias: string, title: string | null): AliasResult;
|
|
|
|
/** Get all aliases that point to a specific session path */
|
|
export function getAliasesForSession(sessionPath: string): Array<{ name: string; createdAt: string; title: string | null }>;
|
|
|
|
/**
|
|
* Remove aliases whose sessions no longer exist.
|
|
* @param sessionExists - Function that returns true if a session path is valid
|
|
*/
|
|
export function cleanupAliases(sessionExists: (sessionPath: string) => boolean): CleanupResult;
|