Skip to content

fix(config): honor CODEX_HOME through toolRoots - #942

Merged
jeff-r2026 merged 3 commits into
Tencent:mainfrom
SaulMoro:fix/codex-home-tool-root
Oct 1, 2026
Merged

jeff-r2026 merged 3 commits into
Tencent:mainfrom
SaulMoro:fix/codex-home-tool-root

Conversation

@SaulMoro

@SaulMoro SaulMoro commented Sep 30, 2026 •

Copy link
Copy Markdown
Collaborator

Summary

Codex joins Claude Code as a relocatable tool. init records CODEX_HOME into toolRoots.codex, and every Codex user-root path follows it, the hook root in project scope included. This reuses the #725 toolRoots mechanism, so no new command or config key is added.

 RELOCATABLE_TOOLS (src/types.ts)
   claude → CLAUDE_CONFIG_DIR, .claude
+  codex  → CODEX_HOME,        .codex

 init
-  recordClaudeConfigRoot / releasePreviousClaudeRoot
+  recordToolRoots / releasePreviousToolRoots      # loop over the table
 doctor
-  "Claude Code root matches CLAUDE_CONFIG_DIR"
+  one check per relocatable tool: + "Codex root matches CODEX_HOME"
 Codex writes that bypassed toolPaths
-  co-author  → ~/.codex/config.toml (hard-coded)
+  co-author  → <Codex root>/config.toml        # toolRoots.codex or ~/.codex, not the skills mapping
-  skillExistsOnDisk → Claude root only
+  skillExistsOnDisk → every relocatable root

The doctor check now compares the paths each root resolves to, not "is a root recorded". An unrecorded CODEX_HOME=~/.codex passes because recording it would move nothing. An unrecorded CLAUDE_CONFIG_DIR=~/.claude still fails, because it moves .claude.json.

Closes #939

Evidence

Real CLI run of the issue's reproduction (npm run build, sandbox HOME, local bare team repo with one skill, CODEX_HOME=$HOME/.codex-alt, no ~/.codex). Commands: teamai init <repo> --provider git --scope user --agent codex --force, teamai pull --force, teamai doctor.

  • Before (origin/main df940cd):

    toolRoots in config: (none)
    ⚠   ✖ codex is installed
        → enabledAgents lists codex, but it has no directory under <sandbox>/home, so a pull delivers nothing to it.
    files under ~/.codex-alt: (none)
    

    After:

    ℹ Recorded CODEX_HOME as the Codex root: <sandbox>/home/.codex-alt
    ✔ Updated teamai hooks in <sandbox>/home/.codex-alt/hooks.json
    ✔ [user] Synced 1 skills (1 new, 0 updated)
    files: .codex-alt/hooks.json  .codex-alt/skills/demo-skill/SKILL.md  .codex-alt/skills/teamai/SKILL.md
    doctor: ✔ Codex root matches CODEX_HOME  ✔ codex is installed  ✔ teamai hooks in codex settings  ✔ Skills delivered to codex
    
  • Before (initialized with ~/.codex, then CODEX_HOME exported): doctor shows no root check. The only failure is an indirect ✖ Skills delivered to codex.
    After:

    ✖ Codex root matches CODEX_HOME
      → CODEX_HOME is <sandbox>/home/.codex-alt; this config syncs Codex to <sandbox>/home/.codex (no root recorded). Re-run `teamai init` to record it.
    
  • New unit tests pass:

    • tool-roots: Codex paths move to the root; hooks land in .codex-alt/hooks.json and ~/.codex is never created; detectToolRoot reads CODEX_HOME.
    • init: records CODEX_HOME; says nothing about a Codex root a Claude-only member never synced.
    • doctor: fails and names both directories; passes when recorded; passes for an unrecorded explicit ~/.codex.
    • coauthor-reconcile: commit_attribution goes to .codex-alt/config.toml, and stays in ~/.codex/config.toml when the team maps toolPaths.codex.skills to .agents/skills.
    • usage-tracking: a skill under the recorded Codex root counts as installed.
  • Co-author with a custom Codex skills mapping (review finding). Real CLI teamai pull --force, sandbox HOME, team toolPaths.codex: { skills: .agents/skills }, sharing.coAuthor.enabled: false, no CODEX_HOME:

    before (6963fbcb): ./.agents/config.toml: commit_attribution = ""
    after:            ./.codex/config.toml:  commit_attribution = ""
    

    Checks: npx tsc --noEmit and npm run lint pass. npx vitest run: 6663 passed, 1 skipped, 2 failed in push-env.test.ts. Those are timing failures under full-suite load: the file passes on its own (19/19) with and without this change.

