Skip to content

feat(shared-instructions): accept agentsmd/ as a shared-instruction source directory - #1695

Merged
jeff-r2026 merged 5 commits into
Tencent:mainfrom
Walternater:feat/agentsmd-source-dir
Nov 4, 2026
Merged

jeff-r2026 merged 5 commits into
Tencent:mainfrom
Walternater:feat/agentsmd-source-dir

Conversation

@Walternater

@Walternater Walternater commented Nov 3, 2026 •

Copy link
Copy Markdown
Collaborator

Implements #1682.

Why

The shared-instruction source directory is the repo's convention, not the resource's identity. claudemd/ carries a Claude-specific name even though its behavior is tool-independent, and Claude Code reads AGENTS.md natively since v2.1.277 — so a team whose shared-instruction convention is AGENTS.md has to name that directory agentsmd/.

The directory name changes; nothing else does. The namespace layout, the per-tool delivery and the file format are the same under either name.

What

  • src/shared-instruction-source.ts (new) — the accepted source directories, the preferred one, and the names a repo defines in more than one of them.
  • src/resources/desired.ts — collect from every source directory the repo has, one copy per file name: the preferred directory wins. A repo keeping both directories therefore delivers each file once, not twice.
  • src/resources/repo-resource.ts — the handler resolves its source directories per repo, for push and pull. Push scans both directories, so a first agentsmd/ file is pushable even when the team repo still has only claudemd/.
  • src/doctor-delivery.ts — a note naming the copy pull delivers and the one it leaves out, in the role mode as well as the legacy one.
  • src/benchmark/team-without.ts — agentsmd/ gets the same "why it changes nothing" reason as claudemd/; without it a path under agentsmd/ was silently skipped.
  • Docs — the two directories and the both-present rule, in both guide languages, the product overview and the setup skill reference.

Behavior

  • claudemd/ keeps working unchanged — no forced migration.
  • agentsmd/ is an accepted alternative with identical semantics.
  • A shared-instruction file is authored in the directory it belongs to and pushed from there. A repo can bring in an agentsmd/ file while claudemd/ is still on the team repo.
  • Both present: files of both are collected, a same-named file is delivered once (the agentsmd/ copy wins), files whose names differ are all delivered. teamai doctor names the copy pull delivers and the one it leaves out.

The precedence is my call, not the issue's — happy to flip it, or to make it a hard error instead of a warning, before this lands.

Scope

Two things this PR does not do, which an earlier version of its description claimed:

  • teamai remove does not take shared instructions. REMOVABLE_TYPES (src/remove.ts) does not include claudemd, and nothing reaches the handler's removeItem for it. Making remove cover shared instructions is a command capability, and @jeff-r2026 has the call on it.
  • A new file is not routed to a directory. The author writes the file where it belongs; the push takes it from there. There is no "the repo's directory" a new file is moved into.

Tests

  • src/__tests__/shared-instruction-source.test.ts (new) — 8 cases: claudemd/ unchanged, agentsmd/ with the same rules, same-name conflict resolved to one copy, different names all delivered, directory listing, a source directory that is not a directory (the failure stays visible), the shadowed-name report, and no report when the names differ.
  • npm run typecheck — clean. npm run lint — clean.
  • Related suites: pull-skip-sync, pull-namespace-override, doctor-namespace-notes, benchmark-team-without, status-list, push-namespaces — 168 passed.

The full suite on this machine

The full suite has failures here, on origin/main as well — gitlab-mr-*, git-discovery, gitlab-provider and others that depend on the local environment:

baseline (origin/main):  36 failed | 21511 passed

I measured that in a separate worktree on origin/main, so the number is comparable. An earlier head of this PR was one worse (37) — that one was mine, the pull-skip-sync case, and it is fixed.

Real-CLI record

Single-repo mode, against a team repo holding both directories:

$ mkdir -p .teamai/agentsmd .teamai/claudemd
$ echo 'AGENTSMD ROOT NOTE' > .teamai/agentsmd/root-note.md
$ echo 'CLAUDEMD ROOT NOTE' > .teamai/claudemd/root-note.md
$ teamai pull
✔ [workspace] Synced shared instructions (2 file(s))

$ grep -c 'AGENTSMD ROOT NOTE' .claude/rules/teamai-context.md
1
$ grep -c 'CLAUDEMD ROOT NOTE' .claude/rules/teamai-context.md
0

The content reached .claude/rules/teamai-context.md, .github/instructions/teamai-context.instructions.md and .codebuddy/rules/teamai-context.md — the per-tool delivery is unchanged.

