moai-adk 0.8.1__py3-none-any.whl → 0.8.3__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.

Potentially problematic release.


This version of moai-adk might be problematic. Click here for more details.

Files changed (87) hide show
  1. moai_adk/cli/commands/update.py +15 -4
  2. moai_adk/core/config/migration.py +1 -1
  3. moai_adk/core/issue_creator.py +7 -3
  4. moai_adk/core/tags/__init__.py +86 -0
  5. moai_adk/core/tags/ci_validator.py +433 -0
  6. moai_adk/core/tags/cli.py +283 -0
  7. moai_adk/core/tags/generator.py +109 -0
  8. moai_adk/core/tags/inserter.py +99 -0
  9. moai_adk/core/tags/mapper.py +126 -0
  10. moai_adk/core/tags/parser.py +76 -0
  11. moai_adk/core/tags/pre_commit_validator.py +355 -0
  12. moai_adk/core/tags/reporter.py +957 -0
  13. moai_adk/core/tags/tags.py +149 -0
  14. moai_adk/core/tags/validator.py +897 -0
  15. moai_adk/templates/.claude/agents/alfred/cc-manager.md +25 -2
  16. moai_adk/templates/.claude/agents/alfred/debug-helper.md +24 -12
  17. moai_adk/templates/.claude/agents/alfred/doc-syncer.md +19 -12
  18. moai_adk/templates/.claude/agents/alfred/git-manager.md +20 -12
  19. moai_adk/templates/.claude/agents/alfred/implementation-planner.md +19 -12
  20. moai_adk/templates/.claude/agents/alfred/project-manager.md +29 -2
  21. moai_adk/templates/.claude/agents/alfred/quality-gate.md +25 -2
  22. moai_adk/templates/.claude/agents/alfred/skill-factory.md +30 -2
  23. moai_adk/templates/.claude/agents/alfred/spec-builder.md +26 -11
  24. moai_adk/templates/.claude/agents/alfred/tag-agent.md +30 -8
  25. moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +27 -12
  26. moai_adk/templates/.claude/agents/alfred/trust-checker.md +25 -2
  27. moai_adk/templates/.claude/commands/alfred/0-project.md +5 -0
  28. moai_adk/templates/.claude/commands/alfred/1-plan.md +82 -19
  29. moai_adk/templates/.claude/commands/alfred/2-run.md +72 -15
  30. moai_adk/templates/.claude/commands/alfred/3-sync.md +74 -14
  31. moai_adk/templates/.claude/hooks/alfred/.moai/cache/version-check.json +9 -0
  32. moai_adk/templates/.claude/hooks/alfred/README.md +258 -145
  33. moai_adk/templates/.claude/hooks/alfred/TROUBLESHOOTING.md +471 -0
  34. moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +92 -57
  35. moai_adk/templates/.claude/hooks/alfred/core/version_cache.py +198 -0
  36. moai_adk/templates/.claude/hooks/alfred/notification__handle_events.py +102 -0
  37. moai_adk/templates/.claude/hooks/alfred/post_tool__log_changes.py +102 -0
  38. moai_adk/templates/.claude/hooks/alfred/pre_tool__auto_checkpoint.py +108 -0
  39. moai_adk/templates/.claude/hooks/alfred/session_end__cleanup.py +102 -0
  40. moai_adk/templates/.claude/hooks/alfred/session_start__show_project_info.py +102 -0
  41. moai_adk/templates/.claude/hooks/alfred/{core → shared/core}/project.py +286 -19
  42. moai_adk/templates/.claude/hooks/alfred/shared/core/version_cache.py +198 -0
  43. moai_adk/templates/.claude/hooks/alfred/{handlers → shared/handlers}/session.py +21 -7
  44. moai_adk/templates/.claude/hooks/alfred/stop__handle_interrupt.py +102 -0
  45. moai_adk/templates/.claude/hooks/alfred/subagent_stop__handle_subagent_end.py +102 -0
  46. moai_adk/templates/.claude/hooks/alfred/user_prompt__jit_load_docs.py +120 -0
  47. moai_adk/templates/.claude/settings.json +5 -5
  48. moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +9 -6
  49. moai_adk/templates/.claude/skills/moai-spec-authoring/README.md +56 -56
  50. moai_adk/templates/.claude/skills/moai-spec-authoring/SKILL.md +101 -100
  51. moai_adk/templates/.claude/skills/moai-spec-authoring/examples/validate-spec.sh +3 -3
  52. moai_adk/templates/.claude/skills/moai-spec-authoring/examples.md +219 -219
  53. moai_adk/templates/.claude/skills/moai-spec-authoring/reference.md +287 -287
  54. moai_adk/templates/.github/ISSUE_TEMPLATE/spec.yml +9 -11
  55. moai_adk/templates/.github/PULL_REQUEST_TEMPLATE.md +9 -21
  56. moai_adk/templates/.github/workflows/moai-release-create.yml +100 -0
  57. moai_adk/templates/.github/workflows/moai-release-pipeline.yml +182 -0
  58. moai_adk/templates/.github/workflows/release.yml +49 -0
  59. moai_adk/templates/.github/workflows/tag-report.yml +261 -0
  60. moai_adk/templates/.github/workflows/tag-validation.yml +176 -0
  61. moai_adk/templates/.moai/config.json +6 -1
  62. moai_adk/templates/.moai/hooks/install.sh +79 -0
  63. moai_adk/templates/.moai/hooks/pre-commit.sh +66 -0
  64. moai_adk/templates/CLAUDE.md +39 -40
  65. moai_adk/templates/src/moai_adk/core/__init__.py +5 -0
  66. moai_adk/templates/src/moai_adk/core/tags/__init__.py +86 -0
  67. moai_adk/templates/src/moai_adk/core/tags/ci_validator.py +433 -0
  68. moai_adk/templates/src/moai_adk/core/tags/cli.py +283 -0
  69. moai_adk/templates/src/moai_adk/core/tags/pre_commit_validator.py +355 -0
  70. moai_adk/templates/src/moai_adk/core/tags/reporter.py +957 -0
  71. moai_adk/templates/src/moai_adk/core/tags/validator.py +897 -0
  72. {moai_adk-0.8.1.dist-info → moai_adk-0.8.3.dist-info}/METADATA +240 -14
  73. {moai_adk-0.8.1.dist-info → moai_adk-0.8.3.dist-info}/RECORD +85 -50
  74. moai_adk/templates/.claude/hooks/alfred/HOOK_SCHEMA_VALIDATION.md +0 -313
  75. moai_adk/templates/.moai/memory/config-schema.md +0 -444
  76. /moai_adk/templates/.claude/hooks/alfred/{core → shared/core}/__init__.py +0 -0
  77. /moai_adk/templates/.claude/hooks/alfred/{core → shared/core}/checkpoint.py +0 -0
  78. /moai_adk/templates/.claude/hooks/alfred/{core → shared/core}/context.py +0 -0
  79. /moai_adk/templates/.claude/hooks/alfred/{core → shared/core}/tags.py +0 -0
  80. /moai_adk/templates/.claude/hooks/alfred/{handlers → shared/handlers}/__init__.py +0 -0
  81. /moai_adk/templates/.claude/hooks/alfred/{handlers → shared/handlers}/notification.py +0 -0
  82. /moai_adk/templates/.claude/hooks/alfred/{handlers → shared/handlers}/tool.py +0 -0
  83. /moai_adk/templates/.claude/hooks/alfred/{handlers → shared/handlers}/user.py +0 -0
  84. /moai_adk/templates/.moai/memory/{issue-label-mapping.md → ISSUE-LABEL-MAPPING.md} +0 -0
  85. {moai_adk-0.8.1.dist-info → moai_adk-0.8.3.dist-info}/WHEEL +0 -0
  86. {moai_adk-0.8.1.dist-info → moai_adk-0.8.3.dist-info}/entry_points.txt +0 -0
  87. {moai_adk-0.8.1.dist-info → moai_adk-0.8.3.dist-info}/licenses/LICENSE +0 -0
@@ -8,223 +8,336 @@ Alfred Hooks integrates with Claude Code's event system to automatically manage
8
8
 
9
9
  ## 📐 Architecture
10
10
 
11
- ### Modular Design (9 Files, ≤284 LOC each)
11
+ ### Individual Hook Files (Event + Function Naming)
12
12
 
13
13
  ```
14
14
  .claude/hooks/alfred/
15
- ├── alfred_hooks.py # Main entry point (CLI router)
16
- ├── core/ # Core business logic
17
- ├── __init__.py # Type definitions (HookPayload, HookResult)
18
- ├── project.py # Language detection, Git info, SPEC counting
19
- ├── context.py # JIT retrieval, workflow context
20
- ├── checkpoint.py # Event-driven checkpoint creation
21
- │ └── tags.py # TAG search, verification, caching
22
- └── handlers/ # Event handlers
23
- ├── __init__.py # Handler exports
24
- ├── session.py # SessionStart, SessionEnd
25
- ├── user.py # UserPromptSubmit
26
- ├── tool.py # PreToolUse, PostToolUse
27
- └── notification.py # Notification, Stop, SubagentStop
15
+ ├── session_start__show_project_info.py # SessionStart: Display project status
16
+ ├── user_prompt__jit_load_docs.py # UserPromptSubmit: JIT document loading
17
+ ├── pre_tool__auto_checkpoint.py # PreToolUse: Automatic safety checkpoints
18
+ ├── post_tool__log_changes.py # PostToolUse: Change tracking (stub)
19
+ ├── session_end__cleanup.py # SessionEnd: Cleanup resources (stub)
20
+ ├── notification__handle_events.py # Notification: Event processing (stub)
21
+ ├── stop__handle_interrupt.py # Stop: Interrupt handling (stub)
22
+ ├── subagent_stop__handle_subagent_end.py # SubagentStop: Sub-agent cleanup (stub)
23
+ └── shared/ # Shared business logic
24
+ ├── core/ # Core modules
25
+ ├── __init__.py # Type definitions (HookPayload, HookResult)
26
+ ├── project.py # Language detection, Git info, SPEC counting
27
+ │ ├── context.py # JIT retrieval, workflow context
28
+ │ ├── checkpoint.py # Event-driven checkpoint creation
29
+ │ └── version_cache.py # Library version management
30
+ └── handlers/ # Event handlers
31
+ ├── __init__.py # Handler exports
32
+ ├── session.py # SessionStart, SessionEnd handlers
33
+ ├── user.py # UserPromptSubmit handler
34
+ ├── tool.py # PreToolUse, PostToolUse handlers
35
+ └── notification.py # Notification, Stop handlers
28
36
  ```
