Files
getsentry__sentry-for-ai/plugin-src/claude/build.sh
Evan Purkhiser cc302403eb feat(build): add content-root override and shared-reference hydration (#220)
Task-shaped skills will draw their reference material (per-platform SDK
guides, per-signal concepts) from a single maintained library rather
than duplicating it. Each shipped skill must still be self-contained, so
the build copies a skill's declared references into it.

Add a CONTENT_ROOT env var (default: repo root) so the same build steps
can assemble an alternate skill tree, e.g. CONTENT_ROOT=skills-next.

hydrate-references.py walks a skills directory: for every skill with a
references.yml it brace-expands and globs the `needs:` patterns against
the library, copies the matches into the skill's references/ preserving
subpaths, and strips the manifest so it never ships. It runs via `uv run
--script` with inline PyYAML and braceexpand dependencies. build-common.sh
invokes it once per build, and only when some skill declares references,
so existing skills are unaffected and the common case spawns no
interpreter.

Factor the steps shared across all four agent builders into
build-common.sh (content-root resolution, skill copy+hydrate, commands,
SKILL_TREE), sourced by each plugin-src/<agent>/build.sh.
2026-06-26 16:52:56 -04:00

42 lines
1.7 KiB
Bash
Executable File

#!/usr/bin/env bash
#
# build.sh — Build the Claude Code distribution of the Sentry plugin.
#
# Claude consumes the plugin at the dist branch ROOT (its
# `.claude-plugin/marketplace.json` uses `source: "./"`) and HONORS
# `disable-model-invocation`, so the skill-tree routing works natively. No skill
# mutation is needed: this copies the manifest (from alongside this script) plus
# the shared content from the repo root.
#
# Claude's MCP server is declared inline in `plugin.json` (`mcpServers`), so no
# `.mcp.json` is shipped here; the root `mcp.json` only feeds the Cursor and
# Codex builds.
#
# Skill content (skills/, commands/, references/, SKILL_TREE.md) is read from
# CONTENT_ROOT, defaulting to the repo root. Point it at an alternate tree (e.g.
# CONTENT_ROOT=skills-next) to build a different skill set with the same steps.
#
# Usage: build.sh <TARGET_DIR> (TARGET_DIR assumed empty)
set -euo pipefail
TARGET_DIR="${1:?usage: build.sh <TARGET_DIR>}"
SRC_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
REPO_ROOT="$(cd "$SRC_DIR/../.." && pwd)"
cd "$REPO_ROOT"
source "$REPO_ROOT/scripts/build-common.sh"
resolve_content_root "$REPO_ROOT"
mkdir -p "$TARGET_DIR/.claude-plugin"
cp "$SRC_DIR/plugin.json" "$TARGET_DIR/.claude-plugin/plugin.json"
cp "$SRC_DIR/marketplace.json" "$TARGET_DIR/.claude-plugin/marketplace.json"
copy_skills "$CONTENT_ROOT" "$TARGET_DIR/skills"
copy_commands "$CONTENT_ROOT" "$TARGET_DIR/commands"
copy_skill_tree "$CONTENT_ROOT" "$TARGET_DIR/SKILL_TREE.md"
rsync -a assets/ "$TARGET_DIR/assets/"
cp "$SRC_DIR/README.md" "$TARGET_DIR/README.md"
cp LICENSE "$TARGET_DIR/LICENSE"
echo "Built Claude dist into $TARGET_DIR (root plugin, content from $CONTENT_ROOT)."