Skip to content

fix(run): don't print the built-in variables setup for .cfm templates - #26

Merged
bpamiri merged 4 commits into
wheelsfrom
peter/run-cfm-prelude
Oct 6, 2026
Merged

bpamiri merged 4 commits into
wheelsfrom
peter/run-cfm-prelude

Conversation

@bpamiri

@bpamiri bpamiri commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator

Upstream issue: cybersonic#137

What

lucli run hello.cfm (with <cfoutput>hello #1+1#</cfoutput>) printed about 20 lines of setup code (// LuCLI Built-in Variables Setup, __scriptDir = '…', …, // === Original Script Content ===) before hello 2. .cfs files were not affected.

Why

executeTemplate (the .cfm path) prepended the built-in variables setup, which is CFML script, to the template as plain text. In a template, text outside <cfscript> is output.

How

  • executeTemplate builds the content with a new wrapBuiltinSetupForTemplate(setup, template): <cfscript> + setup + </cfscript>, then the template unchanged, with nothing in between. So the setup runs and the output is exactly what the template renders.
  • The marker comment is not added for templates.
  • injectBuiltinVariables is unchanged for any other caller.
  • .cfs scripts go through executeScriptContent and are untouched.

Tests

  • New: TemplatePreludeTest. The setup is inside <cfscript>, the template follows with nothing in between, there's no marker, and an empty or null setup leaves the template unchanged.

  • End to end (isolated LUCLI_HOME / -Duser.home):

    v0.6.2.2 this branch
    run hello.cfm the setup lines, then hello 2 hello 2
    run vars.cfm (<cfoutput>#listLast(__scriptPath, "/")#</cfoutput>) vars.cfm vars.cfm

    So the variables are still available.

  • Full suite (mvn test -DargLine="-Duser.home=<empty dir>"): 771 tests. The only failures are the 17 known clean-home failures that base wheels shows under the same sandbox (Test suite isn't isolated from the developer's LuCLI home: writes into ~/.lucli, fails in a clean home #25); none are new. The real ~/.lucli was untouched. Unsandboxed, CI runs the normal way.

Fork bookkeeping

CHANGELOG ## Unreleased entry; FORK.md "Next queue" row 13. It will conflict on those two files with whichever of #22–#24 merges first; I'll merge wheels in when it's this PR's turn.

Upstream

The same change goes to cybersonic/LuCLI as a cherry-pick -x onto upstream main (without FORK.md) once this is reviewed.

🤖 Generated with Claude Code

bpamiri and others added 2 commits October 6, 2026 04:50
executeTemplate prepended the built-in variables setup (script) to the
.cfm content as plain text. In a template, text outside <cfscript> is
output, so 'lucli run hello.cfm' printed ~20 lines of setup code and an
'Original Script Content' marker before 'hello 2'.

The setup now runs inside <cfscript> directly ahead of the unchanged
template (wrapBuiltinSetupForTemplate), so the output is exactly the
template's and the built-in variables stay available. .cfs scripts go
through executeScriptContent and are unchanged.

Upstream: cybersonic#137

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Peter Amiri <peter@alurium.com>
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Peter Amiri <peter@alurium.com>
@bpamiri

bpamiri commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

rev1-r3 review @ c26936d: code APPROVE (final after the wheels merge + CI on that head)

End to end (the RED/GREEN): JDK 21 jars, isolated LUCLI_HOME + -Dlucli.home, sandboxed HOME + -Duser.home, lucli run <file>.

File base (wheels @ 8942048) this branch
hello.cfm: <cfoutput>hello #1+1#</cfoutput> 19 lines: // LuCLI Built-in Variables Setup, __scriptDir = '…', … then hello 2 hello 2 (1 line)
vars.cfm: #listLast(__scriptPath,"/")#|#arrayLen(__arguments)# setup text, then the values vars.cfm|0: the built-ins are still set
s.cfs: writeOutput("cfs " & (1+2)) cfs 3 cfs 3 (the .cfs path is untouched)

Nothing was written under the sandboxed user.home in either run. TemplatePreludeTest passes 2/0/0. It can't be RED on base, because wrapBuiltinSetupForTemplate is new; the table above is the behavioural RED.

Code: minimal. The setup runs inside <cfscript>…</cfscript> with the template appended directly, so nothing between them is output. There's no marker comment, an empty or null setup returns the template unchanged, and injectBuiltinVariables stays as it is for every other caller.

Nits, not blocking:

  • The .cfm path no longer wraps the setup in Timer.start/stop("injectBuiltinVariables"), so --timing loses that span for templates. Consider keeping it for parity.
  • The verbose and debug dump right after still prints === CFS Script with Built-in Variables === for a .cfm. That's cosmetic.

Merge state: BLOCKED/conflicting on CHANGELOG/FORK.md as expected. I'll delta-check the wheels merge (only those two files) and read CI on that head before the final.

bpamiri and others added 2 commits October 6, 2026 05:03
Signed-off-by: Peter Amiri <peter@alurium.com>

# Conflicts:
#	CHANGELOG.md
#	FORK.md
… the debug dump as a CFM template

Review nits on #26.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Signed-off-by: Peter Amiri <peter@alurium.com>
@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Integration Tests (ubuntu-latest, Java 21)

78 tests   78 ✅  1m 23s ⏱️
14 suites   0 💤
 1 files     0 ❌

Results for commit 2ce882e.

@github-actions

github-actions Bot commented Oct 6, 2026

Copy link
Copy Markdown

Unit Tests (ubuntu-latest, Java 21)

 64 files   64 suites   2m 4s ⏱️
780 tests 774 ✅ 6 💤 0 ❌
785 runs  779 ✅ 6 💤 0 ❌

Results for commit 2ce882e.

@bpamiri

bpamiri commented Oct 6, 2026

Copy link
Copy Markdown
Collaborator Author

rev1-r3 review @ 2ce882e: APPROVE (final)

There are two commits on top of the approved c26936d:

PR CI on this head: 8 pass (Build ×3, Unit ×3, Integration ×2); APT smoke skipped. mergeStateStatus is CLEAN.

Ready to merge.

@bpamiri
bpamiri merged commit 5d1439c into wheels Oct 6, 2026
11 checks passed
@bpamiri
bpamiri deleted the peter/run-cfm-prelude branch October 6, 2026 12:08
bpamiri added a commit that referenced this pull request Oct 8, 2026
- pom.xml version 0.6.2.3 (the Windows file/product version follows
  ${project.version}); install-validation default 0.6.2.3.
- FORK.md: 'Next queue' becomes the 0.6.2.3 queue (rows 8-15: #19,
  #21-#24, #26-#28), with the row-8 compatibility note (Wheels 4.1.x
  stays at max 0.6.2.2: no __lucliMcpCall handling), and a new empty
  Next queue.
- CHANGELOG unchanged: fork entries stay under Unreleased, as for
  0.6.2.2.

Sandboxed mvn test (-Duser.home only): 788 run, 0 failures.

Signed-off-by: Peter Amiri <peter@alurium.com>
Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant