moai-adk 0.9.1__py3-none-any.whl โ 0.11.0__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.
- moai_adk/core/project/phase_executor.py +4 -0
- moai_adk/core/tags/ci_validator.py +33 -3
- moai_adk/core/template_engine.py +6 -2
- moai_adk/templates/.git-hooks/pre-push +143 -0
- moai_adk/templates/.github/workflows/moai-gitflow.yml +6 -1
- moai_adk/templates/.github/workflows/release.yml +6 -2
- moai_adk/templates/.github/workflows/tag-validation.yml +57 -8
- moai_adk/templates/CLAUDE.md +477 -28
- moai_adk/templates/README.md +256 -0
- {moai_adk-0.9.1.dist-info โ moai_adk-0.11.0.dist-info}/METADATA +740 -90
- moai_adk-0.11.0.dist-info/RECORD +77 -0
- moai_adk/templates/.claude/agents/alfred/cc-manager.md +0 -316
- moai_adk/templates/.claude/agents/alfred/debug-helper.md +0 -208
- moai_adk/templates/.claude/agents/alfred/doc-syncer.md +0 -214
- moai_adk/templates/.claude/agents/alfred/git-manager.md +0 -406
- moai_adk/templates/.claude/agents/alfred/implementation-planner.md +0 -350
- moai_adk/templates/.claude/agents/alfred/project-manager.md +0 -273
- moai_adk/templates/.claude/agents/alfred/quality-gate.md +0 -343
- moai_adk/templates/.claude/agents/alfred/skill-factory.md +0 -865
- moai_adk/templates/.claude/agents/alfred/spec-builder.md +0 -287
- moai_adk/templates/.claude/agents/alfred/tag-agent.md +0 -287
- moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +0 -326
- moai_adk/templates/.claude/agents/alfred/trust-checker.md +0 -375
- moai_adk/templates/.claude/commands/alfred/0-project.md +0 -1189
- moai_adk/templates/.claude/commands/alfred/1-plan.md +0 -728
- moai_adk/templates/.claude/commands/alfred/2-run.md +0 -545
- moai_adk/templates/.claude/commands/alfred/3-sync.md +0 -683
- moai_adk/templates/.claude/commands/alfred/9-feedback.md +0 -149
- moai_adk/templates/.claude/hooks/alfred/.moai/cache/version-check.json +0 -9
- moai_adk/templates/.claude/hooks/alfred/README.md +0 -343
- moai_adk/templates/.claude/hooks/alfred/TROUBLESHOOTING.md +0 -471
- moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +0 -209
- moai_adk/templates/.claude/hooks/alfred/core/version_cache.py +0 -198
- moai_adk/templates/.claude/hooks/alfred/notification__handle_events.py +0 -102
- moai_adk/templates/.claude/hooks/alfred/post_tool__log_changes.py +0 -102
- moai_adk/templates/.claude/hooks/alfred/pre_tool__auto_checkpoint.py +0 -108
- moai_adk/templates/.claude/hooks/alfred/session_end__cleanup.py +0 -102
- moai_adk/templates/.claude/hooks/alfred/session_start__show_project_info.py +0 -102
- moai_adk/templates/.claude/hooks/alfred/shared/core/__init__.py +0 -170
- moai_adk/templates/.claude/hooks/alfred/shared/core/checkpoint.py +0 -271
- moai_adk/templates/.claude/hooks/alfred/shared/core/context.py +0 -67
- moai_adk/templates/.claude/hooks/alfred/shared/core/project.py +0 -683
- moai_adk/templates/.claude/hooks/alfred/shared/core/tags.py +0 -198
- moai_adk/templates/.claude/hooks/alfred/shared/core/version_cache.py +0 -198
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/__init__.py +0 -21
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/notification.py +0 -25
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/session.py +0 -175
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/tool.py +0 -90
- moai_adk/templates/.claude/hooks/alfred/shared/handlers/user.py +0 -61
- moai_adk/templates/.claude/hooks/alfred/stop__handle_interrupt.py +0 -102
- moai_adk/templates/.claude/hooks/alfred/subagent_stop__handle_subagent_end.py +0 -102
- moai_adk/templates/.claude/hooks/alfred/user_prompt__jit_load_docs.py +0 -120
- moai_adk/templates/.claude/output-styles/alfred/agentic-coding.md +0 -640
- moai_adk/templates/.claude/output-styles/alfred/moai-adk-learning.md +0 -696
- moai_adk/templates/.claude/output-styles/alfred/study-with-alfred.md +0 -474
- moai_adk/templates/.claude/settings.json +0 -144
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/SKILL.md +0 -122
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-git-workflow/reference.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/SKILL.md +0 -237
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/examples.md +0 -615
- moai_adk/templates/.claude/skills/moai-alfred-interactive-questions/reference.md +0 -653
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-language-detection/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-alfred-trust-validation/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-cc-agents/SKILL.md +0 -269
- moai_adk/templates/.claude/skills/moai-cc-agents/templates/agent-template.md +0 -32
- moai_adk/templates/.claude/skills/moai-cc-claude-md/SKILL.md +0 -298
- moai_adk/templates/.claude/skills/moai-cc-claude-md/templates/CLAUDE-template.md +0 -26
- moai_adk/templates/.claude/skills/moai-cc-commands/SKILL.md +0 -307
- moai_adk/templates/.claude/skills/moai-cc-commands/templates/command-template.md +0 -21
- moai_adk/templates/.claude/skills/moai-cc-hooks/SKILL.md +0 -252
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/pre-bash-check.sh +0 -19
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/preserve-permissions.sh +0 -19
- moai_adk/templates/.claude/skills/moai-cc-hooks/scripts/validate-bash-command.py +0 -24
- moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/SKILL.md +0 -199
- moai_adk/templates/.claude/skills/moai-cc-mcp-plugins/templates/settings-mcp-template.json +0 -39
- moai_adk/templates/.claude/skills/moai-cc-memory/SKILL.md +0 -316
- moai_adk/templates/.claude/skills/moai-cc-memory/templates/session-summary-template.md +0 -18
- moai_adk/templates/.claude/skills/moai-cc-settings/SKILL.md +0 -263
- moai_adk/templates/.claude/skills/moai-cc-settings/templates/settings-complete-template.json +0 -30
- moai_adk/templates/.claude/skills/moai-cc-skills/SKILL.md +0 -291
- moai_adk/templates/.claude/skills/moai-cc-skills/templates/SKILL-template.md +0 -15
- moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +0 -290
- moai_adk/templates/.claude/skills/moai-domain-backend/examples.md +0 -1633
- moai_adk/templates/.claude/skills/moai-domain-backend/reference.md +0 -660
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-cli-tool/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-domain-data-science/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-data-science/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-data-science/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-database/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-database/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-domain-devops/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-domain-devops/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-devops/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-domain-frontend/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-frontend/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-domain-ml/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-ml/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-ml/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-mobile-app/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-domain-security/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-security/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-security/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-domain-web-api/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-domain-web-api/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-domain-web-api/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +0 -303
- moai_adk/templates/.claude/skills/moai-essentials-debug/examples.md +0 -1064
- moai_adk/templates/.claude/skills/moai-essentials-debug/reference.md +0 -1047
- moai_adk/templates/.claude/skills/moai-essentials-perf/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-essentials-perf/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-essentials-perf/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-essentials-refactor/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-essentials-refactor/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-essentials-refactor/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-essentials-review/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-essentials-review/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-essentials-review/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +0 -116
- moai_adk/templates/.claude/skills/moai-foundation-ears/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-foundation-ears/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-foundation-git/SKILL.md +0 -122
- moai_adk/templates/.claude/skills/moai-foundation-git/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-foundation-git/reference.md +0 -29
- moai_adk/templates/.claude/skills/moai-foundation-langs/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-foundation-langs/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-foundation-langs/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-foundation-specs/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-foundation-specs/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-foundation-specs/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-foundation-tags/SKILL.md +0 -113
- moai_adk/templates/.claude/skills/moai-foundation-tags/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-foundation-tags/reference.md +0 -28
- moai_adk/templates/.claude/skills/moai-foundation-trust/SKILL.md +0 -307
- moai_adk/templates/.claude/skills/moai-foundation-trust/examples.md +0 -0
- moai_adk/templates/.claude/skills/moai-foundation-trust/reference.md +0 -1099
- moai_adk/templates/.claude/skills/moai-lang-c/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-c/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-c/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-cpp/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-cpp/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-csharp/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-csharp/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-dart/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-dart/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-dart/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-go/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-go/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-java/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-java/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +0 -125
- moai_adk/templates/.claude/skills/moai-lang-javascript/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-javascript/reference.md +0 -32
- moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-kotlin/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-kotlin/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-php/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-php/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +0 -431
- moai_adk/templates/.claude/skills/moai-lang-python/examples.md +0 -624
- moai_adk/templates/.claude/skills/moai-lang-python/reference.md +0 -316
- moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-r/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-r/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-ruby/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-ruby/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-rust/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-rust/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-scala/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-scala/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-shell/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-shell/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-shell/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-sql/SKILL.md +0 -124
- moai_adk/templates/.claude/skills/moai-lang-sql/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-sql/reference.md +0 -31
- moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +0 -123
- moai_adk/templates/.claude/skills/moai-lang-swift/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-swift/reference.md +0 -30
- moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +0 -127
- moai_adk/templates/.claude/skills/moai-lang-typescript/examples.md +0 -29
- moai_adk/templates/.claude/skills/moai-lang-typescript/reference.md +0 -34
- moai_adk/templates/.claude/skills/moai-skill-factory/CHECKLIST.md +0 -482
- moai_adk/templates/.claude/skills/moai-skill-factory/EXAMPLES.md +0 -278
- moai_adk/templates/.claude/skills/moai-skill-factory/INTERACTIVE-DISCOVERY.md +0 -524
- moai_adk/templates/.claude/skills/moai-skill-factory/METADATA.md +0 -477
- moai_adk/templates/.claude/skills/moai-skill-factory/PARALLEL-ANALYSIS-REPORT.md +0 -429
- moai_adk/templates/.claude/skills/moai-skill-factory/PYTHON-VERSION-MATRIX.md +0 -391
- moai_adk/templates/.claude/skills/moai-skill-factory/SKILL-FACTORY-WORKFLOW.md +0 -431
- moai_adk/templates/.claude/skills/moai-skill-factory/SKILL-UPDATE-ADVISOR.md +0 -577
- moai_adk/templates/.claude/skills/moai-skill-factory/SKILL.md +0 -271
- moai_adk/templates/.claude/skills/moai-skill-factory/STEP-BY-STEP-GUIDE.md +0 -466
- moai_adk/templates/.claude/skills/moai-skill-factory/STRUCTURE.md +0 -583
- moai_adk/templates/.claude/skills/moai-skill-factory/WEB-RESEARCH.md +0 -526
- moai_adk/templates/.claude/skills/moai-skill-factory/reference.md +0 -465
- moai_adk/templates/.claude/skills/moai-skill-factory/scripts/generate-structure.sh +0 -328
- moai_adk/templates/.claude/skills/moai-skill-factory/scripts/validate-skill.sh +0 -312
- moai_adk/templates/.claude/skills/moai-skill-factory/templates/SKILL_TEMPLATE.md +0 -245
- moai_adk/templates/.claude/skills/moai-skill-factory/templates/examples-template.md +0 -285
- moai_adk/templates/.claude/skills/moai-skill-factory/templates/reference-template.md +0 -278
- moai_adk/templates/.claude/skills/moai-skill-factory/templates/scripts-template.sh +0 -303
- moai_adk/templates/.claude/skills/moai-spec-authoring/README.md +0 -137
- moai_adk/templates/.claude/skills/moai-spec-authoring/SKILL.md +0 -219
- moai_adk/templates/.claude/skills/moai-spec-authoring/examples/validate-spec.sh +0 -161
- moai_adk/templates/.claude/skills/moai-spec-authoring/examples.md +0 -541
- moai_adk/templates/.claude/skills/moai-spec-authoring/reference.md +0 -622
- moai_adk/templates/.github/workflows/tag-report.yml +0 -261
- moai_adk/templates/.moai/config.json +0 -113
- moai_adk/templates/.moai/docs/quick-issue-creation-guide.md +0 -219
- moai_adk/templates/.moai/hooks/install.sh +0 -79
- moai_adk/templates/.moai/hooks/pre-commit.sh +0 -66
- moai_adk/templates/.moai/memory/CLAUDE-AGENTS-GUIDE.md +0 -208
- moai_adk/templates/.moai/memory/CLAUDE-PRACTICES.md +0 -369
- moai_adk/templates/.moai/memory/CLAUDE-RULES.md +0 -539
- moai_adk/templates/.moai/memory/DEVELOPMENT-GUIDE.md +0 -344
- moai_adk/templates/.moai/memory/GITFLOW-PROTECTION-POLICY.md +0 -220
- moai_adk/templates/.moai/memory/ISSUE-LABEL-MAPPING.md +0 -150
- moai_adk/templates/.moai/memory/SKILLS-DESCRIPTION-POLICY.md +0 -218
- moai_adk/templates/.moai/memory/SPEC-METADATA.md +0 -356
- moai_adk/templates/.moai/memory/gitflow-protection-policy.md +0 -220
- moai_adk/templates/.moai/memory/spec-metadata.md +0 -356
- moai_adk/templates/.moai/project/product.md +0 -161
- moai_adk/templates/.moai/project/structure.md +0 -156
- moai_adk/templates/.moai/project/tech.md +0 -227
- moai_adk/templates/src/moai_adk/core/__init__.py +0 -5
- moai_adk/templates/src/moai_adk/core/tags/__init__.py +0 -86
- moai_adk/templates/src/moai_adk/core/tags/ci_validator.py +0 -433
- moai_adk/templates/src/moai_adk/core/tags/cli.py +0 -283
- moai_adk/templates/src/moai_adk/core/tags/validator.py +0 -897
- moai_adk-0.9.1.dist-info/RECORD +0 -320
- {moai_adk-0.9.1.dist-info โ moai_adk-0.11.0.dist-info}/WHEEL +0 -0
- {moai_adk-0.9.1.dist-info โ moai_adk-0.11.0.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.9.1.dist-info โ moai_adk-0.11.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,471 +0,0 @@
|
|
|
1
|
-
# Alfred Hooks Troubleshooting Guide
|
|
2
|
-
|
|
3
|
-
This guide helps you diagnose and resolve common issues with MoAI-ADK's Alfred hooks system.
|
|
4
|
-
|
|
5
|
-
## Quick Diagnosis
|
|
6
|
-
|
|
7
|
-
Run this command to verify hook integrity:
|
|
8
|
-
|
|
9
|
-
```bash
|
|
10
|
-
# Test hook execution
|
|
11
|
-
echo '{"cwd": "."}' | uv run .claude/hooks/alfred/alfred_hooks.py SessionStart
|
|
12
|
-
```
|
|
13
|
-
|
|
14
|
-
**Expected output**: JSON with `"continue": true` and a system message
|
|
15
|
-
**If failed**: See error-specific sections below
|
|
16
|
-
|
|
17
|
-
---
|
|
18
|
-
|
|
19
|
-
## Error 1: "Hook not found"
|
|
20
|
-
|
|
21
|
-
### Symptom
|
|
22
|
-
```
|
|
23
|
-
error: Failed to spawn: `.claude/hooks/alfred/alfred_hooks.py`
|
|
24
|
-
Caused by: No such file or directory (os error 2)
|
|
25
|
-
```
|
|
26
|
-
|
|
27
|
-
### Root Causes
|
|
28
|
-
1. **Project initialized with older MoAI-ADK version** (before hooks system)
|
|
29
|
-
2. **Hooks directory deleted accidentally**
|
|
30
|
-
3. **Template copy failed during `/alfred:0-project` initialization**
|
|
31
|
-
4. **Working directory mismatch** (Claude Code started from wrong directory)
|
|
32
|
-
|
|
33
|
-
### Solutions
|
|
34
|
-
|
|
35
|
-
#### Solution 1: Update Project (Recommended)
|
|
36
|
-
```bash
|
|
37
|
-
# Re-run project initialization to restore hooks
|
|
38
|
-
/alfred:0-project
|
|
39
|
-
```
|
|
40
|
-
|
|
41
|
-
#### Solution 2: Manual Template Copy
|
|
42
|
-
```bash
|
|
43
|
-
# Copy hooks from MoAI-ADK installation
|
|
44
|
-
python3 -c "
|
|
45
|
-
import moai_adk
|
|
46
|
-
from pathlib import Path
|
|
47
|
-
import shutil
|
|
48
|
-
|
|
49
|
-
template_dir = Path(moai_adk.__file__).parent / 'templates' / '.claude' / 'hooks' / 'alfred'
|
|
50
|
-
target_dir = Path('.claude/hooks/alfred')
|
|
51
|
-
target_dir.parent.mkdir(parents=True, exist_ok=True)
|
|
52
|
-
shutil.copytree(template_dir, target_dir, dirs_exist_ok=True)
|
|
53
|
-
print(f'Copied hooks to {target_dir}')
|
|
54
|
-
"
|
|
55
|
-
```
|
|
56
|
-
|
|
57
|
-
#### Solution 3: Verify File Existence
|
|
58
|
-
```bash
|
|
59
|
-
# Check all required files exist
|
|
60
|
-
ls -la .claude/hooks/alfred/
|
|
61
|
-
ls -la .claude/hooks/alfred/handlers/
|
|
62
|
-
ls -la .claude/hooks/alfred/core/
|
|
63
|
-
|
|
64
|
-
# Expected files:
|
|
65
|
-
# .claude/hooks/alfred/alfred_hooks.py
|
|
66
|
-
# .claude/hooks/alfred/handlers/__init__.py
|
|
67
|
-
# .claude/hooks/alfred/handlers/session.py
|
|
68
|
-
# .claude/hooks/alfred/handlers/user.py
|
|
69
|
-
# .claude/hooks/alfred/handlers/tool.py
|
|
70
|
-
# .claude/hooks/alfred/handlers/notification.py
|
|
71
|
-
# .claude/hooks/alfred/core/__init__.py
|
|
72
|
-
# .claude/hooks/alfred/core/project.py
|
|
73
|
-
# .claude/hooks/alfred/core/context.py
|
|
74
|
-
# .claude/hooks/alfred/core/checkpoint.py
|
|
75
|
-
```
|
|
76
|
-
|
|
77
|
-
---
|
|
78
|
-
|
|
79
|
-
## Error 2: "Import error: No module named 'handlers'"
|
|
80
|
-
|
|
81
|
-
### Symptom
|
|
82
|
-
```python
|
|
83
|
-
ImportError: No module named 'handlers'
|
|
84
|
-
ModuleNotFoundError: No module named 'core'
|
|
85
|
-
```
|
|
86
|
-
|
|
87
|
-
### Root Causes
|
|
88
|
-
1. **Corrupted hooks directory** (partial copy, missing `__init__.py`)
|
|
89
|
-
2. **Python path resolution issue** (sys.path manipulation failed)
|
|
90
|
-
3. **Missing handler/core modules**
|
|
91
|
-
|
|
92
|
-
### Solutions
|
|
93
|
-
|
|
94
|
-
#### Solution 1: Verify Module Structure
|
|
95
|
-
```bash
|
|
96
|
-
# Check all __init__.py files exist
|
|
97
|
-
find .claude/hooks/alfred -name "__init__.py"
|
|
98
|
-
|
|
99
|
-
# Expected output:
|
|
100
|
-
# .claude/hooks/alfred/handlers/__init__.py
|
|
101
|
-
# .claude/hooks/alfred/core/__init__.py
|
|
102
|
-
```
|
|
103
|
-
|
|
104
|
-
#### Solution 2: Test Imports Manually
|
|
105
|
-
```bash
|
|
106
|
-
cd .claude/hooks/alfred && python3 -c "
|
|
107
|
-
import sys
|
|
108
|
-
from pathlib import Path
|
|
109
|
-
sys.path.insert(0, str(Path.cwd()))
|
|
110
|
-
|
|
111
|
-
from handlers import handle_session_start
|
|
112
|
-
from core import HookResult
|
|
113
|
-
print('โ
Imports successful')
|
|
114
|
-
"
|
|
115
|
-
```
|
|
116
|
-
|
|
117
|
-
#### Solution 3: Re-initialize Hooks
|
|
118
|
-
```bash
|
|
119
|
-
# Force re-copy from template
|
|
120
|
-
/alfred:0-project update --force
|
|
121
|
-
```
|
|
122
|
-
|
|
123
|
-
---
|
|
124
|
-
|
|
125
|
-
## Error 3: "Hook execution timeout"
|
|
126
|
-
|
|
127
|
-
### Symptom
|
|
128
|
-
```
|
|
129
|
-
Hook timeout after 5 seconds
|
|
130
|
-
โ ๏ธ Hook execution timeout - continuing without session info
|
|
131
|
-
```
|
|
132
|
-
|
|
133
|
-
### Root Causes
|
|
134
|
-
1. **Slow Git operations** (large repository, many branches)
|
|
135
|
-
2. **Slow file I/O** (network drive, slow disk)
|
|
136
|
-
3. **Heavy SPEC counting** (many `.moai/specs/` directories)
|
|
137
|
-
4. **Subprocess hang** (rare, usually indicates system issue)
|
|
138
|
-
|
|
139
|
-
### Solutions
|
|
140
|
-
|
|
141
|
-
#### Solution 1: Identify Slow Operations
|
|
142
|
-
```bash
|
|
143
|
-
# Time hook execution
|
|
144
|
-
time echo '{"cwd": "."}' | uv run .claude/hooks/alfred/alfred_hooks.py SessionStart
|
|
145
|
-
|
|
146
|
-
# If >5 seconds, check:
|
|
147
|
-
# - Git repository size: du -sh .git
|
|
148
|
-
# - SPEC count: find .moai/specs -type d -name "SPEC-*" | wc -l
|
|
149
|
-
# - Disk I/O: iotop (Linux) or sudo fs_usage (macOS)
|
|
150
|
-
```
|
|
151
|
-
|
|
152
|
-
#### Solution 2: Increase Timeout (Temporary Workaround)
|
|
153
|
-
```bash
|
|
154
|
-
# Edit alfred_hooks.py line 129
|
|
155
|
-
# Change: signal.alarm(5) # 5 seconds
|
|
156
|
-
# To: signal.alarm(10) # 10 seconds
|
|
157
|
-
|
|
158
|
-
# Location: .claude/hooks/alfred/alfred_hooks.py
|
|
159
|
-
```
|
|
160
|
-
|
|
161
|
-
**Note**: This is a workaround. File an issue if hooks consistently timeout.
|
|
162
|
-
|
|
163
|
-
#### Solution 3: Disable Slow Features (Not Currently Supported)
|
|
164
|
-
**Future enhancement**: Add `.moai/config.json` option to disable expensive checks:
|
|
165
|
-
```json
|
|
166
|
-
{
|
|
167
|
-
"hooks": {
|
|
168
|
-
"session_start": {
|
|
169
|
-
"skip_git_info": false,
|
|
170
|
-
"skip_spec_count": false
|
|
171
|
-
}
|
|
172
|
-
}
|
|
173
|
-
}
|
|
174
|
-
```
|
|
175
|
-
|
|
176
|
-
---
|
|
177
|
-
|
|
178
|
-
## Error 4: "JSON parse error"
|
|
179
|
-
|
|
180
|
-
### Symptom
|
|
181
|
-
```
|
|
182
|
-
JSON parse error: Expecting value: line 1 column 1 (char 0)
|
|
183
|
-
```
|
|
184
|
-
|
|
185
|
-
### Root Causes
|
|
186
|
-
1. **Empty stdin** (Claude Code passed no payload)
|
|
187
|
-
2. **Invalid JSON format** (malformed payload)
|
|
188
|
-
3. **Encoding issues** (non-UTF-8 characters)
|
|
189
|
-
|
|
190
|
-
### Solutions
|
|
191
|
-
|
|
192
|
-
#### Solution 1: Test with Minimal Payload
|
|
193
|
-
```bash
|
|
194
|
-
# Empty payload (should work - returns empty dict)
|
|
195
|
-
echo '' | uv run .claude/hooks/alfred/alfred_hooks.py SessionStart
|
|
196
|
-
|
|
197
|
-
# Minimal valid payload
|
|
198
|
-
echo '{"cwd": "."}' | uv run .claude/hooks/alfred/alfred_hooks.py SessionStart
|
|
199
|
-
```
|
|
200
|
-
|
|
201
|
-
#### Solution 2: Check Claude Code Version
|
|
202
|
-
```bash
|
|
203
|
-
# Ensure Claude Code is up-to-date
|
|
204
|
-
claude-code --version
|
|
205
|
-
|
|
206
|
-
# Update if needed
|
|
207
|
-
pip install --upgrade claude-code
|
|
208
|
-
```
|
|
209
|
-
|
|
210
|
-
---
|
|
211
|
-
|
|
212
|
-
## Error 5: "Permission denied"
|
|
213
|
-
|
|
214
|
-
### Symptom
|
|
215
|
-
```
|
|
216
|
-
PermissionError: [Errno 13] Permission denied: '.claude/hooks/alfred/alfred_hooks.py'
|
|
217
|
-
```
|
|
218
|
-
|
|
219
|
-
### Root Causes
|
|
220
|
-
1. **File not executable** (missing execute permission)
|
|
221
|
-
2. **Directory permissions** (parent directory not readable)
|
|
222
|
-
3. **Ownership issues** (file owned by different user)
|
|
223
|
-
|
|
224
|
-
### Solutions
|
|
225
|
-
|
|
226
|
-
#### Solution 1: Fix Permissions
|
|
227
|
-
```bash
|
|
228
|
-
# Make executable
|
|
229
|
-
chmod +x .claude/hooks/alfred/alfred_hooks.py
|
|
230
|
-
|
|
231
|
-
# Fix directory permissions
|
|
232
|
-
chmod -R u+rX .claude/hooks/alfred/
|
|
233
|
-
```
|
|
234
|
-
|
|
235
|
-
#### Solution 2: Check Ownership
|
|
236
|
-
```bash
|
|
237
|
-
# Check file owner
|
|
238
|
-
ls -l .claude/hooks/alfred/alfred_hooks.py
|
|
239
|
-
|
|
240
|
-
# Change owner if needed (replace USER with your username)
|
|
241
|
-
sudo chown -R USER:USER .claude/hooks/alfred/
|
|
242
|
-
```
|
|
243
|
-
|
|
244
|
-
---
|
|
245
|
-
|
|
246
|
-
## Error 6: "UV environment issues"
|
|
247
|
-
|
|
248
|
-
### Symptom
|
|
249
|
-
```
|
|
250
|
-
uv: command not found
|
|
251
|
-
error: failed to create virtualenv
|
|
252
|
-
```
|
|
253
|
-
|
|
254
|
-
### Root Causes
|
|
255
|
-
1. **UV not installed**
|
|
256
|
-
2. **UV not in PATH**
|
|
257
|
-
3. **Virtual environment corruption**
|
|
258
|
-
|
|
259
|
-
### Solutions
|
|
260
|
-
|
|
261
|
-
#### Solution 1: Install/Update UV
|
|
262
|
-
```bash
|
|
263
|
-
# Install UV
|
|
264
|
-
pip install uv
|
|
265
|
-
|
|
266
|
-
# Or update
|
|
267
|
-
pip install --upgrade uv
|
|
268
|
-
|
|
269
|
-
# Verify
|
|
270
|
-
uv --version
|
|
271
|
-
```
|
|
272
|
-
|
|
273
|
-
#### Solution 2: Check PATH
|
|
274
|
-
```bash
|
|
275
|
-
# Find UV installation
|
|
276
|
-
which uv
|
|
277
|
-
|
|
278
|
-
# Add to PATH if needed
|
|
279
|
-
export PATH="$HOME/.local/bin:$PATH"
|
|
280
|
-
```
|
|
281
|
-
|
|
282
|
-
#### Solution 3: Rebuild Virtual Environment
|
|
283
|
-
```bash
|
|
284
|
-
# Remove existing environment
|
|
285
|
-
rm -rf .venv
|
|
286
|
-
|
|
287
|
-
# Recreate
|
|
288
|
-
uv venv
|
|
289
|
-
uv sync
|
|
290
|
-
```
|
|
291
|
-
|
|
292
|
-
---
|
|
293
|
-
|
|
294
|
-
## Platform-Specific Issues
|
|
295
|
-
|
|
296
|
-
### macOS: SIGALRM Not Working
|
|
297
|
-
**Note**: SIGALRM is fully supported on macOS. If timeout protection isn't working:
|
|
298
|
-
|
|
299
|
-
```bash
|
|
300
|
-
# Verify Python version (3.8+ required)
|
|
301
|
-
python3 --version
|
|
302
|
-
|
|
303
|
-
# Test signal module
|
|
304
|
-
python3 -c "import signal; print(hasattr(signal, 'SIGALRM'))"
|
|
305
|
-
# Expected: True
|
|
306
|
-
```
|
|
307
|
-
|
|
308
|
-
### Windows: SIGALRM Not Available
|
|
309
|
-
**Known Limitation**: SIGALRM is not available on Windows.
|
|
310
|
-
|
|
311
|
-
**Workaround**: Hooks must complete in <2 seconds (no timeout protection).
|
|
312
|
-
|
|
313
|
-
**Alternative**: Use threading-based timeout (future enhancement):
|
|
314
|
-
```python
|
|
315
|
-
import threading
|
|
316
|
-
|
|
317
|
-
def run_with_timeout(func, timeout=5):
|
|
318
|
-
result = []
|
|
319
|
-
def wrapper():
|
|
320
|
-
result.append(func())
|
|
321
|
-
|
|
322
|
-
thread = threading.Thread(target=wrapper)
|
|
323
|
-
thread.start()
|
|
324
|
-
thread.join(timeout)
|
|
325
|
-
|
|
326
|
-
if thread.is_alive():
|
|
327
|
-
raise TimeoutError("Function timeout")
|
|
328
|
-
return result[0]
|
|
329
|
-
```
|
|
330
|
-
|
|
331
|
-
### Linux: Signal Conflicts
|
|
332
|
-
If other tools use SIGALRM (rare), hooks may conflict.
|
|
333
|
-
|
|
334
|
-
**Diagnosis**:
|
|
335
|
-
```bash
|
|
336
|
-
# Check for signal handlers
|
|
337
|
-
python3 -c "
|
|
338
|
-
import signal
|
|
339
|
-
print('Current SIGALRM handler:', signal.getsignal(signal.SIGALRM))
|
|
340
|
-
"
|
|
341
|
-
```
|
|
342
|
-
|
|
343
|
-
---
|
|
344
|
-
|
|
345
|
-
## Advanced Debugging
|
|
346
|
-
|
|
347
|
-
### Enable Hook Logging
|
|
348
|
-
```bash
|
|
349
|
-
# Create custom hook wrapper with logging
|
|
350
|
-
cat > .claude/hooks/alfred/debug_hooks.sh <<'EOF'
|
|
351
|
-
#!/bin/bash
|
|
352
|
-
EVENT=$1
|
|
353
|
-
INPUT=$(cat)
|
|
354
|
-
|
|
355
|
-
echo "[$(date)] Event: $EVENT" >> /tmp/alfred_hooks.log
|
|
356
|
-
echo "[$(date)] Input: $INPUT" >> /tmp/alfred_hooks.log
|
|
357
|
-
|
|
358
|
-
OUTPUT=$(echo "$INPUT" | uv run .claude/hooks/alfred/alfred_hooks.py "$EVENT" 2>&1)
|
|
359
|
-
EXIT_CODE=$?
|
|
360
|
-
|
|
361
|
-
echo "[$(date)] Output: $OUTPUT" >> /tmp/alfred_hooks.log
|
|
362
|
-
echo "[$(date)] Exit: $EXIT_CODE" >> /tmp/alfred_hooks.log
|
|
363
|
-
|
|
364
|
-
echo "$OUTPUT"
|
|
365
|
-
exit $EXIT_CODE
|
|
366
|
-
EOF
|
|
367
|
-
|
|
368
|
-
chmod +x .claude/hooks/alfred/debug_hooks.sh
|
|
369
|
-
|
|
370
|
-
# Update settings.json to use debug wrapper
|
|
371
|
-
# "command": "uv run \"$CLAUDE_PROJECT_DIR\"/.claude/hooks/alfred/debug_hooks.sh SessionStart"
|
|
372
|
-
```
|
|
373
|
-
|
|
374
|
-
### Monitor Hook Performance
|
|
375
|
-
```bash
|
|
376
|
-
# Benchmark all hook events
|
|
377
|
-
for event in SessionStart UserPromptSubmit PreToolUse PostToolUse SessionEnd; do
|
|
378
|
-
echo "Testing $event..."
|
|
379
|
-
time echo '{"cwd": "."}' | uv run .claude/hooks/alfred/alfred_hooks.py $event > /dev/null
|
|
380
|
-
done
|
|
381
|
-
```
|
|
382
|
-
|
|
383
|
-
### Validate Hook Output Schema
|
|
384
|
-
```bash
|
|
385
|
-
# Test output format
|
|
386
|
-
OUTPUT=$(echo '{"cwd": "."}' | uv run .claude/hooks/alfred/alfred_hooks.py SessionStart)
|
|
387
|
-
|
|
388
|
-
# Check required fields
|
|
389
|
-
echo "$OUTPUT" | python3 -c "
|
|
390
|
-
import json, sys
|
|
391
|
-
data = json.load(sys.stdin)
|
|
392
|
-
assert 'continue' in data, 'Missing continue field'
|
|
393
|
-
assert isinstance(data['continue'], bool), 'continue must be boolean'
|
|
394
|
-
print('โ
Valid hook output schema')
|
|
395
|
-
"
|
|
396
|
-
```
|
|
397
|
-
|
|
398
|
-
---
|
|
399
|
-
|
|
400
|
-
## Getting Help
|
|
401
|
-
|
|
402
|
-
### Collect Diagnostic Information
|
|
403
|
-
```bash
|
|
404
|
-
# Create diagnostic report
|
|
405
|
-
cat > /tmp/hooks_diagnostic.txt <<EOF
|
|
406
|
-
=== MoAI-ADK Hooks Diagnostic Report ===
|
|
407
|
-
Date: $(date)
|
|
408
|
-
|
|
409
|
-
=== Environment ===
|
|
410
|
-
OS: $(uname -s)
|
|
411
|
-
Python: $(python3 --version)
|
|
412
|
-
UV: $(uv --version 2>&1)
|
|
413
|
-
Claude Code: $(claude-code --version 2>&1)
|
|
414
|
-
|
|
415
|
-
=== File Structure ===
|
|
416
|
-
$(find .claude/hooks/alfred -type f 2>&1)
|
|
417
|
-
|
|
418
|
-
=== Permissions ===
|
|
419
|
-
$(ls -la .claude/hooks/alfred/ 2>&1)
|
|
420
|
-
|
|
421
|
-
=== Hook Test ===
|
|
422
|
-
$(echo '{"cwd": "."}' | uv run .claude/hooks/alfred/alfred_hooks.py SessionStart 2>&1)
|
|
423
|
-
|
|
424
|
-
=== Settings ===
|
|
425
|
-
$(cat .claude/settings.json 2>&1 | grep -A 10 "SessionStart")
|
|
426
|
-
EOF
|
|
427
|
-
|
|
428
|
-
cat /tmp/hooks_diagnostic.txt
|
|
429
|
-
```
|
|
430
|
-
|
|
431
|
-
### Report Issues
|
|
432
|
-
1. **GitHub Issues**: https://github.com/modu-ai/moai-adk/issues
|
|
433
|
-
2. **Include**: Diagnostic report (above) + error message + steps to reproduce
|
|
434
|
-
3. **Security**: Do NOT include secrets, API keys, or sensitive paths
|
|
435
|
-
|
|
436
|
-
---
|
|
437
|
-
|
|
438
|
-
## Preventive Maintenance
|
|
439
|
-
|
|
440
|
-
### Regular Health Checks
|
|
441
|
-
```bash
|
|
442
|
-
# Add to .git/hooks/post-merge
|
|
443
|
-
cat > .git/hooks/post-merge <<'EOF'
|
|
444
|
-
#!/bin/bash
|
|
445
|
-
# Verify hooks after pulling updates
|
|
446
|
-
echo '{"cwd": "."}' | uv run .claude/hooks/alfred/alfred_hooks.py SessionStart > /dev/null 2>&1
|
|
447
|
-
if [ $? -ne 0 ]; then
|
|
448
|
-
echo "โ ๏ธ Alfred hooks failed - run /alfred:0-project update"
|
|
449
|
-
fi
|
|
450
|
-
EOF
|
|
451
|
-
|
|
452
|
-
chmod +x .git/hooks/post-merge
|
|
453
|
-
```
|
|
454
|
-
|
|
455
|
-
### Keep MoAI-ADK Updated
|
|
456
|
-
```bash
|
|
457
|
-
# Check version
|
|
458
|
-
python3 -c "import moai_adk; print(moai_adk.__version__)"
|
|
459
|
-
|
|
460
|
-
# Update
|
|
461
|
-
pip install --upgrade moai-adk
|
|
462
|
-
|
|
463
|
-
# Re-initialize project
|
|
464
|
-
/alfred:0-project update
|
|
465
|
-
```
|
|
466
|
-
|
|
467
|
-
---
|
|
468
|
-
|
|
469
|
-
**Last Updated**: 2025-10-29
|
|
470
|
-
**Applies To**: MoAI-ADK v0.7.0+
|
|
471
|
-
**Hooks Architecture Version**: Hybrid Modular (9 modules)
|
|
@@ -1,209 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# @CODE:HOOKS-REFACTOR-001 | SPEC: SPEC-HOOKS-REFACTOR-001.md
|
|
3
|
-
"""Alfred Hooks - Main entry point for MoAI-ADK Claude Code Hooks
|
|
4
|
-
|
|
5
|
-
A main entry point that routes Claude Code events to the appropriate handlers.
|
|
6
|
-
|
|
7
|
-
๐๏ธ Architecture:
|
|
8
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
9
|
-
โ alfred_hooks.py (Router) โ
|
|
10
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
11
|
-
โ - CLI argument parsing โ
|
|
12
|
-
โ - JSON I/O (stdin/stdout) โ
|
|
13
|
-
โ - Event routing to handlers โ
|
|
14
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
15
|
-
โผ
|
|
16
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
17
|
-
โ handlers/ (Event Handlers) โ
|
|
18
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
19
|
-
โ - session.py: SessionStart, SessionEnd โ
|
|
20
|
-
โ - user.py: UserPromptSubmit โ
|
|
21
|
-
โ - tool.py: PreToolUse, PostToolUse โ
|
|
22
|
-
โ - notification.py: Notification, Stop, SubagentStop โ
|
|
23
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
24
|
-
โผ
|
|
25
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
26
|
-
โ core/ (Business Logic) โ
|
|
27
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโค
|
|
28
|
-
โ - project.py: Language detection, Git info, SPEC progress โ
|
|
29
|
-
โ - context.py: JIT Retrieval, workflow context โ
|
|
30
|
-
โ - checkpoint.py: Event-Driven Checkpoint system โ
|
|
31
|
-
โ - tags.py: TAG search/verification, library version cache โ
|
|
32
|
-
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
|
|
33
|
-
|
|
34
|
-
๐ ๏ธ Usage:
|
|
35
|
-
python alfred_hooks.py <event_name> < payload.json
|
|
36
|
-
|
|
37
|
-
๐ฃ Supported Events:
|
|
38
|
-
- SessionStart: Start Session (display project status)
|
|
39
|
-
- UserPromptSubmit: Prompt submission (JIT document loading)
|
|
40
|
-
- PreToolUse: Before using the tool (automatically creates checkpoint)
|
|
41
|
-
- SessionEnd, PostToolUse, Notification, Stop, SubagentStop
|
|
42
|
-
|
|
43
|
-
๐ฆ Exit Codes:
|
|
44
|
-
- 0: Success
|
|
45
|
-
- 1: Error (no arguments, JSON parsing failure, exception thrown)
|
|
46
|
-
|
|
47
|
-
๐งช TDD History:
|
|
48
|
-
- RED: Module separation design, event routing test
|
|
49
|
-
- GREEN: 1233 LOC โ 9 items Module separation implementation (SRP compliance)
|
|
50
|
-
- REFACTOR: Import optimization, enhanced error handling
|
|
51
|
-
|
|
52
|
-
Setup sys.path for package imports
|
|
53
|
-
"""
|
|
54
|
-
|
|
55
|
-
import json
|
|
56
|
-
import signal
|
|
57
|
-
import sys
|
|
58
|
-
from pathlib import Path
|
|
59
|
-
from typing import Any
|
|
60
|
-
|
|
61
|
-
from core import HookResult
|
|
62
|
-
from handlers import (
|
|
63
|
-
handle_notification,
|
|
64
|
-
handle_post_tool_use,
|
|
65
|
-
handle_pre_tool_use,
|
|
66
|
-
handle_session_end,
|
|
67
|
-
handle_session_start,
|
|
68
|
-
handle_stop,
|
|
69
|
-
handle_subagent_stop,
|
|
70
|
-
handle_user_prompt_submit,
|
|
71
|
-
)
|
|
72
|
-
|
|
73
|
-
# Add the hooks directory to sys.path to enable package imports
|
|
74
|
-
HOOKS_DIR = Path(__file__).parent
|
|
75
|
-
if str(HOOKS_DIR) not in sys.path:
|
|
76
|
-
sys.path.insert(0, str(HOOKS_DIR))
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
class HookTimeoutError(Exception):
|
|
80
|
-
"""Hook execution timeout exception"""
|
|
81
|
-
pass
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
def _hook_timeout_handler(signum, frame):
|
|
85
|
-
"""Signal handler for global hook timeout"""
|
|
86
|
-
raise HookTimeoutError("Hook execution exceeded 5-second timeout")
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
def main() -> None:
|
|
90
|
-
"""Main entry point - Claude Code Hook script with GLOBAL TIMEOUT PROTECTION
|
|
91
|
-
|
|
92
|
-
Receives the event name as a CLI argument and reads the JSON payload through stdin.
|
|
93
|
-
Calls the handler appropriate for the event and outputs the results to stdout as JSON.
|
|
94
|
-
Enforces a 5-second global timeout to prevent subprocess hangs from freezing Claude Code.
|
|
95
|
-
|
|
96
|
-
๐ ๏ธ Usage:
|
|
97
|
-
python alfred_hooks.py <event_name> < payload.json
|
|
98
|
-
|
|
99
|
-
๐ฃ Supported Events:
|
|
100
|
-
- SessionStart: Start Session (display project status)
|
|
101
|
-
- UserPromptSubmit: Prompt submission (JIT document loading)
|
|
102
|
-
- SessionEnd, PreToolUse, PostToolUse, Notification, Stop, SubagentStop
|
|
103
|
-
|
|
104
|
-
๐ฆ Exit Codes:
|
|
105
|
-
- 0: Success
|
|
106
|
-
- 1: Error (timeout, no arguments, JSON parsing failure, exception thrown)
|
|
107
|
-
|
|
108
|
-
๐ Examples:
|
|
109
|
-
$ echo '{"cwd": "."}' | python alfred_hooks.py SessionStart
|
|
110
|
-
{"message": "๐ MoAI-ADK Session Started\\n...", ...}
|
|
111
|
-
|
|
112
|
-
๐๏ธ Notes:
|
|
113
|
-
- Claude Code is automatically called (no need for direct user execution)
|
|
114
|
-
- JSON I/O processing through stdin/stdout
|
|
115
|
-
- Print error message to stderr
|
|
116
|
-
- UserPromptSubmit uses a special output schema (hookEventName + additionalContext)
|
|
117
|
-
- CRITICAL: 5-second global timeout prevents Claude Code freeze on subprocess hang
|
|
118
|
-
|
|
119
|
-
๐งช TDD History:
|
|
120
|
-
- RED: Event routing, JSON I/O, error handling testing
|
|
121
|
-
- GREEN: Handler map-based routing implementation
|
|
122
|
-
- REFACTOR: Error message clarification, exit code standardization, UserPromptSubmit schema separation
|
|
123
|
-
- HOTFIX: Added global SIGALRM timeout to prevent subprocess hang (Issue #66)
|
|
124
|
-
|
|
125
|
-
@TAG:HOOKS-TIMEOUT-001
|
|
126
|
-
"""
|
|
127
|
-
# Set global 5-second timeout for entire hook execution
|
|
128
|
-
signal.signal(signal.SIGALRM, _hook_timeout_handler)
|
|
129
|
-
signal.alarm(5)
|
|
130
|
-
|
|
131
|
-
try:
|
|
132
|
-
# Check for event argument
|
|
133
|
-
if len(sys.argv) < 2:
|
|
134
|
-
print("Usage: alfred_hooks.py <event>", file=sys.stderr)
|
|
135
|
-
sys.exit(1)
|
|
136
|
-
|
|
137
|
-
event_name = sys.argv[1]
|
|
138
|
-
|
|
139
|
-
try:
|
|
140
|
-
# Read JSON from stdin
|
|
141
|
-
input_data = sys.stdin.read()
|
|
142
|
-
# Handle empty stdin gracefully (return empty dict)
|
|
143
|
-
if not input_data or not input_data.strip():
|
|
144
|
-
data = {}
|
|
145
|
-
else:
|
|
146
|
-
data = json.loads(input_data)
|
|
147
|
-
|
|
148
|
-
cwd = data.get("cwd", ".")
|
|
149
|
-
|
|
150
|
-
# Route to appropriate handler
|
|
151
|
-
handlers = {
|
|
152
|
-
"SessionStart": handle_session_start,
|
|
153
|
-
"UserPromptSubmit": handle_user_prompt_submit,
|
|
154
|
-
"SessionEnd": handle_session_end,
|
|
155
|
-
"PreToolUse": handle_pre_tool_use,
|
|
156
|
-
"PostToolUse": handle_post_tool_use,
|
|
157
|
-
"Notification": handle_notification,
|
|
158
|
-
"Stop": handle_stop,
|
|
159
|
-
"SubagentStop": handle_subagent_stop,
|
|
160
|
-
}
|
|
161
|
-
|
|
162
|
-
handler = handlers.get(event_name)
|
|
163
|
-
result = handler({"cwd": cwd, **data}) if handler else HookResult()
|
|
164
|
-
|
|
165
|
-
# Output Hook result as JSON
|
|
166
|
-
# Note: UserPromptSubmit uses to_user_prompt_submit_dict() for special schema
|
|
167
|
-
if event_name == "UserPromptSubmit":
|
|
168
|
-
print(json.dumps(result.to_user_prompt_submit_dict()))
|
|
169
|
-
else:
|
|
170
|
-
print(json.dumps(result.to_dict()))
|
|
171
|
-
|
|
172
|
-
sys.exit(0)
|
|
173
|
-
|
|
174
|
-
except json.JSONDecodeError as e:
|
|
175
|
-
# Return valid Hook response even on JSON parse error
|
|
176
|
-
error_response: dict[str, Any] = {
|
|
177
|
-
"continue": True,
|
|
178
|
-
"hookSpecificOutput": {"error": f"JSON parse error: {e}"}
|
|
179
|
-
}
|
|
180
|
-
print(json.dumps(error_response))
|
|
181
|
-
print(f"JSON parse error: {e}", file=sys.stderr)
|
|
182
|
-
sys.exit(1)
|
|
183
|
-
except Exception as e:
|
|
184
|
-
# Return valid Hook response even on unexpected error
|
|
185
|
-
error_response: dict[str, Any] = {
|
|
186
|
-
"continue": True,
|
|
187
|
-
"hookSpecificOutput": {"error": f"Hook error: {e}"}
|
|
188
|
-
}
|
|
189
|
-
print(json.dumps(error_response))
|
|
190
|
-
print(f"Unexpected error: {e}", file=sys.stderr)
|
|
191
|
-
sys.exit(1)
|
|
192
|
-
|
|
193
|
-
except HookTimeoutError:
|
|
194
|
-
# CRITICAL: Hook took too long - return minimal valid response to prevent Claude Code freeze
|
|
195
|
-
timeout_response: dict[str, Any] = {
|
|
196
|
-
"continue": True,
|
|
197
|
-
"systemMessage": "โ ๏ธ Hook execution timeout - continuing without session info"
|
|
198
|
-
}
|
|
199
|
-
print(json.dumps(timeout_response))
|
|
200
|
-
print("Hook timeout after 5 seconds", file=sys.stderr)
|
|
201
|
-
sys.exit(1)
|
|
202
|
-
|
|
203
|
-
finally:
|
|
204
|
-
# Always cancel the alarm to prevent signal leakage
|
|
205
|
-
signal.alarm(0)
|
|
206
|
-
|
|
207
|
-
|
|
208
|
-
if __name__ == "__main__":
|
|
209
|
-
main()
|