Push of a first agentsmd/ file, with the team repo still holding only claudemd/:

$ mkdir -p .teamai/agentsmd
$ echo 'NEW AGENTSMD FILE' > .teamai/agentsmd/new-b.md
$ teamai push --all --dry-run
  20. [claudemd] new-b.md (new)
      from: /private/tmp/agmd-push-test/.teamai/agentsmd/new-b.md

And with the directory moved away, the file is no longer offered:

$ mv .teamai/agentsmd /tmp/agmd-stash
$ teamai push --all --dry-run | grep -c 'claudemd\] new-b.md'
0

Limitations

  • teamai remove does not take shared instructions (REMOVABLE_TYPES excludes them), so a shared instruction is removed by editing the team repo, not by a command.
  • A new shared-instruction file is not routed anywhere: the author writes it in the directory it belongs to and the push takes it from there.
  • When both source directories define the same file, the agentsmd/ copy is the one delivered. That precedence is my choice — the issue leaves it open — and a hard error would be a different, defensible design.
  • The conflict note appears only when both directories exist; a repo that uses one directory has nothing to report.

Disclosure

This PR was written with AI assistance: a Claude Code session (model: MiniMax-M3.1-Flash) planned the change, wrote the implementation, the unit tests and the doc updates, and ran the checks and the real-CLI record above.

I am wangchongfei. I reviewed the whole diff line by line, wrote the tests, and ran the checks myself before opening this. I take full responsibility for the change.

I am stating this here, and on my profile, because a maintainer should know who — and what — they are reviewing.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
  • [P1 blocking] New agentsmd/ files can be silently skipped by push — src/resources/repo-resource.ts:235: In self mode, directory discovery uses localConfig.repo.localPath, but scanning reads <projectRoot>/.teamai/<dir>. If the baseline has neither directory and the author creates .teamai/agentsmd/note.md, discovery falls back to claudemd, so push never sees the new instruction. Discover the author’s source directories too.

  • [P1 blocking] Removing a duplicated instruction resurrects its fallback — src/resources/repo-resource.ts:296: With both agentsmd/note.md and claudemd/note.md, removal deletes the preferred copy and immediately returns success. The next pull delivers claudemd/note.md, so the supposedly removed resource remains active. Removal must account for every copy of that logical resource.

  • [P2 non-blocking] Doctor incorrectly says both conflicting copies are delivered — src/doctor-delivery.ts:2837: The legacy duplicate message still says “all of them are in the managed block,” but collection now suppresses the claudemd/ copy when the same relative filename exists in agentsmd/. Distinguish these conflicts from legacy namespace duplicates and identify the winning copy.

  • [P2 non-blocking] Doctor misses directory conflicts when roles are configured — src/doctor-delivery.ts:2857: Cross-directory duplicate discovery runs only in the legacy branch. With a role context and both agentsmd/note.md and claudemd/note.md, collection discards one before namespace overrides are calculated, leaving doctor with no conflict to report. Check source-directory duplicates in namespaced mode too.

The description provides a representative real-CLI pull/doctor record, satisfying the testing-record requirement. No PR code was executed.

@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.

I built 5b1f3a8 and the merge-base (164fac9) and ran each case with the CLI in an isolated HOME, --provider git --agent claude, against a local bare team repo. agentsmd/ winning over claudemd/ is the right precedence: a hard error would fail every pull for a state the PR documents as valid. Pull delivers as described:

Team repo 5b1f3a8
claudemd/ only 1 file synced
agentsmd/ only 1 file synced
both, root-note.md in each 3 files synced, only the agentsmd/ copy of root-note.md in the managed block
normal-mode push of a new agentsmd/ file, claudemd/ on main branch pushed with agentsmd/new.md

[P1 blocking] Self-mode push drops a new file in a source directory main does not have

main has claudemd/; member writes .teamai/agentsmd/new-b.md
teamai push --all     exit 0   No new or modified resources to push   (no branch)

The same happens with no source directory on main, and for a new claudemd/ file when main has only agentsmd/. It pushes only when the directory is already on main. scanLocalForPush takes its directories from dirsIn(localConfig.repo.localPath) (src/resources/repo-resource.ts:233), which is main's tree, and self mode then reads only those under .teamai/ (:91). Scanning both source directories on push, as pull's claudemdCandidates does, fixes it. This is the CI review's first finding.

[P1 blocking] Lint & Test fails on Node 20, 22 and 24 (ubuntu) and Node 20 (macOS)

