moai-adk 0.4.0__py3-none-any.whl โ†’ 0.4.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.

Files changed (125) hide show
  1. moai_adk/__init__.py +1 -8
  2. moai_adk/cli/commands/init.py +10 -5
  3. moai_adk/cli/commands/update.py +274 -118
  4. moai_adk/cli/prompts/init_prompts.py +14 -18
  5. moai_adk/core/diagnostics/slash_commands.py +1 -1
  6. moai_adk/core/project/backup_utils.py +1 -0
  7. moai_adk/core/project/phase_executor.py +3 -1
  8. moai_adk/core/project/validator.py +3 -2
  9. moai_adk/core/template/backup.py +11 -3
  10. moai_adk/core/template/merger.py +16 -3
  11. moai_adk/core/template/processor.py +22 -3
  12. moai_adk/templates/.claude/agents/alfred/cc-manager.md +443 -424
  13. moai_adk/templates/.claude/agents/alfred/debug-helper.md +116 -103
  14. moai_adk/templates/.claude/agents/alfred/doc-syncer.md +130 -116
  15. moai_adk/templates/.claude/agents/alfred/git-manager.md +186 -174
  16. moai_adk/templates/.claude/agents/alfred/implementation-planner.md +227 -213
  17. moai_adk/templates/.claude/agents/alfred/project-manager.md +205 -125
  18. moai_adk/templates/.claude/agents/alfred/quality-gate.md +224 -209
  19. moai_adk/templates/.claude/agents/alfred/spec-builder.md +174 -160
  20. moai_adk/templates/.claude/agents/alfred/tag-agent.md +151 -139
  21. moai_adk/templates/.claude/agents/alfred/tdd-implementer.md +209 -196
  22. moai_adk/templates/.claude/agents/alfred/trust-checker.md +247 -233
  23. moai_adk/templates/.claude/commands/alfred/0-project.md +673 -640
  24. moai_adk/templates/.claude/commands/alfred/1-plan.md +342 -333
  25. moai_adk/templates/.claude/commands/alfred/2-run.md +295 -285
  26. moai_adk/templates/.claude/commands/alfred/3-sync.md +366 -356
  27. moai_adk/templates/.claude/hooks/alfred/README.md +52 -52
  28. moai_adk/templates/.claude/hooks/alfred/alfred_hooks.py +44 -48
  29. moai_adk/templates/.claude/hooks/alfred/core/__init__.py +17 -17
  30. moai_adk/templates/.claude/hooks/alfred/core/checkpoint.py +59 -59
  31. moai_adk/templates/.claude/hooks/alfred/core/context.py +19 -19
  32. moai_adk/templates/.claude/hooks/alfred/core/project.py +52 -52
  33. moai_adk/templates/.claude/hooks/alfred/handlers/__init__.py +1 -1
  34. moai_adk/templates/.claude/hooks/alfred/handlers/notification.py +4 -4
  35. moai_adk/templates/.claude/hooks/alfred/handlers/session.py +27 -27
  36. moai_adk/templates/.claude/hooks/alfred/handlers/tool.py +16 -17
  37. moai_adk/templates/.claude/hooks/alfred/handlers/user.py +11 -11
  38. moai_adk/templates/.claude/output-styles/alfred/agentic-coding.md +308 -307
  39. moai_adk/templates/.claude/output-styles/alfred/moai-adk-learning.md +297 -296
  40. moai_adk/templates/.claude/output-styles/alfred/study-with-alfred.md +191 -190
  41. moai_adk/templates/.claude/skills/moai-alfred-code-reviewer/SKILL.md +112 -0
  42. moai_adk/templates/.claude/skills/moai-alfred-debugger-pro/SKILL.md +103 -0
  43. moai_adk/templates/.claude/skills/moai-alfred-ears-authoring/SKILL.md +103 -0
  44. moai_adk/templates/.claude/skills/moai-alfred-git-workflow/SKILL.md +95 -0
  45. moai_adk/templates/.claude/skills/moai-alfred-language-detection/SKILL.md +99 -0
  46. moai_adk/templates/.claude/skills/moai-alfred-performance-optimizer/SKILL.md +105 -0
  47. moai_adk/templates/.claude/skills/moai-alfred-refactoring-coach/SKILL.md +97 -0
  48. moai_adk/templates/.claude/skills/moai-alfred-spec-metadata-validation/SKILL.md +97 -0
  49. moai_adk/templates/.claude/skills/moai-alfred-tag-scanning/SKILL.md +90 -0
  50. moai_adk/templates/.claude/skills/moai-alfred-trust-validation/SKILL.md +99 -0
  51. moai_adk/templates/.claude/skills/moai-alfred-tui-survey/SKILL.md +87 -0
  52. moai_adk/templates/.claude/skills/moai-alfred-tui-survey/examples.md +62 -0
  53. moai_adk/templates/.claude/skills/moai-claude-code/SKILL.md +70 -43
  54. moai_adk/templates/.claude/skills/moai-claude-code/examples.md +141 -141
  55. moai_adk/templates/.claude/skills/moai-claude-code/reference.md +179 -165
  56. moai_adk/templates/.claude/skills/moai-claude-code/templates/agent-full.md +78 -78
  57. moai_adk/templates/.claude/skills/moai-claude-code/templates/command-full.md +90 -90
  58. moai_adk/templates/.claude/skills/moai-claude-code/templates/plugin-full.json +39 -25
  59. moai_adk/templates/.claude/skills/moai-claude-code/templates/settings-full.json +117 -74
  60. moai_adk/templates/.claude/skills/moai-claude-code/templates/skill-full.md +131 -134
  61. moai_adk/templates/.claude/skills/moai-domain-backend/SKILL.md +43 -12
  62. moai_adk/templates/.claude/skills/moai-domain-cli-tool/SKILL.md +43 -12
  63. moai_adk/templates/.claude/skills/moai-domain-data-science/SKILL.md +43 -12
  64. moai_adk/templates/.claude/skills/moai-domain-database/SKILL.md +43 -12
  65. moai_adk/templates/.claude/skills/moai-domain-devops/SKILL.md +43 -12
  66. moai_adk/templates/.claude/skills/moai-domain-frontend/SKILL.md +43 -12
  67. moai_adk/templates/.claude/skills/moai-domain-ml/SKILL.md +43 -11
  68. moai_adk/templates/.claude/skills/moai-domain-mobile-app/SKILL.md +43 -12
  69. moai_adk/templates/.claude/skills/moai-domain-security/SKILL.md +43 -12
  70. moai_adk/templates/.claude/skills/moai-domain-web-api/SKILL.md +43 -12
  71. moai_adk/templates/.claude/skills/moai-essentials-debug/SKILL.md +47 -11
  72. moai_adk/templates/.claude/skills/moai-essentials-perf/SKILL.md +47 -11
  73. moai_adk/templates/.claude/skills/moai-essentials-refactor/SKILL.md +51 -14
  74. moai_adk/templates/.claude/skills/moai-essentials-review/SKILL.md +46 -10
  75. moai_adk/templates/.claude/skills/moai-foundation-ears/SKILL.md +62 -25
  76. moai_adk/templates/.claude/skills/moai-foundation-git/SKILL.md +44 -17
  77. moai_adk/templates/.claude/skills/moai-foundation-langs/SKILL.md +44 -14
  78. moai_adk/templates/.claude/skills/moai-foundation-specs/SKILL.md +45 -13
  79. moai_adk/templates/.claude/skills/moai-foundation-tags/SKILL.md +46 -14
  80. moai_adk/templates/.claude/skills/moai-foundation-trust/SKILL.md +48 -8
  81. moai_adk/templates/.claude/skills/moai-lang-c/SKILL.md +44 -12
  82. moai_adk/templates/.claude/skills/moai-lang-clojure/SKILL.md +44 -12
  83. moai_adk/templates/.claude/skills/moai-lang-cpp/SKILL.md +44 -11
  84. moai_adk/templates/.claude/skills/moai-lang-csharp/SKILL.md +44 -11
  85. moai_adk/templates/.claude/skills/moai-lang-dart/SKILL.md +44 -12
  86. moai_adk/templates/.claude/skills/moai-lang-elixir/SKILL.md +44 -11
  87. moai_adk/templates/.claude/skills/moai-lang-go/SKILL.md +44 -11
  88. moai_adk/templates/.claude/skills/moai-lang-haskell/SKILL.md +44 -11
  89. moai_adk/templates/.claude/skills/moai-lang-java/SKILL.md +44 -12
  90. moai_adk/templates/.claude/skills/moai-lang-javascript/SKILL.md +44 -12
  91. moai_adk/templates/.claude/skills/moai-lang-julia/SKILL.md +44 -12
  92. moai_adk/templates/.claude/skills/moai-lang-kotlin/SKILL.md +44 -12
  93. moai_adk/templates/.claude/skills/moai-lang-lua/SKILL.md +44 -11
  94. moai_adk/templates/.claude/skills/moai-lang-php/SKILL.md +44 -11
  95. moai_adk/templates/.claude/skills/moai-lang-python/SKILL.md +44 -12
  96. moai_adk/templates/.claude/skills/moai-lang-r/SKILL.md +44 -11
  97. moai_adk/templates/.claude/skills/moai-lang-ruby/SKILL.md +44 -11
  98. moai_adk/templates/.claude/skills/moai-lang-rust/SKILL.md +44 -12
  99. moai_adk/templates/.claude/skills/moai-lang-scala/SKILL.md +44 -12
  100. moai_adk/templates/.claude/skills/moai-lang-shell/SKILL.md +44 -11
  101. moai_adk/templates/.claude/skills/moai-lang-sql/SKILL.md +44 -12
  102. moai_adk/templates/.claude/skills/moai-lang-swift/SKILL.md +44 -12
  103. moai_adk/templates/.claude/skills/moai-lang-typescript/SKILL.md +44 -12
  104. moai_adk/templates/.github/PULL_REQUEST_TEMPLATE.md +44 -43
  105. moai_adk/templates/.github/workflows/moai-gitflow.yml +36 -35
  106. moai_adk/templates/.moai/config.json +9 -6
  107. moai_adk/templates/.moai/memory/development-guide.md +220 -221
  108. moai_adk/templates/.moai/memory/gitflow-protection-policy.md +85 -85
  109. moai_adk/templates/.moai/memory/spec-metadata.md +149 -150
  110. moai_adk/templates/.moai/project/product.md +90 -90
  111. moai_adk/templates/.moai/project/structure.md +85 -85
  112. moai_adk/templates/.moai/project/tech.md +117 -117
  113. moai_adk/templates/CLAUDE.md +350 -722
  114. moai_adk-0.4.1.dist-info/METADATA +303 -0
  115. moai_adk-0.4.1.dist-info/RECORD +152 -0
  116. moai_adk/templates/.claude/commands/alfred/1-spec.md +0 -31
  117. moai_adk/templates/.claude/commands/alfred/2-build.md +0 -30
  118. moai_adk/templates/.claude/skills/scripts/standardize_skills.py +0 -166
  119. moai_adk/templates/.claude/skills/scripts/verify_standardization.sh +0 -43
  120. moai_adk/templates/.moai/hooks/pre-push.sample +0 -88
  121. moai_adk-0.4.0.dist-info/METADATA +0 -1816
  122. moai_adk-0.4.0.dist-info/RECORD +0 -145
  123. {moai_adk-0.4.0.dist-info โ†’ moai_adk-0.4.1.dist-info}/WHEEL +0 -0
  124. {moai_adk-0.4.0.dist-info โ†’ moai_adk-0.4.1.dist-info}/entry_points.txt +0 -0
  125. {moai_adk-0.4.0.dist-info โ†’ moai_adk-0.4.1.dist-info}/licenses/LICENSE +0 -0