29
37
 
30
38
  ### Design Principles
31
39
 
32
- - **Single Responsibility**: Each module has one clear responsibility
33
- - **Separation of Concerns**: core (business logic) vs handlers (event processing)
34
- - **CODE-FIRST**: Scan code directly without intermediate cache (mtime Based invalidation)
35
- - **Context Engineering**: Minimize initial context burden with JIT Retrieval
40
+ - **Clarity First**: File names describe what each hook does (UX priority)
41
+ - **DRY Implementation**: Shared logic in `shared/` modules (maintainability)
42
+ - **Self-Documenting**: Event + Function naming convention (e.g., `session_start__show_project_info.py`)
43
+ - **Independent Execution**: Each hook file is self-contained and executable
44
+ - **Timeout Protection**: All hooks enforce 5-second SIGALRM timeout
36
45
 
37
46
  ---
38
47
 
39
- ## 🎯 Core Modules
48
+ ## 🎯 Hook Files
40
49
 
41
- ### `core/project.py` (284 LOC)
50
+ ### `session_start__show_project_info.py`
42
51
 
43
- **Project metadata and language detection**
52
+ **Event**: SessionStart
53
+ **Purpose**: Display project information when session begins
44
54
 
45
- ```python
46
- # Public API
47
- detect_language(cwd: str) -> str
48
- get_project_language(cwd: str) -> str
49
- get_git_info(cwd: str) -> dict[str, Any]
50
- count_specs(cwd: str) -> dict[str, int]
55
+ **Output**:
56
+ - Programming language
57
+ - Git branch and status
58
+ - SPEC progress (completed/total %)
59
+ - Recent checkpoints
60
+
61
+ **Example**:
62
+ ```bash
63
+ echo '{"cwd": "."}' | uv run session_start__show_project_info.py
64
+ # Output: {"continue": true, "systemMessage": "🚀 MoAI-ADK v0.8.0 | 📦 python..."}
51
65
  ```
52
66
 
53
- **Features**:
54
- - Automatic detection of 20 languages ​​(Python, TypeScript, Java, Go, Rust, etc.)
55
- - `.moai/config.json` First, fallback to auto-detection
56
- - Check Git information (branch, commit, changes)
57
- - SPEC progress calculation (total, completed, percentage)
67
+ ---
58
68
 
59
- ### `core/context.py` (110 LOC)
69
+ ### `user_prompt__jit_load_docs.py`
60
70
 
61
- **JIT Context Retrieval and Workflow Management**
71
+ **Event**: UserPromptSubmit
72
+ **Purpose**: Analyze prompt and recommend relevant documents
62
73
 
63
- ```python
64
- # Public API
65
- get_jit_context(prompt: str, cwd: str) -> list[str]
66
- save_phase_context(phase: str, data: Any, ttl: int = 600)
67
- load_phase_context(phase: str, ttl: int = 600) -> Any | None
68
- clear_workflow_context()
74
+ **Features**:
75
+ - Pattern matching for Alfred commands (`/alfred:1-plan` → spec-metadata.md)
76
+ - @TAG mention detection
77
+ - SPEC reference extraction
78
+ - Document path suggestions
79
+
80
+ **Output Schema** (UserPromptSubmit-specific):
81
+ ```json
82
+ {
83
+ "continue": true,
84
+ "hookSpecificOutput": {
85
+ "hookEventName": "UserPromptSubmit",
86
+ "additionalContext": "Suggested documents: .moai/memory/spec-metadata.md"
87
+ }
88
+ }
69
89
  ```