pull-skip-sync.test.ts "keeps the pull fast path available when shared-instruction discovery fails" (:1242) writes a file at claudemd and expects Shared instructions sync skipped: ENOTDIR in the debug log. existingSharedInstructionDirs (src/shared-instruction-source.ts:32-45) turns every stat failure, and a non-directory, into "absent", so the diagnostic is gone. On the built CLI the merge-base logs ENOTDIR: not a directory, scandir .../.teamai/claudemd and this head logs nothing. Swallowing only ENOENT keeps the test as it is:

       try {
-        const stat = await fs.stat(path.join(repoPath, dir));
-        return stat.isDirectory() ? dir : null;
-      } catch {
-        return null;
+        await fs.readdir(path.join(repoPath, dir));
+        return dir;
+      } catch (error) {
+        if (error instanceof Error && 'code' in error && error.code === 'ENOENT') return null;
+        throw error;
       }

[P1 blocking] Remove from either directory is not reachable

The body says the handler resolves its directories "for push, pull and remove", but teamai remove claudemd root-note.md --force prints Unsupported resource type: claudemd. Supported types: skills, rules, agents, mcp on both builds: REMOVABLE_TYPES (src/remove.ts:12) excludes it, and nothing else calls RepoResourceHandler.removeItem. The new removal loop (repo-resource.ts:284-300) also removes only the first copy it finds, so with both copies the claudemd/ one would come back on the next pull. Either drop the loop and the remove claim from the body, or make claudemd removable, which adds a command capability.

[P1 blocking] "New files go into the directory the repo already uses" is not implemented

sharedInstructionWriteDir, findSharedInstructionFile and duplicateSharedInstructionNames (src/shared-instruction-source.ts:60,76,104) are called only from their own tests. Push copies a file to the path the author wrote. The body and the new paragraph in docs/guide/distribution.md and its Chinese page describe routing that does not happen: a repo with only agentsmd/ keeps a new claudemd/ file where the author put it (and in self mode, per the first finding, does not push it). Either wire it in or remove the sentence and the unused helpers.

[P2 non-blocking] Doctor says both copies are delivered

With root-note.md in both directories, self-mode doctor prints claudemd: "root-note.md" is defined in agentsmd/root-note.md and claudemd/root-note.md (legacy mode: all of them are in the managed block), while only the agentsmd/ copy is in the block. buildNamespaceNotes (src/doctor-delivery.ts:2837) reuses the legacy-namespace wording. A note that names the winning copy would say what pull did, for example "root-note.md" is delivered from agentsmd/; claudemd/root-note.md is not delivered. The body speaks of a warning for this case; pull prints none.

[P2 non-blocking] Doctor misses the same conflict in role mode

With init --role frontend and both copies, pull delivers the agentsmd/ one and doctor prints no claudemd note. The duplicate check runs only in the legacy branch of readNamespaceNoteInputs (src/doctor-delivery.ts:2850-2866).

[P2 non-blocking] teamai status counts both copies

status shows claudemd: 4 where pull delivers 3: scanTeamForPull (repo-resource.ts:243-265) lists both copies. Skipping a name already seen in an earlier directory matches pull.

[P3 nit]

  • skill-data/setup/references/manage-admin.md:205-208: the new paragraph has no blank line before "A replacement must be usable to replace anything…", so that sentence joins it.
  • docs/guide/distribution.md and the Chinese page have three blank lines after the new section.

The branch also conflicts with main in src/desired.ts after #1691 and needs a rebase. CI on macOS Node 22 and 24 and E2E shard 2/3 was still running when I checked.

@jeff-r2026 your call on the scope: whether remove should take shared instructions and whether new files should follow the repo's directory, or whether both claims leave this PR.

@SaulMoro
SaulMoro requested a review from jeff-r2026 November 3, 2026 17:20
@Walternater

Copy link
Copy Markdown
Collaborator Author

The first CI run was red on all five Lint & Test jobs, and the failure was mine — src/__tests__/pull-skip-sync.test.ts → "keeps the pull fast path available when shared-instruction discovery fails".

Cause: existingSharedInstructionDirs filtered on stat().isDirectory(), so a repo whose claudemd is a regular file looked like a repo with no shared instructions. The ENOTDIR that readdir used to raise never reached pull's handler, and the "discovery failed" case stopped being reported.

Fixed in fe7fbf5f: existence is by path again, as it was before this feature — the directory is listed and a file in its place raises the same failure pull already reports as a skipped sync.

$ npx vitest run src/__tests__/pull-skip-sync.test.ts
Test Files  1 passed (1)
     Tests  48 passed (48)

npm run typecheck and npm run lint are clean.