@@ -2,7 +2,7 @@
2
2
 
3
3
  **Event-Driven Context Management for MoAI-ADK**
4
4
 
5
- Alfred Hooks๋Š” Claude Code์˜ ์ด๋ฒคํŠธ ์‹œ์Šคํ…œ๊ณผ ํ†ตํ•ฉ๋˜์–ด ํ”„๋กœ์ ํŠธ ์ปจํ…์ŠคํŠธ๋ฅผ ์ž๋™์œผ๋กœ ๊ด€๋ฆฌํ•˜๊ณ , ์œ„ํ—˜ํ•œ ์ž‘์—… ์ „์— checkpoint๋ฅผ ์ƒ์„ฑํ•˜๋ฉฐ, JIT (Just-in-Time) ๋ฌธ์„œ ๋กœ๋”ฉ์„ ์ œ๊ณตํ•ฉ๋‹ˆ๋‹ค.
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
6
 
7
7
  ---
8
8
 
@@ -29,10 +29,10 @@ Alfred Hooks๋Š” Claude Code์˜ ์ด๋ฒคํŠธ ์‹œ์Šคํ…œ๊ณผ ํ†ตํ•ฉ๋˜์–ด ํ”„๋กœ์ ํŠธ
29
29
 
30
30
  ### Design Principles
