Add .oflm user directory, scan new → legacy, and put the user directory in the search chains
Background
get_models_directory() (common/utils.cpp:254) resolves the user directory to %USERPROFILE%.flm on Windows and $HOME/.config/flm on Linux. The other three lookups — find_model_list(), find_model_info(), find_xclbin_path() — never look there at all. They go executable directory → CWD → ../share/flm → build-time prefix.
That is why flm-add ends by printing:
export FLM_CONFIG_PATH="$HOME/.config/flm/model_list.json" export FLM_XCLBIN_PATH="$HOME/.config/flm"
The user-level registry and the user-level xclbins/ symlinks only work because the user wires them in by hand.
Proposal
- Introduce .oflm as the user directory for new installs, keeping the existing per-platform convention: %USERPROFILE%.oflm on Windows, $HOME/.config/oflm on Linux (the dot belongs on Windows only; .config is already hidden).
- Scan new → legacy: .oflm first, .flm second, in every lookup. An existing install keeps working with no migration step and no copying of multi-GB weights.
- Add the user directory to find_model_list(), find_model_info() and find_xclbin_path() — ahead of the bundle, behind the explicit env var. This is what makes the env exports optional rather than mandatory, and it is the half that flm-add currently works around.
- While in there: find_model_info()'s Windows branch stops at the executable directory and never reaches ../share/flm or the install prefix, unlike its Linux branch. Probably unintentional.
Open question — first-wins or merge?
The two kinds of lookup want different answers, and picking one for both is a trap:
- Weights / xclbins/
— first-wins per entry is right. Look for under .oflm, then .flm. - model_list.json — first-wins loses the user's whole registry the moment an .oflm/model_list.json appears, because a registry file is not one entry. A merge (built-ins, then legacy user file, then new user file, later never allowed to shadow a built-in tag) keeps both.
Related: flm-add's register() seeds a missing user registry with a full deep copy of the system registry. That snapshot goes stale as soon as the application ships new built-in models, and it becomes actively wrong under a merge. If scanning becomes new → legacy, the user file should hold user entries only.
Migration surface
The user directory holds models/, history/ (runner/runner.cpp:480), and — for flm-add installs — model_list.json plus xclbins/ symlinks. All four need to resolve under either root.
Came at this from the embedding backend, which turns out to exercise the open question in the issue harder than the LLM path does. Three things.
1. Embedding models need no separate store — they already resolve through get_models_directory()
There is no second model tree. src/open_npue_adapter/npue_embedding.cpp takes
the model's directory and does two lookups inside it:
- the container —
find_container():npue_containerfrom the model entry, else the single.npuein the directory, else build one fromconfig.jsonon first run; - the design set —
find_artifacts():<model dir>/npue_designs/gemm_rtp/design.jsonfirst, thenfind_xclbin_path()+/xclbins/<npue_design_family>/gemm_rtp/.
So the weights and the per-model npue_designs/ are covered by proposal item 2
for free, with no embedding-specific work. Worth noting only because
npue_designs/ is a sixth thing under the model directory that the Migration
surface list does not name, and it would be easy to tidy away.
2. find_xclbin_path() returns a ROOT, not a resolved artifact — so item 2 cannot deliver what item 3 promises
common/utils.cpp:120. It returns the first prefix whose xclbins/ directory
exists (env var, then executable dir, then CWD, then the build-time prefix). It
never checks whether the artifact you actually want is under that prefix.
Scan new → legacy at the prefix level therefore means: the moment
%USERPROFILE%\.oflm\xclbins\ exists at all — even holding one entry —
every lookup binds to that root, and .flm\xclbins\ is never consulted again. A
user who flm-adds one thing into .oflm loses everything they already had in
.flm.
That is the same failure the issue already identifies for model_list.json
("first-wins loses the user's whole registry ... because a registry file is not
one entry"), and the issue's answer for the other case — "Weights /
xclbins/<name> — first-wins per entry is right" — is the correct answer but
is not something a prefix-returning function can implement. The shape has to
change: from return a root to resolve this name across roots, e.g.
std::optional<fs::path> find_xclbin(std::string_view name); // .oflm, then .flm, then bundle
with the existing find_xclbin_path() kept for callers that genuinely want a
root. Same argument applies to find_model_info().
3. Embeddings make the mixed-root case likely rather than theoretical, because the unit is a FAMILY
The LLM path looks up xclbins/<model>, so one model is one entry and a mixed
install is a bit contrived. The embedding path looks up
xclbins/<npue_design_family>, and families are shared: six models over five
families in src/model_list.json, with BERT-h768-gated-bfp16 serving two of
them (nomic-embed-text-v1.5 and gte-multilingual-base have matching GEMM
geometry, so they run the same design set bit for bit).
A design set is also built rather than downloaded, so "I built one family into the new directory and the rest are still in the old one" is the expected intermediate state, not an edge case.
Small one, while in there
include/utils/utils.hpp:382 documents get_models_directory() as
"Documents/flm/models on Windows or ~/.config/flm on Linux". The implementation
returns %USERPROFILE%\.flm and $HOME/.config/flm (get_user_directory()
appends /.config itself, so the .cpp comment at line 252 is right and the
header is the one that is wrong). Three descriptions of one function is how the
Documents/ reading survives.
I believe this is addressed in #157