You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
fix(cli): expand ~ in t3 policy templates --policy - #41438
t3 policy templates <directory> --policy=~/policy.json fails with No policy file at ~/policy.json., even when ~/policy.json exists. bash and zsh do not expand ~ after the = in --policy=~/…, so the CLI receives the literal ~/policy.json. The same happens with a quoted path or when a script passes the argument without a shell.
Change
The templates handler in apps/server/src/cli/policy.ts expands the path once with expandHomePath from os-jank.ts and uses the result for both the existence check and ManagedPolicy.load. The error message still shows the path as typed, as in #41271.
Scope
This is a small fix for an obvious bug, so it has no issue. It follows #41199 (project add --track), #41271 (thread --output-schema) and #41430 (environment link --from), which fixed the same gap for other flags. It changes only --policy. The positional policy check <file> and templates <directory> arguments are left alone, because the shell already expands an unquoted leading ~ there.
Verification
policy.test.ts had no templates test, so a new case in its it.layer block runs policy templates <home> --policy=~/policy.json through the CLI with HostProcess.HomeDirectory set to a temp dir. It checks that the generated macOS profile carries the policy's organization rather than the sample's.
main: UserError: No policy file at ~/policy.json.
fix: Tests 2 passed (2)
From a checkout, with a scratch HOME and ~/policy.json holding {"schemaVersion":1,"organization":"Tilde Corp"}:
Claude Fable 5.2 (high, Claude Agent in T3 Code) found the bug. Claude Opus 5.5 (high) and GPT-6.2 Astra (high, Codex) reproduced it independently. Claude Opus 5.5 (Claude Agent in T3 Code) wrote the fix and test. Claude Opus 5.5 (xhigh), GPT-6.2 Sol, GPT-6.2 Astra (high, Codex), and Claude Fable 5.2 reviewed the patch in T3 Code.
Reviewing files that changed from the base of the PR and between 3cbc63e and a139d32.
You can disable this status message by setting the reviews.review_status to false in the CodeRabbit configuration file.
Use the checkbox below for a quick retry:
Trigger review
No actionable comments were generated in the recent review.
Walkthrough
The policy templates command now expands supplied policy paths before checking and loading them. A new CLI test checks template generation when the policy path starts with ~.
Changes: Policy path handling
Layer / File(s)
Summary
Expand policy paths and verify template generation apps/server/src/cli/policy.ts, apps/server/src/cli/policy.test.ts
The command expands the supplied path before checking for and loading the policy file. The missing-file error still uses the original argument. A CLI test checks that --policy=~/policy.json produces a macOS profile containing Tilde Corp.
pingdotgg/t3code#29862: Adds the policy templates command whose policy-file input handling this change updates.
Suggested labels:bugfix
Suggested reviewers:macroscopeapp
Merge Risk: Minimal · previous review 3cbc6
The policy templates command now expands a leading ~ in --policy paths, which fixes the case where the shell leaves it unexpanded. The change is narrow, covered by a new test, and has no identified merge-blocking risk.
Pre-merge checks: 4
Check name
Status
Explanation
Title check
The title "fix(cli): expand ~ in t3 policy templates --policy" matches the main change. The PR makes the templates handler in apps/server/src/cli/policy.ts expand a leading ~ in the --policy path with…
Description check
The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and each one is filled in. The Problem section gives the failing command and the shell behavi…
Linked Issues check
Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check
Check skipped because no linked issues were found for this pull request.
Full details: Title check
Explanation
The title "fix(cli): expand ~ in t3 policy templates --policy" matches the main change. The PR makes the templates handler in apps/server/src/cli/policy.ts expand a leading ~ in the --policy path with expandHomePath before the existence check and ManagedPolicy.load. It uses a conventional commit format and is concise and specific.
Full details: Description check
Explanation
The description follows the repository template. It has Problem, Change, Scope, and Verification sections, and each one is filled in. The Problem section gives the failing command and the shell behavior behind it. The Change section names the handler and helper. The Scope section explains why no issue is linked and says only --policy changes. The Verification section gives a new test, before and after output, and a repo check. The template's optional agent-model line is also filled in. The description does not link an issue, but it gives a reason for that, as the template allows for small obvious fixes.
Finishing Touches
Generate unit tests (beta)
Create a new PR
Autofix · Keep fixing CodeRabbit findings and required CI, and resolving merge conflicts
Reviewing files that changed from the base of the PR and between 27ecc0f and 3cbc63e.
Files selected for processing: 2
apps/server/src/cli/policy.test.ts
apps/server/src/cli/policy.ts
Included review availability: This review used your included allowance. Your plan provides up to 10 included reviews per hour; 8 remain after this review.
Created identical synthetic ~/policy.json files containing {"schemaVersion":1,"organization":"Tilde Corp"} in isolated homes. Ran t3 policy templates "$HOME/policy-templates-out" '--policy=~/policy.json' using each commit's built CLI on Linux x86_64. Base exited 1 and generated nothing; head exited 0, generated all three templates, and included “Tilde Corp” three times in the macOS profile. The shell-expanded control succeeded on both.
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
size:XS0-9 changed lines (additions + deletions).vouch:unvouchedAuthor is not yet trusted in the VOUCHED list.
2 participants
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
t3 policy templates <directory> --policy=~/policy.jsonfails withNo policy file at ~/policy.json., even when~/policy.jsonexists. bash and zsh do not expand~after the=in--policy=~/…, so the CLI receives the literal~/policy.json. The same happens with a quoted path or when a script passes the argument without a shell.Change
The
templateshandler inapps/server/src/cli/policy.tsexpands the path once withexpandHomePathfromos-jank.tsand uses the result for both the existence check andManagedPolicy.load. The error message still shows the path as typed, as in #41271.Scope
This is a small fix for an obvious bug, so it has no issue. It follows #41199 (
project add --track), #41271 (thread --output-schema) and #41430 (environment link --from), which fixed the same gap for other flags. It changes only--policy. The positionalpolicy check <file>andtemplates <directory>arguments are left alone, because the shell already expands an unquoted leading~there.Verification
policy.test.tshad notemplatestest, so a new case in itsit.layerblock runspolicy templates <home> --policy=~/policy.jsonthrough the CLI withHostProcess.HomeDirectoryset to a temp dir. It checks that the generated macOS profile carries the policy's organization rather than the sample's.From a checkout, with a scratch
HOMEand~/policy.jsonholding{"schemaVersion":1,"organization":"Tilde Corp"}:Before:
After (the profile contains
Tilde Corp):vp run check:changed upstream/mainpasses.Claude Fable 5.2 (high, Claude Agent in T3 Code) found the bug. Claude Opus 5.5 (high) and GPT-6.2 Astra (high, Codex) reproduced it independently. Claude Opus 5.5 (Claude Agent in T3 Code) wrote the fix and test. Claude Opus 5.5 (xhigh), GPT-6.2 Sol, GPT-6.2 Astra (high, Codex), and Claude Fable 5.2 reviewed the patch in T3 Code.