mirror of
https://github.com/xr843/Master-skill.git
synced 2026-05-10 05:16:25 +00:00
feat: add multi-platform plugin support and session-start hook
Add support for 5 platforms beyond NPX: - Claude Code: .claude-plugin/plugin.json + marketplace.json - Cursor: .cursor-plugin/plugin.json + hooks-cursor.json - Codex CLI: .codex/INSTALL.md with symlink setup - OpenCode: .opencode/INSTALL.md with plugin config - Gemini CLI: gemini-extension.json + GEMINI.md Infrastructure: - SessionStart hook with platform detection (Claude Code, Cursor, Copilot CLI) that injects available masters list - Cross-platform run-hook.cmd polyglot wrapper (Windows + Unix) - .version-bump.json for unified version management across all platform config files - Update README/README_EN with multi-platform install instructions Co-Authored-By: Claude Opus 4.6 (1M context) <noreply@anthropic.com>
This commit is contained in:
@@ -0,0 +1,10 @@
|
||||
{
|
||||
"version": 1,
|
||||
"hooks": {
|
||||
"sessionStart": [
|
||||
{
|
||||
"command": "./hooks/session-start"
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,16 @@
|
||||
{
|
||||
"hooks": {
|
||||
"SessionStart": [
|
||||
{
|
||||
"matcher": "startup|clear|compact",
|
||||
"hooks": [
|
||||
{
|
||||
"type": "command",
|
||||
"command": "\"${CLAUDE_PLUGIN_ROOT}/hooks/run-hook.cmd\" session-start",
|
||||
"async": false
|
||||
}
|
||||
]
|
||||
}
|
||||
]
|
||||
}
|
||||
}
|
||||
Executable
+29
@@ -0,0 +1,29 @@
|
||||
: ; # Polyglot wrapper — runs as cmd.exe on Windows, bash on Unix
|
||||
: ; exec bash "$0" "$@" 2>/dev/null
|
||||
: ; exit
|
||||
@echo off
|
||||
setlocal enabledelayedexpansion
|
||||
|
||||
set "HOOK=%~1"
|
||||
set "HOOK_DIR=%~dp0"
|
||||
|
||||
:: Try common Git for Windows bash locations
|
||||
for %%B in (
|
||||
"C:\Program Files\Git\bin\bash.exe"
|
||||
"C:\Program Files (x86)\Git\bin\bash.exe"
|
||||
"%LOCALAPPDATA%\Programs\Git\bin\bash.exe"
|
||||
) do (
|
||||
if exist %%B (
|
||||
%%B "%HOOK_DIR%%HOOK%" %2 %3 %4 %5
|
||||
exit /b %ERRORLEVEL%
|
||||
)
|
||||
)
|
||||
|
||||
:: Fallback: try bash from PATH
|
||||
where bash >nul 2>&1 && (
|
||||
bash "%HOOK_DIR%%HOOK%" %2 %3 %4 %5
|
||||
exit /b %ERRORLEVEL%
|
||||
)
|
||||
|
||||
:: No bash found — exit silently
|
||||
exit /b 0
|
||||
Executable
+47
@@ -0,0 +1,47 @@
|
||||
#!/usr/bin/env bash
|
||||
# Master-skill session-start hook
|
||||
# Injects available masters list into conversation context on session start.
|
||||
# Compatible with Claude Code, Cursor, and Copilot CLI.
|
||||
|
||||
set -euo pipefail
|
||||
|
||||
SCRIPT_DIR="$(cd "$(dirname "${BASH_SOURCE[0]}")" && pwd)"
|
||||
PLUGIN_ROOT="$(cd "$SCRIPT_DIR/.." && pwd)"
|
||||
|
||||
# Build masters list from prebuilt/ directory
|
||||
MASTERS_LIST=""
|
||||
for dir in "$PLUGIN_ROOT"/prebuilt/*/; do
|
||||
[ -d "$dir" ] || continue
|
||||
name=$(basename "$dir")
|
||||
[ "$name" = "compare" ] && continue
|
||||
skill_file="$dir/SKILL.md"
|
||||
if [ -f "$skill_file" ]; then
|
||||
# Extract lineage from frontmatter
|
||||
lineage=$(grep '^lineage:' "$skill_file" 2>/dev/null | head -1 | sed 's/^lineage: *//' || echo "")
|
||||
if [ -n "$lineage" ]; then
|
||||
MASTERS_LIST="${MASTERS_LIST} /${name} — ${lineage}\n"
|
||||
fi
|
||||
fi
|
||||
done
|
||||
|
||||
# Build the context message
|
||||
CONTEXT="Master-skill plugin loaded. Available Buddhist masters:
|
||||
${MASTERS_LIST} /compare-masters — multi-tradition comparison
|
||||
/create-master — generate new master from FoJin knowledge graph
|
||||
|
||||
All doctrinal responses include CBETA citations linked to fojin.app."
|
||||
|
||||
# Escape for JSON embedding
|
||||
CONTEXT_ESCAPED=$(echo "$CONTEXT" | python3 -c "import sys,json; print(json.dumps(sys.stdin.read()))" 2>/dev/null || echo "\"$CONTEXT\"")
|
||||
|
||||
# Platform detection and output format
|
||||
if [ -n "${CURSOR_PLUGIN_ROOT:-}" ]; then
|
||||
# Cursor format
|
||||
echo "{\"additional_context\": $CONTEXT_ESCAPED}"
|
||||
elif [ -n "${CLAUDE_PLUGIN_ROOT:-}" ] && [ -z "${COPILOT_CLI:-}" ]; then
|
||||
# Claude Code format
|
||||
echo "{\"hookSpecificOutput\": {\"additionalContext\": $CONTEXT_ESCAPED}}"
|
||||
else
|
||||
# Copilot CLI / SDK standard format
|
||||
echo "{\"additionalContext\": $CONTEXT_ESCAPED}"
|
||||
fi
|
||||
Reference in New Issue
Block a user