create-ax-project 1.0.0
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.
- package/README.md +374 -0
- package/bin/create.js +193 -0
- package/package.json +38 -0
- package/template/.claude/CLAUDE.md +7 -0
- package/template/.claude/commands/CLAUDE.md +0 -0
- package/template/.claude/commands/benchmark.md +103 -0
- package/template/.claude/commands/brainstorm.md +67 -0
- package/template/.claude/commands/checkpoint.md +93 -0
- package/template/.claude/commands/codex.md +107 -0
- package/template/.claude/commands/collaborate.md +85 -0
- package/template/.claude/commands/context.md +154 -0
- package/template/.claude/commands/deploy.md +102 -0
- package/template/.claude/commands/fork.md +142 -0
- package/template/.claude/commands/gemini.md +84 -0
- package/template/.claude/commands/handoff.md +80 -0
- package/template/.claude/commands/implement.md +82 -0
- package/template/.claude/commands/init-project.md +49 -0
- package/template/.claude/commands/next.md +125 -0
- package/template/.claude/commands/planning.md +69 -0
- package/template/.claude/commands/qa.md +81 -0
- package/template/.claude/commands/refactor.md +95 -0
- package/template/.claude/commands/research.md +60 -0
- package/template/.claude/commands/restore.md +113 -0
- package/template/.claude/commands/run-stage.md +78 -0
- package/template/.claude/commands/stages.md +109 -0
- package/template/.claude/commands/status.md +73 -0
- package/template/.claude/commands/tasks.md +80 -0
- package/template/.claude/commands/test.md +93 -0
- package/template/.claude/commands/ui-ux.md +61 -0
- package/template/.claude/commands/validate.md +174 -0
- package/template/.claude/hooks/CLAUDE.md +0 -0
- package/template/.claude/hooks/ai-selector.sh +223 -0
- package/template/.claude/hooks/auto-checkpoint.sh +187 -0
- package/template/.claude/hooks/output-validator.sh +289 -0
- package/template/.claude/hooks/post-stage.sh +123 -0
- package/template/.claude/hooks/pre-stage.sh +186 -0
- package/template/.claude/hooks/session-start.sh +90 -0
- package/template/.claude/hooks/statusline.sh +115 -0
- package/template/.claude/hooks/stop.sh +104 -0
- package/template/.claude/settings.json +149 -0
- package/template/.claude/skills/ai-collaboration/CLAUDE.md +0 -0
- package/template/.claude/skills/ai-collaboration/README.md +61 -0
- package/template/.claude/skills/ai-collaboration/debate.md +148 -0
- package/template/.claude/skills/ai-collaboration/parallel.md +96 -0
- package/template/.claude/skills/ai-collaboration/prompts/CLAUDE.md +107 -0
- package/template/.claude/skills/auto-checkpoint/CLAUDE.md +0 -0
- package/template/.claude/skills/auto-checkpoint/README.md +77 -0
- package/template/.claude/skills/auto-checkpoint/prompts/CLAUDE.md +113 -0
- package/template/.claude/skills/auto-checkpoint/rollback.md +152 -0
- package/template/.claude/skills/auto-checkpoint/trigger.md +122 -0
- package/template/.claude/skills/context-compression/CLAUDE.md +0 -0
- package/template/.claude/skills/context-compression/README.md +121 -0
- package/template/.claude/skills/context-compression/analyze.md +114 -0
- package/template/.claude/skills/context-compression/compress.md +175 -0
- package/template/.claude/skills/context-compression/prompts/CLAUDE.md +0 -0
- package/template/.claude/skills/context-compression/prompts/compression.md +172 -0
- package/template/.claude/skills/output-validator/CLAUDE.md +0 -0
- package/template/.claude/skills/output-validator/README.md +86 -0
- package/template/.claude/skills/output-validator/prompts/CLAUDE.md +119 -0
- package/template/.claude/skills/output-validator/validate.md +182 -0
- package/template/.claude/skills/smart-handoff/CLAUDE.md +0 -0
- package/template/.claude/skills/smart-handoff/README.md +59 -0
- package/template/.claude/skills/smart-handoff/extract.md +76 -0
- package/template/.claude/skills/smart-handoff/prompts/CLAUDE.md +86 -0
- package/template/.claude/skills/smart-handoff/summarize.md +94 -0
- package/template/.claude/skills/stage-transition/CLAUDE.md +0 -0
- package/template/.claude/skills/stage-transition/README.md +84 -0
- package/template/.claude/skills/stage-transition/handoff-gen.md +160 -0
- package/template/.claude/skills/stage-transition/prompts/CLAUDE.md +0 -0
- package/template/.claude/skills/stage-transition/prompts/transition.md +145 -0
- package/template/.claude/skills/stage-transition/validate.md +108 -0
- package/template/CLAUDE.md +528 -0
- package/template/config/CLAUDE.md +0 -0
- package/template/config/ai_benchmarking.yaml +184 -0
- package/template/config/ai_collaboration.yaml +159 -0
- package/template/config/ai_logging.yaml +129 -0
- package/template/config/auto_checkpoint.yaml +189 -0
- package/template/config/context.yaml +78 -0
- package/template/config/git.yaml +161 -0
- package/template/config/handoff_intelligence.yaml +229 -0
- package/template/config/implementation.yaml.template +181 -0
- package/template/config/mcp_fallbacks.yaml +252 -0
- package/template/config/memory_integration.yaml +200 -0
- package/template/config/model_enforcement.yaml +141 -0
- package/template/config/models.yaml +242 -0
- package/template/config/output_validation.yaml +352 -0
- package/template/config/pipeline.yaml +357 -0
- package/template/config/pipeline_forking.yaml +236 -0
- package/template/config/qa_logging.yaml +166 -0
- package/template/config/smart_rollback.yaml +209 -0
- package/template/config/stage_personas.yaml +354 -0
- package/template/config/workflow.yaml +54 -0
- package/template/scripts/CLAUDE.md +0 -0
- package/template/scripts/ai-benchmark.sh +272 -0
- package/template/scripts/codex-wrapper.sh +97 -0
- package/template/scripts/context-manager.sh +528 -0
- package/template/scripts/create-checkpoint.sh +116 -0
- package/template/scripts/gemini-wrapper.sh +96 -0
- package/template/scripts/init-project.sh +109 -0
- package/template/scripts/list-stages.sh +245 -0
- package/template/scripts/next-stage.sh +228 -0
- package/template/scripts/output-validate.sh +12 -0
- package/template/scripts/pipeline-fork.sh +293 -0
- package/template/scripts/pre-run-check.sh +361 -0
- package/template/scripts/restore-checkpoint.sh +247 -0
- package/template/scripts/run-stage.sh +139 -0
- package/template/scripts/show-status.sh +185 -0
- package/template/scripts/smart-handoff.sh +254 -0
- package/template/stages/01-brainstorm/CLAUDE.md +103 -0
- package/template/stages/01-brainstorm/HANDOFF.md +110 -0
- package/template/stages/01-brainstorm/HANDOFF.md.template +112 -0
- package/template/stages/01-brainstorm/README.md +97 -0
- package/template/stages/01-brainstorm/config.yaml +92 -0
- package/template/stages/01-brainstorm/inputs/.gitkeep +0 -0
- package/template/stages/01-brainstorm/inputs/CLAUDE.md +0 -0
- package/template/stages/01-brainstorm/inputs/project_brief.md +40 -0
- package/template/stages/01-brainstorm/outputs/.gitkeep +0 -0
- package/template/stages/01-brainstorm/outputs/CLAUDE.md +0 -0
- package/template/stages/01-brainstorm/outputs/ideas.md +159 -0
- package/template/stages/01-brainstorm/outputs/requirements_analysis.md +222 -0
- package/template/stages/01-brainstorm/prompts/CLAUDE.md +0 -0
- package/template/stages/01-brainstorm/prompts/collaboration.md +46 -0
- package/template/stages/01-brainstorm/prompts/ideation.md +62 -0
- package/template/stages/01-brainstorm/prompts/persona.md +73 -0
- package/template/stages/01-brainstorm/prompts/requirements.md +73 -0
- package/template/stages/01-brainstorm/prompts/validation.md +50 -0
- package/template/stages/01-brainstorm/templates/CLAUDE.md +0 -0
- package/template/stages/01-brainstorm/templates/ideas.md +91 -0
- package/template/stages/01-brainstorm/templates/requirements_analysis.md +129 -0
- package/template/stages/02-research/CLAUDE.md +101 -0
- package/template/stages/02-research/HANDOFF.md +158 -0
- package/template/stages/02-research/HANDOFF.md.template +102 -0
- package/template/stages/02-research/config.yaml +68 -0
- package/template/stages/02-research/inputs/.gitkeep +0 -0
- package/template/stages/02-research/outputs/.gitkeep +0 -0
- package/template/stages/02-research/outputs/CLAUDE.md +0 -0
- package/template/stages/02-research/outputs/feasibility_report.md +176 -0
- package/template/stages/02-research/outputs/tech_research.md +403 -0
- package/template/stages/02-research/prompts/CLAUDE.md +0 -0
- package/template/stages/02-research/prompts/collaboration.md +51 -0
- package/template/stages/02-research/prompts/feasibility.md +73 -0
- package/template/stages/02-research/prompts/market_analysis.md +58 -0
- package/template/stages/02-research/prompts/tech_stack.md +60 -0
- package/template/stages/02-research/prompts/validation.md +51 -0
- package/template/stages/02-research/templates/.gitkeep +0 -0
- package/template/stages/03-planning/CLAUDE.md +98 -0
- package/template/stages/03-planning/HANDOFF.md +168 -0
- package/template/stages/03-planning/HANDOFF.md.template +91 -0
- package/template/stages/03-planning/config.yaml +64 -0
- package/template/stages/03-planning/inputs/.gitkeep +0 -0
- package/template/stages/03-planning/outputs/.gitkeep +0 -0
- package/template/stages/03-planning/outputs/CLAUDE.md +0 -0
- package/template/stages/03-planning/outputs/architecture.md +400 -0
- package/template/stages/03-planning/outputs/implementation.yaml +209 -0
- package/template/stages/03-planning/outputs/project_plan.md +204 -0
- package/template/stages/03-planning/outputs/tech_stack.md +176 -0
- package/template/stages/03-planning/prompts/CLAUDE.md +0 -0
- package/template/stages/03-planning/prompts/architecture.md +62 -0
- package/template/stages/03-planning/prompts/collaboration.md +57 -0
- package/template/stages/03-planning/prompts/validation.md +59 -0
- package/template/stages/03-planning/templates/.gitkeep +0 -0
- package/template/stages/04-ui-ux/CLAUDE.md +88 -0
- package/template/stages/04-ui-ux/HANDOFF.md +165 -0
- package/template/stages/04-ui-ux/HANDOFF.md.template +92 -0
- package/template/stages/04-ui-ux/config.yaml +57 -0
- package/template/stages/04-ui-ux/inputs/.gitkeep +0 -0
- package/template/stages/04-ui-ux/outputs/.gitkeep +0 -0
- package/template/stages/04-ui-ux/outputs/CLAUDE.md +0 -0
- package/template/stages/04-ui-ux/outputs/design_system.md +449 -0
- package/template/stages/04-ui-ux/outputs/user_flows.md +321 -0
- package/template/stages/04-ui-ux/outputs/wireframes.md +241 -0
- package/template/stages/04-ui-ux/prompts/.gitkeep +0 -0
- package/template/stages/04-ui-ux/prompts/CLAUDE.md +0 -0
- package/template/stages/04-ui-ux/prompts/collaboration.md +56 -0
- package/template/stages/04-ui-ux/prompts/validation.md +54 -0
- package/template/stages/04-ui-ux/templates/.gitkeep +0 -0
- package/template/stages/05-task-management/CLAUDE.md +105 -0
- package/template/stages/05-task-management/HANDOFF.md +187 -0
- package/template/stages/05-task-management/HANDOFF.md.template +97 -0
- package/template/stages/05-task-management/config.yaml +81 -0
- package/template/stages/05-task-management/inputs/.gitkeep +0 -0
- package/template/stages/05-task-management/outputs/.gitkeep +0 -0
- package/template/stages/05-task-management/outputs/CLAUDE.md +0 -0
- package/template/stages/05-task-management/outputs/milestones.md +253 -0
- package/template/stages/05-task-management/outputs/sprint_plan.md +203 -0
- package/template/stages/05-task-management/outputs/tasks.md +402 -0
- package/template/stages/05-task-management/prompts/.gitkeep +0 -0
- package/template/stages/05-task-management/prompts/CLAUDE.md +0 -0
- package/template/stages/05-task-management/prompts/collaboration.md +54 -0
- package/template/stages/05-task-management/prompts/validation.md +66 -0
- package/template/stages/05-task-management/templates/CLAUDE.md +0 -0
- package/template/stages/05-task-management/templates/notion_integration.md +176 -0
- package/template/stages/05-task-management/templates/parallel_groups.yaml +153 -0
- package/template/stages/05-task-management/templates/task_schema.yaml +154 -0
- package/template/stages/06-implementation/CLAUDE.md +163 -0
- package/template/stages/06-implementation/HANDOFF.md +184 -0
- package/template/stages/06-implementation/HANDOFF.md.template +192 -0
- package/template/stages/06-implementation/config.yaml +62 -0
- package/template/stages/06-implementation/inputs/.gitkeep +0 -0
- package/template/stages/06-implementation/outputs/.gitkeep +0 -0
- package/template/stages/06-implementation/prompts/.gitkeep +0 -0
- package/template/stages/06-implementation/prompts/CLAUDE.md +0 -0
- package/template/stages/06-implementation/prompts/collaboration.md +64 -0
- package/template/stages/06-implementation/prompts/validation.md +65 -0
- package/template/stages/06-implementation/templates/.gitkeep +0 -0
- package/template/stages/07-refactoring/CLAUDE.md +180 -0
- package/template/stages/07-refactoring/HANDOFF.md +82 -0
- package/template/stages/07-refactoring/HANDOFF.md.template +97 -0
- package/template/stages/07-refactoring/config.yaml +68 -0
- package/template/stages/07-refactoring/inputs/.gitkeep +0 -0
- package/template/stages/07-refactoring/outputs/.gitkeep +0 -0
- package/template/stages/07-refactoring/outputs/refactoring_report.md +102 -0
- package/template/stages/07-refactoring/prompts/.gitkeep +0 -0
- package/template/stages/07-refactoring/prompts/CLAUDE.md +0 -0
- package/template/stages/07-refactoring/prompts/collaboration.md +71 -0
- package/template/stages/07-refactoring/prompts/validation.md +76 -0
- package/template/stages/07-refactoring/templates/.gitkeep +0 -0
- package/template/stages/08-qa/CLAUDE.md +93 -0
- package/template/stages/08-qa/HANDOFF.md +114 -0
- package/template/stages/08-qa/HANDOFF.md.template +96 -0
- package/template/stages/08-qa/config.yaml +56 -0
- package/template/stages/08-qa/inputs/.gitkeep +0 -0
- package/template/stages/08-qa/outputs/.gitkeep +0 -0
- package/template/stages/08-qa/outputs/qa_report.md +138 -0
- package/template/stages/08-qa/prompts/.gitkeep +0 -0
- package/template/stages/08-qa/prompts/CLAUDE.md +0 -0
- package/template/stages/08-qa/prompts/collaboration.md +65 -0
- package/template/stages/08-qa/prompts/validation.md +71 -0
- package/template/stages/08-qa/templates/.gitkeep +0 -0
- package/template/stages/09-testing/CLAUDE.md +124 -0
- package/template/stages/09-testing/HANDOFF.md +118 -0
- package/template/stages/09-testing/HANDOFF.md.template +113 -0
- package/template/stages/09-testing/config.yaml +65 -0
- package/template/stages/09-testing/inputs/.gitkeep +0 -0
- package/template/stages/09-testing/outputs/.gitkeep +0 -0
- package/template/stages/09-testing/outputs/test_report.md +146 -0
- package/template/stages/09-testing/prompts/.gitkeep +0 -0
- package/template/stages/09-testing/prompts/CLAUDE.md +0 -0
- package/template/stages/09-testing/prompts/collaboration.md +77 -0
- package/template/stages/09-testing/prompts/validation.md +83 -0
- package/template/stages/09-testing/templates/.gitkeep +0 -0
- package/template/stages/10-deployment/CLAUDE.md +117 -0
- package/template/stages/10-deployment/HANDOFF.md +141 -0
- package/template/stages/10-deployment/HANDOFF.md.template +148 -0
- package/template/stages/10-deployment/config.yaml +61 -0
- package/template/stages/10-deployment/inputs/.gitkeep +0 -0
- package/template/stages/10-deployment/outputs/.gitkeep +0 -0
- package/template/stages/10-deployment/prompts/.gitkeep +0 -0
- package/template/stages/10-deployment/prompts/CLAUDE.md +0 -0
- package/template/stages/10-deployment/prompts/collaboration.md +80 -0
- package/template/stages/10-deployment/prompts/validation.md +93 -0
- package/template/stages/10-deployment/templates/CLAUDE.md +0 -0
- package/template/stages/10-deployment/templates/github-actions-cd.yaml +118 -0
- package/template/stages/10-deployment/templates/github-actions-ci.yaml +136 -0
- package/template/state/progress.json.template +111 -0
- package/template/state/templates/CLAUDE.md +0 -0
- package/template/state/templates/handoff_base.md.template +187 -0
- package/template/state/templates/phase_state.md.template +97 -0
|
@@ -0,0 +1,289 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# ax-templates Output Validator Hook
|
|
3
|
+
# 스테이지 산출물 검증
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
8
|
+
PROJECT_ROOT="$(cd "$SCRIPT_DIR/../.." && pwd)"
|
|
9
|
+
CONFIG_FILE="$PROJECT_ROOT/config/output_validation.yaml"
|
|
10
|
+
PROGRESS_FILE="$PROJECT_ROOT/state/progress.json"
|
|
11
|
+
VALIDATIONS_DIR="$PROJECT_ROOT/state/validations"
|
|
12
|
+
|
|
13
|
+
# 색상 정의
|
|
14
|
+
RED='\033[0;31m'
|
|
15
|
+
GREEN='\033[0;32m'
|
|
16
|
+
YELLOW='\033[1;33m'
|
|
17
|
+
BLUE='\033[0;34m'
|
|
18
|
+
NC='\033[0m'
|
|
19
|
+
|
|
20
|
+
# 결과 아이콘
|
|
21
|
+
PASS="✅"
|
|
22
|
+
FAIL="❌"
|
|
23
|
+
WARN="⚠️"
|
|
24
|
+
INFO="ℹ️"
|
|
25
|
+
|
|
26
|
+
# 로그 함수
|
|
27
|
+
log_pass() { echo -e "${GREEN}${PASS}${NC} $1"; }
|
|
28
|
+
log_fail() { echo -e "${RED}${FAIL}${NC} $1"; }
|
|
29
|
+
log_warn() { echo -e "${YELLOW}${WARN}${NC} $1"; }
|
|
30
|
+
log_info() { echo -e "${BLUE}${INFO}${NC} $1"; }
|
|
31
|
+
|
|
32
|
+
# 검증 결과 저장
|
|
33
|
+
TOTAL_CHECKS=0
|
|
34
|
+
PASSED_CHECKS=0
|
|
35
|
+
FAILED_CHECKS=0
|
|
36
|
+
WARNINGS=0
|
|
37
|
+
|
|
38
|
+
# 현재 스테이지 확인
|
|
39
|
+
get_current_stage() {
|
|
40
|
+
if [ -f "$PROGRESS_FILE" ]; then
|
|
41
|
+
cat "$PROGRESS_FILE" 2>/dev/null | grep -o '"current_stage"[[:space:]]*:[[:space:]]*"[^"]*"' | cut -d'"' -f4
|
|
42
|
+
else
|
|
43
|
+
echo "unknown"
|
|
44
|
+
fi
|
|
45
|
+
}
|
|
46
|
+
|
|
47
|
+
# 파일 존재 확인
|
|
48
|
+
check_file_exists() {
|
|
49
|
+
local file_path="$1"
|
|
50
|
+
local required="$2"
|
|
51
|
+
local full_path="$PROJECT_ROOT/$file_path"
|
|
52
|
+
|
|
53
|
+
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
|
|
54
|
+
|
|
55
|
+
if [ -e "$full_path" ]; then
|
|
56
|
+
log_pass "$file_path 존재"
|
|
57
|
+
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
|
58
|
+
return 0
|
|
59
|
+
else
|
|
60
|
+
if [ "$required" = "true" ]; then
|
|
61
|
+
log_fail "$file_path 누락"
|
|
62
|
+
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
|
63
|
+
return 1
|
|
64
|
+
else
|
|
65
|
+
log_warn "$file_path 누락 (선택사항)"
|
|
66
|
+
WARNINGS=$((WARNINGS + 1))
|
|
67
|
+
return 0
|
|
68
|
+
fi
|
|
69
|
+
fi
|
|
70
|
+
}
|
|
71
|
+
|
|
72
|
+
# 디렉토리 확인
|
|
73
|
+
check_directory_exists() {
|
|
74
|
+
local dir_path="$1"
|
|
75
|
+
local full_path="$PROJECT_ROOT/$dir_path"
|
|
76
|
+
|
|
77
|
+
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
|
|
78
|
+
|
|
79
|
+
if [ -d "$full_path" ]; then
|
|
80
|
+
log_pass "$dir_path 디렉토리 존재"
|
|
81
|
+
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
|
82
|
+
return 0
|
|
83
|
+
else
|
|
84
|
+
log_fail "$dir_path 디렉토리 누락"
|
|
85
|
+
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
|
86
|
+
return 1
|
|
87
|
+
fi
|
|
88
|
+
}
|
|
89
|
+
|
|
90
|
+
# 파일 최소 크기 확인
|
|
91
|
+
check_file_size() {
|
|
92
|
+
local file_path="$1"
|
|
93
|
+
local min_size="$2"
|
|
94
|
+
local full_path="$PROJECT_ROOT/$file_path"
|
|
95
|
+
|
|
96
|
+
if [ -f "$full_path" ]; then
|
|
97
|
+
local size=$(wc -c < "$full_path")
|
|
98
|
+
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
|
|
99
|
+
|
|
100
|
+
if [ "$size" -ge "$min_size" ]; then
|
|
101
|
+
log_pass "$file_path 크기 충족 (${size} bytes >= ${min_size})"
|
|
102
|
+
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
|
103
|
+
return 0
|
|
104
|
+
else
|
|
105
|
+
log_fail "$file_path 크기 미달 (${size} bytes < ${min_size})"
|
|
106
|
+
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
|
107
|
+
return 1
|
|
108
|
+
fi
|
|
109
|
+
fi
|
|
110
|
+
}
|
|
111
|
+
|
|
112
|
+
# 마크다운 섹션 확인
|
|
113
|
+
check_markdown_sections() {
|
|
114
|
+
local file_path="$1"
|
|
115
|
+
shift
|
|
116
|
+
local sections=("$@")
|
|
117
|
+
local full_path="$PROJECT_ROOT/$file_path"
|
|
118
|
+
|
|
119
|
+
if [ -f "$full_path" ]; then
|
|
120
|
+
for section in "${sections[@]}"; do
|
|
121
|
+
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
|
|
122
|
+
|
|
123
|
+
if grep -q "^#.*$section" "$full_path" || grep -q "^##.*$section" "$full_path"; then
|
|
124
|
+
log_pass "$file_path: '$section' 섹션 존재"
|
|
125
|
+
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
|
126
|
+
else
|
|
127
|
+
log_fail "$file_path: '$section' 섹션 누락"
|
|
128
|
+
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
|
129
|
+
fi
|
|
130
|
+
done
|
|
131
|
+
fi
|
|
132
|
+
}
|
|
133
|
+
|
|
134
|
+
# 명령어 실행 검증
|
|
135
|
+
run_validation_command() {
|
|
136
|
+
local name="$1"
|
|
137
|
+
local command="$2"
|
|
138
|
+
local required="$3"
|
|
139
|
+
|
|
140
|
+
TOTAL_CHECKS=$((TOTAL_CHECKS + 1))
|
|
141
|
+
log_info "실행 중: $name ($command)"
|
|
142
|
+
|
|
143
|
+
if eval "$command" > /dev/null 2>&1; then
|
|
144
|
+
log_pass "$name 통과"
|
|
145
|
+
PASSED_CHECKS=$((PASSED_CHECKS + 1))
|
|
146
|
+
return 0
|
|
147
|
+
else
|
|
148
|
+
if [ "$required" = "true" ]; then
|
|
149
|
+
log_fail "$name 실패"
|
|
150
|
+
FAILED_CHECKS=$((FAILED_CHECKS + 1))
|
|
151
|
+
return 1
|
|
152
|
+
else
|
|
153
|
+
log_warn "$name 실패 (선택사항)"
|
|
154
|
+
WARNINGS=$((WARNINGS + 1))
|
|
155
|
+
return 0
|
|
156
|
+
fi
|
|
157
|
+
fi
|
|
158
|
+
}
|
|
159
|
+
|
|
160
|
+
# 스테이지별 검증
|
|
161
|
+
validate_stage() {
|
|
162
|
+
local stage="$1"
|
|
163
|
+
local stage_dir="$PROJECT_ROOT/stages/$stage"
|
|
164
|
+
local outputs_dir="$stage_dir/outputs"
|
|
165
|
+
|
|
166
|
+
echo ""
|
|
167
|
+
echo "=========================================="
|
|
168
|
+
echo " 산출물 검증: $stage"
|
|
169
|
+
echo "=========================================="
|
|
170
|
+
echo ""
|
|
171
|
+
|
|
172
|
+
# HANDOFF.md 확인 (모든 스테이지 공통)
|
|
173
|
+
check_file_exists "stages/$stage/HANDOFF.md" "true"
|
|
174
|
+
|
|
175
|
+
case "$stage" in
|
|
176
|
+
"01-brainstorm")
|
|
177
|
+
check_file_exists "stages/$stage/outputs/ideas.md" "true"
|
|
178
|
+
check_file_size "stages/$stage/outputs/ideas.md" 500
|
|
179
|
+
check_file_exists "stages/$stage/outputs/requirements_analysis.md" "true"
|
|
180
|
+
check_markdown_sections "stages/$stage/outputs/requirements_analysis.md" "기능" "비기능"
|
|
181
|
+
;;
|
|
182
|
+
|
|
183
|
+
"02-research")
|
|
184
|
+
check_file_exists "stages/$stage/outputs/tech_research.md" "true"
|
|
185
|
+
check_file_size "stages/$stage/outputs/tech_research.md" 2000
|
|
186
|
+
check_file_exists "stages/$stage/outputs/feasibility_report.md" "true"
|
|
187
|
+
;;
|
|
188
|
+
|
|
189
|
+
"03-planning")
|
|
190
|
+
check_file_exists "stages/$stage/outputs/architecture.md" "true"
|
|
191
|
+
check_file_exists "stages/$stage/outputs/tech_stack.md" "true"
|
|
192
|
+
check_file_exists "stages/$stage/outputs/project_plan.md" "true"
|
|
193
|
+
;;
|
|
194
|
+
|
|
195
|
+
"06-implementation")
|
|
196
|
+
check_directory_exists "stages/$stage/outputs/source_code"
|
|
197
|
+
check_file_exists "stages/$stage/outputs/implementation_log.md" "true"
|
|
198
|
+
|
|
199
|
+
# 빌드 검증
|
|
200
|
+
if [ -f "$PROJECT_ROOT/package.json" ]; then
|
|
201
|
+
run_validation_command "lint" "npm run lint --prefix $PROJECT_ROOT" "true"
|
|
202
|
+
run_validation_command "typecheck" "npm run typecheck --prefix $PROJECT_ROOT" "true"
|
|
203
|
+
fi
|
|
204
|
+
;;
|
|
205
|
+
|
|
206
|
+
"09-testing")
|
|
207
|
+
check_directory_exists "stages/$stage/outputs/tests"
|
|
208
|
+
check_file_exists "stages/$stage/outputs/test_report.md" "true"
|
|
209
|
+
check_file_exists "stages/$stage/outputs/coverage_report.md" "true"
|
|
210
|
+
|
|
211
|
+
# 테스트 검증
|
|
212
|
+
if [ -f "$PROJECT_ROOT/package.json" ]; then
|
|
213
|
+
run_validation_command "test" "npm run test --prefix $PROJECT_ROOT" "true"
|
|
214
|
+
fi
|
|
215
|
+
;;
|
|
216
|
+
|
|
217
|
+
*)
|
|
218
|
+
log_info "스테이지 $stage에 대한 특정 검증 규칙 없음"
|
|
219
|
+
;;
|
|
220
|
+
esac
|
|
221
|
+
}
|
|
222
|
+
|
|
223
|
+
# 결과 요약 출력
|
|
224
|
+
print_summary() {
|
|
225
|
+
echo ""
|
|
226
|
+
echo "=========================================="
|
|
227
|
+
echo " 검증 결과 요약"
|
|
228
|
+
echo "=========================================="
|
|
229
|
+
echo ""
|
|
230
|
+
echo "총 검사: $TOTAL_CHECKS"
|
|
231
|
+
echo -e "${GREEN}통과: $PASSED_CHECKS${NC}"
|
|
232
|
+
echo -e "${RED}실패: $FAILED_CHECKS${NC}"
|
|
233
|
+
echo -e "${YELLOW}경고: $WARNINGS${NC}"
|
|
234
|
+
echo ""
|
|
235
|
+
|
|
236
|
+
# 점수 계산
|
|
237
|
+
if [ "$TOTAL_CHECKS" -gt 0 ]; then
|
|
238
|
+
local score=$(echo "scale=2; $PASSED_CHECKS / $TOTAL_CHECKS" | bc)
|
|
239
|
+
echo "점수: $score"
|
|
240
|
+
|
|
241
|
+
if [ "$FAILED_CHECKS" -eq 0 ]; then
|
|
242
|
+
echo -e "${GREEN}${PASS} 검증 통과${NC}"
|
|
243
|
+
return 0
|
|
244
|
+
else
|
|
245
|
+
echo -e "${RED}${FAIL} 검증 실패 - 스테이지 전환 차단됨${NC}"
|
|
246
|
+
return 1
|
|
247
|
+
fi
|
|
248
|
+
fi
|
|
249
|
+
}
|
|
250
|
+
|
|
251
|
+
# 결과 저장
|
|
252
|
+
save_results() {
|
|
253
|
+
local stage="$1"
|
|
254
|
+
local timestamp=$(date +%Y%m%d_%H%M%S)
|
|
255
|
+
|
|
256
|
+
mkdir -p "$VALIDATIONS_DIR"
|
|
257
|
+
|
|
258
|
+
cat > "$VALIDATIONS_DIR/${stage}_${timestamp}.json" << EOF
|
|
259
|
+
{
|
|
260
|
+
"stage": "$stage",
|
|
261
|
+
"timestamp": "$(date -u +%Y-%m-%dT%H:%M:%SZ)",
|
|
262
|
+
"total_checks": $TOTAL_CHECKS,
|
|
263
|
+
"passed": $PASSED_CHECKS,
|
|
264
|
+
"failed": $FAILED_CHECKS,
|
|
265
|
+
"warnings": $WARNINGS,
|
|
266
|
+
"score": $(echo "scale=2; $PASSED_CHECKS / $TOTAL_CHECKS" | bc 2>/dev/null || echo "0")
|
|
267
|
+
}
|
|
268
|
+
EOF
|
|
269
|
+
}
|
|
270
|
+
|
|
271
|
+
# 메인 실행
|
|
272
|
+
main() {
|
|
273
|
+
local stage="${1:-$(get_current_stage)}"
|
|
274
|
+
local verbose="${2:-false}"
|
|
275
|
+
|
|
276
|
+
if [ "$stage" = "unknown" ]; then
|
|
277
|
+
log_fail "현재 스테이지를 확인할 수 없습니다."
|
|
278
|
+
exit 1
|
|
279
|
+
fi
|
|
280
|
+
|
|
281
|
+
validate_stage "$stage"
|
|
282
|
+
save_results "$stage"
|
|
283
|
+
print_summary
|
|
284
|
+
}
|
|
285
|
+
|
|
286
|
+
# 직접 실행 시에만 main 호출
|
|
287
|
+
if [[ "${BASH_SOURCE[0]}" == "${0}" ]]; then
|
|
288
|
+
main "$@"
|
|
289
|
+
fi
|
|
@@ -0,0 +1,123 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# post-stage.sh - 스테이지 완료 후 훅
|
|
3
|
+
# ax-templates workflow pipeline
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
STAGE_ID="$1"
|
|
8
|
+
PROJECT_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
9
|
+
PROGRESS_FILE="$PROJECT_ROOT/state/progress.json"
|
|
10
|
+
TIMESTAMP=$(date -u +"%Y-%m-%dT%H:%M:%SZ")
|
|
11
|
+
|
|
12
|
+
# 색상 정의
|
|
13
|
+
RED='\033[0;31m'
|
|
14
|
+
GREEN='\033[0;32m'
|
|
15
|
+
YELLOW='\033[1;33m'
|
|
16
|
+
BLUE='\033[0;34m'
|
|
17
|
+
NC='\033[0m' # No Color
|
|
18
|
+
|
|
19
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
20
|
+
echo "📋 Post-Stage Hook: $STAGE_ID"
|
|
21
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
22
|
+
|
|
23
|
+
# 1. 완료 조건 검증
|
|
24
|
+
validate_completion() {
|
|
25
|
+
local stage_dir="$PROJECT_ROOT/stages/$STAGE_ID"
|
|
26
|
+
local config_file="$stage_dir/config.yaml"
|
|
27
|
+
|
|
28
|
+
echo "완료 조건 검증 중..."
|
|
29
|
+
|
|
30
|
+
# outputs 디렉토리 확인
|
|
31
|
+
if [ -d "$stage_dir/outputs" ]; then
|
|
32
|
+
local output_count=$(ls -1 "$stage_dir/outputs" 2>/dev/null | wc -l)
|
|
33
|
+
echo -e " ${GREEN}✓${NC} 출력 파일: $output_count 개"
|
|
34
|
+
fi
|
|
35
|
+
|
|
36
|
+
return 0
|
|
37
|
+
}
|
|
38
|
+
|
|
39
|
+
# 2. HANDOFF.md 생성 알림
|
|
40
|
+
check_handoff() {
|
|
41
|
+
local handoff_file="$PROJECT_ROOT/stages/$STAGE_ID/HANDOFF.md"
|
|
42
|
+
|
|
43
|
+
if [ ! -f "$handoff_file" ]; then
|
|
44
|
+
echo -e " ${YELLOW}⚠${NC} HANDOFF.md 미생성"
|
|
45
|
+
echo " /handoff 를 실행하여 핸드오프 문서를 생성해주세요."
|
|
46
|
+
return 1
|
|
47
|
+
fi
|
|
48
|
+
|
|
49
|
+
echo -e " ${GREEN}✓${NC} HANDOFF.md 존재"
|
|
50
|
+
|
|
51
|
+
# 핸드오프 아카이브
|
|
52
|
+
local archive_name="${STAGE_ID}-$(date +%Y%m%d-%H%M).md"
|
|
53
|
+
cp "$handoff_file" "$PROJECT_ROOT/state/handoffs/$archive_name"
|
|
54
|
+
echo -e " ${GREEN}✓${NC} 핸드오프 아카이브: state/handoffs/$archive_name"
|
|
55
|
+
|
|
56
|
+
return 0
|
|
57
|
+
}
|
|
58
|
+
|
|
59
|
+
# 3. progress.json 업데이트
|
|
60
|
+
update_progress() {
|
|
61
|
+
echo "상태 업데이트 중..."
|
|
62
|
+
|
|
63
|
+
# jq로 상태 업데이트
|
|
64
|
+
if command -v jq &> /dev/null; then
|
|
65
|
+
local tmp_file=$(mktemp)
|
|
66
|
+
jq ".stages.\"$STAGE_ID\".status = \"completed\" | \
|
|
67
|
+
.stages.\"$STAGE_ID\".completed_at = \"$TIMESTAMP\" | \
|
|
68
|
+
.stages.\"$STAGE_ID\".handoff_generated = true | \
|
|
69
|
+
.pipeline.updated_at = \"$TIMESTAMP\"" \
|
|
70
|
+
"$PROGRESS_FILE" > "$tmp_file" && mv "$tmp_file" "$PROGRESS_FILE"
|
|
71
|
+
|
|
72
|
+
echo -e " ${GREEN}✓${NC} progress.json 업데이트됨"
|
|
73
|
+
else
|
|
74
|
+
echo -e " ${YELLOW}⚠${NC} jq 미설치 - 수동 업데이트 필요"
|
|
75
|
+
fi
|
|
76
|
+
|
|
77
|
+
return 0
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# 4. 체크포인트 생성 알림 (필수 스테이지)
|
|
81
|
+
remind_checkpoint() {
|
|
82
|
+
local stage_num=$(echo "$STAGE_ID" | cut -d'-' -f1)
|
|
83
|
+
|
|
84
|
+
if [ "$stage_num" == "06" ] || [ "$stage_num" == "07" ]; then
|
|
85
|
+
echo ""
|
|
86
|
+
echo -e "${BLUE}📌 체크포인트 알림${NC}"
|
|
87
|
+
echo " 이 스테이지는 체크포인트 생성이 권장됩니다."
|
|
88
|
+
echo " /checkpoint \"스테이지 완료\" 를 실행해주세요."
|
|
89
|
+
fi
|
|
90
|
+
}
|
|
91
|
+
|
|
92
|
+
# 5. 다음 스테이지 안내
|
|
93
|
+
show_next_stage() {
|
|
94
|
+
local config_file="$PROJECT_ROOT/stages/$STAGE_ID/config.yaml"
|
|
95
|
+
local next_stage=""
|
|
96
|
+
|
|
97
|
+
if [ -f "$config_file" ]; then
|
|
98
|
+
next_stage=$(grep "next_stage:" "$config_file" | cut -d'"' -f2 | head -1)
|
|
99
|
+
fi
|
|
100
|
+
|
|
101
|
+
echo ""
|
|
102
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
103
|
+
|
|
104
|
+
if [ -z "$next_stage" ] || [ "$next_stage" == "null" ]; then
|
|
105
|
+
echo -e "${GREEN}🎉 파이프라인 완료!${NC}"
|
|
106
|
+
echo " 모든 스테이지가 완료되었습니다."
|
|
107
|
+
else
|
|
108
|
+
echo -e "${GREEN}✓${NC} 스테이지 $STAGE_ID 완료"
|
|
109
|
+
echo ""
|
|
110
|
+
echo -e "${BLUE}다음 스테이지: $next_stage${NC}"
|
|
111
|
+
echo " 실행: /run-stage $next_stage"
|
|
112
|
+
fi
|
|
113
|
+
|
|
114
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
115
|
+
}
|
|
116
|
+
|
|
117
|
+
# 실행
|
|
118
|
+
echo ""
|
|
119
|
+
validate_completion
|
|
120
|
+
check_handoff
|
|
121
|
+
update_progress
|
|
122
|
+
remind_checkpoint
|
|
123
|
+
show_next_stage
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# pre-stage.sh - 스테이지 실행 전 훅
|
|
3
|
+
# ax-templates workflow pipeline
|
|
4
|
+
|
|
5
|
+
set -e
|
|
6
|
+
|
|
7
|
+
STAGE_ID="$1"
|
|
8
|
+
PROJECT_ROOT="$(cd "$(dirname "$0")/../.." && pwd)"
|
|
9
|
+
PROGRESS_FILE="$PROJECT_ROOT/state/progress.json"
|
|
10
|
+
|
|
11
|
+
# 색상 정의
|
|
12
|
+
RED='\033[0;31m'
|
|
13
|
+
GREEN='\033[0;32m'
|
|
14
|
+
YELLOW='\033[1;33m'
|
|
15
|
+
CYAN='\033[0;36m'
|
|
16
|
+
NC='\033[0m' # No Color
|
|
17
|
+
|
|
18
|
+
CONTEXT_TRIGGER_FILE="$PROJECT_ROOT/state/context/auto-trigger.json"
|
|
19
|
+
|
|
20
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
21
|
+
echo "🔍 Pre-Stage Hook: $STAGE_ID"
|
|
22
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
23
|
+
|
|
24
|
+
# 1. 이전 스테이지 완료 여부 확인
|
|
25
|
+
check_prerequisites() {
|
|
26
|
+
local stage_num=$(echo "$STAGE_ID" | cut -d'-' -f1)
|
|
27
|
+
|
|
28
|
+
# 01 스테이지는 전제조건 없음
|
|
29
|
+
if [ "$stage_num" == "01" ]; then
|
|
30
|
+
echo -e "${GREEN}✓${NC} 첫 번째 스테이지 - 전제조건 없음"
|
|
31
|
+
return 0
|
|
32
|
+
fi
|
|
33
|
+
|
|
34
|
+
# 이전 스테이지 번호 계산
|
|
35
|
+
local prev_num=$(printf "%02d" $((10#$stage_num - 1)))
|
|
36
|
+
local prev_stage=$(ls "$PROJECT_ROOT/stages/" | grep "^${prev_num}-" | head -1)
|
|
37
|
+
|
|
38
|
+
if [ -z "$prev_stage" ]; then
|
|
39
|
+
echo -e "${RED}✗${NC} 이전 스테이지를 찾을 수 없습니다: $prev_num"
|
|
40
|
+
return 1
|
|
41
|
+
fi
|
|
42
|
+
|
|
43
|
+
# 이전 스테이지 상태 확인
|
|
44
|
+
local prev_status=$(jq -r ".stages.\"$prev_stage\".status" "$PROGRESS_FILE" 2>/dev/null || echo "pending")
|
|
45
|
+
|
|
46
|
+
if [ "$prev_status" != "completed" ]; then
|
|
47
|
+
echo -e "${RED}✗${NC} 이전 스테이지 미완료: $prev_stage (상태: $prev_status)"
|
|
48
|
+
echo " 먼저 이전 스테이지를 완료해주세요."
|
|
49
|
+
return 1
|
|
50
|
+
fi
|
|
51
|
+
|
|
52
|
+
echo -e "${GREEN}✓${NC} 이전 스테이지 완료: $prev_stage"
|
|
53
|
+
return 0
|
|
54
|
+
}
|
|
55
|
+
|
|
56
|
+
# 2. HANDOFF.md 존재 확인
|
|
57
|
+
check_handoff() {
|
|
58
|
+
local stage_num=$(echo "$STAGE_ID" | cut -d'-' -f1)
|
|
59
|
+
|
|
60
|
+
# 01 스테이지는 핸드오프 불필요
|
|
61
|
+
if [ "$stage_num" == "01" ]; then
|
|
62
|
+
echo -e "${GREEN}✓${NC} 첫 번째 스테이지 - 핸드오프 불필요"
|
|
63
|
+
return 0
|
|
64
|
+
fi
|
|
65
|
+
|
|
66
|
+
local prev_num=$(printf "%02d" $((10#$stage_num - 1)))
|
|
67
|
+
local prev_stage=$(ls "$PROJECT_ROOT/stages/" | grep "^${prev_num}-" | head -1)
|
|
68
|
+
local handoff_file="$PROJECT_ROOT/stages/$prev_stage/HANDOFF.md"
|
|
69
|
+
|
|
70
|
+
if [ ! -f "$handoff_file" ]; then
|
|
71
|
+
echo -e "${RED}✗${NC} HANDOFF.md 없음: $handoff_file"
|
|
72
|
+
echo " 이전 스테이지에서 /handoff 를 실행해주세요."
|
|
73
|
+
return 1
|
|
74
|
+
fi
|
|
75
|
+
|
|
76
|
+
echo -e "${GREEN}✓${NC} HANDOFF.md 존재: $prev_stage/HANDOFF.md"
|
|
77
|
+
return 0
|
|
78
|
+
}
|
|
79
|
+
|
|
80
|
+
# 3. 필수 입력 파일 확인
|
|
81
|
+
check_inputs() {
|
|
82
|
+
local config_file="$PROJECT_ROOT/stages/$STAGE_ID/config.yaml"
|
|
83
|
+
|
|
84
|
+
if [ ! -f "$config_file" ]; then
|
|
85
|
+
echo -e "${YELLOW}⚠${NC} config.yaml 없음 - 입력 파일 검증 스킵"
|
|
86
|
+
return 0
|
|
87
|
+
fi
|
|
88
|
+
|
|
89
|
+
# YAML에서 required inputs 추출 (간단한 파싱)
|
|
90
|
+
local inputs=$(grep -A100 "^inputs:" "$config_file" | grep -A50 "required:" | grep "name:" | head -5)
|
|
91
|
+
|
|
92
|
+
if [ -z "$inputs" ]; then
|
|
93
|
+
echo -e "${GREEN}✓${NC} 필수 입력 파일 없음"
|
|
94
|
+
return 0
|
|
95
|
+
fi
|
|
96
|
+
|
|
97
|
+
echo "필수 입력 파일 확인 중..."
|
|
98
|
+
# 실제 구현에서는 YAML 파서 사용 권장
|
|
99
|
+
echo -e "${GREEN}✓${NC} 입력 파일 검증 완료"
|
|
100
|
+
return 0
|
|
101
|
+
}
|
|
102
|
+
|
|
103
|
+
# 4. 체크포인트 확인 (필수 스테이지)
|
|
104
|
+
check_checkpoint() {
|
|
105
|
+
local stage_num=$(echo "$STAGE_ID" | cut -d'-' -f1)
|
|
106
|
+
|
|
107
|
+
# 06, 07 스테이지는 이전 체크포인트 확인
|
|
108
|
+
if [ "$stage_num" == "07" ]; then
|
|
109
|
+
local cp_count=$(jq '.checkpoints | length' "$PROGRESS_FILE" 2>/dev/null || echo "0")
|
|
110
|
+
|
|
111
|
+
if [ "$cp_count" == "0" ]; then
|
|
112
|
+
echo -e "${YELLOW}⚠${NC} 경고: 체크포인트가 없습니다."
|
|
113
|
+
echo " 리팩토링 전 체크포인트 생성을 권장합니다."
|
|
114
|
+
echo " /checkpoint 를 실행해주세요."
|
|
115
|
+
else
|
|
116
|
+
echo -e "${GREEN}✓${NC} 체크포인트 존재: $cp_count 개"
|
|
117
|
+
fi
|
|
118
|
+
fi
|
|
119
|
+
|
|
120
|
+
return 0
|
|
121
|
+
}
|
|
122
|
+
|
|
123
|
+
# 5. 컨텍스트 상태 확인 (50% 이하 경고)
|
|
124
|
+
check_context_status() {
|
|
125
|
+
if [ ! -f "$CONTEXT_TRIGGER_FILE" ]; then
|
|
126
|
+
echo -e "${GREEN}✓${NC} 컨텍스트 상태 정상"
|
|
127
|
+
return 0
|
|
128
|
+
fi
|
|
129
|
+
|
|
130
|
+
local TRIGGERED=$(jq -r '.triggered // false' "$CONTEXT_TRIGGER_FILE" 2>/dev/null || echo "false")
|
|
131
|
+
local REMAINING=$(jq -r '.remaining // 100' "$CONTEXT_TRIGGER_FILE" 2>/dev/null || echo "100")
|
|
132
|
+
local LEVEL=$(jq -r '.level // "warning"' "$CONTEXT_TRIGGER_FILE" 2>/dev/null || echo "warning")
|
|
133
|
+
|
|
134
|
+
if [ "$TRIGGERED" = "true" ]; then
|
|
135
|
+
echo ""
|
|
136
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
137
|
+
|
|
138
|
+
if [ "$LEVEL" = "critical" ]; then
|
|
139
|
+
echo -e "${RED}⚠️ 컨텍스트 크리티컬 상태 (${REMAINING}% 남음)${NC}"
|
|
140
|
+
echo ""
|
|
141
|
+
echo "자동 스냅샷이 저장되었습니다."
|
|
142
|
+
echo "스테이지 시작 전 /compact 또는 /clear를 권장합니다."
|
|
143
|
+
echo ""
|
|
144
|
+
echo -e "${YELLOW}계속 진행하시겠습니까? (y/n)${NC}"
|
|
145
|
+
else
|
|
146
|
+
echo -e "${YELLOW}⚠️ 컨텍스트 부족 경고 (${REMAINING}% 남음)${NC}"
|
|
147
|
+
echo ""
|
|
148
|
+
echo "자동 스냅샷이 저장되었습니다."
|
|
149
|
+
echo "긴 작업 스테이지의 경우 /compact 실행을 권장합니다."
|
|
150
|
+
echo ""
|
|
151
|
+
echo -e "${CYAN}계속 진행하시겠습니까? (y/n)${NC}"
|
|
152
|
+
fi
|
|
153
|
+
|
|
154
|
+
read -r response </dev/tty 2>/dev/null || response="y"
|
|
155
|
+
|
|
156
|
+
if [ "$response" != "y" ] && [ "$response" != "Y" ]; then
|
|
157
|
+
echo ""
|
|
158
|
+
echo "스테이지 시작이 취소되었습니다."
|
|
159
|
+
echo " → /compact 실행 후 다시 시도해주세요."
|
|
160
|
+
echo " → 스냅샷 위치: state/context/"
|
|
161
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
162
|
+
return 1
|
|
163
|
+
fi
|
|
164
|
+
|
|
165
|
+
echo ""
|
|
166
|
+
echo -e "${GREEN}✓${NC} 사용자 확인 완료 - 스테이지 진행"
|
|
167
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
168
|
+
return 0
|
|
169
|
+
fi
|
|
170
|
+
|
|
171
|
+
echo -e "${GREEN}✓${NC} 컨텍스트 상태 정상"
|
|
172
|
+
return 0
|
|
173
|
+
}
|
|
174
|
+
|
|
175
|
+
# 실행
|
|
176
|
+
echo ""
|
|
177
|
+
check_context_status || exit 1
|
|
178
|
+
check_prerequisites || exit 1
|
|
179
|
+
check_handoff || exit 1
|
|
180
|
+
check_inputs || exit 1
|
|
181
|
+
check_checkpoint
|
|
182
|
+
|
|
183
|
+
echo ""
|
|
184
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
185
|
+
echo -e "${GREEN}✓${NC} Pre-Stage Hook 완료 - 스테이지 실행 가능"
|
|
186
|
+
echo "━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━"
|
|
@@ -0,0 +1,90 @@
|
|
|
1
|
+
#!/bin/bash
|
|
2
|
+
# session-start.sh - 세션 시작 시 자동 복구
|
|
3
|
+
# ax-templates workflow pipeline
|
|
4
|
+
#
|
|
5
|
+
# SessionStart hook: Claude Code 세션 시작/재개 시 실행
|
|
6
|
+
# /compact 후 저장된 스냅샷이 있으면 자동으로 컨텍스트 복구 안내
|
|
7
|
+
|
|
8
|
+
set -e
|
|
9
|
+
|
|
10
|
+
PROJECT_ROOT="$(cd "$(dirname "${BASH_SOURCE[0]}")/../.." && pwd)"
|
|
11
|
+
TRIGGER_FILE="$PROJECT_ROOT/state/context/auto-trigger.json"
|
|
12
|
+
CONTEXT_DIR="$PROJECT_ROOT/state/context"
|
|
13
|
+
PROGRESS_FILE="$PROJECT_ROOT/state/progress.json"
|
|
14
|
+
|
|
15
|
+
# 컨텍스트 디렉토리 확인
|
|
16
|
+
mkdir -p "$CONTEXT_DIR"
|
|
17
|
+
|
|
18
|
+
# jq 필요
|
|
19
|
+
if ! command -v jq &> /dev/null; then
|
|
20
|
+
exit 0
|
|
21
|
+
fi
|
|
22
|
+
|
|
23
|
+
# 1. 트리거 파일 확인 - compact가 실행되었는지
|
|
24
|
+
if [ ! -f "$TRIGGER_FILE" ]; then
|
|
25
|
+
exit 0 # 복구 필요 없음
|
|
26
|
+
fi
|
|
27
|
+
|
|
28
|
+
COMPACT_SCHEDULED=$(jq -r '.compact_scheduled // false' "$TRIGGER_FILE" 2>/dev/null || echo "false")
|
|
29
|
+
if [ "$COMPACT_SCHEDULED" != "true" ]; then
|
|
30
|
+
exit 0 # compact가 예정되지 않았음
|
|
31
|
+
fi
|
|
32
|
+
|
|
33
|
+
# 2. 최근 스냅샷 찾기
|
|
34
|
+
LATEST_SNAPSHOT=$(ls -1t "$CONTEXT_DIR"/auto-snapshot-*.md 2>/dev/null | head -1)
|
|
35
|
+
if [ -z "$LATEST_SNAPSHOT" ]; then
|
|
36
|
+
# 스냅샷 없음 - 트리거 파일 정리
|
|
37
|
+
rm -f "$TRIGGER_FILE"
|
|
38
|
+
exit 0
|
|
39
|
+
fi
|
|
40
|
+
|
|
41
|
+
# 3. 현재 스테이지 정보
|
|
42
|
+
CURRENT_STAGE="none"
|
|
43
|
+
if [ -f "$PROGRESS_FILE" ]; then
|
|
44
|
+
CURRENT_STAGE=$(jq -r '.current_stage // "none"' "$PROGRESS_FILE" 2>/dev/null || echo "none")
|
|
45
|
+
fi
|
|
46
|
+
|
|
47
|
+
# 4. 복구 컨텍스트 생성 (Claude에게 전달)
|
|
48
|
+
RECOVERY_CONTEXT=$(cat << EOF
|
|
49
|
+
|
|
50
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
51
|
+
🔄 세션 복구 - 자동 /compact 후 재시작
|
|
52
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
53
|
+
|
|
54
|
+
## 복구 정보
|
|
55
|
+
- 스냅샷: $(basename "$LATEST_SNAPSHOT")
|
|
56
|
+
- 스테이지: $CURRENT_STAGE
|
|
57
|
+
- 저장 시간: $(jq -r '.timestamp // "unknown"' "$TRIGGER_FILE" 2>/dev/null)
|
|
58
|
+
|
|
59
|
+
## 스냅샷 내용
|
|
60
|
+
$(cat "$LATEST_SNAPSHOT" 2>/dev/null | head -50)
|
|
61
|
+
|
|
62
|
+
## 복구 지침
|
|
63
|
+
1. 위 스냅샷 내용을 참고하여 작업 컨텍스트 파악
|
|
64
|
+
2. stages/$CURRENT_STAGE/CLAUDE.md 확인
|
|
65
|
+
3. 중단된 작업부터 재개
|
|
66
|
+
|
|
67
|
+
━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━━
|
|
68
|
+
EOF
|
|
69
|
+
)
|
|
70
|
+
|
|
71
|
+
# 5. JSON 출력 (Claude에게 컨텍스트 전달)
|
|
72
|
+
# additionalContext를 통해 Claude가 복구 정보를 받음
|
|
73
|
+
cat << EOF
|
|
74
|
+
{
|
|
75
|
+
"hookSpecificOutput": {
|
|
76
|
+
"hookEventName": "SessionStart",
|
|
77
|
+
"additionalContext": $(echo "$RECOVERY_CONTEXT" | jq -Rs .)
|
|
78
|
+
}
|
|
79
|
+
}
|
|
80
|
+
EOF
|
|
81
|
+
|
|
82
|
+
# 6. 트리거 파일 정리 (복구 완료 표시)
|
|
83
|
+
jq '. + {"recovered": true, "recovery_time": "'"$(date -Iseconds)"'"}' \
|
|
84
|
+
"$TRIGGER_FILE" > "$TRIGGER_FILE.tmp" && mv "$TRIGGER_FILE.tmp" "$TRIGGER_FILE"
|
|
85
|
+
|
|
86
|
+
# 일정 시간 후 트리거 파일 삭제 (다음 세션에서 중복 복구 방지)
|
|
87
|
+
# 백그라운드에서 5분 후 삭제
|
|
88
|
+
(sleep 300 && rm -f "$TRIGGER_FILE" 2>/dev/null) &
|
|
89
|
+
|
|
90
|
+
exit 0
|