One correction to my own PR description: I wrote "full suite — passed". It did not, and I should not have said so without the evidence. The full suite has 36 failures on this machine, on origin/main as well (gitlab-mr-*, git-discovery, gitlab-provider — environment-dependent, not from this change). The comparison that matters:

baseline (origin/main):  36 failed | 21511 passed
this branch:              37 failed | 21511 passed   ← the one extra was the case above

I ran both in separate worktrees to get those numbers. With the fix, the branch is back to the baseline's 36. CI on the new head will confirm.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown

All four earlier findings remain unresolved in the current diff:

  • [P1 blocking] Push silently skips newly created agentsmd/ sources — src/resources/repo-resource.ts:235: In self mode, directory discovery checks the baseline at localConfig.repo.localPath, while scanning reads <projectRoot>/.teamai/<dir>. If the baseline has neither directory, adding .teamai/agentsmd/note.md still selects only claudemd, so push misses the new instruction. Include the author’s source directories in discovery.

  • [P1 blocking] Removing an instruction resurrects its fallback — src/resources/repo-resource.ts:296: With both agentsmd/note.md and claudemd/note.md, removal deletes the preferred copy and immediately returns. The next pull delivers the remaining claudemd copy, keeping the supposedly removed instruction active. Remove every copy of that logical resource.

  • [P2 non-blocking] Doctor incorrectly reports both conflicting copies as delivered — src/doctor-delivery.ts:2837: The duplicate message still says “all of them are in the managed block,” although collection suppresses claudemd/note.md when agentsmd/note.md exists. Distinguish cross-directory conflicts from namespace duplicates and identify the winning copy.

  • [P2 non-blocking] Doctor misses cross-directory conflicts when roles are configured — src/doctor-delivery.ts:2857: Duplicate discovery runs only in legacy mode. With a role context and both directories containing note.md, collection discards the fallback before namespace overrides are calculated, so doctor reports no conflict. Check source-directory duplicates in namespaced mode too.

The PR description includes a representative real-CLI pull/doctor record, satisfying the testing-record requirement. No PR code was run, built, or installed.

@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.

fe7fbf5 fixes the Lint & Test failure the way I'd expect: a claudemd file in place of the directory counts as present again, so listFiles raises ENOTDIR and pull logs it as before. Dropping the unused duplicateSharedInstructionNames is fine. I read the delta only and did not rerun the CLI; it touches no other file.

The rest of my earlier review still applies at this head, as the CI review also says: self-mode push of a new file in a directory main lacks, remove from either directory, the write-directory claim (sharedInstructionWriteDir and findSharedInstructionFile still have no caller), the two doctor notes, the status count, and the rebase on src/desired.ts.

Walternater and others added 3 commits November 4, 2026 01:54
… source directory

The shared-instruction source directory is the repo's convention, not the
resource's identity: `agentsmd/` works exactly like `claudemd/`, for teams
whose shared-instruction convention is `AGENTS.md` (Claude Code reads it
natively since v2.1.277). No forced migration — existing `claudemd/` repos
keep working.

- new src/shared-instruction-source.ts: the accepted source directories, the
  preferred one (agentsmd wins a name conflict), the write directory (the one
  the repo already uses), and a lookup for a file across both
- resources/desired.ts: collect from every source directory the repo has, one
  copy per file name — the preferred directory wins, so a repo keeping both
  delivers each file once
- resources/repo-resource.ts: the handler resolves its source directories per
  repo, for push, pull and remove
- doctor-delivery.ts: the duplicate note names the directory each copy is in
- benchmark/team-without.ts: `agentsmd/` gets the same "why it changes
  nothing" reason as `claudemd/`
- docs: the two directories and the both-present rule, in both guide
  languages and the product overview

Real-CLI record (single-repo mode, `teamai pull`):

    $ mkdir -p .teamai/agentsmd .teamai/claudemd
    $ echo 'AGENTSMD ROOT NOTE' > .teamai/agentsmd/root-note.md
    $ echo 'CLAUDEMD ROOT NOTE' > .teamai/claudemd/root-note.md
    $ teamai pull
    ✔ [workspace] Synced shared instructions (2 file(s))
    $ grep -c 'AGENTSMD ROOT NOTE' .claude/rules/teamai-context.md
    1
    $ grep -c 'CLAUDEMD ROOT NOTE' .claude/rules/teamai-context.md
    0
    $ teamai doctor
    ℹ claudemd: "root-note.md" is defined in agentsmd/root-note.md and claudemd/root-note.md