Merge Danger

Door: two-way

Nothing changes until a member runs init with CODEX_HOME set. Reverting drops support for the toolRoots.codex key: an older CLI warns "Ignoring toolRoots.codex" and syncs to ~/.codex again.

Blast Radius: Codex

  • Only members who export CODEX_HOME see different behavior. After re-running init, their hooks and managed MCP servers are removed from the previous Codex root, and skills and rules there are left and named in the output.
  • codex-internal and tcodex are unchanged.
  • src/models/switch.ts still reads the live CODEX_HOME for model switching, as it does for Claude. A process without the variable, such as a hook, would switch models in ~/.codex. This behavior predates this PR and is out of scope here.
  • fix(rules): give Codex the team rules: session hooks in a project, its own AGENTS.md in user scope #940 (Codex AGENTS.md) will follow the root automatically if it declares the file as toolPaths.codex.claudemd.

Codex keeps its home in $CODEX_HOME, but teamai resolved every Codex
path under ~/.codex, so a member who exports the variable got no
skills, hooks, agents or MCP in the directory Codex reads, and doctor
stayed green.

Extend the toolRoots relocation built for CLAUDE_CONFIG_DIR (Tencent#725) to
Codex. A RELOCATABLE_TOOLS table maps each tool to its variable; init
records CODEX_HOME into toolRoots.codex, a re-init that moves the root
releases the old hooks and managed MCP servers, and doctor adds a
"Codex root matches CODEX_HOME" check. The two Codex writes outside
toolPaths now follow the root: the co-author setting in config.toml and
the skill-existence probe used by usage tracking.

The doctor check compares the paths each root resolves to rather than
requiring a record, so an unrecorded CODEX_HOME=~/.codex passes while
an unrecorded CLAUDE_CONFIG_DIR=~/.claude still fails (it moves
.claude.json).

Closes Tencent#939
Derive the Codex co-author file from the scoped paths, list relocatable
skill roots from RELOCATABLE_TOOLS, and skip the root-release warning
for a tool the member does not sync or whose old root does not exist.
@jeff-r2026 jeff-r2026 self-assigned this Oct 1, 2026
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown
  • [P2 non-blocking] src/coauthor-reconcile.ts:126 derives the Codex config directory from the first skills/settings/agents probe. With a supported custom mapping such as toolPaths.codex: { skills: ".agents/skills" }, co-author reconciliation now writes ~/.agents/config.toml instead of Codex’s $CODEX_HOME/config.toml—a regression from the previous fixed Codex location. Resolve the codex target from toolRoots.codex/the default .codex root (or its mcp path), while retaining explicit fallbacks for tcodex and codex-internal.

The PR description includes sufficient real-CLI end-to-end verification for this runtime change.

A team mapping toolPaths.codex.skills to .agents/skills sent the Codex
co-author setting to ~/.agents/config.toml. Resolve each Codex's own root
(toolRoots.codex or ~/.codex, ~/.tcodex, ~/.codex-internal) instead.
@github-actions

github-actions Bot commented Oct 1, 2026

Copy link
Copy Markdown

No findings.

  • The earlier co-author custom-path issue is resolved: Codex now targets toolRoots.codex or the default .codex root rather than deriving config.toml from the skills path.
  • The PR description includes sufficient representative real-CLI end-to-end verification for this runtime change.

@jeff-r2026
jeff-r2026 merged commit b2d3598 into Tencent:main Oct 1, 2026
13 checks passed
SaulMoro added a commit to SaulMoro/teamai-cli that referenced this pull request Oct 1, 2026
Tencent#942 pinned Codex's default paths before Tencent#938 moved its rules to the
session-start hook: no rules path, and an AGENTS.md that follows the
root in user scope.
jeff-r2026 pushed a commit that referenced this pull request Oct 1, 2026
…s own AGENTS.md in user scope (#940)

* fix(rules): inline rules without frontmatter, naming path-scoped globs

hermesRulesText becomes inlinedRulesText, the one renderer for tools that read rules from a single instructions file. It strips frontmatter and leads a path-scoped rule with 'Applies to files matching: <globs>'. Hermes SOUL.md and doctor's Hermes check use it. Part of #938.

* fix(rules): inline team rules into Codex AGENTS.md in project scope

Codex reads instructions from AGENTS.md, not from .codex/rules, so the
copies pull wrote there never reached it (#938). The codex defaults drop
rules and gain claudemd (AGENTS.md, ~/.codex/AGENTS.md at user scope).
pullAllRules syncs a [teamai:team-rules] block into that file once per
path while an enabled, installed Codex-family tool maps it, and removes
it otherwise. syncManagedInstructions probes rules ?? settings, so a
machine without Codex gets no ~/.codex.

* fix(rules): render the Codex team-rules block with inlinedRulesText

Follows the T3 rename, so a path-scoped rule reaches AGENTS.md without frontmatter, after its Applies to line.

* test(rules): cover Codex AGENTS.md in user scope, culture, shared instructions and recall

Codex now reaches AGENTS.md through its default claudemd path; these tests
pin user scope (~/.codex/AGENTS.md), a full project-scope pull writing all
four teamai blocks into one AGENTS.md, and recall on/off. Also corrects the
injectRecallBlockIntoTools comment, which listed Codex as skipped.

* fix(rules): remove Codex team rules and their old copies on uninstall

Uninstall strips the [teamai:team-rules] block and scans the legacy .codex/rules directory for teamai's copies. A shared instruction file now keeps only the blocks a remaining enabled, installed tool would write, so --agent codex drops the team-rules block while Pi keeps its own.

* fix(doctor): check the team-rules block in Codex AGENTS.md

Codex reads no rules directory, so doctor now compares the team-rules
block in each AGENTS.md an enabled, installed Codex-family tool maps
with what pull renders. It fails on a missing or stale block, on an
AGENTS.override.md that Codex reads instead, and on an entry with no
claudemd path. The file list comes from RulesHandler, the same
resolver the pull writes through.

* fix(rules): remove the .codex/rules copies earlier pulls delivered

Codex never read the <rule>.md copies teamai wrote to .codex/rules (and
.codex-internal/rules, .tcodex/rules). Every rules sync now removes the
ones that still hold what teamai delivered, including teamai-recall.md,
keeps edited copies and names them, and leaves *.rules alone.

* docs(rules): document where Codex reads team rules (AGENTS.md)

* fix(rules): give Codex its AGENTS.md rules on an already-synced pull

A CLI upgrade with the team repo unchanged takes the "Already synced" fast path, which never ran the rules sync. So a member upgrading from 0.22.0 got no team-rules block in AGENTS.md and kept the old .codex/rules copies until the repo moved or they ran pull --force. The fast path now runs the Codex part of the rules sync (block + reclaim) and nothing else.

* fix(doctor): tell a Codex member a plain pull restores the team-rules block

The already-synced pull now rewrites the block, so the fix text no longer sends the member to pull --force.

* fix(rules): give codex-internal and tcodex the codex instructions layout

codex-internal and tcodex drop their rules path and read team rules from
AGENTS.md like codex. Codex-family instruction writers probe
rules ?? settings ?? skills, so a team entry with neither rules nor settings
no longer counts as installed. writesInstructionBlock is the one answer to
which blocks a tool gets, shared by pull's writers and uninstall.

* fix(rules): keep an empty AGENTS.md that held no team-rules block

removeClaudeMdSection now reports whether it removed a section and can delete a file left holding only whitespace. The team-rules sync and recall off use it, so a pull that removed nothing no longer deletes a member's own empty AGENTS.md.

* fix(doctor): pass the Codex team-rules check when no rule has a body

When every team rule is frontmatter only, pull writes no team-rules block, so a missing block is correct and an AGENTS.override.md shadows nothing. Also note that an empty override shadows AGENTS.md too.

* fix(doctor): a plain pull applies the Codex claudemd toolPaths fix

Editing teamai.yaml moves the team repo, so a plain pull does the full sync; --force is not needed. Matches the other Codex block checks.

* fix(uninstall): name the instruction file uninstall cleans

The summary and result lines said CLAUDE.md for every instruction file, including Codex's AGENTS.md. They now print the file's path under an 'Instruction-file blocks' heading.

* refactor(recall): gate the recall block on writesInstructionBlock

recall on now asks the same question as pull's recall writer and uninstall, so the three cannot drift. No behavior change.

* fix(rules): reclaim .codex/rules copies of rules the team removed

The tombstone cleanup walks toolPath.rules, which Codex no longer has, so a copy of a rule tombstoned after the member's last pre-#938 pull stayed forever. The legacy reclaim now removes tombstoned names too, keeping and naming a copy the member changed since delivery (#822).

* test(rules): cover codex-internal and tcodex in reclaim, doctor and uninstall

Parametrizes the project-scope legacy reclaim, the four Codex doctor failure cases and the full uninstall over the Codex family.

* test(pull): cover the project-scope Codex fast path after an upgrade

* test(local-agent): pin the prompt sync into Codex's AGENTS.md

With Codex's default claudemd (#938), an HTTP prompt command reported by Codex writes the shared-instructions block into ~/.codex/AGENTS.md when ~/.codex exists, and creates nothing when it does not.

* refactor(rules): move rulePaths into rule-format

It reads a tool-neutral rule's paths: frontmatter, which both the Copilot renderer and the inlined-rules renderer use; it no longer lives in the Copilot module.

* fix(doctor): ask nothing of a Codex entry that delivers no rules to it

A team toolPaths entry such as codex: { agents: .codex/agents } has neither
rules nor claudemd: the team sends Codex no rules on purpose, like any tool
without a rules path. Doctor failed it on every member's machine (E2E
doctor-delivery-cli). It now fails only an entry that still lists the
pre-#938 rules path without claudemd. Part of #938.

* fix(rules): keep a teamai-recall.md the member edited since the last pull

The legacy Codex reclaim removed any .codex/rules/teamai-recall.md that
opened with the recall heading, so text a member appended after the last
pull that wrote it was deleted. The built-in rule is not in the delivery
ledger, so match the file against the exact bodies teamai deployed
instead; an edited copy is kept and named like other legacy copies.

* fix(rules): keep a member's empty AGENTS.md when the team-rules block goes

Removing the last block deleted any instructions file it left empty, so
an empty AGENTS.md a repository tracked was deleted once Codex was
disabled or the team had no rules left. injectClaudeMdSection now creates
a file as just the block, and deleteIfEmpty deletes only a file that
opens with it; a member's empty file is written back empty.

Also describe the per-block cleanup of shared instruction files in the
deployed uninstall skill.

* fix(rules): address review on uninstall, remove, doctor and markers

- uninstall and the legacy [teamai:rules] strip remove blocks through
  removeClaudeMdSection, so a member's empty AGENTS.md survives them as it
  does pull. Removing a block at the top of a file keeps the next one
  there, so a file teamai created still goes with its last block.
- `remove rules` refreshes with the rules this member's pull delivers
  (role, project and tag selection) instead of every rule in the repo.
- doctor reports a Codex team-rules block left behind when the team has
  no rules, and nothing else in that case.
- teamRulesBlock strips the block markers wherever they appear in a rule,
  not only as whole lines, since the block is located by substring.

* refactor(rules): split legacy Codex rule-copy ownership out of the reclaim

legacyRuleCopies classifies each .codex/rules copy (and the codex-internal
and tcodex dirs) as teamai's or edited, on the ledger, team-render,
tombstone and shipped-recall proofs reclaimLegacyRuleCopies used inline.
Read-only and public so uninstall can apply the same check. No behavior
change.

* fix(uninstall): keep edited legacy Codex rule copies, remove removed rules' copies

Uninstall picked every .md in a legacy rules dir whose name matched a
current team rule or a built-in, so it deleted copies a pull had kept as
the member's edits, and left copies of rules the team had tombstoned.
It now takes the legacy dirs from RulesHandler.legacyRuleCopies, the
check pull reclaims by: owned copies go, edited ones stay and are named
in one English warning. The tool's current rules dir is unchanged.

Addresses the codex-review findings on #940.

* fix(rules): give Codex the team rules through its session-start hook

The project AGENTS.md the earlier revision wrote the rules into is read by
Cursor, Copilot, OpenCode and Claude too, which already get the rules in
their own format. The Codex family now gets them from the teamai
session-start hook instead, and pull writes no rule file for it.

- A team-rules handler adds the user-scope rules, then the cwd project's,
  as pull resolves them, skipping a scope that does not enable the tool.
  It adds nothing on resume, whose history already holds them.
- A SubagentStart entry gives a fresh subagent the same rules.
- Both entries set additionalContextLimit: 0; past 2,500 tokens Codex
  keeps only the start and end of a hook's context.
- doctor checks the limit on the session-start entry; the AGENTS.md
  block check, its markers and its uninstall handling are gone. The block
  never shipped.
- Culture, shared instructions and recall still go to AGENTS.md; the old
  .codex/rules cleanup and the remove-rules role filter are unchanged.

For #938.

* test(tool-roots): expect Codex's instruction file under CODEX_HOME

#942 pinned Codex's default paths before #938 moved its rules to the
session-start hook: no rules path, and an AGENTS.md that follows the
root in user scope.

* fix(rules): keep Codex's project content out of AGENTS.md (#945)

The project AGENTS.md is the owners' file, and Cursor, Copilot, OpenCode
and Claude read it too. The Codex family now takes its project content
from the session hooks and its user content from its own AGENTS.md:

- Project scope: no `claudemd` in the Codex-family defaults, so pull
  writes nothing to the project AGENTS.md. The session-start and
  subagent-start hooks add the project's rules plus the culture,
  claudemd/ and recall blocks, leaving out a block another tool already
  wrote into the project AGENTS.md.
- User scope: the team rules go into a team-rules block of
  ~/.codex/AGENTS.md (and the variants' homes), beside the other blocks;
  the hook adds nothing outside a project. The "Already synced" pull
  writes the block too.
- doctor checks that block in user scope, and both hook entries' limit
  in a project. uninstall removes the block.

For #938.

* fix(rules): keep tombstoned Codex copies without delivery records
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
* fix(config): honor CODEX_HOME through toolRoots

Codex keeps its home in $CODEX_HOME, but teamai resolved every Codex
path under ~/.codex, so a member who exports the variable got no
skills, hooks, agents or MCP in the directory Codex reads, and doctor
stayed green.

Extend the toolRoots relocation built for CLAUDE_CONFIG_DIR (Tencent#725) to
Codex. A RELOCATABLE_TOOLS table maps each tool to its variable; init
records CODEX_HOME into toolRoots.codex, a re-init that moves the root
releases the old hooks and managed MCP servers, and doctor adds a
"Codex root matches CODEX_HOME" check. The two Codex writes outside
toolPaths now follow the root: the co-author setting in config.toml and
the skill-existence probe used by usage tracking.

The doctor check compares the paths each root resolves to rather than
requiring a record, so an unrecorded CODEX_HOME=~/.codex passes while
an unrecorded CLAUDE_CONFIG_DIR=~/.claude still fails (it moves
.claude.json).

Closes Tencent#939

* fix(config): address review on CODEX_HOME relocation

Derive the Codex co-author file from the scoped paths, list relocatable
skill roots from RELOCATABLE_TOOLS, and skip the root-release warning
for a tool the member does not sync or whose old root does not exist.

* fix(coauthor): resolve the Codex config root, not the skills mapping

A team mapping toolPaths.codex.skills to .agents/skills sent the Codex
co-author setting to ~/.agents/config.toml. Resolve each Codex's own root
(toolRoots.codex or ~/.codex, ~/.tcodex, ~/.codex-internal) instead.
Walternater pushed a commit to Walternater/teamai-cli that referenced this pull request Nov 2, 2026
…s own AGENTS.md in user scope (Tencent#940)

* fix(rules): inline rules without frontmatter, naming path-scoped globs

hermesRulesText becomes inlinedRulesText, the one renderer for tools that read rules from a single instructions file. It strips frontmatter and leads a path-scoped rule with 'Applies to files matching: <globs>'. Hermes SOUL.md and doctor's Hermes check use it. Part of Tencent#938.

* fix(rules): inline team rules into Codex AGENTS.md in project scope

Codex reads instructions from AGENTS.md, not from .codex/rules, so the
copies pull wrote there never reached it (Tencent#938). The codex defaults drop
rules and gain claudemd (AGENTS.md, ~/.codex/AGENTS.md at user scope).
pullAllRules syncs a [teamai:team-rules] block into that file once per
path while an enabled, installed Codex-family tool maps it, and removes
it otherwise. syncManagedInstructions probes rules ?? settings, so a
machine without Codex gets no ~/.codex.

* fix(rules): render the Codex team-rules block with inlinedRulesText

Follows the T3 rename, so a path-scoped rule reaches AGENTS.md without frontmatter, after its Applies to line.

* test(rules): cover Codex AGENTS.md in user scope, culture, shared instructions and recall

Codex now reaches AGENTS.md through its default claudemd path; these tests
pin user scope (~/.codex/AGENTS.md), a full project-scope pull writing all
four teamai blocks into one AGENTS.md, and recall on/off. Also corrects the
injectRecallBlockIntoTools comment, which listed Codex as skipped.

* fix(rules): remove Codex team rules and their old copies on uninstall

Uninstall strips the [teamai:team-rules] block and scans the legacy .codex/rules directory for teamai's copies. A shared instruction file now keeps only the blocks a remaining enabled, installed tool would write, so --agent codex drops the team-rules block while Pi keeps its own.

* fix(doctor): check the team-rules block in Codex AGENTS.md

Codex reads no rules directory, so doctor now compares the team-rules
block in each AGENTS.md an enabled, installed Codex-family tool maps
with what pull renders. It fails on a missing or stale block, on an
AGENTS.override.md that Codex reads instead, and on an entry with no
claudemd path. The file list comes from RulesHandler, the same
resolver the pull writes through.

* fix(rules): remove the .codex/rules copies earlier pulls delivered

Codex never read the <rule>.md copies teamai wrote to .codex/rules (and
.codex-internal/rules, .tcodex/rules). Every rules sync now removes the
ones that still hold what teamai delivered, including teamai-recall.md,
keeps edited copies and names them, and leaves *.rules alone.

* docs(rules): document where Codex reads team rules (AGENTS.md)

* fix(rules): give Codex its AGENTS.md rules on an already-synced pull

A CLI upgrade with the team repo unchanged takes the "Already synced" fast path, which never ran the rules sync. So a member upgrading from 0.22.0 got no team-rules block in AGENTS.md and kept the old .codex/rules copies until the repo moved or they ran pull --force. The fast path now runs the Codex part of the rules sync (block + reclaim) and nothing else.

* fix(doctor): tell a Codex member a plain pull restores the team-rules block

The already-synced pull now rewrites the block, so the fix text no longer sends the member to pull --force.

* fix(rules): give codex-internal and tcodex the codex instructions layout

codex-internal and tcodex drop their rules path and read team rules from
AGENTS.md like codex. Codex-family instruction writers probe
rules ?? settings ?? skills, so a team entry with neither rules nor settings
no longer counts as installed. writesInstructionBlock is the one answer to
which blocks a tool gets, shared by pull's writers and uninstall.

* fix(rules): keep an empty AGENTS.md that held no team-rules block

removeClaudeMdSection now reports whether it removed a section and can delete a file left holding only whitespace. The team-rules sync and recall off use it, so a pull that removed nothing no longer deletes a member's own empty AGENTS.md.

* fix(doctor): pass the Codex team-rules check when no rule has a body

When every team rule is frontmatter only, pull writes no team-rules block, so a missing block is correct and an AGENTS.override.md shadows nothing. Also note that an empty override shadows AGENTS.md too.

* fix(doctor): a plain pull applies the Codex claudemd toolPaths fix

Editing teamai.yaml moves the team repo, so a plain pull does the full sync; --force is not needed. Matches the other Codex block checks.

* fix(uninstall): name the instruction file uninstall cleans

The summary and result lines said CLAUDE.md for every instruction file, including Codex's AGENTS.md. They now print the file's path under an 'Instruction-file blocks' heading.

* refactor(recall): gate the recall block on writesInstructionBlock

recall on now asks the same question as pull's recall writer and uninstall, so the three cannot drift. No behavior change.

* fix(rules): reclaim .codex/rules copies of rules the team removed

The tombstone cleanup walks toolPath.rules, which Codex no longer has, so a copy of a rule tombstoned after the member's last pre-Tencent#938 pull stayed forever. The legacy reclaim now removes tombstoned names too, keeping and naming a copy the member changed since delivery (Tencent#822).

* test(rules): cover codex-internal and tcodex in reclaim, doctor and uninstall

Parametrizes the project-scope legacy reclaim, the four Codex doctor failure cases and the full uninstall over the Codex family.

* test(pull): cover the project-scope Codex fast path after an upgrade

* test(local-agent): pin the prompt sync into Codex's AGENTS.md

With Codex's default claudemd (Tencent#938), an HTTP prompt command reported by Codex writes the shared-instructions block into ~/.codex/AGENTS.md when ~/.codex exists, and creates nothing when it does not.

* refactor(rules): move rulePaths into rule-format

It reads a tool-neutral rule's paths: frontmatter, which both the Copilot renderer and the inlined-rules renderer use; it no longer lives in the Copilot module.

* fix(doctor): ask nothing of a Codex entry that delivers no rules to it

A team toolPaths entry such as codex: { agents: .codex/agents } has neither
rules nor claudemd: the team sends Codex no rules on purpose, like any tool
without a rules path. Doctor failed it on every member's machine (E2E
doctor-delivery-cli). It now fails only an entry that still lists the
pre-Tencent#938 rules path without claudemd. Part of Tencent#938.

* fix(rules): keep a teamai-recall.md the member edited since the last pull

The legacy Codex reclaim removed any .codex/rules/teamai-recall.md that
opened with the recall heading, so text a member appended after the last
pull that wrote it was deleted. The built-in rule is not in the delivery
ledger, so match the file against the exact bodies teamai deployed
instead; an edited copy is kept and named like other legacy copies.

* fix(rules): keep a member's empty AGENTS.md when the team-rules block goes

Removing the last block deleted any instructions file it left empty, so
an empty AGENTS.md a repository tracked was deleted once Codex was
disabled or the team had no rules left. injectClaudeMdSection now creates
a file as just the block, and deleteIfEmpty deletes only a file that
opens with it; a member's empty file is written back empty.

Also describe the per-block cleanup of shared instruction files in the
deployed uninstall skill.

* fix(rules): address review on uninstall, remove, doctor and markers

- uninstall and the legacy [teamai:rules] strip remove blocks through
  removeClaudeMdSection, so a member's empty AGENTS.md survives them as it
  does pull. Removing a block at the top of a file keeps the next one
  there, so a file teamai created still goes with its last block.
- `remove rules` refreshes with the rules this member's pull delivers
  (role, project and tag selection) instead of every rule in the repo.
- doctor reports a Codex team-rules block left behind when the team has
  no rules, and nothing else in that case.
- teamRulesBlock strips the block markers wherever they appear in a rule,
  not only as whole lines, since the block is located by substring.

* refactor(rules): split legacy Codex rule-copy ownership out of the reclaim

legacyRuleCopies classifies each .codex/rules copy (and the codex-internal
and tcodex dirs) as teamai's or edited, on the ledger, team-render,
tombstone and shipped-recall proofs reclaimLegacyRuleCopies used inline.
Read-only and public so uninstall can apply the same check. No behavior
change.

* fix(uninstall): keep edited legacy Codex rule copies, remove removed rules' copies

Uninstall picked every .md in a legacy rules dir whose name matched a
current team rule or a built-in, so it deleted copies a pull had kept as
the member's edits, and left copies of rules the team had tombstoned.
It now takes the legacy dirs from RulesHandler.legacyRuleCopies, the
check pull reclaims by: owned copies go, edited ones stay and are named
in one English warning. The tool's current rules dir is unchanged.

Addresses the codex-review findings on Tencent#940.

* fix(rules): give Codex the team rules through its session-start hook

The project AGENTS.md the earlier revision wrote the rules into is read by
Cursor, Copilot, OpenCode and Claude too, which already get the rules in
their own format. The Codex family now gets them from the teamai
session-start hook instead, and pull writes no rule file for it.

- A team-rules handler adds the user-scope rules, then the cwd project's,
  as pull resolves them, skipping a scope that does not enable the tool.
  It adds nothing on resume, whose history already holds them.
- A SubagentStart entry gives a fresh subagent the same rules.
- Both entries set additionalContextLimit: 0; past 2,500 tokens Codex
  keeps only the start and end of a hook's context.
- doctor checks the limit on the session-start entry; the AGENTS.md
  block check, its markers and its uninstall handling are gone. The block
  never shipped.
- Culture, shared instructions and recall still go to AGENTS.md; the old
  .codex/rules cleanup and the remove-rules role filter are unchanged.

For Tencent#938.

* test(tool-roots): expect Codex's instruction file under CODEX_HOME

Tencent#942 pinned Codex's default paths before Tencent#938 moved its rules to the
session-start hook: no rules path, and an AGENTS.md that follows the
root in user scope.

* fix(rules): keep Codex's project content out of AGENTS.md (Tencent#945)

The project AGENTS.md is the owners' file, and Cursor, Copilot, OpenCode
and Claude read it too. The Codex family now takes its project content
from the session hooks and its user content from its own AGENTS.md:

- Project scope: no `claudemd` in the Codex-family defaults, so pull
  writes nothing to the project AGENTS.md. The session-start and
  subagent-start hooks add the project's rules plus the culture,
  claudemd/ and recall blocks, leaving out a block another tool already
  wrote into the project AGENTS.md.
- User scope: the team rules go into a team-rules block of
  ~/.codex/AGENTS.md (and the variants' homes), beside the other blocks;
  the hook adds nothing outside a project. The "Already synced" pull
  writes the block too.
- doctor checks that block in user scope, and both hook entries' limit
  in a project. uninstall removes the block.

For Tencent#938.

* fix(rules): keep tombstoned Codex copies without delivery records
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.

[bug] teamai ignores CODEX_HOME: every Codex resource lands in ~/.codex

2 participants