-
Notifications
You must be signed in to change notification settings - Fork 2
Expand file tree
/
Copy pathMakefile
More file actions
161 lines (142 loc) · 6.8 KB
/
Copy pathMakefile
File metadata and controls
161 lines (142 loc) · 6.8 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
BUN := $(HOME)/.bun/bin/bun
.PHONY: help install test lint format typecheck check build clean dev setup setup-bump release eval eval-llm demo gh-demo
.DEFAULT_GOAL := help
help: ## Show available targets
@grep -E '^[a-zA-Z_-]+:.*?## .*$$' $(MAKEFILE_LIST) | awk 'BEGIN {FS = ":.*?## "}; {printf " \033[36m%-16s\033[0m %s\n", $$1, $$2}'
install: ## Install dependencies
$(BUN) install
test: ## Run tests
$(BUN) test
lint: ## Run linter
$(BUN) run lint
lint-fix: ## Run linter with auto-fix
$(BUN) run lint:fix
format: ## Format code
$(BUN) run format
format-check: ## Check code formatting
$(BUN) run format:check
typecheck: ## Run type checker
$(BUN) run typecheck
check: lint format-check typecheck test ## Run all checks (lint + format + typecheck + test)
eval: ## Run scan evals (regex only)
$(BUN) evals/scan/run-eval.ts
eval-llm: ## Run scan evals with LLM (requires ANTHROPIC_API_KEY)
$(BUN) evals/scan/run-eval.ts --llm
build: ## Compile single binary to dist/skilltree
$(BUN) build --compile src/cli.ts --outfile dist/skilltree
clean: ## Remove dist/ and node_modules/
rm -rf dist/ node_modules/
dev: ## Run CLI from source (use ARGS= to pass args)
$(BUN) run src/cli.ts $(ARGS)
setup: build ## Build and install binary + skill + completions
@mkdir -p $(HOME)/.skilltree/bin $(HOME)/.skilltree/completions
@rm -f $(HOME)/.skilltree/bin/skilltree
@cp dist/skilltree $(HOME)/.skilltree/bin/skilltree
@# Issue #92: skip `teach` on the post-merge bump path. `teach` resolves
@# the contributor's *personal* global manifest, so transient failures
@# there would otherwise leave the bumped binary uninstalled.
@if [ -z "$(SKILTREE_SKIP_TEACH)" ]; then $(BUN) run src/cli.ts teach > /dev/null; fi
@$(BUN) run src/cli.ts completion zsh > $(HOME)/.skilltree/completions/_skilltree
@$(BUN) run src/cli.ts completion bash > $(HOME)/.skilltree/completions/skilltree.bash
@echo ""
@echo " \033[1mskilltree v$$(grep '"version"' package.json | head -1 | sed 's/.*"\([0-9][^"]*\)".*/\1/') installed\033[0m"
@echo ""
@echo " \033[32m✔\033[0m Binary → ~/.skilltree/bin/skilltree"
@if [ -z "$(SKILTREE_SKIP_TEACH)" ]; then \
echo " \033[32m✔\033[0m Skill → ~/.claude/skills/skilltree/"; \
else \
echo " \033[33m·\033[0m Skill → not refreshed (run \`make setup\` to refresh global skill)"; \
fi
@echo " \033[32m✔\033[0m Completions → ~/.skilltree/completions/"
@echo ""
@if echo "$$PATH" | grep -q "$(HOME)/.skilltree/bin"; then \
echo " PATH already configured."; \
else \
echo " Add to your shell rc file:"; \
echo " \033[36mexport PATH=\"\$$HOME/.skilltree/bin:\$$PATH\"\033[0m"; \
fi
@# Warn if npm-installed version is also on PATH
@NPM_BIN=$$(which -a skilltree 2>/dev/null | grep -v "$(HOME)/.skilltree/bin" | head -1); \
if [ -n "$$NPM_BIN" ]; then \
echo " \033[33m⚠ npm-installed skilltree also found at: $$NPM_BIN\033[0m"; \
if echo "$$PATH" | tr ':' '\n' | grep -n "." | grep -q ".*skilltree/bin" && \
SETUP_POS=$$(echo "$$PATH" | tr ':' '\n' | grep -n "$(HOME)/.skilltree/bin" | head -1 | cut -d: -f1) && \
NPM_DIR=$$(dirname "$$NPM_BIN") && \
NPM_POS=$$(echo "$$PATH" | tr ':' '\n' | grep -n "$$NPM_DIR" | head -1 | cut -d: -f1) && \
[ "$$SETUP_POS" -gt "$$NPM_POS" ] 2>/dev/null; then \
echo " \033[33m npm version takes precedence — move ~/.skilltree/bin earlier in PATH\033[0m"; \
echo " \033[33m or run: npm uninstall -g skilltree-pm\033[0m"; \
else \
echo " \033[33m dev version takes precedence (good). To clean up: npm uninstall -g skilltree-pm\033[0m"; \
fi; \
echo ""; \
fi
@echo ""
@echo " For tab completions (zsh):"
@echo " \033[36msource \$$HOME/.skilltree/completions/_skilltree\033[0m"
@echo ""
@echo " To seed community registries:"
@echo " \033[36mskilltree registry init\033[0m"
@echo ""
setup-bump: ## Post-bump variant of setup: binary + completions only, skips `teach` (used by post-merge hook; see issue #92)
@$(MAKE) setup SKILTREE_SKIP_TEACH=1
demo: ## Record demo GIF + MP4 locally (no publish)
@command -v vhs >/dev/null || (echo "Error: vhs not installed. Run: brew install vhs"; exit 1)
@command -v ffmpeg >/dev/null || (echo "Error: ffmpeg not installed. Run: brew install ffmpeg"; exit 1)
@command -v gifsicle >/dev/null || (echo "Error: gifsicle not installed. Run: brew install gifsicle"; exit 1)
vhs demo/demo.tape
ffmpeg -y -i demo/demo.gif -movflags faststart -pix_fmt yuv420p \
-vf "scale=trunc(iw/2)*2:trunc(ih/2)*2" demo/demo.mp4
# GitHub camo proxy rejects images > ~5 MB with a silent 404 — README
# image stops rendering on the repo page. Compress in place so we stay
# safely under the limit no matter how the tape grows.
gifsicle -O3 --lossy=80 --colors 128 -b demo/demo.gif
@echo ""
@echo " \033[32m✔\033[0m Recorded locally"
@echo " GIF: demo/demo.gif ($$(du -h demo/demo.gif | cut -f1))"
@echo " MP4: demo/demo.mp4 ($$(du -h demo/demo.mp4 | cut -f1))"
@echo " Run 'make gh-demo' to publish to GitHub Pages"
gh-demo: demo ## Record demo and publish to GitHub Pages
@WORK=$$(mktemp -d); \
git worktree add "$$WORK" gh-pages; \
cp demo/demo.gif demo/demo.mp4 "$$WORK/"; \
cd "$$WORK" && git add demo.gif demo.mp4 && \
PRE_COMMIT_ALLOW_NO_CONFIG=1 git commit -m "chore: update demo assets" && \
git push origin gh-pages; \
cd - >/dev/null; \
git worktree remove "$$WORK"; \
echo ""; \
echo " \033[32m✔\033[0m Published to GitHub Pages"; \
echo " GIF: https://imarios.github.io/skilltree/demo.gif"; \
echo " MP4: https://imarios.github.io/skilltree/demo.mp4"
release: ## Tag and release a version (usage: make release V=0.2.0)
ifndef V
$(error Usage: make release V=0.2.0)
endif
@# Guard: tag must not already exist
@if git tag -l | grep -q "^v$(V)$$"; then \
echo "Error: tag v$(V) already exists"; exit 1; \
fi
@# Guard: new version must be higher than current
@CURRENT=$$(grep '"version"' package.json | head -1 | sed 's/.*"version": "\(.*\)".*/\1/'); \
if [ "$$(printf '%s\n%s' "$$CURRENT" "$(V)" | sort -V | tail -1)" = "$$CURRENT" ] && [ "$$CURRENT" != "$(V)" ]; then \
echo "Error: $(V) is lower than current version $$CURRENT"; exit 1; \
fi; \
if [ "$$CURRENT" = "$(V)" ]; then \
echo "Error: $(V) is the same as current version"; exit 1; \
fi
@# Guard: working tree must be clean
@if [ -n "$$(git status --porcelain -- src/ tests/ package.json)" ]; then \
echo "Error: uncommitted changes in src/, tests/, or package.json. Commit or stash first."; exit 1; \
fi
@# Guard: tests must pass
@echo "Running checks..."
@$(BUN) test --quiet || (echo "Error: tests failing. Fix before releasing."; exit 1)
@echo "Releasing v$(V)..."
@sed -i '' 's/"version": ".*"/"version": "$(V)"/' package.json
@git add package.json
@git commit -m "bump: version → $(V)"
@git tag v$(V)
@$(MAKE) setup
@echo ""
@echo "Released v$(V) — binary installed at ~/.skilltree/bin/skilltree"