31
31
 
32
- - **Single Responsibility**: ๊ฐ ๋ชจ๋“ˆ์€ ํ•˜๋‚˜์˜ ๋ช…ํ™•ํ•œ ์ฑ…์ž„
33
- - **Separation of Concerns**: core (๋น„์ฆˆ๋‹ˆ์Šค ๋กœ์ง) vs handlers (์ด๋ฒคํŠธ ์ฒ˜๋ฆฌ)
34
- - **CODE-FIRST**: ์ค‘๊ฐ„ ์บ์‹œ ์—†์ด ์ฝ”๋“œ ์ง์ ‘ ์Šค์บ” (mtime ๊ธฐ๋ฐ˜ ๋ฌดํšจํ™”)
35
- - **Context Engineering**: JIT Retrieval๋กœ ์ดˆ๊ธฐ ์ปจํ…์ŠคํŠธ ๋ถ€๋‹ด ์ตœ์†Œํ™”
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
36
36
 
37
37
  ---
38
38
 
@@ -40,7 +40,7 @@ Alfred Hooks๋Š” Claude Code์˜ ์ด๋ฒคํŠธ ์‹œ์Šคํ…œ๊ณผ ํ†ตํ•ฉ๋˜์–ด ํ”„๋กœ์ ํŠธ
40
40
 
41
41
  ### `core/project.py` (284 LOC)
42
42
 
43
- **ํ”„๋กœ์ ํŠธ ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ๋ฐ ์–ธ์–ด ๊ฐ์ง€**
43
+ **Project metadata and language detection**
44
44
 
45
45
  ```python
46
46
  # Public API
@@ -51,14 +51,14 @@ count_specs(cwd: str) -> dict[str, int]
51
51
  ```
52
52
 
53
53
  **Features**:
54
- - 20๊ฐœ ์–ธ์–ด ์ž๋™ ๊ฐ์ง€ (Python, TypeScript, Java, Go, Rust, etc.)
55
- - `.moai/config.json` ์šฐ์„ , fallback to auto-detection
56
- - Git ์ •๋ณด ์กฐํšŒ (branch, commit, changes)
57
- - SPEC ์ง„ํ–‰๋„ ๊ณ„์‚ฐ (total, completed, percentage)
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)
58
58
 
