Skip to content

feat(resources)!: let workflows, hooks, rules and MCP servers carry their own files as folders - #1804

Merged
SaulMoro merged 161 commits into
Tencent:mainfrom
hz89Dev:feat/issue-1787-resource-folders
Nov 9, 2026
Merged

SaulMoro merged 161 commits into
Tencent:mainfrom
hz89Dev:feat/issue-1787-resource-folders

Conversation

@hz89Dev

@hz89Dev hz89Dev commented Nov 9, 2026 •

Copy link
Copy Markdown
Contributor

Summary

A team could share a workflow, hook, rule or MCP server only as one file. A workflow's script, a hook's scanner, an MCP server's code and a rule's detail had to live somewhere else, and teamai's own prompts, hint texts and thresholds were constants no team could change. Now each of these can be a folder, the way a skill already is: a marker file and the files it needs next to it. One layered resolver finds them all (teamai default, then team root, then active namespace).

A team repo can now hold:

workflows/release/
├─ WORKFLOW.yaml
├─ plan.sh
└─ prompts/summary.md
hooks/block-secrets/
├─ HOOK.yaml
└─ scan.sh
hooks/teamai-friction-reminder/      copied from the package, then edited: replaces teamai's
├─ HOOK.yaml
├─ problem.md
└─ ...                               every other text the default ships
rules/api-style/
├─ RULE.md
├─ RULE.zh.md
└─ checklist.md
mcp/notes/
├─ MCP.yaml
└─ notes.mjs
benchmarks/smoke/
├─ SUITE.yaml                        suite.yaml still works
└─ tasks/
# workflows/release/WORKFLOW.yaml
schemaVersion: v1alpha1
name: release
description: Plan the release, then summarise it.
steps:
  - id: plan
    command: sh "$TEAMAI_WORKFLOW_DIR/plan.sh"
    output: { version: string }
  - id: summary
    needs: [plan]
    prompt_file: prompts/summary.md     # a file of the folder
    output: { summary: string }
outputs:
  version: steps.plan.outputs.version
  summary: steps.summary.outputs.summary
# hooks/block-secrets/HOOK.yaml       (no id: the directory name is the id)
description: Scan for secrets before a commit
event: PreToolUse
matcher: Bash
command: bash "${TEAMAI_HOOK_DIR}/scan.sh"
timeout: 15
# Replace a default hook: copy it whole, then change what you need
cp -r "$(npm root -g)/teamai-cli/hooks/teamai-friction-reminder" hooks/
# hooks/teamai-friction-reminder/HOOK.yaml   (a with: key left out keeps teamai's value)
description: Remind after longer sessions only
with:
  min_tools: 30
<!-- rules/api-style/RULE.md -->
---
paths: ["src/api/**"]
---
Follow the team API style. Before adding an endpoint, read ${TEAMAI_RULE_DIR}/checklist.md.
# mcp/notes/MCP.yaml                  (no name: the directory name is the server name; stdio only)
description: Search the team's notes
transport: stdio
command: node
args: ["${TEAMAI_MCP_DIR}/notes.mjs"]
requires: [node]

After teamai pull:

Folder Where it lands What the tool gets
workflow <data home>/workflows/folders/<sourceHash>/, stored when a run starts TEAMAI_WORKFLOW_DIR in every step's processes. The run keeps that copy whatever a later pull does. resume --claim rebuilds it on another machine
hook ~/.teamai/hooks/block-secrets.e246f037/, ~/.teamai/projects/<slug>/hooks/..., or .teamai/delivered/hooks/... in each single-repo worktree. One directory per version of the folder's files (e246f037: the first 8 hex digits of the SHA-256 of each file's path, mode and git blob id, HOOK.yaml included). Every checkout of a commit gives the same version: a committed file counts as git stores it, whatever core.autocrlf, core.fileMode or its encoding, and a new or edited file as it is on disk. Pull copies no file git ignores, and refuses a folder holding a git submodule or a repository of its own. A version's files never change bash "<that path>/scan.sh", forward slashes. A tool whose settings pull cannot rewrite, or one the member excluded, keeps the files of the version it holds. In single-repo, Claude Code gets $CLAUDE_PROJECT_DIR/.teamai/delivered/...
default hook the scope's data home the hint prints the team's problem.md and waits for 30 tool calls
rule .teamai/delivered/rules/api-style/ in each worktree; in user scope ~/.teamai/rules/api-style/, granted to Claude Code through permissions.additionalDirectories (uninstall removes it) api-style.md in the tool's rules directory, with the path in place of ${TEAMAI_RULE_DIR}
MCP server .teamai/delivered/mcp/notes.<version>/ in each worktree; in user scope ~/.teamai/mcp/notes.<version>/. One directory per version of the folder's files, as for hooks node <that path>/notes.mjs for every tool mcp/mcp.yaml reaches. A tool whose MCP file pull cannot rewrite, or one the member excluded, keeps the files of the version it holds
suite unchanged SUITE.yaml is read like suite.yaml; both in one directory is invalid

Also in this PR:

  • Three defaults ship as workflow folders. Their prompts are now files: teamai-import-from-mr (draft.en.md, draft.zh.md), teamai-codebase-deep-enrich (component.md, architecture.md, scenarios.md) and teamai-import-from-repo (narrative.md). Golden tests check the text is byte-identical to before.
  • Five hints ship as default hook folders (teamai-friction-reminder, -mr-hint, -todowrite-hint, -env-hint, -package-hint), and teamai's recall rule ships as rules/teamai-recall/. A team replaces any of them with a folder of the same name at the root of its repo.
  • teamai review --branch checks hook, MCP and rule folders as pull reads them, fails a replacement of a default hook or of the recall rule that pull refuses, and scans the recall replacement for credentials like the other rules. teamai remove mcp and teamai remove rules remove a server or rule folder. teamai uninstall removes teamai's copies of a rule folder. It keeps a delivered folder that a file it leaves still names, and says which file: a member's or edited rule copy in any worktree, or an MCP or hook entry it could not remove.
  • Every default folder, and workflows/, agents/ and scorers/ at the package root, has a README.md and a README.zh-CN.md. Each shows in tables and Mermaid decision trees what a team can change, what the resource reads and gives, what pull refuses, and which settings change it. It links the guide for defaults and full texts instead of copying them, so a change to a default does not need a README change. The package directory agents/ now holds READMEs, so teamai deploys only its own agents from it (edb22d2fa).
  • With those READMEs, the package root gained folders, so the README images moved from assets/ to docs/assets/, and every root README links them there (5d1d7732f). The root READMEs change only in those <img> paths.
  • Pull says when it could not apply the team MCP servers, and why (14ba3f04d). Since feat(mcp): distribute team MCP servers as a seventh resource type #252 it wrote that only to ~/.teamai/debug.log, so a .mcp.json it could not write read as a pull with nothing to change.
  • The dashboard's Resources page has a Resource layers panel. It shows every definition of each name, its layer and form, what it replaces, and whether pull uses it, with pull's own message when it does not.

What members see, verbatim from the code:

# pull, a teamai- folder that replaces no default (review --branch warns with the same text)
⚠ [workflows] workflows/teamai-release/ is skipped: a teamai- name only replaces a teamai default, and teamai has no workflow named teamai-release. Rename the folder.
hooks/teamai-lint/ is skipped: a teamai- name only replaces a teamai default, and teamai has no hook named teamai-lint. Rename the folder.
mcp/teamai-db/ is skipped: a teamai- name only replaces a teamai default, and teamai has no MCP server named teamai-db. Rename the folder.

# pull, a default hook replacement it refuses (teamai's stays in force)
⚠ hooks/teamai-friction-reminder/ is refused, and teamai's default stays in force until it is fixed: HOOK.yaml: with.min_tools must be a whole number from 1 to 1000
hooks/payments/teamai-friction-reminder/ is refused, and teamai's default stays in force: a default hook is replaced at the root of the team repo only. Move it to hooks/teamai-friction-reminder/
rules/teamai-recall/ is not used, so teamai's recall rule stays in force: rules/teamai-recall/RULE.md does not contain "Nothing was searched:". Fix the folder in the team repo.
rules/teamai-recall/ is not used, so teamai's recall rule stays in force: rules/teamai-recall/block.md is a symlink. Fix the folder in the team repo.
rules/teamai-recall/ is not used, so teamai's recall rule stays in force: rules/teamai-recall/block.md names ${TEAMAI_RULE_DIR}, but a recall file is delivered as its text, and no other file of the folder is. Put what it points at in the file. Fix the folder in the team repo.

# pull, a directory that became a folder
⚠ rules/onboarding/ holds RULE.md, so it is one folder, and db.md in it is one of its files, no longer read on its own.
[workflows] workflows/release/ is a workflow folder; checks.yaml in it is not a workflow

# pull and review --branch, a folder that is itself a symlink (nothing is read from it)
⚠ [workflows] workflows/ship/WORKFLOW.yaml:1: field "(root)": workflows/ship/ is a symlink, and a folder holds its own files, never a link, so nothing is read from it. Put the directory itself in the team repo.
hooks/lint/ is a symlink, and a folder holds its own files, never a link, so nothing is read from it. Put the directory itself in the team repo; pull leaves every member's team hooks as they are until it is fixed.

# pull, a delivered folder that cannot be replaced (the installed version stays)
Team hook folders could not be delivered: could not replace the delivered folder <path> (<cause>); a program running from it, such as a hook on Windows, can hold it, so close that program. Team hooks were not applied this run, so your installed team hooks are unchanged. Run teamai pull again.
Team MCP server folders could not be delivered: could not move the new version of the delivered folder <path> into place (<cause>); the installed version stays, and the next pull tries again. mcp was not applied this run, so your installed team MCP servers are unchanged. Run teamai pull again.

# pull, a folder the team dropped that cannot be removed (the others are delivered)
Could not remove <path>, which the team no longer delivers (<cause>). Nothing names it any more; the next pull removes it.

# env, a team variable that uses a reserved folder name
TEAMAI_HOOK_DIR is reserved for the folder path teamai gives a workflow step, hook, rule or MCP server; those team env values are ignored.

# review --branch
✖ [format] mcp/mcp.yaml: server "lookup" uses ${TEAMAI_MCP_DIR}, which only an MCP server folder has. Move it to mcp/lookup/MCP.yaml, beside the files it runs; pull leaves every member's team MCP servers as they are until it is fixed.
✖ [duplicates] MCP server "jira-lite" is defined in both mcp/mcp.yaml and mcp/jira-lite/, in the same place, so pull leaves every member's team MCP servers as they are. Keep one of them.
! [naming] workflows/teamai-release/ is skipped: a teamai- name only replaces a teamai default, and teamai has no workflow named teamai-release. Rename the folder.
✖ [structure] rules/teamai-recall/ is not used, so teamai's recall rule stays in force: rules/teamai-recall/RULE.md does not contain "Nothing was searched:". Fix the folder in the team repo.

How pull delivers a type's folders (hooks, rules, MCP servers), so the installed entries always match them:

1. write each new version beside its folder        .api-style.new-1a2b3c4d/
   a write fails -> discard them all; nothing changed
2. rename each into place, keeping the installed    api-style/ <- new, .api-style.old-1a2b3c4d/ <- installed
   a rename fails -> put back every installed version already replaced, then stop:
                     "your installed team hooks are unchanged" holds
3. drop the installed versions; prune what the team dropped (a folder still in use is kept, with a warning)

Type of Change

  • Bug fix (non-breaking change that fixes an issue)
  • New feature (non-breaking change that adds functionality)
  • Breaking change (fix or feature causing existing behavior to change)
  • Documentation only
  • Refactor / internal cleanup

Test Plan

  • npx tsc --noEmit passes
  • npm run lint passes
  • The test files that cover what I changed pass (npx vitest run <test files>); the full npx vitest run passes if the change touches src/__tests__/helpers/, a vitest*.config.ts, package.json or package-lock.json. CI runs the full suite on every push to a PR.
  • Added/updated tests for the change

The branch touches package.json and src/__tests__/helpers/windows-tests.ts, so I ran the full unit suite. Its only failures are nine OpenCode doctor checks that fail only under the full parallel run (below); CI is the authority for those files.

Verification

Local checks at 9bdf7677a (macOS):

Check Result
Type check (tsc --noEmit and the lint plugin project, TypeScript 7.0.2) exit 0
npm run lint exit 0, Documentation checks passed.
npm run build exit 0
npm run test:e2e on the 6 files that drive folder delivery, skips and uninstall (hook-folder-worktrees, hook-shells-windows, pull-skipped-folders-1791, git-exclude-uninstall-915, managed-resources-uninstall, workflow-team-workspace) 41 passed, 6 skipped (Windows-only)
Full unit suite (774 files) 23080 passed, 27 skipped, 9 failed. The 9 are the OpenCode checks of doctor-rules-delivery.test.ts, which this branch does not touch: they fail only when the whole suite runs in parallel, did so on main too, and the file alone passes 80 of 80

