/lsfusion-ai-skills:lsfusion-evalfrom lsfusion-ai-skills
Run lsFusion code against a running server (local dev or deployed production) and inspect what code is actually loaded there. Use when the user wants to: evaluate an lsFusion expression or run a script via HTTP (/exec, /eval, /eval/action), call a project action by name remotely, check that a class / property / form / module exists in the running config, count or sample data through the lsFusion layer instead of PostgreSQL directly, or read / grep the `.lsf` sources deployed on a remote host (the `/files/*` API on the web port). Use it when the task is "ask the server" rather than "edit code locally": the canonical way to verify server state before changing things, debug what's actually running, and answer "is the schema in sync with my source?". Triggers on "call action via HTTP", "/eval", "eval/action", "run lsfusion script remotely", "check what's on the server", "what logic is running on the server", "look at .lsf on the server", "count via API", "API check", "verify class/property on the server".
Ships in lsfusion-ai-skills. Installing the plugin adds it to Claude Code.
What the skill costs in Claude's context, stage by stage
Name and description: Claude knows it exists.
SKILL.md joins the conversation and stays.
Read when SKILL.md points to them.
Companion MCP server —
lsfusion-ai(ai.lsfusion.org, registered by thelsfusion-ai-skillsplugin). Callmcp__lsfusion-ai__lsfusion_get_guidancefirst in any lsFusion task (if its rules aren't already in context) and follow every rule it returns — the element order, the coding rules, and thelsfusion_report_feedbackconsent policy all live there. Confirm syntax withmcp__lsfusion-ai__lsfusion_retrieve_docsinstead of guessing. If these tools are missing, the server isn't installed — see the ai-skills README to add it.
This skill covers two complementary ways to inspect a running lsFusion install — local dev or production — without touching PostgreSQL directly:
.lsf files
actually loaded by the server are served back over the /files/list /
/files/read / /files/search endpoints on the web port. The answer
comes from what the JVM has on its classpath right now, not from
anything on disk.Together these answer the question "what is actually running on this server right now?" — which you must answer truthfully before you change anything. If your local sources differ from what's deployed, every assumption you make from reading local code is wrong.
The mistake that brings agents here: writing a
TestData.lsf/SeedData.lsf/Migration001.lsf/FixCustomer.lsfmodule to call once, adding it to top-REQUIRE, and restarting the server — when the entire job was a short script the eval endpoint runs in sub-second without touching the codebase. Reach for this skill the moment a task is runtime data manipulation, not schema. The lsfusion-dev skill cross-references this distinction; honour it.
| You want to … | Use |
|---|---|
| Seed test data on a dev install | This skill — POST a mutation script to /eval/action |
| One-shot fix on production data (with user approval) | This skill — same path; never silently |
| Clean up all rows of a class | This skill — POST a delete-and-apply script to /eval/action |
| Evaluate an lsFusion expression / call an action on a running server | This skill — HTTP Action API |
| Confirm a class / property / form exists in the running schema | This skill — RETURN OVERRIDE (GROUP SUM 1 IF Class c IS Class), 0; over /eval/action: 200 + count = exists, 500 "not found" = it doesn't |
| Count / sample data | This skill — RETURN <expr>; (or RETURN JSON FROM ... for tabular data) |
See the .lsf source actually loaded on a remote host | This skill — /files/list, /files/read, /files/search on the web port |
| Inspect physical DB tables / columns / indexes, or read data through SQL | Direct psql — but this is a last resort; first ask the user, per the rule in the lsfusion-dev skill. lsFusion mangles names; raw SQL almost always misleads. |
| Check which database the server is connected to, or whether a database / table exists | Read-only catalog queries (pg_stat_activity, pg_database, information_schema.tables) — metadata, not data, so no need to ask first (lsfusion-dev skill, the direct-SQL rule) |
Edit .lsf source | The lsfusion-dev skill + IDE MCP tools |
| Deploy a new jar | The lsfusion-deploy skill |
The fixed verification order (rationale in the lsfusion-dev skill,
step 5) is the same locally and remotely — never UI first: server log
(tail /var/log/lsfusion6-server/stdout.log over SSH, or lsfdev.ps1 log)
→ API (this skill's /eval/action and /files/*) → UI (lsfusion-dev
verify — the local install by default, any reachable host with -Url;
Part 3 for its prerequisites, limits and the script fallback). Direct psql against
the data is only for what neither log nor API can answer (DBA recovery,
physical-layout debugging) — and only after asking the user; read-only
connection / catalog metadata is the exception.
The lsFusion application server exposes the Action API on port 7651
(direct). On a deployed host fronted by the web client (Tomcat), the same
API is also reachable through the web port — 8080 (HTTP) or via HTTPS on
the host's external port (typically 443). Pick whichever is reachable
from where you're running curl:
| Path | What it does | Key parameter |
|---|---|---|
/exec?action=<name> | Run a named action declared in the project | action= |
/eval?script=<code> | Run an lsFusion script that defines an action run and executes it | script= |
/eval/action?script=<code> | Run an action-body snippet directly (no surrounding run() { ... } wrapper needed) | script= |
Most introspection ("does this class exist", "count rows", "send a value
back") fits /eval/action — you write one line of action code that sends
the answer back in the response body, the server runs it, you read the
value (the status code alone only proves the script compiled). The
value-returning statement is always RETURN: RETURN <expr>; for a
scalar, RETURN JSON FROM ...; for tabular / structured data — both are
detailed in "Getting values back" below.
Access control — enableAPI is the master gate; @@api/@@noauth are
per-action overrides. The enableAPI working parameter (default 0;
2 under devmode) decides who may reach the Action
API at all:
2 — anonymous allowed (dev / sandbox only; never production)1 — any authenticated user may call any action0 (the default) — allowed only for: @@noauth actions, authenticated
requests to @@api actions, and authenticated users who have access to the
System.interpreter navigator formA named project action opts into the API with an annotation on its declaration:
@@api — callable when authenticated, even at enableAPI=0@@noauth — callable without authentication, bypassing enableAPI entirely/eval and /eval/action are built-in endpoints, not @@api actions —
@@api marks a named action and does not apply to these endpoints, so it
never opens them. Because they execute arbitrary lsFusion code, at
enableAPI=0 they require the caller to have access to the
System.interpreter form (the same gate as running code in the UI), and at
enableAPI=1 every authenticated user can run arbitrary code through
them — which is exactly why production should keep enableAPI=0 and expose
specific @@api actions instead (see "Production security" below). The
endpoints also need the platform's EVAL support loaded; the skill family's
default top-module REQUIRE list includes Eval, and a /eval/action 404
usually means the running project doesn't REQUIRE Eval.
Two methods, per the platform docs:
Authorization: Basic <base64(user:pass)> (curl: -u user:pass)Authorization: Bearer <token>, where the token comes from Authentication.getAuthToken[]The default account on a fresh install is admin with empty password.
But — and this is the trap — devmode changes the rules in a way that's easy
to get wrong:
| Server state | What to send | Why |
|---|---|---|
Devmode ON (local dev install, -Dlsfusion.server.devmode=true) | curl without -u — no Authorization header at all | Server auto-authenticates as admin only when it sees no header. |
| Devmode OFF (production, deployed via lsfusion-deploy) | curl -u admin: (empty password) | API requires auth; admin: sends Basic with empty password, server validates and accepts. admin reaches /eval/action even at the default enableAPI=0 because it has System.interpreter access — a non-admin user would be refused there (see access control above). |
| Admin password rotated | curl -u admin:<real password> | Self-explanatory |
The trap: "no header" ≠ "header with empty password". curl without
-u sends nothing; curl -u admin: sends Basic Auth with empty password.
Devmode-auto-auth fires only when the server sees no header; with a
header present the server runs a real credential check on what you sent.
-u admin:<wrong-guess> therefore returns HTTP 401 even in devmode —
don't try -u admin:fusion or -u admin:admin "just in case". An
empty-password Basic (-u admin:) is accepted (verified 200 on
7.0-SNAPSHOT; the empty password matches the default admin account) —
but make the no-header form your default for devmode, and fall back to a
real password only if the user supplies one.
enableAPI to reach /eval/action/eval/action runs arbitrary lsFusion code. The platform's hardening
default is enableAPI=0, under which the endpoint is reachable
only by System.interpreter-privileged users (e.g. admin) — that is the
state you want in production. If a non-admin's /eval/action call is being
refused, the fix is not to set enableAPI=1: that flips on arbitrary
code execution over HTTP for every authenticated user, bypassing the
System.interpreter form gate that limits the interpreter in the UI. Instead
wrap the specific operation in a named action annotated @@api (callable at
enableAPI=0) and have it validate currentUser() itself. Use enableAPI=2
(anonymous) only on a throwaway dev/sandbox box, never production. If a role
genuinely needs broad API access, grant it per-role via
Administration → System → Settings → Parameters, not globally. (This
mirrors the platform docs — Working parameters enableAPI,
Access from an external system, and MCP server setup.)
Use POST with Content-Type: application/x-www-form-urlencoded; charset=UTF-8
and pass the script through --data-urlencode script=.... Keep the charset
suffix as cheap hygiene — but know where non-ASCII actually gets
corrupted, because it is not the HTTP transport: with the server JVM on
a UTF-8 default encoding (lsfusion-dev always passes
-Dfile.encoding=UTF-8; the lsfusion-deploy skill's locale preflight
ensures it on servers), Cyrillic survives POST bodies and query strings
alike — verified byte-for-byte on 7.0-SNAPSHOT,
on the app-server port and the web port. The corruptions that do happen are
client-side, on Windows:
?. Pass non-ASCII scripts from a file
(--data-urlencode "script@C:/path/file.lsf") or send from PowerShell —
never inline.curl -o resp.json, then read the file as UTF-8. (Exactly this artifact has
produced false "the server mangles Cyrillic" reports before.)If a server was installed with a non-UTF-8 locale (legacy hosts), fix the JVM encoding per the lsfusion-deploy skill's locale section instead of fighting transports.
# Local dev (devmode), inline script — response body is "hello"
curl -sS -X POST \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
--data-urlencode "script=RETURN 'hello';" \
http://localhost:7651/eval/action
# Production (devmode off), inline script, on HTTPS via web port
curl -sS -u 'admin:' -X POST \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
--data-urlencode "script=RETURN 'hello';" \
https://<host>/eval/action
# Long script from a file (avoid quoting hell).
# IMPORTANT: on Windows the bundled curl.exe is a Windows-native binary —
# it does NOT understand Git Bash's /tmp prefix. `script@/tmp/probe.lsf` will
# either silently produce an empty `script=` param (server then returns
# HTTP 500 "Eval script was not found"), or pick up an unrelated file at
# C:\tmp\probe.lsf. Always pass a path that the actual curl process can
# resolve — either an absolute Windows path with forward slashes, or
# run curl from the same Bash environment that owns the temp file.
curl -sS -u 'admin:' -X POST \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
--data-urlencode "script@C:/Users/me/probe.lsf" \
https://<host>/eval/action
Always pass -w '\nHTTP %{http_code}\n' in introspection calls — the response
body is often empty (see "Reading the response" below), so the status code is
your real signal.
Client timeout ≠ server failure. /eval/action does not cancel the
action when the HTTP client goes away: if the client gives up waiting on a
long-running script (curl --max-time, PowerShell -TimeoutSec, a proxy
limit), the server keeps executing it and may still APPLY. Treat a
client-side timeout as outcome unknown — check the server log and re-read
the data with a read-only call before doing anything else; re-running the
mutation script on reflex can apply it twice. For genuinely long actions
raise the client timeout instead (locally, lsfdev.ps1 api -Timeout <s>).
The script=... body is lsFusion source. Everything that this skill
documents is the HTTP wrapper — endpoints, auth, content-type, response
codes, file-API parameters. The contents of script= is real lsFusion
code, with all the language's syntax rules and semantic constraints. Run
lsfusion_get_guidance (once per session) and lsfusion_retrieve_docs
before writing or modifying any non-trivial script. Do not guess
syntax from English intuition — string literals use single quotes (not
double), aggregation has restrictions on how operators can be combined,
etc., and every such fact is in the language reference. This skill
deliberately does not duplicate those rules; reaching for retrieve_docs
is part of the workflow.
| Status | Meaning |
|---|---|
HTTP 200, empty body | Script compiled, name-resolved against the running schema, and ran — nothing more. A MESSAGE produces exactly this (its text is swallowed — see the gotchas), and so does a mutation whose APPLY was silently canceled by a constraint. An empty 200 is never data-level proof; write scripts that RETURN something. |
HTTP 200, body present | Script ended in RETURN <expr>; (a scalar, or RETURN JSON FROM ... for structured data) — the value is the body. See "Getting values back" below. |
HTTP 401 | Auth issue — see the trap table above. Usually means you sent the wrong -u form, NOT that the password is wrong. |
HTTP 500, body with [error]: | The script failed one of the compile phases (see "Syntax-checking" below for the exact order). Three error shapes, in the order the server checks them: a parse error (no viable alternative, extraneous input, missing X, mismatched input) = bad syntax; X cannot be used in EVAL module = a forbidden construct whose syntax is fine (this check preempts name resolution — see below); ... is not found = an unknown class/property/action (the deployed config differs from yours, or a missing REQUIRE), reported only for scripts free of forbidden constructs. Genuine type mismatches (... types don't match, should have integral class) surface only when the value is realized — note INTEGER+STRING is not one (it coerces). Parse errors come batched (every statement's, in one response); name errors surface one per call — the body then ends with Only the first error is reported: set 'batchScriptErrors' (or run with 'dryRun') to report several errors at once. (a server started with settings.batchScriptErrors=true batches them instead and drops that trailer). |
HTTP 404 | Endpoint not in this build (no Eval module REQUIREd, or wrong path). |
The canonical "is this name in the running schema?" check against
/eval/action is
RETURN OVERRIDE (GROUP SUM 1 IF MyClass o IS MyClass), 0;
— a 500 "not found" answers no, a 200
with the count in the body answers yes (and tells you how many). Don't use
MESSAGE for this: it yields the same empty 200 as half a dozen failure
modes.
.lsf without a restartA .lsf edit normally needs a server restart (30–60 s) to find out whether
it even parses. eval is a sub-second first-pass linter for the whole
.lsf surface — not just expressions — because the eval string is compiled
as a throwaway module that depends on every loaded module. The server runs
the compile phases in a fixed order, and the error you get back tells you
exactly which phase failed (verified live on 7.0-SNAPSHOT):
| Phase (in order) | Catches | Error shape in the body |
|---|---|---|
| 1. Parse (grammar) | malformed syntax in anything, including forbidden constructs — the whole file, errors batched (except past a CLASS / TABLE: those abort the first pass, see phase 2) | no viable alternative / extraneous input / missing X / mismatched input / required (...)+ loop |
| 2. EVAL restriction | a construct eval can't load (see below). Thrown, so the compile stops there. CLASS / TABLE are refused in the first pass — before name resolution of anything, and nothing after them is even parsed (measured: a name error on line 1 goes unreported when a CLASS sits on line 2; a parse error on line 2 goes unreported when a CLASS sits on line 1). Every other refused construct is caught in the main pass, statement by statement — names in earlier statements are already resolved (a name error on line 1 IS reported with a WHEN on line 3), nothing after it is | <X> statement / option cannot be used in EVAL module, ... is forbidden in EVAL module |
| 3. Name resolution | unknown class / property / action, missing REQUIRE — incl. names used inside FORM and event conditions. Reached only when phase 2 found nothing | property or action '<name>' is not found |
| 4. Type realization | genuine type mismatches — but only when the value is actually used (lazy on unused declarations; INTEGER+STRING coerces, not an error) | ... types don't match / should have integral class |
You can throw any declaration at eval and read the result by three outcomes:
... is not found → a referenced element doesn't exist (typo, or a
REQUIRE you haven't added). Only reported for scripts with no
load-only constructs (see the previous row).... cannot be used in EVAL module / ... is forbidden in EVAL module → eval refuses the construct and stops there; the construct
itself is fine syntactically. How much else was proven depends on the
construct: after a CLASS / TABLE (first pass) only the lines before
it are syntax-checked and no names are; after any other refused
construct (main pass) the whole file parsed clean and names were
checked in the statements before it. Never a names-PASS for the
whole script.So a typo in CLASS, persistent DATA (NONULL / MATERIALIZED /
INDEXED), WHEN, CONSTRAINT etc. still yields a parse error, and a
clean one yields "cannot be used". Plain calc properties, session DATA,
and whole FORM declarations are loadable, so a script containing only
those gets checked all the way through names (a FORM even name-resolves
the properties in its PROPERTIES block). To get name coverage for a
mixed edit, send the loadable statements separately from the load-only
ones.
# wrap the edit as eval statements (statements mode needs a run action).
# 200 => parses + names resolve; 500 => read the phase from the error shape.
curl -sS -X POST -H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
--data-urlencode "script=
profit (Order o) = revenue(o) - cost(o); // your new property
run() { }
" http://localhost:7651/eval
# devmode: no -u.
The endpoint matters: this must hit /eval (statements mode). The
/eval/action endpoint — what lsfdev.ps1 api calls — wraps the body as
an action, so any declaration fails with misleading wrapped-brace
parse errors (missing '}' at 'CLASS', no viable alternative at input '=' at shifted columns) regardless of whether the code is fine. For a
local lsfdev project don't hand-roll the curl at all: lsfdev.ps1 precheck -Files 'src\main\lsfusion\My.lsf' does exactly this per file —
strips the MODULE/REQUIRE/NAMESPACE headers (a full module posted
verbatim dies with missing EOF at 'MODULE') while preserving line
numbers and keeping PRIORITY (eval's own wrapper header precedes
the text, so the file's priority list applies as in the module; the
module's own namespace goes first in that list when the server has it
loaded, so its precedence applies too — NAMESPACE itself is stripped),
appends the run() {}, and labels each verdict by what was
actually proven: [OK] (compiled, names proven), [FAIL] (a real
error), [SKIP] + [NEEDS DRYRUN] (eval cannot check it — a limitation
of the check, not an error), [WARN] + [NEEDS DRYRUN] (an ambiguous
name: eval resolves against every loaded module, the module only against
its REQUIRE closure — the full load decides). A file that declares its
own run() is a [SKIP] instead of linted — /eval executes run(),
and a linter must not run project actions. Only real [FAIL]s exit 1 (3
= no verdict, endpoint unusable); a run of nothing but [SKIP]s /
[WARN]s exits 0 with a [NEEDS DRYRUN] summary.
Limits — eval is a linter, not the loader: it does not validate the
load-time semantics specific to forbidden constructs (constraint logic,
whether MATERIALIZED is legal on that property shape, aggregation
well-formedness beyond grammar), and it cannot judge REQUIRE
completeness — the throwaway module depends on every loaded module,
so names resolve even when the real module's REQUIRE list would not
reach them (that failure surfaces only at a full load — the restart, or
locally the dryrun described below) — and the posted file's own
declarations live in a private namespace, so an overload set spanning
several modules of one shared namespace (the file overloading a name
another module of its namespace declares with a different signature) is
not reproduced either; a ... is not found on such a call is for the full
load to judge. Parse errors come
batched, but name errors surface one per call (fix and re-run — unless
the server runs with settings.batchScriptErrors=true), a refused
construct stops name checking from that statement on (see the phase
table), and
several real-module constructs crash eval's compiler outright instead
of producing the polite restriction error — measured on 7.0-SNAPSHOT:
EXTEND FORM, EXTEND CLASS and DESIGN / NAVIGATOR edits of existing
elements (RuntimeException NF COLLECTION RESTARTED), + { } / +=
implementations of an existing ABSTRACT (ClassCastException ... NFList
/ NullPointerException); a + { } on a non-abstract target is a
genuine ... is not found, in eval and at a full load alike. A file
containing a crashing construct can't be linted past it — only a
full load checks it: the restart, or locally the scoped dryrun (below;
precheck reports such files as
[SKIP] + [NEEDS DRYRUN] rather than failing them). The limit case is a file that is
entirely META definitions / @-instantiations / EXTEND FORM (a
typical extension/main module): eval coverage there is zero — META
bodies compile only at instantiation — and precheck classifies such
files upfront as [SKIP] + [NEEDS DRYRUN], checking just the structure (MODULE
header, META/END balance, brackets); neither an ambiguity nor a
constraint error in them can surface before a full load — locally that
is a seconds-cheap scoped dryrun, on a remote server the restart
cycle — so don't re-lint them. For a whole new module in one
pass on a remote server, temporarily strip the load-only options
(NONULL/MATERIALIZED/INDEXED) so the DATA/calc/form surface
checks cleanly, and probe each CLASS/WHEN/CONSTRAINT separately —
on a local lsfdev box skip that contortion and run the scoped dryrun
(next paragraph), which checks the module exactly as written.
Actually loading the schema still requires the restart — this just
catches the typos first, cheaply. (For comparison, measured on
7.0-SNAPSHOT: ~30 ms per precheck call vs a 26–41 s failed-restart cycle
that reports a single name error.)
Full-fidelity alternative on a local dev box: lsfdev.ps1 dryrun
(lsfusion-dev skill). It launches
the server JVM with -Dsettings.dryRun=true, which loads and checks the
whole project exactly as a restart would — real REQUIRE graph
(missing-REQUIRE caught), EXTEND FORM, META instantiation, the entire
restart-only class — then exits before the DB sync: no ports bound, the
running server untouched, no PostgreSQL at all, ~9 s of JVM on a
772-module project (-TopModule narrows the scope further;
comma-separated list allowed).
It needs the sources and the platform jar
locally, so for a remote server eval stays the only lint. On a local
box split the roles by what eval can actually reach: eval/precheck
per-edit where names get checked — files of plain calc properties,
actions, FORMs with no load-only construct anywhere in them
(milliseconds; one CLASS in the file blinds names for all of it); for
new-module code full of load-only
constructs, where eval is a syntax check at best, the scoped
dryrun -TopModule <Mod> IS the per-edit loop (~4 s per run, every
parse and semantic error batched — unlike a restart), with an
unscoped dryrun as the pre-restart gate — a scoped run skips the
edited modules' dependents, and under a configured logics.topModule
(the standard layout) the restart itself loads only that module's
REQUIRE closure, so wire new modules in before that gate.
MESSAGE is useless over the Action API: its text is swallowed entirely —
not in the response body, and (for a plain MESSAGE) not even in the server
log; only MESSAGE ... NOWAIT leaves a Server message: line in the log.
Without NOWAIT the text is visible nowhere at all — no log-tailing
trick (including lsfdev.ps1 api's own Server message: capture) can
recover it. Don't put MESSAGE in API scripts at all. And that
Server message: line is a no-client-context behavior, not a property
of NOWAIT: an action triggered from a live UI (a form button, a
custom-view controller callback) delivers MESSAGE, NOWAIT included, to
the client's browser and writes nothing to the server log — log-tailing
cannot trace UI-triggered actions either. Instrument those by writing into
a DATA property inside NEWSESSION { ... APPLY; } and reading it back
with RETURN (recipe and its caveats — NULL-safe formatting,
namespace-qualified readback, no isolation inside apply events — in the
lsfusion-dev skill, verification step 2).
Two ways to actually read a value:
1. RETURN <expr>; — the action's return value becomes the response
body. Simplest path for a scalar (a count, a name, a
flag). Works on both endpoints: as the last statement of an /eval/action
body, or inside run() for /eval.
# count via /eval/action — response body is the number, e.g. "6"
# (localhost devmode → NO -u; on production add -u 'admin:' per the auth table)
curl -sS -X POST \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
--data-urlencode "script=RETURN (GROUP SUM 1 IF Item i IS Item);" \
http://localhost:7651/eval/action
# same through /eval — RETURN inside the run action
curl -sS -X POST \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
--data-urlencode "script=run() { RETURN (GROUP SUM 1 IF Item i IS Item); }" \
http://localhost:7651/eval
One NULL annihilates a concatenated RETURN — build multi-value probes
as JSON FROM columns instead. String + propagates NULL, so a probe like
RETURN 'items=' + STRING(cntItems()) + ' orders=' + STRING(cntOrders());
returns an empty body the moment any single operand is NULL —
indistinguishable from the other no-proof empty 200s, and the
"empty body → use RETURN" hint won't rescue you because a
RETURN was there (measured: one NULL among a dozen concatenated
counters blanked the whole probe). Give each value its own column of a
RETURN JSON FROM — a NULL column just drops out of the JSON while the
rest survive (verified live: RETURN JSON FROM a = 1, b = (1 IF 1>2), c = 'ok';
→ {"a": 1, "c": "ok"}; the missing-key rule below tells you how to read
that — and if every column is NULL, the whole JSON is NULL and the body
is empty again). If you do concatenate into one RETURN, wrap every
operand in OVERRIDE ..., 0 / OVERRIDE ..., '' — as the two-counter
recipe under Common recipes does; one bare operand is enough to blank the
body.
2. RETURN JSON FROM ... — tabular / structured data. The JSON
operator builds a JSON value from a list of properties (or
JSON(formName OBJECTS ...) from a form), and RETURN sends it back as the
body with Content-Type: application/json.
# (localhost devmode → NO -u; on production add -u 'admin:')
curl -sS -X POST \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
--data-urlencode "script=
RETURN JSON FROM idItem = id(Item i), nameItem = name(i) WHERE i IS Item;
" \
http://localhost:7651/eval/action
# a single object when no column has a parameter:
# RETURN JSON FROM res = 'hello'; → {"res": "hello"}
Two properties of a JSON value to keep in mind (verified on 7.0):
{"pop": 1, "name": "Brest"} for columns declared name, pop). Parse it,
don't compare it as text.[]; an empty nested object group is dropped with its
key. When "no rows" must come back as [], override it:
RETURN OVERRIDE (JSON FROM ... WHERE ...), JSON('[]');.Other formats (CSV, XML, XLSX, ...) — EXPORT ... TO a local file, then
RETURN it:
LOCAL f = FILE ();
EXPORT CSV ';' HEADER FROM n = name(Item i) ORDER name(i) TO f;
RETURN f();
The response then carries the file with the content type of its extension
(text/csv here) — the same body a bare EXPORT gives. Likewise,
EXPORT JSON FROM ... TO f; RETURN f(); returns JSON byte for byte as exported
(key order kept, [] for no rows). The two paths differ on strings, though:
EXPORT JSON writes a string value that starts and ends with a square or
curly bracket as nested JSON if the value parses as JSON ('[a, b]' →
["a","b"]), while JSON FROM keeps it a string
("[a, b]"), so a value read through RETURN JSON FROM can differ from what
the application's own EXPORT JSON sends.
A missing JSON key means NULL, not a failed export. JSON FROM (like
EXPORT JSON) simply omits a key whose value is NULL for that object:
with RETURN JSON FROM a = f(X x), b = g(x), an object where g is NULL
comes back as {"a": ...} — no "b" at all. Don't read absent keys as "the
calculation didn't run" — the row is there, the value is just NULL (not yet
computed, or genuinely empty). To keep the key present regardless, make the
value non-NULL explicitly: b = OVERRIDE g(x), 0 (or '').
Don't answer with a bare EXPORT (no TO). It writes the
session-local exportFile(), which reaches the body only by accident: only
when the action has no RETURN with a value anywhere in its body — not
even on a branch that never runs — and only if nothing drops it first: a
surrounding NEWSESSION throws it away on exit, and a later APPLY
resets it, both giving an empty body with HTTP 200 (verified on 7.0).
And each bare EXPORT overwrites that same property, so a diagnostics
script with five of them returns only the fifth — it looks as if the
earlier queries matched nothing (EXPORT FROM a = 1; EXPORT FROM b = 2; →
{"b":2}). With RETURN the first one executed ends the script, so put
several values into one RETURN JSON FROM a = ..., b = ..., and several
row sets into one as nested columns:
RETURN JSON FROM items = (JSON FROM n = name(Item i)), orders = (JSON FROM n = number(Order o));
(a nested JSON with no rows is dropped with its key).
RETURN has none of these traps — its value survives NEWSESSION and
APPLY (NEWSESSION { ... RETURN x; } does return x, verified on 7.0).
One-shot eval scripts don't need NEWSESSION at all anyway — every
/eval//eval/action call already runs in its own fresh session.
For one-off introspection (just confirming a class exists), RETURN is also
the shortest form — the same one-liner as a compile-probe, but the count
comes back in the body instead of an ambiguous empty 200.
Each answers in the response body (verified live on 7.0-SNAPSHOT).
// Does class X exist, and how many objects? 200 + count = yes; 500 "not found" = no.
RETURN OVERRIDE (GROUP SUM 1 IF X x IS X), 0;
// Does property p(Class) exist, and on how many objects is it set?
RETURN STRING((OVERRIDE (GROUP SUM 1 IF p(Class c)), 0)) + ' / ' +
STRING((OVERRIDE (GROUP SUM 1 IF c IS Class), 0));
// First 5 names from class X (sample). ORDER by the PROPERTY, not the alias:
// ORDER nm compiles but fails at runtime with a misleading
// "Set operations is invalid" 500. No rows -> empty body (an empty JSON is NULL).
RETURN JSON FROM nm = name(X x) ORDER name(x) TOP 5;
// Module loaded? Reference an element only that module defines — a class
// works best: 200 = loaded, 500 "not found" = not in the running config.
RETURN OVERRIDE (GROUP SUM 1 IF Task t IS Task), 0; // probes the Task module
(For the Eval module specifically no probe is needed — a working
/eval/action call is the proof: the endpoint exists only when the running
config REQUIREs Eval.)
Wrapping counts in STRING(...) when concatenating with text is good style,
but it is not required to avoid an error: + between INTEGER and STRING
coerces (verified — 'count=' + 5 → count=5, 5 + ' items' → 5 items,
in either order), it does not throw. When a comma-bearing OVERRIDE sits
inside an argument list, give it its own parentheses
(STRING((OVERRIDE ..., 0))), or the comma is parsed as an argument
separator.
The script= body can carry any number of statements. Two POSTs
sequenced in a shell pipeline are equally fine — either approach lets
you "clear then refill" or "mutate then count" in one round of API
work:
curl -sS -X POST \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
--data-urlencode "script@/path/to/clean.lsf" \
http://localhost:7651/eval/action
# inspect HTTP code, continue
curl -sS -X POST \
-H 'Content-Type: application/x-www-form-urlencoded; charset=UTF-8' \
--data-urlencode "script@/path/to/seed.lsf" \
http://localhost:7651/eval/action
HTTP 200 is not proof the mutation landed. The server returns 200
when the script compiled and ran — but a failed APPLY (constraint
violation, missing required field, etc.) cancels silently and returns the
same 200 with an empty body. Make every mutation script self-checking; no
NEWSESSION wrapper is needed (an eval call already runs in its own
session):
// ... NEW / assignments ...
APPLY;
IF canceled() THEN RETURN 'CANCELED: ' + (OVERRIDE applyMessage(), 'no message');
RETURN 'OK: ' + STRING((OVERRIDE (GROUP SUM 1 IF ...), 0)); // count proves it landed
applyMessage() carries the human-readable constraint text — but it can be
NULL, and 'CANCELED: ' + NULL is NULL (an empty response that looks
like success), so always wrap it in OVERRIDE. Alternatively verify with a
separate count call or a verify screenshot of the list form (Part 3).
Don't trust the transport-level 200 as data-level confirmation.
Asserting a computed value on the object you just created. You can't read
the NEW alias after APPLY — it's scoped to its block (ACTION §2), and a
plain LOCAL is reset by APPLY (CHANGE §5); a class-wide aggregate mixes in
other rows on a real DB. Two ways to read the specific object (verified on 7.0):
// 1. Re-find by a unique business key after APPLY (simplest, when it has one):
APPLY;
RETURN (GROUP MAX calcProp(Cls o) IF keyProp(o) = <key>);
// 2. Carry the object through APPLY in a nested LOCAL:
LOCAL created = Cls ();
NEW o = Cls { ... ; created() <- o; } // capture while o is in scope
APPLY NESTED (created); // preserve the LOCAL across APPLY
RETURN calcProp(created());
Leave no trace in the codebase. A one-shot seed / cleanup / fix
should not change the project tree. The .lsf script you posted lives
under .lsfusion-dev/ or /tmp/, not under src/main/lsfusion/. If
you find yourself adding a new module to top-REQUIRE to call it once
from the UI, you're in the anti-pattern this skill exists to prevent.
The running server exposes its classpath — every .lsf module, every
properties file, every resource that the JVM loaded — over a read-only HTTP
API. You ask the server for a file and it streams the bytes it's actually
serving from. The answer is by construction the source the running JVM
is using; nothing on the host filesystem can shadow it or fall behind.
This is the way to confirm what's on a server. Reach for it before anything else when the question is "is feature X really deployed?" or "what does Y look like right now over there?".
All three are POST to the web port (Tomcat — 8080 or via HTTPS on
the host's external port). Body is application/json. The app-server HTTP
port 7651 serves only the Action API (/exec, /eval, /eval/action) —
hitting /files/* there fails with HTTP 500 ("Something went wrong"), not
a clean 404, so don't read that as a server-side bug.
| Path | Body | Purpose |
|---|---|---|
/files/list | {"pathPattern":"<glob>","limit":N,"offset":N} | List every classpath entry matching a glob |
/files/read | {"path":"/<path>","offset":N,"maxBytes":N} | Stream the bytes of one entry |
/files/search | {"regex":"<pat>","pathPattern":"<glob>","limit":N,"contextChars":N,"timeoutSeconds":N,"maxScannedFiles":N,"maxFileBytes":N} | Regex-grep across entries; returns matching lines with file path + line number + excerpt |
Check truncated and timedOut in every response — the defaults bite.
/files/list caps at 500 entries by default ("truncated": true means
there are more — page with offset or narrow the glob). /files/search runs
under a ~5-second default time budget, and on a wide glob
(**/*.lsf over a classpath with a couple hundred jars) candidate
enumeration alone can eat all of it — the response comes back
{"hits":[], "timedOut":true, "scannedFiles":0}, which looks exactly like
"no matches" if you only read hits. Never conclude "not found" from a
response with "timedOut": true. For wide scans, pass an explicit
"timeoutSeconds": 15 (or more) and narrow pathPattern to the namespace
you care about; scannedFiles vs candidates in the response tells you how
much of the classpath was actually covered.
Auth is identical to the rest of the Action API: production → -u admin:
(empty password is the default); devmode → no -u at all. See the auth
section in Part 1 if anything is unclear.
The API is part of the platform's ClasspathFileTools server (the stack
trace on a 400-shaped error mentions
lsfusion.server.physics.admin.files.ClasspathFileTools) and is bundled
with the standard package.
Every path is classpath-rooted with a leading slash. There is no notion of a host filesystem path here — the API flattens whatever the JVM's classpath contains:
/<TopModule>.lsf — the top module sits at the root of the classpath/lsfusion.properties — root-level config picked up by the server/<namespace>/<Class>.lsf — sub-paths mirror MODULE namespaces (e.g.
/library/books/Book.lsf)/system/Authentication.lsf — platform modules live alongside yoursThe glob patterns are POSIX-shell-style with ** for "any number of
directories": **/*.lsf, <namespace>/**, **/<Class>*.lsf.
Substitute <host>, the class names, and the namespace for whatever the
project actually uses. The shapes below stay the same.
# Does my new module exist on the running server?
curl -sS -u 'admin:' -X POST \
-H 'Content-Type: application/json' \
-d '{"pathPattern":"**/<Class>*.lsf"}' \
https://<host>/files/list
# → {"timedOut":false,"offset":0,"limit":500,
# "files":["/<ns>/<Class>.lsf","/<ns>/<RelatedClass>.lsf"],"truncated":false}
# What does my top module declare on the deployed server?
curl -sS -u 'admin:' -X POST \
-H 'Content-Type: application/json' \
-d '{"path":"/<TopModule>.lsf"}' \
https://<host>/files/read
# Read the deployed lsfusion.properties — confirms logics.topModule, db.deny* flags as the server saw them at boot
curl -sS -u 'admin:' -X POST \
-H 'Content-Type: application/json' \
-d '{"path":"/lsfusion.properties"}' \
https://<host>/files/read
# Find every place a name is referenced (regex grep), .lsf only, with context.
# Explicit timeoutSeconds: the ~5 s default can expire before a wide glob
# scans a single file (see the callout above).
curl -sS -u 'admin:' -X POST \
-H 'Content-Type: application/json' \
-d '{"regex":"<propertyName>","pathPattern":"**/*.lsf","limit":50,"contextChars":80,"timeoutSeconds":15}' \
https://<host>/files/search
# → {"hits":[{"path":"/<ns>/<Class>.lsf","line":7,"excerpt":"<propertyName> = DATA <OtherClass> (<Class>);"}, …],
# "candidates":420,"timedOut":false,"scannedFiles":37,"truncated":false}
POST /files/read returns:
{
"path": "/lsfusion.properties",
"offset": 0,
"bytesRead": 173,
"truncated": false,
"mimeType": "text/properties",
"eof": true,
"content": "logics.topModule = <TopModule>\r\n…"
}
For text files content is the file as a JSON-escaped string — pipe through
jq -r .content to get the raw text. For binary files the API still wraps
bytes into the same JSON envelope; expect non-printable escapes if you
read e.g. an image. The mimeType field reflects what the platform thinks
based on file extension. truncated: true plus a non-eof response means
you hit maxBytes (defaults are reasonable but bounded) — re-request with
a larger maxBytes or page via offset.
# Pull the deployed copy and diff against your local working tree
curl -sS -u 'admin:' -X POST \
-H 'Content-Type: application/json' \
-d '{"path":"/<namespace>/<Class>.lsf"}' \
https://<host>/files/read | jq -r .content \
> /tmp/deployed.<Class>.lsf
diff /tmp/deployed.<Class>.lsf src/main/lsfusion/<namespace>/<Class>.lsf
If the diff is empty, what you have locally is what's running. If not, the running jar is from a different commit — redeploy via the lsfusion-deploy skill (or git-checkout to whatever matches, depending on which direction is correct for the task).
API calls prove things to you. Screenshots prove things to the user. When a task is "I added a field to this form" or "the new attribute should appear in this column", a rendered screenshot is unambiguous in a way that a JSON count is not — and the user can see at a glance whether the result matches expectations.
verify first — on a deployed host tooThe lsfusion-dev skill's verify command targets the local dev install by
default and any other web client with -Url:
lsfdev.ps1 verify -Url https://host/app/ -User admin -Password '<pwd>' -OpenScript "SHOW Shop.items WINDOW;" -OpenExpect "Coffee beans" -Do "assert-text:[lsfusion-form='Shop.items']=>Tea","screenshot:items"
One run gives you the login (detected automatically — pass the web
client's base URL including its application context, and the target's own
credentials), the direct form open (the mechanism below), -Click /
-DoubleClick / -Do steps with assert-text / assert-count /
screenshot:<name>, full-resolution PNGs + DOM + console on disk, a
watchdog and exit codes CI can trust; -Session continues the same page
across calls (repeat -ProjectDir and -Url on every continuation).
Requirements: Windows PowerShell + Python 3, and a project already set up
with lsfusion-dev — run it there (-ProjectDir): the project supplies the
configuration and the artifact directory, while its own server, Tomcat and
database need not be running (don't setup a project just for this — setup
provisions a database). Limits: no insecure-TLS switch (the certificate
must be valid), no network request capture, and a linear step list — no
branching, no feeding a value read from the page into a later step (plain
inspection is an eval: step). -OpenScript on a deployed install is also
gated by the server: the Eval module must be in the build and the
account needs the UI/API permissions listed in the shared reference below.
Only when verify is unavailable or cannot express the operation: no
set-up lsfusion-dev project on the box, no Windows PowerShell (Linux/macOS
agent), an invalid or self-signed certificate, request/response evidence,
or logic beyond a linear step list. Needing screenshots, several forms,
field entry or assertions between steps is not a reason — verify does
those. Then copy
references/playwright-remote.py, adapt
URL / credentials / the body of navigate_and_capture(), and run. It is an
illustration of the pattern, not a maintained harness: verify carries
readiness and login handling the template does not (see the gotchas below).
In-app browser: optional, after verification. When the session has one
(Claude Desktop's Browser pane, mcp__Claude_Browser__* tools), use it
only after verify (or the script fallback) has done the check, for ONE
attempt at reading an already-rendered page (get_page_text /
read_page beat brittle text matchers) or a quick exploratory click, under
lsfusion-dev's references/verify.md,
section "In-app browser vs verify — the split": stop at
its first failure signature; never retry, resize, reload, or enter a
password through it. Proof-grade screenshots and repeatable evidence come
from verify or the script, never from the pane (its shots are capped
~800 px wide, nothing lands on disk, and headless harnesses — CLI, CI,
subagents — have no pane at all).
A page.goto() on <base>/eval/action?script=<url-encoded action script>
opens the script's form in the web client (302 → /push-notification →
service worker → /main), exactly as if the user had opened it — fully
parameterizable down to one object's edit card:
SHOW Shop.items WINDOW;
FOR Shop.name(Shop.Item i) = 'Coffee beans' DO SHOW EDIT Shop.Item = i WINDOW;
Before writing a script around this, read
references/form-open-url.md — the shared
mechanism reference (also behind lsfusion-dev's verify -OpenScript, the
standard direct-open path: the configured local install by default, another
host with -Url). It carries the rules
that make the call work: WINDOW window mode (a bare SHOW floats and
renders unrepresentative layout), the service-worker registration visit and
stuck-page recovery, namespace-qualified names, URL-encoding, script errors
coming back as the 500 body, and the auth gates on non-devmode installs.
The reference script carries a first-cut workaround for each of these — read it before writing your own, and tighten its waits for your target.
input[name="username"]
and input[name="password"], with an input[name="submit"][type="submit"]
button. Default account admin / empty password unless rotated. After
clicking submit, wait networkidle plus a 2–3 s settle for the SPA to
render the navigator, then check the outcome (password field gone,
navigator visible) regardless of what login() returned: the template
returns False on any timeout, which does not prove devmode, and it
can return True after rejected credentials when its calls complete
without timing out — it never checks that authentication succeeded.
When devmode really is ON, the app renders without a login form and
skipping the login is correct.CHANGEMOUSE 'DBLCLK'
runs its own action; a CUSTOM renderer decides itself; in a dialog a
double-click is OK. Never script it as the route to a card, and never
assume it does nothing either — check what opened: every form layout root
carries lsfusion-form="<sID>", a new visible one after the gesture is an
opened form (visible_forms() in the template). Deterministic route: the
direct open SHOW EDIT <Class> = <obj> WINDOW (URL mechanism above,
open_by_script() in the template) — parameterized, locale-free. Toolbar
route: select the row, then click the form's Edit action inside that
form's subtree ([lsfusion-form="<sID>"]) by its localized caption —
open_detail_via_edit(page, form_sid=…, caption=…, within=…) in the
template clicks the ONE visible control whose caption matches exactly
inside that scope (two matches raise instead of guessing — a form with
several grids needs within= narrowed to the grid's container); a
page-wide button:has-text("Edit") hits the first English Edit of any
form on the page. New objects come from the + Add buttons next to it.Loading overlay between actions. After clicking Edit, lsFusion
shows a Loading spinner before the card paints. A naive
wait_for_timeout(2000) captures the spinner, not the form. Wait for the
overlay to detach first: page.wait_for_selector("text=Loading", state="detached"),
then wait_for_load_state("networkidle"), then an extra 2 s settle.
Caveat: the word Loading may be localized on non-English installs —
the reliable wait is for the target form's own content (a caption, a
known cell value), not for the spinner's text; the template's
wait_loading() only falls back to fixed waits and can still capture
the spinner.wait_for(..., timeout=60000) returns the
instant the element renders, so an oversized budget costs nothing on a
fast run — and reserve fixed waits below 3 s for animation/focus settles
where no readiness selector exists (the template's short waits after
navigator clicks are that kind of settle, not a readiness wait). A
timeout alone does not prove the form is broken.EXTEND FORM ... PROPERTIES(i) myNewCol
appends myNewCol to the right end of the columns; on a 1600 px viewport
with a typical Items grid it'll be off-screen. Focus the grid (click any
visible cell) and press End 10–20 times to scroll the new columns into
view.sID: ... / Path: ... and it lingers. Before each
screenshot, click in dead space (page.mouse.click(800, 400)) to dismiss
it — otherwise screenshots end up with a debug tooltip stuck to the
navigator that's nothing to do with the form you're proving.try_click_text()
tries text first and returns False on a miss — it prints nothing, so
check its result; a miss is a signal to look at a screenshot of where
you actually ended up and pick a different matcher, NOT a fatal error.references/playwright-remote.py ships
with a navigate_and_capture() body that takes 5 screenshots — login page,
post-login navigator, items grid, items grid scrolled right, one item
detail card. Treat this as illustration of the pattern (click navigator entry → wait → screenshot) and replace the body with whatever your task
needs. Output goes to ./screenshots/ under the current working
directory (not the script's folder).
-u admin: ≠ no -u. Repeat after me. The single mistake worth more
than all the others combined.--data-urlencode, not --data. With --data the shell does
no encoding and &, +, =, % inside your script become protocol
syntax — the server then parses garbage.--data-urlencode "script@/path/to/file.lsf" (note
the @, not =). Cleanest way to pass a multi-line script with quotes
and $ inside./eval wants a run action; /eval/action wants an action body.
Mixing them up returns "Property or action 'run' not found" (passed an
action body to /eval) or "syntax error" (passed a module with MODULE /
REQUIRE to /eval/action)./eval/action requires the Eval module to be REQUIREd by
the project. It's in the default REQUIRE list this skill family
recommends. If the deployed project doesn't have it, /eval/action
returns 404 — you'll have to deploy a temporary build with Eval added,
or use /exec?action=<an action the project itself declares with @@api>.What SKILL.md sets; muted values are Claude Code's defaults
3 skills in this plugin
/lsfusion-deployDeploy an lsFusion application to a remote Linux server (Ubuntu/Debian or RHEL). Covers the official auto-installer, switching the platform between major versions or release channels, packaging the configuration into a jar under /var/lib/lsfusion, the app-server and web-client systemd units, HTTPS via Let's Encrypt/certbot, and pulling the remote PostgreSQL DB into a local lsfusion-dev instance. Use whenever the user wants to install lsFusion on a remote host, push a project (Maven repo or plain .lsf files) over ssh/scp, upgrade or downgrade the platform, set up TLS on the web client, debug the production database locally, or diagnose a stopped lsFusion service, a failed schema migration, "Dropping modules" / "Dropping tables" or a "no viable alternative" parse error. Triggers on ssh + systemctl + lsFusion tasks and on "deploy lsfusion", "install lsfusion on the server", "upgrade the platform", "enable https on lsfusion", "pull the prod DB locally". For LOCAL Windows development use lsfusion-dev instead./lsfusion-devSet up, run, and verify lsFusion applications locally on Windows. Use this skill whenever the user works with lsFusion in any way — writing or editing .lsf modules, scaffolding an lsFusion app, downloading the lsFusion server jar or client war, starting the lsFusion application server, diagnosing why the server won't start or a form won't open, or checking an lsFusion result in the browser. Triggers on "lsFusion", ".lsf", "start the lsFusion server", "write lsFusion code", "verify the form", and any request to create, launch, debug, or verify an lsFusion project. Use it even when the user only mentions lsFusion in passing and expects something runnable.npx claudepluginhub lsfusion/ai-skills --plugin lsfusion-ai-skills