-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathinstall.sh
More file actions
executable file
·193 lines (166 loc) · 6.72 KB
/
Copy pathinstall.sh
File metadata and controls
executable file
·193 lines (166 loc) · 6.72 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
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
#!/usr/bin/env bash
# Copyright © 2026 MIH AI B.V.
# Licensed under the Apache License, Version 2.0
# See LICENSE file in the project root
# Prism installer
# Usage: ./install.sh
#
# What it does:
# 1. Checks prerequisites (python3, git required; claude or agent CLI recommended)
# 2. Creates ~/.prism/ directory tree
# 3. Copies hooks, agent prompts, lib, and templates
# 4. Creates a symlink so `prism` is on your PATH
#
# After install, run `prism init` in any project to set up hooks for that project.
set -euo pipefail
PRISM_REPO="$(cd "$(dirname "$0")" && pwd)"
PRISM_HOME="${PRISM_HOME:-$HOME/.prism}"
BIN_DIR="${BIN_DIR:-$HOME/.local/bin}"
# --- Prerequisite checks ---
# python3 is required (hard fail)
command -v python3 >/dev/null 2>&1 || { echo "ERROR: python3 is required but not found."; exit 1; }
# git is required (hard fail)
command -v git >/dev/null 2>&1 || { echo "ERROR: git is required but not found."; exit 1; }
# claude CLI is optional (soft warning) — Claude Code extraction path
command -v claude >/dev/null 2>&1 || echo "WARNING: claude CLI not found. Needed for Claude Code extraction (prism extract) but not for observation capture."
# Cursor agent CLI is optional (soft warning) — Cursor extraction path
command -v agent >/dev/null 2>&1 || command -v cursor-agent >/dev/null 2>&1 || echo "WARNING: agent CLI not found. Cursor-only users need it for extraction. Install: curl https://cursor.com/install -fsS | bash"
# Python version warning
PY_VERSION=$(python3 -c 'import sys; print(f"{sys.version_info.major}.{sys.version_info.minor}")' 2>/dev/null || echo '0.0')
PY_MAJOR=$(echo "$PY_VERSION" | cut -d. -f1)
PY_MINOR=$(echo "$PY_VERSION" | cut -d. -f2)
if [ "$PY_MAJOR" -lt 3 ] || { [ "$PY_MAJOR" -eq 3 ] && [ "$PY_MINOR" -lt 12 ]; }; then
echo "WARNING: Python 3.12+ recommended (found $PY_VERSION). Prism should work but is untested on older versions."
fi
echo "Installing Prism..."
echo " Source: $PRISM_REPO"
echo " Home: $PRISM_HOME"
echo " Binary: $BIN_DIR/prism"
echo ""
# 1. Create directory structure (SETUP-01)
mkdir -p "$PRISM_HOME"/{global/engrams,archive,hooks,agents,lib,skills,projects,cache}
mkdir -p "$BIN_DIR"
# 2. Copy hooks (overwrite on upgrade)
cp "$PRISM_REPO/hooks/capture.sh" "$PRISM_HOME/hooks/capture.sh"
cp "$PRISM_REPO/hooks/capture_cursor.sh" "$PRISM_HOME/hooks/capture_cursor.sh"
chmod +x "$PRISM_HOME/hooks/capture.sh"
chmod +x "$PRISM_HOME/hooks/capture_cursor.sh"
# 3. Copy agent prompts (overwrite on upgrade)
cp "$PRISM_REPO/agents/"*.md "$PRISM_HOME/agents/"
# 4. Copy lib (overwrite on upgrade)
for pyfile in "$PRISM_REPO"/lib/*.py; do
[ -f "$pyfile" ] || continue
case "$(basename "$pyfile")" in
test_*) continue ;; # Exclude test files from install
esac
cp "$pyfile" "$PRISM_HOME/lib/"
done
# Copy lib data files (e.g. lexicon.json loaded at runtime by lexicon.py)
for datafile in "$PRISM_REPO"/lib/*.json; do
[ -f "$datafile" ] || continue
cp "$datafile" "$PRISM_HOME/lib/"
done
# Copy lib asset files (e.g. dashboard.html served by dashboard.py)
for asset in "$PRISM_REPO"/lib/*.html; do
[ -f "$asset" ] || continue
cp "$asset" "$PRISM_HOME/lib/"
done
# 4b. Copy slash command skills (overwrite on upgrade)
if [ -d "$PRISM_REPO/skills" ]; then
for skill_dir in "$PRISM_REPO/skills"/*/; do
[ -d "$skill_dir" ] || continue
skill_name=$(basename "$skill_dir")
mkdir -p "$PRISM_HOME/skills/$skill_name"
cp "$skill_dir"* "$PRISM_HOME/skills/$skill_name/" 2>/dev/null || true
done
fi
# 4c. Copy registry template (overwrite on upgrade)
if [ -d "$PRISM_REPO/templates/registry" ]; then
mkdir -p "$PRISM_HOME/templates/registry"
cp -r "$PRISM_REPO/templates/registry/." "$PRISM_HOME/templates/registry/"
echo " Copied registry template"
fi
# 4d. Copy schemas (overwrite on upgrade)
if [ -d "$PRISM_REPO/schemas" ]; then
mkdir -p "$PRISM_HOME/schemas"
cp "$PRISM_REPO/schemas/"*.json "$PRISM_HOME/schemas/" 2>/dev/null || true
fi
# 5. Copy CLI wrapper (overwrite on upgrade)
cp "$PRISM_REPO/prism" "$PRISM_HOME/prism"
chmod +x "$PRISM_HOME/prism"
# 6. Copy constitution template only if not exists (SETUP-04)
if [ ! -f "$PRISM_HOME/constitution.md" ]; then
cp "$PRISM_REPO/templates/constitution.md" "$PRISM_HOME/constitution.md"
fi
# 7. Write default config.json if missing (SETUP-03)
if [ ! -f "$PRISM_HOME/config.json" ]; then
cat > "$PRISM_HOME/config.json" << 'EOF'
{
"extract_threshold": 15,
"agent_backend": "auto",
"mixed_backend_preference": "cursor",
"cursor_models": {
"fast": "composer-2.5[fast=false]",
"strong": "claude-4.6-sonnet-medium"
},
"review_interval": 5,
"review_cooldown_seconds": 1800,
"review_timeout": 60,
"decay_rate_per_week": 0.05,
"archive_threshold": 0.2,
"publish_min_confidence": 0.7,
"publish_min_evidence": 3,
"max_context_lines": 100,
"registry_url": ""
}
EOF
fi
# 8. Write empty index.json if missing (SETUP-03)
if [ ! -f "$PRISM_HOME/index.json" ]; then
echo '{"engrams": []}' > "$PRISM_HOME/index.json"
fi
# 8b. Seed registries.json with the public registry if not yet configured (SETUP-05)
if [ ! -f "$PRISM_HOME/registries.json" ]; then
cat > "$PRISM_HOME/registries.json" << 'EOF'
{
"registries": [
{
"name": "prism-open-source",
"url": "https://prism-registry.prism-flume.workers.dev",
"token": "prism_8648b53b4c66e15bbd2966d0e60eda96b3517d3ad6fddd5485f5a5a40488f096",
"writable": false
}
],
"default": "prism-open-source"
}
EOF
chmod 600 "$PRISM_HOME/registries.json"
fi
# 9. Record install metadata for version checks
cp "$PRISM_REPO/VERSION" "$PRISM_HOME/VERSION" 2>/dev/null || true
git -C "$PRISM_REPO" rev-parse HEAD > "$PRISM_HOME/.commit" 2>/dev/null || true
echo "$PRISM_REPO" > "$PRISM_HOME/.install_source"
git -C "$PRISM_REPO" remote get-url origin > "$PRISM_HOME/.source_url" 2>/dev/null || true
# Invalidate stale update cache after an upgrade
rm -f "$PRISM_HOME/.update_cache"
# 10. Create symlink (SETUP-02)
# Symlinks to the installed copy so updates via install.sh are picked up
ln -sf "$PRISM_HOME/prism" "$BIN_DIR/prism"
# 11. Check PATH
if ! echo "$PATH" | tr ':' '\n' | grep -qxF "$BIN_DIR"; then
echo "NOTE: $BIN_DIR is not in your PATH."
echo "Add this to your shell profile (~/.zshrc or ~/.bashrc):"
echo ""
echo " export PATH=\"$BIN_DIR:\$PATH\""
echo ""
fi
echo "Done!"
echo ""
echo "Next: cd into a project and run:"
echo ""
echo " prism init # hooks into Claude Code for this project"
# Note on dual-path install (SETUP-07):
# When run from a git clone, PRISM_REPO is the repo root and all source
# files are available. For a curl|bash distribution model, files would
# need to be bundled/extracted first. The primary install path is
# git clone for now (repo is private).