fix: break 3-file import cycle in cli/project-files - #1170
Open
AbhijitK20 wants to merge 1 commit into
Open
Conversation
project-files.ts -> auth.ts -> logger.ts -> project-files.ts Import getConfigDir directly from config-dir instead of auth to break the circular dependency. config-dir.ts exports the identical function (auth.ts just wraps it). anonymous-id.ts already imports from config-dir directly. Add getProjectDataDir tests to exercise the fixed import path.
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
Breaks the circular import dependency between
project-files.ts,auth.ts, andlogger.ts.The cycle:
project-files.tsimportedgetConfigDirfrom./utils/auth, which importslogger, which importsgetCurrentChatDirandgetProjectRootback from../project-files— creating a 3-file circular dependency.The fix: Import
getConfigDirdirectly from./utils/config-dir, which has no dependency onauth.ts,logger.ts, orproject-files.ts.Maintainer Feedback Addressed
Same signature? Yes —
config-dir.ts:14exports the identicalgetConfigDirfunction.auth.ts:37is a thin wrapper:export const getConfigDir = (): string => getConfigDirBase(). No behavior change.Does the cycle cause a real problem? Yes — circular dependencies can cause
undefinedvalues at import time depending on module load order, especially in bundlers or when tree-shaking.Test coverage — Added two tests for
getProjectDataDirinproject-files-chat-id.test.tsto exercise the fixed import path.Notes
anonymous-id.tsalready importsgetConfigDirdirectly fromconfig-dir(this PR alignsproject-files.tswith that pattern)getConfigDirreturns the same value either way