This repository has been archived on 2026-07-15. You can view files and clone it. You cannot open issues or pull requests or push a commit.
Files
ClaudeInit/.claude/hooks/session-init.ps1
2026-04-24 16:42:22 +08:00

25 lines
861 B
PowerShell
Raw Permalink Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# session-init.ps1 — Claude Code SessionStart hook
# 1. 清除上次会话的 changelog ack 标记
# 2. 检查 .claude/.init-done sentinel缺失时创建 .pending-init 标记文件
# claude-init-recall 规则会检测此文件,确保首次会话确定性触发 claude-init
$input = [Console]::In.ReadToEnd()
# 清除 changelog ack 标记
Remove-Item ".claude\changelog\.changelog-ack" -ErrorAction SilentlyContinue
# 检查 claude-init sentinel
$initDone = ".claude\.init-done"
$pendingInit = ".claude\.pending-init"
if (Test-Path $initDone) {
# sentinel 存在,清理可能残留的 pending 标记
Remove-Item $pendingInit -ErrorAction SilentlyContinue
} else {
# sentinel 缺失,创建 pending 标记供 claude-init-recall 规则检测
New-Item -ItemType File -Path $pendingInit -Force | Out-Null
}
Write-Output '{}'
exit 0