59
59
  ### `core/context.py` (110 LOC)
60
60
 
61
- **JIT Context Retrieval ๋ฐ ์›Œํฌํ”Œ๋กœ์šฐ ๊ด€๋ฆฌ**
61
+ **JIT Context Retrieval and Workflow Management**
62
62
 
63
63
  ```python
64
64
  # Public API
@@ -69,15 +69,15 @@ clear_workflow_context()
69
69
  ```
70
70
 
71
71
  **Features**:
72
- - ํ”„๋กฌํ”„ํŠธ ๋ถ„์„ ๊ธฐ๋ฐ˜ ๋ฌธ์„œ ์ž๋™ ์ถ”์ฒœ
73
- - `/alfred:1-spec` โ†’ `spec-metadata.md`
74
- - `/alfred:2-build` โ†’ `development-guide.md`
75
- - ์›Œํฌํ”Œ๋กœ์šฐ ๋‹จ๊ณ„๋ณ„ ์ปจํ…์ŠคํŠธ ์บ์‹ฑ (TTL 10๋ถ„)
76
- - Anthropic Context Engineering ์›์น™ ์ค€์ˆ˜
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
77
77
 
78
78
  ### `core/checkpoint.py` (244 LOC)
79
79
 
80
- **Event-Driven Checkpoint ์ž๋™ํ™”**
80
+ **Event-Driven Checkpoint Automation**
81
81
 
82
82
  ```python
83
83
  # Public API
@@ -88,16 +88,16 @@ list_checkpoints(cwd: str, max_count: int = 10) -> list[dict]
88
88
  ```
89
89
 
90
90
  **Features**:
91
- - ์œ„ํ—˜ํ•œ ์ž‘์—… ์ž๋™ ๊ฐ์ง€:
91
+ - Automatic detection of dangerous tasks:
92
92
  - Bash: `rm -rf`, `git merge`, `git reset --hard`
93
93
  - Edit/Write: `CLAUDE.md`, `config.json`
94
94
  - MultiEdit: โ‰ฅ10 files
95
- - Git checkpoint ์ž๋™ ์ƒ์„ฑ: `checkpoint/before-{operation}-{timestamp}`
96
- - checkpoint ์ด๋ ฅ ๊ด€๋ฆฌ ๋ฐ ๋ณต๊ตฌ ๊ฐ€์ด๋“œ
95
+ - Automatic creation of Git checkpoint: `checkpoint/before-{operation}-{timestamp}`
96
+ - Checkpoint history management and recovery guide
97
97
 
98
98
  ### `core/tags.py` (244 LOC)
99
99
 
100
- **CODE-FIRST TAG ์‹œ์Šคํ…œ**
100
+ **CODE-FIRST TAG SYSTEM**
101
101
 
102
102
  ```python
103
103
  # Public API
@@ -110,10 +110,10 @@ set_library_version(library: str, version: str)
110
110
  ```
111
111
 
112
112
  **Features**:
113
- - ripgrep ๊ธฐ๋ฐ˜ TAG ๊ฒ€์ƒ‰ (JSON ์ถœ๋ ฅ ํŒŒ์‹ฑ)
114
- - mtime ๊ธฐ๋ฐ˜ ์บ์‹œ ๋ฌดํšจํ™” (CODE-FIRST ๋ณด์žฅ)
115
- - TAG ์ฒด์ธ ๊ฒ€์ฆ (@SPEC โ†’ @TEST โ†’ @CODE ์™„์ „์„ฑ ํ™•์ธ)
116
- - ๋ผ์ด๋ธŒ๋Ÿฌ๋ฆฌ ๋ฒ„์ „ ์บ์‹ฑ (TTL 24์‹œ๊ฐ„)
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)
117
117
 
118
118
  ---
119
119
 
@@ -121,32 +121,32 @@ set_library_version(library: str, version: str)
121
121
 
122
122
  ### `handlers/session.py`
123
123
 
124
- **SessionStart, SessionEnd ํ•ธ๋“ค๋Ÿฌ**
124
+ **SessionStart, SessionEnd handlers**
125
125
 
126
- - **SessionStart**: ํ”„๋กœ์ ํŠธ ์ •๋ณด ํ‘œ์‹œ
127
- - ์–ธ์–ด, Git ์ƒํƒœ, SPEC ์ง„ํ–‰๋„, ์ตœ๊ทผ checkpoint
128
- - `systemMessage` ํ•„๋“œ๋กœ ์‚ฌ์šฉ์ž์—๊ฒŒ ์ง์ ‘ ํ‘œ์‹œ
129
- - **SessionEnd**: ์ •๋ฆฌ ์ž‘์—… (stub)
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)
130
130
 
131
131
  ### `handlers/user.py`
132
132
 
133
- **UserPromptSubmit ํ•ธ๋“ค๋Ÿฌ**
133
+ **UserPromptSubmit Handler**
134
134
 
