dsh-dev-modes 1.1.0 → 1.1.2
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +40 -0
- package/client.js +35 -38
- package/helpers/window-quiet.ps1 +186 -0
- package/package.json +3 -2
- package/quiet-run/index.js +19 -9
- package/skills/game-godot/SKILL.md +11 -0
package/README.md
CHANGED
|
@@ -18,6 +18,46 @@
|
|
|
18
18
|
|
|
19
19
|
如果 `~/.dsh/skills/` 里还留着同名副本,运行时会优先使用本包注册的版本;可以删掉副本以免困惑。
|
|
20
20
|
|
|
21
|
+
## 自带开关(1.1.0 起)
|
|
22
|
+
|
|
23
|
+
本包另外挂载两个**宿主级**插件,所以对**所有** Agent 预设生效(包括内置的 Standard / PTC / Minimal / Creator),不只是本包的三个模式。输入框旁边并排两个按钮:
|
|
24
|
+
|
|
25
|
+
| 按钮 | 作用 | 默认 |
|
|
26
|
+
|---|---|---|
|
|
27
|
+
| 🔒 禁止读其它会话 | 每个会话独立:锁定时禁止读取 `~/.dsh/sessions/` 等其它会话文件 | 锁定 |
|
|
28
|
+
| 🔇 静默运行 | 每个会话独立:启动游戏窗口/编辑器时必须挪到屏幕外或改用无窗口方式,不挡前台、不抢焦点 | 静默 |
|
|
29
|
+
|
|
30
|
+
点一下切换,对**当前会话**生效,下一次模型请求立刻起作用。
|
|
31
|
+
|
|
32
|
+
状态存储(升级后原有设置保留):
|
|
33
|
+
|
|
34
|
+
```
|
|
35
|
+
$DSH_HOME/storages/dsh-session-lock/policies.json
|
|
36
|
+
$DSH_HOME/storages/dsh-quiet-run/state.json
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
> 这两个是**提示词级约束**,不是强制拦截:模型被告知规则并遵守,但宿主不会物理阻止。
|
|
40
|
+
|
|
41
|
+
## 静默运行怎么真正生效
|
|
42
|
+
|
|
43
|
+
光有规则还不够——窗口得有人去搬。本包内置 `helpers/window-quiet.ps1`:
|
|
44
|
+
|
|
45
|
+
```powershell
|
|
46
|
+
# 列出当前可见窗口(句柄|PID|坐标|标题)
|
|
47
|
+
powershell.exe -NoProfile -ExecutionPolicy Bypass -File helpers\window-quiet.ps1 -Action list
|
|
48
|
+
|
|
49
|
+
# 按进程号或标题把窗口移到 (20000,20000)
|
|
50
|
+
powershell.exe -NoProfile -ExecutionPolicy Bypass -File helpers\window-quiet.ps1 -Action hide -ProcessId 12345
|
|
51
|
+
powershell.exe -NoProfile -ExecutionPolicy Bypass -File helpers\window-quiet.ps1 -Action hide -Title "记事本"
|
|
52
|
+
|
|
53
|
+
# 全部还原到原坐标
|
|
54
|
+
powershell.exe -NoProfile -ExecutionPolicy Bypass -File helpers\window-quiet.ps1 -Action show
|
|
55
|
+
```
|
|
56
|
+
|
|
57
|
+
静默规则里写的是**这个脚本的绝对路径**,所以模型拿到的是可直接执行的命令,而不是一句"请把窗口移走"的空话。Godot 项目另有更快的做法:`godot_command eval "DisplayServer.window_set_position(Vector2i(20000, 20000))"`。
|
|
58
|
+
|
|
59
|
+
局限:全屏独占的窗口搬不动(Windows 限制),脚本会返回失败——这时模型应当如实告诉你,而不是假装藏好了。
|
|
60
|
+
|
|
21
61
|
## 安装
|
|
22
62
|
|
|
23
63
|
```text
|
package/client.js
CHANGED
|
@@ -44,20 +44,30 @@ window.__ModuleLoader__.load({
|
|
|
44
44
|
return await res.json();
|
|
45
45
|
}
|
|
46
46
|
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
47
|
+
function stateUrl(apiPath, sessionId) {
|
|
48
|
+
return apiPath + '/state' + (sessionId ? '?sessionId=' + encodeURIComponent(sessionId) : '');
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/**
|
|
52
|
+
* 一个开关按钮。
|
|
53
|
+
* sessionId 来自插槽标准 props —— 必须带上,否则宿主只能猜"当前会话",
|
|
54
|
+
* 多开窗口时会写到别的会话去(表现就是"点了没反应 / 关不掉")。
|
|
55
|
+
*/
|
|
56
|
+
function SwitchButton({ apiPath, sessionId, swKey, iconOn, iconOff, labelOn, labelOff, titleOn, titleOff }) {
|
|
57
|
+
const [value, setValue] = React.useState(true);
|
|
50
58
|
const [ready, setReady] = React.useState(false);
|
|
59
|
+
const [busy, setBusy] = React.useState(false);
|
|
60
|
+
const [note, setNote] = React.useState('');
|
|
51
61
|
|
|
52
62
|
const refresh = React.useCallback(async () => {
|
|
53
63
|
try {
|
|
54
|
-
const s = await getJson(apiPath
|
|
64
|
+
const s = await getJson(stateUrl(apiPath, sessionId));
|
|
55
65
|
setReady(Boolean(s.ready));
|
|
56
|
-
setValue(s[
|
|
66
|
+
setValue(s[swKey] !== false);
|
|
57
67
|
} catch (e) {
|
|
58
68
|
setReady(false);
|
|
59
69
|
}
|
|
60
|
-
}, [apiPath,
|
|
70
|
+
}, [apiPath, sessionId, swKey]);
|
|
61
71
|
|
|
62
72
|
React.useEffect(() => {
|
|
63
73
|
refresh();
|
|
@@ -65,34 +75,20 @@ window.__ModuleLoader__.load({
|
|
|
65
75
|
return () => clearInterval(id);
|
|
66
76
|
}, [refresh]);
|
|
67
77
|
|
|
68
|
-
const set = React.useCallback(
|
|
69
|
-
async (next) => {
|
|
70
|
-
await postJson(apiPath + '/set', { [key]: next });
|
|
71
|
-
setValue(next);
|
|
72
|
-
},
|
|
73
|
-
[apiPath, key],
|
|
74
|
-
);
|
|
75
|
-
|
|
76
|
-
return { value, ready, set };
|
|
77
|
-
}
|
|
78
|
-
|
|
79
|
-
function SwitchButton({ apiPath, key, iconOn, iconOff, labelOn, labelOff, titleOn, titleOff, warnWhenOn }) {
|
|
80
|
-
const { value, ready, set } = useSwitch(apiPath, key, key !== 'locked');
|
|
81
|
-
const [busy, setBusy] = React.useState(false);
|
|
82
|
-
const [note, setNote] = React.useState('');
|
|
83
|
-
|
|
84
78
|
const onClick = async () => {
|
|
85
79
|
if (busy || !ready) return;
|
|
86
80
|
setBusy(true);
|
|
87
81
|
setNote('');
|
|
82
|
+
const next = !value;
|
|
88
83
|
try {
|
|
89
|
-
|
|
90
|
-
|
|
84
|
+
await postJson(apiPath + '/set', { sessionId, [swKey]: next });
|
|
85
|
+
setValue(next);
|
|
91
86
|
setNote(next ? '已开启' : '已关闭');
|
|
92
87
|
setTimeout(() => setNote(''), 3000);
|
|
88
|
+
setTimeout(refresh, 300);
|
|
93
89
|
} catch (e) {
|
|
94
90
|
setNote('切换失败:' + ((e && e.message) || String(e)));
|
|
95
|
-
setTimeout(() => setNote(''),
|
|
91
|
+
setTimeout(() => setNote(''), 6000);
|
|
96
92
|
} finally {
|
|
97
93
|
setBusy(false);
|
|
98
94
|
}
|
|
@@ -100,8 +96,13 @@ window.__ModuleLoader__.load({
|
|
|
100
96
|
|
|
101
97
|
const icon = !ready ? '⏳' : value ? iconOn : iconOff;
|
|
102
98
|
const label = !ready ? '未就绪' : value ? labelOn : labelOff;
|
|
103
|
-
const title = !ready
|
|
104
|
-
|
|
99
|
+
const title = !ready
|
|
100
|
+
? sessionId
|
|
101
|
+
? '本会话尚未建立,稍后再试'
|
|
102
|
+
: '还没有会话,稍后再试'
|
|
103
|
+
: value
|
|
104
|
+
? titleOn
|
|
105
|
+
: titleOff;
|
|
105
106
|
|
|
106
107
|
return h(
|
|
107
108
|
'div',
|
|
@@ -113,12 +114,7 @@ window.__ModuleLoader__.load({
|
|
|
113
114
|
onClick,
|
|
114
115
|
disabled: busy || !ready,
|
|
115
116
|
title,
|
|
116
|
-
style: Object.assign(
|
|
117
|
-
{},
|
|
118
|
-
baseBtn,
|
|
119
|
-
busy || !ready ? { opacity: 0.55 } : null,
|
|
120
|
-
warn ? { borderColor: 'rgba(255,138,0,0.6)' } : null,
|
|
121
|
-
),
|
|
117
|
+
style: Object.assign({}, baseBtn, busy || !ready ? { opacity: 0.55 } : null),
|
|
122
118
|
},
|
|
123
119
|
h('span', { style: { fontSize: 14 } }, icon),
|
|
124
120
|
h('span', { style: { fontSize: 12, opacity: 0.85 } }, label),
|
|
@@ -127,31 +123,32 @@ window.__ModuleLoader__.load({
|
|
|
127
123
|
);
|
|
128
124
|
}
|
|
129
125
|
|
|
130
|
-
function DevModeSwitch() {
|
|
126
|
+
function DevModeSwitch(props) {
|
|
127
|
+
const sessionId = props && props.sessionId;
|
|
131
128
|
return h(
|
|
132
129
|
'div',
|
|
133
130
|
{ style: { display: 'inline-flex', alignItems: 'center', gap: 8 } },
|
|
134
131
|
h(SwitchButton, {
|
|
135
132
|
apiPath: '/dsh-session-lock',
|
|
136
|
-
|
|
133
|
+
sessionId,
|
|
134
|
+
swKey: 'locked',
|
|
137
135
|
iconOn: '🔒',
|
|
138
136
|
iconOff: '🔓',
|
|
139
137
|
labelOn: '禁止读其它会话',
|
|
140
138
|
labelOff: '允许读其它会话',
|
|
141
139
|
titleOn: '当前会话已锁定:不会读取其它会话的内容。点击允许。',
|
|
142
140
|
titleOff: '当前会话已允许:可以读取其它会话。点击锁定。',
|
|
143
|
-
warnWhenOn: false,
|
|
144
141
|
}),
|
|
145
142
|
h(SwitchButton, {
|
|
146
143
|
apiPath: '/dsh-quiet-run',
|
|
147
|
-
|
|
144
|
+
sessionId,
|
|
145
|
+
swKey: 'quiet',
|
|
148
146
|
iconOn: '🔇',
|
|
149
147
|
iconOff: '🔊',
|
|
150
148
|
labelOn: '静默运行',
|
|
151
149
|
labelOff: '可见运行',
|
|
152
150
|
titleOn: '静默运行:启动游戏或编辑器时会挪到屏幕外,不挡你、不抢焦点。点击改为可见。',
|
|
153
151
|
titleOff: '可见运行:允许窗口出现在前台。点击改回静默。',
|
|
154
|
-
warnWhenOn: false,
|
|
155
152
|
}),
|
|
156
153
|
);
|
|
157
154
|
}
|
|
@@ -0,0 +1,186 @@
|
|
|
1
|
+
<#
|
|
2
|
+
window-quiet.ps1 — 把窗口挪到屏幕外 / 还原。
|
|
3
|
+
|
|
4
|
+
用途:静默运行模式下启动 GUI(游戏、编辑器、浏览器预览)后,立刻把窗口移到
|
|
5
|
+
可视区域之外,避免挡住用户、抢走焦点;需要用户亲眼看时再把它移回来。
|
|
6
|
+
|
|
7
|
+
用法:
|
|
8
|
+
# 列出当前可见窗口(句柄|PID|left,top|caption)
|
|
9
|
+
pwsh -File window-quiet.ps1 -Action list
|
|
10
|
+
|
|
11
|
+
# 把记事本窗口挪走
|
|
12
|
+
pwsh -File window-quiet.ps1 -Action hide -Title "记事本"
|
|
13
|
+
|
|
14
|
+
# 按进程号挪(适合刚启动、还不确定标题的程序)
|
|
15
|
+
pwsh -File window-quiet.ps1 -Action hide -ProcessId 12345
|
|
16
|
+
|
|
17
|
+
# 全部还原
|
|
18
|
+
pwsh -File window-quiet.ps1 -Action show
|
|
19
|
+
|
|
20
|
+
说明:
|
|
21
|
+
- 只按"可见且标题非空"的顶层窗口匹配,避免误伤系统窗口。
|
|
22
|
+
- 挪走前会把原坐标记到临时文件,-Action show 时原位还原。
|
|
23
|
+
- 全屏独占的窗口挪不动,这是 Windows 的限制,此脚本会返回失败并说明。
|
|
24
|
+
#>
|
|
25
|
+
param(
|
|
26
|
+
[Parameter(Mandatory = $true)]
|
|
27
|
+
[ValidateSet('list', 'hide', 'show')]
|
|
28
|
+
[string]$Action,
|
|
29
|
+
|
|
30
|
+
[string]$Title,
|
|
31
|
+
[int]$ProcessId = 0,
|
|
32
|
+
[int]$X = 20000,
|
|
33
|
+
[int]$Y = 20000
|
|
34
|
+
)
|
|
35
|
+
|
|
36
|
+
$ErrorActionPreference = 'Stop'
|
|
37
|
+
|
|
38
|
+
$sig = @'
|
|
39
|
+
using System;
|
|
40
|
+
using System.Text;
|
|
41
|
+
using System.Collections.Generic;
|
|
42
|
+
using System.Runtime.InteropServices;
|
|
43
|
+
public class DshWin {
|
|
44
|
+
public delegate bool EnumProc(IntPtr h, IntPtr l);
|
|
45
|
+
[DllImport("user32.dll")] public static extern bool EnumWindows(EnumProc cb, IntPtr l);
|
|
46
|
+
[DllImport("user32.dll")] public static extern bool IsWindowVisible(IntPtr h);
|
|
47
|
+
[DllImport("user32.dll")] public static extern bool IsIconic(IntPtr h);
|
|
48
|
+
[DllImport("user32.dll", CharSet=CharSet.Unicode)] public static extern int GetWindowTextW(IntPtr h, StringBuilder s, int n);
|
|
49
|
+
[DllImport("user32.dll")] public static extern uint GetWindowThreadProcessId(IntPtr h, out uint pid);
|
|
50
|
+
[DllImport("user32.dll")] public static extern bool SetWindowPos(IntPtr h, IntPtr after, int x, int y, int cx, int cy, uint flags);
|
|
51
|
+
[DllImport("user32.dll")] public static extern bool GetWindowRect(IntPtr h, out RECT r);
|
|
52
|
+
public struct RECT { public int Left, Top, Right, Bottom; }
|
|
53
|
+
|
|
54
|
+
public static List<string> List() {
|
|
55
|
+
var acc = new List<string>();
|
|
56
|
+
EnumWindows((h, l) => {
|
|
57
|
+
if (!IsWindowVisible(h)) return true;
|
|
58
|
+
var sb = new StringBuilder(1024);
|
|
59
|
+
GetWindowTextW(h, sb, 1024);
|
|
60
|
+
var title = sb.ToString();
|
|
61
|
+
if (title.Length == 0) return true;
|
|
62
|
+
uint pid; GetWindowThreadProcessId(h, out pid);
|
|
63
|
+
RECT r; GetWindowRect(h, out r);
|
|
64
|
+
var w = r.Right - r.Left; var ht = r.Bottom - r.Top;
|
|
65
|
+
acc.Add(h.ToInt64() + "|" + pid + "|" + r.Left + "|" + r.Top + "|" + w + "|" + ht + "|" + title);
|
|
66
|
+
return true;
|
|
67
|
+
}, IntPtr.Zero);
|
|
68
|
+
return acc;
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
public static string Rect(IntPtr h) {
|
|
72
|
+
RECT r; GetWindowRect(h, out r);
|
|
73
|
+
return r.Left + "," + r.Top + "," + (r.Right - r.Left) + "," + (r.Bottom - r.Top);
|
|
74
|
+
}
|
|
75
|
+
|
|
76
|
+
public static bool Move(IntPtr h, int x, int y, int cx, int cy) {
|
|
77
|
+
// SWP_NOZORDER(0x4) | SWP_NOACTIVATE(0x10) —— 不改层级、不抢焦点
|
|
78
|
+
return SetWindowPos(h, IntPtr.Zero, x, y, cx, cy, 0x0014);
|
|
79
|
+
}
|
|
80
|
+
}
|
|
81
|
+
'@
|
|
82
|
+
|
|
83
|
+
if (-not ('DshWin' -as [type])) {
|
|
84
|
+
Add-Type -TypeDefinition $sig -ErrorAction Stop
|
|
85
|
+
}
|
|
86
|
+
|
|
87
|
+
$stateFile = Join-Path $env:TEMP 'dsh-quiet-windows.json'
|
|
88
|
+
|
|
89
|
+
function Read-State {
|
|
90
|
+
if (-not (Test-Path $stateFile)) { return @() }
|
|
91
|
+
try {
|
|
92
|
+
$raw = Get-Content $stateFile -Raw -Encoding UTF8 | ConvertFrom-Json
|
|
93
|
+
} catch {
|
|
94
|
+
return @()
|
|
95
|
+
}
|
|
96
|
+
$flat = New-Object System.Collections.ArrayList
|
|
97
|
+
foreach ($item in @($raw)) {
|
|
98
|
+
if ($null -eq $item) { continue }
|
|
99
|
+
if ($item -is [System.Array]) {
|
|
100
|
+
foreach ($inner in $item) { if ($inner) { [void]$flat.Add($inner) } }
|
|
101
|
+
} else {
|
|
102
|
+
[void]$flat.Add($item)
|
|
103
|
+
}
|
|
104
|
+
}
|
|
105
|
+
return $flat.ToArray()
|
|
106
|
+
}
|
|
107
|
+
|
|
108
|
+
function Write-State($rows) {
|
|
109
|
+
$flat = New-Object System.Collections.ArrayList
|
|
110
|
+
foreach ($item in @($rows)) {
|
|
111
|
+
if ($null -eq $item) { continue }
|
|
112
|
+
if ($item -is [System.Array]) { foreach ($inner in $item) { if ($inner) { [void]$flat.Add($inner) } } }
|
|
113
|
+
else { [void]$flat.Add($item) }
|
|
114
|
+
}
|
|
115
|
+
if ($flat.Count -eq 0) {
|
|
116
|
+
Remove-Item $stateFile -ErrorAction SilentlyContinue
|
|
117
|
+
return
|
|
118
|
+
}
|
|
119
|
+
# 手工拼 JSON 数组,避免单元素被 ConvertTo-Json 序列化成对象
|
|
120
|
+
$body = ($flat | ForEach-Object { $_ | ConvertTo-Json -Depth 5 -Compress }) -join ','
|
|
121
|
+
[System.IO.File]::WriteAllText($stateFile, "[$body]", (New-Object System.Text.UTF8Encoding($false)))
|
|
122
|
+
}
|
|
123
|
+
|
|
124
|
+
$all = [DshWin]::List() | ForEach-Object {
|
|
125
|
+
$p = $_ -split '\|', 7
|
|
126
|
+
[pscustomobject]@{
|
|
127
|
+
handle = [int64]$p[0]; pid = [int]$p[1]
|
|
128
|
+
left = [int]$p[2]; top = [int]$p[3]; width = [int]$p[4]; height = [int]$p[5]
|
|
129
|
+
title = $p[6]
|
|
130
|
+
}
|
|
131
|
+
}
|
|
132
|
+
|
|
133
|
+
switch ($Action) {
|
|
134
|
+
'list' {
|
|
135
|
+
if (-not $all) { '(没有可见窗口)'; break }
|
|
136
|
+
$all | ForEach-Object { "{0}|{1}|{2},{3}|{4}x{5}|{6}" -f $_.handle, $_.pid, $_.left, $_.top, $_.width, $_.height, $_.title }
|
|
137
|
+
break
|
|
138
|
+
}
|
|
139
|
+
|
|
140
|
+
'hide' {
|
|
141
|
+
$matched = $all
|
|
142
|
+
if ($ProcessId -gt 0) { $matched = $matched | Where-Object { $_.pid -eq $ProcessId } }
|
|
143
|
+
if ($Title) { $matched = $matched | Where-Object { $_.title -like "*$Title*" } }
|
|
144
|
+
if (-not $matched) {
|
|
145
|
+
"未匹配到窗口(Title='$Title' ProcessId=$ProcessId)" | Write-Error
|
|
146
|
+
exit 1
|
|
147
|
+
}
|
|
148
|
+
|
|
149
|
+
$state = @(Read-State)
|
|
150
|
+
foreach ($w in $matched) {
|
|
151
|
+
$ok = [DshWin]::Move([IntPtr]$w.handle, $X, $Y, $w.width, $w.height)
|
|
152
|
+
if (-not $ok) {
|
|
153
|
+
"移动失败(可能是全屏独占窗口):$($w.title)"
|
|
154
|
+
continue
|
|
155
|
+
}
|
|
156
|
+
$state += [pscustomobject]@{
|
|
157
|
+
handle = $w.handle; pid = $w.pid; title = $w.title
|
|
158
|
+
left = $w.left; top = $w.top; width = $w.width; height = $w.height
|
|
159
|
+
}
|
|
160
|
+
"已移出可视区:$($w.title) → ($X,$Y)"
|
|
161
|
+
}
|
|
162
|
+
Write-State $state
|
|
163
|
+
break
|
|
164
|
+
}
|
|
165
|
+
|
|
166
|
+
'show' {
|
|
167
|
+
$state = Read-State
|
|
168
|
+
if (-not $state -or $state.Count -eq 0) {
|
|
169
|
+
'没有记录到需要还原的窗口'
|
|
170
|
+
break
|
|
171
|
+
}
|
|
172
|
+
$remaining = New-Object System.Collections.ArrayList
|
|
173
|
+
foreach ($s in $state) {
|
|
174
|
+
$handle = [int64]$s.handle
|
|
175
|
+
$ok = [DshWin]::Move([IntPtr]$handle, [int]$s.left, [int]$s.top, [int]$s.width, [int]$s.height)
|
|
176
|
+
if ($ok) {
|
|
177
|
+
"已还原:$($s.title) → ($($s.left),$($s.top))"
|
|
178
|
+
} else {
|
|
179
|
+
"还原失败(窗口可能已关闭):$($s.title)"
|
|
180
|
+
[void]$remaining.Add($s)
|
|
181
|
+
}
|
|
182
|
+
}
|
|
183
|
+
Write-State $remaining.ToArray()
|
|
184
|
+
break
|
|
185
|
+
}
|
|
186
|
+
}
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-dev-modes",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.2",
|
|
4
4
|
"type": "module",
|
|
5
5
|
"description": "Three DeepSeek Harness Agent presets in one bundle — plus the per-session isolation and quiet-run switches: software development, game development, and read-only discussion, with the matching delivery and engine workflows bundled as skills.",
|
|
6
6
|
"author": "qingfengshangnanzhi",
|
|
@@ -16,7 +16,8 @@
|
|
|
16
16
|
"files": [
|
|
17
17
|
"index.js",
|
|
18
18
|
"client.js",
|
|
19
|
-
"session-lock",
|
|
19
|
+
"session-lock",
|
|
20
|
+
"helpers",
|
|
20
21
|
"quiet-run",
|
|
21
22
|
"cordis.patch.yml",
|
|
22
23
|
"skills",
|
package/quiet-run/index.js
CHANGED
|
@@ -1,35 +1,45 @@
|
|
|
1
1
|
import fs from 'node:fs';
|
|
2
2
|
import path from 'node:path';
|
|
3
3
|
import os from 'node:os';
|
|
4
|
+
import { fileURLToPath } from 'node:url';
|
|
4
5
|
|
|
5
6
|
/**
|
|
6
7
|
* 每个会话独立的「静默运行」开关(并入 dsh-dev-modes)。
|
|
7
8
|
*
|
|
8
|
-
* 静默(默认):启动任何 GUI
|
|
9
|
+
* 静默(默认):启动任何 GUI 都必须立刻挪到屏幕外,不挡用户、不抢焦点。
|
|
9
10
|
* 可见:用户允许窗口出现在前台。
|
|
10
11
|
*
|
|
11
12
|
* 存储:$DSH_HOME/storages/dsh-quiet-run/state.json
|
|
12
13
|
* { "<sessionId>": { "quiet": true, "updatedAt": 1700000000000 } }
|
|
13
|
-
*
|
|
14
|
-
* 目录名沿用独立插件时期的名字,升级后原有设置继续生效。
|
|
15
14
|
*/
|
|
16
15
|
|
|
17
16
|
const HOME = process.env.DSH_HOME || path.join(os.homedir(), '.dsh');
|
|
18
17
|
const STORE_DIR = path.join(HOME, 'storages', 'dsh-quiet-run');
|
|
19
18
|
const STORE_FILE = path.join(STORE_DIR, 'state.json');
|
|
20
19
|
|
|
20
|
+
/** 与包一起分发的窗口搬运脚本(绝对路径,写进规则里让模型直接可用)。 */
|
|
21
|
+
const HELPER = path.join(
|
|
22
|
+
path.dirname(path.dirname(fileURLToPath(import.meta.url))),
|
|
23
|
+
'helpers',
|
|
24
|
+
'window-quiet.ps1',
|
|
25
|
+
);
|
|
26
|
+
|
|
21
27
|
const QUIET_RULE = [
|
|
22
28
|
'## 静默运行(本会话已开启)',
|
|
23
29
|
'',
|
|
24
30
|
'用户可能正在看视频或打字。启动任何 GUI 都不得挡住他、不得抢走焦点。',
|
|
25
31
|
'',
|
|
26
32
|
'- **优先无窗口**:构建、测试、lint、类型检查、逻辑验证一律用无界面方式(headless / batchmode / 纯命令行)',
|
|
27
|
-
'-
|
|
28
|
-
'
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
'
|
|
33
|
+
'- **启动 GUI 之后必须立刻把它移出可视区**,别只说不做。命令:',
|
|
34
|
+
' ```',
|
|
35
|
+
` powershell.exe -NoProfile -ExecutionPolicy Bypass -File "${HELPER}" -Action hide -ProcessId <刚启动的进程号>`,
|
|
36
|
+
` powershell.exe -NoProfile -ExecutionPolicy Bypass -File "${HELPER}" -Action hide -Title "<窗口标题片段>"`,
|
|
37
|
+
` powershell.exe -NoProfile -ExecutionPolicy Bypass -File "${HELPER}" -Action list # 查当前可见窗口`,
|
|
38
|
+
' ```',
|
|
39
|
+
'- 用户要用肉眼看效果时:先问,得到同意后 `-Action show` 还原。用完记得再移出去。',
|
|
40
|
+
'- 不要全屏;不要主动激活、置顶、聚焦窗口。',
|
|
41
|
+
'- 预计超过 1 分钟的构建或测试(首次导入、cook、导出、编译大项目)先说明再跑。',
|
|
42
|
+
'- `hide` 失败(例如全屏独占窗口)时**如实告诉用户"这个窗口挪不走"**,不要假装已经藏起来。',
|
|
33
43
|
].join('\n');
|
|
34
44
|
|
|
35
45
|
const VISIBLE_RULE = [
|
|
@@ -25,6 +25,17 @@ whenToUse: 项目有 project.godot 或 .tscn/.gd 文件,需要跑场景、改
|
|
|
25
25
|
- `godot_run_project` 可能接管用户已打开的实例并返回 `external:true`:此时**不要杀进程**。让用户在编辑器按 F8,或对子进程运行用 `godot_command` 的 `eval get_tree().quit()`。
|
|
26
26
|
- `eval` 只在非 debug 实例可用;需要多帧调用栈时才用 `debug:true`。
|
|
27
27
|
|
|
28
|
+
## 静默运行(开关开启时)
|
|
29
|
+
|
|
30
|
+
系统提示里有「静默运行」段落时,窗口不许挡用户。启动 GUI 后**立刻**执行,别只说不做:
|
|
31
|
+
|
|
32
|
+
- Godot 内部(首选,无闪烁):
|
|
33
|
+
`godot_command eval "DisplayServer.window_set_position(Vector2i(20000, 20000))"`
|
|
34
|
+
- 系统层面(也适用于编辑器、浏览器预览):
|
|
35
|
+
`powershell.exe -NoProfile -ExecutionPolicy Bypass -File "<包内 helpers/window-quiet.ps1>" -Action hide -ProcessId <PID>`
|
|
36
|
+
- 用户要用肉眼看效果:先问,同意后 `-Action show` 还原,用完再移出去。
|
|
37
|
+
- 全屏独占(`window_mode = fullscreen`)的窗口挪不走:如实说明,或先改成窗口模式再跑。
|
|
38
|
+
|
|
28
39
|
## 导出
|
|
29
40
|
|
|
30
41
|
- 先确认 `export_presets.cfg` 里已有对应预设、导出模板已安装,再 `godot_export_project`;缺预设就先建预设,不要盲调导出。
|