loadUserModels ignores --repo-dir, uses cwd instead
Opened by swampadmin · 9/15/2025
Description
loadUserModels() in src/cli/mod.ts uses Deno.cwd() to locate the swamp repo and load extension model types. However, the --repo-dir flag (available on most commands) tells the command where definitions and data live.
When running a command like:
swamp model method run kibana status --json --repo-dir ~/Code/kibana-srefrom a directory that is NOT the swamp repo (e.g. ~/Code/kibana), the extension model loader fails to find the repo marker and silently skips loading user models. The command then fails with:
Unknown model type: @smith/kibana-devSteps to Reproduce
- Create a swamp repo with an extension model at
~/Code/my-swamp-repo cd ~/some-other-directoryswamp model method run my-model my-method --json --repo-dir ~/Code/my-swamp-repo- Observe:
Unknown model type: @myorg/my-model
Expected Behavior
--repo-dir should be respected by the user model loader, so extension models are loaded from the correct repo regardless of cwd.
Actual Behavior
Extension models are only loaded when cwd is the swamp repo directory. The --repo-dir flag has no effect on model type registration.
Root Cause
In src/cli/mod.ts, loadUserModels() (line ~111) reads Deno.cwd() to find the repo marker and resolve the models directory. It does not have access to the --repo-dir option because it runs at CLI startup before command parsing. The fix would involve either:
- Deferring user model loading until after command option parsing, so
--repo-diris available - Or having the command handler call the loader explicitly when
--repo-dirdiffers fromcwd
Workaround
Run all swamp commands from the swamp repo directory instead of using --repo-dir.
Environment
- swamp version: 20260227.003433.0-sha.349ae436
- OS: macOS (darwin 25.3.0)
Closed
No activity in this phase yet.
Sign in to post a ripple.