Skip to content

fix(init): support git worktree hook shims#77

Open
wasabeef wants to merge 7 commits into
mainfrom
fix/worktree-agentnote-hooks
Open

fix(init): support git worktree hook shims#77
wasabeef wants to merge 7 commits into
mainfrom
fix/worktree-agentnote-hooks

Conversation

@wasabeef
Copy link
Copy Markdown
Owner

@wasabeef wasabeef commented May 13, 2026

Pull Request

Summary

  • Support git worktree commits by installing deterministic Agent Note shims in both the worktree-local git dir and the shared common git dir.
  • Resolve git hooks through Git itself with git rev-parse --git-path hooks, so init works from main checkouts, linked worktrees, bare repositories, and worktree-specific core.hooksPath setups.
  • Add regression coverage for bare/non-bare worktrees, arbitrary paths with spaces, detached/orphan/locked/relative worktrees, moved worktrees, duplicate basenames, and deinit cleanup.

Release Note Plan

Release note: Support Agent Note recording from git worktrees by sharing the hook shim through the common git directory.

Type of Change

  • Fix
  • Feature
  • Documentation
  • Refactor
  • Test
  • CI / release

Checklist

  • I kept structural changes separate from behavior changes where practical.
  • I added or updated tests for behavior changes.
  • I updated README / docs / website content when user-facing behavior changed.
  • I rebuilt generated bundles when bundled source changed.
  • I ran the relevant checks locally.

Notes for Reviewers

  • The key behavior is that session buffers stay worktree-local, while hook execution can fall back to the common git dir shim. That keeps parallel worktree sessions isolated without losing notes when hooks are shared.
  • Verification run locally: npx tsx src/commands/init.test.ts, npx tsx src/commands/deinit.test.ts, npm run build, npm run typecheck, npm run lint, npm test, and git diff --check.
  • docs/blog/ is unrelated existing untracked content and is not included.

🧑💬🤖 Agent Note

Total AI Ratio: ████████ 100%
Model: gpt-5.4

Commit AI Ratio Prompts Files
878c7dd fix(init): support git worktree hook shims █████ 100% 8 cli.js 👤, deinit.ts 🤖, init.ts 🤖, paths.ts 🤖
51c7fd0 test(init): cover git worktree layouts █████ 100% 11 deinit.test.ts 🤖, init.test.ts 🤖
f84e6b8 docs: document git worktree support █████ 100% 11 AGENTS.md 🤖, CLAUDE.md 🤖, architecture.md 🤖, investigations.md 🤖
39aac55 test(deinit): avoid shell-interpolated commands █████ 100% 2 AGENTS.md 🤖, CLAUDE.md 🤖, architecture.md 🤖, deinit.test.ts 🤖
83d0fbc test(init): avoid hardcoded worktree base branch █████ 100% 5 init.test.ts 🤖
12d1a97 docs: align hook directory guidance with git resolution █████ 100% 5 architecture.md 🤖
3af909d test(init): avoid shell interpolation in worktree helper █████ 100% 5 init.test.ts 🤖
💬 Prompts & Responses (40 shown / 47 total)

878c7dd fix(init): support git worktree hook shims

🧑 Prompt
Claude Agent View の機能について詳細調査してほしい。Agent Note のセッション判断処理に大きな問題がでないかどうか

🤖 Response
Claude Agent View は外部仕様の変化が絡むので、まず公式情報を確認しつつ、こちらの Claude adapter / session 判定 / hook config との接点を洗います。ローカル実装と照らして「壊れる可能性がある箇所」と「今すぐ対策すべきか」を分けて見ます。
公式 docs では Agent View は claude agents / claude --bg / /bg で background session を supervisor 管理にする機能でした。Agent Note 側で問題になりそうなのは「terminal attached でなくても session が走る」「global list が project 横断」「process が supervisor parent」「CLAUDE_CONFIG_DIR で別 instance」あたりです。次に Claude adapter と git hook の session 判定を照合します。
Claude Agent View は「通常の Claude Code セッションが …

🧑 Prompt
claude-code の github から実装も確認すること

🤖 Response
Claude Code 側の実装も確認します。もし本体が非公開で GitHub には docs / issue / SDK しかない場合は、その範囲で「実装確認できたこと」と「確認不能なこと」を分けて扱います。
GitHub 側は anthropics/claude-code が公開されていますが、README から見る限り本体 CLI の実装そのものは置かれておらず、plugins / scripts / examples 中心の可能性が高いです。ツリーを直接見て、Agent View や hook 実装が参照できるか確認します。
Agent View の一番大きい差分は「background session は edit 前に .claude/worktrees/ の git worktree へ移動する」点でした。これは単なる background 化より重要で、Agent Note の .git/agentnote 保存先や git hooks が worktree ごとにどう見えるかに影響します。ここを追加で確認しています。
調査結果としては、**Agent Vi…

🧑 Prompt
worktree 対応とは?

🤖 Response
worktree 対応は少しややこしいので、Git の保存場所と Agent Note の保存場所を分けて噛み砕きます。要点は「同じ repository でも worktree だと .git の実体が別の場所を指す」ことです。
git worktree は、同じ repository の別作業ディレクトリを作る Git 機能です。Claude Agent View は background agent ごとに .claude/worktrees/... のような作業場所を作って、そこで編集・commit する可能性があります。

問題は、通常 repo と worktree で Git の場所が違うことです。

通常の checkout
repo/.git/
  hooks/
  agentnote/
    bin/agent-note
    sessions/

worktree
repo/.claude/worktrees/xxx/
  .git  -> 実体は repo/.git/worktrees/xxx を指す

Git が見る場所
rep…

🧑 Prompt
そもそも Agent Note って git worktree に対応していなかった?

🤖 Response
まず現状のコード上の対応範囲を切り分けます。git worktree は「一部は自然に動くけど、CLI shim / hook 探索 / notes 共有で落とし穴がある」タイプなので、実際の挙動をローカルで小さく再現して確認します。
正確に言うと、部分対応はしているけど、完全対応とは言いにくいです。

今の Agent Note は git rev-parse --git-dir を使って .git 実体を解決しているので、worktree で .git が file になっている基本ケースには一応対応しています。つまり、worktree 内で agent-note init して、worktree 側の git dir に session data や shim が作られれば動く可能性はあります。

ただし、現在の実装だと落とし穴があります。

  • main checkout で agent-note init しただけでは、worktree 側の $GIT_DIR/agentnote/bin/agent-note は存在しません。
  • Git …

🧑 Prompt
ブランチきって、まずは worktree への完全対応を進めましょう。
これまでのログで worktree の対応ができてるかどうかも洗い出して。

