skills/ 现包含 inkreach-teable + inkreach-teable-plugin, npx skills add 一并安装两个;install.sh 改为遍历安装 skills/*。
92 lines
3.3 KiB
Bash
92 lines
3.3 KiB
Bash
#!/bin/bash
|
|
# Install/upgrade the inkreach-teable CLI + agent skill from this standalone repo.
|
|
# Run from this skill's directory (or anywhere; paths resolve from this file).
|
|
# What it does:
|
|
# 1. Builds the CLI (this repo's root IS the package).
|
|
# 2. Links the `inkreach-teable` command globally.
|
|
# 3. Installs the skill to ~/.zcode/skills/inkreach-teable (user scope —
|
|
# available in every ZCode workspace, shadows same-named workspace skills).
|
|
# Re-run this script after pulling changes to refresh both the command and the skill.
|
|
set -e
|
|
|
|
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
|
# Resolve the repo root: skill lives at <root>/skills/inkreach-teable/scripts/
|
|
REPO_ROOT="$(cd "$SCRIPT_DIR/../../.." && pwd)"
|
|
SKILL_DIR="$REPO_ROOT/skills/inkreach-teable"
|
|
|
|
echo "=== inkreach-teable CLI installation ==="
|
|
|
|
# Check Node.js
|
|
if ! command -v node &> /dev/null; then
|
|
echo "ERROR: Node.js is not installed. Install Node.js >= 18 first."
|
|
exit 1
|
|
fi
|
|
NODE_VERSION=$(node -v | sed 's/v//' | cut -d. -f1)
|
|
if [ "$NODE_VERSION" -lt 18 ]; then
|
|
echo "ERROR: Node.js >= 18 required, found v$(node -v)"
|
|
exit 1
|
|
fi
|
|
echo "✓ Node.js $(node -v)"
|
|
|
|
# Check repo layout
|
|
if [ ! -f "$REPO_ROOT/package.json" ] || [ ! -d "$REPO_ROOT/src" ]; then
|
|
echo "ERROR: CLI source not found at $REPO_ROOT"
|
|
echo " Ensure the inkreach-teable-cli repo is checked out at $REPO_ROOT"
|
|
exit 1
|
|
fi
|
|
|
|
# Build
|
|
echo "Building CLI from $REPO_ROOT ..."
|
|
cd "$REPO_ROOT"
|
|
if command -v pnpm &> /dev/null; then
|
|
pnpm install --prefer-offline 2>/dev/null || true
|
|
pnpm build
|
|
else
|
|
echo "ERROR: pnpm not found. Install pnpm first: npm i -g pnpm"
|
|
exit 1
|
|
fi
|
|
|
|
# Link globally. Prefer pnpm; fall back to npm link; finally create a wrapper.
|
|
echo "Linking 'inkreach-teable' command globally ..."
|
|
LINKED=0
|
|
if command -v pnpm &> /dev/null && pnpm link --global 2>/dev/null; then
|
|
LINKED=1
|
|
elif command -v npm &> /dev/null && npm link 2>/dev/null; then
|
|
LINKED=1
|
|
fi
|
|
# Ensure a usable wrapper exists on PATH even if global bin isn't configured.
|
|
mkdir -p "$HOME/.local/bin"
|
|
cat > "$HOME/.local/bin/inkreach-teable" <<WRAPPER
|
|
#!/bin/bash
|
|
exec node "$REPO_ROOT/dist/bin.js" "\$@"
|
|
WRAPPER
|
|
chmod +x "$HOME/.local/bin/inkreach-teable"
|
|
|
|
# Install every skill in this repo at user scope so they work in ANY workspace,
|
|
# including checkouts of the inkreach-teable application repo (which no longer
|
|
# bundles them): inkreach-teable + inkreach-teable-plugin.
|
|
if [ -d "$REPO_ROOT/skills" ]; then
|
|
mkdir -p "$HOME/.zcode/skills"
|
|
for skill_dir in "$REPO_ROOT/skills"/*/; do
|
|
skill_name="$(basename "$skill_dir")"
|
|
rm -rf "$HOME/.zcode/skills/$skill_name"
|
|
cp -r "$skill_dir" "$HOME/.zcode/skills/$skill_name"
|
|
echo "✓ skill installed: $skill_name (~/.zcode/skills, user scope)"
|
|
done
|
|
fi
|
|
|
|
# Verify
|
|
echo ""
|
|
echo "=== Verification ==="
|
|
if command -v inkreach-teable &> /dev/null; then
|
|
echo "✓ inkreach-teable CLI installed ($(inkreach-teable --version 2>/dev/null || echo 'unknown'))"
|
|
echo ""
|
|
echo "Next: configure endpoint + token:"
|
|
echo " inkreach-teable auth login --endpoint http://localhost:3000 --token <PAT>"
|
|
echo "Or create a PAT first:"
|
|
echo " inkreach-teable auth token create --name my-cli"
|
|
else
|
|
echo "⚠ 'inkreach-teable' not on PATH. Add pnpm/npm global bin to your PATH, or run directly:"
|
|
echo " node $REPO_ROOT/dist/bin.js <command>"
|
|
fi
|