Skip to content

Commit 2b9fc6a

Browse files
NagyViktNagyVikt
andauthored
Restore .agents hook path compatibility for Claude prompt hooks (#158)
Claude/Codex settings invoke hook scripts via .agents/hooks, but this repo only tracked hook files under .codex and .claude. Adding a repo-root compatibility symlink preserves existing hook settings while making the configured path resolvable again. Constraint: Existing hook settings already target .agents/hooks and should remain stable across clients Rejected: Repoint all hook commands to .codex/hooks | would require touching generated settings surfaces for both Claude and Codex Confidence: high Scope-risk: narrow Reversibility: clean Directive: Keep .agents path contract intact unless hook settings are migrated in one atomic change Tested: python3 .agents/hooks/skill_activation.py </dev/null; python3 .agents/hooks/skill_guard.py </dev/null; openspec validate agent-codex-restore-agents-hook-bridge-2026-04-20-08-45 --type change --strict; openspec validate --specs Not-tested: end-to-end interactive Claude hook execution in UI Co-authored-by: NagyVikt <nagy.viktordp@gmail.com>
1 parent 2b76911 commit 2b9fc6a

5 files changed

Lines changed: 54 additions & 0 deletions

File tree

.agents

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
.codex
Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
schema: spec-driven
2+
created: 2026-04-20
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
## Why
2+
3+
- Claude/Codex hooks are configured to execute under `.agents/hooks/*`.
4+
- This repository ships hook implementations under `.codex/hooks` and `.claude/hooks`, but `.agents/` can be missing.
5+
- When `.agents/` is absent, `UserPromptSubmit` fails with `[Errno 2] No such file or directory` and blocks Claude prompt submission.
6+
7+
## What Changes
8+
9+
- Add a repository-root compatibility alias `.agents -> .codex`.
10+
- Keep existing hook settings unchanged so both Claude and Codex continue to resolve the same path contract.
11+
- Verify `skill_activation.py` and `skill_guard.py` execute successfully via the `.agents/hooks` path.
12+
13+
## Impact
14+
15+
- Affected surface is limited to hook path resolution in local agent sessions.
16+
- No runtime package behavior changes, no dependency changes.
17+
- Low risk: symlink is reversible and only routes existing files.
Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,14 @@
1+
## ADDED Requirements
2+
3+
### Requirement: restore-agents-hook-bridge behavior
4+
The repository SHALL provide a valid `.agents/hooks/*` resolution path for local hook execution.
5+
6+
#### Scenario: Hook path compatibility is present
7+
- **WHEN** a local hook command invokes `python3 <repo>/.agents/hooks/skill_activation.py`
8+
- **THEN** the file path SHALL resolve without `ENOENT`
9+
- **AND** the hook process SHALL exit successfully for empty stdin.
10+
11+
#### Scenario: Existing guard hook remains callable through `.agents`
12+
- **WHEN** a local hook command invokes `python3 <repo>/.agents/hooks/skill_guard.py`
13+
- **THEN** the file path SHALL resolve without `ENOENT`
14+
- **AND** the hook process SHALL exit successfully for empty stdin.
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
## 1. Specification
2+
3+
- [x] 1.1 Finalize proposal scope and acceptance criteria for `agent-codex-restore-agents-hook-bridge-2026-04-20-08-45`.
4+
- [x] 1.2 Define normative requirements in `specs/restore-agents-hook-bridge/spec.md`.
5+
6+
## 2. Implementation
7+
8+
- [x] 2.1 Implement scoped behavior changes.
9+
- [x] 2.2 Add/update focused regression coverage.
10+
11+
## 3. Verification
12+
13+
- [x] 3.1 Run targeted project verification commands.
14+
- [x] 3.2 Run `openspec validate agent-codex-restore-agents-hook-bridge-2026-04-20-08-45 --type change --strict`.
15+
- [x] 3.3 Run `openspec validate --specs`.
16+
17+
## 4. Cleanup
18+
19+
- [x] 4.1 Confirm branch is ready for finish.
20+
- [ ] 4.2 After successful merge, run `bash scripts/agent-worktree-prune.sh --base <base> --delete-branches --delete-remote-branches` so merged agent branch/worktree sandboxes are removed from local and `origin`.

0 commit comments

Comments
 (0)