Skip to content

feat(config): add agent profile roots configuration support#1966

Open
fangzc1 wants to merge 5 commits into
git-ai-project:mainfrom
fangzc1:fix/multi-agent-session-roots
Open

feat(config): add agent profile roots configuration support#1966
fangzc1 wants to merge 5 commits into
git-ai-project:mainfrom
fangzc1:fix/multi-agent-session-roots

Conversation

@fangzc1

@fangzc1 fangzc1 commented Jul 23, 2026

Copy link
Copy Markdown

Problem

Agent hook installation and transcript recovery currently assume a single
profile root.

This breaks when an agent is launched with a non-default home, for example:

CODEX_HOME=~/.codex-personal2 codex

In this situation:

  • git-ai install may update hooks in a different profile.
  • The daemon may scan a different transcript directory.
  • Missing checkpoints leave AI edits unattributed, causing git-ai stats to
    report 0% AI.

The same issue can affect other agents with configurable profile or session
directories, so this change addresses the shared root-selection contract rather
than adding a Codex-specific workaround.

Solution

  • Add explicit multi-profile configuration through
    agent_profile_roots..

  • Always retain each agent's official default directory.

  • Preserve existing official environment-variable overrides.

  • Do not scan home directories or infer sibling profiles; additional profiles
    must be configured explicitly.

  • Share root expansion, validation, ordering, canonicalization, and
    deduplication between hook installers and transcript recovery.

  • Install, check, and uninstall profile-owned hooks across selected profiles
    for:

    • Claude Code
    • Codex
    • Cursor
    • Gemini CLI
    • Droid / Factory
  • Pass --agent-profile-root from installed hooks when runtime resolution
    needs the exact profile.

  • Sweep selected transcript roots for Codex, Claude, Cursor, Droid, Gemini,
    Continue CLI, Copilot CLI, and Amp.

  • Document the configuration in the README.

Example:

git-ai config --add agent_profile_roots.codex ~/.codex-personal
git-ai config --add agent_profile_roots.codex ~/.codex-personal2
git-ai install

The effective root set still includes the official default (~/.codex) and
the current CODEX_HOME, when set.

Resolution order

Runtime transcript resolution uses:

  1. Exact transcript path supplied by the hook
  2. Profile root embedded in the installed hook
  3. Official environment override
  4. Official default directory

Old hook commands without --agent-profile-root remain supported.

Safety and performance

  • No changes to daemon trace2 ingestion, Git proxy handling, or rewrite
    processing.

  • No new Git subprocesses, object lookups, ref checks, or per-item Git work.

  • Filesystem work remains outside the critical ingestion path.

  • Missing additional profile roots are skipped.

  • Existing unrelated user hooks are preserved.

  • Duplicate or overlapping roots are deduplicated.

Validation

  • task fmt
  • task lint
  • task build
  • 2,119 library tests passed
  • Profile-root resolver tests passed
  • Multi-profile hook installer tests passed
  • Config CLI round-trip and unset tests passed
  • Droid runtime-root regression passed
  • Codex TestRepo regression passed with committed line-level attribution from
    a non-default profile

A manual reproduction using CODEX_HOME=~/.codex-personal2 also produced the
expected Codex checkpoint, including the exact edited lines and transcript path.

Local test limitation

The complete integration suite could not run on the development machine because
Apple Git 2.39.5 does not support git worktree add --orphan and the required
git merge-tree --merge-base behavior. Feature-specific and non-worktree
regressions pass; CI can validate the remaining matrix with the supported Git
versions.


Open in Devin Review

@fangzc1
fangzc1 force-pushed the fix/multi-agent-session-roots branch from dacb985 to fb70d98 Compare July 23, 2026 14:17
devin-ai-integration[bot]

This comment was marked as resolved.

devin-ai-integration[bot]

This comment was marked as resolved.

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.

1 participant