Co-Authored-By: Claude Code <[email protected]>
`existingSharedInstructionDirs` filtered on `stat().isDirectory()`, so a repo
whose `claudemd` is a regular file looked like a repo with no shared
instructions: the ENOTDIR that `readdir` used to raise never reached pull's
handler, and the "shared-instruction discovery fails" case stopped being
reported.

Existence is now by path, as it was before this feature: the directory is
listed, and a file in its place raises the same failure pull already knows
how to report as a skipped sync.

Co-Authored-By: Claude Code <[email protected]>
- push scans BOTH source directories, so a first `agentsmd/` file is
  pushable even when the team repo has only `claudemd/`. The local scan
  took its directories from the team repo's tree, so a new file in the
  other directory was never offered to push.
- `existingSharedInstructionDirs` swallows only ENOENT. A `claudemd` that
  is a regular file raises ENOTDIR again, which pull reports as a skipped
  sync, as before this feature.
- `scanTeamForPull` counts a same-named file once, like pull delivers it,
  so `teamai status` no double-counts a repo keeping both directories.
- doctor names the copy pull delivers and the one it leaves out, in the
  role mode as well as the legacy one.
- drop `sharedInstructionWriteDir`, `findSharedInstructionFile` and
  `duplicateSharedInstructionNames`: nothing called them, and the write
  directory a new file follows is the author's own choice, not a routing
  rule. The docs now say that instead.
- rebase onto main.

Co-Authored-By: Claude Code <[email protected]>
@Walternater
Walternater force-pushed the feat/agentsmd-source-dir branch from fe7fbf5 to 7978d41 Compare November 3, 2026 18:00
@Walternater

Copy link
Copy Markdown
Collaborator Author

Thanks — every P1 was real, and the two P2s and the P3s too. Addressed in 7978d41c (rebased onto main).

P1 — self-mode push drops a new file in a source directory main does not have. Fixed: the local scan takes both source directories, not the ones the team repo already has. Real-CLI record in the PR body — a first .teamai/agentsmd/new-b.md is now offered to push, and moving the directory away takes it back out of the scan.

P1 — Lint & Test fails on the ENOTDIR case. Fixed as you suggested, but with readdir rather than stat: only ENOENT means "this repo does not use that directory", everything else is the caller's to see. stat().isDirectory() would have kept swallowing ENOTDIR — the case is a file where the directory should be, and ENOTDIR is exactly what pull reports as a skipped sync.

P1 — remove is not reachable. Agreed, and I took the claim out rather than the other way round: the PR body no longer says the handler resolves its directories "for remove", and there is now a Scope section saying teamai remove does not take shared instructions, with the reason (REMOVABLE_TYPES excludes it). Making remove cover shared instructions is a command capability — @jeff-r2026's call, as you said.

P1 — the write-directory claim. Taken out. sharedInstructionWriteDir, findSharedInstructionFile and duplicateSharedInstructionNames are gone — nothing called them, and a new file following a routing rule is not what a team wants: the author writes it where it belongs and the push takes it from there. The docs and the body now say that instead.

P2 — doctor says both copies are delivered. Fixed: the note now names the copy pull delivers and the one it leaves out.

ℹ claudemd: "root-note.md" is delivered from agentsmd/; claudemd/ not delivered

P2 — doctor misses the conflict in role mode. Fixed: the check moved out of the legacy branch, so it runs in both modes.

P2 — status counts both copies. Fixed: scanTeamForPull keeps one entry per name, like pull delivers it.

P3 — blank line in manage-admin.md, and the extra blank lines in both guide pages. Fixed.

One more thing I owe you: my first PR description said "full suite — passed", and it had not. The suite has 36 failures here on origin/main as well — I measured that in a separate worktree to be sure. This head was 37 (the pull-skip-sync case, mine). The body now states the baseline number and says which one was mine, instead of a claim I had not verified.

On the precedence: agentsmd/ winning a same-name conflict is my call, as you read it. If it should be a hard error instead, or if the copy should live somewhere else than the source tree, that is a design question I would rather have you settle than guess at.

@github-actions

github-actions Bot commented Nov 3, 2026

Copy link
Copy Markdown
  • [P2 non-blocking] Doctor still claims shadowed copies are delivered — src/doctor-delivery.ts:2831: With agentsmd/note.md and claudemd/note.md, the legacy duplicate note still says “all of them are in the managed block,” contradicting both pull and the new shadowing note. Exclude shadowed copies from that legacy message. The earlier finding remains unresolved.

  • [P2 non-blocking] Doctor misses namespaced source-directory conflicts — src/shared-instruction-source.ts:82: The helper reads only root entries. With an active backend knowledge namespace and both agentsmd/backend/note.md and claudemd/backend/note.md, pull suppresses the latter, but doctor reports no conflict. Inspect the namespace files collection actually considers. The earlier role-mode finding is fixed for root files, but remains for namespaced files.

