Skip to content

feat(cli): add Snow CLI as class-1 Trellis platform - #443

Merged
taosu0216 merged 11 commits into
mindfold-ai:mainfrom
BaSui01:feat/snow-cli-class1-platform
Jul 23, 2026
Merged

taosu0216 merged 11 commits into
mindfold-ai:mainfrom
BaSui01:feat/snow-cli-class1-platform

Conversation

@BaSui01

@BaSui01 BaSui01 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor

Summary

Add Snow CLI as a first-class Trellis platform.

This enables class-1 Trellis hosting on Snow without hardcoding Trellis into Snow itself:

  • auto context inject via Snow hooks
  • project agent discovery under .snow/agents/
  • beforeSubAgentStart prompt enrichment
  • multi-session active-task isolation via Snow session identity env

Why

Snow CLI now supports the contracts Trellis needs for automatic workflow context:

  1. successful hook stdout JSON → model-visible additionalContext
  2. project-level agents from .snow/agents/**/*.md
  3. beforeSubAgentStart
  4. child-process env: SNOW_SESSION_ID / TRELLIS_CONTEXT_ID / SNOW_CWD / SNOW_PLATFORM

Without a Trellis platform configurator, users still have to hand-wire skills/hooks/agents.

What this PR adds

Platform registration

  • AI_TOOLS.snow / CLI flag: --snow
  • configureSnow() writes project assets under .snow/
  • detection uses .snow/skills (avoids false positive on bare .snow/settings.json)

Generated project layout

