Install the AI skill for the user, not the folder (#3493)

This commit is contained in:
Yota Hamada authored and GitHub committed 2026-11-03 16:56:15 +09:00
1 parent cabd0d2557
commit 15f354f232
2 files changed
+86 -45

No files matched your search

+33 -17
View File
@@ -81,6 +81,8 @@ $Script:DaguExe = $null
$Script:DaguHome = $null
$Script:ServiceUrl = $null
$Script:DetectedSkillTargets = 0
# The user-level skills directory of each detected AI tool.
$Script:SkillTargetDirs = @()
$Script:RebootElevated = $false
$Script:SkillMode = ""
$Script:UninstallInstallPaths = @()
@@ -400,22 +402,29 @@ function Resolve-Defaults {
}
}
# The configuration directory of the GitHub Copilot CLI.
function Get-CopilotHome {
if ($env:COPILOT_HOME) { return $env:COPILOT_HOME }
return Join-Path ([Environment]::GetFolderPath("UserProfile")) ".copilot"
}
function Detect-SkillTargets {
if ($ServiceOnly) {
return
}
$userHome = [Environment]::GetFolderPath("UserProfile")
$count = 0
$dirs = @()
$agentsHome = if ($env:AGENTS_HOME) { $env:AGENTS_HOME } else { Join-Path $userHome ".agents" }
$codexHome = if ($env:CODEX_HOME) { $env:CODEX_HOME } else { Join-Path $userHome ".codex" }
if (Test-Path (Join-Path $userHome ".claude\.claude.json")) { $count++ }
if (Test-Path $agentsHome) { $count++ }
elseif (Test-Path $codexHome) { $count++ }
if (Test-Path (Join-Path $userHome ".config\opencode")) { $count++ }
if (Test-Path (Join-Path $userHome ".gemini\GEMINI.md")) { $count++ }
$xdg = if ($env:XDG_CONFIG_HOME) { $env:XDG_CONFIG_HOME } else { $userHome }
if ((Test-Path (Join-Path $xdg ".copilot\config.json")) -or (Test-Path (Join-Path $userHome ".copilot\config.json"))) { $count++ }
$Script:DetectedSkillTargets = $count
if (Test-Path (Join-Path $userHome ".claude\.claude.json")) { $dirs += Join-Path $userHome ".claude\skills" }
if (Test-Path $agentsHome) { $dirs += Join-Path $agentsHome "skills" }
elseif (Test-Path $codexHome) { $dirs += Join-Path $codexHome "skills" }
if (Test-Path (Join-Path $userHome ".config\opencode")) { $dirs += Join-Path $userHome ".config\opencode\skills" }
if (Test-Path (Join-Path $userHome ".gemini\GEMINI.md")) { $dirs += Join-Path $userHome ".gemini\skills" }
$copilotHome = Get-CopilotHome
if (Test-Path (Join-Path $copilotHome "config.json")) { $dirs += Join-Path $copilotHome "skills" }
$Script:SkillTargetDirs = $dirs
$Script:DetectedSkillTargets = $dirs.Count
}
function Get-ServiceWrapperPath {
@@ -456,9 +465,12 @@ function Discover-SkillRemovals {
$codexSkill = Join-Path $codexHome "skills\dagu"
$openCodeSkill = Join-Path $userHome ".config\opencode\skills\dagu"
$geminiSkill = Join-Path $userHome ".gemini\skills\dagu"
$copilotSkill = Join-Path (Get-CopilotHome) "skills\dagu"
# npx skills --global writes to ~/.agents whatever AGENTS_HOME says.
$npxAgentsSkill = Join-Path $userHome ".agents\skills\dagu"
$xdgCopilot = Join-Path $xdg ".copilot\copilot-instructions.md"
$homeCopilot = Join-Path $userHome ".copilot\copilot-instructions.md"
foreach ($dir in @($claudeSkill, $agentsSkill, $codexSkill, $openCodeSkill, $geminiSkill)) {
foreach ($dir in @($claudeSkill, $agentsSkill, $npxAgentsSkill, $codexSkill, $openCodeSkill, $geminiSkill, $copilotSkill)) {
if (Test-Path $dir) {
Add-UniqueItem ([ref]$Script:UninstallSkillDirs) $dir
}
@@ -1278,22 +1290,26 @@ function Install-AISkill {
foreach ($dir in $SkillsDir) {
Write-WarnMessage "--SkillsDir is no longer supported by the Dagu installer: $dir"
}
Write-WarnMessage "Install the skill with: gh skill install dagucloud/dagu dagu"
Write-WarnMessage "Install the skill with: gh skill install dagucloud/dagu dagu --scope user"
}
elseif ($SkillMode -eq "auto" -and (Get-Command gh -ErrorAction SilentlyContinue)) {
& gh skill install dagucloud/dagu dagu
if ($LASTEXITCODE -ne 0) {
Write-WarnMessage "Failed to install the Dagu AI skill. Install manually with: gh skill install dagucloud/dagu dagu"
# gh and npx skills default to the project in the current directory:
# name the user-level target.
foreach ($dir in $Script:SkillTargetDirs) {
& gh skill install dagucloud/dagu dagu --dir $dir --force
if ($LASTEXITCODE -ne 0) {
Write-WarnMessage "Failed to install the Dagu AI skill into $dir. Install manually with: gh skill install dagucloud/dagu dagu --dir `"$dir`" --force"
}
}
}
elseif ($SkillMode -eq "auto" -and (Get-Command npx -ErrorAction SilentlyContinue)) {
& npx skills add https://github.com/dagucloud/dagu --skill dagu
& npx --yes skills add https://github.com/dagucloud/dagu --skill dagu --global --yes
if ($LASTEXITCODE -ne 0) {
Write-WarnMessage "Failed to install the Dagu AI skill. Install manually with: npx skills add https://github.com/dagucloud/dagu --skill dagu"
Write-WarnMessage "Failed to install the Dagu AI skill. Install manually with: npx skills add https://github.com/dagucloud/dagu --skill dagu --global"
}
}
else {
Write-WarnMessage "No shared skills installer was found. Install manually with: gh skill install dagucloud/dagu dagu"
Write-WarnMessage "No shared skills installer was found. Install manually with: gh skill install dagucloud/dagu dagu --scope user"
}
}
+53 -28
View File
@@ -88,6 +88,8 @@ INSTALL_PATH=""
SERVICE_URL=""
SERVICE_PATH=""
SKILL_DETECTED_COUNT=0
# The user-level skills directory of each detected AI tool.
declare -a SKILL_TARGET_DIRS=()
SCRUB_BACKUP_FILE=""
declare -a UNINSTALL_INSTALL_PATHS=()
declare -a UNINSTALL_DAGU_HOMES=()
@@ -114,7 +116,7 @@ Options:
--service-scope <scope> Service scope: user or system
--host <host> Host address for the Dagu web UI
--port <port> Port for the Dagu web UI
--skills-dir <path> Deprecated; use gh skill install dagucloud/dagu dagu instead
--skills-dir <path> Deprecated; use gh skill install dagucloud/dagu dagu --scope user instead
--admin-username <name> Initial admin username for builtin auth bootstrap
--admin-password <pass> Initial admin password for builtin auth bootstrap
--open-browser <yes|no> Open the Dagu URL after successful setup
@@ -631,27 +633,36 @@ detect_os_arch() {
esac
}
# The configuration directory of the GitHub Copilot CLI.
copilot_home_dir() {
printf '%s' "${COPILOT_HOME:-${HOME}/.copilot}"
}
detect_skill_targets() {
local home_dir codex_dir
local home_dir agents_home codex_home copilot_home
home_dir="${HOME}"
SKILL_DETECTED_COUNT=0
agents_home="${AGENTS_HOME:-${home_dir}/.agents}"
codex_home="${CODEX_HOME:-${home_dir}/.codex}"
SKILL_TARGET_DIRS=()
if [[ -f "${home_dir}/.claude/.claude.json" ]]; then
SKILL_DETECTED_COUNT=$((SKILL_DETECTED_COUNT + 1))
SKILL_TARGET_DIRS+=("${home_dir}/.claude/skills")
fi
if [[ -d "${AGENTS_HOME:-${home_dir}/.agents}" ]]; then
SKILL_DETECTED_COUNT=$((SKILL_DETECTED_COUNT + 1))
elif [[ -d "${CODEX_HOME:-${home_dir}/.codex}" ]]; then
SKILL_DETECTED_COUNT=$((SKILL_DETECTED_COUNT + 1))
if [[ -d "${agents_home}" ]]; then
SKILL_TARGET_DIRS+=("${agents_home}/skills")
elif [[ -d "${codex_home}" ]]; then
SKILL_TARGET_DIRS+=("${codex_home}/skills")
fi
if [[ -d "${home_dir}/.config/opencode" ]]; then
SKILL_DETECTED_COUNT=$((SKILL_DETECTED_COUNT + 1))
SKILL_TARGET_DIRS+=("${home_dir}/.config/opencode/skills")
fi
if [[ -f "${home_dir}/.gemini/GEMINI.md" ]]; then
SKILL_DETECTED_COUNT=$((SKILL_DETECTED_COUNT + 1))
SKILL_TARGET_DIRS+=("${home_dir}/.gemini/skills")
fi
if [[ -f "${XDG_CONFIG_HOME:-${home_dir}}/.copilot/config.json" || -f "${home_dir}/.copilot/config.json" ]]; then
SKILL_DETECTED_COUNT=$((SKILL_DETECTED_COUNT + 1))
copilot_home="$(copilot_home_dir)"
if [[ -f "${copilot_home}/config.json" ]]; then
SKILL_TARGET_DIRS+=("${copilot_home}/skills")
fi
SKILL_DETECTED_COUNT=${#SKILL_TARGET_DIRS[@]}
}
default_install_dir() {
@@ -856,6 +867,8 @@ join_with_comma() {
done
}
# The ${a[@]+"${a[@]}"} form expands an empty array: bash 3.2, the macOS
# default, treats a plain "${a[@]}" of one as unbound under set -u.
strip_matching_install_paths() {
local target="$1"
local filtered=()
@@ -865,7 +878,7 @@ strip_matching_install_paths() {
filtered+=("$path")
fi
done
UNINSTALL_INSTALL_PATHS=("${filtered[@]}")
UNINSTALL_INSTALL_PATHS=(${filtered[@]+"${filtered[@]}"})
}
strip_matching_service_scopes() {
@@ -877,7 +890,7 @@ strip_matching_service_scopes() {
filtered+=("$scope")
fi
done
UNINSTALL_SERVICE_SCOPES=("${filtered[@]}")
UNINSTALL_SERVICE_SCOPES=(${filtered[@]+"${filtered[@]}"})
}
choose_operation_mode() {
@@ -1149,14 +1162,16 @@ discover_mac_uninstall() {
}
discover_skill_removals() {
local agents_home codex_home xdg_copilot home_copilot custom_dir
local agents_home codex_home copilot_skill xdg_copilot home_copilot custom_dir
if [[ -d "${HOME}/.claude/skills/dagu" ]]; then
add_uninstall_skill_dir "${HOME}/.claude/skills/dagu"
fi
agents_home="${AGENTS_HOME:-${HOME}/.agents}"
if [[ -d "${agents_home}/skills/dagu" ]]; then
add_uninstall_skill_dir "${agents_home}/skills/dagu"
fi
# npx skills --global writes to ~/.agents whatever AGENTS_HOME says.
for agents_home in "${AGENTS_HOME:-${HOME}/.agents}" "${HOME}/.agents"; do
if [[ -d "${agents_home}/skills/dagu" ]]; then
add_uninstall_skill_dir "${agents_home}/skills/dagu"
fi
done
codex_home="${CODEX_HOME:-${HOME}/.codex}"
if [[ -d "${codex_home}/skills/dagu" ]]; then
add_uninstall_skill_dir "${codex_home}/skills/dagu"
@@ -1167,6 +1182,10 @@ discover_skill_removals() {
if [[ -d "${HOME}/.gemini/skills/dagu" ]]; then
add_uninstall_skill_dir "${HOME}/.gemini/skills/dagu"
fi
copilot_skill="$(copilot_home_dir)/skills/dagu"
if [[ -d "${copilot_skill}" ]]; then
add_uninstall_skill_dir "${copilot_skill}"
fi
xdg_copilot="${XDG_CONFIG_HOME:-${HOME}}/.copilot/copilot-instructions.md"
home_copilot="${HOME}/.copilot/copilot-instructions.md"
if [[ -f "${xdg_copilot}" ]]; then
@@ -1289,7 +1308,7 @@ show_uninstall_plan() {
ui_kv "Data directory" "${data_action}: $( [[ ${#UNINSTALL_DAGU_HOMES[@]} -gt 0 ]] && join_with_comma "${UNINSTALL_DAGU_HOMES[@]}" || printf 'none detected' )"
ui_kv "PATH cleanup" "$( [[ ${#UNINSTALL_PATH_PROFILES[@]} -gt 0 ]] && join_with_comma "${UNINSTALL_PATH_PROFILES[@]}" || printf 'none detected' )"
if [[ "$REMOVE_SKILL" == "1" ]]; then
ui_kv "AI skill removal" "$( [[ ${#UNINSTALL_SKILL_DIRS[@]} -gt 0 || ${#UNINSTALL_COPILOT_FILES[@]} -gt 0 ]] && join_with_comma "${UNINSTALL_SKILL_DIRS[@]}" "${UNINSTALL_COPILOT_FILES[@]}" || printf 'requested, but nothing detected' )"
ui_kv "AI skill removal" "$( [[ ${#UNINSTALL_SKILL_DIRS[@]} -gt 0 || ${#UNINSTALL_COPILOT_FILES[@]} -gt 0 ]] && join_with_comma ${UNINSTALL_SKILL_DIRS[@]+"${UNINSTALL_SKILL_DIRS[@]}"} ${UNINSTALL_COPILOT_FILES[@]+"${UNINSTALL_COPILOT_FILES[@]}"} || printf 'requested, but nothing detected' )"
else
ui_kv "AI skill removal" "keep"
fi
@@ -2074,7 +2093,7 @@ verify_bootstrap_flow() {
}
install_skill() {
local custom_dir
local custom_dir target_dir
if [[ ${#EXPLICIT_SKILL_DIRS[@]} -eq 0 && "${SKILL_MODE:-skip}" != "auto" ]]; then
return 0
fi
@@ -2086,22 +2105,28 @@ install_skill() {
for custom_dir in "${EXPLICIT_SKILL_DIRS[@]}"; do
ui_warn "--skills-dir is no longer supported by the Dagu installer: ${custom_dir}"
done
ui_warn "Install the skill with: gh skill install dagucloud/dagu dagu"
ui_warn "Install the skill with: gh skill install dagucloud/dagu dagu --scope user"
return 0
fi
# Both installers default to the project in the current directory, and
# stdin may be this script piped into bash: name the user-level target
# and keep them off stdin.
if command -v gh >/dev/null 2>&1; then
if ! gh skill install dagucloud/dagu dagu; then
ui_warn "Failed to install the Dagu AI skill. Install manually with: gh skill install dagucloud/dagu dagu"
fi
for target_dir in "${SKILL_TARGET_DIRS[@]:-}"; do
[[ -n "$target_dir" ]] || continue
if ! gh skill install dagucloud/dagu dagu --dir "$target_dir" --force </dev/null; then
ui_warn "Failed to install the Dagu AI skill into ${target_dir}. Install manually with: gh skill install dagucloud/dagu dagu --dir \"${target_dir}\" --force"
fi
done
return 0
fi
if command -v npx >/dev/null 2>&1; then
if ! npx skills add https://github.com/dagucloud/dagu --skill dagu; then
ui_warn "Failed to install the Dagu AI skill. Install manually with: npx skills add https://github.com/dagucloud/dagu --skill dagu"
if ! npx --yes skills add https://github.com/dagucloud/dagu --skill dagu --global --yes </dev/null; then
ui_warn "Failed to install the Dagu AI skill. Install manually with: npx skills add https://github.com/dagucloud/dagu --skill dagu --global"
fi
return 0
fi
ui_warn "No shared skills installer was found. Install manually with: gh skill install dagucloud/dagu dagu"
ui_warn "No shared skills installer was found. Install manually with: gh skill install dagucloud/dagu dagu --scope user"
}
open_browser_if_requested() {