Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion packs/claude-code/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -158,7 +158,7 @@ ok "claude --version: ${CLAUDE_VER}"

# ── Install loki-skills library ───────────────────────────────────────────────
# Best-effort: pre-install skills (shared or pack-specific).
PACK_SKILLS_DIR="${HOME}/.local/share/lowkey/skills"
PACK_SKILLS_DIR="${HOME}/.claude/skills"
ensure_skills_clone "${PACK_SKILLS_DIR}" || true
log "Skills installed to ${PACK_SKILLS_DIR}"
write_done_marker "claude-code"
Expand Down
2 changes: 1 addition & 1 deletion packs/codex-cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -293,7 +293,7 @@ NOTICE

# ── Install loki-skills library ───────────────────────────────────────────────
# Best-effort: pre-install skills (shared or pack-specific).
PACK_SKILLS_DIR="${HOME}/.local/share/lowkey/skills"
PACK_SKILLS_DIR="${HOME}/.codex/skills"
ensure_skills_clone "${PACK_SKILLS_DIR}" || true
log "Skills installed to ${PACK_SKILLS_DIR}"
write_done_marker "codex-cli"
Expand Down
62 changes: 62 additions & 0 deletions packs/common.sh
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,68 @@
# shared. Override at install time with: LOKI_SKILLS_REPO_URL=...
export LOKI_SKILLS_REPO_URL="${LOKI_SKILLS_REPO_URL:-https://github.com/inceptionstack/loki-skills.git}"

# ── ensure_skills_clone ───────────────────────────────────────────────────────
# Clone loki-skills library to target directory (best-effort, non-fatal).
# Handles update path, partial directory recovery, missing git gracefully.
#
# Usage: ensure_skills_clone <target_dir> [<repo_url>] [<branch>] [<mode>]
# target_dir: where to clone (e.g. ~/.openclaw/workspace/skills)
# repo_url: git repo (default: $LOKI_SKILLS_REPO_URL)
# branch: git branch (default: main)
# mode: 'warn' (default) or 'fail' — controls error handling
#
# Returns: 0 on success, non-zero on failure (caller decides via || true)
ensure_skills_clone() {
local target_dir="${1:?target_dir required}"
local repo_url="${2:-${LOKI_SKILLS_REPO_URL}}"
local branch="${3:-main}"
local mode="${4:-warn}"
local rc=0

# Check git available
if ! command -v git &>/dev/null; then
local msg="git not found; skills clone skipped"
[[ "$mode" == "fail" ]] && { log "$msg (FATAL)"; return 1; } || log "$msg (warn)"
return 0
fi

# Existing repo: try update
if [[ -d "$target_dir" ]] && [[ -d "$target_dir/.git" ]]; then
local origin_url="$(cd "$target_dir" && git config --get remote.origin.url 2>/dev/null)"
if [[ "$origin_url" == "$repo_url" ]]; then
# Same origin, safe to update
if (cd "$target_dir" && git fetch origin "$branch" && git checkout "$branch") &>/dev/null; then
log "Skills repo updated at $target_dir"
return 0
else
log "Skills repo update failed; moving aside and re-cloning"
mv "$target_dir" "${target_dir}.bak.$RANDOM" || true
fi
Comment on lines +47 to +49
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve existing skills checkout when refresh fails

When updating an existing skills repo, any git fetch/checkout error immediately moves the current checkout aside before attempting a fresh clone. In a transient outage (network/auth/remote hiccup), the subsequent clone can fail too, and because callers continue (ensure_skills_clone ... || true), the install completes with the original working skills tree removed from target_dir. This turns a best-effort refresh into a destructive regression on reruns.

Useful? React with 👍 / 👎.

else
# Different origin: move aside and re-clone
log "Skills origin mismatch; moving aside and re-cloning"
mv "$target_dir" "${target_dir}.bak.$RANDOM" || true
fi
fi

# Partial dir (no .git): remove and re-clone
if [[ -d "$target_dir" ]] && [[ ! -d "$target_dir/.git" ]]; then
log "Incomplete skills dir; removing and re-cloning"
rm -rf "$target_dir" || true
fi

# Fresh clone (shallow)
if ! git clone --depth 1 --branch "$branch" "$repo_url" "$target_dir" &>/dev/null; then
local msg="Skills clone failed (repo: $repo_url, branch: $branch)"
[[ "$mode" == "fail" ]] && { log "$msg (FATAL)"; return 1; } || log "$msg (warn, continuing)"
rc=1
else
log "Skills cloned to $target_dir"
fi

return $rc
}