135
- - JIT Context ์ถ”์ฒœ ๋ฌธ์„œ ๋ฆฌ์ŠคํŠธ ๋ฐ˜ํ™˜
136
- - ์‚ฌ์šฉ์ž ํ”„๋กฌํ”„ํŠธ ํŒจํ„ด ๋ถ„์„ ๋ฐ ๊ด€๋ จ ๋ฌธ์„œ ๋กœ๋“œ
135
+ - Return list of JIT Context recommended documents
136
+ - Analyze user prompt patterns and load related documents
137
137
 
138
138
  ### `handlers/tool.py`
139
139
 
140
- **PreToolUse, PostToolUse ํ•ธ๋“ค๋Ÿฌ**
140
+ **PreToolUse, PostToolUse handlers**
141
141
 
142
- - **PreToolUse**: ์œ„ํ—˜ํ•œ ์ž‘์—… ๊ฐ์ง€ ์‹œ ์ž๋™ checkpoint ์ƒ์„ฑ
143
- - **PostToolUse**: ํ›„์ฒ˜๋ฆฌ ์ž‘์—… (stub)
142
+ - **PreToolUse**: Automatic checkpoint creation when dangerous operation is detected
143
+ - **PostToolUse**: Post-processing operation (stub)
144
144
 
145
145
  ### `handlers/notification.py`
146
146
 
147
- **Notification, Stop, SubagentStop ํ•ธ๋“ค๋Ÿฌ**
147
+ **Notification, Stop, SubagentStop handlers**
148
148
 
149
- - ๊ธฐ๋ณธ ๊ตฌํ˜„ (stub, ํ–ฅํ›„ ํ™•์žฅ ๊ฐ€๋Šฅ)
149
+ - Basic implementation (stub, can be expanded in the future)
150
150
 
151
151
  ---
152
152
 
@@ -166,9 +166,9 @@ uv run pytest tests/unit/test_alfred_hooks_core_project.py -v
166
166
 
167
167
  ### Test Coverage (18 tests)
168
168
 
169
- - โœ… **tags.py**: 7 tests (์บ์‹œ, TAG ๊ฒ€์ฆ, ๋ฒ„์ „ ๊ด€๋ฆฌ)
170
- - โœ… **context.py**: 5 tests (JIT, ์›Œํฌํ”Œ๋กœ์šฐ ์ปจํ…์ŠคํŠธ)
171
- - โœ… **project.py**: 6 tests (์–ธ์–ด ๊ฐ์ง€, Git, SPEC ์นด์šดํŠธ)
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)
172
172
 
173
173
  ### Test Structure
174
174
 
@@ -192,22 +192,22 @@ def _load_{module}_module(module_name: str):
192
192
 
193
193
  - **1 file**: 1233 LOC
194
194
  - **Issues**:
195
- - ๋ชจ๋“  ๊ธฐ๋Šฅ์ด ํ•˜๋‚˜์˜ ํŒŒ์ผ์— ์ง‘์ค‘
196
- - ํ…Œ์ŠคํŠธ ์–ด๋ ค์›€, ์œ ์ง€๋ณด์ˆ˜ ๋ณต์žก
197
- - ์ฑ…์ž„ ๋ถ„๋ฆฌ ๋ถˆ๋ช…ํ™•
195
+ - All functions concentrated in one file
196
+ - Difficult to test, complex to maintain
197
+ - Unclear separation of responsibilities
198
198
 
199
199
  ### After (Modular)
200
200
 
201
201
  - **9 files**: โ‰ค284 LOC each
202
202
  - **Benefits**:
203
- - ๋ช…ํ™•ํ•œ ์ฑ…์ž„ ๋ถ„๋ฆฌ (SRP)
204
- - ๋…๋ฆฝ์ ์ธ ๋ชจ๋“ˆ ํ…Œ์ŠคํŠธ ๊ฐ€๋Šฅ
205
- - ํ™•์žฅ ์šฉ์ด, ์œ ์ง€๋ณด์ˆ˜ ๊ฐ„ํŽธ
206
- - Context Engineering ์›์น™ ์ค€์ˆ˜
203
+ - Clear separation of responsibilities (SRP)
204
+ - Independent module testing possible
205
+ - Easy to expand, easy to maintain
206
+ - Compliance with Context Engineering principles
207
207
 
208
208
  ### Breaking Changes
209
209
 
210
- **์—†์Œ** - ์™ธ๋ถ€ API๋Š” ๋™์ผํ•˜๊ฒŒ ์œ ์ง€๋ฉ๋‹ˆ๋‹ค.
210
+ **None** - External APIs remain the same.
211
211
 
212
212
  ---
213
213
 
@@ -215,9 +215,9 @@ def _load_{module}_module(module_name: str):
215
215
 
216
216
  ### Internal Documents
217
217
 
218
- - **CLAUDE.md**: MoAI-ADK ์‚ฌ์šฉ์ž ๊ฐ€์ด๋“œ
219
- - **.moai/memory/development-guide.md**: SPEC-First TDD ์›Œํฌํ”Œ๋กœ์šฐ
220
- - **.moai/memory/spec-metadata.md**: SPEC ๋ฉ”ํƒ€๋ฐ์ดํ„ฐ ํ‘œ์ค€
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
221
221
 
