fix: resolve project ID for non-git directories - #2282
Open
MaxPylypko wants to merge 1 commit into
Open
MaxPylypko wants to merge 1 commit into
MaxPylypko wants to merge 1 commit into
Conversation
When no .git directory is found, fromDirectory() returned ProjectID.global immediately, skipping resolveProjectId() which creates .mimocode-project-id for non-git directories. This caused all non-git projects to share the same global project memory, preventing memory isolation. Now calls resolveProjectId(directory) for non-git directories, which creates .mimocode-project-id with a unique UUID, giving each directory its own project memory at memory/projects/<uuid>/MEMORY.md. Fixes XiaomiMiMo#902, XiaomiMiMo#354, XiaomiMiMo#2012
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
Fixes #902, #354, #2012
When no
.gitdirectory is found,fromDirectory()returnedProjectID.globalimmediately, skippingresolveProjectId()which already handles non-git directories by creating.mimocode-project-idwith a unique UUID.This caused all non-git projects to share the same
globalproject memory, preventing memory isolation between different working directories.Root Cause
In
packages/opencode/src/project/project.ts, thefromDirectory()function:The
resolveProjectId()function inproject-id.tsalready has logic for non-git directories:But this code was dead code — never reached because
fromDirectory()returned early withProjectID.global.Fix
Call
resolveProjectId(directory)for non-git directories:This creates
.mimocode-project-idin the working directory with a unique UUID, giving each directory its own project memory atmemory/projects/<uuid>/MEMORY.md.Impact
.mimocode-project-idfiles are preserved (read before write)MIMOCODE_DISABLE_GITflag still returnsProjectID.globalas beforeTesting
bun typecheckpasses.mimocode-project-idand gets unique project IDpackageManagerin package.json)Build Notes
bun run build:local(from repo root)packages/opencode/dist/mimocode-linux-x64/bin/mimo中文摘要
修复 #902、#354、#2012
当工作目录没有
.git时,fromDirectory()直接返回ProjectID.global,跳过了resolveProjectId()中已有的为非 git 目录创建.mimocode-project-id的逻辑。这导致所有非 git 项目共享同一个
global项目记忆,无法实现不同工作目录之间的记忆隔离。根因
project.ts中的fromDirectory()函数在未找到.git时立即返回ProjectID.global,而project-id.ts中的resolveProjectId()虽然已有处理非 git 目录的代码(创建.mimocode-project-id文件),但该代码从未被执行——属于死代码。修复
对非 git 目录调用
resolveProjectId(directory),在工作目录下创建.mimocode-project-id文件并生成唯一 UUID,使每个目录拥有独立的项目记忆memory/projects/<uuid>/MEMORY.md。影响
.mimocode-project-id文件会被保留(先读后写)MIMOCODE_DISABLE_GIT标志仍返回ProjectID.global构建说明
bun run build:local(在仓库根目录执行)packages/opencode/dist/mimocode-linux-x64/bin/mimo