feat(agents): attribute & group Claude per-project memory#99
Merged
Conversation
…cwd from transcript)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Claude stores per-project memory outside the project tree, under
~/.claude/projects/<encoded-cwd>/memory/, keyed by the session cwd. Previously HarnessKit surfaced all of these as a flat pile ofGlobalrows on the Agents page, with no link to the project they belong to and no grouping.This PR does two things:
Backend — attribute memory to its project. A new generic adapter hook exposes "memory that lives outside the project tree, grouped by owning cwd". The Claude adapter implements it by reading the real cwd from each project's session transcript (the encoded directory name is a lossy, non-injective encoding, so it is never decoded). The scanner then assigns
ConfigScope::Projectwhen that cwd matches a registered project, orConfigScope::Globalotherwise.Frontend — group the MEMORY section. Memory files are grouped by their storage directory under collapsible headers. Registered projects show the project name + a muted store path; unregistered stores show the store path. Rows are indented and show
filename + scope badge + size; the (repeated) path now lives once on the group header instead of on every row.Backend
AgentAdapter::external_project_memory() -> Vec<(Option<PathBuf>, Vec<PathBuf>)>(default empty).ClaudeAdapterimplements it in a single pass over~/.claude/projects/*, reading the cwd from the first transcript line (session_cwd); its oldglobal_memory_filesoverride is removed so memory now comes from exactly one place (no double-listing).Project/Global. Unregistered or undeterminable cwd →Global(nothing is dropped).Frontend
groupMemoryFileshelper +MemoryGroupcomponent;ConfigSectionrenders grouped headers for the memory category only, flat list elsewhere.formatBytes(src/lib/format.ts) and auseCollapsibleStatehook (src/hooks/), both reused by the new component and the existing ones.ConfigFileEntrygainshideScopePath(hide only the path, keep the badge) andinset(indent via the row's own padding so the hover highlight fills to the left edge).Test plan
cargo test -p hk-core— green (adapter,session_cwd, scanner classification, no-double-listing).npx vitest run— green (grouping helper incl. POSIX + Windows paths, collapse hook, byte formatter, grouped-section rendering).npx tsc --noEmitandnpm run lint— clean.Known limitations (by design)
Globalrather than misattributing (safe degrade).~/.claude/projects/<encoded>/memorypath on purpose, since the encoding is lossy and decoding would misrepresent where the files actually live.🤖 Generated with Claude Code