222
222
  ### External Resources
223
223
 
@@ -2,22 +2,9 @@
2
2
  # @CODE:HOOKS-REFACTOR-001 | SPEC: SPEC-HOOKS-REFACTOR-001.md
3
3
  """Alfred Hooks - Main entry point for MoAI-ADK Claude Code Hooks
4
4
 
5
- Claude Code ์ด๋ฒคํŠธ๋ฅผ ์ ์ ˆํ•œ ํ•ธ๋“ค๋Ÿฌ๋กœ ๋ผ์šฐํŒ…ํ•˜๋Š” ๋ฉ”์ธ ์ง„์ž…์ 
5
+ A main entry point that routes Claude Code events to the appropriate handlers.
6
6
 
7
- Setup sys.path for package imports
8
- """
9
- import sys
10
- from pathlib import Path
11
-
12
- # Add the hooks directory to sys.path to enable package imports
13
- HOOKS_DIR = Path(__file__).parent
14
- if str(HOOKS_DIR) not in sys.path:
15
- sys.path.insert(0, str(HOOKS_DIR))
16
-
17
- # Now we can import from the package
18
-
19
- """
20
- Architecture:
7
+ ๐Ÿ—๏ธ Architecture:
21
8
  โ”Œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”
22
9
  โ”‚ alfred_hooks.py (Router) โ”‚
23
10
  โ”œโ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”ค
@@ -44,26 +31,30 @@ Architecture:
44
31
  โ”‚ - tags.py: TAG search/verification, library version cache โ”‚
45
32
  โ””โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”€โ”˜
46
33
 
47
- Usage:
34
+ ๐Ÿ› ๏ธ Usage:
48
35
  python alfred_hooks.py <event_name> < payload.json
49
36
 
50
- Supported Events:
51
- - SessionStart: ์„ธ์…˜ ์‹œ์ž‘ (ํ”„๋กœ์ ํŠธ ์ƒํƒœ ํ‘œ์‹œ)
52
- - UserPromptSubmit: ํ”„๋กฌํ”„ํŠธ ์ œ์ถœ (JIT ๋ฌธ์„œ ๋กœ๋”ฉ)
53
- - PreToolUse: Tool ์‚ฌ์šฉ ์ „ (Checkpoint ์ž๋™ ์ƒ์„ฑ)
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)
54
41
  - SessionEnd, PostToolUse, Notification, Stop, SubagentStop
55
42
 
56
- Exit Codes:
57
- - 0: ์„ฑ๊ณต
58
- - 1: ์—๋Ÿฌ (์ธ์ˆ˜ ์—†์Œ, JSON ํŒŒ์‹ฑ ์‹คํŒจ, ์˜ˆ์™ธ ๋ฐœ์ƒ)
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
59
51
 
60
- TDD History:
61
- - RED: ๋ชจ๋“ˆ ๋ถ„๋ฆฌ ์„ค๊ณ„, ์ด๋ฒคํŠธ ๋ผ์šฐํŒ… ํ…Œ์ŠคํŠธ
62
- - GREEN: 1233 LOC โ†’ 9๊ฐœ ๋ชจ๋“ˆ ๋ถ„๋ฆฌ ๊ตฌํ˜„ (SRP ์ค€์ˆ˜)
63
- - REFACTOR: Import ์ตœ์ ํ™”, ์—๋Ÿฌ ์ฒ˜๋ฆฌ ๊ฐ•ํ™”
52
+ Setup sys.path for package imports
64
53
  """
65
54
 
66
55
  import json
56
+ import sys
57
+ from pathlib import Path
67
58
 
68
59
  from core import HookResult