🤖 Response
worktree は Agent View の本丸っぽいので、先に専用ブランチを切って、履歴・docs・実装の 3 面から「対応済みと言える範囲 / まだ穴がある範囲」を洗い出します。その上で hook の CLI 探索と session 保存先まわりを、実際の git worktree regression test で固定します。
履歴では 4c08e7f fix: support git worktree by using git rev-parse --git-dir があり、当時は「.git が file でも実 git dir を解決する」対応でした。ただし今回見えている穴は別で、main checkout に置いた local shim を worktree hook から見つけられない点と、hook install path が common hooks と噛み合うかです。ブランチを切ってそこを埋めます。

🧑 Prompt
entire の実装も参考にしつつ進めてほしい。(entireのバグがあればそれは解決すること)

🤖 Response
Entire の実装も見ます。ここでは「同じアイデアを真似る」より、worktree / git dir / hook / session storage の境界をどう扱っているかだけを抽出して、Agent Note 側の穴を潰す材料にします。
Entire 側は README に「Git Worktrees は session tracking が worktree ごとに独立」と明記されています。Agent Note も同じ方向に寄せるべきですが、Entire は checkpoint branch 戦略なので、そのまま移植ではなく「worktree ごとの session 保存」と「common hooks / shim 解決」を Agent Note 流に実装します。
実装方針は、session data は worktree ごとに分けたまま維持し、hook 実行時の CLI shim だけ common git dir も見に行く形にします。これは Entire の「worktree を分離境界にする」思想に近く、Agent Note の git notes 設計にも一番自…

🧑 Prompt
worktree より良い実装と完全性を目指して

🤖 Response
完全性を上げるなら「worktree で commit できる」だけでは不十分で、「main で init して worktree commit」「worktree で init して main/worktree commit」の両方を落とさない必要があります。なので shim は worktree 固有だけでなく common git dir 側にも置く設計に寄せます。
実装を入れました。今の test は「main で init → Claude Agent View 的な .claude/worktrees/... で hook event と plain commit → git note が作られる」を実際に走らせる形にしています。次は build と該当 test でまず破綻を見ます。
新規 worktree test は通りましたが、既存の「shell 特殊文字パスで chained hook が走る」test が落ちました。resolveHookDir() の変更が hook path の解決に副作用を出している可能性があるので、そこを先に直します。
落ちた理由…

🧑 Prompt
バグがないか入念にチェック

🤖 Response
ここは少し怖い変更なので、バグ探しモードで見ます。特に「test が通る」だけでは見落としやすい、worktree ごとの session 分離、common shim fallback、custom hooksPath、bare repo、deinit cleanup、既存 hook chaining の順に潰します。
一次レビューでは大きな動作バグは見えていませんが、細かい危険信号を 2 つ見つけました。ひとつは重複 TSDoc、もうひとつは commonGitDir の相対 path 解決が将来の Git variant に対して少し弱い点です。ここは実害が出る前に固めます。
レビューで見つけた修正対象は 2 つです。1 つ目は startsWith("/") で absolute path 判定していて Windows / Git for Windows に弱い点、2 つ目は resolveHookDir() の重複 TSDoc です。worktree 本体のロジックは概ね正しいですが、ここは今直す価値があります。
absolute path 判定を `isAbso…

51c7fd0 test(init): cover git worktree layouts

🧑 Prompt
Claude Agent View の機能について詳細調査してほしい。Agent Note のセッション判断処理に大きな問題がでないかどうか

🤖 Response
Claude Agent View は外部仕様の変化が絡むので、まず公式情報を確認しつつ、こちらの Claude adapter / session 判定 / hook config との接点を洗います。ローカル実装と照らして「壊れる可能性がある箇所」と「今すぐ対策すべきか」を分けて見ます。
公式 docs では Agent View は claude agents / claude --bg / /bg で background session を supervisor 管理にする機能でした。Agent Note 側で問題になりそうなのは「terminal attached でなくても session が走る」「global list が project 横断」「process が supervisor parent」「CLAUDE_CONFIG_DIR で別 instance」あたりです。次に Claude adapter と git hook の session 判定を照合します。
Claude Agent View は「通常の Claude Code セッションが …

🧑 Prompt
claude-code の github から実装も確認すること

🤖 Response
Claude Code 側の実装も確認します。もし本体が非公開で GitHub には docs / issue / SDK しかない場合は、その範囲で「実装確認できたこと」と「確認不能なこと」を分けて扱います。
GitHub 側は anthropics/claude-code が公開されていますが、README から見る限り本体 CLI の実装そのものは置かれておらず、plugins / scripts / examples 中心の可能性が高いです。ツリーを直接見て、Agent View や hook 実装が参照できるか確認します。
Agent View の一番大きい差分は「background session は edit 前に .claude/worktrees/ の git worktree へ移動する」点でした。これは単なる background 化より重要で、Agent Note の .git/agentnote 保存先や git hooks が worktree ごとにどう見えるかに影響します。ここを追加で確認しています。
調査結果としては、**Agent Vi…

🧑 Prompt
worktree 対応とは?

🤖 Response
worktree 対応は少しややこしいので、Git の保存場所と Agent Note の保存場所を分けて噛み砕きます。要点は「同じ repository でも worktree だと .git の実体が別の場所を指す」ことです。
git worktree は、同じ repository の別作業ディレクトリを作る Git 機能です。Claude Agent View は background agent ごとに .claude/worktrees/... のような作業場所を作って、そこで編集・commit する可能性があります。

問題は、通常 repo と worktree で Git の場所が違うことです。

通常の checkout
repo/.git/
  hooks/
  agentnote/
    bin/agent-note
    sessions/

worktree
repo/.claude/worktrees/xxx/
  .git  -> 実体は repo/.git/worktrees/xxx を指す

Git が見る場所
rep…

🧑 Prompt
そもそも Agent Note って git worktree に対応していなかった?

🤖 Response
まず現状のコード上の対応範囲を切り分けます。git worktree は「一部は自然に動くけど、CLI shim / hook 探索 / notes 共有で落とし穴がある」タイプなので、実際の挙動をローカルで小さく再現して確認します。
正確に言うと、部分対応はしているけど、完全対応とは言いにくいです。

今の Agent Note は git rev-parse --git-dir を使って .git 実体を解決しているので、worktree で .git が file になっている基本ケースには一応対応しています。つまり、worktree 内で agent-note init して、worktree 側の git dir に session data や shim が作られれば動く可能性はあります。

ただし、現在の実装だと落とし穴があります。

  • main checkout で agent-note init しただけでは、worktree 側の $GIT_DIR/agentnote/bin/agent-note は存在しません。
  • Git …

🧑 Prompt
ブランチきって、まずは worktree への完全対応を進めましょう。
これまでのログで worktree の対応ができてるかどうかも洗い出して。

🤖 Response
worktree は Agent View の本丸っぽいので、先に専用ブランチを切って、履歴・docs・実装の 3 面から「対応済みと言える範囲 / まだ穴がある範囲」を洗い出します。その上で hook の CLI 探索と session 保存先まわりを、実際の git worktree regression test で固定します。
履歴では 4c08e7f fix: support git worktree by using git rev-parse --git-dir があり、当時は「.git が file でも実 git dir を解決する」対応でした。ただし今回見えている穴は別で、main checkout に置いた local shim を worktree hook から見つけられない点と、hook install path が common hooks と噛み合うかです。ブランチを切ってそこを埋めます。

🧑 Prompt
entire の実装も参考にしつつ進めてほしい。(entireのバグがあればそれは解決すること)

🤖 Response
Entire の実装も見ます。ここでは「同じアイデアを真似る」より、worktree / git dir / hook / session storage の境界をどう扱っているかだけを抽出して、Agent Note 側の穴を潰す材料にします。
Entire 側は README に「Git Worktrees は session tracking が worktree ごとに独立」と明記されています。Agent Note も同じ方向に寄せるべきですが、Entire は checkpoint branch 戦略なので、そのまま移植ではなく「worktree ごとの session 保存」と「common hooks / shim 解決」を Agent Note 流に実装します。
実装方針は、session data は worktree ごとに分けたまま維持し、hook 実行時の CLI shim だけ common git dir も見に行く形にします。これは Entire の「worktree を分離境界にする」思想に近く、Agent Note の git notes 設計にも一番自…

🧑 Prompt
worktree より良い実装と完全性を目指して

🤖 Response
完全性を上げるなら「worktree で commit できる」だけでは不十分で、「main で init して worktree commit」「worktree で init して main/worktree commit」の両方を落とさない必要があります。なので shim は worktree 固有だけでなく common git dir 側にも置く設計に寄せます。
実装を入れました。今の test は「main で init → Claude Agent View 的な .claude/worktrees/... で hook event と plain commit → git note が作られる」を実際に走らせる形にしています。次は build と該当 test でまず破綻を見ます。
新規 worktree test は通りましたが、既存の「shell 特殊文字パスで chained hook が走る」test が落ちました。resolveHookDir() の変更が hook path の解決に副作用を出している可能性があるので、そこを先に直します。
落ちた理由…

🧑 Prompt
どういうテストをした?

🤖 Response
今回追加・実行した主なテストはこの 2 本です。

  1. main checkout で init → worktree で commit
    agent-note init --agent claude --no-action を main checkout で実行したあと、.claude/worktrees/agent-viewgit worktree を作成。worktree 側で Claude hook event を擬似的に流して changes.jsonl / pre_blobs.jsonl を作り、plain git commit を実行。最後に git notes --ref=agentnote show HEAD で note が作られ、prompt / files_touched / by_ai が正しいことを確認しました。これが Claude Agent View 想定の本命 regression です。

  2. worktree 内で init
    main ではなく worktree 側で `agent-note in…