70
90
 
71
- **Features**:
72
- - Automatically recommend documents based on prompt analysis
73
- - `/alfred:1-plan` → `spec-metadata.md`
74
- - `/alfred:2-run` → `development-guide.md`
75
- - Context caching for each workflow step (TTL 10 minutes)
76
- - Compliance with Anthropic Context Engineering principles
91
+ ---
77
92
 
78
- ### `core/checkpoint.py` (244 LOC)
93
+ ### `pre_tool__auto_checkpoint.py`
79
94
 
80
- **Event-Driven Checkpoint Automation**
95
+ **Event**: PreToolUse
96
+ **Matcher**: `Edit|Write|MultiEdit`
97
+ **Purpose**: Automatically create Git checkpoints before risky operations
81
98
 
82
- ```python
83
- # Public API
84
- detect_risky_operation(tool: str, args: dict, cwd: str) -> tuple[bool, str]
85
- create_checkpoint(cwd: str, operation: str) -> str
86
- log_checkpoint(cwd: str, branch: str, description: str)
87
- list_checkpoints(cwd: str, max_count: int = 10) -> list[dict]
88
- ```
99
+ **Risky Operations Detected**:
100
+ - **Bash**: `rm -rf`, `git merge`, `git reset --hard`
101
+ - **Edit/Write**: `CLAUDE.md`, `config.json`, critical configuration files
102
+ - **MultiEdit**: Operations affecting ≥10 files
89
103
 
90
- **Features**:
91
- - Automatic detection of dangerous tasks:
92
- - Bash: `rm -rf`, `git merge`, `git reset --hard`
93
- - Edit/Write: `CLAUDE.md`, `config.json`
94
- - MultiEdit: ≥10 files
95
- - Automatic creation of Git checkpoint: `checkpoint/before-{operation}-{timestamp}`
96
- - Checkpoint history management and recovery guide
104
+ **Checkpoint Strategy**:
105
+ 1. Detect risky pattern
106
+ 2. Create checkpoint branch: `checkpoint/before-{operation}-{timestamp}`
107
+ 3. Log to `.moai/checkpoints.log`
108
+ 4. Return guidance message to user
97
109
 
98
- ### `core/tags.py` (244 LOC)
110
+ **Example**:
111
+ ```bash
112
+ echo '{"toolName": "Bash", "arguments": {"command": "rm -rf temp/"}}' | uv run pre_tool__auto_checkpoint.py
113
+ # Output: {"continue": true, "systemMessage": "✅ Checkpoint created: checkpoint/before-rm-20251029-174500"}
114
+ ```
99
115
 
100
- **CODE-FIRST TAG SYSTEM**
116
+ ---
101
117
 
102
- ```python
103
- # Public API
104
- search_tags(pattern: str, scope: list[str], cache_ttl: int = 60) -> list[dict]
105
- verify_tag_chain(tag_id: str) -> dict[str, Any]
106
- find_all_tags_by_type(tag_type: str) -> dict[str, list[str]]
107
- suggest_tag_reuse(keyword: str) -> list[str]
108
- get_library_version(library: str, cache_ttl: int = 86400) -> str | None
109
- set_library_version(library: str, version: str)
110
- ```
118
+ ### Stub Hooks (Future Enhancement)
111
119
 
