moai-adk 0.10.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/.github/workflows/moai-gitflow.yml +6 -1
- moai_adk/templates/.github/workflows/release.yml +6 -2
- moai_adk/templates/.github/workflows/tag-validation.yml +53 -8
- moai_adk/templates/CLAUDE.md +458 -67
- {moai_adk-0.10.1.dist-info → moai_adk-0.11.0.dist-info}/METADATA +28 -13
- 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/alfred_hooks.py +0 -209
- moai_adk/templates/.claude/hooks/alfred/core/project.py +0 -750
- 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 -756
- 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/.moai/config.json +0 -113
- 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/ISSUE-LABEL-MAPPING.md +0 -150
- moai_adk/templates/.moai/memory/SKILLS-DESCRIPTION-POLICY.md +0 -218
- moai_adk/templates/.moai/memory/gitflow-protection-policy.md +0 -330
- 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-0.10.1.dist-info/RECORD +0 -309
- {moai_adk-0.10.1.dist-info → moai_adk-0.11.0.dist-info}/WHEEL +0 -0
- {moai_adk-0.10.1.dist-info → moai_adk-0.11.0.dist-info}/entry_points.txt +0 -0
- {moai_adk-0.10.1.dist-info → moai_adk-0.11.0.dist-info}/licenses/LICENSE +0 -0
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# @CODE:HOOK-TAG-001 | SPEC: TBD | TEST: tests/hooks/test_tag_validation.py
|
|
3
|
-
"""TAG validation helpers for MoAI-ADK hooks
|
|
4
|
-
|
|
5
|
-
Fast checks used by PreToolUse/PostToolUse to nudge users when
|
|
6
|
-
new or modified files are missing required @TAG annotations.
|
|
7
|
-
|
|
8
|
-
Configurable rules with sensible defaults:
|
|
9
|
-
- Load patterns from .moai/tag-rules.json if present.
|
|
10
|
-
- Otherwise, apply default glob patterns (folder names are not hard-coded only).
|
|
11
|
-
|
|
12
|
-
Defaults (order matters; first match wins):
|
|
13
|
-
1) SPEC
|
|
14
|
-
- .moai/specs/**
|
|
15
|
-
- **/SPEC-*/spec.md
|
|
16
|
-
2) TEST
|
|
17
|
-
- **/*_test.py, **/test_*.py, **/*.test.* (ts,tsx,js,jsx,go,rs)
|
|
18
|
-
- **/*.spec.* (ts,tsx,js,jsx)
|
|
19
|
-
- tests/**
|
|
20
|
-
3) DOC
|
|
21
|
-
- docs/**/*.md, **/README.md, **/*.api.md
|
|
22
|
-
4) CODE
|
|
23
|
-
- Source extensions: .py,.ts,.tsx,.js,.jsx,.go,.rs,.java,.kt,.rb,.php,.c,.cpp,.cs,.swift,.scala
|
|
24
|
-
- Excluding TEST patterns
|
|
25
|
-
|
|
26
|
-
Notes:
|
|
27
|
-
- Best-effort: skip binary/large files and non-target paths
|
|
28
|
-
- Do not block execution; return a list of issues for messaging
|
|
29
|
-
"""
|
|
30
|
-
|
|
31
|
-
from __future__ import annotations
|
|
32
|
-
|
|
33
|
-
import fnmatch
|
|
34
|
-
import json
|
|
35
|
-
import subprocess
|
|
36
|
-
from dataclasses import dataclass
|
|
37
|
-
from pathlib import Path
|
|
38
|
-
from typing import Iterable, List, Optional
|
|
39
|
-
|
|
40
|
-
DEFAULT_CODE_EXTS = (
|
|
41
|
-
".py", ".ts", ".tsx", ".js", ".jsx", ".go", ".rs",
|
|
42
|
-
".java", ".kt", ".rb", ".php", ".c", ".cpp", ".cs",
|
|
43
|
-
".swift", ".scala"
|
|
44
|
-
)
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
@dataclass
|
|
48
|
-
class TagIssue:
|
|
49
|
-
path: str
|
|
50
|
-
expected: str # one of @SPEC, @TEST, @CODE, @DOC
|
|
51
|
-
reason: str
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
@dataclass
|
|
55
|
-
class Rule:
|
|
56
|
-
include: List[str]
|
|
57
|
-
expect: str # '@SPEC:' | '@TEST:' | '@CODE:' | '@DOC:'
|
|
58
|
-
exclude: List[str]
|
|
59
|
-
|
|
60
|
-
|
|
61
|
-
def _load_rules(cwd: str) -> List[Rule]:
|
|
62
|
-
"""Load tag rules from .moai/tag-rules.json or return defaults.
|
|
63
|
-
|
|
64
|
-
Schema example:
|
|
65
|
-
{
|
|
66
|
-
"rules": [
|
|
67
|
-
{"include": ["**/*_test.py", "**/*.test.ts"], "expect": "@TEST:", "exclude": []},
|
|
68
|
-
{"include": ["docs/**/*.md", "**/README.md"], "expect": "@DOC:", "exclude": []}
|
|
69
|
-
]
|
|
70
|
-
}
|
|
71
|
-
"""
|
|
72
|
-
cfg = Path(cwd) / ".moai" / "tag-rules.json"
|
|
73
|
-
if cfg.exists():
|
|
74
|
-
try:
|
|
75
|
-
data = json.loads(cfg.read_text(encoding="utf-8"))
|
|
76
|
-
items = data.get("rules", [])
|
|
77
|
-
rules: List[Rule] = []
|
|
78
|
-
for it in items:
|
|
79
|
-
include = list(it.get("include", []))
|
|
80
|
-
expect = str(it.get("expect", ""))
|
|
81
|
-
exclude = list(it.get("exclude", []))
|
|
82
|
-
if include and expect in ("@SPEC:", "@TEST:", "@CODE:", "@DOC:"):
|
|
83
|
-
rules.append(Rule(include=include, expect=expect, exclude=exclude))
|
|
84
|
-
if rules:
|
|
85
|
-
return rules
|
|
86
|
-
except Exception:
|
|
87
|
-
pass
|
|
88
|
-
|
|
89
|
-
# Defaults (ordered)
|
|
90
|
-
return [
|
|
91
|
-
Rule(
|
|
92
|
-
include=[".moai/specs/**", "**/SPEC-*/spec.md"],
|
|
93
|
-
expect="@SPEC:",
|
|
94
|
-
exclude=[]
|
|
95
|
-
),
|
|
96
|
-
Rule(
|
|
97
|
-
include=[
|
|
98
|
-
"**/*_test.py", "**/test_*.py", "**/*.test.ts",
|
|
99
|
-
"**/*.test.tsx", "**/*.test.js", "**/*.test.jsx",
|
|
100
|
-
"**/*.test.go", "**/*.test.rs", "**/*.spec.ts",
|
|
101
|
-
"**/*.spec.tsx", "tests/**"
|
|
102
|
-
],
|
|
103
|
-
expect="@TEST:",
|
|
104
|
-
exclude=[".claude/**"]
|
|
105
|
-
),
|
|
106
|
-
Rule(
|
|
107
|
-
include=["docs/**/*.md", "**/README.md", "**/*.api.md"],
|
|
108
|
-
expect="@DOC:",
|
|
109
|
-
exclude=[".claude/**"]
|
|
110
|
-
),
|
|
111
|
-
Rule(
|
|
112
|
-
include=["**/*"],
|
|
113
|
-
expect="@CODE:",
|
|
114
|
-
exclude=[
|
|
115
|
-
"tests/**", "docs/**", ".moai/**", ".claude/**",
|
|
116
|
-
"**/*.md", "**/*.json", "**/*.yml", "**/*.yaml",
|
|
117
|
-
"**/*.toml", "**/*.lock", "**/*.svg", "**/*.png",
|
|
118
|
-
"**/*.jpg", "**/*.jpeg", "**/*.gif"
|
|
119
|
-
]
|
|
120
|
-
),
|
|
121
|
-
]
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
def _match_any(path: str, patterns: List[str]) -> bool:
|
|
125
|
-
return any(fnmatch.fnmatch(path, pat) for pat in patterns)
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
def _needs_tag_str(path_str: str, rules: List[Rule]) -> Optional[str]:
|
|
129
|
-
p = path_str
|
|
130
|
-
for rule in rules:
|
|
131
|
-
if _match_any(p, rule.include) and not _match_any(p, rule.exclude):
|
|
132
|
-
if rule.expect == "@CODE:":
|
|
133
|
-
# CODE: limit to source-like extensions to reduce noise
|
|
134
|
-
if not any(p.endswith(ext) for ext in DEFAULT_CODE_EXTS):
|
|
135
|
-
continue
|
|
136
|
-
return rule.expect
|
|
137
|
-
return None
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
def _has_tag(content: str, expected: str) -> bool:
|
|
141
|
-
return expected in content
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
def _iter_recent_changes(cwd: str) -> Iterable[Path]:
|
|
145
|
-
root = Path(cwd)
|
|
146
|
-
try:
|
|
147
|
-
# Staged files
|
|
148
|
-
r1 = subprocess.run(
|
|
149
|
-
["git", "diff", "--name-only", "--cached"],
|
|
150
|
-
cwd=cwd, capture_output=True, text=True, timeout=1
|
|
151
|
-
)
|
|
152
|
-
# Modified (unstaged) tracked files
|
|
153
|
-
r2 = subprocess.run(
|
|
154
|
-
["git", "ls-files", "-m"],
|
|
155
|
-
cwd=cwd, capture_output=True, text=True, timeout=1
|
|
156
|
-
)
|
|
157
|
-
# Untracked (other) files respecting .gitignore
|
|
158
|
-
r3 = subprocess.run(
|
|
159
|
-
["git", "ls-files", "-o", "--exclude-standard"],
|
|
160
|
-
cwd=cwd, capture_output=True, text=True, timeout=1
|
|
161
|
-
)
|
|
162
|
-
names = set()
|
|
163
|
-
if r1.returncode == 0:
|
|
164
|
-
names.update([line.strip() for line in r1.stdout.splitlines() if line.strip()])
|
|
165
|
-
if r2.returncode == 0:
|
|
166
|
-
names.update([line.strip() for line in r2.stdout.splitlines() if line.strip()])
|
|
167
|
-
if r3.returncode == 0:
|
|
168
|
-
names.update([line.strip() for line in r3.stdout.splitlines() if line.strip()])
|
|
169
|
-
for n in names:
|
|
170
|
-
p = (root / n).resolve()
|
|
171
|
-
if p.is_file():
|
|
172
|
-
yield p
|
|
173
|
-
except Exception:
|
|
174
|
-
return []
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
def scan_recent_changes_for_missing_tags(cwd: str) -> list[TagIssue]:
|
|
178
|
-
issues: list[TagIssue] = []
|
|
179
|
-
rules = _load_rules(cwd)
|
|
180
|
-
root = Path(cwd).resolve()
|
|
181
|
-
for path in _iter_recent_changes(cwd):
|
|
182
|
-
try:
|
|
183
|
-
content = path.read_text(encoding="utf-8", errors="ignore")
|
|
184
|
-
except Exception:
|
|
185
|
-
continue
|
|
186
|
-
# compute relative path once and use for matching/excluding
|
|
187
|
-
try:
|
|
188
|
-
rel = path.resolve().relative_to(root)
|
|
189
|
-
rel_s = rel.as_posix()
|
|
190
|
-
except Exception:
|
|
191
|
-
rel_s = path.name
|
|
192
|
-
|
|
193
|
-
expected = _needs_tag_str(rel_s, rules)
|
|
194
|
-
if not expected:
|
|
195
|
-
continue
|
|
196
|
-
if not _has_tag(content, expected):
|
|
197
|
-
issues.append(TagIssue(path=rel_s, expected=expected, reason="missing tag"))
|
|
198
|
-
return issues
|
|
@@ -1,198 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
# @CODE:VERSION-CACHE-001
|
|
3
|
-
"""Version information cache with TTL support
|
|
4
|
-
|
|
5
|
-
TTL-based caching system for version check results to minimize network calls
|
|
6
|
-
during SessionStart hook execution.
|
|
7
|
-
|
|
8
|
-
SPEC: SPEC-UPDATE-ENHANCE-001 - SessionStart 버전 체크 시스템 강화
|
|
9
|
-
Phase 1: Cache System Implementation
|
|
10
|
-
"""
|
|
11
|
-
|
|
12
|
-
import json
|
|
13
|
-
from datetime import datetime, timezone
|
|
14
|
-
from pathlib import Path
|
|
15
|
-
from typing import Any
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
class VersionCache:
|
|
19
|
-
"""TTL-based version information cache
|
|
20
|
-
|
|
21
|
-
Caches version check results with configurable Time-To-Live (TTL)
|
|
22
|
-
to avoid excessive network calls to PyPI during SessionStart events.
|
|
23
|
-
|
|
24
|
-
Attributes:
|
|
25
|
-
cache_dir: Directory to store cache file
|
|
26
|
-
ttl_hours: Time-to-live in hours (default 24)
|
|
27
|
-
cache_file: Path to the cache JSON file
|
|
28
|
-
|
|
29
|
-
Examples:
|
|
30
|
-
>>> cache = VersionCache(Path(".moai/cache"), ttl_hours=24)
|
|
31
|
-
>>> cache.save({"current_version": "0.8.1", "latest_version": "0.9.0"})
|
|
32
|
-
True
|
|
33
|
-
>>> cache.is_valid()
|
|
34
|
-
True
|
|
35
|
-
>>> data = cache.load()
|
|
36
|
-
>>> data["current_version"]
|
|
37
|
-
'0.8.1'
|
|
38
|
-
"""
|
|
39
|
-
|
|
40
|
-
def __init__(self, cache_dir: Path, ttl_hours: int = 4):
|
|
41
|
-
"""Initialize cache with TTL in hours
|
|
42
|
-
|
|
43
|
-
Args:
|
|
44
|
-
cache_dir: Directory where cache file will be stored
|
|
45
|
-
ttl_hours: Time-to-live in hours (default 4)
|
|
46
|
-
"""
|
|
47
|
-
self.cache_dir = Path(cache_dir)
|
|
48
|
-
self.ttl_hours = ttl_hours
|
|
49
|
-
self.cache_file = self.cache_dir / "version-check.json"
|
|
50
|
-
|
|
51
|
-
def _calculate_age_hours(self, last_check_iso: str) -> float:
|
|
52
|
-
"""Calculate age in hours from ISO timestamp (internal helper)
|
|
53
|
-
|
|
54
|
-
Normalizes timezone-aware and naive datetimes for consistent comparison.
|
|
55
|
-
|
|
56
|
-
Args:
|
|
57
|
-
last_check_iso: ISO format timestamp string
|
|
58
|
-
|
|
59
|
-
Returns:
|
|
60
|
-
Age in hours
|
|
61
|
-
|
|
62
|
-
Raises:
|
|
63
|
-
ValueError: If timestamp parsing fails
|
|
64
|
-
"""
|
|
65
|
-
last_check = datetime.fromisoformat(last_check_iso)
|
|
66
|
-
|
|
67
|
-
# Normalize to naive datetime (remove timezone for comparison)
|
|
68
|
-
if last_check.tzinfo is not None:
|
|
69
|
-
last_check = last_check.replace(tzinfo=None)
|
|
70
|
-
|
|
71
|
-
now = datetime.now()
|
|
72
|
-
return (now - last_check).total_seconds() / 3600
|
|
73
|
-
|
|
74
|
-
def is_valid(self) -> bool:
|
|
75
|
-
"""Check if cache exists and is not expired
|
|
76
|
-
|
|
77
|
-
Returns:
|
|
78
|
-
True if cache file exists and is within TTL, False otherwise
|
|
79
|
-
|
|
80
|
-
Examples:
|
|
81
|
-
>>> cache = VersionCache(Path(".moai/cache"))
|
|
82
|
-
>>> cache.is_valid()
|
|
83
|
-
False # No cache file exists yet
|
|
84
|
-
"""
|
|
85
|
-
if not self.cache_file.exists():
|
|
86
|
-
return False
|
|
87
|
-
|
|
88
|
-
try:
|
|
89
|
-
with open(self.cache_file, 'r') as f:
|
|
90
|
-
data = json.load(f)
|
|
91
|
-
|
|
92
|
-
age_hours = self._calculate_age_hours(data["last_check"])
|
|
93
|
-
return age_hours < self.ttl_hours
|
|
94
|
-
|
|
95
|
-
except (json.JSONDecodeError, KeyError, ValueError, OSError):
|
|
96
|
-
# Corrupted or invalid cache file
|
|
97
|
-
return False
|
|
98
|
-
|
|
99
|
-
def load(self) -> dict[str, Any] | None:
|
|
100
|
-
"""Load cached version info if valid
|
|
101
|
-
|
|
102
|
-
Returns:
|
|
103
|
-
Cached version info dictionary if valid, None otherwise
|
|
104
|
-
|
|
105
|
-
Examples:
|
|
106
|
-
>>> cache = VersionCache(Path(".moai/cache"))
|
|
107
|
-
>>> data = cache.load()
|
|
108
|
-
>>> data is None
|
|
109
|
-
True # No valid cache exists
|
|
110
|
-
"""
|
|
111
|
-
if not self.is_valid():
|
|
112
|
-
return None
|
|
113
|
-
|
|
114
|
-
try:
|
|
115
|
-
with open(self.cache_file, 'r') as f:
|
|
116
|
-
return json.load(f)
|
|
117
|
-
except (json.JSONDecodeError, OSError):
|
|
118
|
-
# Graceful degradation on read errors
|
|
119
|
-
return None
|
|
120
|
-
|
|
121
|
-
def save(self, version_info: dict[str, Any]) -> bool:
|
|
122
|
-
"""Save version info to cache file
|
|
123
|
-
|
|
124
|
-
Creates cache directory if it doesn't exist.
|
|
125
|
-
Updates last_check timestamp to current time if not provided.
|
|
126
|
-
|
|
127
|
-
Args:
|
|
128
|
-
version_info: Version information dictionary to cache
|
|
129
|
-
|
|
130
|
-
Returns:
|
|
131
|
-
True on successful save, False on error
|
|
132
|
-
|
|
133
|
-
Examples:
|
|
134
|
-
>>> cache = VersionCache(Path(".moai/cache"))
|
|
135
|
-
>>> cache.save({"current_version": "0.8.1"})
|
|
136
|
-
True
|
|
137
|
-
"""
|
|
138
|
-
try:
|
|
139
|
-
# Create cache directory if it doesn't exist
|
|
140
|
-
self.cache_dir.mkdir(parents=True, exist_ok=True)
|
|
141
|
-
|
|
142
|
-
# Update last_check timestamp only if not provided (for testing)
|
|
143
|
-
if "last_check" not in version_info:
|
|
144
|
-
version_info["last_check"] = datetime.now(timezone.utc).isoformat()
|
|
145
|
-
|
|
146
|
-
# Write to cache file
|
|
147
|
-
with open(self.cache_file, 'w') as f:
|
|
148
|
-
json.dump(version_info, f, indent=2)
|
|
149
|
-
|
|
150
|
-
return True
|
|
151
|
-
|
|
152
|
-
except (OSError, TypeError):
|
|
153
|
-
# Graceful degradation on write errors
|
|
154
|
-
return False
|
|
155
|
-
|
|
156
|
-
def clear(self) -> bool:
|
|
157
|
-
"""Clear/remove cache file
|
|
158
|
-
|
|
159
|
-
Returns:
|
|
160
|
-
True if cache file was removed or didn't exist, False on error
|
|
161
|
-
|
|
162
|
-
Examples:
|
|
163
|
-
>>> cache = VersionCache(Path(".moai/cache"))
|
|
164
|
-
>>> cache.clear()
|
|
165
|
-
True
|
|
166
|
-
"""
|
|
167
|
-
try:
|
|
168
|
-
if self.cache_file.exists():
|
|
169
|
-
self.cache_file.unlink()
|
|
170
|
-
return True
|
|
171
|
-
except OSError:
|
|
172
|
-
return False
|
|
173
|
-
|
|
174
|
-
def get_age_hours(self) -> float:
|
|
175
|
-
"""Get age of cache in hours
|
|
176
|
-
|
|
177
|
-
Returns:
|
|
178
|
-
Age in hours, or 0.0 if cache doesn't exist or is invalid
|
|
179
|
-
|
|
180
|
-
Examples:
|
|
181
|
-
>>> cache = VersionCache(Path(".moai/cache"))
|
|
182
|
-
>>> cache.get_age_hours()
|
|
183
|
-
0.0 # No cache exists
|
|
184
|
-
"""
|
|
185
|
-
if not self.cache_file.exists():
|
|
186
|
-
return 0.0
|
|
187
|
-
|
|
188
|
-
try:
|
|
189
|
-
with open(self.cache_file, 'r') as f:
|
|
190
|
-
data = json.load(f)
|
|
191
|
-
|
|
192
|
-
return self._calculate_age_hours(data["last_check"])
|
|
193
|
-
|
|
194
|
-
except (json.JSONDecodeError, KeyError, ValueError, OSError):
|
|
195
|
-
return 0.0
|
|
196
|
-
|
|
197
|
-
|
|
198
|
-
__all__ = ["VersionCache"]
|
|
@@ -1,21 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Event handlers for Alfred Hooks
|
|
3
|
-
|
|
4
|
-
Claude Code Event Handlers
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from .notification import handle_notification, handle_stop, handle_subagent_stop
|
|
8
|
-
from .session import handle_session_end, handle_session_start
|
|
9
|
-
from .tool import handle_post_tool_use, handle_pre_tool_use
|
|
10
|
-
from .user import handle_user_prompt_submit
|
|
11
|
-
|
|
12
|
-
__all__ = [
|
|
13
|
-
"handle_session_start",
|
|
14
|
-
"handle_session_end",
|
|
15
|
-
"handle_user_prompt_submit",
|
|
16
|
-
"handle_pre_tool_use",
|
|
17
|
-
"handle_post_tool_use",
|
|
18
|
-
"handle_notification",
|
|
19
|
-
"handle_stop",
|
|
20
|
-
"handle_subagent_stop",
|
|
21
|
-
]
|
|
@@ -1,25 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Notification and control handlers
|
|
3
|
-
|
|
4
|
-
Notification, Stop, SubagentStop event handling
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from core import HookPayload, HookResult
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
def handle_notification(payload: HookPayload) -> HookResult:
|
|
11
|
-
"""Notification event handler (default implementation)"""
|
|
12
|
-
return HookResult()
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
def handle_stop(payload: HookPayload) -> HookResult:
|
|
16
|
-
"""Stop event handler (default implementation)"""
|
|
17
|
-
return HookResult()
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
def handle_subagent_stop(payload: HookPayload) -> HookResult:
|
|
21
|
-
"""SubagentStop event handler (default implementation)"""
|
|
22
|
-
return HookResult()
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
__all__ = ["handle_notification", "handle_stop", "handle_subagent_stop"]
|
|
@@ -1,175 +0,0 @@
|
|
|
1
|
-
#!/usr/bin/env python3
|
|
2
|
-
"""Session event handlers
|
|
3
|
-
|
|
4
|
-
SessionStart, SessionEnd event handling
|
|
5
|
-
"""
|
|
6
|
-
|
|
7
|
-
from core import HookPayload, HookResult
|
|
8
|
-
from core.checkpoint import list_checkpoints
|
|
9
|
-
from core.project import count_specs, detect_language, get_git_info, get_package_version_info
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
def handle_session_start(payload: HookPayload) -> HookResult:
|
|
13
|
-
"""SessionStart event handler with GRACEFUL DEGRADATION
|
|
14
|
-
|
|
15
|
-
When Claude Code Session starts, it displays a summary of project status.
|
|
16
|
-
You can check the language, Git status, SPEC progress, and checkpoint list at a glance.
|
|
17
|
-
All optional operations are wrapped in try-except to ensure hook completes quickly even if
|
|
18
|
-
Git commands, file I/O, or other operations timeout or fail.
|
|
19
|
-
|
|
20
|
-
Args:
|
|
21
|
-
payload: Claude Code event payload (cwd key required)
|
|
22
|
-
|
|
23
|
-
Returns:
|
|
24
|
-
HookResult(system_message=project status summary message)
|
|
25
|
-
|
|
26
|
-
Message Format:
|
|
27
|
-
🚀 MoAI-ADK Session Started
|
|
28
|
-
Language: {language}
|
|
29
|
-
[Branch: {branch} ({commit hash})] - optional if git fails
|
|
30
|
-
[Changes: {Number of Changed Files}] - optional if git fails
|
|
31
|
-
[SPEC Progress: {Complete}/{Total} ({percent}%)] - optional if specs fail
|
|
32
|
-
[Checkpoints: {number} available] - optional if checkpoint list fails
|
|
33
|
-
|
|
34
|
-
Graceful Degradation Strategy:
|
|
35
|
-
- CRITICAL: Language detection (must succeed - no try-except)
|
|
36
|
-
- OPTIONAL: Git info (skip if timeout/failure)
|
|
37
|
-
- OPTIONAL: SPEC progress (skip if timeout/failure)
|
|
38
|
-
- OPTIONAL: Checkpoint list (skip if timeout/failure)
|
|
39
|
-
- Always display SOMETHING to user, never return empty message
|
|
40
|
-
|
|
41
|
-
Note:
|
|
42
|
-
- Claude Code processes SessionStart in several stages (clear → compact)
|
|
43
|
-
- Display message only at "compact" stage to prevent duplicate output
|
|
44
|
-
- "clear" step returns minimal result (empty hookSpecificOutput)
|
|
45
|
-
- CRITICAL: All optional operations must complete within 2-3 seconds total
|
|
46
|
-
|
|
47
|
-
TDD History:
|
|
48
|
-
- RED: Session startup message format test
|
|
49
|
-
- GREEN: Generate status message by combining helper functions
|
|
50
|
-
- REFACTOR: Improved message format, improved readability, added checkpoint list
|
|
51
|
-
- FIX: Prevent duplicate output of clear step (only compact step is displayed)
|
|
52
|
-
- UPDATE: Migrated to Claude Code standard Hook schema
|
|
53
|
-
- HOTFIX: Add graceful degradation for timeout scenarios (Issue #66)
|
|
54
|
-
- Phase 3: Add major version warning and release notes display (@TEST:MAJOR-UPDATE-001-07/08)
|
|
55
|
-
|
|
56
|
-
@TAG:CHECKPOINT-EVENT-001
|
|
57
|
-
@TAG:HOOKS-TIMEOUT-001
|
|
58
|
-
@CODE:MAJOR-UPDATE-WARN-001
|
|
59
|
-
"""
|
|
60
|
-
# Claude Code SessionStart runs in several stages (clear, compact, etc.)
|
|
61
|
-
# Ignore the "clear" stage and output messages only at the "compact" stage
|
|
62
|
-
event_phase = payload.get("phase", "")
|
|
63
|
-
if event_phase == "clear":
|
|
64
|
-
# Return minimal valid Hook result for clear phase
|
|
65
|
-
return HookResult(continue_execution=True)
|
|
66
|
-
|
|
67
|
-
cwd = payload.get("cwd", ".")
|
|
68
|
-
|
|
69
|
-
# CRITICAL: Language detection - MUST succeed (no try-except)
|
|
70
|
-
language = detect_language(cwd)
|
|
71
|
-
|
|
72
|
-
# OPTIONAL: Git info - skip if timeout/failure
|
|
73
|
-
git_info = {}
|
|
74
|
-
try:
|
|
75
|
-
git_info = get_git_info(cwd)
|
|
76
|
-
except Exception:
|
|
77
|
-
# Graceful degradation - continue without git info
|
|
78
|
-
pass
|
|
79
|
-
|
|
80
|
-
# OPTIONAL: SPEC progress - skip if timeout/failure
|
|
81
|
-
specs = {"completed": 0, "total": 0, "percentage": 0}
|
|
82
|
-
try:
|
|
83
|
-
specs = count_specs(cwd)
|
|
84
|
-
except Exception:
|
|
85
|
-
# Graceful degradation - continue without spec info
|
|
86
|
-
pass
|
|
87
|
-
|
|
88
|
-
# OPTIONAL: Checkpoint list - skip if timeout/failure
|
|
89
|
-
checkpoints = []
|
|
90
|
-
try:
|
|
91
|
-
checkpoints = list_checkpoints(cwd, max_count=10)
|
|
92
|
-
except Exception:
|
|
93
|
-
# Graceful degradation - continue without checkpoints
|
|
94
|
-
pass
|
|
95
|
-
|
|
96
|
-
# OPTIONAL: Package version info - skip if timeout/failure
|
|
97
|
-
version_info = {}
|
|
98
|
-
try:
|
|
99
|
-
version_info = get_package_version_info()
|
|
100
|
-
except Exception:
|
|
101
|
-
# Graceful degradation - continue without version info
|
|
102
|
-
pass
|
|
103
|
-
|
|
104
|
-
# Build message with available information
|
|
105
|
-
branch = git_info.get("branch", "N/A") if git_info else "N/A"
|
|
106
|
-
commit = git_info.get("commit", "N/A")[:7] if git_info else "N/A"
|
|
107
|
-
changes = git_info.get("changes", 0) if git_info else 0
|
|
108
|
-
spec_progress = f"{specs['completed']}/{specs['total']}" if specs["total"] > 0 else "0/0"
|
|
109
|
-
|
|
110
|
-
# system_message: displayed directly to the user
|
|
111
|
-
lines = [
|
|
112
|
-
"🚀 MoAI-ADK Session Started",
|
|
113
|
-
"", # Blank line after title
|
|
114
|
-
]
|
|
115
|
-
|
|
116
|
-
# Add version info first (at the top, right after title)
|
|
117
|
-
if version_info and version_info.get("current") != "unknown":
|
|
118
|
-
if version_info.get("update_available"):
|
|
119
|
-
# Check if this is a major version update
|
|
120
|
-
if version_info.get("is_major_update"):
|
|
121
|
-
# Major version warning
|
|
122
|
-
lines.append(f" ⚠️ Major version update available: {version_info['current']} → {version_info['latest']}")
|
|
123
|
-
lines.append(" Breaking changes detected. Review release notes:")
|
|
124
|
-
if version_info.get("release_notes_url"):
|
|
125
|
-
lines.append(f" 📝 {version_info['release_notes_url']}")
|
|
126
|
-
else:
|
|
127
|
-
# Regular update
|
|
128
|
-
lines.append(f" 🗿 MoAI-ADK Ver: {version_info['current']} → {version_info['latest']} available ✨")
|
|
129
|
-
if version_info.get("release_notes_url"):
|
|
130
|
-
lines.append(f" 📝 Release Notes: {version_info['release_notes_url']}")
|
|
131
|
-
|
|
132
|
-
# Add upgrade recommendation
|
|
133
|
-
if version_info.get("upgrade_command"):
|
|
134
|
-
lines.append(f" ⬆️ Upgrade: {version_info['upgrade_command']}")
|
|
135
|
-
else:
|
|
136
|
-
# No update available - show current version only
|
|
137
|
-
lines.append(f" 🗿 MoAI-ADK Ver: {version_info['current']}")
|
|
138
|
-
|
|
139
|
-
# Add language info
|
|
140
|
-
lines.append(f" 🐍 Language: {language}")
|
|
141
|
-
|
|
142
|
-
# Add Git info only if available (not degraded)
|
|
143
|
-
if git_info:
|
|
144
|
-
lines.append(f" 🌿 Branch: {branch} ({commit})")
|
|
145
|
-
lines.append(f" 📝 Changes: {changes}")
|
|
146
|
-
|
|
147
|
-
# Add last commit message if available
|
|
148
|
-
last_commit = git_info.get("last_commit", "")
|
|
149
|
-
if last_commit:
|
|
150
|
-
lines.append(f" 🔨 Last: {last_commit}")
|
|
151
|
-
|
|
152
|
-
# Add Checkpoint list (show only the latest 3 items)
|
|
153
|
-
if checkpoints:
|
|
154
|
-
lines.append(f" 🗂️ Checkpoints: {len(checkpoints)} available")
|
|
155
|
-
for cp in reversed(checkpoints[-3:]): # Latest 3 items
|
|
156
|
-
branch_short = cp["branch"].replace("before-", "")
|
|
157
|
-
lines.append(f" 📌 {branch_short}")
|
|
158
|
-
lines.append("") # Blank line before restore command
|
|
159
|
-
lines.append(" ↩️ Restore: /alfred:0-project restore")
|
|
160
|
-
|
|
161
|
-
# Add SPEC progress only if available (not degraded) - at the bottom
|
|
162
|
-
if specs["total"] > 0:
|
|
163
|
-
lines.append(f" 📋 SPEC Progress: {spec_progress} ({specs['percentage']}%)")
|
|
164
|
-
|
|
165
|
-
system_message = "\n".join(lines)
|
|
166
|
-
|
|
167
|
-
return HookResult(system_message=system_message)
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
def handle_session_end(payload: HookPayload) -> HookResult:
|
|
171
|
-
"""SessionEnd event handler (default implementation)"""
|
|
172
|
-
return HookResult()
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
__all__ = ["handle_session_start", "handle_session_end"]
|