Repository navigation
feat: add a runtime Towerfile field and a bun runtime - #380
migueltheduck wants to merge 3 commits into
Conversation
`[app] runtime` declares what starts the script: python (uv), bash or bun. It is copied into the MANIFEST only when set, so existing bundles are unchanged. Without it the runtime still follows the script: .sh runs with bash, anything else with Python. The manifest keeps the value as a string, so a runtime this version doesn't know still parses and fails the run with UnsupportedRuntime instead. Bun apps run `bun install` (frozen when there's a lockfile) when they have a package.json, on the setup channel, then `bun run` on the script. Like uv and bash, bun runs in its own process group and with a cleared environment in protected mode, and installs into the runtime's cache dir when it has one. Bun scripts must be JavaScript or TypeScript, and import_paths aren't supported with bun yet. The packager now leaves node_modules out of bundles, and the MCP tower_file_update tool and the agent skill cover the new key. Co-Authored-By: Claude Opus 5.5 <[email protected]>
The runtime puts a bun app's import paths on NODE_PATH, as it puts a Python app's on PYTHONPATH, so `import_paths = ["../shared"]` makes `../shared/helpers.ts` importable as "helpers". Shared code is packaged under modules/, outside the app directory, so it never walks up into the app's node_modules. Bun would then quietly auto-install the latest version of whatever the shared code imports. The app's node_modules goes on NODE_PATH after the import paths, so shared code gets the versions the app pinned. Co-Authored-By: Claude Opus 5.5 <[email protected]>
tower_file_generate still reads pyproject.toml when there is one. Without it, it reads package.json and writes a bun Towerfile: the name without its npm scope, and the script from `module` (what `bun init` writes), `main` or the `start` script, then common entry points. A `main` that names a build output that doesn't exist yet is skipped. The workflow help and the skill gain a `bun init -y` step. Co-Authored-By: Claude Opus 5.5 <[email protected]>
|
Important Review skippedAuto reviews are disabled on base/target branches other than the default branch. Please check the settings in the CodeRabbit UI or the
|
|
I have read the CLA Document and I hereby sign the CLA You can retrigger this bot by commenting recheck in this Pull Request. Posted by the CLA Assistant Lite bot. |
Why
The runtime picks how to start an app from the script's extension:
.shruns with bash, anything else with uv. There's no way to run a JavaScript or TypeScript app. The bundle also doesn't say which runtime an app needs, so the server can't send its runs to a runner that has it.What
[app] runtime:python,bashorbun. Unknown values are rejected, and bun needs a JavaScript or TypeScript script. Without the field,.shruns with bash and everything else with Python, as before.UnsupportedRuntimeinstead of failing to parse.package.json,bun installruns first, frozen when there's a lockfile. Thenbun run <script>runs in its own process group, with a cleared environment in protected mode, like uv. If bun isn't installed, the run fails withMissingBun.import_pathsgo onNODE_PATH, as Python's go onPYTHONPATH, so../shared/helpers.tsis imported as"helpers". The app'snode_modulesgoes on it too, so shared code gets the versions the app pinned; otherwise bun would quietly auto-install the latest.node_modulesout of bundles, as it does.venv.tower_file_updatetakesruntime.pyproject.toml,tower_file_generatewrites a bun Towerfile frompackage.json. It takes the script frommodule,mainor thestartscript, then falls back to common entry points.bun init.Compatibility
Apps that don't set
runtimeare unaffected: no new key in the MANIFEST, still version 3, and the same runtime choice as before. Servers and runners that don't know the key ignore it.tower_file_generatestill preferspyproject.toml; with nopyproject.tomland nopackage.json, the error now names both files.