112
- **Features**:
113
- - ripgrep-based TAG search (parsing JSON output)
114
- - mtime-based cache invalidation (CODE-FIRST guaranteed)
115
- - TAG chain verification (@SPEC → @TEST → @CODE completeness check)
116
- - Library version caching (TTL 24 hours)
120
+ **`post_tool__log_changes.py`**
121
+ - Change tracking and audit logging
122
+ - Metrics collection (files modified, lines changed)
117
123
 
118
- ---
124
+ **`session_end__cleanup.py`**
125
+ - Clear temporary caches
126
+ - Save session metrics
119
127
 
120
- ## 🎬 Event Handlers
128
+ **`notification__handle_events.py`**
129
+ - Filter and categorize notifications
130
+ - Send alerts to external systems
121
131
 
122
- ### `handlers/session.py`
132
+ **`stop__handle_interrupt.py`**
133
+ - Save partial work before interruption
134
+ - Create recovery checkpoint
123
135
 
124
- **SessionStart, SessionEnd handlers**
136
+ **`subagent_stop__handle_subagent_end.py`**
137
+ - Collect sub-agent execution metrics
138
+ - Log results and errors
125
139
 
126
- - **SessionStart**: Display project information
127
- - Language, Git status, SPEC progress, recent checkpoint
128
- - Display directly to user with `systemMessage` field
129
- - **SessionEnd**: Cleanup task (stub)
140
+ ---
130
141
 
131
- ### `handlers/user.py`
142
+ ## 🏗️ Shared Modules
132
143
 
133
- **UserPromptSubmit Handler**
144
+ ### `shared/core/` - Business Logic
134
145
 
135
- - Return list of JIT Context recommended documents
136
- - Analyze user prompt patterns and load related documents
146
+ **`project.py`** (284 LOC)
147
+ ```python
148
+ detect_language(cwd: str) -> str
149
+ get_git_info(cwd: str) -> dict
150
+ count_specs(cwd: str) -> dict
151
+ ```
152
+
153
+ **`context.py`** (110 LOC)
154
+ ```python
155
+ get_jit_context(prompt: str, cwd: str) -> list[str]
156
+ ```
137
157
 
138
- ### `handlers/tool.py`
158
+ **`checkpoint.py`** (244 LOC)
159
+ ```python
160
+ detect_risky_operation(tool: str, args: dict) -> tuple[bool, str]
161
+ create_checkpoint(cwd: str, operation: str) -> str
162
+ ```
139
163
 
140
- **PreToolUse, PostToolUse handlers**
164
+ ### `shared/handlers/` - Event Processing
141
165
 
142
- - **PreToolUse**: Automatic checkpoint creation when dangerous operation is detected
143
- - **PostToolUse**: Post-processing operation (stub)
166
+ **`session.py`** - SessionStart, SessionEnd
167
+ **`user.py`** - UserPromptSubmit
168
+ **`tool.py`** - PreToolUse, PostToolUse
169
+ **`notification.py`** - Notification, Stop, SubagentStop
144
170
 
145
- ### `handlers/notification.py`
171
+ ---
146
172
 
147
- **Notification, Stop, SubagentStop handlers**
173
+ ## 🔧 Configuration
174
+
175
+ ### settings.json
176
+
177
+ ```json
178
+ {
179
+ "hooks": {
180
+ "SessionStart": [{
181
+ "hooks": [{
182
+ "command": "uv run \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/alfred/session_start__show_project_info.py",
183
+ "type": "command"
184
+ }]
185
+ }],
186
+ "UserPromptSubmit": [{
187
+ "hooks": [{
188
+ "command": "uv run \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/alfred/user_prompt__jit_load_docs.py",
189
+ "type": "command"
190
+ }]
191
+ }],
192
+ "PreToolUse": [{
193
+ "hooks": [{
194
+ "command": "uv run \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/alfred/pre_tool__auto_checkpoint.py",
195
+ "type": "command"
196
+ }],
197
+ "matcher": "Edit|Write|MultiEdit"
198
+ }]
199
+ }
200
+ }
201
+ ```
148
202
 
149
- - Basic implementation (stub, can be expanded in the future)
203
+ **Key Changes**:
204
+ - ✅ File names are self-descriptive (no arguments needed)
205
+ - ✅ `$CLAUDE_PROJECT_DIR` for reliable path resolution
206
+ - ✅ Each hook file is independent and testable
150
207
 
