> ## Documentation Index
> Fetch the complete documentation index at: https://docs.trytrellis.app/llms.txt
> Use this file to discover all available pages before exploring further.

# v0.5.2

> 2026-05-06

修 `SessionStart` hook 在 Python ≤3.11 上启动时崩溃（`SyntaxError: f-string expression part cannot include a backslash`）。无新增 migration。

## Bug Fixes

### Hook session-start：Python ≤3.11 上的 f-string 反斜杠语法错

0.5.0-rc.6（#226）加的 Windows 路径归一化用了这种写法：

```python theme={null}
return f"{drive}:\\{rest.replace('/', '\\')}"
```

PEP 498 不允许反斜杠出现在 f-string 表达式部分。Python ≤3.11 解析这个文件直接抛 SyntaxError，hook 还没跑就 code 1 退出：

```
SessionStart hook (failed)
error: hook exited with code 1
```

Python 3.12 的 PEP 701 放开了这个限制，3.12+ 用户看不见这个 bug。Codex CLI 0.128 + Trellis 0.5.0 用户在群里反馈复现。

修法是把 `.replace(...)` 提到 f-string 外面，先赋给本地变量再插值。一共 9 处：

* `packages/cli/src/templates/codex/hooks/session-start.py`
* `packages/cli/src/templates/copilot/hooks/session-start.py`
* `packages/cli/src/templates/shared-hooks/session-start.py`（Claude Code / Cursor / Gemini CLI / Qoder / CodeBuddy / Factory Droid / Kiro）

`packages/cli/test/regression.test.ts` 加了回归断言：正则扫描三个文件，确认没有 f-string 表达式部分含反斜杠的写法；外加一个尽力做的 `python3 -c "ast.parse(...)"` 检查。

## Upgrade

```bash theme={null}
npm install -g @mindfoldhq/trellis@latest
trellis update
```


This documentation is built and hosted on [Mintlify](https://mintlify.com), a developer documentation platform.