moai-adk 0.9.1__py3-none-any.whl → 0.10.1__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/templates/.claude/hooks/alfred/core/project.py +750 -0
- moai_adk/templates/.claude/hooks/alfred/shared/core/project.py +97 -24
- moai_adk/templates/.git-hooks/pre-push +143 -0
- moai_adk/templates/.github/workflows/tag-validation.yml +4 -0
- moai_adk/templates/.moai/memory/gitflow-protection-policy.md +140 -30
- moai_adk/templates/CLAUDE.md +58 -0
- moai_adk/templates/README.md +256 -0
- {moai_adk-0.9.1.dist-info → moai_adk-0.10.1.dist-info}/METADATA +714 -79
- {moai_adk-0.9.1.dist-info → moai_adk-0.10.1.dist-info}/RECORD +12 -23
- 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/.github/workflows/tag-report.yml +0 -261
- 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/GITFLOW-PROTECTION-POLICY.md +0 -220
- moai_adk/templates/.moai/memory/SPEC-METADATA.md +0 -356
- 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 → moai_adk-0.10.1.dist-info}/WHEEL +0 -0
- {moai_adk-0.9.1.dist-info → moai_adk-0.10.1.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.9.1.dist-info → moai_adk-0.10.1.dist-info}/licenses/LICENSE +0 -0
|
@@ -53,7 +53,8 @@ moai_adk/core/template/languages.py,sha256=V0wLcxCIOve9Q_0_NhrHGQevSIN_MB612GwrO
|
|
|
53
53
|
moai_adk/core/template/merger.py,sha256=ZV8_U1HZJ3bfAtgyNmSxgj8KdTMt4eUnUG6kVVRT7bE,6909
|
|
54
54
|
moai_adk/core/template/processor.py,sha256=_nYHiuN9PGzC3iE4X5SpRMFW-OTkI2u1dOAjD98axAk,19190
|
|
55
55
|
moai_adk/templates/.gitignore,sha256=6VNKResdDpyaii3cmJA4pOLwK2PhYARIWkUODYtKyxg,310
|
|
56
|
-
moai_adk/templates/CLAUDE.md,sha256=
|
|
56
|
+
moai_adk/templates/CLAUDE.md,sha256=TjVPW-u2AtymQIvAc7yAHimetXGFaXoA35p9_rxYb_M,15790
|
|
57
|
+
moai_adk/templates/README.md,sha256=727KhnlpzLukiKRy4ZBZpcn1QL9XtXehv2TUbN9w1ak,8791
|
|
57
58
|
moai_adk/templates/__init__.py,sha256=6MV1gCB7PLZMiL4gaD_dZSKxtcQyo45MMTuN8fVdchA,104
|
|
58
59
|
moai_adk/templates/.claude/settings.json,sha256=CJuGzZU84aWPS0UOcDYJxUOEVau60piT_X4kybyimuQ,3270
|
|
59
60
|
moai_adk/templates/.claude/agents/alfred/cc-manager.md,sha256=gVw9NMzy6UJqQ20GEiYz8Sm03e-4TKNR1-0Lz0MGPTc,9264
|
|
@@ -73,8 +74,6 @@ moai_adk/templates/.claude/commands/alfred/1-plan.md,sha256=NROGRNbxXd-0kXX_eW_7
|
|
|
73
74
|
moai_adk/templates/.claude/commands/alfred/2-run.md,sha256=s8zU2146DXupi3vJHoTDZB3YPm0v1vRnP8p_sPtuIBo,24375
|
|
74
75
|
moai_adk/templates/.claude/commands/alfred/3-sync.md,sha256=Pr9EGFol09l-MLdc2fFSOkpqA7jPHV1KPePqmfkKQgg,26619
|
|
75
76
|
moai_adk/templates/.claude/commands/alfred/9-feedback.md,sha256=VMaKo-ZODHun87uUfiihtHGf8eT4vrEWwxXdQ9RAz3k,3764
|
|
76
|
-
moai_adk/templates/.claude/hooks/alfred/README.md,sha256=LsSMvsxNwdV2CjA2X6Zn_xy73kT7-0Y7G-u_9bLKYlI,10568
|
|
77
|
-
moai_adk/templates/.claude/hooks/alfred/TROUBLESHOOTING.md,sha256=xINO1G3ujccL42JQzExEm-oiY9jHGrXm2YAlxtYkZY4,10753
|
|
78
77
|
moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py,sha256=eOV-evpk8ChZD9_kMNmrRysCpy3ZMzV6cq1Oys0vRn0,9220
|
|
79
78
|
moai_adk/templates/.claude/hooks/alfred/notification__handle_events.py,sha256=Gn-hSpMs6Oy6yJcluXUcmlXiyS48RmsDWZn1xu3tgLA,2911
|
|
80
79
|
moai_adk/templates/.claude/hooks/alfred/post_tool__log_changes.py,sha256=7wxR2gQFX3nmBi9uC6KORjQGrQAv1y6JxJ_fcMxsw78,2939
|
|
@@ -84,12 +83,12 @@ moai_adk/templates/.claude/hooks/alfred/session_start__show_project_info.py,sha2
|
|
|
84
83
|
moai_adk/templates/.claude/hooks/alfred/stop__handle_interrupt.py,sha256=0GrMBWOQreGqJM-Q8_B1kXLdPchDiEnpsQSJlBIByxo,2863
|
|
85
84
|
moai_adk/templates/.claude/hooks/alfred/subagent_stop__handle_subagent_end.py,sha256=YmDOuvWa6OnSowsMitkRovekoJNq65pUPlmiTgQoBnE,2958
|
|
86
85
|
moai_adk/templates/.claude/hooks/alfred/user_prompt__jit_load_docs.py,sha256=AOPc8EmNbKMFsOhk5d7nGZ7aZbm-ZH8MNT0_I1Wv-hE,3585
|
|
87
|
-
moai_adk/templates/.claude/hooks/alfred
|
|
86
|
+
moai_adk/templates/.claude/hooks/alfred/core/project.py,sha256=LxcesuFDZDDBWQut-0ez_4kmTcrrNbsAZrb5GubWeA8,26953
|
|
88
87
|
moai_adk/templates/.claude/hooks/alfred/core/version_cache.py,sha256=mOxvLtLiZDSCSlq0svECCJYIX0rPpNJOwL1KZjOB5yo,5967
|
|
89
88
|
moai_adk/templates/.claude/hooks/alfred/shared/core/__init__.py,sha256=nx_02kZDVFlKOgxBfFz3nqVrxMkmrkE0x7crJhdjl5E,6377
|
|
90
89
|
moai_adk/templates/.claude/hooks/alfred/shared/core/checkpoint.py,sha256=dsvFDSXQNSQlaQLpvhqFbytGOrOivyovi43Y18EmNeI,8483
|
|
91
90
|
moai_adk/templates/.claude/hooks/alfred/shared/core/context.py,sha256=RQd6yk8OGT-twgYtUiNmJIL-UEt_h4oktxqiRP_wXAI,2103
|
|
92
|
-
moai_adk/templates/.claude/hooks/alfred/shared/core/project.py,sha256=
|
|
91
|
+
moai_adk/templates/.claude/hooks/alfred/shared/core/project.py,sha256=1kr8ywemj6IQ8in4A2VccFxABmKT7lq7CFGKzwvtod4,27489
|
|
93
92
|
moai_adk/templates/.claude/hooks/alfred/shared/core/tags.py,sha256=XcYYCS1VmCejp7Ga9xZ3hDfrWWsKM-WyPD_N5gY1q1w,6359
|
|
94
93
|
moai_adk/templates/.claude/hooks/alfred/shared/core/version_cache.py,sha256=zt0a6__qsZVI_rfZuPv3JDpVZeUGLWBvYprTjSg_7gM,5965
|
|
95
94
|
moai_adk/templates/.claude/hooks/alfred/shared/handlers/__init__.py,sha256=j5L7nayKt7tnFQOZuO5sWiie815vmbmYJOn2VRiidLY,569
|
|
@@ -277,6 +276,7 @@ moai_adk/templates/.claude/skills/moai-spec-authoring/SKILL.md,sha256=JoHdTtLdDc
|
|
|
277
276
|
moai_adk/templates/.claude/skills/moai-spec-authoring/examples.md,sha256=rLSWTioSN0njc6W1tcsZA-R_mVG55oEXysii1NRMZWg,14527
|
|
278
277
|
moai_adk/templates/.claude/skills/moai-spec-authoring/reference.md,sha256=vTZ2BBo0mqpzhIcEGabyG7vXrm28V7qiQany5o_OxMQ,16124
|
|
279
278
|
moai_adk/templates/.claude/skills/moai-spec-authoring/examples/validate-spec.sh,sha256=FSXNA_8v36sN4V-3HpGudOXJo2c4t2whf_5QNDn6FiE,4251
|
|
279
|
+
moai_adk/templates/.git-hooks/pre-push,sha256=4BGVMllmG3c_4T1S_nVEWDGQbxeCDll-fIgxAUoSvrI,6468
|
|
280
280
|
moai_adk/templates/.github/PULL_REQUEST_TEMPLATE.md,sha256=rzTnwxhccYZO_yHqsW5FaxIMhggfLO9xJ6D1IYMEQqc,2153
|
|
281
281
|
moai_adk/templates/.github/ISSUE_TEMPLATE/spec.yml,sha256=fon91ozuKBeDwrw2BBuTSbkGApDEptNP9er5dW_-ZVc,5280
|
|
282
282
|
moai_adk/templates/.github/workflows/moai-gitflow.yml,sha256=9QDqqscY7npu_1Sfsn0g9piX0QRDRZFhbEEwkZGXIG0,8684
|
|
@@ -284,37 +284,26 @@ moai_adk/templates/.github/workflows/moai-release-create.yml,sha256=KrHGkAep6iRy
|
|
|
284
284
|
moai_adk/templates/.github/workflows/moai-release-pipeline.yml,sha256=kVpRk_OFgz0AVctLRLA2ASN-G_-prAHTGI7tufe6Pd0,6319
|
|
285
285
|
moai_adk/templates/.github/workflows/release.yml,sha256=5h4-npHKU-t1mnOQePYcpkcdGCN_560-Obu5tUCyNe0,1382
|
|
286
286
|
moai_adk/templates/.github/workflows/spec-issue-sync.yml,sha256=GIYeQQvwcoi0r-o85nEbSSLwT5EsrSEzJKLhLMX7GPk,6483
|
|
287
|
-
moai_adk/templates/.github/workflows/tag-
|
|
288
|
-
moai_adk/templates/.github/workflows/tag-validation.yml,sha256=1JEbUzc0vHL4C2LTs0Q7rBREmrV5N5zM2WBYJ1NMCAI,6769
|
|
287
|
+
moai_adk/templates/.github/workflows/tag-validation.yml,sha256=fo3GsPKO4XdQ4cfe6m8qXWyMza5rkt2LiR9aW7aEshw,6835
|
|
289
288
|
moai_adk/templates/.moai/config.json,sha256=r7TtDLtS06YDP7EsqsghNfKCNkltVxVbmmSJHwQQV-s,2950
|
|
290
|
-
moai_adk/templates/.moai/docs/quick-issue-creation-guide.md,sha256=tFJqsNr9SpXlGao6HXXm6I8FmC7yCkUo9cu6lE1GaVA,5460
|
|
291
|
-
moai_adk/templates/.moai/hooks/install.sh,sha256=P1-RtiHp7m2QIUUcHQ_oHB1xnqRQnD5QePb2iUo7qfA,2112
|
|
292
|
-
moai_adk/templates/.moai/hooks/pre-commit.sh,sha256=86UIhXMqJ4i24mKrLdzvyWXYSMK__EtXGSpE19wgVw4,1802
|
|
293
289
|
moai_adk/templates/.moai/memory/CLAUDE-AGENTS-GUIDE.md,sha256=37Qj5DYcyUniLM1g8IU7UWFI_16tutZrcAkJc4E5i20,15876
|
|
294
290
|
moai_adk/templates/.moai/memory/CLAUDE-PRACTICES.md,sha256=Tf3q68X1DiA3MkIBYu7AMXoeparYrDRpyqVI5Nw92OY,12653
|
|
295
291
|
moai_adk/templates/.moai/memory/CLAUDE-RULES.md,sha256=S9GODGRzwwleOmROVtBDa471Ok5NyQLWIkaO_4peHhU,19783
|
|
296
292
|
moai_adk/templates/.moai/memory/DEVELOPMENT-GUIDE.md,sha256=SAcue1J5-DEJpygDnTgp_ex-ok2E4lbcykBuBiC7tGs,14534
|
|
297
|
-
moai_adk/templates/.moai/memory/GITFLOW-PROTECTION-POLICY.md,sha256=tm2ZOmNMvomAhh4_AGTUNjmSsc-eKzo1SGshojx2QL0,6228
|
|
298
293
|
moai_adk/templates/.moai/memory/ISSUE-LABEL-MAPPING.md,sha256=bKzC2v1ZZWyng0eHSj9oFQ9w9xCbadPe9T9IYWub7wM,3824
|
|
299
294
|
moai_adk/templates/.moai/memory/SKILLS-DESCRIPTION-POLICY.md,sha256=uMEFi6uojnpO_MGGtwhakYQzVF2yzVV9ZzfQe5tB0Hk,7823
|
|
300
|
-
moai_adk/templates/.moai/memory/
|
|
301
|
-
moai_adk/templates/.moai/memory/gitflow-protection-policy.md,sha256=tm2ZOmNMvomAhh4_AGTUNjmSsc-eKzo1SGshojx2QL0,6228
|
|
295
|
+
moai_adk/templates/.moai/memory/gitflow-protection-policy.md,sha256=UABdUWcA_085dZaQk7gaW2-ze3DV-BX399kKtbF1kGI,10401
|
|
302
296
|
moai_adk/templates/.moai/memory/spec-metadata.md,sha256=Ha4ATMxyH2PgQdVbS1fYwVH0PnIkfqk4hfuB5ksMFFk,9702
|
|
303
297
|
moai_adk/templates/.moai/project/product.md,sha256=IrRSqhu0o5KNfn453DUWoUKzdoO3m6013iYCwaHYCxM,5166
|
|
304
298
|
moai_adk/templates/.moai/project/structure.md,sha256=YWZ4ggmfzveKx8SQGFQWXdDUh5mxOLkEyy5yVdR3Rn0,4791
|
|
305
299
|
moai_adk/templates/.moai/project/tech.md,sha256=REecMv8wOvutt-pQZ5nlGk5YdReTan7AHcKJ2Yes6RM,5758
|
|
306
|
-
moai_adk/templates/src/moai_adk/core/__init__.py,sha256=rbztODLKJooQ4ah3_Pjfk9wNM7qlMfXm5o7qotiNAK8,127
|
|
307
|
-
moai_adk/templates/src/moai_adk/core/tags/__init__.py,sha256=nmZKs4eblrOzPg8JOHNkoaRzhPcUDGmMwvnUcyMZwGY,1985
|
|
308
|
-
moai_adk/templates/src/moai_adk/core/tags/ci_validator.py,sha256=PScVKPROu12mnu02nFzi66i-1pdbbnoitGzheI1COV8,13679
|
|
309
|
-
moai_adk/templates/src/moai_adk/core/tags/cli.py,sha256=1VWRT1k62FS5Yyzllat-nyLR3jqvGdyDkj1uOwPfavA,7344
|
|
310
300
|
moai_adk/templates/src/moai_adk/core/tags/pre_commit_validator.py,sha256=Y1G8qtuRjCaHGjQ-Nxn8k2UGOcHRd3EfdZrSqCqHAY4,10230
|
|
311
301
|
moai_adk/templates/src/moai_adk/core/tags/reporter.py,sha256=fn9kc0FNNvaep5cXbA2RkYxbJsw7eq2PHbrZ_XFB1Wc,29301
|
|
312
|
-
moai_adk/templates/src/moai_adk/core/tags/validator.py,sha256=B3xUDubfyT5RlPM3GLYktfe1EQTEdxOrDhD230_etoA,31138
|
|
313
302
|
moai_adk/utils/__init__.py,sha256=VnVfQzzKHvKw4bNdEw5xdscnRQYFrnr-v_TOBr3naPs,225
|
|
314
303
|
moai_adk/utils/banner.py,sha256=znppKd5yo-tTqgyhgPVJjstrTrfcy_v3X1_RFQxP4Fk,1878
|
|
315
304
|
moai_adk/utils/logger.py,sha256=g-m07PGKjK2bKRIInfSn6m-024Bedai-pV_WjZKDeu8,5064
|
|
316
|
-
moai_adk-0.
|
|
317
|
-
moai_adk-0.
|
|
318
|
-
moai_adk-0.
|
|
319
|
-
moai_adk-0.
|
|
320
|
-
moai_adk-0.
|
|
305
|
+
moai_adk-0.10.1.dist-info/METADATA,sha256=k6LuNosCo-PVTVR2GzyUmmzuzaF5KPCD-EPHfqvKrzA,94329
|
|
306
|
+
moai_adk-0.10.1.dist-info/WHEEL,sha256=qtCwoSJWgHk21S1Kb4ihdzI2rlJ1ZKaIurTj_ngOhyQ,87
|
|
307
|
+
moai_adk-0.10.1.dist-info/entry_points.txt,sha256=P9no1794UipqH72LP-ltdyfVd_MeB1WKJY_6-JQgV3U,52
|
|
308
|
+
moai_adk-0.10.1.dist-info/licenses/LICENSE,sha256=M1M2b07fWcSWRM6_P3wbZKndZvyfHyYk_Wu9bS8F7o8,1069
|
|
309
|
+
moai_adk-0.10.1.dist-info/RECORD,,
|
|
@@ -1,343 +0,0 @@
|
|
|
1
|
-
# Alfred Hooks System
|
|
2
|
-
|
|
3
|
-
**Event-Driven Context Management for MoAI-ADK**
|
|
4
|
-
|
|
5
|
-
Alfred Hooks integrates with Claude Code's event system to automatically manage project context, create checkpoints before risky operations, and provide just-in-time (JIT) document loading.
|
|
6
|
-
|
|
7
|
-
---
|
|
8
|
-
|
|
9
|
-
## 📐 Architecture
|
|
10
|
-
|
|
11
|
-
### Individual Hook Files (Event + Function Naming)
|
|
12
|
-
|
|
13
|
-
```
|
|
14
|
-
.claude/hooks/alfred/
|
|
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
|
|
36
|
-
```
|
|
37
|
-
|
|
38
|
-
### Design Principles
|
|
39
|
-
|
|
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
|
|
45
|
-
|
|
46
|
-
---
|
|
47
|
-
|
|
48
|
-
## 🎯 Hook Files
|
|
49
|
-
|
|
50
|
-
### `session_start__show_project_info.py`
|
|
51
|
-
|
|
52
|
-
**Event**: SessionStart
|
|
53
|
-
**Purpose**: Display project information when session begins
|
|
54
|
-
|
|
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..."}
|
|
65
|
-
```
|
|
66
|
-
|
|
67
|
-
---
|
|
68
|
-
|
|
69
|
-
### `user_prompt__jit_load_docs.py`
|
|
70
|
-
|
|
71
|
-
**Event**: UserPromptSubmit
|
|
72
|
-
**Purpose**: Analyze prompt and recommend relevant documents
|
|
73
|
-
|
|
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
|
-
}
|
|
89
|
-
```
|
|
90
|
-
|
|
91
|
-
---
|
|
92
|
-
|
|
93
|
-
### `pre_tool__auto_checkpoint.py`
|
|
94
|
-
|
|
95
|
-
**Event**: PreToolUse
|
|
96
|
-
**Matcher**: `Edit|Write|MultiEdit`
|
|
97
|
-
**Purpose**: Automatically create Git checkpoints before risky operations
|
|
98
|
-
|
|
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
|
|
103
|
-
|
|
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
|
|
109
|
-
|
|
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
|
-
```
|
|
115
|
-
|
|
116
|
-
---
|
|
117
|
-
|
|
118
|
-
### Stub Hooks (Future Enhancement)
|
|
119
|
-
|
|
120
|
-
**`post_tool__log_changes.py`**
|
|
121
|
-
- Change tracking and audit logging
|
|
122
|
-
- Metrics collection (files modified, lines changed)
|
|
123
|
-
|
|
124
|
-
**`session_end__cleanup.py`**
|
|
125
|
-
- Clear temporary caches
|
|
126
|
-
- Save session metrics
|
|
127
|
-
|
|
128
|
-
**`notification__handle_events.py`**
|
|
129
|
-
- Filter and categorize notifications
|
|
130
|
-
- Send alerts to external systems
|
|
131
|
-
|
|
132
|
-
**`stop__handle_interrupt.py`**
|
|
133
|
-
- Save partial work before interruption
|
|
134
|
-
- Create recovery checkpoint
|
|
135
|
-
|
|
136
|
-
**`subagent_stop__handle_subagent_end.py`**
|
|
137
|
-
- Collect sub-agent execution metrics
|
|
138
|
-
- Log results and errors
|
|
139
|
-
|
|
140
|
-
---
|
|
141
|
-
|
|
142
|
-
## 🏗️ Shared Modules
|
|
143
|
-
|
|
144
|
-
### `shared/core/` - Business Logic
|
|
145
|
-
|
|
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
|
-
```
|
|
157
|
-
|
|
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
|
-
```
|
|
163
|
-
|
|
164
|
-
### `shared/handlers/` - Event Processing
|
|
165
|
-
|
|
166
|
-
**`session.py`** - SessionStart, SessionEnd
|
|
167
|
-
**`user.py`** - UserPromptSubmit
|
|
168
|
-
**`tool.py`** - PreToolUse, PostToolUse
|
|
169
|
-
**`notification.py`** - Notification, Stop, SubagentStop
|
|
170
|
-
|
|
171
|
-
---
|
|
172
|
-
|
|
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
|
-
```
|
|
202
|
-
|
|
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
|
|
207
|
-
|
|
208
|
-
---
|
|
209
|
-
|
|
210
|
-
## 🧪 Testing
|
|
211
|
-
|
|
212
|
-
### Test Individual Hooks
|
|
213
|
-
|
|
214
|
-
```bash
|
|
215
|
-
# Test SessionStart hook
|
|
216
|
-
echo '{"cwd": "."}' | uv run session_start__show_project_info.py
|
|
217
|
-
|
|
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
|
|
223
|
-
```
|
|
224
|
-
|
|
225
|
-
### Expected Output
|
|
226
|
-
|
|
227
|
-
All hooks should return valid JSON with:
|
|
228
|
-
- `"continue": true` (required field)
|
|
229
|
-
- `"systemMessage"` or `"hookSpecificOutput"` (depending on hook type)
|
|
230
|
-
|
|
231
|
-
---
|
|
232
|
-
|
|
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
|
|
252
|
-
```
|
|
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
|
-
|
|
261
|
-
---
|
|
262
|
-
|
|
263
|
-
## 🏗️ Architecture Decisions
|
|
264
|
-
|
|
265
|
-
### Why Individual Hook Files? (UX Priority)
|
|
266
|
-
|
|
267
|
-
**Before** (Single Router):
|
|
268
|
-
```
|
|
269
|
-
alfred_hooks.py SessionStart ❌ Unclear what "SessionStart" does
|
|
270
|
-
```
|
|
271
|
-
|
|
272
|
-
**After** (Individual Files):
|
|
273
|
-
```
|
|
274
|
-
session_start__show_project_info.py ✅ Immediately clear purpose
|
|
275
|
-
```
|
|
276
|
-
|
|
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
|
|
283
|
-
|
|
284
|
-
**Tradeoffs**:
|
|
285
|
-
- ⚠️ **More Files**: 8 hook files instead of 1 router
|
|
286
|
-
- ⚠️ **Shared Logic**: Still needs `shared/` directory for DRY principle
|
|
287
|
-
|
|
288
|
-
**Decision**: **UX > Technical Elegance** - Users benefit from clarity
|
|
289
|
-
|
|
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
|
-
```
|
|
309
|
-
|
|
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
|
-
---
|
|
319
|
-
|
|
320
|
-
## 📈 Version History
|
|
321
|
-
|
|
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
|
|
328
|
-
|
|
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
|
|
333
|
-
|
|
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)
|
|
338
|
-
|
|
339
|
-
---
|
|
340
|
-
|
|
341
|
-
**Last Updated**: 2025-10-29
|
|
342
|
-
**Version**: 0.9.0
|
|
343
|
-
**Author**: @Alfred (MoAI-ADK SuperAgent)
|