chore: sync upstream feat/v0.6.0-beta into main (preserve i18n)#3
Merged
Conversation
added 30 commits
May 4, 2026 12:49
Search and drill into past Claude Code / Codex / OpenCode sessions without leaving the project. Five subcommands wired through commander as a passthrough group: `projects`, `list`, `search`, `context`, `extract`. Cleans hook injections, AGENTS.md preambles, tool noise, and handles compaction so search hits reflect real dialogue. Source originated as a POC at nb_project/mem-poc; integrated here with ESLint/TS adjustments (interface over type aliases, no non-null assertions, `unknown` callback return for readJsonl). Adds zod ^4 as a runtime dep.
Codex multi_agent_v2 fires SessionStart for each spawned sub-agent. The hook indiscriminately injected "dispatch trellis-implement" guidance into every session, causing a freshly-spawned trellis-implement sub-agent to re-read it and spawn another same-name sub-agent — an outer wrapper agent stayed `running` forever while the inner one completed, blocking `wait_agent` in the main session. Codex SessionStart stdin currently exposes no agent-identity field (upstream openai/codex#16226 OPEN), so detect-and-skip in the hook is not feasible. Mitigate at the prompt layer instead: - B (hard guard): prepend a Recursion guard block to `developer_instructions` in trellis-implement.toml / trellis-check.toml forbidding spawn of trellis-implement / trellis-check. - A-soft (wording softening): add a Sub-agent self-exemption clause to both the READY-state guidance and the `<guidelines>` block of codex/hooks/session-start.py. Tests cover both layers via keyword assertions in templates/codex.test.ts.
Per the "Audit ALL Writers" rule (spec/cli/backend/quality-guidelines.md), the dispatch wording also lives in shared-hooks/session-start.py — used by Claude / Cursor / Gemini / Qoder / CodeBuddy / Droid / Kiro. Mirror the codex-side A-soft clause in both injection sites (READY-state block + `<guidelines>` block) so non-Codex sub-agents do not regress when they hit the same recursion-prone wording. Test asserts the self-exemption clause appears in both locations.
Cursor's agent definition parser only recognizes inline literal descriptions; it leaves the UI Description field blank when frontmatter uses YAML block scalars (`description: |\n body`). The trellis-research / trellis-implement / trellis-check agents shipped with block scalars, so the agents appeared unconfigured in the Cursor UI. Collapse the three frontmatters to single-line `description: <body>` literals; body content preserved verbatim. Adds templates/cursor.test.ts asserting parsed `description` is a single-line string for all three agent files.
PRD, curated implement.jsonl / check.jsonl, and research findings for the codex sub-agent recursion + cursor description format fix (commits 9768b08, 0f3c706, d8efcbc). Research file documents why A-hard (stdin agent_id detection) is not yet feasible — pending upstream openai/codex#16226.
…ent-description-format
…h-in-session-start-hooks
# Conflicts: # .trellis/workspace/taosu/index.md # .trellis/workspace/taosu/journal-5.md
PRD + 2 research files (CLAUDE_ENV_FILE / windows env injection; sub-agent dispatch + context injection) backing the 0.5.3 fix direction: marker-based hook fallback in sub-agent definitions + non-blocking task.py start when no session identity.
…ows-for-hook-session-identity
Class-1 platforms (claude / cursor / opencode / kiro / codebuddy /
droid) inject sub-agent context (prd.md + implement.jsonl /
check.jsonl) via PreToolUse hook. The hook silent-skips on Windows
at v2.1.119 (upstream openai/codex-style bug, anthropics/claude-code
#53254), and the existing sub-agent definition files trust the hook
to always fire — no fallback exists. Sub-agents that don't receive
the hook injection ran with no context, the AI then "强行" patched
forward without specs.
Add marker-based dual-channel context loading:
1. inject-subagent-context.py: prepend `<!-- trellis-hook-injected -->`
sentinel marker to the build_implement_prompt / build_check_prompt /
build_finish_prompt outputs. The marker is only emitted on the
hook-success path.
2. Sub-agent definition files: each class-1 trellis-implement /
trellis-check definition now opens with a `Trellis Context Loading
Protocol` section. The sub-agent checks for the marker:
- Present → hook injected; proceed with implementation directly.
- Absent → hook didn't fire (Windows / --continue / fork); read
Active task path from the dispatch prompt's first line, then
Read prd.md + the relevant jsonl file yourself.
3. workflow.md: dispatch protocol scope changed from "class-2
platforms" to "all platforms, all sub-agents EXCEPT trellis-research".
Class-1 hook success path ignores the line; failure path uses it.
trellis-research is intentionally not marker'd — research is decoupled
from active task and has its own spec-tree context loader.
class-2 platforms (codex / copilot / gemini / qoder) untouched —
they already use buildPullBasedPrelude.
`task.py start` previously hard-failed (return 1) when `resolve_context_key()` returned None — i.e. when no SessionStart hook had injected `TRELLIS_CONTEXT_ID`. The error message blamed the AI session, but the real cause is upstream: Windows + Claude Code didn't source CLAUDE_ENV_FILE pre-v2.1.111 and still skips PowerShell tool / `--continue` resume paths. The AI then "强行" patched forward, producing inconsistent state. Replace the hard-fail with a yellow-tagged degraded-mode warning, still flip task.json.status (planning → in_progress), and return 0 so the AI continues based on conversation context. Happy path (resolve_context_key truthy) is byte-identical to before. Only the else branch changes.
Cover the 0.5.3 fixes: - HOOK_INJECTED_MARKER constant pinned and asserted across all 13 writer sites (3 hook builders + 10 markdown agent files + 2 Kiro JSON files), enforcing the Audit ALL Writers contract from spec/cli/backend/quality-guidelines.md. - Each class-1 sub-agent file is asserted to carry the protocol heading + Active task: + prd.md + matching jsonl filename, via keyword assertions (no whole-section hardcoding). - workflow.md dispatch protocol is asserted to cover all sub-agents rather than the prior class-2-only language. - task.py start under absent context_key is asserted to print a degraded-mode warning, still flip planning → in_progress, and return 0 (split into two tests for the two surfaces).
# Conflicts: # .trellis/workspace/taosu/index.md # .trellis/workspace/taosu/journal-5.md
…nd-non-blocking-task-py-start
…coverage) `packages/cli/src/commands/mem.ts` was integrated to feat/v0.6.0-beta as a 1461-LoC POC drop in commit e1b368d with zero unit tests. Adds coverage before 0.6 GA so platform-specific parsing edge cases (Claude Code / Codex / OpenCode session formats) and dialogue-cleaning logic don't silently break when upstream session schemas evolve. mem.ts changes: - Surgical: only `export` annotations on the 18 helpers + parsers listed in the PRD. No logic edits, no rename, no refactor. Prettier auto-wrapped `isBootstrapTurn`'s signature when `export ` pushed it past 80 cols (whitespace only). New tests (1499 LoC across 3 files, 84 tests): - test/commands/mem-helpers.test.ts (422 LoC, 44 tests) — Tier 1 pure helpers: relevanceScore, parseArgv, buildFilter, inRange, sameProject, isBootstrapTurn, stripInjectionTags, chunkAround, searchInDialogue, shortDate, shortPath. Each ≥3 cases (happy + edges). - test/commands/mem-platforms.test.ts (781 LoC, 24 tests) — Tier 2 fixture-driven parsers for Claude / Codex / OpenCode. vi.mock node:os to point HOME at per-suite tmpdir; minimal inline fixtures cover empty sessions, bootstrap-only filtering, injection-tag cleaning, compaction (Claude isCompactSummary + Codex compacted events), synthetic-part dropping (OpenCode), and date / cwd filter behavior. - test/commands/mem-integration.test.ts (296 LoC, 16 tests) — Tier 3 runMem(args) smoke for all 5 subcommands (list, search, context, extract, projects) plus help and unknown-command, asserting both human-readable output and --json roundtrip shape. Coverage on mem.ts: - statements: 81.89% (target ≥70%) - functions: 89.04% - lines: 87.93% - branches: 64.91% Vitest 1019/1019 (was 935 → +84). Lint clean. Typecheck clean.
…tforms-sub-agent-vs-inline
…at pre-flight - package.json: 0.5.7 → 0.6.0-0 (intermediate seed; `pnpm version prerelease --preid beta` lifts to 0.6.0-beta.0) - manifests/0.6.0-beta.0.json: new manifest declaring `trellis mem` as the headline addition + carrying configSectionsAdded entry forward from 0.5.7 - check-docs-changelog.js: accept the X.Y.Z-N seed format (initial prerelease before the first beta) so the pre-flight gate doesn't reject the minor-bump-first-beta workflow Not released yet. Run `pnpm release:beta` from packages/cli when ready; CI publishes to the @beta dist-tag on tag push.
… 0.6 beta lifecycle - docs-site → 3b2c7ba: 0.6 beta lifecycle (banner / Beta version block / beta tree / v0.6.0-beta.0 changelog) + mem-recall skill page (EN+ZH) + index.mdx updates + docs.json wiring - marketplace → ad95a26: feat: add mem-recall skill (SKILL.md authored, ports local chat-history-recall to wrap `trellis mem` CLI) Plus task records under .trellis/tasks/05-08-marketplace-skill-chat-recall/. Not released yet.
…ght task records
Local dogfood file sync:
- .trellis/.version 0.5.0 → 0.5.7
- .trellis/.template-hashes.json refreshed
- .trellis/scripts/task.py updated to current template (degraded-mode
start path, etc.)
- .agents/skills/trellis-start/SKILL.md updated
- .claude/{agents,hooks}/, .cursor/{agents,hooks}/, .codex/{agents,
hooks,config.toml}, .opencode/agents/, .pi/agents/ all aligned to
current 0.5.7 / v0.6.0-beta template content
In-flight task records:
- .trellis/tasks/05-08-fix-copilot-pi-hook-injection-248-249/ (planning;
PRD + research/ for mindfold-ai#248 Copilot + mindfold-ai#249 Pi, fix not yet implemented)
- .trellis/tasks/05-08-scratch-start-task/ (scratch)
- .trellis/tasks/05-08-temporary-task/ (scratch)
Brings working tree to clean state on feat/v0.6.0-beta.
* fix(cli): rename pi subagent tool to trellis_subagent, avoid community conflict Rename Trellis's Pi extension subagent tool from "subagent" to "trellis_subagent" to avoid name collision with nicobailon/pi-subagents. Add isTrellisAgent() validation via existsSync on .pi/agents/trellis-*.md. Remove pi-subagents package isolation from settings.json (no longer needed). Update platform-integration spec to match. * chore(task): archive 05-17-rename-pi-trellis-subagent-tool * chore: record journal * chore(task): verify pi subagent tool rename * chore(task): archive 05-17-verify-trellis-subagent-pi --------- Co-authored-by: shane <Shane.s@riversense.tw>
* feat(cli): 重构 trellis 扩展,引入原生进度卡片与子代理动态渲染
- 重构 `index.ts.txt`,引入 `RunState`、`ProgressDetails`、`ToolTrace` 等类型定义,支持子代理运行状态追踪
- 新增 `NativeCardHandle` 机制,允许原生进度卡片(`renderResult`)动态更新子代理执行进度
- 实现 `runSubagent` 函数,支持 `single`、`parallel`、`chain` 三种调度模式,并通过 `onUpdate` 回调实时推送进度
- 添加 `renderCall` / `renderResult` 自定义渲染器,支持 `Alt+O` 快捷键展开/折叠最新子代理卡片详情
- 提取 `splitModelThinking`、`buildPiArgs`、`resolveRunCfg` 等工具函数,统一模型与 thinking 参数的解析逻辑
- 使用 `BoundedBufferCollector` 控制 stdout/stderr 缓冲区上限,避免内存泄漏
- 引入 `THROTTLE_MS` 节流机制,控制进度更新频率
- 移除冗余的 `PiBeforeAgentStartEvent`、`PiContextEvent`、`PiToolCallEvent` 接口,简化为泛型类型推断
- 优化 `commandStartsWithTrellisContext` 检测逻辑,仅在 bash 命令中注入 `TRELLIS_CONTEXT_ID`
- 通过 `pi.on?.("tool_result")` 钩子,将失败/取消的子代理标记为错误,保证主代理正确感知结果
- 清理未使用的 `session_shutdown`、`context` 等事件处理,保持代码精简
* fix(cli): rename pi subagent tool to trellis_subagent + validate agent
Brings PR mindfold-ai#286 in line with mindfold-ai#290 (merged on main):
- Rename custom tool from "subagent" to "trellis_subagent" to avoid
name collision with nicobailon/pi-subagents.
- Add isTrellisAgent() validation in execute() entry; non-Trellis
agent names get a clear error pointing to community alternatives.
- Dedup agent-name normalization via normalizeAgent() helper.
* test(pi): adapt tests to mindfold-ai#286 extension rewrite
PR mindfold-ai#286 reorganized the Pi extension (renamed many helpers, inlined
some, removed the dead-code input handler). The merged tests from main
asserted on the old function names with brittle toContain() string
matches.
This commit:
- Rewrites pi.test.ts to test mindfold-ai#286's actual contracts behaviorally
via the vm-sandbox loader (normalizeAgent, isTrellisAgent, parseAgentFM,
buildPiArgs, resolveRunCfg, cmdHasTrellisCtx, shellQuote) plus a small
set of surface checks (tool name, event handlers, error patching).
- Drops the implementation-detail asserts in platforms.test.ts for
helpers that mindfold-ai#286 renamed or inlined; keeps file-existence checks
and stable invariants (tool name, session/tool_call events, agent
validation).
All 1171 tests pass; lint + typecheck clean.
---------
Co-authored-by: taosu <taosu@mindfold.ai>
…old-ai#291) * fix: block archived task recreate collisions * chore(task): archive 05-17-fix-archived-task-create-collision * chore: record journal (cherry picked from commit 283289a)
…indfold-ai#283) Add a one-line "Tools" prelude inside `[workflow-state:in_progress]` that disambiguates the three identifiers used in the Flow line: - `trellis-implement` / `trellis-research` are sub-agent types only (Task/Agent tool — no skill exists by these names) - `trellis-update-spec` is a skill - `trellis-check` exists as both; prefer the Agent form for verification Without this note, agents that see the Flow line in isolation tend to generalize "trellis-* in backticks" as skills and call the Skill tool with `trellis-implement`, which errors with "skill not found". The other status blocks already list only true skills, so the disambiguation is local to `in_progress` (and `in_progress-inline` already uses skill-only names, so it is left untouched). Updates both the canonical template and the project's own `.trellis/workflow.md`, plus the corresponding entry in `.trellis/.template-hashes.json`. (cherry picked from commit b05d1c4)
…ync-upstream-0.6-beta # Conflicts: # .codex/hooks/inject-workflow-state.py # .cursor/hooks/session-start.py # .pi/extensions/trellis/index.ts # .trellis/.template-hashes.json # .trellis/scripts/common/session_context.py # .trellis/spec/cli/backend/commands-mem.md # .trellis/spec/cli/backend/index.md # .trellis/spec/cli/backend/migrations.md # .trellis/spec/cli/backend/platform-integration.md # .trellis/spec/cli/backend/release-process.md # .trellis/spec/cli/backend/script-conventions.md # .trellis/spec/guides/cross-layer-thinking-guide.md # .trellis/workflow.md # .trellis/workspace/taosu/index.md # .trellis/workspace/taosu/journal-5.md # docs-site # marketplace # packages/cli/package.json # packages/cli/src/cli/index.ts # packages/cli/src/commands/init.ts # packages/cli/src/commands/update.ts # packages/cli/src/configurators/workflow.ts # packages/cli/src/templates/markdown/spec/guides/cross-platform-thinking-guide.md.txt # packages/cli/src/templates/opencode/plugins/inject-subagent-context.js # packages/cli/src/templates/pi/extensions/trellis/index.ts.txt # packages/cli/src/templates/shared-hooks/inject-workflow-state.py # packages/cli/src/templates/trellis/config.yaml # packages/cli/src/templates/trellis/index.ts # packages/cli/src/templates/trellis/scripts/common/config.py # packages/cli/src/templates/trellis/scripts/common/session_context.py # packages/cli/src/templates/trellis/scripts/common/task_store.py # packages/cli/src/templates/trellis/workflow.md # packages/cli/test/configurators/platforms.test.ts # packages/cli/test/regression.test.ts # packages/cli/test/scripts/task-archive.integration.test.ts # packages/cli/test/templates/pi.test.ts
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
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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.
Summary
Verification
Notes
Test plan
🤖 Generated with Claude Code