151
208
  ---
152
209
 
153
210
  ## 🧪 Testing
154
211
 
155
- ### Test Suite
212
+ ### Test Individual Hooks
156
213
 
157
214
  ```bash
158
- # Run all tests
159
- uv run pytest tests/unit/test_alfred_hooks_*.py -v --no-cov
215
+ # Test SessionStart hook
216
+ echo '{"cwd": "."}' | uv run session_start__show_project_info.py
160
217
 
161
- # Run specific module tests
162
- uv run pytest tests/unit/test_alfred_hooks_core_tags.py -v
163
- uv run pytest tests/unit/test_alfred_hooks_core_context.py -v
164
- uv run pytest tests/unit/test_alfred_hooks_core_project.py -v
218
+ # Test UserPromptSubmit hook
219
+ echo '{"cwd": ".", "userPrompt": "/alfred:1-plan"}' | uv run user_prompt__jit_load_docs.py
220
+
221
+ # Test PreToolUse hook
222
+ echo '{"cwd": ".", "toolName": "Edit", "arguments": {"file_path": "CLAUDE.md"}}' | uv run pre_tool__auto_checkpoint.py
165
223
  ```
166
224
 
167
- ### Test Coverage (18 tests)
225
+ ### Expected Output
168
226
 
169
- - **tags.py**: 7 tests (cache, TAG verification, version management)
170
- - **context.py**: 5 tests (JIT, workflow context)
171
- - **project.py**: 6 tests (language detection, Git, SPEC count)
227
+ All hooks should return valid JSON with:
228
+ - `"continue": true` (required field)
229
+ - `"systemMessage"` or `"hookSpecificOutput"` (depending on hook type)
172
230
 
173
- ### Test Structure
231
+ ---
174
232
 
