Skip to content

feat(server): run a repository's t3.json setup action automatically - #68

Merged
tusharbhardwaj-bk merged 2 commits into
expbkmainfrom
t3code/8b94491c
Aug 9, 2026
Merged

feat(server): run a repository's t3.json setup action automatically#68
tusharbhardwaj-bk merged 2 commits into
expbkmainfrom
t3code/8b94491c

Conversation

@tusharbhardwaj-bk

@tusharbhardwaj-bk tusharbhardwaj-bk commented Aug 8, 2026

Copy link
Copy Markdown

Problem

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 surfaced solely as a manual "Add action" import in the web UI (ProjectScriptsControl.tsximportFileScript), 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 is bk-docs, whose committed setup script symlinks gitignored .env files into each new worktree: without the import, every new worktree started with no .env.

Fix

ProjectSetupScriptRunner now falls back to t3.json when a project has no persisted worktree-setup script. It takes the first entry flagged runOnWorktreeCreate and synthesizes a ProjectScript under the stable id t3-json-setup (which only names the default setup terminal and appears in bootstrap receipts — the Coordinator always passes preferredTerminalId).

  • A persisted project script always wins; the checked-in file is only the fallback.
  • T3ProjectFileLoader.load is infallible, so a missing, unreadable, or malformed t3.json still means no-script, never a bootstrap failure — and no new error channel.
  • The T3ProjectFileScript → ProjectScript conversion lives next to setupProjectScript in packages/shared/src/projectScripts.ts, mirroring the web import path's defaults (icon ?? "play").
  • server.ts provides T3ProjectFileLoader.layer to the runner inside GitManagerLayerLive; FileSystem/Path already come from PlatformServicesLive.

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 over t3.json; t3.json used when there is no persisted script; no t3.json; no qualifying t3.json entry; malformed t3.jsonno-script.
  • tsgo --noEmit clean in apps/server and packages/shared; targeted vp lint and vp fmt --check clean.
  • Repo-wide suites deliberately left to CI (shared dev box).

Retargeted to expbkmain per the fork's ship-to-staging rule in AGENTS.md; origin/expbkmain is merged in, so CI validates against the real base.

Note: the markers CI 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.md gains a "Ship the setup action in the repository" section.

Model: Claude Opus 5. Harness: Claude Code in T3 Code.

🤖 Generated with Claude Code


View with [code]smith Autofix with [code]smith
Need help on this PR? Tag @codesmith-bot with what you need. Autofix is disabled.

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.
@github-actions github-actions Bot added size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list. labels Aug 8, 2026
@tusharbhardwaj-bk
tusharbhardwaj-bk changed the base branch from bkmain to expbkmain August 8, 2026 14:53
@tusharbhardwaj-bk
tusharbhardwaj-bk merged commit 70b4b57 into expbkmain Aug 9, 2026
12 of 13 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

size:L vouch:trusted PR author is trusted by repo permissions or the VOUCHED list.

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant