feat: add skill install scripts and move skill into htsy/
This commit is contained in:
@@ -0,0 +1,136 @@
|
||||
[CmdletBinding()]
|
||||
param(
|
||||
[string]$Source,
|
||||
[string]$Dest,
|
||||
[string]$SkillsDir,
|
||||
[string]$Agent = $(if ($env:HTSY_SKILL_AGENT) { $env:HTSY_SKILL_AGENT } else { "" }),
|
||||
[string]$Repo = $(if ($env:HTSY_SKILL_REPO_URL) { $env:HTSY_SKILL_REPO_URL } else { "https://git.ikuban.com/server/htsy-skill.git" })
|
||||
)
|
||||
|
||||
$ErrorActionPreference = "Stop"
|
||||
|
||||
function Resolve-Dest {
|
||||
param(
|
||||
[string]$ExactDest,
|
||||
[string]$ParentSkillsDir,
|
||||
[string]$TargetAgent
|
||||
)
|
||||
|
||||
if ($ExactDest) {
|
||||
return $ExactDest
|
||||
}
|
||||
|
||||
if ($env:HTSY_SKILL_DEST) {
|
||||
return $env:HTSY_SKILL_DEST
|
||||
}
|
||||
|
||||
if (-not $ParentSkillsDir -and $env:AGENT_SKILLS_DIR) {
|
||||
$ParentSkillsDir = $env:AGENT_SKILLS_DIR
|
||||
}
|
||||
|
||||
if ($ParentSkillsDir) {
|
||||
return Join-Path $ParentSkillsDir "htsy"
|
||||
}
|
||||
|
||||
switch ($TargetAgent) {
|
||||
"claude" {
|
||||
$claudeHome = $env:CLAUDE_HOME
|
||||
if (-not $claudeHome) {
|
||||
$claudeHome = Join-Path $HOME ".claude"
|
||||
}
|
||||
return Join-Path (Join-Path $claudeHome "skills") "htsy"
|
||||
}
|
||||
"claude-user" {
|
||||
$claudeHome = $env:CLAUDE_HOME
|
||||
if (-not $claudeHome) {
|
||||
$claudeHome = Join-Path $HOME ".claude"
|
||||
}
|
||||
return Join-Path (Join-Path $claudeHome "skills") "htsy"
|
||||
}
|
||||
"claude-project" {
|
||||
return Join-Path (Join-Path (Join-Path (Get-Location).Path ".claude") "skills") "htsy"
|
||||
}
|
||||
"codex" {
|
||||
$codexHome = $env:CODEX_HOME
|
||||
if (-not $codexHome) {
|
||||
$codexHome = Join-Path $HOME ".codex"
|
||||
}
|
||||
return Join-Path (Join-Path $codexHome "skills") "htsy"
|
||||
}
|
||||
"" {
|
||||
throw "Specify -Agent claude|claude-project|codex, -SkillsDir, or -Dest."
|
||||
}
|
||||
default {
|
||||
throw "Unknown agent: $TargetAgent"
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
function Copy-Skill {
|
||||
param(
|
||||
[Parameter(Mandatory = $true)][string]$From,
|
||||
[Parameter(Mandatory = $true)][string]$To
|
||||
)
|
||||
|
||||
if (-not (Test-Path (Join-Path $From "SKILL.md"))) {
|
||||
throw "Invalid source: $From does not contain SKILL.md"
|
||||
}
|
||||
|
||||
$destParent = Split-Path -Parent $To
|
||||
if (-not (Test-Path $destParent)) {
|
||||
New-Item -ItemType Directory -Force $destParent | Out-Null
|
||||
}
|
||||
|
||||
$tmpDest = Join-Path $destParent (".htsy-install-{0}" -f ([guid]::NewGuid().ToString("N")))
|
||||
New-Item -ItemType Directory -Force $tmpDest | Out-Null
|
||||
|
||||
try {
|
||||
Get-ChildItem -LiteralPath $From -Force | Copy-Item -Destination $tmpDest -Recurse -Force
|
||||
|
||||
if (Test-Path $To) {
|
||||
Remove-Item -Path $To -Recurse -Force
|
||||
}
|
||||
|
||||
Move-Item -Path $tmpDest -Destination $To
|
||||
}
|
||||
catch {
|
||||
if (Test-Path $tmpDest) {
|
||||
Remove-Item -Path $tmpDest -Recurse -Force
|
||||
}
|
||||
throw
|
||||
}
|
||||
}
|
||||
|
||||
$Dest = Resolve-Dest -ExactDest $Dest -ParentSkillsDir $SkillsDir -TargetAgent $Agent
|
||||
|
||||
$scriptDir = Split-Path -Parent $MyInvocation.MyCommand.Path
|
||||
$repoRoot = (Resolve-Path (Join-Path $scriptDir "..")).Path
|
||||
$tempRoot = $null
|
||||
|
||||
try {
|
||||
if (-not $Source) {
|
||||
$localSkill = Join-Path $repoRoot "htsy"
|
||||
if (Test-Path (Join-Path $localSkill "SKILL.md")) {
|
||||
$Source = $localSkill
|
||||
}
|
||||
else {
|
||||
if (-not (Get-Command git -ErrorAction SilentlyContinue)) {
|
||||
throw "git is required when the local htsy/ directory is unavailable."
|
||||
}
|
||||
|
||||
$tempRoot = Join-Path ([System.IO.Path]::GetTempPath()) ("htsy-skill-{0}" -f ([guid]::NewGuid().ToString("N")))
|
||||
git clone --depth 1 $Repo $tempRoot
|
||||
$Source = Join-Path $tempRoot "htsy"
|
||||
}
|
||||
}
|
||||
|
||||
Copy-Skill -From $Source -To $Dest
|
||||
|
||||
Write-Host "Installed htsy skill to: $Dest"
|
||||
Write-Host "Verify: $(Join-Path $Dest 'SKILL.md')"
|
||||
}
|
||||
finally {
|
||||
if ($tempRoot -and (Test-Path $tempRoot)) {
|
||||
Remove-Item -Path $tempRoot -Recurse -Force
|
||||
}
|
||||
}
|
||||
Executable
+148
@@ -0,0 +1,148 @@
|
||||
#!/usr/bin/env bash
|
||||
set -euo pipefail
|
||||
|
||||
DEFAULT_REPO_URL="https://git.ikuban.com/server/htsy-skill.git"
|
||||
REPO_URL="${HTSY_SKILL_REPO_URL:-$DEFAULT_REPO_URL}"
|
||||
SOURCE_DIR=""
|
||||
DEST_DIR="${HTSY_SKILL_DEST:-}"
|
||||
SKILLS_DIR="${AGENT_SKILLS_DIR:-}"
|
||||
AGENT="${HTSY_SKILL_AGENT:-}"
|
||||
TMP_DIR=""
|
||||
TMP_DEST=""
|
||||
|
||||
usage() {
|
||||
cat <<'USAGE'
|
||||
Install the htsy agent skill.
|
||||
|
||||
Usage:
|
||||
scripts/install-htsy-skill.sh --agent claude|claude-project|codex [--source PATH]
|
||||
scripts/install-htsy-skill.sh --dest PATH [--source PATH]
|
||||
scripts/install-htsy-skill.sh --skills-dir PATH [--source PATH]
|
||||
|
||||
Options:
|
||||
--source PATH Path to the htsy skill directory. Defaults to ./htsy when run from this repository.
|
||||
--agent NAME Install target: claude, claude-project, or codex.
|
||||
--dest PATH Exact destination skill directory, for example /path/to/skills/htsy.
|
||||
--skills-dir PATH
|
||||
Parent skills directory. The installer writes PATH/htsy.
|
||||
--repo URL Repository URL used when ./htsy is not available.
|
||||
-h, --help Show this help.
|
||||
|
||||
Environment:
|
||||
AGENT_SKILLS_DIR Parent skills directory. The installer writes AGENT_SKILLS_DIR/htsy.
|
||||
CODEX_HOME Codex home directory when --agent codex is used.
|
||||
CLAUDE_HOME Claude home directory when --agent claude is used.
|
||||
HTSY_SKILL_AGENT Default value for --agent.
|
||||
HTSY_SKILL_REPO_URL Repository URL fallback.
|
||||
HTSY_SKILL_DEST Destination skill directory.
|
||||
USAGE
|
||||
}
|
||||
|
||||
while [ "$#" -gt 0 ]; do
|
||||
case "$1" in
|
||||
--source)
|
||||
SOURCE_DIR="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--dest)
|
||||
DEST_DIR="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--skills-dir)
|
||||
SKILLS_DIR="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--agent)
|
||||
AGENT="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
--repo)
|
||||
REPO_URL="${2:-}"
|
||||
shift 2
|
||||
;;
|
||||
-h|--help)
|
||||
usage
|
||||
exit 0
|
||||
;;
|
||||
*)
|
||||
echo "Unknown option: $1" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
done
|
||||
|
||||
if [ -z "$DEST_DIR" ]; then
|
||||
if [ -n "$SKILLS_DIR" ]; then
|
||||
DEST_DIR="$SKILLS_DIR/htsy"
|
||||
else
|
||||
case "$AGENT" in
|
||||
claude|claude-user)
|
||||
DEST_DIR="${CLAUDE_HOME:-$HOME/.claude}/skills/htsy"
|
||||
;;
|
||||
claude-project)
|
||||
DEST_DIR="$PWD/.claude/skills/htsy"
|
||||
;;
|
||||
codex)
|
||||
DEST_DIR="${CODEX_HOME:-$HOME/.codex}/skills/htsy"
|
||||
;;
|
||||
"")
|
||||
echo "Specify --agent claude|claude-project|codex, --skills-dir, or --dest." >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
*)
|
||||
echo "Unknown agent: $AGENT" >&2
|
||||
usage >&2
|
||||
exit 2
|
||||
;;
|
||||
esac
|
||||
fi
|
||||
fi
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
REPO_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
cleanup() {
|
||||
if [ -n "$TMP_DEST" ]; then
|
||||
rm -rf "$TMP_DEST"
|
||||
fi
|
||||
if [ -n "$TMP_DIR" ]; then
|
||||
rm -rf "$TMP_DIR"
|
||||
fi
|
||||
}
|
||||
trap cleanup EXIT
|
||||
|
||||
if [ -z "$SOURCE_DIR" ]; then
|
||||
if [ -f "$REPO_ROOT/htsy/SKILL.md" ]; then
|
||||
SOURCE_DIR="$REPO_ROOT/htsy"
|
||||
else
|
||||
if ! command -v git >/dev/null 2>&1; then
|
||||
echo "git is required when the local htsy/ directory is unavailable." >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
TMP_DIR="$(mktemp -d)"
|
||||
git clone --depth 1 "$REPO_URL" "$TMP_DIR/htsy-skill"
|
||||
SOURCE_DIR="$TMP_DIR/htsy-skill/htsy"
|
||||
fi
|
||||
fi
|
||||
|
||||
if [ ! -f "$SOURCE_DIR/SKILL.md" ]; then
|
||||
echo "Invalid source: $SOURCE_DIR does not contain SKILL.md" >&2
|
||||
exit 1
|
||||
fi
|
||||
|
||||
DEST_PARENT="$(dirname "$DEST_DIR")"
|
||||
mkdir -p "$DEST_PARENT"
|
||||
TMP_DEST="$DEST_PARENT/.htsy-install.$$"
|
||||
rm -rf "$TMP_DEST"
|
||||
mkdir -p "$TMP_DEST"
|
||||
cp -R "$SOURCE_DIR/." "$TMP_DEST/"
|
||||
|
||||
rm -rf "$DEST_DIR"
|
||||
mv "$TMP_DEST" "$DEST_DIR"
|
||||
TMP_DEST=""
|
||||
|
||||
echo "Installed htsy skill to: $DEST_DIR"
|
||||
echo "Verify: $DEST_DIR/SKILL.md"
|
||||
Reference in New Issue
Block a user