feat: add runtime file discovery chain#379
Open
fry69 wants to merge 3 commits into
Open
Conversation
…me/, $DS4_RUNTIME_DIR) Implement ds4_get_executable_path() and ds4_find_runtime_file() so the binary works from any CWD without --chdir. The lookup chain is: 1. Absolute path (starts with '/') → use as-is 2. $DS4_RUNTIME_DIR env var → check there 3. Binary-relative (dirname of executable) → check there 4. ~/.ds4/runtime/ → check there 5. CWD-relative (current fallback) → check there Changes: - ds4.h: declare ds4_get_executable_path() and ds4_find_runtime_file() - ds4.c: implement both functions; resolve opt->model_path and opt->mtp_path through the chain in ds4_engine_open() - ds4_metal.m: resolve metal/*.metal sources through ds4_find_runtime_file() instead of the old hard-coded CWD list; env overrides still work
…me discovery chain The --dump-tokens path in ds4 (the basic CLI binary) called model_open() directly without resolving through ds4_find_runtime_file(), so it would fail unless -m /abs/path was given or CWD was the source tree. Now it uses the same ds4_find_runtime_file() lookup that ds4_engine_open() uses, making --dump-tokens work from any CWD.
…e installation Introduce 'make install-user' that copies ds4 and ds4-agent to ~/.local/bin (configurable via INSTALL_BIN_DIR), copies metal/*.metal to ~/.ds4/runtime/metal/, and suggests a model symlink or points to download_model.sh. No system directories are touched. The model file itself is never copied (multi-GB); only a symlink command is printed if ds4flash.gguf exists in the build directory.
9e98560 to
3c10f66
Compare
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.
This PR adds automatic discovery for runtime files to
ds4andds4-agent, so they can be run from anywhere without fuss.There is also a new Makefile target
install-userthat installs those runtime files automatically, defensively.This works for me on macOS, it may need polish for other platforms.
Automatically generated PR message below:
Problem
ds4-agent currently depends on the process CWD to find the model file, Metal kernel sources, and expert routing files. The user must either launch from the ds4 source tree, use --chdir to point to it, or pass -m /full/path/to/model.gguf explicitly every time. This is fragile and confusing — the binary should "just work" from any directory.
Solution
Add a runtime file discovery chain and a make install-user target so the binaries work from any CWD with zero flags.
Runtime discovery (ds4.c, ds4_metal.m, ds4.h)
New functions ds4_get_executable_path() and ds4_find_runtime_file() search for runtime files in this order:
Where the lookup is applied:
User-local install (Makefile)
New make install-user target copies files to user-local paths (no system directories touched):
The model file itself is never copied (multi-GB, fragile). If ds4flash.gguf exists in the build directory the install target prints a one-line ln -s command the user can run explicitly.
--chdir is kept for backward compatibility but is now rarely needed.
Files changed: 4 files, +191/-18 lines