Liking cljdoc? Tell your friends :D

com.blockether.vis.ext.language-clojure.repl-manager

Owned, session-scoped nREPL lifecycle for the Clojure pack.

OWNERSHIP: each vis SESSION owns its own nREPL subprocess(es). The processes atom is keyed by [session-id dir], so two sessions in the same directory get two independent REPLs and neither can see or stop the other's. A managed REPL lives and dies with THIS vis process — there is NO persistent registry and NO PID re-attach across a vis restart. Restarting vis means a fresh REPL, exactly like the Python pack.

PORT: we PICK a free ephemeral port ourselves and pass it to the launcher EXPLICITLY (nrepl.cmdline --port N, lein repl :headless :port N, bb nrepl-server N), so we always KNOW our port without ever reading a .nrepl-port file back. Any stray .nrepl-port a tool drops in the project is deleted after boot — vis never depends on it and never leaves it behind.

ALIASES: a REPL is ALWAYS booted with the project's :dev :test deps + paths on its classpath (full dependency spec), with the user's :main-opts dropped (our synthetic :vis/nrepl-launch alias appends last so -m nrepl.cmdline wins). Unknown :dev/:test aliases are silently ignored by tools.deps, so this is safe in any project.

Starting/stopping is CORE and ALWAYS allowed — never gated behind a flag.

Owned, session-scoped nREPL lifecycle for the Clojure pack.

OWNERSHIP: each vis SESSION owns its own nREPL subprocess(es). The `processes`
atom is keyed by `[session-id dir]`, so two sessions in the same directory get
two independent REPLs and neither can see or stop the other's. A managed REPL
lives and dies with THIS vis process — there is NO persistent registry and NO
PID re-attach across a vis restart. Restarting vis means a fresh REPL, exactly
like the Python pack.

PORT: we PICK a free ephemeral port ourselves and pass it to the launcher
EXPLICITLY (`nrepl.cmdline --port N`, `lein repl :headless :port N`,
`bb nrepl-server N`), so we always KNOW our port without ever reading a
`.nrepl-port` file back. Any stray `.nrepl-port` a tool drops in the project is
deleted after boot — vis never depends on it and never leaves it behind.

ALIASES: a REPL is ALWAYS booted with the project's `:dev :test` deps + paths
on its classpath (full dependency spec), with the user's `:main-opts` dropped
(our synthetic `:vis/nrepl-launch` alias appends last so `-m nrepl.cmdline`
wins). Unknown `:dev`/`:test` aliases are silently ignored by tools.deps, so
this is safe in any project.

Starting/stopping is CORE and ALWAYS allowed — never gated behind a flag.
raw docstring

ensure-repl-for-dir!clj

(ensure-repl-for-dir! session-id dir)

Return the live REPL info for [session-id dir], AUTOSTARTING one (with the default :dev :test aliases) when the session owns none for dir. Returns nil only when there is no launchable Clojure build file in dir. Used by eval / test to guarantee a REPL is up for the target dir.

Return the live REPL info for `[session-id dir]`, AUTOSTARTING one (with the
default :dev :test aliases) when the session owns none for `dir`. Returns nil
only when there is no launchable Clojure build file in `dir`. Used by eval /
test to guarantee a REPL is up for the target dir.
sourceraw docstring

id-ofclj

(id-of dir)

Stable session-resource id for the REPL rooted at dir.

Stable session-resource id for the REPL rooted at `dir`.
sourceraw docstring

launcher-forclj

(launcher-for dir aliases port)

Subprocess command to boot a project nREPL in dir on the EXPLICIT port, honouring aliases (deps.edn aliases / lein profiles). Returns {:tool kw :cmd [strings]} or nil when no known Clojure build file is present.

Subprocess command to boot a project nREPL in `dir` on the EXPLICIT `port`,
honouring `aliases` (deps.edn aliases / lein profiles). Returns
`{:tool kw :cmd [strings]}` or nil when no known Clojure build file is present.
sourceraw docstring

nrepl-versionclj

source

repl-by-idclj

(repl-by-id session-id id)

The session's live REPL info matching resource id, or nil.

The session's live REPL info matching resource `id`, or nil.
sourceraw docstring

resolve-target!clj

(resolve-target! session-id id default-dir)

Resolve — and AUTOSTART when needed — the REPL an eval should hit for session-id. id is an optional explicit resource id; default-dir is where we autostart when the session owns no REPL yet. Returns {:id :dir :port}.

