Skip to content

feat(claude): add opt-in trellis init --with-statusline flag#333

Open
wang199001 wants to merge 2 commits into
mindfold-ai:mainfrom
wang199001:feat/statusline-opt-in
Open

feat(claude): add opt-in trellis init --with-statusline flag#333
wang199001 wants to merge 2 commits into
mindfold-ai:mainfrom
wang199001:feat/statusline-opt-in

Conversation

@wang199001

Copy link
Copy Markdown

概述

实现当初移除默认 statusLine 时(0.5.0-beta.15, 9ea89f2)官方推荐但未实现的 opt-in 方案:
trellis init --with-statusline 为 Claude Code 安装 Trellis 状态栏(hook 脚本 +
settings.json 的 statusLine 配置项)。交互式(非 -y)init 在选择了 Claude Code 且未传
flag 时会额外询问"是否安装 Trellis statusLine",默认否。

默认完全关闭:不选择安装时,init 产物与当前版本逐字节一致,当初"项目级 statusLine
静默覆盖用户全局配置"的问题不可能回归。

脚本基于移除前的仓库最终版(会话级任务解析、[session] 来源标记、Windows UTF-8 修复),
新增两项能力:

  • 限额重置倒计时:5h 17% (reset 4h31m) · 7d 19% (reset 2d11h)
  • 宽度自适应:窄终端下(通过 Claude Code v2.1.153+ 注入的 COLUMNS 环境变量检测)
    限额段自动换到独立一行,避免状态栏折行错位

Closes #332

行为矩阵

场景 结果
trellis init --claude(默认 / -y 不安装任何内容,输出与现状逐字节一致
trellis init --claude --with-statusline 安装 hook 脚本 + statusLine 配置项
交互式 init 选中 Claude Code、未传 flag 确认询问,默认-y 模式从不询问
未安装的项目执行 trellis update 永远不会被强制安装(已从模板收集中排除)
已安装的项目执行 trellis update 两个产物均保留,settings.json 跨 update 逐字节不变

测试

  • 默认关闭回归(settings.json 与解析后的模板逐字节一致)
  • flag 安装矩阵(hook + 配置项;{{PYTHON_CMD}} 已解析)
  • 其他平台不受 flag 影响
  • 交互确认矩阵:是 / 否(默认)/ -y 不询问 / 传 flag 不询问 / 已配置不重复询问 / re-init 加平台路径生效
  • update 双向安全(未装的不会被装上;已装的跨 update 字节不变)
  • resets_at 格式容错(epoch 秒 + ISO-8601,未知格式省略倒计时而非崩溃)
  • COLUMNS 宽/窄两种渲染(窄屏分行,宽屏或未注入时单行且与原行为一致)
  • pnpm lint / pnpm lint:py / pnpm typecheck / pnpm test 全部通过

截图

  • 双行
image
  • 单行
image

Re-introduce the Claude Code statusLine as an explicit opt-in, the shape
recommended when the default install was removed in 0.5.0-beta.15
(9ea89f2). Default init output stays byte-identical: no statusLine key,
no statusline.py.

- New template src/templates/claude/hooks/statusline.py (claude-specific,
  not a shared hook): session-scoped task resolution via the shared
  resolver, [session] source tag, Windows reconfigure fix, rate-limit
  display with reset countdown (5h 17% (reset 4h31m)), and width
  adaptation via the COLUMNS env var (rate limits move to their own line
  on narrow terminals; explicit \n to avoid the wrap-height bug).
- --with-statusline wired through both init paths (fresh init and
  re-init add-platform); statusLine settings injection mirrors update's
  preservation serialization byte-for-byte to avoid phantom updates.
- Interactive (non -y) init additionally asks "Install Trellis
  statusLine for Claude Code?" (default No) when Claude Code is selected
  and the flag was not passed; -y and flag-passed runs never prompt.
- Update safety both directions: statusline.py stays out of the
  unconditional template walk (never force-installed on opted-out
  projects); opted-in installs survive update (existing
  preserveExistingClaudeStatusLine + no manifest entry).
- Tests: default-off regression, flag-on file matrix, other platforms
  unaffected, update safety both ways, ISO-8601/epoch resets_at
  tolerance, COLUMNS split/single-line, interactive confirm matrix
  (Yes/No/-y/flag/already-configured); resurrected the session-scoped
  statusline tests removed in 9ea89f2.
- Specs: restored statusline statements adapted to the new placement;
  documented the settings-injection serialization contract and the
  statusline COLUMNS/no-TTY runtime constraints.
Resolve conflict in init.ts InitOptions: keep both withStatusline (statusline opt-in) and workflow/workflowSource (from main).
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

[功能建议] 以显式 opt-in(--with-statusline)方式恢复 Claude Code 状态栏

1 participant