-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathsetup
More file actions
executable file
·465 lines (419 loc) · 17.9 KB
/
setup
File metadata and controls
executable file
·465 lines (419 loc) · 17.9 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
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
#!/usr/bin/env bash
# nanopm setup — install nanopm skills into Claude Code, Mistral Vibe, or OpenAI Codex
# Usage: curl -fsSL https://raw.githubusercontent.com/nmrtn/nanopm/main/setup | bash
# curl -fsSL https://raw.githubusercontent.com/nmrtn/nanopm/main/setup | bash -s -- --host=vibe
# bash setup [--host=auto|claude|vibe|codex|all]
set -euo pipefail
NANOPM_VERSION="0.6.4"
NANOPM_REPO="https://github.com/nmrtn/nanopm"
NANOPM_RAW="https://raw.githubusercontent.com/nmrtn/nanopm/main"
GLOBAL_CONFIG_DIR="$HOME/.nanopm"
# ── colors ────────────────────────────────────────────────────────────────────
_bold() { printf '\033[1m%s\033[0m' "$*"; }
_green() { printf '\033[0;32m%s\033[0m' "$*"; }
_yellow(){ printf '\033[0;33m%s\033[0m' "$*"; }
_red() { printf '\033[0;31m%s\033[0m' "$*"; }
# ── helpers ───────────────────────────────────────────────────────────────────
step() { echo; printf ' %s %s\n' "$(_bold '→')" "$*"; }
ok() { printf ' %s %s\n' "$(_green '✓')" "$*"; }
warn() { printf ' %s %s\n' "$(_yellow '⚠')" "$*"; }
fail() { printf ' %s %s\n' "$(_red '✗')" "$*"; echo; exit 1; }
# ── parse arguments ───────────────────────────────────────────────────────────
_HOST="auto"
while [ "$#" -gt 0 ]; do
case "$1" in
--host=*) _HOST="${1#--host=}"; shift ;;
--host) shift; _HOST="${1:-auto}"; shift ;;
*) shift ;;
esac
done
# ── detect install source ─────────────────────────────────────────────────────
# Running from piped curl: download files. Running locally: copy from repo root.
_SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]:-/dev/stdin}")" 2>/dev/null && pwd || echo "")"
if [ -f "$_SCRIPT_DIR/lib/nanopm.sh" ]; then
_SOURCE="local"
_REPO_ROOT="$_SCRIPT_DIR"
else
_SOURCE="remote"
_REPO_ROOT=""
fi
# ── banner ────────────────────────────────────────────────────────────────────
echo
echo " $(_bold 'nanopm') v${NANOPM_VERSION} — PM automation for AI coding agents"
echo " $NANOPM_REPO"
echo
# ── resolve --host ─────────────────────────────────────────────────────────────
# auto: detect which agents are installed and install to all of them
if [ "$_HOST" = "auto" ]; then
_HOST="claude"
command -v vibe >/dev/null 2>&1 && _HOST="${_HOST},vibe"
command -v codex >/dev/null 2>&1 && _HOST="${_HOST},codex"
fi
# Build _TARGETS array: "name:dir" entries
_TARGETS=()
case ",$_HOST," in
*,claude,*|*,all,*) _TARGETS+=("claude:$HOME/.claude/skills") ;;
esac
case ",$_HOST," in
*,vibe,*|*,all,*) _TARGETS+=("vibe:$HOME/.vibe/skills") ;;
esac
case ",$_HOST," in
*,codex,*|*,all,*) _TARGETS+=("codex:$HOME/.codex/skills") ;;
esac
case ",$_HOST," in
*,agents,*|*,all,*) _TARGETS+=("agents:$HOME/.agents/skills") ;;
esac
if [ "${#_TARGETS[@]}" -eq 0 ]; then
fail "Unknown --host value '$_HOST'. Use: auto, claude, vibe, codex, all, or comma-separated combo."
fi
# ── preflight checks ──────────────────────────────────────────────────────────
step "Checking host(s): $_HOST"
_VALID_TARGETS=()
for _te in "${_TARGETS[@]}"; do
_tname="${_te%%:*}"
_tdir="${_te##*:}"
case "$_tname" in
claude)
if [ ! -d "$HOME/.claude" ]; then
warn "Claude Code not found at ~/.claude — skipping (install from https://claude.ai/claude-code)"
else
ok "Claude Code found → $_tdir"
_VALID_TARGETS+=("$_te")
fi
;;
vibe)
if ! command -v vibe >/dev/null 2>&1 && [ ! -d "$HOME/.vibe" ]; then
warn "Mistral Vibe not found — skipping (install from https://mistral.ai/fr/products/vibe)"
else
ok "Mistral Vibe found → $_tdir"
_VALID_TARGETS+=("$_te")
fi
;;
codex)
if ! command -v codex >/dev/null 2>&1 && [ ! -d "$HOME/.codex" ]; then
warn "OpenAI Codex not found — skipping (install from https://github.com/openai/codex)"
else
ok "OpenAI Codex found → $_tdir"
_VALID_TARGETS+=("$_te")
fi
;;
agents)
ok "Agent Skills path → $_tdir"
_VALID_TARGETS+=("$_te")
;;
esac
done
if [ "${#_VALID_TARGETS[@]}" -eq 0 ]; then
fail "No supported hosts found. Install Claude Code, Mistral Vibe, or OpenAI Codex first."
fi
_TARGETS=("${_VALID_TARGETS[@]}")
# curl (needed for remote installs)
if [ "$_SOURCE" = "remote" ] && ! command -v curl >/dev/null 2>&1; then
fail "curl not found. Install curl and retry."
fi
# python3 (needed for skill translation)
if ! command -v python3 >/dev/null 2>&1; then
fail "python3 not found. Install Python 3 and retry."
fi
# git (optional but warn)
if ! command -v git >/dev/null 2>&1; then
warn "git not found — /pm-retro will need git history to detect drift"
fi
# ── create directories ────────────────────────────────────────────────────────
step "Creating directories"
for _te in "${_TARGETS[@]}"; do
mkdir -p "${_te##*:}"
done
mkdir -p "$GLOBAL_CONFIG_DIR/lib"
mkdir -p "$GLOBAL_CONFIG_DIR/connectors"
mkdir -p "$GLOBAL_CONFIG_DIR/memory"
ok "Directories ready"
# ── copy / download files ─────────────────────────────────────────────────────
_install_file() {
local src_path="$1" # relative path from repo root
local dst_path="$2" # absolute destination path
local dst_dir
dst_dir="$(dirname "$dst_path")"
mkdir -p "$dst_dir"
if [ "$_SOURCE" = "local" ]; then
cp "$_REPO_ROOT/$src_path" "$dst_path"
else
curl -fsSL "$NANOPM_RAW/$src_path" -o "$dst_path"
fi
}
# ── translation functions ─────────────────────────────────────────────────────
# Translate a Claude SKILL.md for Mistral Vibe:
# - Remap PascalCase tool names → snake_case in allowed-tools frontmatter
# - Convert comma-separated list → space-separated (Vibe format)
_translate_skill_for_vibe() {
local src="$1" dst="$2"
mkdir -p "$(dirname "$dst")"
python3 - "$src" "$dst" <<'PYEOF'
import sys
src, dst = sys.argv[1], sys.argv[2]
tool_map = {
'Bash': 'bash',
'Read': 'read_file',
'Write': 'write_file',
'Edit': 'search_replace',
'Glob': None, # no Glob in Vibe — drop
'Grep': 'grep',
'AskUserQuestion': 'ask_user_question',
'Agent': 'task',
'WebFetch': 'webfetch',
'WebSearch': 'webfetch', # closest equivalent
'TodoWrite': None, # no equivalent — drop
}
with open(src) as f:
text = f.read()
def translate_tools(tools_str):
tools = [t.strip() for t in tools_str.split(',')]
mapped = [tool_map.get(t, t.lower()) for t in tools]
mapped = [t for t in mapped if t] # drop None values
return ' '.join(mapped)
in_front = False
lines = text.split('\n')
out = []
for line in lines:
if line.strip() == '---':
in_front = not in_front
out.append(line)
continue
if in_front and line.startswith('allowed-tools:'):
tools_part = line[len('allowed-tools:'):].strip()
out.append('allowed-tools: ' + translate_tools(tools_part))
else:
out.append(line)
with open(dst, 'w') as f:
f.write('\n'.join(out))
PYEOF
}
# Translate a Claude SKILL.md for OpenAI Codex:
# - Strip allowed-tools from frontmatter entirely (Codex ignores/rejects it)
_translate_skill_for_codex() {
local src="$1" dst="$2"
mkdir -p "$(dirname "$dst")"
python3 - "$src" "$dst" <<'PYEOF'
import sys
src, dst = sys.argv[1], sys.argv[2]
with open(src) as f:
text = f.read()
in_front = False
lines = text.split('\n')
out = []
for line in lines:
if line.strip() == '---':
in_front = not in_front
out.append(line)
continue
if in_front and line.startswith('allowed-tools:'):
continue # drop it
out.append(line)
with open(dst, 'w') as f:
f.write('\n'.join(out))
PYEOF
}
# ── install shared runtime ────────────────────────────────────────────────────
step "Installing lib/nanopm.sh and ETHOS.md"
_install_file "lib/nanopm.sh" "$GLOBAL_CONFIG_DIR/lib/nanopm.sh"
chmod +x "$GLOBAL_CONFIG_DIR/lib/nanopm.sh"
_install_file "ETHOS.md" "$GLOBAL_CONFIG_DIR/ETHOS.md"
ok "lib/nanopm.sh and ETHOS.md installed"
step "Installing state binaries"
mkdir -p "$GLOBAL_CONFIG_DIR/bin"
# Remove deprecated binaries from prior versions (v0.6.0 dropped telemetry)
for _stale in nanopm-telemetry-log nanopm-telemetry-sync nanopm-analytics; do
[ -e "$GLOBAL_CONFIG_DIR/bin/$_stale" ] && rm -f "$GLOBAL_CONFIG_DIR/bin/$_stale"
done
# Remove deprecated supabase config dir
[ -d "$GLOBAL_CONFIG_DIR/supabase" ] && rm -rf "$GLOBAL_CONFIG_DIR/supabase"
# Remove deprecated analytics/sessions dirs
[ -d "$GLOBAL_CONFIG_DIR/analytics" ] && rm -rf "$GLOBAL_CONFIG_DIR/analytics"
[ -d "$GLOBAL_CONFIG_DIR/sessions" ] && rm -rf "$GLOBAL_CONFIG_DIR/sessions"
_install_file "bin/nanopm-state-log" "$GLOBAL_CONFIG_DIR/bin/nanopm-state-log"
_install_file "bin/nanopm-state-read" "$GLOBAL_CONFIG_DIR/bin/nanopm-state-read"
chmod +x "$GLOBAL_CONFIG_DIR/bin/nanopm-state-log"
chmod +x "$GLOBAL_CONFIG_DIR/bin/nanopm-state-read"
ok "State binaries installed (typed JSONL under ~/.nanopm/projects/)"
step "Installing connectors"
for connector in README.md linear.md notion.md dovetail.md github.md productboard.md; do
_install_file "connectors/$connector" "$GLOBAL_CONFIG_DIR/connectors/$connector"
done
ok "Connectors installed"
# ── install skills ────────────────────────────────────────────────────────────
step "Installing skills"
_SKILL_LIST="pm-scan pm-discovery pm-audit pm-objectives pm-strategy pm-roadmap pm-prd pm-breakdown pm-retro pm-run pm-upgrade pm-user-feedback pm-competitors-intel pm-interview pm-standup pm-weekly-update pm-data"
for skill in $_SKILL_LIST; do
# Download/copy source SKILL.md to a temp file once
_SKILL_TMP=$(mktemp)
if [ "$_SOURCE" = "local" ]; then
cp "$_REPO_ROOT/$skill/SKILL.md" "$_SKILL_TMP"
else
curl -fsSL "$NANOPM_RAW/$skill/SKILL.md" -o "$_SKILL_TMP"
fi
# Install to each target with the appropriate translation
for _te in "${_TARGETS[@]}"; do
_tname="${_te%%:*}"
_tdir="${_te##*:}"
mkdir -p "$_tdir/$skill"
case "$_tname" in
claude|agents)
cp "$_SKILL_TMP" "$_tdir/$skill/SKILL.md"
;;
vibe)
_translate_skill_for_vibe "$_SKILL_TMP" "$_tdir/$skill/SKILL.md"
;;
codex)
_translate_skill_for_codex "$_SKILL_TMP" "$_tdir/$skill/SKILL.md"
;;
esac
done
rm -f "$_SKILL_TMP"
ok " $skill"
done
# ── global config init ────────────────────────────────────────────────────────
step "Initializing global config"
_CONFIG="$GLOBAL_CONFIG_DIR/config"
if [ ! -f "$_CONFIG" ]; then
cat > "$_CONFIG" <<'EOF'
# nanopm global config
# Managed by nanopm. Edit manually or via nanopm_config_set.
# Format: key=value (one per line, no quotes)
EOF
ok "Config initialized at ~/.nanopm/config"
else
# Clean up duplicate lines (legacy setup scripts appended on each run instead
# of deduping) and prune deprecated keys (telemetry was removed in v0.6.0).
_CONFIG_TMP=$(mktemp "${_CONFIG}.tmp.XXXXXX") || _CONFIG_TMP=""
if [ -n "$_CONFIG_TMP" ]; then
# Single-pass awk:
# - Drop deprecated keys (telemetry=...)
# - Pass through comments and blank lines
# - Dedupe KEY=VALUE lines (last write wins, original order preserved)
if awk -F= '
BEGIN { n = 0 }
# Deprecated keys to strip
/^telemetry=/ { next }
# Comments and blank lines pass through immediately
/^#/ { print; next }
/^$/ { print; next }
# Valid key=value: stash latest, remember first-seen order
/^[A-Za-z_][A-Za-z0-9_]*=/ {
if (!(($1) in seen)) { order[++n] = $1; seen[$1] = 1 }
last[$1] = $0
next
}
# Anything else: pass through unchanged
{ print }
END {
for (i = 1; i <= n; i++) print last[order[i]]
}
' "$_CONFIG" > "$_CONFIG_TMP" 2>/dev/null; then
mv "$_CONFIG_TMP" "$_CONFIG"
ok "Config preserved (deprecated keys pruned, duplicates collapsed)"
else
rm -f "$_CONFIG_TMP"
ok "Config preserved (cleanup skipped — awk unavailable?)"
fi
else
ok "Config preserved"
fi
fi
# Write installed version to ~/.nanopm/VERSION (used by update check).
# Clear the update-check cache so the next preamble does a fresh fetch
# instead of comparing against a stale cached remote version.
echo "$NANOPM_VERSION" > "$GLOBAL_CONFIG_DIR/VERSION"
rm -f "$GLOBAL_CONFIG_DIR/last-update-check"
ok "Version $NANOPM_VERSION written to ~/.nanopm/VERSION (update cache cleared)"
# ── project-level .gitignore ──────────────────────────────────────────────────
# Only if we're inside a git repo right now (running from a project directory)
step "Checking .gitignore"
_GIT_ROOT=$(git rev-parse --show-toplevel 2>/dev/null || echo "")
if [ -n "$_GIT_ROOT" ]; then
_GITIGNORE="$_GIT_ROOT/.gitignore"
if [ -f "$_GITIGNORE" ]; then
if grep -q "^\.nanopm/" "$_GITIGNORE" 2>/dev/null; then
ok ".nanopm/ already in .gitignore"
else
echo "" >> "$_GITIGNORE"
echo "# nanopm — local PM state (not for version control)" >> "$_GITIGNORE"
echo ".nanopm/" >> "$_GITIGNORE"
ok "Added .nanopm/ to .gitignore"
fi
else
cat >> "$_GIT_ROOT/.gitignore" <<'EOF'
# nanopm — local PM state (not for version control)
.nanopm/
EOF
ok "Created .gitignore with .nanopm/"
fi
else
ok "Not in a git repo — skipping .gitignore"
fi
# ── verify installation ───────────────────────────────────────────────────────
step "Verifying installation"
_ERRORS=0
for _te in "${_TARGETS[@]}"; do
_tname="${_te%%:*}"
_tdir="${_te##*:}"
_te_errors=0
for skill in $_SKILL_LIST; do
if [ ! -f "$_tdir/$skill/SKILL.md" ]; then
warn "MISSING: [$_tname] $skill/SKILL.md"
_ERRORS=$(( _ERRORS + 1 ))
_te_errors=$(( _te_errors + 1 ))
fi
done
if [ "$_te_errors" -eq 0 ]; then
ok "[$_tname] all 13 skills verified at $_tdir"
fi
done
if [ "$_ERRORS" -gt 0 ]; then
fail "$_ERRORS skill(s) failed to install. Check your network connection and retry."
fi
# ── check for browse binary (optional, enables Tier 3 data) ──────────────────
step "Checking browser capability (optional, enables Tier 3 data)"
if [ -x "$HOME/.nanopm/bin/browse" ]; then
ok "Browse binary found (~/.nanopm/bin/browse) — Tier 3 connectors available"
else
warn "No browse binary found — Tier 3 (browser) connectors will be skipped"
warn "Tier 1 (MCP), Tier 2 (API), and Tier 4 (manual) work without it."
fi
# ── done ──────────────────────────────────────────────────────────────────────
_INSTALLED_NAMES=""
for _te in "${_TARGETS[@]}"; do
_n="${_te%%:*}"
if [ -n "$_INSTALLED_NAMES" ]; then
_INSTALLED_NAMES="${_INSTALLED_NAMES}, ${_n}"
else
_INSTALLED_NAMES="$_n"
fi
done
echo
echo " $(_bold "$(_green "nanopm installed for: ${_INSTALLED_NAMES}")")"
echo
echo " Available skills:"
echo " /pm-run — run the full pipeline in one command (recommended)"
echo " /pm-scan — read an existing codebase to understand what it actually does"
echo " /pm-discovery — figure out WHAT to build before planning HOW (greenfield)"
echo " /pm-audit — deep product audit, produces AUDIT.md"
echo " /pm-objectives — set OKRs, produces OBJECTIVES.md"
echo " /pm-strategy — product strategy + adversarial review, produces STRATEGY.md"
echo " /pm-roadmap — outcome-driven roadmap, produces ROADMAP.md"
echo " /pm-prd — write a PRD for a feature"
echo " /pm-breakdown — break PRD into tasks, create tickets in Linear / GitHub Issues"
echo " /pm-retro — compare roadmap vs commits, surfaces drift"
echo " /pm-upgrade — upgrade nanopm to the latest version"
echo " /pm-competitors-intel — monitor competitor changelogs, API docs, and product updates"
echo
echo " Daily ops:"
echo " /pm-standup — morning briefing: what shipped, today's meetings, top priorities"
echo " /pm-interview — user interview guide or transcript debrief → FEEDBACK.md"
echo " /pm-weekly-update — draft stakeholder update email"
echo " /pm-data — answer a product question with PostHog or Amplitude"
echo
echo " Start with:"
echo " $(_bold '/pm-run') — or $(_bold '/pm-discovery') if you're not sure what to build"
echo
echo " Docs: $NANOPM_REPO"
echo