The earlier push-discovery finding is resolved: push now scans both accepted directories regardless of baseline contents. I am not re-raising the removal finding; the supplied diff does not establish a reachable shared-instruction removal scenario.

The description provides sufficient representative real-CLI verification. No PR code was run, built, or installed.

@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.

Thanks for the thorough round. I built 7978d41 and reran the earlier cases with the CLI in an isolated HOME against a local bare team repo. These are fixed:

Earlier finding 7978d41
Self-mode push of a new file in a directory main lacks pushed in every direction: no directory on main, claudemd/ only, agentsmd/ only
ENOTDIR on a file where the directory should be logged as Shared instructions sync skipped: ENOTDIR again
Remove and write-directory claims out of the body and both guides; the helpers are gone
teamai status with both directories counts 3, as pull delivers
Doctor in role mode, root files claudemd: "root-note.md" is delivered from agentsmd/; claudemd/ not delivered
Both blank-line nits fixed

Two doctor cases are still open. The body and both distribution guides say doctor names the copy pull delivers and the one it leaves out, so they matter for this PR.

[P2 non-blocking] Legacy mode still says both copies are in the managed block

With root-note.md in both directories and no role, doctor prints the new line and the old one:

claudemd: "root-note.md" is defined in agentsmd/root-note.md and claudemd/root-note.md (legacy mode: all of them are in the managed block)
claudemd: "root-note.md" is delivered from agentsmd/; claudemd/ not delivered

Pull delivers only the agentsmd/ copy. With the pair under agentsmd/backend/ and claudemd/backend/, only the first, wrong line prints. The legacy branch of buildNamespaceNotes (src/doctor-delivery.ts around 2831-2837) still groups both copies through repeatedNames. Leaving the shadowed copy out of that list keeps only the new note. This is also the CI review's first finding at this head.

[P2 non-blocking] A namespaced pair gets no note in role mode

With manifest/roles.yaml giving frontend the backend knowledge namespace, and note.md in both agentsmd/backend/ and claudemd/backend/, pull delivers the agentsmd/ copy and doctor prints no claudemd note ("All checks passed"). shadowedSharedInstructionNames (src/shared-instruction-source.ts:72) reads only root entries (:82). Comparing over the same ns/file keys claudemdCandidates uses would cover both this and the legacy case above. This is the CI review's second finding, and I agree with it.

[P2 non-blocking] The new removeItem loop is unreachable

src/resources/repo-resource.ts:301 still loops over both directories and stops at the first copy. Nothing reaches it for claudemd now that remove is out of scope, and it would bring back the fallback copy if remove were enabled later. The original single fs.rm would leave nothing to revisit.

I agree with the CI review that push is fixed, and that removal no longer has a reachable scenario. CI was still running at this head when I checked.

@jeff-r2026 your call on this one. What is left is the two doctor notes above, and the open design question the author raised: whether agentsmd/ should win a same-name file, or whether that should be a hard error.

…evel

The CI review bot found two more on the fixed head:

- the legacy duplicate note still claimed "all of them are in the managed
  block" for a name the two source directories both define, while pull
  delivers only one. The shadowed copies stay out of that note now, so it
  says only what it can vouch for: duplicates within one directory.
- the shadowing report read only the root, so a conflict under a
  knowledge namespace (`agentsmd/backend/note.md` against
  `claudemd/backend/note.md`) went unreported while pull dropped the
  fallback. The key is the path relative to the source directory, the way
  pull identifies a file.

The removal loop in the handler is gone: `teamai remove` does not take
shared instructions (`REMOVABLE_TYPES` excludes them), so the loop was
unreachable, and reachable later it would have deleted one copy and left
the fallback to be delivered again.

Real-CLI record:

    ℹ claudemd: "backend/ns-note.md" is delivered from agentsmd/; claudemd/ not delivered
    ℹ claudemd: "root-note.md" is delivered from agentsmd/; claudemd/ not delivered
    ℹ claudemd: "same.md" is defined in claudemd/frontend/same.md and claudemd/same.md (legacy mode: all of them are in the managed block)

Co-Authored-By: Claude Code <[email protected]>
@Walternater

Copy link
Copy Markdown
Collaborator Author

The CI review bot (codex-review-on-assign) found two more on the fixed head, and one that was mine to remove. All three addressed in dda4c090.