175
- ```python
176
- # Dynamic module loading for isolated testing
177
- def _load_{module}_module(module_name: str):
178
- repo_root = Path(__file__).resolve().parents[2]
179
- hooks_dir = repo_root / ".claude" / "hooks" / "alfred"
180
- sys.path.insert(0, str(hooks_dir))
181
-
182
- module_path = hooks_dir / "core" / "{module}.py"
183
- spec = importlib.util.spec_from_file_location(module_name, module_path)
184
- # ...
233
+ ## 🐛 Troubleshooting
234
+
235
+ For detailed troubleshooting guide, see [TROUBLESHOOTING.md](./TROUBLESHOOTING.md).
236
+
237
+ ### Quick Diagnosis
238
+
239
+ ```bash
240
+ # List all hook files
241
+ ls -la .claude/hooks/alfred/*.py
242
+
243
+ # Expected output:
244
+ # session_start__show_project_info.py
245
+ # user_prompt__jit_load_docs.py
246
+ # pre_tool__auto_checkpoint.py
247
+ # post_tool__log_changes.py
248
+ # session_end__cleanup.py
249
+ # notification__handle_events.py
250
+ # stop__handle_interrupt.py
251
+ # subagent_stop__handle_subagent_end.py
185
252
  ```
186
253
 
254
+ ### Common Issues
255
+
256
+ 1. **"Hook not found"** → Run `/alfred:0-project update`
257
+ 2. **"Import error: No module named 'handlers'"** → Check `shared/handlers/__init__.py` exists
258
+ 3. **"Timeout"** → Check Git/file operations, consider increasing timeout in hook file
259
+ 4. **"Permission denied"** → Run `chmod +x .claude/hooks/alfred/*.py`
260
+
187
261
  ---
188
262
 
189
- ## 🔄 Migration from moai_hooks.py
263
+ ## 🏗️ Architecture Decisions
190
264
 
191
- ### Before (Monolithic)
265
+ ### Why Individual Hook Files? (UX Priority)
192
266
 
193
- - **1 file**: 1233 LOC
194
- - **Issues**:
195
- - All functions concentrated in one file
196
- - Difficult to test, complex to maintain
197
- - Unclear separation of responsibilities
267
+ **Before** (Single Router):
268
+ ```
269
+ alfred_hooks.py SessionStart ❌ Unclear what "SessionStart" does
270
+ ```
198
271
 
199
- ### After (Modular)
272
+ **After** (Individual Files):
273
+ ```
274
+ session_start__show_project_info.py ✅ Immediately clear purpose
275
+ ```
200
276
 
201
- - **9 files**: ≤284 LOC each
202
- - **Benefits**:
203
- - Clear separation of responsibilities (SRP)
204
- - Independent module testing possible
205
- - Easy to expand, easy to maintain
206
- - Compliance with Context Engineering principles
277
+ **Benefits**:
278
+ 1. **Self-Documenting**: File name describes functionality
279
+ 2. **Easy Debugging**: Error messages show which hook failed
280
+ 3. **Simple Discovery**: `ls` command shows all available hooks
281
+ 4. **Independent Testing**: Each hook can be tested in isolation
282
+ 5. **Selective Disabling**: Comment out specific hook in settings.json
207
283
 
208
- ### Breaking Changes
284
+ **Tradeoffs**:
285
+ - ⚠️ **More Files**: 8 hook files instead of 1 router
286
+ - ⚠️ **Shared Logic**: Still needs `shared/` directory for DRY principle
209
287
 
210
- **None** - External APIs remain the same.
288
+ **Decision**: **UX > Technical Elegance** - Users benefit from clarity
211
289
 
212
- ---
290
+ ### Why Keep shared/ Directory? (DRY Principle)
291
+
292
+ **Shared Logic** (70% of codebase):
293
+ - Type definitions (HookResult, HookPayload)
294
+ - Project metadata (language detection, Git info)
295
+ - Checkpoint creation
296
+ - JIT context analysis
297
+
298
+ **Alternative** (Code Duplication):
299
+ ```python
300
+ # ❌ BAD: Copy HookResult to each hook file
301
+ # session_start__show_project_info.py
302
+ class HookResult: # 50 LOC duplicated
303
+ ...
304
+
305
+ # user_prompt__jit_load_docs.py
306
+ class HookResult: # 50 LOC duplicated again
307
+ ...
308
+ ```
213
309
 
214
- ## 📚 References
310
+ **Current** (Shared Module):
311
+ ```python
312
+ # ✅ GOOD: Import from shared module
313
+ from shared.core import HookResult # DRY principle
314
+ ```
315
+
316
+ **Decision**: **Hybrid Approach** - Individual files for UX + Shared modules for DRY
317
+
318
+ ---
215
319
 
216
- ### Internal Documents
320
+ ## 📈 Version History
217
321
 
218
- - **CLAUDE.md**: MoAI-ADK User Guide
219
- - **.moai/memory/development-guide.md**: SPEC-First TDD Workflow
220
- - **.moai/memory/spec-metadata.md**: SPEC metadata standard
322
+ ### v0.9.0 (2025-10-29) - Individual Hook Files (UX Priority)
323
+ - ✅ **BREAKING**: Split `alfred_hooks.py` into 8 individual files
324
+ - ✅ **NAMING**: Event + Function naming convention (`session_start__show_project_info.py`)
325
+ - ✅ **STRUCTURE**: Moved shared logic to `shared/` directory
326
+ - ✅ **UX**: File names are self-descriptive (no arguments needed)
327
+ - ✅ **DEBUGGING**: Error messages now show which hook failed
221
328
 
222
- ### External Resources
329
+ ### v0.8.0 (2025-10-29) - Path Resolution & Timeout Fixes
330
+ - ✅ **FIXED**: Use `$CLAUDE_PROJECT_DIR` for reliable path resolution
331
+ - ✅ **ADDED**: Global SIGALRM timeout protection (5 seconds)
332
+ - ✅ **ADDED**: Comprehensive TROUBLESHOOTING.md guide
223
333
 
224
- - [Claude Code Hooks Documentation](https://docs.claude.com/en/docs/claude-code)
225
- - [Anthropic Context Engineering](https://docs.anthropic.com/claude/docs/context-engineering)
334
+ ### v0.7.0 (2025-10-17) - Stateless Refactoring
335
+ - **REMOVED**: Workflow context from hooks (delegated to Commands layer)
336
+ - ✅ **PERFORMANCE**: 180ms → 70ms (61% improvement)
337
+ - ✅ **COMPLIANCE**: 100% stateless (no global variables)
226
338
 
227
339
  ---
228
340
 
229
- **Last Updated**: 2025-10-16
341
+ **Last Updated**: 2025-10-29
342
+ **Version**: 0.9.0
230
343
  **Author**: @Alfred (MoAI-ADK SuperAgent)