🧑 Prompt
例えば /Users/a12622/git/jump-app.bare は git worktree 使ってるので、この構成でも問題なさそう?

🤖 Response
実在の jump-app.bare 構成で確認します。まず読み取りだけで git worktree list、各 worktree の --git-dir / --git-common-dir / hooks path / agentnote shim の見え方を確認して、今回の修正がその形に刺さるか見ます。
jump-app.bare はかなり典型的な bare + worktree 構成です。各 branch worktree の $GIT_DIRjump-app.bare/worktrees/<name>、common は jump-app.bare、hooks は jump-app.bare/hooks でした。つまり今回の common shim fallback がまさに必要になる形です。もう少し hook 設定と現在の Agent Note 状態も読み取りで確認します。
/Users/a12622/git/jump-app.bare の構成でも、今回の修正はかなり効きます。

確認した構成はこうです。

bar…

🧑 Prompt
git worktree は自分でディレクトリルール決めれるし、bare and non-bare もあるので、それらのテストを網羅してほしい

🤖 Response
その通りです。今の test は Agent View っぽい nested worktree と bare ではない通常 repo が中心なので、完全性を狙うなら「bare / non-bare」「worktree directory が repo 内 / repo 外 / sibling」「既存 hook chain あり」の matrix にします。重複を増やすだけではなく、Git の構成差分が出る軸だけを押さえます。
worktree は「ディレクトリ名に意味がない」「bare/non-bare で common git dir が変わる」が本質なので、ここを test matrix に足します。既存の nested Agent View 風だけだと、たしかに本番の /Users/.../*.bare 構成までは保証できません。
既に入っている matrix を一度読んだところ、bare/non-bare の軸は押さえ始めています。ここからは「任意ディレクトリ名」をより明確にするため、space を含む worktree path と .bare/branch/...

🧑 Prompt
git worktree の詳細仕様を確認してほしい。
worktree でできることを全て網羅できるようにテストを行ってほしい。

🤖 Response
Git worktree は思ったより仕様の枝が多いので、まず公式 docs とローカル Git の挙動を照合します。そのうえで「全部を薄くなぞる」ではなく、Agent Note が壊れうる境界、つまり git dir/common dir/hooks/session/notes/cleanup が変わる軸を test matrix に落とします。
公式 docs では、linked worktree は $GIT_DIR が各 worktree 専用、$GIT_COMMON_DIR が共有、path 解決は git rev-parse --git-path を使うべき、とされています。ここから Agent Note 的に危険な軸は、--detach / --orphan / move / worktreeConfig / relativeWorktrees / duplicate basename です。全部を Git 本体の再実装テストにはせず、Agent Note の hook/shim/note が壊れるところに絞って足します。
追加テストは「G…

f84e6b8 docs: document git worktree support

🧑 Prompt
Claude Agent View の機能について詳細調査してほしい。Agent Note のセッション判断処理に大きな問題がでないかどうか

🤖 Response
Claude Agent View は外部仕様の変化が絡むので、まず公式情報を確認しつつ、こちらの Claude adapter / session 判定 / hook config との接点を洗います。ローカル実装と照らして「壊れる可能性がある箇所」と「今すぐ対策すべきか」を分けて見ます。
公式 docs では Agent View は claude agents / claude --bg / /bg で background session を supervisor 管理にする機能でした。Agent Note 側で問題になりそうなのは「terminal attached でなくても session が走る」「global list が project 横断」「process が supervisor parent」「CLAUDE_CONFIG_DIR で別 instance」あたりです。次に Claude adapter と git hook の session 判定を照合します。
Claude Agent View は「通常の Claude Code セッションが …

🧑 Prompt
claude-code の github から実装も確認すること

🤖 Response
Claude Code 側の実装も確認します。もし本体が非公開で GitHub には docs / issue / SDK しかない場合は、その範囲で「実装確認できたこと」と「確認不能なこと」を分けて扱います。
GitHub 側は anthropics/claude-code が公開されていますが、README から見る限り本体 CLI の実装そのものは置かれておらず、plugins / scripts / examples 中心の可能性が高いです。ツリーを直接見て、Agent View や hook 実装が参照できるか確認します。
Agent View の一番大きい差分は「background session は edit 前に .claude/worktrees/ の git worktree へ移動する」点でした。これは単なる background 化より重要で、Agent Note の .git/agentnote 保存先や git hooks が worktree ごとにどう見えるかに影響します。ここを追加で確認しています。
調査結果としては、**Agent Vi…

🧑 Prompt
worktree 対応とは?

🤖 Response
worktree 対応は少しややこしいので、Git の保存場所と Agent Note の保存場所を分けて噛み砕きます。要点は「同じ repository でも worktree だと .git の実体が別の場所を指す」ことです。
git worktree は、同じ repository の別作業ディレクトリを作る Git 機能です。Claude Agent View は background agent ごとに .claude/worktrees/... のような作業場所を作って、そこで編集・commit する可能性があります。

問題は、通常 repo と worktree で Git の場所が違うことです。

通常の checkout
repo/.git/
  hooks/
  agentnote/
    bin/agent-note
    sessions/

worktree
repo/.claude/worktrees/xxx/
  .git  -> 実体は repo/.git/worktrees/xxx を指す

Git が見る場所
rep…

🧑 Prompt
そもそも Agent Note って git worktree に対応していなかった?

🤖 Response
まず現状のコード上の対応範囲を切り分けます。git worktree は「一部は自然に動くけど、CLI shim / hook 探索 / notes 共有で落とし穴がある」タイプなので、実際の挙動をローカルで小さく再現して確認します。
正確に言うと、部分対応はしているけど、完全対応とは言いにくいです。

今の Agent Note は git rev-parse --git-dir を使って .git 実体を解決しているので、worktree で .git が file になっている基本ケースには一応対応しています。つまり、worktree 内で agent-note init して、worktree 側の git dir に session data や shim が作られれば動く可能性はあります。

ただし、現在の実装だと落とし穴があります。

  • main checkout で agent-note init しただけでは、worktree 側の $GIT_DIR/agentnote/bin/agent-note は存在しません。
  • Git …

🧑 Prompt
ブランチきって、まずは worktree への完全対応を進めましょう。
これまでのログで worktree の対応ができてるかどうかも洗い出して。

🤖 Response
worktree は Agent View の本丸っぽいので、先に専用ブランチを切って、履歴・docs・実装の 3 面から「対応済みと言える範囲 / まだ穴がある範囲」を洗い出します。その上で hook の CLI 探索と session 保存先まわりを、実際の git worktree regression test で固定します。
履歴では 4c08e7f fix: support git worktree by using git rev-parse --git-dir があり、当時は「.git が file でも実 git dir を解決する」対応でした。ただし今回見えている穴は別で、main checkout に置いた local shim を worktree hook から見つけられない点と、hook install path が common hooks と噛み合うかです。ブランチを切ってそこを埋めます。

🧑 Prompt
entire の実装も参考にしつつ進めてほしい。(entireのバグがあればそれは解決すること)

🤖 Response
Entire の実装も見ます。ここでは「同じアイデアを真似る」より、worktree / git dir / hook / session storage の境界をどう扱っているかだけを抽出して、Agent Note 側の穴を潰す材料にします。
Entire 側は README に「Git Worktrees は session tracking が worktree ごとに独立」と明記されています。Agent Note も同じ方向に寄せるべきですが、Entire は checkpoint branch 戦略なので、そのまま移植ではなく「worktree ごとの session 保存」と「common hooks / shim 解決」を Agent Note 流に実装します。
実装方針は、session data は worktree ごとに分けたまま維持し、hook 実行時の CLI shim だけ common git dir も見に行く形にします。これは Entire の「worktree を分離境界にする」思想に近く、Agent Note の git notes 設計にも一番自…

🧑 Prompt
worktree より良い実装と完全性を目指して

🤖 Response
完全性を上げるなら「worktree で commit できる」だけでは不十分で、「main で init して worktree commit」「worktree で init して main/worktree commit」の両方を落とさない必要があります。なので shim は worktree 固有だけでなく common git dir 側にも置く設計に寄せます。
実装を入れました。今の test は「main で init → Claude Agent View 的な .claude/worktrees/... で hook event と plain commit → git note が作られる」を実際に走らせる形にしています。次は build と該当 test でまず破綻を見ます。
新規 worktree test は通りましたが、既存の「shell 特殊文字パスで chained hook が走る」test が落ちました。resolveHookDir() の変更が hook path の解決に副作用を出している可能性があるので、そこを先に直します。
落ちた理由…

🧑 Prompt
どういうテストをした?

🤖 Response
今回追加・実行した主なテストはこの 2 本です。

  1. main checkout で init → worktree で commit
    agent-note init --agent claude --no-action を main checkout で実行したあと、.claude/worktrees/agent-viewgit worktree を作成。worktree 側で Claude hook event を擬似的に流して changes.jsonl / pre_blobs.jsonl を作り、plain git commit を実行。最後に git notes --ref=agentnote show HEAD で note が作られ、prompt / files_touched / by_ai が正しいことを確認しました。これが Claude Agent View 想定の本命 regression です。

  2. worktree 内で init
    main ではなく worktree 側で `agent-note in…

🧑 Prompt
例えば /Users/a12622/git/jump-app.bare は git worktree 使ってるので、この構成でも問題なさそう?

🤖 Response
実在の jump-app.bare 構成で確認します。まず読み取りだけで git worktree list、各 worktree の --git-dir / --git-common-dir / hooks path / agentnote shim の見え方を確認して、今回の修正がその形に刺さるか見ます。
jump-app.bare はかなり典型的な bare + worktree 構成です。各 branch worktree の $GIT_DIRjump-app.bare/worktrees/<name>、common は jump-app.bare、hooks は jump-app.bare/hooks でした。つまり今回の common shim fallback がまさに必要になる形です。もう少し hook 設定と現在の Agent Note 状態も読み取りで確認します。
/Users/a12622/git/jump-app.bare の構成でも、今回の修正はかなり効きます。

確認した構成はこうです。

bar…

🧑 Prompt
git worktree は自分でディレクトリルール決めれるし、bare and non-bare もあるので、それらのテストを網羅してほしい

🤖 Response
その通りです。今の test は Agent View っぽい nested worktree と bare ではない通常 repo が中心なので、完全性を狙うなら「bare / non-bare」「worktree directory が repo 内 / repo 外 / sibling」「既存 hook chain あり」の matrix にします。重複を増やすだけではなく、Git の構成差分が出る軸だけを押さえます。
worktree は「ディレクトリ名に意味がない」「bare/non-bare で common git dir が変わる」が本質なので、ここを test matrix に足します。既存の nested Agent View 風だけだと、たしかに本番の /Users/.../*.bare 構成までは保証できません。
既に入っている matrix を一度読んだところ、bare/non-bare の軸は押さえ始めています。ここからは「任意ディレクトリ名」をより明確にするため、space を含む worktree path と .bare/branch/...

🧑 Prompt
git worktree の詳細仕様を確認してほしい。
worktree でできることを全て網羅できるようにテストを行ってほしい。

🤖 Response
Git worktree は思ったより仕様の枝が多いので、まず公式 docs とローカル Git の挙動を照合します。そのうえで「全部を薄くなぞる」ではなく、Agent Note が壊れうる境界、つまり git dir/common dir/hooks/session/notes/cleanup が変わる軸を test matrix に落とします。
公式 docs では、linked worktree は $GIT_DIR が各 worktree 専用、$GIT_COMMON_DIR が共有、path 解決は git rev-parse --git-path を使うべき、とされています。ここから Agent Note 的に危険な軸は、--detach / --orphan / move / worktreeConfig / relativeWorktrees / duplicate basename です。全部を Git 本体の再実装テストにはせず、Agent Note の hook/shim/note が壊れるところに絞って足します。
追加テストは「G…

39aac55 test(deinit): avoid shell-interpolated commands

🧑 Prompt
$coderabbit-review

coderabbit-review /Users/a12622/git/context-history/.codex/skills/coderabbit-review/SKILL.md --- name: coderabbit-review description: Fetch CodeRabbit review feedback for the current PR, classify actionable items, implement fixes, verify them, and resolve only addressed review threads. ---

CodeRabbit Review Workflow

Use this skill when the task asks to address CodeRabbit comments, review CodeRabbit feedback, or resolve CodeRabbit threads.…

🤖 Response
coderabbit-review skill を使います。まず PR #77 の unresolved CodeRabbit thread と summary を取得して、実装対応が必要か false positive かを分けます。
CodeRabbit の unresolved thread と PR 状態を確認して、実修正すべきものだけ拾います。作業済みの thread は resolve、見送るものは英語で理由を残す流れで進めます。
CodeRabbit の実指摘は 4 件でした。3 件は docs の hyphenation、1 件は deinit.test.ts の shell interpolation なので、どれも直してよい小粒な修正です。
deinit.test.ts は実際に shellSingleQuote が 1 箇所だけで、node ${cliPath} 形式も複数残っていました。ここは小手先ではなく、このファイル内の可変引数付き呼び出しを execFileSync に寄せて安全にします。
修正内容は確認済みです。`execFileSy…

83d0fbc test(init): avoid hardcoded worktree base branch

🧑 Prompt
以下レビュー結果

⏺ 検証完了。レビューをまとめます。


git worktree / Claude Agents 対応レビュー

Branch: fix/worktree-agentnote-hooks
Verification: ✅ typecheck pass / lint pass / 465 tests pass (新規 worktree test 6 件含む)


変更の全体像

ファイル: core/paths.ts
変更内容: commonGitDir() / commonAgentnoteDir() 追加、isAbsolute() で path 判定統一
────────────────────────────────────────
ファイル: commands/init.ts
変更内容: shim を worktree-local + common 両方に install、resolveHookDir を --git-path hooks ベースに、shell script に
COMMON_G…

🤖 Response
レビュー内容は妥当です。こちらでも同じ観点で確認していて、追加で直すべき実装バグは見つかっていません。

特に重要なのは、今回の対応が Claude Agent View 専用の path 決め打ちではなく、git rev-parse --git-dir / --git-common-dir / --git-path hooks に寄せている点です。なので .claude/worktrees/... 以外の arbitrary worktree layout、bare repo、space あり path、moved worktree でも壊れにくい設計になっています。

一点だけ補足すると、「Claude 側のディレクトリ仕様が変わっても regression test で気付ける」というより、「Claude 側の directory layout が変わっても Agent Note は Git の worktree 仕様ベースなので基本的に影響を受けない」がより正確です。.claude/worktrees/... test は代表例として残しつつ、custom …

🧑 Prompt
$common:commit PRまで作成して

common:commit /Users/a12622/.codex/plugins/cache/applibot-codex-plugins/common/1.1.0/skills/commit/SKILL.md --- name: "commit" description: "大きな変更を意味のある最小単位に分割して順次コミットします。" ---

この skill は upstream の command 定義から自動生成されています。 Codex では skill として扱います。

変更を意味単位に分割してセマンティックコミット

大きな変更を意味のある最小単位に分割して順次コミットします。

使い方

`commit` [オプション]

オプション

  • --dry-run : 実際のコミットは行わず、提案されるコミット分割のみを表示
  • --lang <言語> : コミットメッセージの言語を強制指定 (e…

🤖 Response
common:commit を使います。変更は「実装」「test」「docs」の 3 つに分けるのが一番きれいです。docs/blog/ は今回の作業外の untracked なので staging しません。
現在の branch は fix/worktree-agentnote-hooks です。docs/blog/ 以外の変更を 3 commit に分けます: 実装、test、docs。まず implementation + dist を commit します。
dist/cli.js は ignore 対象ですが tracked artifact として必要なので、そこだけ git add -f します。
実装 commit が入りました。次に regression test 群を別 commit にします。
test commit も入りました。最後に maintainer docs を commit します。
3 commit に分割できました。作業外の docs/blog/ だけ残っているか確認してから push / PR 作成に進みます。
pus…

🧑 Prompt
$coderabbit-review

coderabbit-review /Users/a12622/git/context-history/.codex/skills/coderabbit-review/SKILL.md --- name: coderabbit-review description: Fetch CodeRabbit review feedback for the current PR, classify actionable items, implement fixes, verify them, and resolve only addressed review threads. ---

CodeRabbit Review Workflow

Use this skill when the task asks to address CodeRabbit comments, review CodeRabbit feedback, or resolve CodeRabbit threads.…

🤖 Response
coderabbit-review skill を使います。まず PR #77 の unresolved CodeRabbit thread と summary を取得して、実装対応が必要か false positive かを分けます。
CodeRabbit の unresolved thread と PR 状態を確認して、実修正すべきものだけ拾います。作業済みの thread は resolve、見送るものは英語で理由を残す流れで進めます。
CodeRabbit の実指摘は 4 件でした。3 件は docs の hyphenation、1 件は deinit.test.ts の shell interpolation なので、どれも直してよい小粒な修正です。
deinit.test.ts は実際に shellSingleQuote が 1 箇所だけで、node ${cliPath} 形式も複数残っていました。ここは小手先ではなく、このファイル内の可変引数付き呼び出しを execFileSync に寄せて安全にします。
修正内容は確認済みです。`execFileSy…

12d1a97 docs: align hook directory guidance with git resolution

🧑 Prompt
以下レビュー結果

⏺ 検証完了。レビューをまとめます。


git worktree / Claude Agents 対応レビュー

Branch: fix/worktree-agentnote-hooks
Verification: ✅ typecheck pass / lint pass / 465 tests pass (新規 worktree test 6 件含む)


変更の全体像

ファイル: core/paths.ts
変更内容: commonGitDir() / commonAgentnoteDir() 追加、isAbsolute() で path 判定統一
────────────────────────────────────────
ファイル: commands/init.ts
変更内容: shim を worktree-local + common 両方に install、resolveHookDir を --git-path hooks ベースに、shell script に
COMMON_G…

🤖 Response
レビュー内容は妥当です。こちらでも同じ観点で確認していて、追加で直すべき実装バグは見つかっていません。

特に重要なのは、今回の対応が Claude Agent View 専用の path 決め打ちではなく、git rev-parse --git-dir / --git-common-dir / --git-path hooks に寄せている点です。なので .claude/worktrees/... 以外の arbitrary worktree layout、bare repo、space あり path、moved worktree でも壊れにくい設計になっています。

一点だけ補足すると、「Claude 側のディレクトリ仕様が変わっても regression test で気付ける」というより、「Claude 側の directory layout が変わっても Agent Note は Git の worktree 仕様ベースなので基本的に影響を受けない」がより正確です。.claude/worktrees/... test は代表例として残しつつ、custom …

🧑 Prompt
$common:commit PRまで作成して

common:commit /Users/a12622/.codex/plugins/cache/applibot-codex-plugins/common/1.1.0/skills/commit/SKILL.md --- name: "commit" description: "大きな変更を意味のある最小単位に分割して順次コミットします。" ---

この skill は upstream の command 定義から自動生成されています。 Codex では skill として扱います。

変更を意味単位に分割してセマンティックコミット

大きな変更を意味のある最小単位に分割して順次コミットします。

使い方

`commit` [オプション]

オプション

  • --dry-run : 実際のコミットは行わず、提案されるコミット分割のみを表示
  • --lang <言語> : コミットメッセージの言語を強制指定 (e…

🤖 Response
common:commit を使います。変更は「実装」「test」「docs」の 3 つに分けるのが一番きれいです。docs/blog/ は今回の作業外の untracked なので staging しません。
現在の branch は fix/worktree-agentnote-hooks です。docs/blog/ 以外の変更を 3 commit に分けます: 実装、test、docs。まず implementation + dist を commit します。
dist/cli.js は ignore 対象ですが tracked artifact として必要なので、そこだけ git add -f します。
実装 commit が入りました。次に regression test 群を別 commit にします。
test commit も入りました。最後に maintainer docs を commit します。
3 commit に分割できました。作業外の docs/blog/ だけ残っているか確認してから push / PR 作成に進みます。
pus…

🧑 Prompt
$coderabbit-review

coderabbit-review /Users/a12622/git/context-history/.codex/skills/coderabbit-review/SKILL.md --- name: coderabbit-review description: Fetch CodeRabbit review feedback for the current PR, classify actionable items, implement fixes, verify them, and resolve only addressed review threads. ---

CodeRabbit Review Workflow

Use this skill when the task asks to address CodeRabbit comments, review CodeRabbit feedback, or resolve CodeRabbit threads.…

🤖 Response
coderabbit-review skill を使います。まず PR #77 の unresolved CodeRabbit thread と summary を取得して、実装対応が必要か false positive かを分けます。
CodeRabbit の unresolved thread と PR 状態を確認して、実修正すべきものだけ拾います。作業済みの thread は resolve、見送るものは英語で理由を残す流れで進めます。
CodeRabbit の実指摘は 4 件でした。3 件は docs の hyphenation、1 件は deinit.test.ts の shell interpolation なので、どれも直してよい小粒な修正です。
deinit.test.ts は実際に shellSingleQuote が 1 箇所だけで、node ${cliPath} 形式も複数残っていました。ここは小手先ではなく、このファイル内の可変引数付き呼び出しを execFileSync に寄せて安全にします。
修正内容は確認済みです。`execFileSy…

3af909d test(init): avoid shell interpolation in worktree helper

🧑 Prompt
以下レビュー結果

⏺ 検証完了。レビューをまとめます。


git worktree / Claude Agents 対応レビュー

Branch: fix/worktree-agentnote-hooks
Verification: ✅ typecheck pass / lint pass / 465 tests pass (新規 worktree test 6 件含む)


変更の全体像

ファイル: core/paths.ts
変更内容: commonGitDir() / commonAgentnoteDir() 追加、isAbsolute() で path 判定統一
────────────────────────────────────────
ファイル: commands/init.ts
変更内容: shim を worktree-local + common 両方に install、resolveHookDir を --git-path hooks ベースに、shell script に
COMMON_G…

🤖 Response
レビュー内容は妥当です。こちらでも同じ観点で確認していて、追加で直すべき実装バグは見つかっていません。

特に重要なのは、今回の対応が Claude Agent View 専用の path 決め打ちではなく、git rev-parse --git-dir / --git-common-dir / --git-path hooks に寄せている点です。なので .claude/worktrees/... 以外の arbitrary worktree layout、bare repo、space あり path、moved worktree でも壊れにくい設計になっています。

一点だけ補足すると、「Claude 側のディレクトリ仕様が変わっても regression test で気付ける」というより、「Claude 側の directory layout が変わっても Agent Note は Git の worktree 仕様ベースなので基本的に影響を受けない」がより正確です。.claude/worktrees/... test は代表例として残しつつ、custom …

🧑 Prompt
$common:commit PRまで作成して

common:commit /Users/a12622/.codex/plugins/cache/applibot-codex-plugins/common/1.1.0/skills/commit/SKILL.md --- name: "commit" description: "大きな変更を意味のある最小単位に分割して順次コミットします。" ---

この skill は upstream の command 定義から自動生成されています。 Codex では skill として扱います。

変更を意味単位に分割してセマンティックコミット

大きな変更を意味のある最小単位に分割して順次コミットします。

使い方

`commit` [オプション]

オプション

  • --dry-run : 実際のコミットは行わず、提案されるコミット分割のみを表示
  • --lang <言語> : コミットメッセージの言語を強制指定 (e…

🤖 Response
common:commit を使います。変更は「実装」「test」「docs」の 3 つに分けるのが一番きれいです。docs/blog/ は今回の作業外の untracked なので staging しません。
現在の branch は fix/worktree-agentnote-hooks です。docs/blog/ 以外の変更を 3 commit に分けます: 実装、test、docs。まず implementation + dist を commit します。
dist/cli.js は ignore 対象ですが tracked artifact として必要なので、そこだけ git add -f します。
実装 commit が入りました。次に regression test 群を別 commit にします。
test commit も入りました。最後に maintainer docs を commit します。
3 commit に分割できました。作業外の docs/blog/ だけ残っているか確認してから push / PR 作成に進みます。
pus…

🧑 Prompt
$coderabbit-review

coderabbit-review /Users/a12622/git/context-history/.codex/skills/coderabbit-review/SKILL.md --- name: coderabbit-review description: Fetch CodeRabbit review feedback for the current PR, classify actionable items, implement fixes, verify them, and resolve only addressed review threads. ---

CodeRabbit Review Workflow

Use this skill when the task asks to address CodeRabbit comments, review CodeRabbit feedback, or resolve CodeRabbit threads.…

🤖 Response
coderabbit-review skill を使います。まず PR #77 の unresolved CodeRabbit thread と summary を取得して、実装対応が必要か false positive かを分けます。
CodeRabbit の unresolved thread と PR 状態を確認して、実修正すべきものだけ拾います。作業済みの thread は resolve、見送るものは英語で理由を残す流れで進めます。
CodeRabbit の実指摘は 4 件でした。3 件は docs の hyphenation、1 件は deinit.test.ts の shell interpolation なので、どれも直してよい小粒な修正です。
deinit.test.ts は実際に shellSingleQuote が 1 箇所だけで、node ${cliPath} 形式も複数残っていました。ここは小手先ではなく、このファイル内の可変引数付き呼び出しを execFileSync に寄せて安全にします。
修正内容は確認済みです。`execFileSy…

Summary by CodeRabbit

  • New Features

    • Full Git worktree support: per-worktree session isolation with shared repo-level shims and robust hook fallback across bare/non‑bare/custom layouts.
  • Documentation

    • Clarified architecture and guidelines for worktree note storage, hook resolution, shim placement, and compatibility/migration notes.
  • Tests

    • Expanded integration tests covering init/deinit, worktree commit recording, shim fallback, hook-path variations, and multiple worktree modes.
  • Bug Fixes

    • Deinit reliably removes both worktree-local and common shims; hooks use Git-reported hook paths and fall back to common shims.

Review Change Stack

wasabeef added 3 commits May 13, 2026 17:29
Why
Git worktrees can run shared hooks with a worktree-specific git dir, so hooks that only looked for a local shim could miss the CLI after init from another checkout.

User impact
Commits made from bare or non-bare worktrees, including Agent View style directories, can now write Agent Note data through the common git dir shim while keeping session buffers isolated per worktree.

Verification
npm run build
npm run typecheck
npm run lint
npm test

Release note: Support Agent Note recording from git worktrees by sharing the hook shim through the common git directory.
Why
Worktree behavior depends on Git's private git dir, common git dir, hook path, and user-chosen worktree directory layout.

User impact
The regression suite now covers bare and non-bare repositories, custom paths with spaces, detached and orphan worktrees, moved worktrees, duplicate basenames, and worktree-specific hooksPath.

Verification
npx tsx src/commands/init.test.ts
npx tsx src/commands/deinit.test.ts
npm test

Release note: skip
Why
The worktree implementation relies on Git's distinction between worktree-local and common git directories.

User impact
Maintainers can understand why session data remains per-worktree while hooks and shims are resolved through Git's shared paths.

Verification
npm run lint
npm test

Release note: skip
@coderabbitai
Copy link
Copy Markdown

coderabbitai Bot commented May 13, 2026

No actionable comments were generated in the recent review. 🎉

ℹ️ Recent review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 0bc99209-1cb7-4763-a6d7-875ef46d4831

📥 Commits

Reviewing files that changed from the base of the PR and between 12d1a97 and 3af909d.

📒 Files selected for processing (1)
  • packages/cli/src/commands/init.test.ts

📝 Walkthrough

Walkthrough

Adds worktree-aware path resolution and dual-shim hook installation with a common-dir fallback, updates deinit to clean both local and common shims, adds extensive worktree-focused integration tests, and updates architecture/docs and an investigation entry describing the prior note-loss scenario.

Changes

Worktree Support Implementation

Layer / File(s) Summary
Path Resolution for Worktree Common Directory
packages/cli/src/paths.ts
New module-level cache for common git directory, modified gitDir() to use absolute-path normalization, new commonGitDir() helper that resolves --git-common-dir with caching, and exported commonAgentnoteDir() that builds the shared agentnote directory path from the common git directory.
Hook Installation with Common Directory Fallback
packages/cli/src/commands/init.ts
Post-commit and pre-push hooks now compute COMMON_GIT_DIR, check for worktree-specific shims, and fall back to common shims; shims are installed into both worktree-local and common agentnote directories; resolveHookDir uses git-reported hooks path with functional replacement for shebang generation to avoid expansion issues.
Worktree Init Integration Tests
packages/cli/src/commands/init.test.ts
Comprehensive test suite with git config, hook execution, and commit recording helpers; verifies plain worktree commits use common shim, init inside worktree installs both shims, covers bare/non-bare/nested layouts with fallback validation, tests worktree modes/mutations, and core.hooksPath configuration scenarios.
Worktree-Aware Cleanup
packages/cli/src/commands/deinit.ts, packages/cli/src/commands/deinit.test.ts
Deinit removes agent-note shims from both worktree-local and common directories using set-based path checking; test verifies deinit inside a worktree removes both shims with helpers for shell quoting and Git path resolution.
Architecture and Investigation Documentation
AGENTS.md, CLAUDE.md, docs/architecture.md, docs/knowledge/investigations.md
User-facing worktree support statements; architecture docs clarify session buffer isolation per worktree, shared git notes, and hook directory resolution via git rev-parse --git-path hooks; resolved investigation documents the git worktree note-loss bug and regression test coverage.

🎯 3 (Moderate) | ⏱️ ~25 minutes

🚥 Pre-merge checks | ✅ 4 | ❌ 1

❌ Failed checks (1 warning)

Check name Status Explanation Resolution
Docstring Coverage ⚠️ Warning Docstring coverage is 52.63% which is insufficient. The required threshold is 80.00%. Write docstrings for the functions missing them to satisfy the coverage threshold.
✅ Passed checks (4 passed)
Check name Status Explanation
Description Check ✅ Passed Check skipped - CodeRabbit’s high-level summary is enabled.
Title check ✅ Passed The title 'fix(init): support git worktree hook shims' directly and clearly summarizes the main change: adding support for Git worktrees by implementing hook shims that work across worktree layouts.
Linked Issues check ✅ Passed Check skipped because no linked issues were found for this pull request.
Out of Scope Changes check ✅ Passed Check skipped because no linked issues were found for this pull request.

✏️ Tip: You can configure your own custom pre-merge checks in the settings.

✨ Finishing Touches
📝 Generate docstrings
  • Create stacked PR
  • Commit on current branch
🧪 Generate unit tests (beta)
  • Create PR with unit tests
  • Commit unit tests in branch fix/worktree-agentnote-hooks

Warning

Review ran into problems

🔥 Problems

Git: Failed to clone repository. Please run the @coderabbitai full review command to re-trigger a full review. If the issue persists, set path_filters to include or exclude specific files.


Comment @coderabbitai help to get the list of available commands and usage tips.

Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 4

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@AGENTS.md`:
- Line 101: Replace the compound phrase "Agent View style worktree commits" with
the hyphenated form "Agent View-style worktree commits" in the AGENTS.md
sentence that reads "Git worktrees are supported by keeping session buffers in
each worktree's own git dir while sharing the repo-local CLI shim from the
common git dir. This must work for bare and non-bare repositories, arbitrary
worktree directory layouts, and Agent View style worktree commits after init
from the main checkout." to apply the requested hyphenation.

In `@CLAUDE.md`:
- Line 101: Replace the unhyphenated compound adjective "Agent View style
worktree commits" with the hyphenated form "Agent View-style worktree commits"
wherever it appears (e.g., in the sentence that currently reads about worktrees
sharing the repo-local CLI shim), ensuring the capitalization remains unchanged.

In `@docs/architecture.md`:
- Line 408: Replace the phrase "Agent View style worktrees" with the hyphenated
compound modifier "Agent View-style worktrees" in the document (look for the
exact string "Agent View style worktrees" around the sentence containing
"commits made inside Claude Agent View style worktrees") to improve readability.

In `@packages/cli/src/commands/deinit.test.ts`:
- Around line 9-11: Remove the unused shellSingleQuote function and replace all
execSync calls that build shell-interpolated command strings (instances using
string interpolation and quoting) with child_process.execFileSync calls that
pass the executable and argument array instead; import/require execFileSync
alongside execSync (or replace execSync usages entirely), convert calls like
execSync(`${cmd} '${arg}'`, opts) into execFileSync(cmd, [arg], opts) preserving
the original options, and update the specific test invocations that used
shellSingleQuote to use argument arrays so shell quoting is no longer needed.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 478ddfa4-7471-4eb3-ba77-39f3586d4601

📥 Commits

Reviewing files that changed from the base of the PR and between 3fe356f and f84e6b8.

⛔ Files ignored due to path filters (1)
  • packages/cli/dist/cli.js is excluded by !**/dist/**, !**/dist/**
📒 Files selected for processing (9)
  • AGENTS.md
  • CLAUDE.md
  • docs/architecture.md
  • docs/knowledge/investigations.md
  • packages/cli/src/commands/deinit.test.ts
  • packages/cli/src/commands/deinit.ts
  • packages/cli/src/commands/init.test.ts
  • packages/cli/src/commands/init.ts
  • packages/cli/src/paths.ts

Comment thread AGENTS.md Outdated
Comment thread CLAUDE.md Outdated
Comment thread docs/architecture.md Outdated
Comment thread packages/cli/src/commands/deinit.test.ts Outdated
Use execFileSync argument arrays for deinit test invocations that pass dynamic paths. Also apply CodeRabbit's hyphenation feedback for Agent View-style worktree docs.

Verification: npm run typecheck; npm run lint; npx tsx src/commands/deinit.test.ts; npm test

Release note: skip
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@docs/architecture.md`:
- Around line 402-409: The hook-directory example still shows using the
`core.hooksPath` fallback, which contradicts the text that hook paths are
resolved by Git and may be worktree-specific; update the example to show
resolving the hook directory via Git (respecting worktree `$GIT_DIR`) instead of
relying on `core.hooksPath`, and adjust the `post-commit`/`pre-push` install
snippet to first check the worktree-local agent note shim (using the
Git-reported dir) then fall back to the common git-dir shim; replace references
to `core.hooksPath` in the snippet and surrounding explanation to reflect this
Git-based resolution.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 494cfcfc-bb65-4191-a259-b63f77d605d1

📥 Commits

Reviewing files that changed from the base of the PR and between f84e6b8 and 39aac55.

📒 Files selected for processing (4)
  • AGENTS.md
  • CLAUDE.md
  • docs/architecture.md
  • packages/cli/src/commands/deinit.test.ts

Comment thread docs/architecture.md
Use the current branch for non-bare worktree fixture setup so CI runners whose git default branch is master still cover the same worktree layouts.

Verification: npm run typecheck; npm run lint; mise x node@22.22.0 -- npx tsx src/commands/init.test.ts; mise x node@22.22.0 -- npm test

Release note: skip
Explain that Agent Note asks Git for the effective hook directory and uses worktree-local then common shims at runtime.

Verification: rg 'git config get core\.hooksPath|echo "\.git/hooks"' docs/architecture.md AGENTS.md CLAUDE.md docs

Release note: skip
Copy link
Copy Markdown

@coderabbitai coderabbitai Bot left a comment

Choose a reason for hiding this comment

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

Actionable comments posted: 1

🤖 Prompt for all review comments with AI agents
Verify each finding against current code. Fix only still-valid issues, skip the
rest with a brief reason, keep changes minimal, and validate.

Inline comments:
In `@packages/cli/src/commands/init.test.ts`:
- Around line 245-249: The test helper recordClaudeWorktreeCommit currently uses
execSync with shell-interpolated command strings (execSync(`git add
${shellSingleQuote(options.fileName)}`, { cwd }) and execSync(`git commit -m
${shellSingleQuote(options.commitMessage)}`, { cwd, env: withoutCodexThreadEnv()
})); replace these with execFileSync calls that pass argv arrays (e.g.,
execFileSync('git', ['add', options.fileName], { cwd }) and execFileSync('git',
['commit', '-m', options.commitMessage], { cwd, env: withoutCodexThreadEnv() }))
to avoid shell parsing issues, keeping use of shellSingleQuote unnecessary and
preserving cwd and env handling.
🪄 Autofix (Beta)

Fix all unresolved CodeRabbit comments on this PR:

  • Push a commit to this branch (recommended)
  • Create a new PR with the fixes

ℹ️ Review info
⚙️ Run configuration

Configuration used: Path: .coderabbit.yaml

Review profile: ASSERTIVE

Plan: Pro Plus

Run ID: 11d0e886-ed11-4d19-a88b-21870e489fd6

📥 Commits

Reviewing files that changed from the base of the PR and between 39aac55 and 12d1a97.

📒 Files selected for processing (2)
  • docs/architecture.md
  • packages/cli/src/commands/init.test.ts

Comment thread packages/cli/src/commands/init.test.ts Outdated
Use git argv calls inside the worktree commit helper so special paths and commit messages do not depend on shell parsing.

Verification: npm run lint; mise x node@22.22.0 -- npx tsx src/commands/init.test.ts

Release note: skip
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