cursor Init 完善多人协同changelog,以及godot相关基础skill和代码规范
This commit is contained in:
@@ -1,23 +1,48 @@
|
||||
# session-init.ps1 — 会话启动时检测 composer_mode,非 agent 模式设置跳过标志
|
||||
#
|
||||
# sessionStart input 包含 composer_mode 字段("agent" / "ask" / "edit" / "debug" 等)
|
||||
# 通过 env 输出的环境变量会传递给同会话内所有后续 hook
|
||||
# sessionStart: reset changelog runtime markers and skip checks outside agent mode.
|
||||
$utf8 = New-Object System.Text.UTF8Encoding($false)
|
||||
[Console]::InputEncoding = $utf8
|
||||
[Console]::OutputEncoding = $utf8
|
||||
|
||||
$input = [Console]::In.ReadToEnd()
|
||||
$inputPayload = [Console]::In.ReadToEnd()
|
||||
$mode = $null
|
||||
|
||||
try {
|
||||
$data = $input | ConvertFrom-Json
|
||||
$mode = $data.composer_mode
|
||||
if (-not [string]::IsNullOrWhiteSpace($inputPayload)) {
|
||||
$data = $inputPayload | ConvertFrom-Json
|
||||
if ($data.composer_mode -is [string]) {
|
||||
$mode = $data.composer_mode
|
||||
}
|
||||
}
|
||||
} catch {
|
||||
$mode = $null
|
||||
}
|
||||
|
||||
Remove-Item ".cursor\changelog\.changelog-ack" -ErrorAction SilentlyContinue
|
||||
|
||||
if ($mode -and $mode -ne "agent") {
|
||||
$json = '{"env":{"CURSOR_SKIP_CHANGELOG":"1","CURSOR_COMPOSER_MODE":"' + $mode + '"}}'
|
||||
Write-Output $json
|
||||
} else {
|
||||
Write-Output '{}'
|
||||
$cursorDir = Split-Path -Parent $PSScriptRoot
|
||||
$ackFile = Join-Path $cursorDir 'changelog\.changelog-ack'
|
||||
$sessionMarker = Join-Path $cursorDir 'changelog\.session-start'
|
||||
Remove-Item -LiteralPath $ackFile -Force -ErrorAction SilentlyContinue
|
||||
try {
|
||||
$stream = [System.IO.File]::Open(
|
||||
$sessionMarker,
|
||||
[System.IO.FileMode]::Create,
|
||||
[System.IO.FileAccess]::Write,
|
||||
[System.IO.FileShare]::ReadWrite
|
||||
)
|
||||
$stream.Dispose()
|
||||
} catch {
|
||||
# Runtime marker failure must not block session startup.
|
||||
}
|
||||
|
||||
if (-not [string]::IsNullOrWhiteSpace($mode) -and $mode -ne 'agent') {
|
||||
$result = [ordered]@{
|
||||
env = [ordered]@{
|
||||
CURSOR_SKIP_CHANGELOG = '1'
|
||||
CURSOR_COMPOSER_MODE = $mode
|
||||
}
|
||||
}
|
||||
[Console]::Out.WriteLine(($result | ConvertTo-Json -Compress -Depth 4))
|
||||
} else {
|
||||
[Console]::Out.WriteLine('{}')
|
||||
}
|
||||
|
||||
exit 0
|
||||
|
||||
Reference in New Issue
Block a user