After merging main at 5d687270b (#1798 to #1801): type check, npm run lint and npm run build exit 0; the full unit suite has 23209 passed, 27 skipped, and the same 9 parallel-only OpenCode doctor failures plus one test of this branch that needed recall on, since #1801 gives the TodoWrite hint only then (fixed in the merge). npm run test:e2e on hook-fast-path-1788, hook-folder-worktrees, pull-skipped-folders-1791 and git-exclude-uninstall-915: 33 passed. The hints a default hook folder replaces run at session-start and Stop, or in the full dispatch for TodoWrite, so #1801's fast path leaves them as they were.

After the review at 9bdf7677a, at 4c36235cf: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since 5d687270b (vitest-affected, 11012 tests) have 11000 passed, 3 skipped, and the same 9 parallel-only OpenCode doctor failures; that file alone passes 80 of 80. The real-CLI record for a symlinked folder follows the every-type record below.

At 01406b649, after the second round of review: type check, npm run lint and npm run build exit 0, and vitest-affected since 5d687270b (11816 tests) has 11804 passed, 3 skipped, and the same 9 parallel-only OpenCode doctor failures (80 of 80 alone). 435048d79 adds only README files; the 22 test files that read the default folders pass (913 tests), one with README.zh-CN.md added to the recall folder's file list. The last commit adds the workflow folder files to the leaks check; review-branch.test.ts passes (111), with type check and lint at exit 0.

At fbff2d0d1, the head, after the third round of review and merging main (#1802): type check, npm run lint and npm run build exit 0. The full unit suite (783 files, 23431 tests) has 23395 passed, 27 skipped, and the same 9 parallel-only OpenCode doctor failures; that file alone passes 80 of 80. Each fix of this round has a test that failed before it. The 30 Mermaid diagrams of the default READMEs render.

At f2742b72c, the head, after the fourth round of review: type check, npm run lint and npm run build exit 0. The full unit suite (783 files, 23434 tests) has 23398 passed, 27 skipped, and the same 9 parallel-only OpenCode doctor failures; that file alone passes 80 of 80. npm run test:e2e on pull-skipped-folders-1791, git-exclude-uninstall-915, hook-folder-worktrees and managed-resources-uninstall: 24 passed. The tests for the worktree and retention fixes fail on the commit before each one. The two-worktree record follows the team-policy record below.

At db8c1e302, the head, after the fifth round of review: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since f2742b72c (vitest-affected, 372 files, 11748 tests) pass but for the same 9 parallel-only OpenCode doctor failures (80 of 80 alone) and one test whose mcp-reconcile mock lacked an export pull reads: pull's MCP step had thrown there all along, unseen until 14ba3f04d printed it, and the mock is fixed in db8c1e302. Each fix of this round has a test that failed before it. The Linux-only case test of 19165a0fe is skipped on macOS and runs in CI.

At 10e10703c, after the sixth round of review: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since db8c1e302 (vitest-affected, 339 files, 10744 tests) pass but for the same 9 parallel-only OpenCode doctor failures (80 of 80 alone). Each fix has a test that failed before it.

At 02f0ad66d, after the seventh round of review: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since 10e10703c (vitest-affected, 8923 tests) pass but for the same 9 parallel-only OpenCode doctor failures (80 of 80 alone). npm run test:e2e -- src/__tests__/e2e/hook-folder-worktrees.test.ts: 3 passed. Each fix has a test that failed before it. Records from before a042b9a8d show a hook folder at hooks/<id>/; it is hooks/<id>.<version>/ since.

At c8cdfafc6, after the eighth round of review: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since 02f0ad66d (vitest-affected, 372 files, 11762 tests) pass but for the same 9 parallel-only OpenCode doctor failures (80 of 80 alone) and one mcp-reconcile test that pinned the unversioned mcp/notes/ path, fixed in 64fc4ac3b (305 of 305). npm run test:e2e on hook-folder-worktrees, git-exclude-uninstall-915, managed-resources-uninstall and mcp-uninstall: 21 passed. Each fix has a test that failed before it. Every version a test pins was computed outside teamai. Records from before 64fc4ac3b show an MCP folder at mcp/<name>/ and a hook version taken from its command alone.

At 4ad6f49c7, after the ninth round of review: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since c8cdfafc6 (vitest-affected, 372 files, 11765 tests) pass but for the same 9 parallel-only OpenCode doctor failures (80 of 80 alone) and one Muse history test, which caught a change to which hash the history match checks; that change is reverted in 7e21f8ec2 (368 of 368 across muse, mcp-reconcile and mcp-folders-delivery). npm run test:e2e on hook-folder-worktrees, mcp-uninstall, managed-resources-uninstall and repo-attribution-worktrees-809: 13 passed. The last one failed in CI shard 1 at c8cdfafc6 on the last of its seven sessions; it passes here and touches no folder code. Expected versions in tests come from helpers/folder-version.ts, which works them out from the team repo's folder on disk, and Python gives the same values. Records from before 7e21f8ec2 show a version taken from HOOK.yaml or MCP.yaml alone.

At a2fc686f5, after the tenth round of review: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since 4ad6f49c7 (vitest-affected, 372 files, 11767 tests) pass but for the same 9 parallel-only OpenCode doctor failures (80 of 80 alone). npm run test:e2e on hook-folder-worktrees, mcp-uninstall and managed-resources-uninstall: 7 passed. helpers/folder-version.ts now reads text with CRLF as LF and leaves out the executable bit, as pull does.

At 80b45408f, after the eleventh round of review: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since a2fc686f5 (vitest-affected, 782 files with the origin/main merge, 23467 tests) pass but for the same 9 parallel-only OpenCode doctor failures. npm run test:e2e on hook-folder-worktrees, mcp-uninstall and managed-resources-uninstall: 7 passed. helpers/folder-version.ts works versions out with git ls-files -s, -m, -o and git hash-object --no-filters, not the code under test.

At 41811c09c, after the twelfth round of review: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since 80b45408f (vitest-affected, 372 files, 11777 tests) pass but for the same 9 parallel-only OpenCode doctor failures. npm run test:e2e on hook-folder-worktrees, mcp-uninstall and managed-resources-uninstall: 7 passed.

At 41b137727: type check and npm run lint exit 0. The unit tests that reach what changed since 41811c09c (vitest-affected, 372 files, 11778 tests) pass but for the same 9 parallel-only OpenCode doctor failures.

At 1104e40eb: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since 41b137727 (vitest-affected, 372 files, 11780 tests) pass but for the same 9 parallel-only OpenCode doctor failures. npm run test:e2e on hook-folder-worktrees, mcp-uninstall and managed-resources-uninstall: 7 passed.

At f57b27af9, the head: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since 1104e40eb (vitest-affected, 287 files, 8934 tests) pass but for the same 9 parallel-only OpenCode doctor failures. No E2E file covers review --branch; the real-CLI record above does.

repo-attribution-worktrees-809 failed CI shard 1 at c8cdfafc6 and f57b27af9, both times missing the last session's event. Each hook hands its event to a detached child, and the test read events.jsonl before the last child wrote. 70ccbab3a makes it wait for those children (waitForDetachedChildren), a test-only change; it passes locally (6 of 6).

Golden tests written before each move check that teamai's own texts did not change. They cover the three default workflows' prompts, 78 hint strings for language unset, en and zh (only the 16 zh friction texts change, on purpose), and the recall rule and blocks byte for byte.

Each record below ran the built CLI in a sandboxed HOME, against a bare team repo reached through a git insteadOf rewrite (git provider).

Workflow folder, teamai workflow start --driver local, at e20d4ecca. The folder holds WORKFLOW.yaml, an executable plan.sh, summary.md (the prompt_file), notes.md and README.md. The prompt step was answered by a stub claude, which logged TEAMAI_WORKFLOW_DIR and read notes.md from it.

$ teamai list workflows --verbose
  release  (team)
    path: <sandbox>/home/.teamai/team-repo/workflows/release
$ teamai workflow start release --driver local
ℹ Run r24fbcc5891d73f5b started. If it stops before it ends, continue it with: teamai workflow resume r24fbcc5891d73f5b
{"data":{"done":{"run":"r24fbcc5891d73f5b","outcome":"succeeded","outputs":{"version":"1.2.0","summary":"Summarise release 1.2.0 from the file no | notes: Retries 429 responses with backoff."}},"cancelled":[]}}
$ ls -l ~/.teamai/workflows/folders/*
-rw-r--r--  README.md
-rw-r--r--  WORKFLOW.yaml
-rw-r--r--  notes.md
-rwxr-xr-x  plan.sh
-rw-r--r--  summary.md
stub claude log: TEAMAI_WORKFLOW_DIR <sandbox>/home/.teamai/workflows/folders/<hash>

Hook folder, fired by Claude Code 2.1.319, at 4feacd514 (user scope, this build first on PATH as teamai):

== teamai pull
ℹ Applying 1 team hook(s):
ℹ   [block-secrets] bash "<sandbox>/home/.teamai/hooks/block-secrets/scan.sh"
== delivered folder
./block-secrets/HOOK.yaml
./block-secrets/scan.sh
== claude -p: run git status
hook fired: {"hook_event_name":"PreToolUse","tool_name":"Bash","tool_input":{"command":"git status --short",…}}
== claude -p: echo a fake AWS key
{"is_error":false,"result":"I didn't run the command. A PreToolUse hook (`block-secrets`, from `~/.teamai/hooks/block-secrets/scan.sh`) blocked it because it saw an AWS access key ID in the command. …"}
hook fired: {"hook_event_name":"PreToolUse","tool_name":"Bash","tool_input":{"command":"echo AKIAIOSFODNN7EXAMPLE",…}}
PreToolUse entries after both sessions: 1

Other real-CLI runs, one per type, each at the branch head named:

Type At What it showed
Default workflow folder d515aa4f1 teamai import --from-mr --dry-run sent the shipped draft.en.md text. After the docs' copy-and-edit steps, the prompt held the team's added ## Open questions section (stub claude)
Default hook replacement e61bcb5cd Claude Code got the team's problem.md at Stop after 3 tool calls, under with: { min_tools: 2, min_score: 1 }. A min_tools: 5000 push gave the refusal line above, and the delivered copy was removed
Rule folder 829f87750 Claude Code read checklist.md through ${TEAMAI_RULE_DIR} with no permission prompt. A control run without user settings was denied. teamai uninstall --force removed the grant
Suite 74b64aa72 teamai benchmark try on a SUITE.yaml task passed. teamai status counted benchmarks: 1
MCP folder b55a5d2d4 Two workspaces bound to different teams each started their own jira-lite (a node .mjs and a uv run --script PEP 723 server). claude mcp list showed both ✔ Connected
MCP review and remove ade867c4d teamai review --branch failed the http-folder, ${TEAMAI_MCP_DIR}, duplicate and missing-command branches with the messages above. teamai remove mcp jira-lite --force committed the folder's removal
teamai- skip, worktree copies, uninstall a60fbefbc Project scope with Codex as the agent: pull printed the workflow skip line and wrote .teamai/delivered/rules/api-style/ under its own .git/info/exclude block. teamai uninstall --force removed both

Every type in one team repo, at 9bdf7677a. A member of project checkout (namespace payments active, Claude Code and Codex) that ran init and a first pull on an earlier head pulls again with this build, then runs review --branch on a branch that adds workflows/teamai-release/ and hooks/teamai-lint/. Each warning below comes from a broken definition the repo holds on purpose:

$ teamai pull
⚠ rules/teamai-recall/ is not used, so teamai's recall rule stays in force: rules/teamai-recall/RULE.md does not contain "Nothing was searched:". Fix the folder in the team repo.
⚠ [workflows] workflows/deploy.yaml:1: field "(root)": Workflow "deploy" is defined twice in one place, as workflows/deploy.yaml and as workflows/deploy/; a workflow defined twice has no runnable version
⚠ [workflows] workflows/deploy.yaml has no runnable version
⚠ [workflows] teamai's default teamai-import-from-repo cannot start: step "enrich" with.wiki_root is not an input workflow "teamai-codebase-enrich" declares
⚠ [workflows] teamai's default teamai-import-from-repo cannot start: step "enrich" with.project is not an input workflow "teamai-codebase-enrich" declares
⚠ [benchmarks] benchmarks/broken/SUITE.yaml:8: field "repetitions": Too small: expected number to be >=1
⚠ [benchmarks] benchmarks/broken/SUITE.yaml has no runnable version
⚠ hooks/teamai-mr-hint/ is refused, and teamai's default stays in force until it is fixed: HOOK.yaml: with.lookback_days must be a whole number from 1 to 90
⚠ mcp/jira-lite/MCP.yaml: transport http is refused in a folder, which holds the files of a server teamai starts (stdio). A URL server carries no files: declare it in mcp.yaml. mcp was not applied this run, so your installed team MCP servers are unchanged. Fix the file in the team repo and push.
⚠ Pull finished, but 1 check(s) failed:
⚠   ✖ Team MCP servers can be read
exit 0

$ teamai review --branch teamai/push/member/1
[review] branch teamai/push/member/1: 4 fail, 2 warn, 17 info
  ✖ [structure] rules/teamai-recall/ is not used, so teamai's recall rule stays in force: rules/teamai-recall/RULE.md does not contain "Nothing was searched:". Fix the folder in the team repo.
  ! [naming] hooks/teamai-lint/ is skipped: a teamai- name only replaces a teamai default, and teamai has no hook named teamai-lint. Rename the folder.
  ✖ [format] mcp/jira-lite/MCP.yaml: transport http is refused in a folder, which holds the files of a server teamai starts (stdio). A URL server carries no files: declare it in mcp.yaml; pull leaves every member's team MCP servers as they are until it is fixed.
  ✖ [workflows] workflows/deploy.yaml:1: field "(root)": Workflow "deploy" is defined twice in one place, as workflows/deploy.yaml and as workflows/deploy/; a workflow defined twice has no runnable version
  ✖ [workflows] benchmarks/broken/SUITE.yaml:8: field "repetitions": Too small: expected number to be >=1
  ! [naming] workflows/teamai-release/ is skipped: a teamai- name only replaces a teamai default, and teamai has no workflow named teamai-release. Rename the folder.
exit 1

A folder that is a symlink, at 4c36235cf. The same member reviews a branch whose workflows/ship and hooks/lint link to directories under shared/ in the team repo. The 17 info lines are left out:

# the branch links workflows/ship -> ../shared/ship and hooks/lint -> ../shared/lint

$ teamai review --branch teamai/push/member/symlink
[review] branch teamai/push/member/symlink: 6 fail, 0 warn, 17 info
  ✖ [structure] rules/teamai-recall/ is not used, so teamai's recall rule stays in force: rules/teamai-recall/RULE.md does not contain "Nothing was searched:". Fix the folder in the team repo.
  ✖ [format] hooks/lint/ is a symlink, and a folder holds its own files, never a link, so nothing is read from it. Put the directory itself in the team repo; pull leaves every member's team hooks as they are until it is fixed.
  ✖ [format] mcp/jira-lite/MCP.yaml: transport http is refused in a folder, which holds the files of a server teamai starts (stdio). A URL server carries no files: declare it in mcp.yaml; pull leaves every member's team MCP servers as they are until it is fixed.
  ✖ [workflows] workflows/deploy.yaml:1: field "(root)": Workflow "deploy" is defined twice in one place, as workflows/deploy.yaml and as workflows/deploy/; a workflow defined twice has no runnable version
  ✖ [workflows] workflows/ship/WORKFLOW.yaml:1: field "(root)": workflows/ship/ is a symlink, and a folder holds its own files, never a link, so nothing is read from it. Put the directory itself in the team repo.
  ✖ [workflows] benchmarks/broken/SUITE.yaml:8: field "repetitions": Too small: expected number to be >=1
exit 1

The 17 info lines, one per root resource, are cut. None of them describes hooks/teamai-lint or workflows/teamai-release/ as delivered any more; at faafa77a5 there were 19, those two included. The other fixes after a60fbefbc are covered by unit tests: delivering a type's folders all or none, a case-only rename, uninstall across worktrees, a workflow folder file committed with CRLF, and a recall replacement holding a link or ${TEAMAI_RULE_DIR}.

Team policy on the Resources page, at c97cbaa3d. The fixture team above, with mcp/jira-lite/ turned into a stdio node server, and:

# teamai.yaml
sharing:
  mcp: { allowedCommands: [npx] }
  hooks: { requireTeamScripts: true }
$ teamai pull
⚠ Skipped 1 team hook(s) whose command is neither in a hook folder through ${TEAMAI_HOOK_DIR} nor under ~/.teamai/team-scripts/ (sharing.hooks.requireTeamScripts)
ℹ Applying 1 team hook(s):
ℹ   [block-secrets] bash "<data home>/hooks/block-secrets/scan.sh"
⚠   ✖ MCP servers delivered to claude
    → In <checkout>/.mcp.json, skipped: github (unresolved variable(s): GITHUB_TOKEN), jira-lite (command "node" is not in sharing.mcp.allowedCommands), notes (command "node" is not in sharing.mcp.allowedCommands). ...
$ ls <data home>/mcp
jira-lite  notes

GET /api/resources/layered from teamai dashboard for that workspace, root and payments definitions:

hooks/payments/hooks.yaml  lint           refused   its command is neither in a hook folder through ${TEAMAI_HOOK_DIR} nor under ~/.teamai/team-scripts/ (sharing.hooks.requireTeamScripts)
hooks/block-secrets/       block-secrets  in-force  delivered <data home>/hooks/block-secrets
mcp/jira-lite/             jira-lite      refused   command "node" is not in sharing.mcp.allowedCommands   delivered <data home>/mcp/jira-lite
mcp/notes/                 notes          refused   command "node" is not in sharing.mcp.allowedCommands   delivered <data home>/mcp/notes
mcp/mcp.yaml               github         in-force

Before this commit the three refused rows showed in-force. github stays in-force: pull skips it on this machine for a variable it has not set, which the page does not judge (see Limitations).

Two worktrees of one workspace, at f2742b72c. The fixture team above with mcp/jira-lite/ as a stdio node server, <checkout> and a linked worktree <wt2>, both pulled. The team then renames server.js to main.js and adds a line to rules/api-style/checklist.md, and only <checkout> pulls:

$ ls <checkout>/.teamai/delivered/mcp/jira-lite        $ ls <wt2>/.teamai/delivered/mcp/jira-lite
MCP.yaml  main.js  server.js  server.py               MCP.yaml  server.js  server.py
$ node <checkout>/.teamai/delivered/mcp/jira-lite/main.js
jira v2
$ node <wt2>/.teamai/delivered/mcp/jira-lite/server.js    # what <wt2>/.mcp.json still starts
jira
$ grep checklist <checkout>/.claude/rules/api-style.md    # and the same in <wt2>, each naming its own folder
<checkout>/.teamai/delivered/rules/api-style/checklist.md
$ tail -1 <checkout>/.teamai/delivered/rules/api-style/checklist.md; tail -1 <wt2>/.teamai/delivered/rules/api-style/checklist.md
- Version every endpoint.
- Version every public endpoint.

Once <wt2> pulls, its .mcp.json starts <wt2>/.teamai/delivered/mcp/jira-lite/main.js (jira v2), and server.js stays beside it until the folder goes. git status --untracked-files=all lists nothing under .teamai in either worktree. Hooks stay shared: the hook entry in <checkout>/.claude/settings.local.json runs bash "<data home>/hooks/block-secrets/scan.sh", as every worktree runs the same hook entries.

A configuration pull cannot write, at 14ba3f04d. The same <checkout>, with the team's jira-lite installed and printing jira v2. The team changes main.js to print jira v3 and adds "--v3" to args; the member's checkout directory is read-only, so .mcp.json cannot be replaced:

$ chmod 555 <checkout> && teamai pull
⚠ [workspace] Team MCP servers were not applied: EACCES: permission denied, open '<checkout>/.mcp.json.33597.79bdc6a39aac.tmp'. Fix the cause, then run `teamai pull` again.
$ node <checkout>/.teamai/delivered/mcp/jira-lite/main.js    # what .mcp.json still starts
jira v2
$ ls -a <checkout>/.teamai/delivered/mcp
.  ..  jira-lite  notes
$ chmod 755 <checkout> && teamai pull
$ node <checkout>/.teamai/delivered/mcp/jira-lite/main.js --v3
jira v3

Before 14ba3f04d that pull printed nothing about MCP. Before a6e324284 the old .mcp.json started the new main.js (jira v3). With the team dropping jira-lite instead, the read-only pull keeps both the entry and the folder, and the next pull removes them together (c674de897).

Removing a rule folder, at 10e10703c. The same <checkout>, with rules/api-style/ delivered:

$ teamai remove rules api-style --force
✔ Removed 1 rules from 2 location(s)
ℹ Branch teamai/push/member/20261109-145656 has been pushed. You can create a PR manually.
$ git -C team.git show --stat teamai/push/member/20261109-145656
[teamai] Remove 1 rules: "api-style" by Member
 rules/.removed               | 1 +
 rules/api-style/RULE.md      | 4 ----
 rules/api-style/RULE.zh.md   | 1 -
 rules/api-style/checklist.md | 3 ---

<checkout>/.claude/rules/api-style.md and <checkout>/.teamai/delivered/rules/api-style/ are gone. Before 10e10703c the folder stayed in the team repo, and the refresh that follows the removal delivered it again.

A hook entry pull cannot rewrite, at 02f0ad66d. Workspace with a team repo; Claude Code's entries in the main checkout's .claude/settings.local.json. The installed entry runs block-secrets.5508e78f/scan.sh --v2. The team then changes the script and its command to --v3, and the member's settings.local.json is read-only:

$ teamai pull   # settings.local.json read-only
ℹ   [block-secrets] bash ".../hooks/block-secrets.bb0e0f70/scan.sh" --v3
⚠ Failed to reconcile hooks for claude: EACCES: permission denied, open '.../checkout/.claude/settings.local.json'
folders: block-secrets.5508e78f block-secrets.bb0e0f70
entry:   block-secrets.5508e78f/scan.sh" --v2
runs:    scan v2 ran with --v2

$ teamai pull   # writable again
ℹ   [block-secrets] bash ".../hooks/block-secrets.bb0e0f70/scan.sh" --v3
folders: block-secrets.bb0e0f70
entry:   block-secrets.bb0e0f70/scan.sh" --v3
runs:    scan v3 ran with --v3

runs is the whole installed command run through bash, as Claude Code runs it. The same run on the build before the fix pruned block-secrets.2030ec53 while the entry still named it: the main checkout's manifest sits in <data home>/workspaces/<id>/, which the prune did not read.

An MCP file pull cannot rewrite, at c8cdfafc6, 4ad6f49c7, 54f026449 and 80b45408f. A team MCP server folder whose MCP file pull cannot rewrite (jira-lite, node "${TEAMAI_MCP_DIR}/main.js" --v3, Claude Code and Codex):

$ teamai pull                                # first pull on this build
.mcp.json   jira-lite  node .../.teamai/delivered/mcp/jira-lite.3dc59bcb/main.js --v3
.teamai/delivered/mcp/   jira-lite.3dc59bcb/   (the unversioned jira-lite/ is gone)

# team pushes --v4 and a new main.js; .mcp.json and the checkout made read-only
$ teamai pull
Team MCP servers were not applied: EACCES: permission denied, open '.../checkout/.mcp.json.<pid>.tmp'
.mcp.json   jira-lite  .../jira-lite.3dc59bcb/main.js --v3
$ node .../jira-lite.3dc59bcb/main.js --v3
jira v3

# write access restored
$ teamai pull
.mcp.json            jira-lite  .../jira-lite.725a3544/main.js --v4
.codex/config.toml   jira-lite  .../jira-lite.725a3544/main.js --v4
.teamai/delivered/mcp/   jira-lite.725a3544/   (3dc59bcb removed)
$ node .../jira-lite.725a3544/main.js --v4
jira v4 ran with --v4

3dc59bcb is the first 8 hex digits of the SHA-256 of {"args":["${TEAMAI_MCP_DIR}/main.js","--v3"],"command":"node","name":"jira-lite","transport":"stdio"}, computed outside teamai.

The version now comes from the folder's files. The first pull on that build moved the server to jira-lite.b61b2284/ (same files, new formula). The team then changes only main.js, with MCP.yaml unchanged:

$ teamai pull   # .mcp.json and the checkout read-only
Team MCP servers were not applied: EACCES: permission denied, open '.../checkout/.mcp.json.<pid>.tmp'
.mcp.json   jira-lite  .../jira-lite.b61b2284/main.js --v4
$ node .../jira-lite.b61b2284/main.js --v4
jira v4 ran with --v4

$ teamai pull   # writable again
.mcp.json            jira-lite  .../jira-lite.c59a4075/main.js --v4
.codex/config.toml   jira-lite  .../jira-lite.c59a4075/main.js --v4
.teamai/delivered/mcp/   jira-lite.c59a4075/   (b61b2284 removed)
$ node .../jira-lite.c59a4075/main.js --v4
jira v5 script, same MCP.yaml, ran with --v4

At 54f026449 the version reads text with CRLF as LF, and leaves out the executable bit and the files git ignores. The first pull on that build moved the server to jira-lite.f87ad19c/. A member whose team clone is a Windows-style checkout then pulls the same commit. That clone has core.autocrlf=true and core.fileMode=false, an executable server.py, and an ignored __pycache__/:

$ file team-repo/mcp/jira-lite/main.js
main.js: ASCII text, with CRLF line terminators
$ git -C team-repo status --short          # clean
$ teamai pull
.mcp.json            jira-lite  .../jira-lite.f87ad19c/main.js
.codex/config.toml   jira-lite  .../jira-lite.f87ad19c/main.js
.teamai/delivered/mcp/   jira-lite.f87ad19c/   notes.8d9ecbbc/

Both pulls give f87ad19c. A Python script outside teamai gives the same value from the files git ls-files lists at HEAD, with CRLF read as LF.

At 80b45408f a committed file counts by its mode and git blob id. The team adds start.bat, saved in GBK, which is not UTF-8. One member's clone pulls it laid out the Windows way, then the same clone laid out the macOS way:

# core.autocrlf=true, core.fileMode=false, an ignored __pycache__/
$ file team-repo/mcp/jira-lite/start.bat team-repo/mcp/jira-lite/main.js
start.bat: ISO-8859 text, with CRLF line terminators
main.js:   ASCII text, with CRLF line terminators
$ teamai pull
.mcp.json            jira-lite  .../jira-lite.edef9a43/main.js
.codex/config.toml   jira-lite  .../jira-lite.edef9a43/main.js
.teamai/delivered/mcp/jira-lite.edef9a43/   MCP.yaml  main.js  server.py  start.bat   (no __pycache__/)

# core.autocrlf=false, core.fileMode=true, files checked out again; git status clean
$ file team-repo/mcp/jira-lite/start.bat
start.bat: ISO-8859 text
$ teamai pull
.mcp.json            jira-lite  .../jira-lite.edef9a43/main.js
.codex/config.toml   jira-lite  .../jira-lite.edef9a43/main.js

A Python script outside teamai gives edef9a43 from git ls-files -s of the team repo.

At 41811c09c a folder that holds a git submodule is refused. The team vendors a server as a submodule, mcp/vendored/server, which the member's team clone has not checked out. The build before it delivered vendored with only MCP.yaml:

$ git ls-files -s mcp/vendored
100644 26ab5048...  0  mcp/vendored/MCP.yaml
160000 8118c0b0...  0  mcp/vendored/server
$ teamai pull
⚠ mcp/vendored/ cannot be delivered: server/ is a git submodule. teamai delivers only the team repo's own files: commit those files to the team repo itself, then run teamai pull again. mcp was not applied this run, so your installed team MCP servers are unchanged. Fix the file in the team repo and push.

A rule folder whose directory becomes a file, at 41b137727. rules/review-list/ holds details/checklist.md; the team replaces details/ with a file details. A rule copy the member edited, which pull keeps, may still name the checklist, so pull says it went:

$ teamai pull
⚠ .../.teamai/delivered/rules/review-list/details/checklist.md is gone: the new version has .../.teamai/delivered/rules/review-list/details in its place. A rule copy or a configuration pull left as it was may still name it: update it to the new version's files.
$ find .teamai/delivered/rules/review-list -type f
.teamai/delivered/rules/review-list/RULE.md
.teamai/delivered/rules/review-list/details

A repository of its own under an ignored directory, at 1104e40eb. The team clone ignores build/, and mcp/jira-lite/build/vend/ is a clone of its own. Git lists it as one ignored record, and pull delivers the same version without it. Before the fix, the unit test for this case got the folder refused:

$ git -C team-repo/mcp/jira-lite ls-files -o -i --exclude-standard -- .
__pycache__/server.cpython-312.pyc
build/vend/
$ teamai pull
$ ls .teamai/delivered/mcp/jira-lite.edef9a43/
MCP.yaml  main.js  server.py  start.bat

teamai review --branch on default hook and recall replacements, at f57b27af9. A branch copies teamai's hooks/teamai-friction-reminder/ with min_tools: 5000, and a valid rules/teamai-recall/ whose block.md holds an API key. Before the fix, the unit tests for both cases got no finding:

$ teamai review --branch review-demo
✖ [structure] hooks/teamai-friction-reminder/ is refused, and teamai's default stays in force until it is fixed: HOOK.yaml: with.min_tools must be a whole number from 1 to 1000
✖ [leaks] rules/teamai-recall/block.md looks like it carries a credential (openai); remove it before this branch is merged.

Dashboard

The Resources page of the fixture member above, built at 9bdf7677a, in headless Chromium. No page has a horizontal scrollbar at any width (scrollWidth - clientWidth is 0 on all six).

1440, Resources: each definition, its layer and form, and why pull does not use it 1440, a rule folder opened: its files, the text each language reads, and the path each tool reads
1440, Overview: the notice that links to what pull refuses 768, zh-CN, dark 430, Overview 430, Resources

Related Issues

Closes #1787

Notes for Reviewers

Breaking or behaviour changes

Compared with the last release, a team or member notices:

Change Who notices What to do
A directory that holds a marker (WORKFLOW.yaml, HOOK.yaml, RULE.md, MCP.yaml, SUITE.yaml) is one resource, and every file in it belongs to it. rules/onboarding/RULE.md was the rule onboarding/RULE, and each other .md there was a rule of its own. Now rules/onboarding/ is the rule folder onboarding, and pull removes the copies of the other files and says so once. workflows/release/WORKFLOW.yaml was a workflow named WORKFLOW; it is now the workflow folder release. A SCORER.md or AGENT.md directory is skipped Teams that already use those file names Rename the marker to keep the old meaning: git mv rules/onboarding/RULE.md rules/onboarding/overview.md
A teamai-* workflow, hook or MCP folder only replaces a default of that name. Any other is skipped with a warning. A single file workflows/teamai-x.yaml keeps working Teams using that prefix for their own folders Rename the folder
teamai-import-from-mr, teamai-codebase-deep-enrich and teamai-import-from-repo ship as folders, not workflows/<name>.yaml Teams that copy the shipped file to customise it Copy the folder: cp -R "$(npm root -g)/teamai-cli/workflows/teamai-import-from-mr" workflows/. A team workflows/<name>.yaml still replaces the default
With language: zh, the friction reminder is in Chinese. Every other hint prints what it printed before language: zh teams None
The env and package hints now read language, so a broken teamai.yaml makes them print Invalid teamai.yaml: ..., as the TodoWrite and MR hints already did Members with a broken team config Fix teamai.yaml
TEAMAI_WORKFLOW_DIR, TEAMAI_HOOK_DIR, TEAMAI_RULE_DIR and TEAMAI_MCP_DIR are reserved team env names, and a team value for them is ignored with the warning above. The CHANGELOG lists it under Breaking Changes Teams with such a variable Rename it
For user-scope rule folders, pull adds ~/.teamai/rules to permissions.additionalDirectories in ~/.claude/settings.json, after the member's own entries. A project needs no grant: its folders are in the worktree Claude Code users with user-scope rule folders None. Uninstall removes it
Each worktree of a project with rule or MCP folders gets .teamai/delivered/rules/ and .teamai/delivered/mcp/; a single-repo worktree also gets .teamai/delivered/hooks/. Git ignores it through its own .git/info/exclude block, whatever sharing.gitExclude says Teams with rule, MCP or single-repo hook folders None
Once a worktree is removed, the next pull of another worktree, or teamai doctor --fix, removes the team hook entries it left in HOME Single-repo teams with HOME-file hook tools None
benchmarks/<suite>/SUITE.yaml is accepted, and docs and messages say SUITE.yaml. A directory holding both spellings is invalid Suite authors None
requireTeamScripts also keeps a folder hook whose command names ${TEAMAI_HOOK_DIR} Teams with that setting None
The package ships hooks/ and rules/ Everyone None

Members on an older teamai misread folders. Before #1791 they read each file of rules/api-style/ as its own always-on rule, and from #1791 on they skip the folder. Every member should upgrade before the team commits a folder; each type's docs section says so.

Limitations / not verified

  • Windows: CI only. Six unit files are added to the windows job's list (default-hooks, delivered-folders, hook-folders, mcp-folders, rule-folder-paths, workflow-folder-paths), plus new cases in e2e/hook-shells-windows.test.ts. None ran locally; the Windows (paths, hook rendering, hook shells) job passed at 9bdf7677a. hook-folders-dispatch.test.ts simulates win32 for CodeBuddy on macOS and is not on that list.
  • Agents and providers. Real-CLI runs drove Claude Code. Codex was the configured agent for one project-scope pull and uninstall. CodeBuddy, OpenCode and the bridged tools are covered by unit tests only. Only the git provider ran; gitlab and github are left to CI.
  • Chinese texts. The 8 new hooks/teamai-friction-reminder/*.zh.md texts and the zh-CN guide pages need a reviewer who reads Chinese.
  • Stored workflow folders. teamai never deletes run records. A stored folder is removed only by teamai doctor --fix, once no run and no pulled workflow uses it and it is an hour old, or once a run was swept past workflows.retention. A folder used by a run that is still kept stays.
  • SUITE.yaml two-spelling refusal. Its unit and E2E tests skip on a case-insensitive file system, so they ran on neither macOS run. Linux CI runs them.
  • Dashboard and machine gates. The Resources page shows what the team's policy refuses (sharing.mcp.allowedCommands, allowedHosts, sharing.hooks.requireTeamScripts). It does not judge what one machine lacks: a variable or secret not set, a missing requires binary, or a transport a tool cannot run. Pull names those per tool. sharing.*.autoApply and TEAMAI_HOOKS_DISABLED hold hooks until teamai hooks inject, and the page shows them in force.
  • Claude Code's local MCP scope. When teamai writes Claude Code's servers to the local scope in ~/.claude.json ([feat] keep the resources pull delivers in project scope out of git #915), Claude Code files every worktree of a repository under one key (claudeProjectKey). That entry names the folder of the worktree that pulled last, which keeps working while that worktree exists. Once it is removed, Claude Code in the others cannot start the server until their next pull.
  • Claiming a folder default from another teamai version (a slice 1 acceptance item) cannot happen today. Every folder default is private: true (workflows/teamai-import-from-mr/WORKFLOW.yaml, workflows/teamai-codebase-deep-enrich/WORKFLOW.yaml and workflows/teamai-import-from-repo/WORKFLOW.yaml, line 5). workflow publish refuses a private run with isolated_run, so no such run reaches a claim. The version-mismatch refusal is shared with single-file defaults and tested there.

Commits

145 commits, grouped by slice. The branch also has merge commits from integrating the slices and origin/main.

Slice 0. One layered resolver (3)

f7f47b08a refactor(resources): add one layered resolver for team resources
13639e0c3 refactor(workflows): find workflows through the layered resolver
d46c0d8da feat(resources): read every file of a resource folder

Slice 1. Workflow folders (8)

a01f011bf feat(workflows): read workflow folders at pull
5e6d164f8 feat(workflows): add answer_file, folder-relative prompt files and duplicate names
f28ab9f98 feat(workflows): run workflow folders from a stored copy
56f038b4a feat(workflows): warn of confined folder readers and refuse folders in benchmark arms
ac7747dee feat(workflows): reserve TEAMAI_WORKFLOW_DIR and keep it portable
d9da145a6 docs(workflows): document workflow folders
e20d4ecca test(e2e): expect workflow folders to be read, not skipped
4ef7c960c fix(workflows): free the stored folder of a run swept past retention

Slice 2. Three default workflows as folders (5)

1628ede8e test(workflows): pin the texts three defaults give the tool
542347f16 fix(workflows): give a default folder's steps the text of their files
d69ed6b1d feat(workflows): ship three defaults as workflow folders
d515aa4f1 docs(workflows): show default workflow folders and how to copy one
ade867c4d fix(workflows): refuse a default folder that ships an executable file

Slice 3. Hook folders, and delivery to the data home (15)

25326e820 feat(resources): report invalid entry lists and folder names from the resolver
3acc9e857 refactor(hooks): read team hooks through the layered resolver
77fbd72f5 feat(resources): deliver resource folders to the data home of their scope
0acc4e769 fix(lint): check every file under src/resources/ for bare remove of a delivered copy
4998b7c83 feat(hooks): read team hook folders
83ef4869c feat(hooks): deliver hook folders and run them from the data home
08aecb7be feat(hooks): keep a worktree's delivered folders out of git, and remove them on uninstall
f3997bd46 docs(hooks): describe team hook folders
4feacd514 test(hooks): run hook folders on the Windows CI job
5aa8595e4 refactor(partition): name the stale workspaces apart from removing them
7dc4d4439 fix(hooks): remove the HOME entries of a removed worktree
a18529131 test(hooks): run a hook folder on CodeBuddy's Windows gate, the Codex dispatcher and the bridge
169c7aaa8 fix(review): check hook folders on a branch as pull reads them
efd117f41 test(hooks): run a hook folder of one id from two teams, from an inherited user scope, and across versions
2fd599b15 fix(uninstall): name delivered folders by what they are in the preview

Slice 4. Default hook folders (5)

7c7411350 test(hooks): pin the hint texts teamai's hooks print today
e36564aa4 feat(hooks): ship the hint texts and thresholds as default hook folders
15725ada9 feat(hooks): replace a default hook's texts and thresholds from the team repo
ce79e15ee feat(hooks): pick each hint text's language variant, and remind zh teams in Chinese
e61bcb5cd docs(hooks): describe the default hook folders and how a team replaces one

Slice 5. Rule folders (9)

54572dc8c test(rules): pin the recall rule and blocks as teamai delivers them today
f60be6b26 feat(resources): walk a type whose names are paths, folders included
c4d1a6724 feat(rules): deliver rule folders, naming their files per tool
705bb61db feat(rules): ship teamai-recall as rules/teamai-recall/, replaceable by a team
5a4ab5df4 fix(review): check rule folders on a branch as pull reads them
cb25f3a4c feat(push): keep a rule out of a rule folder, and cover rule folder paths on Windows
ac48d89e7 test(rules): a workspace rule folder and an inherited user one keep their own files
829f87750 docs(rules): document rule folders as a deterministic skill
9bd991a75 fix(rules): name a rule folder's files only when they stop being rules

Slice 6. SUITE.yaml (3)

2a937fa38 feat(benchmarks): read a suite from SUITE.yaml as well as suite.yaml
af41dd22e feat(benchmarks): accept SUITE.yaml in benchmark try, status and messages
74b64aa72 docs(benchmarks): show SUITE.yaml as a suite's file

Slice 7. MCP server folders (6)

e4e209d0d feat(mcp): read and deliver team MCP server folders
a08d0fce1 test(mcp): run MCP server folders on the Windows CI job
b55a5d2d4 docs(mcp): describe MCP server folders
e6d505989 feat(mcp): remove MCP server folders with teamai remove mcp
d668e2a24 fix(review): check MCP server folders on a branch as pull reads them
c4ffd781f docs(cli): name MCP server folders in remove --role help

Across types: markers, docs, CHANGELOG (7)

d8ae2234f fix(env): say why each reserved team env name is reserved
e7c09d90f docs(sharing): describe reserved folder names as this release reads them
78b05abf0 docs(changelog): describe resource folders as this release ships them
0b52f36d2 refactor(resources): read hook and MCP places through one helper
7ea4b4432 fix(cli): stop calling workflows, hooks and MCP servers single files
6603d4c88 refactor(folder-markers): give only a skipped folder type a skip line
48df00b23 docs(changelog): describe rule folders once, and drop a claim no folder default can reach

Dashboard (8)

79459a095 feat(resources): list every definition a survey finds
ef5355ffb feat(dashboard): read which definition of each resource applies, and why
2ff76a9ca fix(dashboard): count a default hook text as changed by what the hint reads
108b208f0 feat(workflows): record the defaults that cannot start against the team's workflows
0249708c9 feat(dashboard): show which definition of each resource applies, and what is wrong
ff3897bb7 refactor(rules): read which recall folder applies apart from its warning
6364b1bf7 feat(dashboard): list rule folders and teamai's recall rule by layer
36eb6ee9d docs(dashboard): describe the resource layers on the Resources page

Review fixes (76)

21c9657a5 fix(workflows): skip a teamai- folder that names no default
a32e36605 fix(uninstall): remove a remote team's rule folder copies in the worktree
da30f71ce docs(doctor): say that --fix removes stored workflow folders
9a87f5fa7 docs(sharing): say a single-repo hook file differs per worktree
b8e8818a0 refactor(tools): put channelsOf's doc comment back on it
3013ac521 refactor(resources): read hook and MCP folders through one marker reader
d7e686344 refactor: find the package root through one helper
9ecc311eb refactor(folders): read rendered text files through one helper
ab37701ec refactor(default-hooks): prove every text is read instead of throwing
a60fbefbc refactor(workflows): name retypedInputs' arguments and pin folders together
3e106b0af fix(resources): take only en and zh as language variants of a folder text
458ecb8ee fix(resources): say why a delivered folder could not be replaced
f6c9a5909 refactor(review): read hooks.yaml without turning an error into empty text
358475866 refactor(hooks): release a removed checkout's hooks only where pull prunes it
659d5f19c refactor(resources): spell each folder marker and folder path variable once
eb9218241 refactor(resources): resolve hooks and MCP servers through the resolver
9823edabd refactor(hooks): name a delivered hook folder FolderDelivery, as every type does
fc50f95ed fix(resources): say team folders, not hook files, when the delivered block cannot be written
16d127d9a fix(workflows): take a WORKFLOW.yaml as a folder only where the scan meets folders
ed9c12a43 fix(review): name a rule folder's files only where the branch adds its RULE.md
7d2809b5b refactor(rules): name the recall rule's marker from its layout
6ef12245a fix(review): warn about a teamai- folder that replaces no default, which pull skips
0b67e152f refactor(resources): give a worktree's .teamai/delivered/ one owner
faafa77a5 fix(resources): put a delivered folder back when its new version cannot take its place
edc6ce226 fix(review): say nothing of where a folder pull skips sits
32152678d fix(rules): refuse a recall rule replacement that holds a link
c3c2295e6 fix(review): fail a recall rule replacement that pull refuses
a96473d6a fix(uninstall): remove the delivered folders of every worktree of the project
1a0287b5e fix(resources): keep a delivered folder the team renamed only in case
178f93a08 fix(rules): refuse a recall rule replacement that names ${TEAMAI_RULE_DIR}
62e49b054 fix(workflows): record the team commit of a workflow folder holding a CRLF file
9bdf7677a fix(resources): deliver a type's folders all or none
3eefaf3cc docs(workflows): say where the three folder defaults moved, beside the copy steps
0208f61bd fix(workflows): name a workflow folder's path where a message points to the workflow
11771a56a fix(resources): name a folder that is a symlink instead of dropping it
aedb1f920 docs(changelog): list the reserved folder env names as a breaking change
4c36235cf fix(workflows): name a workflow folder that is a symlink, in pull and in review
245f5a444 fix(mcp): keep a server's folder when the team's secrets cannot be read
c56847204 fix(resources): finish a folder delivery whose old version cannot be removed
aa382b705 fix(rules): keep the folder of a removed rule while the member keeps an edited copy
ca9d0e27b fix(dashboard): show a workflow folder pull skips as refused
01406b649 fix(mcp): recognise a folder server's earlier versions after the records are lost
435048d79 docs(defaults): add a Chinese README to each default folder
5d8f65c4a fix(review): check every file of a workflow folder for credentials
edb22d2fa fix(agents): deploy only teamai's agents from the package directory
5d1d7732f chore(docs): move the README images to docs/assets
57b627404 fix(mcp): keep the folder of every server whose configuration pull keeps
991857264 fix(rules): keep the files a kept rule copy names, and deliver both folder roots together
c97cbaa3d fix(dashboard): show a server or hook the team's policy refuses as refused
ab435fd9a docs(defaults): rewrite the default READMEs as tables and decision trees
a8d35457f fix(resources): keep the files an earlier version of a folder had until the folder goes
f2742b72c fix(resources): deliver rule and MCP folders to each worktree
c674de897 fix(resources): remove a folder only once no configuration that names it is left
19165a0fe fix(resources): keep earlier files only where a path names them, and tell case apart where the disk does
a6e324284 fix(mcp): put back the folder version a configuration runs when its write fails
14ba3f04d fix(pull): say when the team MCP servers could not be applied
b440166a1 test(mcp): keep the file a server an excluded tool installed runs while the team renames it
db8c1e302 test(pull): mock describeKeptMemberServer where pull's MCP step reads it
f9c54edb9 fix(mcp): keep a server folder while any tool's file still holds an entry of its name
18ed8e8ef fix(hooks): remove a hook folder only once no installed entry runs from it
10e10703c fix(rules): write inlined rules after their folders, and remove a rule folder's source
575328432 fix(uninstall): remove teamai's copies of a rule folder, and keep the folder a kept copy names
a042b9a8d fix(hooks): deliver a hook folder per command, so an entry pull cannot rewrite keeps its files
02f0ad66d fix(hooks): read the main checkout's hook records where they are, before removing a folder
64fc4ac3b fix(folders): version a hook or MCP folder by its whole definition
c8cdfafc6 fix(uninstall): keep a delivered folder a file it leaves still names
7e21f8ec2 fix(folders): version a hook or MCP folder by its files
4ad6f49c7 fix(uninstall): read the command CodeBuddy's project gate carries encoded
54f026449 fix(folders): give every member's checkout the same folder version
a2fc686f5 fix(uninstall): read CodeBuddy's settings as JSONC
80b45408f fix(folders): version a folder by what git stores for it
41811c09c fix(folders): refuse a folder whose files git does not list
41b137727 fix(folders): say which earlier file a new rule folder path replaced
1104e40eb fix(folders): leave out a repository under a directory git ignores
f57b27af9 fix(review): check default hook and recall replacements as pull does
70ccbab3a test(e2e): wait for the hooks' detached writers before reading events

Each resource type finds its items by name with its own code: the
workflow cache scans workflows/ and calls resolveNamespacedItems, and
default-workflows.ts reads the package's defaults. Folders (Tencent#1787) need
that lookup once, so every type gets the same file, folder and
namespace rules.

src/resources/resolver.ts exports Resources.list and Resources.resolve.
A type declares its layout (directory, marker, file naming, an optional
entry-list file); a tree holds the team's root and namespace layers,
teamai's defaults, or both. The most specific layer wins as a whole,
through resolveNamespacedItems, so replacement and conflict rules stay
those of Tencent#707. A directory holding a marker this release cannot read is
skipped, as Tencent#1791 made it. Workflows are the only registered type, and
nothing calls the resolver yet.

Verified with a table through Resources.resolve and Resources.list:
default only, team root replaces the default, a namespace replaces the
root, an inactive namespace is ignored, legacy mode, two active
namespaces conflict, a file and a folder of one name are a duplicate,
an entry in an entry-list file, plus folders in a namespace and in the
package, and no namespace read for a root-only tree. A test checks that
every registered layout's marker is reserved in src/folder-markers.ts.
npx vitest run src/__tests__/resource-resolver.test.ts: 13 passed.
tsc --noEmit and oxlint on both files pass.
The workflow cache scanned workflows/ and its namespaces itself, and
DefaultWorkflows.named and all were a second lookup over the package's
defaults. Both now go through Resources, so the folder slices change
one lookup.

syncWorkflowDefinitions lists the team's root and namespace layers with
Resources.list. The manifest is still read only when workflows or
prompts have a namespace on disk, and a manifest that cannot be read
still activates no namespace. DefaultWorkflows keeps its contract
(PREFIX, originOf, overrideProblems, guarded names) and exposes the
teamai layer, which parses each shipped file once so a default keeps
one definition object, as the retyped-input checks compare it by
identity. loadCachedWorkflow, listCachedWorkflows, the reject warning,
the reference checks, handoff's definitionsOf and the generated skill
name resolve defaults through that layer. DefaultWorkflows.named and
all are removed. The resolver reads teamai's package once per process,
as the old loader did.

The alias rules, alias_conflict, default_override_alias and the
user-scope guard in resolveStart are unchanged.

Verified: the 19 unit test files that import the workflow cache,
default-workflows, namespace-resolver, handoff, workflow-skills or
folder-markers pass before and after (749 tests each). An interleaved
timing of default-workflows.test.ts and workflow-cache.test.ts against
the previous commit shows no slowdown (34s, 34s before; 31s, 33s
after). tsc --noEmit and oxlint on the changed files pass.
Workflow, hook, rule and MCP folders (Tencent#1787) all need the same walk: every
file under the folder with its executable bit, hidden entries skipped, and a
symlink or an unreadable path reported by name instead of silently left out,
as readSuiteFiles does today.

Tested by folder-files.test.ts (listing, symlink, unreadable).
… resolver

An entry-list file that did not parse, or could not be read, resolved as a
file with no entries, so a broken hooks/hooks.yaml would have dropped every
team hook without a word. Team hooks are the first entry-list type to move
onto the resolver, so the read now says why a file or folder defines nothing.

- Resources.survey returns the resolutions and diagnostics: `invalid` for an
  entry-list file that does not parse or cannot be read and for a folder
  whose name breaks the layout's new `nameRule`; `note` for the notes an
  entry list gives and for a directory that gained the marker beside files
  its type reads, which become support files (common rule 1 of Tencent#1787).
- Resources.layer reads one layer alone, for a type that applies its own
  rules to each item before the layers are resolved.
- list and resolve take only a PlainLayout (no entry list, no name rule), so
  a type that can meet an invalid file cannot read it through them.

Verified: resource-resolver tests (18), default-workflows and workflow cache
namespace tests, typecheck, lint.
Team hooks are the next type to move onto the resolver (Tencent#1787 slice 3). The
resolver now finds them: the entries of hooks/hooks.yaml and
hooks/<ns>/hooks.yaml come from Resources.layer, and a file that does not
parse or cannot be read comes back as its diagnostic, which still stops team
hooks for the run.

The entry policy stays in namespaced-entries, which MCP shares: per-entry
roles: and unknown keys apply before the layers are resolved, legacy mode
reads the root alone, and a workspace with children unions its members. A
reader may now read a whole place (readPlace) instead of one file, so each
entry carries the file or folder that defines it; env, secrets, MCP and
models keep reading one file per place. review --branch reads a hooks file
with parseTeamHooks.

No behaviour change: the hooks, MCP, env, secrets, namespace, workspace
children and review tests pass unchanged (28 files, 1405 tests), typecheck
and lint pass.
A workflow can now be a directory, workflows/<name>/WORKFLOW.yaml with
the files it needs beside it, at the team root or in a namespace
(Tencent#1787). WORKFLOW.yaml is switched to supported in folder-markers, so
the resolver hands the sync folder items and Tencent#1791 no longer skips them.

The sync reads every file of the folder through FolderFiles and keeps
them in the cache entry as UTF-8 text with LF line endings, with the
executable bit git records (a file git does not track keeps the bit on
disk). The entry's sourceHash covers every file's path, mode and
content, so checkouts on Windows and on macOS hash the same folder
alike. WORKFLOW.yaml's name must match the folder name. Another *.yaml
in a folder is a support file, and pull prints one note per folder.

A symlink, a file that is not UTF-8, or more than 1 MB in total is the
coded diagnostic workflow_folder_invalid, which drops the last valid
version. The code is added to the failure-code list lint checks.

review --branch names a folder after its directory, so two folders in
co-active namespaces no longer read as a duplicate "WORKFLOW", and it
reviews no support file as a workflow.

Tested by workflow-folders.test.ts (root and namespace discovery, the
support-file note, symlink, non-UTF-8, size, git mode and LF hashing),
review-branch.test.ts, folder-markers.test.ts and
folder-marker-scans.test.ts, whose workflow cases now expect folders to
be read. tsc --noEmit and npm run lint pass.
…plicate names

Inside a workflow folder, prompt_file and the new answer_file name a file
of the folder, relative to its root; subdirectories are allowed, and ..
or an absolute path makes the workflow invalid. Outside a folder both
resolve under prompts/ with the namespace lookup prompt_file has today.
The sync inlines the text as the step's prompt or answer, as written,
and checks its templates at the key's own field. answer_file is an
answer-step action, so "a step has exactly one action" now lists it,
and a workflow output bundle refuses it as it refuses prompt_file.

A file and a folder of one name in one place (workflows/release.yaml
beside workflows/release/) now say so: "defined twice in one place",
with "Remove one of them" as the advice start prints, instead of the
"multiple active namespaces" text every resolver conflict got. The
conflict cache entry records the reason so start gives that advice.
Both keep no runnable version and the code workflow_namespace_conflict.

Tested by workflow-folders.test.ts (folder-relative and subdirectory
paths, .. and absolute refused, answer_file through the prompts
namespace lookup, duplicate), workflow-from.test.ts (bundle refusal),
workflow-parse.test.ts and workflow-answer.test.ts. A seeded fault that
accepts .. fails the refusal case. tsc --noEmit and npm run lint pass.
…cope

Hook, rule and MCP server folders carry files their command or text names
(Tencent#1787, common rule 9). Pull needs one owner for copying such a folder to the
scope that owns it and naming its path: DeliveredFolders.

- pathOf: ~/.teamai/<type>/[<ns>/]<name>/ for the user scope,
  ~/.teamai/projects/<slug>/<type>/... for a workspace with a remote team
  (shared by its worktrees), <worktree>/.teamai/delivered/<type>/... in
  single-repo (one per worktree). The path is the same for every version.
- deliver writes a new version to a hidden sibling and renames it into place,
  leaves a folder that already holds the version alone, removes what an
  interrupted delivery left, and records each file in the delivery ledger.
- prune removes the folders of a type the scope no longer delivers through
  removeDelivered.
- render puts the path, with forward slashes and no quoting, in place of
  ${TEAMAI_<TYPE>_DIR} in one pass, or the path from a tool's project
  directory variable (common rule 10).

Typed for hooks, rules and mcp; only hooks call it in this change.
Verified: delivered-folders tests (12), typecheck, lint.
… delivered copy

teamai/remove-delivered checked four listed files and flagged any call named
remove(. A new delivery module, such as the resource folders of Tencent#1787, would
escape it unless someone remembered to list it, and an unrelated remove (a
Set's, a helper's) was flagged in the listed files.

The rule now applies to src/pull.ts and every file under src/resources/, and
reports only remove imported from fs-extra or src/utils/fs, by name, by alias
or through the module's default or namespace import. The seven calls the wider
scope reaches delete paths the delivery record never names (docs staging, a
team env file, OpenCode's config, removeDelivered itself) and carry a disable
with that reason.

Verified: the rule's ruleHarness fixtures (10), typecheck, lint.
A team can now ship a hook as hooks/[<ns>/]<id>/HOOK.yaml beside the
scripts it runs. The hook's id is the directory name. HOOK.yaml takes a
hooks.yaml entry's keys without id, roles and projects, and its command
names the folder through ${TEAMAI_HOOK_DIR}. That variable is rendered,
in one pass and with forward slashes, to the path the scope delivers the
folder at, so the command stays the same across versions.

- requireTeamScripts lets a folder hook through when its command, before
  substitution, names ${TEAMAI_HOOK_DIR}; other commands keep the
  team-scripts rule.
- ${TEAMAI_HOOK_DIR} in hooks.yaml, a HOOK.yaml that does not parse, and
  a hooks.yaml id beside a folder of the same name each stop team hooks
  for the run and keep what is installed, as an invalid entry does
  today. The duplicate is now caught in legacy mode too, and names both
  sources.
- A teamai- folder replaces no default yet, so it is skipped with a
  warning.
- Hooks held by autoApply are listed with their rendered command.
- The hooks marker is supported, so pull no longer skips hook folders.

Verified with the new hook-folder unit tests and the test files that
import the hooks resolver, namespaced entries and folder markers
(399 passed), plus typecheck and lint.
A run of a workflow folder stores the folder's files once per
sourceHash under <dataHome>/workflows/folders/<sourceHash>/ and gives
every step TEAMAI_WORKFLOW_DIR, the copy of the folder that defines
the step. A nested workflow gets its own folder; a single file gets
none. The copy stays for the run's whole life, whatever pull does to
the folder later.

- resume --claim rebuilds the folders on the claiming machine from the
  team commit the run ran at, or from this teamai's package for a
  default.
- doctor --fix removes a stored folder once no run record and no
  cached workflow references it and it is an hour old.
- teamai's own defaults may ship as folders.
- status and list count a folder as one workflow named after it; push
  sends every file of a folder, not only its YAML.
Pull, init and hooks inject now write each team hook folder to the data
home of the scope that owns it before any tool entry names it, and
remove the scope's folders the team dropped. A folder that cannot be
written keeps the installed team hooks for that run. A workspace that
holds a hook back keeps its folders too.

In single-repo, Claude Code's command names the folder through
$CLAUDE_PROJECT_DIR ($env:CLAUDE_PROJECT_DIR when its hooks run under
PowerShell), so a committed .claude/settings.json holds the same
command in every worktree. TOOLS records the variable as
hooks.projectDirVariable; other tools get the absolute path.

The team hook history also reads committed HOOK.yaml versions, with the
id from the directory and the current scope's path, so teamai still
recognises entries it wrote from an earlier version.

Verified with the new delivery tests (user scope, a new version, a
dropped folder, single-repo, history) and the test files that import
src/hooks.ts: 1859 passed; the 119 failures all come from os.userInfo()
failing in the sandbox, in local-agent, which this change does not
touch. Typecheck and lint pass.
…n benchmark arms

- Pull warns of a confined step whose prompt names
  TEAMAI_WORKFLOW_DIR: a confined launch reads only its directory, so
  the folder may be out of its reach.
- A benchmark arm refuses a workflow folder, its own or one it runs:
  a trial runs a bundle of copies, which carries no files beside the
  workflow.
- Tests pin that the skill driver gives a command step
  TEAMAI_WORKFLOW_DIR, and that the skill generated for a folder
  leaves its README out.
- TEAMAI_WORKFLOW_DIR joins the reserved team env names, so no team
  value points a step at another folder.
- Its path uses forward slashes on Windows too, and a test in the
  Windows job runs a command step through the platform shell from a
  data home path holding spaces and non-ASCII characters.
- .gitattributes checks hooks/, rules/ and workflows/ out with LF, so
  a default folder's sourceHash matches on every system.
…ve them on uninstall

A single-repo worktree delivers its hook folders in .teamai/delivered/,
inside the team content the repository commits. DeliveredFolders.sync
now runs one type's folders end to end: deliver, prune, and in
single-repo keep .teamai/delivered/ out of git through its own
delivered-folders block in .git/info/exclude. The block is written
whatever sharing.gitExclude says, so git status, push and review
--branch never see the copies, and its exclude file is recorded so
uninstall finds it. Rule and MCP folders will go through the same call.

A full uninstall removes .teamai/delivered/ and leaves the team
content; a targeted --agent uninstall keeps it, since other tools still
run the hooks from it.

TEAMAI_HOOK_DIR joins the reserved team env names, and a test keeps
"delivered" out of every resource type and layout directory.

Verified with the delivery, hook-folder, delivered-folders,
git-exclude-delivered and env-loader tests (357 passed) and the
uninstall suite (242 passed; one failure comes from os.userInfo()
failing in the sandbox, in local-agent). Typecheck and lint pass.
The Hooks section of the sharing guide now leads with the folder form:
the block-secrets tree and its HOOK.yaml, where each scope delivers the
folder, how ${TEAMAI_HOOK_DIR} is rendered (forward slashes, no
quotes), and $CLAUDE_PROJECT_DIR in single-repo. requireTeamScripts is
described as a provenance check, not a sandbox. The Windows page shows
how to quote the variable for Git Bash, Windows PowerShell and Node
from a home holding a space. The reserved-markers section says hook
folders are read. The admin skill names the folder form, and the
CHANGELOG has the entry.

Verified with node scripts/check-docs.mjs and npm run lint.
- The workflow guide gets a "Workflow folders" section, with the tree
  and WORKFLOW.yaml first, and documents TEAMAI_WORKFLOW_DIR next to
  TEAMAI_RUN_DIR.
- The advanced guide covers answer_file, how a run keeps its copy of
  a folder, the limits, the confined-step warning and the benchmark
  arm limitation.
- AGENTS.md and the engine notes name the folder form of a default
  workflow.
- The docs example check pulls each `# workflows/<name>/WORKFLOW.yaml`
  example in a team repo of its own, with the files it names.
The Windows job now runs the delivered-folders and hook-folder unit
tests, with a new case rendering a home that holds a space and
non-ASCII letters with forward slashes. The Windows hook-shells E2E
delivers a folder under such a sandboxed home and runs its rendered
command under Git Bash, Windows PowerShell and node.

Windows does not keep the executable bit, so a delivered folder now
counts as current there when its paths and bytes match; otherwise every
pull would rewrite folders whose files a test or a team marks
executable.

Verified on macOS: the unit files pass (22 tests), the E2E file
collects and skips its 6 Windows cases, typecheck and lint pass. The
Windows cases themselves run only on the CI windows job.
teamai-import-from-mr, teamai-codebase-deep-enrich and
teamai-import-from-repo are about to move their answer texts into
files of their own. These fixtures pin what each answer step gives the
tool today, so the move can be checked to change nothing.

- Each default runs on the local driver with stand-ins for teamai and
  claude, for fixed inputs: both languages of teamai-import-from-mr,
  one component with architecture and scenarios for the deep enrich,
  one narrated item for the repo import.
- Every text the tool reads is compared byte for byte with a file
  under fixtures/default-workflow-prompts/.

Verified: the test passes on the single-file defaults, and fails when
a fixture gains a trailing newline.
…oday

The recall rule and its two instruction blocks are about to move from
TypeScript constants into the teamai folder rules/teamai-recall/. With no
team replacement they must stay byte-identical for every language value.

Capture them from the current code, for language unset, en and zh: the
rule deployBuiltinRules writes, and the blocks resolveInstructionBlocks
gives pull and the session hook. The fixtures are LF in .gitattributes so
the comparison holds on Windows too.

Verified: the new test passes against the current code (6 cases).
The friction reminder, the merged-MR hint, the TodoWrite hint, the
session-start env hint and the package hint are about to move from
TypeScript constants into hook folders a team can replace. This captures
what each prints today, through the builders the hooks call, as a
fixture: 26 cases, each for language unset, en and zh. With no team
replacement each must stay byte for byte the same afterwards.

The friction reminder, the env hint and the package hint read no
language today, so their three entries per case are the same text.

Verified: the new test passes against the current code (26 tests).
A default shipped as a workflow folder kept prompt_file and answer_file
unread: readDefault parsed WORKFLOW.yaml but never put the files' text
into the steps, so the local driver got a lease it could not run. A
team folder did not have this problem, because pull reads the files.

- resolveFolderFiles (parse.ts) reads each prompt_file and answer_file
  of a definition, inline workflows included, from a folder's files
  and checks their templates.
- Pull uses it for a team folder, in place of the same walk it did
  inline, and readDefault uses it for a default folder. A default
  whose file is missing or whose template does not check is a teamai
  bug, so it throws, as a default that does not parse does.

Verified: the new workflow-folders test fails without the change (the
steps have no prompt or answer) and passes with it.
teamai-import-from-mr, teamai-codebase-deep-enrich and
teamai-import-from-repo carried long answer texts inline in their YAML,
so a team that wanted to change one prompt had to copy and keep the
whole file. Each is now a folder a team copies and edits like its own.

- Every inline answer moves to a file of the folder, through
  answer_file: draft.en.md and draft.zh.md (still chosen by
  inputs.language), component.md, architecture.md and scenarios.md,
  and narrative.md. The files hold the parsed text exactly, with no
  trailing newline, as the block scalars gave it.
- Each folder has a README.md: the files, inputs, outputs, related
  settings and how to replace it.
- No file is executable, so the folder hashes the same on every
  system.

Verified: the fixtures of the texts each answer step gives the tool
match byte for byte after the move, and npm pack --dry-run lists every
file of the three folders.
- "Default workflows" names the three defaults that are folders and
  their files.
- "Override a default" copies teamai-import-from-mr whole, adds a
  section to draft.en.md, and pushes it.
- CHANGELOG entry.
Rules are named by their path at any depth (rules/fe/style.md is
fe/style), so the one-level layers survey and layer read do not fit them.
Rule folders (rules/fe/style/RULE.md, also fe/style) need the same
discovery the other folder types get: the marker matched against readdir
names, a folder's files kept out of the item list, a file and a folder of
one name reported as a duplicate, and the rule 1 note when a directory
that held items gains the marker.

Resources.walk gives that for a layout, and RESOURCE_LAYOUTS gains rules
(RULE.md, any .md a rule). Files are read as the rules scan read them, so
the switch to it changes nothing for file rules. The note leaves out the
marker's language variants (RULE.zh.md), which are the folder's own text.

Verified: resource-resolver.test.ts 21/21. The duplicate and note cases
passed on their first run, so I broke each in turn and saw it fail.
pruneWorkspaceDirs decided which `workspaces/<id>/` directories belong to
gone checkouts and removed them in one step. Hook records live in those
directories too, and the hooks pass needs the same answer, with the
checkout's root, before the directory goes.

staleWorkspaces now returns each stale directory with the root its `root`
file names; pruneWorkspaceDirs removes what it returns. No behaviour
change: partition, submodule-checkout and the other importers pass.
A single-repo worktree's ZCode and bridged-tool entries live in HOME,
gated to the worktree, and run the hook folders it delivered in its own
`.teamai/delivered/`. Removing the worktree left them there for good: a
full pull pruned the worktree's `workspaces/<id>/`, and with it the
records that name them, before the hooks pass ran.

releaseRemovedCheckoutHooks reads each stale workspace's hook records and
removes its gated entries from HOME, team entries only. Pull calls it
before pruning, the hooks pass calls it for the fast path, and so does
doctor --fix. The gate names the checkout's realpath, taken while it
existed, so the removed root is resolved through its nearest existing
ancestor.

Tested by a unit test through reconcileTeamHooksForConfig and an E2E with
two real worktrees: a full pull of the remaining worktree and doctor --fix
each leave no entry naming the removed one, and each worktree runs its own
branch's script.
teamai's hints kept their texts and thresholds as TypeScript constants,
so no team could change them. They now live in five folders of the npm
package, laid out as a team's own hook folders are: hooks/<name>/ with
HOOK.yaml holding `with:`, and one file per text, `{{ name }}` marking
a variable:

  teamai-friction-reminder  min_tools, min_score, weights, tool-error
                            tiers and bonuses (the CONTRIBUTE_* values);
                            the headline, task and action texts
  teamai-mr-hint            lookback_days, max_mrs; offer-command and
                            offer-workflow, with .en.md variants
  teamai-todowrite-hint     message, with an .en.md variant
  teamai-env-hint           variables, secrets, exec, secrets-rule
  teamai-package-hint       message

src/default-hooks.ts keeps the contract of each folder in code: the
parameters with their ranges and the variables each text offers. It
reads a folder with CRLF read as LF and one trailing newline dropped,
picks <text>.<language>.md over <text>.md, and fills variables in one
pass. The handlers keep their logic and build their text from the
folder; the older entry points share the same builders. The package
files list gains hooks.

Verified: the golden texts captured before this change match byte for
byte (26 cases, three languages each); the 28 test files importing the
changed modules pass apart from the 118 local-agent tests that fail on
this machine without the change (os.userInfo()); typecheck and lint
pass.
A team can now ship a stdio MCP server as mcp/[<ns>/]<name>/MCP.yaml
beside the files it runs, so a script server no longer needs a separate
package or install step. The server's name is the directory name, under
the MCP name rule (letters, digits, - and _). MCP.yaml takes an mcp.yaml
server's keys without name, roles and projects. ${TEAMAI_MCP_DIR} in its
command, args and env is rendered, in one pass and with forward slashes,
to the folder's path in the data home of the scope that owns it; headers
are left as written.

- Pull, mcp inject and every other command that applies team MCP write
  each folder to that data home with DeliveredFolders.sync before any
  tool config names it, and remove the
  scope's folders the team dropped. A folder that cannot be written keeps
  the installed team MCP servers for that run. A workspace that holds a
  server back keeps its folders too.
- The rendered server goes to every tool config that mcp.yaml reaches.
  requires: and sharing.mcp.allowedCommands apply to it as to any other
  stdio server, so the runner (uv, node, npx) is what they check.
- In single-repo the folder lands in .teamai/delivered/mcp/ and the tool
  config gets its absolute path. Claude Code does not expand
  $CLAUDE_PROJECT_DIR in .mcp.json, so TOOLS gains no MCP variable.
- An http or sse folder, ${TEAMAI_MCP_DIR} in mcp.yaml, an MCP.yaml that
  does not parse, a refused folder name, and an mcp.yaml server beside a
  folder of the same name each stop team MCP for the run and keep what is
  installed, as an invalid entry does today. A teamai- folder is skipped
  with a notice, since teamai ships no MCP server it could replace.
- A directory holding any folder marker is never read as a namespace, so
  mcp.yaml scans no longer descend into a server folder.
- TEAMAI_MCP_DIR is reserved, so no team env value can shadow it.

Verified with the new MCP folder unit and delivery tests (two workspaces
bound to different teams each start their own server, user scope,
single-repo with git status clean, requires, allowedCommands, dry run, a
dropped folder, an invalid folder keeping what is installed) and the 302
test files that import the touched modules: 2404 passed. Of the 148
failures, 140 are local-agent MCP and model-config tests that fail
identically on the parent commit, from os.userInfo() failing in the
sandbox, and 1 is uninstall for the same reason; the other 7 were
mcp-cmd fixtures on the old shape, now fixed (13 passed). Typecheck and
lint pass.
Reading CRLF as LF only for UTF-8 text still split members: Git for
Windows applies core.autocrlf to every file it treats as text, so a .bat
saved in GBK got another version on Windows than on macOS, and in
single-repo the committed .claude/settings.json flipped between them.

A file git tracks and the checkout has not changed now counts by its
committed mode and blob id, which every checkout of a commit shares,
whatever autocrlf, fileMode or the encoding. A file the author has not
committed yet counts as it is on disk. One `git ls-files` per folder
tells them apart. Pull no longer copies the files git ignores, so a
version covers exactly the files it delivers. Outside git every file
counts as it is on disk, and a git failure now stops the folder with
git's error instead of giving another version without a word.
@hz89Dev

hz89Dev commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

The P1, the P2 and the first nit from the review at a2fc686f are fixed in 80b45408f, along your lines. Each fix has a test that failed on the earlier formula.

Finding Fix Test
[P1 blocking] A GBK .bat still splits members DeliveredFolders.identify runs one git ls-files -z -t -s -o -m --exclude-standard -- . per folder. A file git tracks and the checkout has not changed (H) counts by its committed mode and blob id, whatever autocrlf, fileMode or the encoding. A file the author has not committed yet, edited (C) or new (?), counts by its bytes and executable bit on disk delivered-folders.test.ts "is the same in every checkout of a commit, whatever autocrlf, the executable bit or a file's encoding" (two clones of one commit, a GBK .bat, one clone autocrlf=true, fileMode=false); "changes when the team commits a change to a file's mode alone"; "counts what the author has not committed yet: an edited file, then a new one"
[P2 non-blocking] The version covers fewer files than delivery copies The first option: pull delivers the files the version covers. A file git ignores is neither versioned nor copied. A mode change git records gives a new version, so placeAll no longer rewrites a version's directory for a mode or an ignored file. The guide (en and zh-CN) and the CHANGELOG say so "delivers none of the files git ignores"
[P3 nit] gitIgnored reads every git failure as nothing ignored Only gitFindsNoRepository (no .git up the tree, checked without starting git) leads to the on-disk identity. Inside a repository, a git failure makes the folder invalid: hooks/block-secrets/ cannot be delivered: git could not list the files of <dir> (<git's error>). Fix what git reports, then run teamai pull again. "fails, naming the folder, when git cannot list it"; hook-folders.test.ts "when git cannot list a folder's files, naming the folder and what to do"

I kept untracked files in the version, as you suggested, so an author's uncommitted folder still versions. A member's own stray untracked file in a committed folder, such as desktop.ini, still counts for that member. Leaving it out would mean either not delivering it, which breaks the author testing a new script before committing, or delivering files the version does not cover, which is your P2.

[P3 nit] review --branch versioning every folder: I left it. Review reads a folder as pull reads it (placeFindings says so), and now that git decides which files a folder holds and can fail, review reports a folder pull would refuse. The cost is one git ls-files per folder.

Real CLI, in the description: the team adds a GBK start.bat to jira-lite. One clone laid out the Windows way (autocrlf=true, fileMode=false, an ignored __pycache__/), then the macOS way, both give jira-lite.edef9a43, and __pycache__/ is not copied. A Python script outside teamai gives edef9a43 from git ls-files -s.

Checks at 80b45408f: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since a2fc686f5 (23467 tests, wider with the origin/main merge) pass, apart from the usual 9 OpenCode doctor failures that only happen in parallel runs. E2E hook-folder-worktrees, mcp-uninstall and managed-resources-uninstall: 7 passed.

Could you take another look?

@SaulMoro

SaulMoro commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Thanks. Versioning by git's blob ids fixes the GBK case and the mismatch between version and delivery. -m compares through checkout's filters whenever the stat data changes, so a CRLF checkout that was only touched still counts as unmodified. A git failure keeps what is installed, and the helper computes blob ids with git hash-object rather than reusing the implementation. One more case to fix before I approve:

[P2 non-blocking] src/resources/delivered-folders.ts:239: kept keeps only files that git ls-files lists by their own path. A submodule is listed as one gitlink record (H 160000 <commit> 0\tserver), and a nested repository as ? nested/, so none of the files under them match. They drop out of both the version and the delivery, and nothing is printed. A team that vendors an MCP server as a submodule, mcp/jira/server/ (pull updates team submodules), got server/ delivered at a2fc686f, but at 80b45408 it gets only MCP.yaml, and the server fails with "file not found". Refusing the folder would fail closed, for example mcp/jira/ cannot be delivered: server/ is a git submodule or repository of its own. More generally, name any file in files that git neither lists nor ignores, instead of dropping it. That also covers an NFD name on macOS that the index holds as NFC.

Nits, for your judgement:

  • [P3 nit] delivered-folders.ts:236: a file under assume-unchanged or skip-worktree that the member edited still counts by its committed blob. The version stays the same while the bytes delivered change, so that version's directory is rewritten in place.
  • [P3 nit] delivered-folders.ts:207: a member who turns core.autocrlf off after checkout gets a version of their own once the mtimes change (ls-files -m then reports every file as C).
  • [P3 nit] delivered-folders.ts:187 and docs/guide/sharing.md:330: the text says "committed", but the blob comes from the index, so a staged edit counts by its staged blob.

A folder's version and delivery kept only the files git ls-files names by
their own path. A submodule is one gitlink record and a repository of its
own one `? dir/` record, so a team that vendors an MCP server as a
submodule got only MCP.yaml delivered, and the server failed with "file
not found". Nothing was printed.

Pull now refuses such a folder, checked out or not, and names it:
"mcp/jira/ cannot be delivered: server/ is a git submodule". Any other
file git neither lists nor ignores refuses its folder too. Paths compare
in NFC, so a name macOS holds as NFD on disk still matches the index. A
file git is told not to check (assume-unchanged, skip-worktree) counts
as it is on disk, so editing it gives a new version rather than
rewriting the old one in place.
@hz89Dev

hz89Dev commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

The P2 and two of the three nits from the review at 80b45408 are fixed in 41811c09c. Each fix has a test that failed before it.

Finding Fix Test
[P2 non-blocking] Files under a submodule or a nested repository drop out without a word A folder that holds a gitlink (mode 160000) or a ? dir/ record is refused, whether the submodule is checked out or not: mcp/vendored/ cannot be delivered: server/ is a git submodule. teamai delivers only the team repo's own files: commit those files to the team repo itself, then run teamai pull again. Any other file git neither lists nor ignores refuses its folder too, by name. Paths compare in NFC, so an NFD name on disk matches the index, and the version uses the NFC path delivered-folders.test.ts "refuses a folder holding a git submodule, whose files git does not list"; "... even where it is not checked out"; "refuses a folder holding a git repository of its own"; "delivers a file whose name is NFD on disk and NFC in git"
[P3 nit] An edited assume-unchanged or skip-worktree file keeps its version ls-files now runs with -v. Only H counts by the index; h (assume-unchanged), S (skip-worktree), C and M count as they are on disk "counts a file git is told to assume unchanged as it is on disk"
[P3 nit] "Committed", but the blob comes from the index The doc comment and the guide now say the index: the commit's mode and blob unless the author staged an edit, and "a new or edited file counts as it is on disk" docs

The not-checked-out case came from the real CLI. The pull of the first version of this fix delivered vendored with only MCP.yaml, because the member's team clone had an empty server/, so no file was missing from git's list. Now the gitlink alone refuses the folder. The record is in the description.

[P3 nit] Turning core.autocrlf off after checkout: I left it. Once the mtimes change, git status reports every file as modified too, so the version follows what git itself says about that checkout. Checking the files out again under the new setting brings the member back to the team's version.

Checks at 41811c09c: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since 80b45408f (11777 tests) pass, apart from the usual 9 OpenCode doctor failures that only happen in parallel runs. E2E hook-folder-worktrees, mcp-uninstall and managed-resources-uninstall: 7 passed.

Could you take another look?

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
  • [P2 non-blocking] Preserve retained rule references across file/directory collisions — src/resources/delivered-folders.ts:310: If a member edits a delivered rule referencing details/checklist.md, and the team replaces details/ with a file named details, this clash filter deletes the old checklist while pull preserves the edited rule. Its reference then fails with ENOTDIR. Preserve the installed folder when a retained consumer needs a path that conflicts with the replacement.

Earlier findings: The previously reported exact repros are resolved in the current diff; this finding concerns another retention path.

Testing: The description documents sufficient build and representative real-CLI/E2E verification. Older recorded commits are not blocking. Nothing from the PR was run, built, or installed during this review.

@SaulMoro

SaulMoro commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Thanks. Refusing a folder git can't list fixes the submodule case, and it fails closed: hook and MCP callers keep the installed version and its configuration, and the message prints once per pull. A single-repo author's untracked files still deliver as they are on disk, and both sides of the comparison are in NFC. One case left:

[P2 non-blocking] src/resources/delivered-folders.ts:135: git ls-files -o -i --exclude-standard doesn't descend into a nested repository. It prints the whole repository as one record, build/vend/. A folder holding a clone under an ignored directory therefore counts every file in that clone as unlisted, and pull refuses the folder with "git lists … as neither tracked, new nor ignored". That is wrong, since git does ignore those files, and the message names each of them with no cap. Remote-team members never have ignored files, so this hits single-repo checkouts and authors. Treating an ignored record that ends in / as a prefix covering everything under it fixes it.

On the CI review's file/directory clash (delivered-folders.ts:310): I'm not asking for that one. A rule folder keeps one path, and one path can't hold details as both a file and a directory, so the new version winning there is the only consistent choice. It's a limit of a fixed path rather than a bug, and a rule copy that names a path the team changed from a directory to a file can't be kept working. A short note in sharing.md beside the earlier-files sentence would be enough, if you want one.

Nits:

  • [P3 nit] delivered-folders.ts:166: the refusal lists every stray file. The first few plus "and N more" would read better.
  • [P3 nit] delivered-folders.ts:98: the new doc-comment sentence is one long line among wrapped ones.

A rule folder keeps the files an earlier version had, but where the team
turns a directory into a file of the same name, or back, the new version
takes the path and the earlier files under it went without a word. A
rule copy the member edited, which pull leaves as it is, could still name
one and fail with ENOTDIR.

The new version still wins, as every copy this pull writes names it; a
folder cannot hold both. Pull now names the earlier file that went and
what took its place, so the member can update the copy they kept.
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
  • [P2 non-blocking] Preserve retained rule references across file/directory collisions — src/resources/delivered-folders.ts:317: This earlier finding remains unresolved. If a member-edited rule still references details/checklist.md and the team replaces details/ with a file, pull retains the edited rule but deletes its checklist, causing ENOTDIR. The new warning reports the breakage without preventing it. Preserve the installed folder when a retained consumer needs a conflicting path.

Earlier findings: The other previously reported exact repros are resolved; they are not raised again.

Testing: The description documents sufficient build and representative real-CLI/E2E verification. Older recorded commits are not blocking. Nothing from the PR was run, built, or installed during this review.

@hz89Dev

hz89Dev commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

[P2 non-blocking] Rule folder file/directory clash: addressed in 41b137727, with a different fix than preserving the installed folder.

A rule folder keeps one path across versions, so it cannot hold both details/checklist.md and a file details. Whichever stays, one reader breaks. If the installed folder stayed, every rule copy this pull writes would name details and find a directory. If the new version wins, only a copy the member edited and pull kept can still name the checklist. So the new version still wins, and pull now names what went instead of dropping it without a word:

⚠ .../.teamai/delivered/rules/review-list/details/checklist.md is gone: the new version has .../.teamai/delivered/rules/review-list/details in its place. A rule copy or a configuration pull left as it was may still name it: update it to the new version's files.

The warning comes once, on the pull that makes the change. Test: delivered-folders.test.ts "says which earlier file a new one took the place of, which a copy pull left as it was may still name". Real CLI run in the description. The unit tests that reach the change (11778) pass apart from the usual 9 parallel-only OpenCode doctor failures.

@SaulMoro

SaulMoro commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

On the CI review's repeat of the file/directory clash at 41b13772: I consider it resolved, and it doesn't hold approval. Keeping the installed folder would break every rule copy this pull writes, all of which name details as a file, to save one edited copy that names details/checklist.md. One fixed path can't serve both, so the new version winning, with a warning that names what went, is the right behaviour. No further change is needed for it.

The only item still open from my review is the nested repository under an ignored directory (delivered-folders.ts:135).

`git ls-files -o -i` does not descend into a repository of its own: a
clone under an ignored directory is one record, `build/vend/`. Its files
then matched no ignored path, so pull refused the folder, naming each of
them as "neither tracked, new nor ignored". An ignored record ending in
`/` now covers everything under it.

The refusal names at most three files and how many more. The guide says
that a rule folder keeps a file the team removes, and that a path the
team turns from a directory into a file, or back, goes to the new
version, with pull naming the file that went.
@hz89Dev

hz89Dev commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

The P2 and both nits from the review at 41b13772 are fixed in 1104e40eb, and the guide has the note on the file/directory clash.

Finding Fix Test
[P2 non-blocking] A repository of its own under an ignored directory is refused An ignored record ending in / (build/vend/) now covers every file under it, so those files are left out like any ignored file, and the folder is delivered delivered-folders.test.ts "leaves out a repository of its own under a directory git ignores, as it does every ignored file" (failed before: "git lists build/vend/main.js as neither tracked, new nor ignored")
[P3 nit] The refusal lists every stray file It names the first three and how many more: git lists a.sh, b.sh, c.sh and 2 more as neither tracked, new nor ignored "names the first few files git does not list, and how many more"
[P3 nit] One long line in the doc comment Wrapped, and it now says that a repository under an ignored directory is left out
Note on the clash sharing.md (en and zh-CN), after "Edit a rule folder in the team repo": a file the team removes stays in the delivered copy until the rule goes; a path can't be both a file and a directory, so when the team turns details/ into a file the new version takes the path and pull names the file that went docs

Real CLI, in the description: with build/ ignored in the team clone and a clone of its own at mcp/jira-lite/build/vend/, git ls-files -o -i prints build/vend/ as one record, and pull delivers jira-lite.edef9a43 as before, without build/.

Checks at 1104e40eb: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since 41b137727 (11780 tests) pass, apart from the usual 9 OpenCode doctor failures that only happen in parallel runs. E2E hook-folder-worktrees, mcp-uninstall and managed-resources-uninstall: 7 passed.

Could you take another look?

@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
  • [P2 non-blocking] Preserve retained rule references across file/directory collisions — src/resources/delivered-folders.ts:317: This earlier finding remains unresolved. When a member-edited rule references details/checklist.md and the team replaces details/ with a file, pull preserves the rule but deletes its checklist, causing ENOTDIR. The warning does not prevent breakage; preserve the installed folder when a retained consumer needs the conflicting path.

  • [P2 non-blocking] Include recall replacements in credential scanning — src/review-branch.ts:861: readTeamRules excludes rules/teamai-recall/, so it never reaches this resource-based leaks check. A valid recall replacement containing a credential in block.md passes review and subsequently distributes that credential into members’ instruction files. Enumerate the recall replacement’s files for leak scanning too.

  • [P2 non-blocking] Validate default-hook replacements during branch review — src/resources/hooks.ts:196: Known default-hook folders return skipped without validation, and review’s placeFindings never invokes their separate replacement validator. Consequently, a complete hooks/teamai-friction-reminder/ with with.min_tools: 5000 produces no refusal finding, although pull rejects it. Include readDefaultHookReplacements’ refusal messages in branch review.

Earlier findings: The other previously reported exact repros are resolved; they are not raised again.

Testing: The description provides sufficient build and representative real-CLI/E2E records. Older recorded commits are not blocking. Nothing from the PR was run, built, or installed during this review.

@SaulMoro

SaulMoro commented Nov 9, 2026

Copy link
Copy Markdown
Collaborator

This was generated by AI during triage.

Thanks, 1104e40e fixes the nested repository and both nits. The CI review on it repeats the file/directory clash, which I covered above and which doesn't need a change. It also raises two new gaps in teamai review --branch. Both reproduce in the code and come from this PR, so please fix them before I approve:

  • [P2 non-blocking] src/review-branch.ts:861: the leaks check reads the resources readTeamRules gives, and that skips the recall replacement folder (src/resources/rules.ts:1718, if (name === RECALL_RULE_NAME) continue). A credential in rules/teamai-recall/block.md therefore passes review, and pull then writes it into every member's instruction files. Scan the files of the recall replacement too.
  • [P2 non-blocking] src/resources/hooks.ts:196: a default-hook replacement folder is skipped in the team hook scan, and review never calls readDefaultHookReplacements. So a hooks/teamai-friction-reminder/ that pull refuses gets no finding in review. Add the refusals from readDefaultHookReplacements to review's findings.

`teamai review --branch` skipped two kinds of folder this branch adds.
A replacement of a default hook, such as hooks/teamai-friction-reminder/
with `with.min_tools: 5000`, gave no finding, though pull refuses it.
And the leak scan never read rules/teamai-recall/, so a credential in a
recall replacement's block.md passed review and went into every
member's instructions.

Review now fails each replacement of a default hook pull refuses, with
what pull prints, and scans the recall folder for credentials and
internal addresses like the other rules. Pull and review read default
hook folders through one function.
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
  • [P2 non-blocking] Preserve retained rule references across file/directory collisions — src/resources/delivered-folders.ts:319: This earlier finding remains unresolved. When a member-edited rule references details/checklist.md and the team replaces details/ with a file, pull preserves the rule but deletes its checklist, causing ENOTDIR. The warning reports the breakage without preventing it. Preserve the installed folder when a retained consumer needs the conflicting path.

Earlier findings: Recall-replacement credential scanning and default-hook replacement validation are resolved in the current diff; they are not raised again.

Testing: The description documents sufficient build and representative real-CLI/E2E verification. Older recorded commits are not blocking. Nothing from the PR was run, built, or installed during this review.

@hz89Dev

hz89Dev commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

Both new P2s from the review at 1104e40e are fixed in f57b27af9. Each fix has a test that failed before it. The file/directory clash stays as it is, as discussed above.

Finding Fix Test
[P2 non-blocking] Recall replacements skip the leak scan leakFindings reads rules/teamai-recall/ as it reads scorers/, so a credential or an internal address in a recall replacement fails review, whether pull would use the folder or refuse it review-branch.test.ts "fails a replacement of teamai's recall rule whose text carries a credential, as it fails a rule"
[P2 non-blocking] Default-hook replacements are not validated in review Review fails each replacement pull refuses, with what pull prints. Pull and review read those folders through one function (readDefaultHookFolders in hooks.ts; defaultHookRefusals(root) for review), so the two cannot drift. The guide says so (en and zh-CN) "fails a replacement of a default hook that pull refuses, with what pull prints" (teamai's own folder, min_tools: 5000)

Real CLI, in the description:

$ teamai review --branch review-demo
✖ [structure] hooks/teamai-friction-reminder/ is refused, and teamai's default stays in force until it is fixed: HOOK.yaml: with.min_tools must be a whole number from 1 to 1000
✖ [leaks] rules/teamai-recall/block.md looks like it carries a credential (openai); remove it before this branch is merged.

Checks at f57b27af9: type check, npm run lint and npm run build exit 0. The unit tests that reach what changed since 1104e40eb (8934 tests) pass, apart from the usual 9 OpenCode doctor failures that only happen in parallel runs.

Each hook-dispatch hands its event to a detached child and exits, and the
Tencent#809 test read events.jsonl as soon as the last hook returned. On a slow
runner the last session's child had not written yet, so "records every
session" missed api-personal (CI shard 1, twice on this branch). The
test now waits for the detached children, as the helper is for.
@github-actions

github-actions Bot commented Nov 9, 2026

Copy link
Copy Markdown
  • [P2 non-blocking] Preserve retained rule references across file/directory collisions — src/resources/delivered-folders.ts:319: This earlier finding remains unresolved. When a member-edited rule references details/checklist.md and the team replaces details/ with a file, pull preserves the rule but deletes its checklist, causing ENOTDIR. The warning does not prevent breakage; preserve the installed folder when a retained consumer needs the conflicting path.

Earlier findings: The other previously reported findings are resolved and are not raised again.

Testing: The description documents sufficient build and representative real-CLI/E2E verification. Older recorded commits are not blocking. Nothing from the PR was run, built, or installed during this review.

@SaulMoro SaulMoro left a comment

Copy link
Copy Markdown
Collaborator

Choose a reason for hiding this comment

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

This was generated by AI during triage.

Approving at 70ccbab. Everything that blocked is resolved:

  • Reserved env names. TEAMAI_WORKFLOW_DIR, TEAMAI_HOOK_DIR, TEAMAI_RULE_DIR and TEAMAI_MCP_DIR are listed under Breaking Changes, with what a team that sets one should do (aedb1f92).

  • Symlinked folder root. A hook, rule, MCP or workflow folder that is itself a symlink gets a diagnostic. For workflows that diagnostic is workflow_folder_invalid, and review --branch now follows such a link within the branch (11771a56, 4c36235c).

  • MCP folders of kept servers. Pull now works out which servers keep their installed configuration before it delivers any folder: a server a workspace holds back, a server whose declared secret is not set on this machine, and every server when secrets cannot be read. Each of those keeps its folder as it is (245f5a44, 57b62740).

  • Backup removal. If an old version cannot be removed after the swap succeeds, pull only warns. What was delivered is recorded, and the new hook and MCP configuration are still applied (c5684720).

  • Edited rule copies. A rule folder stays while any tool still holds a copy of that rule, including OMP's flat names. A kept edited copy also keeps the files the new version dropped. The data-home folders and their worktree copies are written in one delivery (aa382b70, 99185726).

  • Dashboard. A teamai- workflow folder that pull skips now shows as refused, and so do a server or hook the team's policy refuses, each with pull's message (ca9d0e27, c97cbaa3).

  • MCP ownership history. Past versions of each committed MCP.yaml now count during recovery (01406b64).

  • Workflow folder leaks check. review --branch now reads every file in a workflow folder, the same as for hook, MCP and rule folders (5d8f65c4).

  • Shared folders across worktrees. In a project, rule and MCP folders are now delivered to each worktree's .teamai/delivered/. A pull in one worktree no longer changes what another worktree runs or reads (f2742b72). Remote-team hooks stay shared, which is correct, since every worktree runs the same hook entries. The single ~/.claude.json local-scope entry is listed under Limitations.

  • Failure-path P2s. Excluded targets keep their servers' folders, and a folder keeps the files an earlier version had (a8d35457).

  • Prune after the configuration. MCP folders are now placed with their previous version set aside. A failed configuration write puts the folders back along with the configurations. Prune runs only after every write, and keeps any folder an installed entry still names: a kept, held or excluded server, including one the team moved to mcp.yaml (c674de89, a6e32428). A failed MCP reconcile now gives a warning instead of going only to debug.log (14ba3f04), and this is listed under Bug Fixes.

  • Earlier files. Your reason for keeping them holds: an edited rule copy or an excluded tool stays on the old version on purpose, beyond any one run. A folder that replaces a default hook now holds only its current files. Case-only renames are told apart where the disk can hold both names, and every delivery site has to declare earlierFiles (19165a0f).

  • Hermes inline rules. A pull that could not rewrite every inline block keeps every delivered rule folder (c674de89).

  • Retention from what survives. Once writes are done, MCP prune keeps the folder of every server some tool's file still holds an entry for (f9c54edb). Hook folders are pruned after every tool's entries are written, keeping each hook a manifest of the scope still records (18ed8e8e). Inline rule files are written after RuleFolders.sync (10e10703).

  • teamai remove rules on a folder. It removes rules/<name>/ from the team repo, and checks each tool's copy against the text pull renders for that tool (10e10703).

  • Versioned hook and MCP folders. A hook or MCP folder sits at <name>.<version>/, where the version hashes the whole definition, and stays while any surviving entry names it. The prune decodes CodeBuddy's Windows gate command before matching. An unchanged definition keeps its version: keys are sorted, the schemas have no defaults, and ${VAR} is hashed before it is filled in (a042b9a8, 64fc4ac3, 02f0ad66). Rule folders keep one path and are the only ones that still keep earlier files.

  • Uninstall. Delivered folders go last. A folder that a file uninstall leaves still names is kept, judged per worktree, and named in a warning. Every MCP folder is kept when an MCP file cannot be read (57532843, c8cdfafc).

  • Same version on every machine. A tracked, unchanged file counts by its index mode and blob id, and a new or edited one by its bytes on disk. Paths compare in NFC, and ignored files are neither versioned nor delivered. So a GBK .bat, autocrlf, fileMode and each member's own excludes give one version per team commit (54f02644, 80b45408).

  • Folders git can't list. A submodule, a nested repository that git doesn't ignore, or any file git neither lists nor ignores refuses the folder, with a message, and the installed version stays (41811c09, 1104e40e).

  • Rule path clash. When the team turns a directory into a file, the new version takes the path and pull names the file that went. sharing.md says so in both languages (41b13772, 1104e40e).

  • Uninstall and CodeBuddy. Uninstall decodes CodeBuddy's project-gate command and reads its settings as JSONC (4ad6f49c, a2fc686f).

  • review --branch checks what pull checks. It now runs the leaks check over the recall replacement folder, and reports a default-hook replacement pull would refuse (f57b27af).

  • The worktree attribution E2E waits for the hooks' detached writers before it reads events, so the last session no longer races the assertion (70ccbab3).

@hz89Dev

hz89Dev commented Nov 9, 2026

Copy link
Copy Markdown
Contributor Author

@SaulMoro both gaps from your comment are fixed in f57b27af9, with a test for each that failed before it (details in the reply above): review now scans rules/teamai-recall/ for credentials, and fails each default hook replacement pull refuses, through the same reader pull uses. 70ccbab3a makes the #809 E2E wait for the hooks' detached writers, which is what failed shard 1. All 18 checks pass at 70ccbab3a.

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.

[feat] Resources as folders: workflows, hooks, rules and MCP servers carry their own files

3 participants