Path Purpose
.snow/skills/trellis-* Trellis skills
.snow/commands/trellis-*.json prompt commands (continue / finish-work, …)
.snow/agents/*.md trellis-implement / trellis-check / trellis-research
.snow/hooks/* onSessionStart / onUserMessage / beforeSubAgentStart
.snow/hooks/write-trellis-context.py inject + breadcrumb writer
.snow/SNOW.md operator guide

Hook inject protocol

Stdout JSON (exit 0):

{ "additionalContext": "...", "display": "..." }

Modes:

Hook Mode Payload
onSessionStart session full context
onUserMessage user compact breadcrumb
beforeSubAgentStart subagent full + agent-kind tailoring

Also writes .snow/log/trellis-context.txt for pull-based agent reads.

Session identity

  • active_task.py now knows platform snow
  • resolves SNOW_SESSION_ID
  • canonical platform identifier: snow
  • still prefers explicit TRELLIS_CONTEXT_ID when present

Review hardening (latest tip)

  • rebased onto latest upstream/main (resolved prior conflicts)
  • no legacy .snow/sub-agents.trellis.json
  • no class-2 pull prelude on Snow agents
  • hook timeout 5s, session-scoped runtime lookup, UTF-8 byte truncate
  • user-mode compact inject does not clobber full log breadcrumb
  • execution tests for session/user/subagent modes

Usage

trellis init --snow -u your-name
snow

Expected behavior:

  1. new Snow session auto-injects Trellis context
  2. #trellis-implement / project agents are schedulable
  3. sub-agent start gets active-task breadcrumb
  4. child shells see SNOW_SESSION_ID + TRELLIS_CONTEXT_ID=snow-<id>

Tests

pnpm --filter @mindfoldhq/trellis exec vitest run test/configurators/platforms.test.ts -t "snow"
pnpm --filter @mindfoldhq/trellis exec vitest run test/templates/snow-write-trellis-context.test.ts
python -m py_compile packages/cli/src/templates/snow/hooks/write-trellis-context.py

Notes / compatibility

  • No Trellis core workflow semantics are changed for other platforms
  • trellis-start is filtered for Snow (hasHooks=true)
  • Windows: hook script drains empty stdin with timeout to avoid hang
  • Generated .snow/ project assets are intentionally not tracked in this repository

Test plan

  • trellis init --snow writes skills/commands/agents/hooks/SNOW.md
  • no trellis-start skill/command for Snow
  • hook script modes session / user / subagent present
  • active_task resolves SNOW_SESSION_ID
  • automated execution tests for inject modes + isolation + truncate
  • Reviewer: run trellis init --snow in a clean project and open Snow session
  • Reviewer: confirm first model turn receives injected Trellis context
  • Reviewer: schedule #trellis-implement / beforeSubAgentStart inject
  • Reviewer: task.py current/start works under Snow-injected env without manual TRELLIS_CONTEXT_ID

Summary by CodeRabbit

  • New Features
    • Added Snow CLI (--snow) support to initialization and platform configuration.
    • Snow projects now generate and manage .snow/ skills, commands, agents, hooks, and SNOW.md.
    • Enabled Snow CLI–aware session context and active-task resolution, including injected breadcrumbs for session, user, and sub-agent modes.
  • Documentation
    • Added/updated Snow CLI platform references and operator/workflow guidance templates.
  • Bug Fixes
    • Improved template file listing to ignore non-file entries.
  • Tests
    • Added end-to-end and hook execution tests covering Snow CLI generation, platform detection, and context injection behavior.

Copilot AI review requested due to automatic review settings July 17, 2026 10:32

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@coderabbitai

coderabbitai Bot commented Jul 17, 2026

Copy link
Copy Markdown

Review Change Stack

Note

Reviews paused

It looks like this branch is under active development. To avoid overwhelming you with review comments due to an influx of new commits, CodeRabbit has automatically paused this review. You can configure this behavior by changing the reviews.auto_review.auto_pause_after_reviewed_commits setting.

Use the following commands to manage reviews:

  • @coderabbitai resume to resume automatic reviews.
  • @coderabbitai review to trigger a single review.

Use the checkboxes below for quick actions:

  • ▶️ Resume reviews
  • 🔍 Trigger review
📝 Walkthrough

Walkthrough

Snow CLI support is added across CLI flags, platform metadata, template generation, Snow agents and hooks, session-context resolution, documentation, ignore rules, and integration tests.

Changes

Snow CLI platform integration

Layer / File(s) Summary
Platform plumbing and CLI registration
.agents/..., .trellis/..., packages/cli/src/cli/index.ts, packages/cli/src/commands/init.ts, packages/cli/src/types/ai-tools.ts, packages/cli/src/configurators/shared.ts, .gitignore, packages/cli/src/templates/common/...
Registers Snow identifiers, --snow, .snow metadata, session environment handling, shared configurator behavior, documentation maps, and generated-directory ignoring.
Snow templates and hook declarations
packages/cli/src/templates/snow/*, packages/cli/src/templates/template-utils.ts
Adds Snow agent prompts, hook JSON definitions, operator documentation, template discovery helpers, and regular-file filtering.
Snow artifact generation and persistence
packages/cli/src/configurators/index.ts, packages/cli/src/configurators/snow.ts
Collects and writes Snow skills, command JSON, agents, hooks, and SNOW.md under .snow/.
Runtime context hook
packages/cli/src/templates/snow/hooks/write-trellis-context.py
Resolves task, workflow, session, and sub-agent context; writes logs; truncates injected breadcrumbs; and emits fail-open JSON payloads.
Snow platform validation
packages/cli/test/configurators/*, packages/cli/test/templates/snow-write-trellis-context.test.ts
Validates platform configuration, generated assets, hook content, session modes, runtime selection, truncation, and fallback output.

Estimated code review effort: 4 (Complex) | ~60 minutes

Sequence Diagram(s)

sequenceDiagram
  participant SnowCLI
  participant SnowHook
  participant TrellisTaskScript
  participant SnowProjectFiles
  SnowCLI->>SnowHook: invoke session, user, or subagent hook
  SnowHook->>TrellisTaskScript: resolve current task and runtime context
  TrellisTaskScript-->>SnowHook: return task and workflow data
  SnowHook->>SnowProjectFiles: write breadcrumb log
  SnowHook-->>SnowCLI: return additionalContext and display JSON
Loading

Possibly related PRs

Suggested reviewers: cnhlaia

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 30.77% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title clearly and concisely summarizes the main change: adding Snow CLI as a first-class Trellis platform.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.
✨ Finishing Touches
🧪 Generate unit tests (beta)
  • Create PR with unit tests

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 4

🧹 Nitpick comments (1)
packages/cli/test/configurators/platforms.test.ts (1)

836-845: 📐 Maintainability & Code Quality | 🔵 Trivial | ⚡ Quick win

Execute the generated hook instead of only scanning its source.

These assertions pass even when mode resolution, JSON output, byte limits, session isolation, or log persistence are broken. Add fixture-based executions for session, user, and subagent, asserting parsed stdout and trellis-context.txt; verify Python availability in the declared CI toolchain.

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/test/configurators/platforms.test.ts` around lines 836 - 845,
Replace the source-string checks in the hookPy test with fixture-based
executions of the generated write-trellis-context.py hook for session, user, and
subagent modes. Assert parsed stdout plus trellis-context.txt contents, covering
mode resolution, JSON output, byte limits, session isolation, and
implement.jsonl persistence; also verify Python is available in the declared CI
toolchain.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/templates/snow/hooks/write-trellis-context.py`:
- Around line 539-545: Update the user-message hook’s log-writing flow around
trellis-context.txt so it never overwrites the full breadcrumb with compact
user-mode context. Preserve the existing full snapshot when available, or
generate and write refreshed full log context separately, while keeping the
compact context for injection behavior.
- Around line 369-381: Update the session-file fallback in the context-writing
flow to select only the runtime session identified by TRELLIS_CONTEXT_ID or
SNOW_SESSION_ID, rather than sorting all files by modification time. If neither
identifier is available or no matching session file exists, omit this fallback
and do not populate body from another session.
- Around line 67-85: Reduce the subprocess timeout in _run from 15 seconds to a
value below Snow’s hook timeout, such as five seconds, so stalled task.py
executions finish fail-open before the parent hook is terminated. Keep the
existing output and exception handling unchanged.
- Around line 522-525: Update _truncate to enforce max_bytes using UTF-8 encoded
byte length rather than character count. Preserve text unchanged when its UTF-8
representation fits; otherwise truncate on a valid UTF-8 character boundary and
append the existing truncation marker while ensuring the final encoded result
does not exceed max_bytes.

---

Nitpick comments:
In `@packages/cli/test/configurators/platforms.test.ts`:
- Around line 836-845: Replace the source-string checks in the hookPy test with
fixture-based executions of the generated write-trellis-context.py hook for
session, user, and subagent modes. Assert parsed stdout plus trellis-context.txt
contents, covering mode resolution, JSON output, byte limits, session isolation,
and implement.jsonl persistence; also verify Python is available in the declared
CI toolchain.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 50196b64-e496-4e95-a1a9-17a308572df9

📥 Commits

Reviewing files that changed from the base of the PR and between 51a5674 and 5310123.

📒 Files selected for processing (21)
  • .agents/skills/trellis-meta/references/platform-files/platform-map.md
  • .trellis/scripts/common/active_task.py
  • packages/cli/src/cli/index.ts
  • packages/cli/src/commands/init.ts
  • packages/cli/src/configurators/index.ts
  • packages/cli/src/configurators/shared.ts
  • packages/cli/src/configurators/snow.ts
  • packages/cli/src/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md
  • packages/cli/src/templates/snow/SNOW.md
  • packages/cli/src/templates/snow/agents/trellis-check.md
  • packages/cli/src/templates/snow/agents/trellis-implement.md
  • packages/cli/src/templates/snow/agents/trellis-research.md
  • packages/cli/src/templates/snow/hooks/beforeSubAgentStart.json
  • packages/cli/src/templates/snow/hooks/onSessionStart.json
  • packages/cli/src/templates/snow/hooks/onUserMessage.json
  • packages/cli/src/templates/snow/hooks/write-trellis-context.py
  • packages/cli/src/templates/snow/index.ts
  • packages/cli/src/templates/template-utils.ts
  • packages/cli/src/templates/trellis/scripts/common/active_task.py
  • packages/cli/src/types/ai-tools.ts
  • packages/cli/test/configurators/platforms.test.ts

Comment thread packages/cli/src/templates/snow/hooks/write-trellis-context.py
Comment thread packages/cli/src/templates/snow/hooks/write-trellis-context.py Outdated
Comment thread packages/cli/src/templates/snow/hooks/write-trellis-context.py Outdated
Comment thread packages/cli/src/templates/snow/hooks/write-trellis-context.py Outdated
@BaSui01

BaSui01 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up: CodeRabbit review fixes

Pushed fix(snow): address CodeRabbit review on write-trellis-context.

Addressed

  1. Subprocess timeout: task.py child timeout 15s5s (below Snow user/subagent hook timeout) so fail-open JSON can still emit.
  2. Session isolation: runtime session lookup no longer picks newest file by mtime; only resolves current session via TRELLIS_CONTEXT_ID / SNOW_SESSION_ID / stdin sessionId.
  3. UTF-8 byte limits: _truncate now enforces max size in UTF-8 bytes.
  4. Full breadcrumb preservation: user-mode inject stays compact, but .snow/log/trellis-context.txt is refreshed with full session context instead of being clobbered by compact output.

Validation

  • python -m py_compile packages/cli/src/templates/snow/hooks/write-trellis-context.py
  • UTF-8 truncate unit check
  • vitest Snow configurator test passed

@BaSui01

BaSui01 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

Note on PR base branch

This PR is intentionally opened as:

  • head: BaSui01:feat/snow-cli-class1-platform (feature branch)
  • base: mindfold-ai/Trellis:main

I do not have push permission on mindfold-ai/Trellis, so I cannot create/push an official long-lived base branch such as feat/snow-cli myself.

If maintainers prefer this work to land onto a dedicated integration branch first (e.g. feat/snow-cli), please create that branch from current main and I can retarget this PR immediately.

@BaSui01

BaSui01 commented Jul 17, 2026

Copy link
Copy Markdown
Contributor Author

请维护者确认 base 分支

@taosu0216 你好 👋

本 PR 当前是:

  • head: BaSui01:feat/snow-cli-class1-platform(功能分支,已就绪)
  • base: main

我这边对 mindfold-ai/Trellis 没有 push 权限,无法自行创建官方 feat/snow-cli 分支。

如果你们希望先合到独立功能分支(而不是直接进 main),麻烦帮忙:

git checkout main && git pull
git checkout -b feat/snow-cli
git push origin feat/snow-cli

建好后我可以立刻把本 PR retarget 到 feat/snow-cli
如果官方惯例仍是平台适配直接进 main(参考 Grok 等平台 PR),那当前 base=main 也可以,按你们习惯即可。

感谢!

@BaSui01
BaSui01 force-pushed the feat/snow-cli-class1-platform branch from f8edeec to 462f232 Compare July 18, 2026 06:23

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.agents/skills/trellis-meta/references/platform-files/platform-map.md:
- Line 50: Synchronize the two platform maps: in
.agents/skills/trellis-meta/references/platform-files/platform-map.md at line
50, remove the inaccurate “pull-based prelude” wording while retaining Snow’s
auto-discovered hooks and optional legacy sub-agent configuration; in
packages/cli/src/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md
at line 27, add Snow to the “Trellis Sub-Agent Support” list using the same
hook-injection wording.

In `@packages/cli/src/templates/snow/hooks/write-trellis-context.py`:
- Around line 115-145: The _jsonl_summaries function currently retains the
earliest entries despite callers expecting recent entries. Continue scanning the
entire JSONL file, maintain only the latest max_items summaries in file order,
and return those retained entries while preserving existing parsing, truncation,
and formatting behavior.

In `@packages/cli/test/configurators/platforms.test.ts`:
- Line 886: Update the agents declaration in the affected test fixture to use
the repository-approved array type syntax required by the
`@typescript-eslint/array-type` rule, preserving the existing element shape of id
and tools.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 4fb36383-05ed-4da5-b1c5-7f50ba9e57a4

📥 Commits

Reviewing files that changed from the base of the PR and between f8edeec and 462f232.

📒 Files selected for processing (22)
  • .agents/skills/trellis-meta/references/platform-files/platform-map.md
  • .trellis/scripts/common/active_task.py
  • packages/cli/src/cli/index.ts
  • packages/cli/src/commands/init.ts
  • packages/cli/src/configurators/index.ts
  • packages/cli/src/configurators/shared.ts
  • packages/cli/src/configurators/snow.ts
  • packages/cli/src/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md
  • packages/cli/src/templates/markdown/agents.md
  • packages/cli/src/templates/snow/SNOW.md
  • packages/cli/src/templates/snow/agents/trellis-check.md
  • packages/cli/src/templates/snow/agents/trellis-implement.md
  • packages/cli/src/templates/snow/agents/trellis-research.md
  • packages/cli/src/templates/snow/hooks/beforeSubAgentStart.json
  • packages/cli/src/templates/snow/hooks/onSessionStart.json
  • packages/cli/src/templates/snow/hooks/onUserMessage.json
  • packages/cli/src/templates/snow/hooks/write-trellis-context.py
  • packages/cli/src/templates/snow/index.ts
  • packages/cli/src/templates/template-utils.ts
  • packages/cli/src/templates/trellis/scripts/common/active_task.py
  • packages/cli/src/types/ai-tools.ts
  • packages/cli/test/configurators/platforms.test.ts
🚧 Files skipped from review as they are similar to previous changes (14)
  • packages/cli/src/templates/snow/hooks/onUserMessage.json
  • packages/cli/src/templates/snow/hooks/onSessionStart.json
  • packages/cli/src/templates/snow/hooks/beforeSubAgentStart.json
  • packages/cli/src/templates/template-utils.ts
  • .trellis/scripts/common/active_task.py
  • packages/cli/src/templates/snow/agents/trellis-research.md
  • packages/cli/src/configurators/shared.ts
  • packages/cli/src/templates/snow/index.ts
  • packages/cli/src/templates/snow/SNOW.md
  • packages/cli/src/cli/index.ts
  • packages/cli/src/templates/snow/agents/trellis-implement.md
  • packages/cli/src/types/ai-tools.ts
  • packages/cli/src/templates/snow/agents/trellis-check.md
  • packages/cli/src/configurators/index.ts

Comment thread .agents/skills/trellis-meta/references/platform-files/platform-map.md Outdated
Comment thread packages/cli/src/templates/snow/hooks/write-trellis-context.py
"utf-8",
),
) as {
agents: Array<{ id: string; tools: string[] }>;

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Use the repository-approved array type syntax.

This declaration violates the configured @typescript-eslint/array-type rule.

Proposed fix
-      agents: Array<{ id: string; tools: string[] }>;
+      agents: { id: string; tools: string[] }[];
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
agents: Array<{ id: string; tools: string[] }>;
agents: { id: string; tools: string[] }[];
🧰 Tools
🪛 ESLint

[error] 886-886: Array type using 'Array' is forbidden. Use 'T[]' instead.

(@typescript-eslint/array-type)

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/test/configurators/platforms.test.ts` at line 886, Update the
agents declaration in the affected test fixture to use the repository-approved
array type syntax required by the `@typescript-eslint/array-type` rule, preserving
the existing element shape of id and tools.

Source: Linters/SAST tools

@BaSui01
BaSui01 force-pushed the feat/snow-cli-class1-platform branch from 462f232 to d55bd58 Compare July 21, 2026 03:41
@BaSui01

BaSui01 commented Jul 21, 2026

Copy link
Copy Markdown
Contributor Author

Follow-up: rebased onto latest upstream/main + review hardening

PR tip rewritten on top of current upstream/main (was ~20 commits behind and CONFLICTING).

What changed since previous tip

  1. Rebase / resynthesis
  2. Class-1 final shape
    • No legacy .snow/sub-agents.trellis.json
    • No class-2 pull-based prelude on Snow agents
    • Primary path remains .snow/agents/*.md + inject hooks
  3. CodeRabbit hardening retained/improved
    • write-trellis-context.py child timeout 5s
    • Session-scoped runtime lookup (no mtime cross-session pick)
    • UTF-8 byte truncation
    • User-mode inject stays compact; .snow/log/trellis-context.txt keeps full snapshot
  4. Dogfood
    • Project .snow/ assets committed (skills/commands/agents/hooks/SNOW.md/settings)
    • Runtime ignored: .snow/log/, .snow/notebook/, .snow/permissions.json, legacy JSON
  5. Tests
    • Existing Snow configurator assertions extended
    • New execution tests: test/templates/snow-write-trellis-context.test.ts
      • session / user / subagent modes
      • session isolation
      • UTF-8 truncate
      • fail-open JSON

Validation

pnpm --filter @mindfoldhq/trellis exec vitest run test/configurators/platforms.test.ts -t "snow"
pnpm --filter @mindfoldhq/trellis exec vitest run test/templates/snow-write-trellis-context.test.ts
python -m py_compile packages/cli/src/templates/snow/hooks/write-trellis-context.py

Note for reviewers

  • Head history was rewritten (force-with-lease) because the previous tip diverged from local synthesis on latest main.
  • Please re-run a clean trellis init --snow smoke + Snow session inject check if convenient.

@BaSui01
BaSui01 requested a review from Copilot July 21, 2026 03:43

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Copilot was unable to review this pull request because the user who requested the review has reached their quota limit.

@taosu0216

Copy link
Copy Markdown
Contributor

Thanks for the PR — this is a serious integration effort, and we've verified the core work is solid: the hook contract matches upstream snow-cli (checked against hooksConfig.ts / hookContextInject.ts on main), the templates/configurator/tests follow the existing platform patterns, and the full test suite passes locally. The ~2100 lines of templates + source + tests are close to mergeable quality.

Before we can merge, four things need to change:

1. Remove .snow/settings.json (blocker)
This file contains your personal Snow config, including "yoloMode": true. Anyone who clones this repo and opens Snow would silently get auto-approval mode. Please delete it and add it to the dogfood .gitignore entries.

2. Regenerate or drop the .snow/ dogfood directory (blocker)
The committed .snow/ tree (~6.1k lines, 74% of the diff) was generated on Windows: files contain CRLF line endings and commands are rendered as python instead of python3. On macOS/Linux this both breaks execution (python usually doesn't exist) and causes a full-directory churn the next time anyone re-syncs dogfood. Either drop the directory from this PR (our preference — the Grok integration #433 didn't ship dogfood either) or regenerate it in an LF/python3 environment.

3. Drop the snocli alias everywhere
snocli doesn't exist as a name: the npm package is snow-ai, the binary is snow, and the upstream repo has zero occurrences of "snocli". Please remove it from the PR title, CliFlag type, --snocli flag, resolveCliFlag special-case, and _ENV_PLATFORM_ALIASES — keep only --snow.

4. Fix the configured-platform detection to match its own comment
In getConfiguredPlatforms, the comment says configDir is .snow/skills to avoid false positives, but the code right below also accepts bare .snow/commands / .snow/agents — which are exactly the directories ordinary Snow users create for their own (non-Trellis) commands and agents. A Snow user who never opted into Trellis would get Trellis files written into their .snow/ on trellis update. Please remove the OR clause and detect only .snow/skills.

One more process note: platform additions normally go through the tracking epic #349 first (comment there to claim) — we'll add a Snow evaluation entry there. Given snow-cli's traction the evaluation itself isn't a concern, but note this integration depends on the hook contract that only landed in snow-ai 0.8.18 a few days ago, so we'd like to see it hold stable on the user side before shipping.

@BaSui01 BaSui01 changed the title feat(cli): add Snow CLI (snocli) as class-1 Trellis platform feat(cli): add Snow CLI as class-1 Trellis platform Jul 23, 2026
BaSui03 added 3 commits July 23, 2026 14:16
Wire trellis init --snow/--snocli to write .snow skills, prompt commands,
project agents, and inject hooks (session/user/beforeSubAgentStart) that
emit additionalContext for snow-cli#194-compatible hosts.
Drain host-piped hook context with a short timeout on Windows so manual
CLI runs and TTY invocations do not block on stdin.read().
- Teach active_task resolver about snow platform + SNOW_SESSION_ID
- Expand write-trellis-context modes (session/user/subagent)
- Document session identity env contract in SNOW.md
- Strengthen Snow platform configurator tests

Note: full-suite pre-commit has pre-existing unrelated failures
(cursor/trae/reasonix/omp/atomic-write). Snow-specific tests pass.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actionable comments posted: 3

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In @.agents/skills/trellis-meta/references/platform-files/platform-map.md:
- Line 22: The Pi Agent skill directory must be consistent across both platform
maps. Keep the
`.agents/skills/trellis-meta/references/platform-files/platform-map.md` entry as
`.pi/skills/`; update the Pi Agent Skill directory entry at
`packages/cli/src/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md:22-22`
from `.agents/skills/` to `.pi/skills/`.

In `@packages/cli/src/configurators/snow.ts`:
- Around line 62-69: Update collectSnowStaticFiles and the hook-writing path in
configureSnow to apply replacePythonCommandLiterals(hook.content) consistently
when building tracked Snow hook content and writing files, matching the existing
command handling. Preserve shebang-aware substitution and ensure the
.snow/hooks/* template content exactly matches the bytes configureSnow writes.

In `@packages/cli/src/templates/snow/hooks/write-trellis-context.py`:
- Around line 478-483: Memoize the task.py current --source result for the
duration of a single hook invocation. Update build_context and its callers so
the first build_context call performs the _run invocation and the second reuses
the cached current output, while preserving _parse_active_task_path behavior and
existing user-mode compact/full context generation.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 64f5900d-7074-44f6-a45c-627e4c33485e

📥 Commits

Reviewing files that changed from the base of the PR and between 462f232 and 2860d05.

📒 Files selected for processing (25)
  • .agents/skills/trellis-meta/references/platform-files/platform-map.md
  • .gitignore
  • .trellis/scripts/common/active_task.py
  • packages/cli/src/cli/index.ts
  • packages/cli/src/commands/init.ts
  • packages/cli/src/configurators/index.ts
  • packages/cli/src/configurators/shared.ts
  • packages/cli/src/configurators/snow.ts
  • packages/cli/src/templates/common/bundled-skills/trellis-meta/references/platform-files/overview.md
  • packages/cli/src/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md
  • packages/cli/src/templates/snow/SNOW.md
  • packages/cli/src/templates/snow/agents/trellis-check.md
  • packages/cli/src/templates/snow/agents/trellis-implement.md
  • packages/cli/src/templates/snow/agents/trellis-research.md
  • packages/cli/src/templates/snow/hooks/beforeSubAgentStart.json
  • packages/cli/src/templates/snow/hooks/onSessionStart.json
  • packages/cli/src/templates/snow/hooks/onUserMessage.json
  • packages/cli/src/templates/snow/hooks/write-trellis-context.py
  • packages/cli/src/templates/snow/index.ts
  • packages/cli/src/templates/template-utils.ts
  • packages/cli/src/templates/trellis/scripts/common/active_task.py
  • packages/cli/src/types/ai-tools.ts
  • packages/cli/test/configurators/index.test.ts
  • packages/cli/test/configurators/platforms.test.ts
  • packages/cli/test/templates/snow-write-trellis-context.test.ts
🚧 Files skipped from review as they are similar to previous changes (10)
  • packages/cli/src/templates/snow/hooks/onUserMessage.json
  • packages/cli/src/templates/snow/hooks/onSessionStart.json
  • packages/cli/src/templates/snow/hooks/beforeSubAgentStart.json
  • packages/cli/src/templates/snow/index.ts
  • packages/cli/src/configurators/shared.ts
  • packages/cli/src/templates/snow/SNOW.md
  • packages/cli/src/templates/template-utils.ts
  • packages/cli/src/templates/snow/agents/trellis-research.md
  • packages/cli/src/templates/snow/agents/trellis-check.md
  • packages/cli/src/templates/snow/agents/trellis-implement.md

| CodeBuddy | `--codebuddy` | `.codebuddy/` | `.codebuddy/skills/` | `.codebuddy/agents/` | `.codebuddy/hooks/` + `.codebuddy/settings.json` |
| GitHub Copilot | `--copilot` | `.github/` | `.github/skills/` | `.github/agents/` | `.github/copilot/hooks/` + prompts |
| Factory Droid | `--droid` | `.factory/` | `.factory/skills/` | `.factory/droids/` | `.factory/hooks/` + settings |
| Pi Agent | `--pi` | `.pi/` | `.pi/skills/` | `.pi/agents/` | `.pi/extensions/trellis/` (native `trellis_subagent` tool) + `.pi/settings.json` |

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

📐 Maintainability & Code Quality | 🟡 Minor | ⚡ Quick win

Pi Agent's Skill directory disagrees between the two platform maps. One canonical doc says .pi/skills/, the other says .agents/skills/; the "Shared .agents/skills/" section in both files names only Codex and Gemini CLI as writers of that shared layer, so the bundled copy's .agents/skills/ entry for Pi Agent looks like a stale copy/paste from the Codex/Gemini rows.

  • .agents/skills/trellis-meta/references/platform-files/platform-map.md#L22-L22: keep as .pi/skills/ (consistent with the Shared-skills section).
  • packages/cli/src/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md#L22-L22: change Pi Agent's Skill directory column from .agents/skills/ to .pi/skills/ to match.
📍 Affects 2 files
  • .agents/skills/trellis-meta/references/platform-files/platform-map.md#L22-L22 (this comment)
  • packages/cli/src/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md#L22-L22
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In @.agents/skills/trellis-meta/references/platform-files/platform-map.md at
line 22, The Pi Agent skill directory must be consistent across both platform
maps. Keep the
`.agents/skills/trellis-meta/references/platform-files/platform-map.md` entry as
`.pi/skills/`; update the Pi Agent Skill directory entry at
`packages/cli/src/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md:22-22`
from `.agents/skills/` to `.pi/skills/`.

Comment thread packages/cli/src/configurators/snow.ts
Comment on lines +478 to +483
task_py = repo / ".trellis" / "scripts" / "task.py"
current = ""
task_dir: Path | None = None
if task_py.is_file():
py = sys.executable or "python3"
current = _run([py, "-X", "utf8", str(task_py), "current", "--source"], repo)

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🩺 Stability & Availability | 🟠 Major | ⚡ Quick win

User-mode hook now runs task.py twice, doubling timeout exposure.

When mode == "user", build_context() is invoked twice (compact at Line 591, full at Line 601), and each call independently re-invokes _run(...) against task.py (Line 483). The _run timeout was deliberately set to 5s specifically to leave headroom under Snow's 15s hook timeout (comment at Lines 77-79), but two sequential 5s-bounded subprocess calls can now consume up to ~10s before the rest of the hook logic even runs — eroding most of that headroom on the most frequently-fired hook (every user message).

Memoize the task.py current --source output for the duration of one hook invocation so the second build_context call reuses it instead of re-spawning the process.

🔧 Proposed fix: memoize the task.py subprocess call
+import functools
+
+
+@functools.lru_cache(maxsize=4)
+def _cached_task_current(task_py: Path, repo: Path) -> str:
+    py = sys.executable or "python3"
+    return _run([py, "-X", "utf8", str(task_py), "current", "--source"], repo)
+
+
 def build_context(
     repo: Path,
     *,
     mode: str,
     stdin_ctx: dict[str, Any],
 ) -> str:
     ...
     task_py = repo / ".trellis" / "scripts" / "task.py"
     current = ""
     task_dir: Path | None = None
     if task_py.is_file():
-        py = sys.executable or "python3"
-        current = _run([py, "-X", "utf8", str(task_py), "current", "--source"], repo)
+        current = _cached_task_current(task_py, repo)
         lines.extend(["## task.py current --source", "```", current, "```", ""])
         task_dir = _parse_active_task_path(current, repo)

Also applies to: 591-602

🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/templates/snow/hooks/write-trellis-context.py` around lines
478 - 483, Memoize the task.py current --source result for the duration of a
single hook invocation. Update build_context and its callers so the first
build_context call performs the _run invocation and the second reuses the cached
current output, while preserving _parse_active_task_path behavior and existing
user-mode compact/full context generation.

@BaSui01
BaSui01 force-pushed the feat/snow-cli-class1-platform branch from 2860d05 to e5bb249 Compare July 23, 2026 06:27
taosu added 2 commits July 23, 2026 14:30
…ce mirror sync

Snow is class-1 hook-backed like ZCode but was absent from every workflow.md
platform list after the PR slim-down, so Snow sessions would miss the
sub-agent dispatch and jsonl-curation guidance. Added beside ZCode in all 13
marker lists + the dispatch-protocol prose (template + dogfood), with the
marketplace mirror synced and the submodule pointer bumped.

@coderabbitai coderabbitai Bot left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

♻️ Duplicate comments (1)
packages/cli/src/configurators/snow.ts (1)

62-69: 🗄️ Data Integrity & Integration | 🟠 Major | ⚡ Quick win

collectSnowStaticFiles still diverges from what configureSnow writes — unresolved from a prior review round.

collectSnowStaticFiles (used by collectSnowTemplates for trellis update hash tracking) stores raw hook.content, while configureSnow (Lines 138-143) writes replacePythonCommandLiterals(hook.content) to disk. Whenever the resolved Python command differs from the literal in the template, the tracked hash for .snow/hooks/* won't match the actual file bytes, breaking trellis update's modification detection for Snow hooks — same as flagged previously; the code here is unchanged.

🐛 Proposed fix
 function collectSnowStaticFiles(): Map<string, string> {
   const files = new Map<string, string>();
   for (const hook of getAllHooks()) {
-    files.set(`.snow/hooks/${hook.targetPath}`, hook.content);
+    files.set(
+      `.snow/hooks/${hook.targetPath}`,
+      replacePythonCommandLiterals(hook.content),
+    );
   }
   files.set(".snow/SNOW.md", getSnowGuide());
   return files;
 }
🤖 Prompt for AI Agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

In `@packages/cli/src/configurators/snow.ts` around lines 62 - 69, Update
collectSnowStaticFiles to store each hook’s content after applying
replacePythonCommandLiterals, matching the transformation used by configureSnow
before writing .snow/hooks files. Keep the existing hook target paths and Snow
guide handling unchanged so update hash tracking reflects the actual disk
contents.
🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Duplicate comments:
In `@packages/cli/src/configurators/snow.ts`:
- Around line 62-69: Update collectSnowStaticFiles to store each hook’s content
after applying replacePythonCommandLiterals, matching the transformation used by
configureSnow before writing .snow/hooks files. Keep the existing hook target
paths and Snow guide handling unchanged so update hash tracking reflects the
actual disk contents.

ℹ️ Review info
⚙️ Run configuration

Configuration used: defaults

Review profile: CHILL

Plan: Pro Plus

Run ID: 5ac5210d-771b-46af-94ad-37d1b7c9cc83

📥 Commits

Reviewing files that changed from the base of the PR and between 2860d05 and e5bb249.

📒 Files selected for processing (25)
  • .agents/skills/trellis-meta/references/platform-files/platform-map.md
  • .gitignore
  • .trellis/scripts/common/active_task.py
  • packages/cli/src/cli/index.ts
  • packages/cli/src/commands/init.ts
  • packages/cli/src/configurators/index.ts
  • packages/cli/src/configurators/shared.ts
  • packages/cli/src/configurators/snow.ts
  • packages/cli/src/templates/common/bundled-skills/trellis-meta/references/platform-files/overview.md
  • packages/cli/src/templates/common/bundled-skills/trellis-meta/references/platform-files/platform-map.md
  • packages/cli/src/templates/snow/SNOW.md
  • packages/cli/src/templates/snow/agents/trellis-check.md
  • packages/cli/src/templates/snow/agents/trellis-implement.md
  • packages/cli/src/templates/snow/agents/trellis-research.md
  • packages/cli/src/templates/snow/hooks/beforeSubAgentStart.json
  • packages/cli/src/templates/snow/hooks/onSessionStart.json
  • packages/cli/src/templates/snow/hooks/onUserMessage.json
  • packages/cli/src/templates/snow/hooks/write-trellis-context.py
  • packages/cli/src/templates/snow/index.ts
  • packages/cli/src/templates/template-utils.ts
  • packages/cli/src/templates/trellis/scripts/common/active_task.py
  • packages/cli/src/types/ai-tools.ts
  • packages/cli/test/configurators/index.test.ts
  • packages/cli/test/configurators/platforms.test.ts
  • packages/cli/test/templates/snow-write-trellis-context.test.ts
🚧 Files skipped from review as they are similar to previous changes (14)
  • packages/cli/src/cli/index.ts
  • .trellis/scripts/common/active_task.py
  • packages/cli/test/configurators/index.test.ts
  • packages/cli/src/templates/template-utils.ts
  • packages/cli/src/templates/snow/hooks/onUserMessage.json
  • packages/cli/src/configurators/index.ts
  • .agents/skills/trellis-meta/references/platform-files/platform-map.md
  • .gitignore
  • packages/cli/src/templates/snow/agents/trellis-implement.md
  • packages/cli/src/templates/snow/agents/trellis-check.md
  • packages/cli/src/templates/snow/agents/trellis-research.md
  • packages/cli/src/configurators/shared.ts
  • packages/cli/src/templates/snow/index.ts
  • packages/cli/src/templates/snow/SNOW.md

@taosu0216
taosu0216 merged commit 3dc7ba0 into mindfold-ai:main Jul 23, 2026
1 check passed
Xio-Shark pushed a commit to Xio-Shark/Trellis that referenced this pull request Sep 17, 2026
* feat(cli): add Snow CLI (snocli) class-1 platform support

Wire trellis init --snow/--snocli to write .snow skills, prompt commands,
project agents, and inject hooks (session/user/beforeSubAgentStart) that
emit additionalContext for snow-cli#194-compatible hosts.

* fix(snow): avoid hanging write-trellis-context.py on empty stdin

Drain host-piped hook context with a short timeout on Windows so manual
CLI runs and TTY invocations do not block on stdin.read().

* feat(snow): complete latest Snow session-identity adaptation

- Teach active_task resolver about snow platform + SNOW_SESSION_ID
- Expand write-trellis-context modes (session/user/subagent)
- Document session identity env contract in SNOW.md
- Strengthen Snow platform configurator tests

Note: full-suite pre-commit has pre-existing unrelated failures
(cursor/trae/reasonix/omp/atomic-write). Snow-specific tests pass.

* feat(snow): drop legacy sub-agent JSON and class-2 pull prelude

* fix(snow): harden class-1 inject and align agent docs

* chore(snow): dogfood project .snow assets for clone-and-use

* test(snow): execute write-trellis-context session/user/subagent modes

* fix(snow): address maintainer review blockers

* test(cli): align platform expectations after rebase

* feat(snow): add Snow to workflow.md platform marker lists + marketplace mirror sync

Snow is class-1 hook-backed like ZCode but was absent from every workflow.md
platform list after the PR slim-down, so Snow sessions would miss the
sub-agent dispatch and jsonl-curation guidance. Added beside ZCode in all 13
marker lists + the dispatch-protocol prose (template + dogfood), with the
marketplace mirror synced and the submodule pointer bumped.

* test: include Snow in hook-platform marker expectations

---------

Co-authored-by: BaSui <basui0103@gmail.com>
Co-authored-by: taosu <taosu@mindfold.ai>
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.

4 participants