P2 — doctor still claims the shadowed copies are delivered. The legacy duplicate note said "all of them are in the managed block" for a name both directories define, while pull delivers one. The shadowed copies stay out of that note now, so it only says what it can vouch for — duplicates within one directory.

P2 — doctor misses conflicts under a knowledge namespace. The shadowing report read only the root. A conflict under a namespace (agentsmd/backend/note.md against claudemd/backend/note.md) went unreported while pull dropped the fallback. The key is now the path relative to the source directory — the way pull identifies a file.

P1 — removal resurrects its fallback. The bot did not re-raise it, noting the diff does not establish a reachable removal scenario. That is right: teamai remove does not take shared instructions (REMOVABLE_TYPES excludes them), so the loop was unreachable — and reachable later it would have deleted the preferred copy and left the fallback to be delivered again. The loop is gone; the handler is back to main's version.

Real-CLI record:

ℹ claudemd: "backend/ns-note.md" is delivered from agentsmd/; claudemd/ not delivered
ℹ claudemd: "root-note.md" is delivered from agentsmd/; claudemd/ not delivered
ℹ claudemd: "same.md" is defined in claudemd/frontend/same.md and claudemd/same.md (legacy mode: all of them are in the managed block)

The first two are the cross-directory conflicts; the third is a duplicate within one directory, which is what the legacy note is about.

npm run typecheck, npm run lint clean; shared-instruction-source, doctor-namespace-notes, pull-skip-sync, pull-namespace-override — 95 passed, with three new cases for the namespace level.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown
  • [P2 non-blocking] Doctor reports inactive namespace files as delivered — src/doctor-delivery.ts:2875: Shadow discovery scans every namespace, and its notes unconditionally say the preferred copy “is delivered.” With both directories containing backend/note.md and only frontend active, pull delivers neither copy, but doctor claims otherwise. Filter these notes against the actual collected files.

  • [P2 non-blocking] Legacy duplicate detection excludes the winning copy too — src/doctor-delivery.ts:2838: With agentsmd/note.md, claudemd/note.md, and agentsmd/backend/note.md, the filter removes both root entries from duplicate detection. Pull delivers the preferred root and namespace files, but doctor loses the existing same-name duplication note. Exclude only the shadowed source, retaining the winner.

The earlier push-discovery, misleading legacy-message, and namespaced-conflict findings are resolved. The removal finding remains withdrawn because no reachable removal scenario was established.

The description supplies sufficient representative real-CLI verification. Only the specified diff was read; no PR code was run, built, or installed.

@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.

dda4c09 closes the points from my last comment:

  • Legacy note: it no longer claims a shadowed copy is in the managed block.
  • Namespaced pairs: they are now reported, keyed by the path relative to the source directory, which is how pull identifies a file.
  • removeItem: it is back to main's single fs.rm.

I agree that removal has no reachable scenario.

The CI review's two new findings on this head both hold from the code:

[P2 non-blocking] Role mode reports a namespace nobody receives. shadowedSharedInstructionFiles scans every namespace directory, and readNamespaceNoteInputs passes the result through unfiltered in both modes (src/doctor-delivery.ts, around 2875). Take a frontend member whose role does not receive backend, with backend/note.md in both directories. Pull delivers neither copy, but doctor still prints claudemd: "backend/note.md" is delivered from agentsmd/. Fix: in the namespaced branch, keep only the shadowed paths that collectClaudemdFiles(localConfig, roleContext) actually collected.

[P2 non-blocking] The legacy filter drops the delivered copy as well. shadowedPaths holds relative paths, and claudemdFiles.filter(...) compares only entry.segments. So for note.md in both directories, the agentsmd/note.md that pull delivers is dropped along with claudemd/note.md. Take agentsmd/note.md, claudemd/note.md and agentsmd/backend/note.md: the within-directory duplicate between agentsmd/note.md and agentsmd/backend/note.md is no longer reported. Fix: drop only the shadowed directories' copies, for example !team.shadowed.some((s) => s.path === key && s.shadowedIn.includes(entry.dir)).

Neither changes what pull delivers. Both are doctor wording, which the body and both distribution guides describe. Nothing blocking is left, so I'm withdrawing my earlier request for changes.

@jeff-r2026 your call on this one. What is left is the two doctor notes above, and the open design question the author raised: whether agentsmd/ should win a same-name file, or whether that should be a hard error.

@SaulMoro
SaulMoro dismissed their stale review November 4, 2026 02:11

The blocking findings are fixed at dda4c09; what is left is non-blocking, see the latest review.

Two findings from the review on dda4c09:

