-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathinit.sh
More file actions
executable file
·155 lines (136 loc) · 4.43 KB
/
Copy pathinit.sh
File metadata and controls
executable file
·155 lines (136 loc) · 4.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
#!/usr/bin/env bash
set -euo pipefail
usage() {
echo "usage: $0 --target PATH" >&2
}
if [[ $# -ne 2 || "$1" != "--target" || -z "$2" ]]; then
usage
exit 2
fi
SOURCE_ROOT="$(CDPATH= cd -- "$(dirname -- "$0")" && pwd -P)"
TARGET="$2"
if [[ -e "$TARGET" && ! -d "$TARGET" ]]; then
echo "initialization failed: target is not a directory: $TARGET" >&2
exit 1
fi
mkdir -p -- "$TARGET"
TARGET="$(CDPATH= cd -- "$TARGET" && pwd -P)"
STAGING="$(mktemp -d "${TMPDIR:-/tmp}/coding-context-framework-init.XXXXXX")"
trap 'rm -rf -- "$STAGING"' EXIT
files=(
AGENTS.md
CLAUDE.md
ARCHITECTURE.md
VERSION
scripts/task
tasks/board.yaml
tasks/task.schema.json
tests/__init__.py
tests/helpers.py
tests/test_claude_compat.py
.agents/skills/task-board/SKILL.md
.agents/skills/task-board/scripts/task
.agents/skills/task-plan/SKILL.md
.agents/skills/task-plan/scripts/check-task-plan.sh
.agents/skills/plan-go/SKILL.md
.agents/skills/plan-go/agents/openai.yaml
.agents/skills/plan-go/LICENSE
.agents/skills/plan-go/scripts/loop-evidence
.agents/skills/plan-go/scripts/loop_evidence.py
.agents/skills/plan-go/scripts/loop_spec.sh
.agents/skills/herdr-workflow/SKILL.md
.agents/skills/herdr-workflow/references/evaluation.md
docs/domains/index.md
docs/domains/general.md
docs/design-docs/layered-testing-practice.md
docs/exec-plans/_template.md
docs/generated/evidence/templates/evidence-manifest.yaml
docs/generated/evidence/templates/integration-cases.md
docs/generated/evidence/templates/validation-report.md
docs/agent-routing.md
)
claude_skills=(task-board task-plan plan-go herdr-workflow)
for relative in "${files[@]}"; do
source_file="$SOURCE_ROOT/$relative"
if [[ ! -f "$source_file" ]]; then
echo "initialization failed: source file is missing: $relative" >&2
exit 1
fi
mkdir -p -- "$STAGING/$(dirname -- "$relative")"
cp -- "$source_file" "$STAGING/$relative"
done
conflicts=()
migrate_legacy_claude_md=false
migrate_legacy_claude_skills=false
if [[ -L "$TARGET/CLAUDE.md" && "$(readlink "$TARGET/CLAUDE.md")" == "AGENTS.md" ]]; then
migrate_legacy_claude_md=true
fi
if [[ -L "$TARGET/.claude/skills" ]]; then
if [[ "$(readlink "$TARGET/.claude/skills")" == "../.agents/skills" ]]; then
migrate_legacy_claude_skills=true
else
conflicts+=(".claude/skills")
fi
elif [[ -e "$TARGET/.claude/skills" && ! -d "$TARGET/.claude/skills" ]]; then
conflicts+=(".claude/skills")
fi
for relative in "${files[@]}"; do
destination="$TARGET/$relative"
if [[ "$relative" == "CLAUDE.md" && "$migrate_legacy_claude_md" == true ]]; then
continue
fi
if [[ -e "$destination" || -L "$destination" ]]; then
if [[ ! -f "$destination" ]] || ! cmp -s -- "$STAGING/$relative" "$destination"; then
conflicts+=("$relative")
fi
fi
done
if [[ "$migrate_legacy_claude_skills" != true ]]; then
for name in "${claude_skills[@]}"; do
relative=".claude/skills/$name"
destination="$TARGET/$relative"
expected_target="../../.agents/skills/$name"
if [[ -L "$destination" ]]; then
if [[ "$(readlink "$destination")" != "$expected_target" ]]; then
conflicts+=("$relative")
fi
elif [[ -e "$destination" ]]; then
conflicts+=("$relative")
fi
done
fi
if (( ${#conflicts[@]} > 0 )); then
echo "initialization failed: refusing to overwrite changed files:" >&2
for relative in "${conflicts[@]}"; do
echo " $relative" >&2
done
exit 1
fi
for relative in "${files[@]}"; do
destination="$TARGET/$relative"
if [[ "$relative" == "CLAUDE.md" && "$migrate_legacy_claude_md" == true ]]; then
unlink "$destination"
fi
if [[ ! -e "$destination" ]]; then
mkdir -p -- "$(dirname -- "$destination")"
cp -- "$STAGING/$relative" "$destination"
fi
done
if [[ "$migrate_legacy_claude_skills" == true ]]; then
unlink "$TARGET/.claude/skills"
fi
mkdir -p -- "$TARGET/.claude/skills"
for name in "${claude_skills[@]}"; do
destination="$TARGET/.claude/skills/$name"
if [[ ! -e "$destination" && ! -L "$destination" ]]; then
ln -s "../../.agents/skills/$name" "$destination"
fi
done
chmod +x \
"$TARGET/scripts/task" \
"$TARGET/.agents/skills/task-board/scripts/task" \
"$TARGET/.agents/skills/task-plan/scripts/check-task-plan.sh" \
"$TARGET/.agents/skills/plan-go/scripts/loop-evidence" \
"$TARGET/.agents/skills/plan-go/scripts/loop_evidence.py" \
"$TARGET/.agents/skills/plan-go/scripts/loop_spec.sh"
echo "initialized Coding Context Framework in $TARGET"