# Colors
_CLR_GREEN='\033[0;32m'
_CLR_CYAN='\033[0;36m'
Expand Down
2 changes: 1 addition & 1 deletion packs/hermes/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -146,7 +146,7 @@ fi

# ── Install loki-skills library ───────────────────────────────────────────────
# Best-effort: pre-install skills (shared or pack-specific).
PACK_SKILLS_DIR="${HOME}/.local/share/lowkey/skills"
PACK_SKILLS_DIR="${HOME}/.hermes/skills"
ensure_skills_clone "${PACK_SKILLS_DIR}" || true
log "Skills installed to ${PACK_SKILLS_DIR}"
write_done_marker "hermes"
Expand Down
9 changes: 4 additions & 5 deletions packs/ironclaw/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -365,11 +365,10 @@ ok "Systemd service installed with EnvironmentFile + --no-onboard"

# ── Done ─────────────────────────────────────────────────────────────────────

# ── Install loki-skills library ───────────────────────────────────────────────
# Best-effort: pre-install skills (shared or pack-specific).
PACK_SKILLS_DIR="${HOME}/.ironclaw/skills"
ensure_skills_clone "${PACK_SKILLS_DIR}" || true
log "Skills installed to ${PACK_SKILLS_DIR}"
# ── IronClaw Skills Configuration (MCP-native, no direct skills auto-discovery) ─
# IronClaw uses MCP servers (Model Context Protocol) for extensions, not local skills.
# Skill reference docs: see ~/.openclaw/workspace/skills/ + BOOTSTRAP-MCPORTER.md
log "IronClaw configured for MCP servers (no local skills pre-install needed)"
write_done_marker "ironclaw"
printf "\n[PACK:ironclaw] INSTALLED — ironclaw CLI ready\n"
printf " model: %s via bedrockify:%s\n" "${MODEL}" "${BEDROCKIFY_PORT}"
Expand Down
2 changes: 1 addition & 1 deletion packs/kiro-cli/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -363,7 +363,7 @@ fi
# Best-effort: pre-install skills to kiro workspace.
PACK_SKILLS_DIR="${HOME}/.kiro/skills"
ensure_skills_clone "${PACK_SKILLS_DIR}" || true
log "Skills installed to ${PACK_SKILLS_DIR}"
log "Skills auto-installed to ${PACK_SKILLS_DIR}"

# ── Done ──────────────────────────────────────────────────────────────────────
write_done_marker "kiro-cli"
Expand Down
2 changes: 1 addition & 1 deletion packs/pi/install.sh
Original file line number Diff line number Diff line change
Expand Up @@ -130,7 +130,7 @@ ok "Pi config written: ${HOME}/.pi/agent/models.json"
# Best-effort: pre-install skills as reference docs for Pi users.
# Skills are stored per-agent (not auto-discovered), so users must manually
# create TypeScript extensions to use them. This ensures they're always available.
PACK_SKILLS_DIR="${HOME}/.pi/agent/skills"
PACK_SKILLS_DIR="${HOME}/.pi/agent/extensions"
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

P1 Badge Preserve user Pi extensions when syncing skills

Pointing PACK_SKILLS_DIR at ~/.pi/agent/extensions causes reruns of this installer to delete user-created Pi extensions: ensure_skills_clone treats any existing non-git directory as “incomplete” and removes it with rm -rf before cloning (packs/common.sh, partial-dir branch). In Pi, that directory is where users are expected to place their own TypeScript extensions, so this change can silently wipe working custom extensions on reinstall/upgrade.

Useful? React with 👍 / 👎.

ensure_skills_clone "${PACK_SKILLS_DIR}" || true
log "Skills installed to ${PACK_SKILLS_DIR} (reference docs; manual extension creation needed)"

Expand Down