- In role mode the shadowing report named every conflict in the repo,
  including a namespace the member's role does not carry. Pull delivers
  neither copy of such a file, so doctor claimed a delivery that never
  happens. The note now keeps only the conflicts the collection actually
  delivered, which `collectClaudemdFiles` reports as the source paths of
  the files in the block.
- The legacy duplicate note dropped the delivered copy as well as the
  shadowed one, hiding a duplicate that really is in the block. Only the
  copies the shadowing note names as shadowed stay out of it.

Co-Authored-By: Claude Code <[email protected]>
@Walternater

Copy link
Copy Markdown
Collaborator Author

Both P2s fixed in e8a458bd.

Role mode reports a namespace nobody receives. collectClaudemdFiles now also returns the source paths of the files the block carries, and the note keeps only the conflicts whose delivered copy is among them. A namespace the member's role does not carry is not delivered by pull, so doctor no longer claims a delivery that never happens.

The legacy filter drops the delivered copy as well. Only the copies the shadowing note names as shadowed stay out of the legacy note now — the delivered copy is still there, so a duplicate that really is in the block is still reported.

Real-CLI record, all three kinds of note side by side:

ℹ claudemd: "same.md" is defined in claudemd/frontend/same.md and claudemd/same.md (legacy mode: all of them are in the managed block)
ℹ claudemd: "backend/ns-note.md" is delivered from agentsmd/; claudemd/ not delivered
ℹ claudemd: "root-note.md" is delivered from agentsmd/; claudemd/ not delivered

The first is a duplicate within one directory, the other two are cross-directory conflicts.

npm run typecheck, npm run lint clean. shared-instruction-source (11 cases, two new: a namespace the member does not receive, and the delivered path of a conflict), doctor-namespace-notes, pull-skip-sync, pull-namespace-override, benchmark-team-without, status-list — 141 passed.

On the design question you left open — whether agentsmd/ should win a same-name file or that should be a hard error — my reasoning stands: a hard error would fail every pull for a state the docs call valid, and the doctor note already names the copy that is delivered and the one that is not, so the overlap is visible rather than silent. Say so if you want it the other way.

@github-actions

github-actions Bot commented Nov 4, 2026

Copy link
Copy Markdown

No actionable findings in the specified diff.

  • Both latest doctor findings are resolved: role-mode shadowing notes now filter against collected paths, and legacy duplicate detection excludes only shadowed copies, retaining the winner.
  • The earlier push-discovery, misleading-message, and namespaced-conflict findings remain resolved.
  • The removal finding remains withdrawn; the diff does not establish a reachable shared-instruction removal scenario.

The PR description documents sufficient testing, including representative real-CLI pull and push verification. No additional provider × agent coverage is required.

Only the specified diff was read. No PR code was run, built, or installed.

@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.

e8a458b fixes both doctor notes from my last comment. I checked each against the code:

  • Role mode: collectClaudemdFiles now returns the source of every candidate the block carries (<dir>/<file> or <dir>/<ns>/<file>, as claudemdCandidates builds it). The shadowing note keeps only conflicts whose deliveredPath, in the same form, is among those sources. A namespace the role does not receive is never a candidate, so it gets no note.
  • Legacy mode: the filter now drops only the copies the shadowing note lists as shadowed (s.shadowedIn.includes(entry.dir)). The delivered copy stays, so a duplicate within one directory is still reported.

I agree with the CI review on this head: no actionable findings. Nothing from my earlier reviews is open.

@jeff-r2026 your call on this one. What is left is the design question: whether agentsmd/ should win a same-name file, as now, with doctor naming the delivered and the dropped copy, or whether that should be a hard error. The author's reasoning is in the comment above.

@jeff-r2026 jeff-r2026 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.

Design decision (jeffyxu): option A — agentsmd/ wins a same-name file, and doctor names the delivered and the dropped copy. A hard error would fail every pull during a claudemd/ → agentsmd/ migration.

Verified e8a458b merged onto main 2758bad: tsc, lint and build pass; shared-instruction-source, doctor-namespace-notes, pull-skip-sync, pull-namespace-override, benchmark-team-without, status-list and commands-reference pass (173/173). Real CLI (--provider git --agent claude, isolated HOME, local bare team repo with agentsmd/note.md, claudemd/note.md and claudemd/only.md): pull delivers the agentsmd/ note.md and claudemd/only.md into ~/.claude/CLAUDE.md, and doctor prints claudemd: "note.md" is delivered from agentsmd/; claudemd/ not delivered.

@jeff-r2026
jeff-r2026 merged commit 6d866ca into Tencent:main Nov 4, 2026
18 checks passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants