feat(server): run a repository's t3.json setup action automatically - #68
Merged
Conversation
A repository could already declare `scripts[].runOnWorktreeCreate` in its checked-in `t3.json`, but the server only read that file for the project icon: the scripts were offered as a manual "Add action" import in the web UI. So a repo that commits its setup action still came up with nothing running until someone clicked through it — once per project, per environment. ProjectSetupScriptRunner now falls back to `t3.json` when a project has no persisted worktree-setup script, synthesizing a ProjectScript from the first entry flagged `runOnWorktreeCreate`. A configured project script still wins, and loading stays infallible, so a missing or malformed file is still just "no setup script" rather than a bootstrap failure. Model: Claude Opus 5. Harness: Claude Code in T3 Code.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Problem
A repository could already declare
scripts[].runOnWorktreeCreatein its checked-int3.json, but the server only read that file for the project icon. The scripts were surfaced solely as a manual "Add action" import in the web UI (ProjectScriptsControl.tsx→importFileScript), so a repo that commits its setup action still came up with nothing running until a human clicked through it — once per project, per T3 instance. The motivating case isbk-docs, whose committed setup script symlinks gitignored.envfiles into each new worktree: without the import, every new worktree started with no.env.Fix
ProjectSetupScriptRunnernow falls back tot3.jsonwhen a project has no persisted worktree-setup script. It takes the first entry flaggedrunOnWorktreeCreateand synthesizes aProjectScriptunder the stable idt3-json-setup(which only names the default setup terminal and appears in bootstrap receipts — the Coordinator always passespreferredTerminalId).T3ProjectFileLoader.loadis infallible, so a missing, unreadable, or malformedt3.jsonstill meansno-script, never a bootstrap failure — and no new error channel.T3ProjectFileScript → ProjectScriptconversion lives next tosetupProjectScriptinpackages/shared/src/projectScripts.ts, mirroring the web import path's defaults (icon ?? "play").server.tsprovidesT3ProjectFileLoader.layerto the runner insideGitManagerLayerLive;FileSystem/Pathalready come fromPlatformServicesLive.Every fork edit to an upstream-owned file sits inside a
T3-CUSTOM(expbkt3)marker.Verification
vp test run src/project/ProjectSetupScriptRunner.test.ts— 9 passed, including new coverage for: persisted script wins overt3.json;t3.jsonused when there is no persisted script; not3.json; no qualifyingt3.jsonentry; malformedt3.json→no-script.tsgo --noEmitclean inapps/serverandpackages/shared; targetedvp lintandvp fmt --checkclean.Retargeted to
expbkmainper the fork's ship-to-staging rule inAGENTS.md;origin/expbkmainis merged in, so CI validates against the real base.Note: the
markersCI job is already failing on both fork branches (see PR #55) from a pre-existing baseline backlog unrelated to this change; none of the files touched here are flagged.Docs:
docs/user/worktree-setup.mdgains a "Ship the setup action in the repository" section.Model: Claude Opus 5. Harness: Claude Code in T3 Code.
🤖 Generated with Claude Code
Need help on this PR? Tag
@codesmith-botwith what you need. Autofix is disabled.