Rules (the ownership contract):

  • explicit id → that REPL (throws if no such live REPL in this session);
  • 0 REPLs → autostart default-dir with [:dev :test], use it;
  • 1 REPL → use it (it's the implicit default);
  • 1 REPLs → throw, listing the ids (the model MUST pass one).

Resolve — and AUTOSTART when needed — the REPL an eval should hit for
`session-id`. `id` is an optional explicit resource id; `default-dir` is where
we autostart when the session owns no REPL yet. Returns `{:id :dir :port}`.

Rules (the ownership contract):
  - explicit `id` → that REPL (throws if no such live REPL in this session);
  - 0 REPLs       → autostart `default-dir` with [:dev :test], use it;
  - 1 REPL        → use it (it's the implicit default);
  - >1 REPLs      → throw, listing the ids (the model MUST pass one).
sourceraw docstring

restart-for-dir!clj

(restart-for-dir! session-id dir)

Recover THIS session's REPL for dir when its recorded process is dead OR alive-but-UNREACHABLE (a boot that never bound its port, or a wedged server thread) — the failure proc-alive? alone cannot see. Gives a still-present process a brief grace window to finish booting before killing it, so a slow cold-deps start is not needlessly restarted; otherwise stops the stale process and autostarts a fresh one. Returns the live REPL info, or nil when dir has no launchable Clojure build file.

Recover THIS session's REPL for `dir` when its recorded process is dead OR
alive-but-UNREACHABLE (a boot that never bound its port, or a wedged server
thread) — the failure `proc-alive?` alone cannot see. Gives a still-present
process a brief grace window to finish booting before killing it, so a slow
cold-deps start is not needlessly restarted; otherwise stops the stale
process and autostarts a fresh one. Returns the live REPL info, or nil when
`dir` has no launchable Clojure build file.
sourceraw docstring

session-replsclj

(session-repls session-id)

Live REPLs OWNED by session-id, as a vec of {:id :dir :port :tool :aliases :pid} sorted by dir. Prunes dead entries as a side effect. This is the SINGLE source of truth for ctx + eval/test targeting — there is no external-port discovery.

Live REPLs OWNED by `session-id`, as a vec of
`{:id :dir :port :tool :aliases :pid}` sorted by dir. Prunes dead entries as a
side effect. This is the SINGLE source of truth for ctx + eval/test targeting —
there is no external-port discovery.
sourceraw docstring

start!clj

(start! session-id dir)
(start! session-id dir {:keys [aliases]})

Self-start a project nREPL subprocess OWNED by session-id in dir. Always allowed — never flag-gated. Default :aliases are [:dev :test] (merged with any explicitly passed). We pick a FREE port, pass it to the launcher, drop any stray .nrepl-port, and wait briefly for OUR port to come up.

  • Already ours + alive for [session-id dir] → :already-running.
  • No known build file → :no-launcher.
  • Else :started (port up) or :starting (still coming up; ctx will show it).

Model-facing: STRING keys + STRING enum values (crosses as a tool :result).

Self-start a project nREPL subprocess OWNED by `session-id` in `dir`.
Always allowed — never flag-gated. Default `:aliases` are [:dev :test] (merged
with any explicitly passed). We pick a FREE port, pass it to the launcher, drop
any stray `.nrepl-port`, and wait briefly for OUR port to come up.

- Already ours + alive for `[session-id dir]` → :already-running.
- No known build file → :no-launcher.
- Else :started (port up) or :starting (still coming up; ctx will show it).

Model-facing: STRING keys + STRING enum values (crosses as a tool `:result`).
sourceraw docstring

statusclj

(status session-id dir)

Live view of THIS session's managed REPL for dir. Always safe. Model-facing: STRING keys + STRING enum values (crosses as a tool :result).

Live view of THIS session's managed REPL for `dir`. Always safe. Model-facing:
STRING keys + STRING enum values (crosses as a tool `:result`).
sourceraw docstring

stop!clj

(stop! session-id dir)

Stop THIS session's managed nREPL for dir (graceful, then forced). Clears the in-memory cache. No-op-safe. Model-facing STRING-keyed result.

Stop THIS session's managed nREPL for `dir` (graceful, then forced). Clears the
in-memory cache. No-op-safe. Model-facing STRING-keyed result.
sourceraw docstring

tail-logclj

(tail-log log-path)
(tail-log log-path n)

Tail a managed nREPL launcher log as line strings. Returns [] when the log does not exist yet or cannot be read; resource viewers treat that as an empty but still log-capable resource.

Tail a managed nREPL launcher log as line strings. Returns [] when the log
does not exist yet or cannot be read; resource viewers treat that as an empty
but still log-capable resource.
sourceraw docstring

cljdoc builds & hosts documentation for Clojure/Script libraries

Keyboard shortcuts
Ctrl+kJump to recent docs
Move to previous article
Move to next article
Ctrl+/Jump to the search field
× close