-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsetup.sh
More file actions
executable file
·124 lines (105 loc) · 4.22 KB
/
Copy pathsetup.sh
File metadata and controls
executable file
·124 lines (105 loc) · 4.22 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
#!/bin/sh
set -e
# Factory Setup Script
#
# Run this from the HOST PROJECT ROOT after adding factory as a submodule:
#
# git submodule add https://github.com/custodyzero/factory.git .factory
# ./.factory/setup.sh
#
# Layout after setup:
# .factory/ — tooling (git submodule, hidden)
# factory/ — artifacts (features, packets, completions)
#
# What this script does:
# 1. Installs factory dependencies (inside .factory/)
# 2. Copies template files to host project root (no-clobber)
# 3. Creates artifact directories under factory/
# 4. Seeds host-project memory + cache directories
# 5. Configures git hooks
SCRIPT_DIR="$(cd "$(dirname "$0")" && pwd)"
PROJECT_ROOT="$(cd "${SCRIPT_DIR}/.." && pwd)"
FACTORY_DIR="$(basename "$SCRIPT_DIR")"
ARTIFACT_DIR="factory"
echo ""
echo "Factory Setup"
echo "============="
echo " Project root: ${PROJECT_ROOT}"
echo " Tooling dir: ${FACTORY_DIR}/ (submodule)"
echo " Artifact dir: ${ARTIFACT_DIR}/ (features, packets, completions)"
echo ""
# ── 1. Install factory dependencies ──────────────────────────────────────────
echo "Installing factory dependencies..."
cd "$SCRIPT_DIR"
if command -v pnpm >/dev/null 2>&1; then
pnpm install --frozen-lockfile 2>/dev/null || pnpm install
elif command -v npm >/dev/null 2>&1; then
npm ci 2>/dev/null || npm install
else
echo "ERROR: Neither pnpm nor npm found. Node.js is required for factory tooling."
exit 1
fi
cd "$PROJECT_ROOT"
# ── 2. Copy template files (no-clobber) ─────────────────────────────────────
copy_template() {
src="$1"
dest="$2"
if [ -f "$dest" ]; then
echo " SKIP ${dest} (already exists)"
else
cp "$src" "$dest"
echo " COPY ${dest}"
fi
}
echo ""
echo "Copying template files..."
copy_template "${FACTORY_DIR}/templates/factory.config.json" "factory.config.json"
copy_template "${FACTORY_DIR}/templates/CLAUDE.md" "CLAUDE.md"
copy_template "${FACTORY_DIR}/templates/AGENTS.md" "AGENTS.md"
# ── 3. Create artifact directories ──────────────────────────────────────────
echo ""
echo "Creating artifact directories..."
for subdir in intents features packets completions; do
mkdir -p "${ARTIFACT_DIR}/${subdir}"
echo " MKDIR ${ARTIFACT_DIR}/${subdir}/"
done
# ── 4. Seed host-project memory + cache directories ─────────────────────────
echo ""
echo "Creating memory and cache directories..."
for subdir in \
memory \
memory/architectural-facts \
memory/recurring-failures \
memory/project-conventions \
memory/code-patterns \
memory/suggestions \
cache
do
mkdir -p "${ARTIFACT_DIR}/${subdir}"
echo " MKDIR ${ARTIFACT_DIR}/${subdir}/"
done
copy_template "${FACTORY_DIR}/templates/memory.md" "${ARTIFACT_DIR}/memory/MEMORY.md"
if [ -f ".gitignore" ]; then
if ! grep -qx "${ARTIFACT_DIR}/cache/" ".gitignore"; then
printf "\n%s\n" "${ARTIFACT_DIR}/cache/" >> ".gitignore"
echo " APPEND .gitignore -> ${ARTIFACT_DIR}/cache/"
else
echo " SKIP .gitignore (${ARTIFACT_DIR}/cache/ already present)"
fi
fi
# ── 5. Configure git hooks ──────────────────────────────────────────────────
echo ""
echo "Configuring git hooks..."
git config core.hooksPath "${FACTORY_DIR}/hooks"
echo " Set core.hooksPath = ${FACTORY_DIR}/hooks"
# ── Done ─────────────────────────────────────────────────────────────────────
echo ""
echo "Factory setup complete."
echo ""
echo "Next steps:"
echo " 1. Edit factory.config.json — set project_name and verification commands"
echo " 2. Edit CLAUDE.md — customize for your project"
echo " 3. Create a spec under specs/<spec-id>.md and run:"
echo " npx tsx ${FACTORY_DIR}/tools/run.ts <spec-id>"
echo " (hand-authored intents under ${ARTIFACT_DIR}/intents/ remain supported for back-compat)"
echo ""