fix(ckg): accept file path for ckg tool and clarify path parameter - #426
Open
nankingjing wants to merge 1 commit into
Open
fix(ckg): accept file path for ckg tool and clarify path parameter#426nankingjing wants to merge 1 commit into
nankingjing wants to merge 1 commit into
Conversation
The ckg tool's 'path' parameter description was ambiguous ('The path to
the codebase.'), leading some models (e.g. Doubao) to pass a file path
instead of the codebase directory. This caused a hard failure ('Codebase
path X is not a directory') and the CKG was never initialized.
Clarify the parameter description to state a directory is required, and,
when a file path is passed anyway, fall back to its parent directory so
the index can still be built.
Fixes bytedance#354
Author
|
Reviewed — the fallback to parent directory when a file path is given is a clean defensive fix for the CKG tool. Ready for review. |
Author
|
@chao-peng ready for review. Fixes CKG tool accepting a file path: falls back to parent directory when path is a file, and clarifies the path parameter description. |
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
The
ckgtool'spathparameter description was ambiguous ("The path to the codebase."), leading some models (e.g. Doubao, see #354) to pass a file path instead of the codebase directory. This caused a hard failure (Codebase path X is not a directory) and the CKG was never initialized, sosearch_function/search_class/search_class_methodcould not be used at all.Changes
pathparameter description — it now explicitly states a directory (the codebase root) is required, and documents the file-path fallback. This is the root cause: the ambiguous description misled the model.execute()— if a file path is passed and the file exists, resolve to its parent directory so the CKG index can still be built. Other non-directory paths (e.g. broken symlinks) still return the original clear error.Why this is correct
CKGDatabase.__init__indexes viaPath.glob("**/*"), so it needs a directory; passing the parent directory of the intended file is exactly what it expects.pathlib.Path.is_file()/.parentsemantics and only triggers when the path exists but is not a directory, so existing directory behavior is unchanged._ckg_databasescache keys on the resolved directoryPath, keeping caching consistent.Fixes #354