69
60
  from handlers import (
@@ -77,39 +68,44 @@ from handlers import (
77
68
  handle_user_prompt_submit,
78
69
  )
79
70
 
71
+ # Add the hooks directory to sys.path to enable package imports
72
+ HOOKS_DIR = Path(__file__).parent
73
+ if str(HOOKS_DIR) not in sys.path:
74
+ sys.path.insert(0, str(HOOKS_DIR))
75
+
80
76
 
81
77
  def main() -> None:
82
- """๋ฉ”์ธ ์ง„์ž…์  - Claude Code Hook ์Šคํฌ๋ฆฝํŠธ
78
+ """Main entry point - Claude Code Hook script
83
79
 
84
- CLI ์ธ์ˆ˜๋กœ ์ด๋ฒคํŠธ๋ช…์„ ๋ฐ›๊ณ , stdin์œผ๋กœ JSON ํŽ˜์ด๋กœ๋“œ๋ฅผ ์ฝ์Šต๋‹ˆ๋‹ค.
85
- ์ด๋ฒคํŠธ์— ๋งž๋Š” ํ•ธ๋“ค๋Ÿฌ๋ฅผ ํ˜ธ์ถœํ•˜๊ณ , ๊ฒฐ๊ณผ๋ฅผ JSON์œผ๋กœ stdout์— ์ถœ๋ ฅํ•ฉ๋‹ˆ๋‹ค.
80
+ Receives the event name as a CLI argument and reads the JSON payload through stdin.
81
+ Calls the handler appropriate for the event and outputs the results to stdout as JSON.
86
82
 
87
- Usage:
83
+ ๐Ÿ› ๏ธ Usage:
88
84
  python alfred_hooks.py <event_name> < payload.json
89
85
 
90
- Supported Events:
91
- - SessionStart: ์„ธ์…˜ ์‹œ์ž‘ (ํ”„๋กœ์ ํŠธ ์ƒํƒœ ํ‘œ์‹œ)
92
- - UserPromptSubmit: ํ”„๋กฌํ”„ํŠธ ์ œ์ถœ (JIT ๋ฌธ์„œ ๋กœ๋”ฉ)
86
+ ๐Ÿ“ฃ Supported Events:
87
+ - SessionStart: Start Session (display project status)
88
+ - UserPromptSubmit: Prompt submission (JIT document loading)
93
89
  - SessionEnd, PreToolUse, PostToolUse, Notification, Stop, SubagentStop
94
90
 
95
- Exit Codes:
96
- - 0: ์„ฑ๊ณต
97
- - 1: ์—๋Ÿฌ (์ธ์ˆ˜ ์—†์Œ, JSON ํŒŒ์‹ฑ ์‹คํŒจ, ์˜ˆ์™ธ ๋ฐœ์ƒ)
91
+ ๐Ÿšฆ Exit Codes:
92
+ - 0: Success
93
+ - 1: Error (no arguments, JSON parsing failure, exception thrown)
98
94
 
99
- Examples:
95
+ ๐Ÿ“ Examples:
100
96
  $ echo '{"cwd": "."}' | python alfred_hooks.py SessionStart
101
97
  {"message": "๐Ÿš€ MoAI-ADK Session Started\\n...", ...}
102
98
 
103
- Notes:
104
- - Claude Code๊ฐ€ ์ž๋™์œผ๋กœ ํ˜ธ์ถœ (์‚ฌ์šฉ์ž ์ง์ ‘ ์‹คํ–‰ ๋ถˆํ•„์š”)
105
- - stdin/stdout์œผ๋กœ JSON I/O ์ฒ˜๋ฆฌ
106
- - stderr๋กœ ์—๋Ÿฌ ๋ฉ”์‹œ์ง€ ์ถœ๋ ฅ
107
- - UserPromptSubmit์€ ํŠน๋ณ„ํ•œ ์ถœ๋ ฅ ์Šคํ‚ค๋งˆ ์‚ฌ์šฉ (hookEventName + additionalContext)
99
+ ๐Ÿ—’๏ธ Notes:
100
+ - Claude Code is automatically called (no need for direct user execution)
101
+ - JSON I/O processing through stdin/stdout
102
+ - Print error message to stderr
103
+ - UserPromptSubmit uses a special output schema (hookEventName + additionalContext)
108
104
 
109
- TDD History:
110
- - RED: ์ด๋ฒคํŠธ ๋ผ์šฐํŒ…, JSON I/O, ์—๋Ÿฌ ์ฒ˜๋ฆฌ ํ…Œ์ŠคํŠธ
111
- - GREEN: ํ•ธ๋“ค๋Ÿฌ ๋งต ๊ธฐ๋ฐ˜ ๋ผ์šฐํŒ… ๊ตฌํ˜„
112
- - REFACTOR: ์—๋Ÿฌ ๋ฉ”์‹œ์ง€ ๋ช…ํ™•ํ™”, exit code ํ‘œ์ค€ํ™”, UserPromptSubmit ์Šคํ‚ค๋งˆ ๋ถ„๋ฆฌ
105
+ ๐Ÿงช TDD History:
106
+ - RED: Event routing, JSON I/O, error handling testing
107
+ - GREEN: Handler map-based routing implementation
108
+ - REFACTOR: Error message clarification, exit code standardization, UserPromptSubmit schema separation
113
109
  """
114
110
  # Check for event argument
115
111
  if len(sys.argv) < 2:
@@ -140,7 +136,7 @@ def main() -> None:
140
136
  handler = handlers.get(event_name)
141
137
  result = handler({"cwd": cwd, **data}) if handler else HookResult()
142
138
 
143
- # UserPromptSubmit์€ ํŠน๋ณ„ํ•œ ์ถœ๋ ฅ ์Šคํ‚ค๋งˆ ์‚ฌ์šฉ
139
+ # UserPromptSubmit uses a special output schema
144
140
  if event_name == "UserPromptSubmit":
145
141
  print(json.dumps(result.to_user_prompt_submit_dict()))
146
142
  else:
@@ -1,7 +1,7 @@
1
1
  #!/usr/bin/env python3
2
2
  """Core module for Alfred Hooks
3
3
 
4
- ๊ณตํ†ต ํƒ€์ž… ์ •์˜ ๋ฐ ์œ ํ‹ธ๋ฆฌํ‹ฐ ํ•จ์ˆ˜
4
+ Common type definitions and utility functions
5
5
  """
6
6
 
7
7
  from dataclasses import asdict, dataclass, field
@@ -9,64 +9,64 @@ from typing import Any, NotRequired, TypedDict
9
9
 
10
10
 
11
11
  class HookPayload(TypedDict):
12
- """Claude Code Hook ์ด๋ฒคํŠธ ํŽ˜์ด๋กœ๋“œ ํƒ€์ž… ์ •์˜
12
+ """Claude Code Hook event payload type definition
13
13
 
14
- Claude Code๊ฐ€ Hook ์Šคํฌ๋ฆฝํŠธ์— ์ „๋‹ฌํ•˜๋Š” ๋ฐ์ดํ„ฐ ๊ตฌ์กฐ.
15
- ์ด๋ฒคํŠธ์— ๋”ฐ๋ผ ํ•„๋“œ๊ฐ€ ๋‹ค๋ฅผ ์ˆ˜ ์žˆ์œผ๋ฏ€๋กœ NotRequired ์‚ฌ์šฉ.
14
+ Data structure that Claude Code passes to the Hook script.
15
+ Use NotRequired because fields may vary depending on the event.
16
16
  """
17
17
 
18
18
  cwd: str
19
- userPrompt: NotRequired[str] # UserPromptSubmit ์ด๋ฒคํŠธ๋งŒ ํฌํ•จ
20
- tool: NotRequired[str] # PreToolUse/PostToolUse ์ด๋ฒคํŠธ
19
+ userPrompt: NotRequired[str] # Includes only UserPromptSubmit events
20
+ tool: NotRequired[str] # PreToolUse/PostToolUse events
21
21
  arguments: NotRequired[dict[str, Any]] # Tool arguments
22
22
 
23
23
 
24
24
  @dataclass
25
25
  class HookResult:
26
- """Hook ์‹คํ–‰ ๊ฒฐ๊ณผ"""
26
+ """Hook execution result"""
27
27
 
28
28
  message: str | None = None
29
- systemMessage: str | None = None # ์‚ฌ์šฉ์ž์—๊ฒŒ ์ง์ ‘ ํ‘œ์‹œ๋˜๋Š” ๋ฉ”์‹œ์ง€
29
+ systemMessage: str | None = None # Message displayed directly to the user # noqa: N815
30
30
  blocked: bool = False
31
- contextFiles: list[str] = field(default_factory=list)
31
+ contextFiles: list[str] = field(default_factory=list) # noqa: N815
32
32
  suggestions: list[str] = field(default_factory=list)
33
- exitCode: int = 0
33
+ exitCode: int = 0 # noqa: N815
34
34
 
35
35
  def to_dict(self) -> dict[str, Any]:
36
- """์ผ๋ฐ˜ Hook์šฉ ๋”•์…”๋„ˆ๋ฆฌ ๋ณ€ํ™˜"""
36
+ """Dictionary conversion for general Hook"""
37
37
  return asdict(self)
38
38
 
39
39
  def to_user_prompt_submit_dict(self) -> dict[str, Any]:
40
- """UserPromptSubmit Hook ์ „์šฉ ์ถœ๋ ฅ ํ˜•์‹
40
+ """UserPromptSubmit Hook-specific output format
41
41
 
42
- Claude Code๋Š” UserPromptSubmit์— ๋Œ€ํ•ด ํŠน๋ณ„ํ•œ ์Šคํ‚ค๋งˆ๋ฅผ ์š”๊ตฌ:
42
+ Claude Code requires a special schema for UserPromptSubmit:
43
43
  {
44
44
  "hookEventName": "UserPromptSubmit",
45
45
  "additionalContext": "string (required)"
46
46
  }
47
47
 
48
48
  Returns:
49
- Claude Code UserPromptSubmit Hook ์Šคํ‚ค๋งˆ์— ๋งž๋Š” ๋”•์…”๋„ˆ๋ฆฌ
49
+ Claude Code UserPromptSubmit Hook Dictionary matching schema
50
50
 
51
51
  Examples:
52
52
  >>> result = HookResult(contextFiles=["tests/"])
53
53
  >>> result.to_user_prompt_submit_dict()
54
54
  {'hookEventName': 'UserPromptSubmit', 'additionalContext': '๐Ÿ“Ž Context: tests/'}
55
55
  """
56
- # contextFiles๋ฅผ additionalContext ๋ฌธ์ž์—ด๋กœ ๋ณ€ํ™˜
56
+ # Convert contextFiles to additionalContext string
57
57
  if self.contextFiles:
58
58
  context_str = "\n".join([f"๐Ÿ“Ž Context: {f}" for f in self.contextFiles])
59
59
  else:
60
60
  context_str = ""
61
61
 
62
- # message๊ฐ€ ์žˆ์œผ๋ฉด ์ถ”๊ฐ€
62
+ # Add message if there is one
63
63
  if self.message:
64
64
  if context_str:
65
65
  context_str = f"{self.message}\n\n{context_str}"
66
66
  else:
67
67
  context_str = self.message
68
68
 
69
- # ๋นˆ ๋ฌธ์ž์—ด์ด๋ฉด ๊ธฐ๋ณธ๊ฐ’ ์‚ฌ์šฉ
69
+ # If the string is empty, use default
70
70
  if not context_str:
71
71
  context_str = ""
72
72