Skip to content

chore: sync upstream feat/v0.6.0-beta into main (preserve i18n)#3

Merged
cooker-code merged 207 commits into
mainfrom
chore/sync-upstream-0.6-beta
May 21, 2026
Merged

chore: sync upstream feat/v0.6.0-beta into main (preserve i18n)#3
cooker-code merged 207 commits into
mainfrom
chore/sync-upstream-0.6-beta

Conversation

@cooker-code
Copy link
Copy Markdown
Owner

Summary

  • 合并 upstream/feat/v0.6.0-beta(包含 v0.6.0-beta.20)到 cooker-code 分支,同时保留 PR1-A 引入的 i18n 中文模板支持
  • 解决 36 个文件冲突:24 个走 `--theirs`(运行时 artifacts / templates / 测试)+ 2 个 submodule 指针 + 8 个手动合并(i18n × upstream 0.6.0-beta 重叠点)
  • 关键合并点:`init.ts`/`update.ts`/`configurators/workflow.ts` 同时保留 `language` 字段 + 上游新增的 `--workflow` / `--workflow-source` / `workflowMdOverride`;`config.yaml` 保留 Language section 同时接入新的 Channel worker OOM guard section
  • 移除 `templates/pi/settings.json` 残留的 `npm:pi-subagents` package 节(被 b1a6e89 删除,但因无冲突标记被 git 误保留)

Verification

  • `pnpm typecheck` ✅
  • `pnpm test`(CLI 1190 / core 278) ✅
  • `pnpm i18n:check`:0 missing / 0 drift ✅
  • 提交流程通过 husky + lint-staged(eslint+prettier)

Notes

  • `workflow.zh.md` 暂未跟随 upstream 更新的 `workflow.md` 做翻译同步,依赖 `getWorkflowTemplate(locale)` 内置的英文 fallback。后续 PR 1-B 跟进
  • 合并 commit:`85f19208`(merge commit,保留双 parent 历史用于后续上游同步)

Test plan

  • `trellis init --language zh` 在干净仓库下生成中文 workflow.md
  • `trellis init --workflow tdd` 上游新功能在 i18n 路径下不被 override 破坏
  • `trellis update` 切换 `language` 走 autoUpdateFiles(无冲突提示)

🤖 Generated with Claude Code

taosu 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.
# 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.
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).
PRD + jsonl curation backing the 0.5.3 hotfix
(commits d35224c, e04482d, 5ac145a). Implementation derives from
the archived research at archive/2026-05/05-06-research-claude-code-
env-injection-on-windows-for-hook-session-identity (referenced as
spec/research files in implement.jsonl).
# Conflicts:
#	.trellis/workspace/taosu/index.md
#	.trellis/workspace/taosu/journal-5.md
…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.
…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.
taosu and others added 29 commits May 17, 2026 13:52
* 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
@cooker-code cooker-code merged commit d68f65c into main May 21, 2026
1 check passed
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.