Skip to main content
← Back to list
01Issue
BugClosedSwamp Club
AssigneesNone

loadUserModels ignores --repo-dir, uses cwd instead

Opened by swampadmin · 8/25/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-sre

from 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-dev

Steps to Reproduce

  1. Create a swamp repo with an extension model at ~/Code/my-swamp-repo
  2. cd ~/some-other-directory
  3. swamp model method run my-model my-method --json --repo-dir ~/Code/my-swamp-repo
  4. 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-dir is available
  • Or having the command handler call the loader explicitly when --repo-dir differs from cwd

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)
02Bog Flow
OPENTRIAGEDIN PROGRESSCLOSED

Closed

No activity in this phase yet.

03Sludge Pulse

Sign in to post a ripple.