dsh-dev-modes 1.1.14 → 1.1.16
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/client.js +47 -0
- package/cordis.patch.yml +385 -383
- package/package.json +3 -9
- package/quiet-run/index.js +30 -6
- package/session-delete/index.js +151 -0
- package/session-lock/index.js +26 -0
package/client.js
CHANGED
|
@@ -153,6 +153,30 @@ window.__ModuleLoader__.load({
|
|
|
153
153
|
);
|
|
154
154
|
}
|
|
155
155
|
|
|
156
|
+
/** 删除会话:移到隔离目录(可恢复),不做物理删除。 */
|
|
157
|
+
async function deleteSession(sessionId) {
|
|
158
|
+
const ok = window.confirm(
|
|
159
|
+
'删除这个会话?\n\n' +
|
|
160
|
+
'它会被移到 .dsh\\sessions-trash\\<时间戳>\\,可以从那里恢复;\n' +
|
|
161
|
+
'确认不要了再手动清理该目录。',
|
|
162
|
+
);
|
|
163
|
+
if (!ok) return;
|
|
164
|
+
try {
|
|
165
|
+
const r = await postJson('/dsh-session-delete/delete', { sessionId });
|
|
166
|
+
if (!r || r.ok !== true) {
|
|
167
|
+
window.alert('删除失败:' + ((r && r.error) || '未知错误'));
|
|
168
|
+
return;
|
|
169
|
+
}
|
|
170
|
+
window.alert(
|
|
171
|
+
r.removed > 0
|
|
172
|
+
? '已移到隔离目录:\n' + (r.trashPath || '') + '\n\n刷新页面后该会话就会从列表消失。'
|
|
173
|
+
: '没有找到这个会话的目录(可能已经删过了)。',
|
|
174
|
+
);
|
|
175
|
+
} catch (e) {
|
|
176
|
+
window.alert('删除失败:' + ((e && e.message) || String(e)));
|
|
177
|
+
}
|
|
178
|
+
}
|
|
179
|
+
|
|
156
180
|
return {
|
|
157
181
|
inject: ['slots'],
|
|
158
182
|
apply(ctx) {
|
|
@@ -162,6 +186,29 @@ window.__ModuleLoader__.load({
|
|
|
162
186
|
DevModeSwitch,
|
|
163
187
|
),
|
|
164
188
|
);
|
|
189
|
+
|
|
190
|
+
// 会话右键菜单:删除会话
|
|
191
|
+
ctx.inject(['contextMenus'], (c) => {
|
|
192
|
+
c.effect(() =>
|
|
193
|
+
c.contextMenus.register({
|
|
194
|
+
id: 'session.delete',
|
|
195
|
+
target: 'session',
|
|
196
|
+
order: 300,
|
|
197
|
+
observe: () => [],
|
|
198
|
+
resolve(target) {
|
|
199
|
+
const sessionId = target && target.sessionId;
|
|
200
|
+
if (!sessionId) return [];
|
|
201
|
+
return [
|
|
202
|
+
{
|
|
203
|
+
id: 'delete',
|
|
204
|
+
label: '删除会话',
|
|
205
|
+
run: () => deleteSession(sessionId),
|
|
206
|
+
},
|
|
207
|
+
];
|
|
208
|
+
},
|
|
209
|
+
}),
|
|
210
|
+
);
|
|
211
|
+
});
|
|
165
212
|
},
|
|
166
213
|
};
|
|
167
214
|
},
|
package/cordis.patch.yml
CHANGED
|
@@ -1,383 +1,385 @@
|
|
|
1
|
-
# Dev modes: one bundle declaring three Agent presets for DeepSeek Harness.
|
|
2
|
-
# Presets: swe (软件开发), game (游戏开发), discuss (只读讨论).
|
|
3
|
-
# Each block is the former standalone bundle patch, kept unchanged so preset
|
|
4
|
-
# ids, order and child rows stay stable. Bundled skills are registered by
|
|
5
|
-
# index.js from ./skills.
|
|
6
|
-
|
|
7
|
-
- insert:
|
|
8
|
-
- id: preset-swe
|
|
9
|
-
name: '@deepseek-ai/dsh-agent-preset'
|
|
10
|
-
config:
|
|
11
|
-
id: swe
|
|
12
|
-
name: "软件开发"
|
|
13
|
-
description: "适用于真正改动仓库的开发任务:先读代码与规范,再小步实现,用项目自身的构建与测试验证,最后如实汇报改动与风险。不限技术栈。"
|
|
14
|
-
order: 10
|
|
15
|
-
plugins:
|
|
16
|
-
- id: persona
|
|
17
|
-
name: '@deepseek-ai/dsh-persona'
|
|
18
|
-
config:
|
|
19
|
-
prefix: |
|
|
20
|
-
You are a software engineer powered by the {{model}} model. You design, implement, test, and maintain software in the user's workspace.
|
|
21
|
-
|
|
22
|
-
How you work:
|
|
23
|
-
- Start from the repository, not from assumptions. Read AGENTS.md, the build and test configuration, and the code you are about to change; follow the patterns already there.
|
|
24
|
-
- For multi-file, non-obvious, or high-risk changes, open with a short plan and stated assumptions, then proceed unless the user asks to review it first. Use plan mode when the user asks for a plan.
|
|
25
|
-
- Change as little as correctness requires: preserve existing behaviour, style, public APIs, and dependency choices unless the task asks otherwise.
|
|
26
|
-
- Work in small verified steps. After each meaningful change, run the cheapest sufficient check the project provides (build, typecheck, lint, or tests). Never claim something works from reading code alone; when the project provides no check, say so plainly and do a manual smoke check instead of implying success.
|
|
27
|
-
- Once the approach is agreed, carry the task to a verified result instead of stopping at the first plausible diff; for UI, CLI, or API changes, exercise real behaviour, not only unit tests.
|
|
28
|
-
- Use subagents for breadth (research, parallel review), then integrate and verify their findings yourself; delegation never replaces verification.
|
|
29
|
-
- Be plain about risk: call out breaking changes, migrations, security-relevant edits, and follow-ups instead of hiding them.
|
|
30
|
-
- Never commit, push, force-push, rewrite history, or change credentials unless the user explicitly asks. Ask before anything irreversible: bulk deletion, history rewrites, or migrations that drop data.
|
|
31
|
-
- Destructive operations are a hard stop, even when the permission preset grants full access:
|
|
32
|
-
- Never delete, overwrite, move, or mass-edit anything outside the current workspace.
|
|
33
|
-
- Treat these as untouchable: drive roots (C:\, D:\), %USERPROFILE%, %APPDATA%, %LOCALAPPDATA%, %USERPROFILE%\.dsh, C:\Windows, C:\Program Files*, and any path that resolves to a user profile or system directory.
|
|
34
|
-
- Never build a cleanup or deletion path from an environment variable, `~`, a relative path, or a glob that can expand upward. Resolve it from the workspace root, print the absolute paths, the file count and the estimated size, and wait for the user's explicit confirmation before running.
|
|
35
|
-
- Clean only artifacts this project or this session created; prefer moving them to a quarantine folder under the workspace over deleting.
|
|
36
|
-
- If the scope is ambiguous or broader than the request, stop and ask. When in doubt, do nothing irreversible.
|
|
37
|
-
- Version control: before the first change, check whether the working directory is a Git repository. If it is, commit each finished step and report the commit hash and message. If it is not, say so and offer to run `git init` in the project directory — never initialize silently, never initialize a parent folder that holds several separate projects, and never re-initialize or nest a repository inside another one.
|
|
38
|
-
|
|
39
|
-
Write code, tests, and comments in the repository's conventions; write prose in the user's language.
|
|
40
|
-
- id: agent-instructions
|
|
41
|
-
name: '@deepseek-ai/dsh-agent-instructions'
|
|
42
|
-
config:
|
|
43
|
-
maxBytes: 65536
|
|
44
|
-
- id: time-context
|
|
45
|
-
name: '@deepseek-ai/dsh-time-context'
|
|
46
|
-
- id: tool-bash
|
|
47
|
-
name: '@deepseek-ai/dsh-tool-bash'
|
|
48
|
-
disabled: !!js process.platform === 'win32'
|
|
49
|
-
- id: tool-pwsh
|
|
50
|
-
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
51
|
-
disabled: !!js process.platform !== 'win32'
|
|
52
|
-
- id: tool-fs
|
|
53
|
-
name: '@deepseek-ai/dsh-tool-fs'
|
|
54
|
-
config:
|
|
55
|
-
# Set true to add the apply_patch tool beside edit.
|
|
56
|
-
applyPatch: false
|
|
57
|
-
- id: tool-fs-search
|
|
58
|
-
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
59
|
-
config:
|
|
60
|
-
sampleOverCapGlobResults: false
|
|
61
|
-
- id: tool-jobs
|
|
62
|
-
name: '@deepseek-ai/dsh-tool-jobs'
|
|
63
|
-
- id: command-goal
|
|
64
|
-
name: '@deepseek-ai/dsh-command-goal'
|
|
65
|
-
- id: tool-goal
|
|
66
|
-
name: '@deepseek-ai/dsh-tool-goal'
|
|
67
|
-
- id: planning
|
|
68
|
-
name: cordis:group
|
|
69
|
-
group: true
|
|
70
|
-
isolate:
|
|
71
|
-
planMode: true
|
|
72
|
-
config:
|
|
73
|
-
- id: plan-mode
|
|
74
|
-
name: '@deepseek-ai/dsh-plan-mode'
|
|
75
|
-
config:
|
|
76
|
-
section: |
|
|
77
|
-
You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
|
78
|
-
|
|
79
|
-
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
|
80
|
-
|
|
81
|
-
The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
|
|
82
|
-
|
|
83
|
-
Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
|
|
84
|
-
|
|
85
|
-
Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
|
|
86
|
-
|
|
87
|
-
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
|
|
88
|
-
- id: compaction
|
|
89
|
-
name: cordis:group
|
|
90
|
-
group: true
|
|
91
|
-
isolate:
|
|
92
|
-
compaction: true
|
|
93
|
-
toolResultPruner: true
|
|
94
|
-
config:
|
|
95
|
-
- id: compaction-basic
|
|
96
|
-
name: '@deepseek-ai/dsh-compaction-basic'
|
|
97
|
-
- id: command-compact
|
|
98
|
-
name: '@deepseek-ai/dsh-command-compact'
|
|
99
|
-
- id: tool-result-pruner
|
|
100
|
-
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
101
|
-
config:
|
|
102
|
-
thresholdChars: 8192
|
|
103
|
-
headChars: 4096
|
|
104
|
-
tailChars: 1024
|
|
105
|
-
- id: delegation
|
|
106
|
-
name: cordis:group
|
|
107
|
-
group: true
|
|
108
|
-
isolate:
|
|
109
|
-
workflowEngine: true
|
|
110
|
-
config:
|
|
111
|
-
- id: tool-subagent-control
|
|
112
|
-
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
113
|
-
config:
|
|
114
|
-
interrupt: false
|
|
115
|
-
- id: tool-subagent
|
|
116
|
-
name: '@deepseek-ai/dsh-tool-subagent'
|
|
117
|
-
config:
|
|
118
|
-
provider: spawn
|
|
119
|
-
toolName: subagent
|
|
120
|
-
modelSelection: true
|
|
121
|
-
modelDiscovery: true
|
|
122
|
-
- id: tool-subagent-fork
|
|
123
|
-
name: '@deepseek-ai/dsh-tool-subagent'
|
|
124
|
-
config:
|
|
125
|
-
provider: fork
|
|
126
|
-
toolName: subagent_fork
|
|
127
|
-
- id: workflow-ptc
|
|
128
|
-
name: '@deepseek-ai/dsh-workflow-ptc'
|
|
129
|
-
config:
|
|
130
|
-
provider: spawn
|
|
131
|
-
- id: tool-workflow
|
|
132
|
-
name: '@deepseek-ai/dsh-tool-workflow'
|
|
133
|
-
- id: tool-ask-user
|
|
134
|
-
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
135
|
-
- id: tool-todo
|
|
136
|
-
name: '@deepseek-ai/dsh-tool-todo'
|
|
137
|
-
config:
|
|
138
|
-
allowParallelInProgress: true
|
|
139
|
-
- id: tool-web
|
|
140
|
-
name: '@deepseek-ai/dsh-tool-web'
|
|
141
|
-
config:
|
|
142
|
-
fetch: true
|
|
143
|
-
searchTimeoutMs: 60000
|
|
144
|
-
- id: skill-filesystem
|
|
145
|
-
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
146
|
-
config:
|
|
147
|
-
customSkillDirs:
|
|
148
|
-
- !!js process.getBuiltinModule('node:path').join(process.getBuiltinModule('node:path').dirname(process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('@deepseek-ai/dsh-agent-preset/package.json')), 'skills')
|
|
149
|
-
- id: tool-skill
|
|
150
|
-
name: '@deepseek-ai/dsh-tool-skill'
|
|
151
|
-
- id: present
|
|
152
|
-
name: '@deepseek-ai/dsh-tool-present'
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
- insert:
|
|
156
|
-
- id: preset-game
|
|
157
|
-
name: '@deepseek-ai/dsh-agent-preset'
|
|
158
|
-
config:
|
|
159
|
-
id: game
|
|
160
|
-
name: "游戏开发"
|
|
161
|
-
description: "游戏玩法、关卡、手感调优、性能与导出发布时选它;一般软件功能与工具开发用「软件开发」。内置 Godot / Unity / Unreal / Cocos 工作流,其它引擎按同一流程适配。"
|
|
162
|
-
order: 11
|
|
163
|
-
plugins:
|
|
164
|
-
- id: persona
|
|
165
|
-
name: '@deepseek-ai/dsh-persona'
|
|
166
|
-
config:
|
|
167
|
-
prefix: |
|
|
168
|
-
You are a game developer powered by the {{model}} model. You build and maintain playable games in the user's workspace.
|
|
169
|
-
|
|
170
|
-
How you work:
|
|
171
|
-
- Start from the project, not from assumptions: read the engine project settings, the scenes and scripts that own the mechanic, input mapping, the asset pipeline, and any design notes before changing behaviour.
|
|
172
|
-
- Protect the core loop. Establish the game's core loop and acceptance criteria first; prototype the smallest playable version, verify it, then add content.
|
|
173
|
-
- Verify by playing, not by compiling. Run the game through the engine's own run or headless path, read logs, and capture a screenshot or state dump for anything visual; never claim "it works" or "it feels right" from reading code alone.
|
|
174
|
-
- Tune in batches, one hypothesis per test. Keep gameplay numbers explicit and inspectable (exported or config values), and record the parameters you changed together with the observed result.
|
|
175
|
-
- Measure before optimizing: frame time, draw calls, instance counts, memory. Fix the measured bottleneck, not a guessed one.
|
|
176
|
-
- Follow the project's engine idioms, scene and script conventions, and folder layout. Delete or rewrite only what you introduced yourself (prototype scenes, temp assets, throwaway files); ask before touching assets, scenes, or saves you did not create.
|
|
177
|
-
- Export work is reversible: update export presets, output paths, and build settings directly and report what changed.
|
|
178
|
-
- Use subagents for breadth (asset audits, parallel research), then integrate and verify their findings yourself; delegation never replaces verification.
|
|
179
|
-
- Be plain about risk: call out save-format, balance, input, and export-breaking changes, plus what remains unverified.
|
|
180
|
-
- Never commit, push, force-push, rewrite history, or change signing identity or credentials unless the user explicitly asks. Ask before anything irreversible: save-format migration or bulk deletion of content you did not create.
|
|
181
|
-
- Destructive operations are a hard stop, even when the permission preset grants full access:
|
|
182
|
-
- Never delete, overwrite, move, or mass-edit anything outside the current workspace.
|
|
183
|
-
- Treat these as untouchable: drive roots (C:\, D:\), %USERPROFILE%, %APPDATA%, %LOCALAPPDATA%, %USERPROFILE%\.dsh, C:\Windows, C:\Program Files*, and any path that resolves to a user profile or system directory.
|
|
184
|
-
- Never build a cleanup or deletion path from an environment variable, `~`, a relative path, or a glob that can expand upward. Resolve it from the workspace root, print the absolute paths, the file count and the estimated size, and wait for the user's explicit confirmation before running.
|
|
185
|
-
- Clean only artifacts this project or this session created; prefer moving them to a quarantine folder under the workspace over deleting.
|
|
186
|
-
- If the scope is ambiguous or broader than the request, stop and ask. When in doubt, do nothing irreversible.
|
|
187
|
-
- Version control: before the first change, check whether the working directory is a Git repository. If it is, commit each finished step and report the commit hash and message. If it is not, say so and offer to run `git init` in the project directory — never initialize silently, never initialize a parent folder that holds several separate projects, and never re-initialize or nest a repository inside another one.
|
|
188
|
-
|
|
189
|
-
Load the game-dev-delivery skill before any game change larger than a one-line fix; it is this mode's checklist. Identify the game engine from the project and load its skill too — game-godot, game-unity, game-unreal, or game-cocos — before engine-specific work. This persona is the non-negotiable subset — where a skill is more specific, follow the skill. Write code and assets in the project's conventions; write prose in the user's language.
|
|
190
|
-
- id: agent-instructions
|
|
191
|
-
name: '@deepseek-ai/dsh-agent-instructions'
|
|
192
|
-
config:
|
|
193
|
-
maxBytes: 65536
|
|
194
|
-
- id: time-context
|
|
195
|
-
name: '@deepseek-ai/dsh-time-context'
|
|
196
|
-
- id: tool-bash
|
|
197
|
-
name: '@deepseek-ai/dsh-tool-bash'
|
|
198
|
-
disabled: !!js process.platform === 'win32'
|
|
199
|
-
- id: tool-pwsh
|
|
200
|
-
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
201
|
-
disabled: !!js process.platform !== 'win32'
|
|
202
|
-
- id: tool-fs
|
|
203
|
-
name: '@deepseek-ai/dsh-tool-fs'
|
|
204
|
-
config:
|
|
205
|
-
# Set true to add the apply_patch tool beside edit.
|
|
206
|
-
applyPatch: false
|
|
207
|
-
- id: tool-fs-search
|
|
208
|
-
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
209
|
-
config:
|
|
210
|
-
sampleOverCapGlobResults: false
|
|
211
|
-
- id: tool-jobs
|
|
212
|
-
name: '@deepseek-ai/dsh-tool-jobs'
|
|
213
|
-
- id: command-goal
|
|
214
|
-
name: '@deepseek-ai/dsh-command-goal'
|
|
215
|
-
- id: tool-goal
|
|
216
|
-
name: '@deepseek-ai/dsh-tool-goal'
|
|
217
|
-
- id: planning
|
|
218
|
-
name: cordis:group
|
|
219
|
-
group: true
|
|
220
|
-
isolate:
|
|
221
|
-
planMode: true
|
|
222
|
-
config:
|
|
223
|
-
- id: plan-mode
|
|
224
|
-
name: '@deepseek-ai/dsh-plan-mode'
|
|
225
|
-
config:
|
|
226
|
-
section: |
|
|
227
|
-
You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
|
228
|
-
|
|
229
|
-
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
|
230
|
-
|
|
231
|
-
The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
|
|
232
|
-
|
|
233
|
-
Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
|
|
234
|
-
|
|
235
|
-
Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
|
|
236
|
-
|
|
237
|
-
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
|
|
238
|
-
- id: compaction
|
|
239
|
-
name: cordis:group
|
|
240
|
-
group: true
|
|
241
|
-
isolate:
|
|
242
|
-
compaction: true
|
|
243
|
-
toolResultPruner: true
|
|
244
|
-
config:
|
|
245
|
-
- id: compaction-basic
|
|
246
|
-
name: '@deepseek-ai/dsh-compaction-basic'
|
|
247
|
-
- id: command-compact
|
|
248
|
-
name: '@deepseek-ai/dsh-command-compact'
|
|
249
|
-
- id: tool-result-pruner
|
|
250
|
-
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
251
|
-
config:
|
|
252
|
-
thresholdChars: 8192
|
|
253
|
-
headChars: 4096
|
|
254
|
-
tailChars: 1024
|
|
255
|
-
- id: delegation
|
|
256
|
-
name: cordis:group
|
|
257
|
-
group: true
|
|
258
|
-
isolate:
|
|
259
|
-
workflowEngine: true
|
|
260
|
-
config:
|
|
261
|
-
- id: tool-subagent-control
|
|
262
|
-
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
263
|
-
config:
|
|
264
|
-
interrupt: false
|
|
265
|
-
- id: tool-subagent
|
|
266
|
-
name: '@deepseek-ai/dsh-tool-subagent'
|
|
267
|
-
config:
|
|
268
|
-
provider: spawn
|
|
269
|
-
toolName: subagent
|
|
270
|
-
modelSelection: true
|
|
271
|
-
modelDiscovery: true
|
|
272
|
-
- id: tool-subagent-fork
|
|
273
|
-
name: '@deepseek-ai/dsh-tool-subagent'
|
|
274
|
-
config:
|
|
275
|
-
provider: fork
|
|
276
|
-
toolName: subagent_fork
|
|
277
|
-
- id: workflow-ptc
|
|
278
|
-
name: '@deepseek-ai/dsh-workflow-ptc'
|
|
279
|
-
config:
|
|
280
|
-
provider: spawn
|
|
281
|
-
- id: tool-workflow
|
|
282
|
-
name: '@deepseek-ai/dsh-tool-workflow'
|
|
283
|
-
- id: tool-ask-user
|
|
284
|
-
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
285
|
-
- id: tool-todo
|
|
286
|
-
name: '@deepseek-ai/dsh-tool-todo'
|
|
287
|
-
config:
|
|
288
|
-
allowParallelInProgress: true
|
|
289
|
-
- id: tool-web
|
|
290
|
-
name: '@deepseek-ai/dsh-tool-web'
|
|
291
|
-
config:
|
|
292
|
-
fetch: true
|
|
293
|
-
searchTimeoutMs: 60000
|
|
294
|
-
- id: skill-filesystem
|
|
295
|
-
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
296
|
-
config:
|
|
297
|
-
customSkillDirs:
|
|
298
|
-
- !!js process.getBuiltinModule('node:path').join(process.getBuiltinModule('node:path').dirname(process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('@deepseek-ai/dsh-agent-preset/package.json')), 'skills')
|
|
299
|
-
- id: tool-skill
|
|
300
|
-
name: '@deepseek-ai/dsh-tool-skill'
|
|
301
|
-
- id: present
|
|
302
|
-
name: '@deepseek-ai/dsh-tool-present'
|
|
303
|
-
|
|
304
|
-
|
|
305
|
-
- insert:
|
|
306
|
-
- id: preset-discuss
|
|
307
|
-
name: '@deepseek-ai/dsh-agent-preset'
|
|
308
|
-
config:
|
|
309
|
-
id: discuss
|
|
310
|
-
name: "只读讨论"
|
|
311
|
-
description: "只读讨论:能读代码文档、看图、搜索、提问,但不能写文件、执行命令或启动程序。适合方案讨论、只读代码审查与设计取舍;要真正改动或运行验证,切到「软件开发」(游戏相关选「游戏开发」)。"
|
|
312
|
-
order: 12
|
|
313
|
-
plugins:
|
|
314
|
-
- id: persona
|
|
315
|
-
name: '@deepseek-ai/dsh-persona'
|
|
316
|
-
config:
|
|
317
|
-
prefix: |
|
|
318
|
-
You are a thoughtful technical collaborator powered by the {{model}} model. You discuss, analyze, review, and explain; you never act on the user's system.
|
|
319
|
-
|
|
320
|
-
How you work:
|
|
321
|
-
- You have no tools that write or edit files, run commands you choose, install packages, launch programs, or delegate work. Never claim to have changed, created, run, fixed, or built anything, and never imply you did.
|
|
322
|
-
- You may read files and images, discover files with glob, search contents with grep, and load skills to ground the discussion. Prefer reading the real code over speculating, and keep what you verified separate from what you assume.
|
|
323
|
-
- Answer the question that was asked: explain the trade-offs, risks, and alternatives, then recommend one option with reasons.
|
|
324
|
-
- When an answer depends on something you cannot inspect, say what to check and how to check it instead of inventing it.
|
|
325
|
-
- When the user asks for a change, describe it precisely — files, functions, steps, and the check that proves it — as a paste-ready spec or a code block labeled NOT APPLIED, then tell them to choose 「软件开发」 (or 「游戏开发」 for game work) under Settings → Agent presets and start a new session, since this session keeps its mode. Do not attempt it yourself.
|
|
326
|
-
- Skills are reference only: where a skill instructs you to run, install, write, or launch something, that step cannot run here — describe it and hand it off. These rules outrank any skill.
|
|
327
|
-
- Keep responses focused and evidence-based; cite the file paths and lines you actually read.
|
|
328
|
-
- Respond in the user's language.
|
|
329
|
-
- id: agent-instructions
|
|
330
|
-
name: '@deepseek-ai/dsh-agent-instructions'
|
|
331
|
-
config:
|
|
332
|
-
maxBytes: 65536
|
|
333
|
-
- id: time-context
|
|
334
|
-
name: '@deepseek-ai/dsh-time-context'
|
|
335
|
-
- id: tool-fs
|
|
336
|
-
name: '@deepseek-ai/dsh-tool-fs'
|
|
337
|
-
config:
|
|
338
|
-
# Read-only: the write, edit and apply_patch tools are not mounted.
|
|
339
|
-
read: true
|
|
340
|
-
readImage: true
|
|
341
|
-
write: false
|
|
342
|
-
edit: false
|
|
343
|
-
applyPatch: false
|
|
344
|
-
- id: tool-fs-search
|
|
345
|
-
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
346
|
-
config:
|
|
347
|
-
sampleOverCapGlobResults: false
|
|
348
|
-
- id: compaction
|
|
349
|
-
name: cordis:group
|
|
350
|
-
group: true
|
|
351
|
-
isolate:
|
|
352
|
-
compaction: true
|
|
353
|
-
toolResultPruner: true
|
|
354
|
-
config:
|
|
355
|
-
- id: compaction-basic
|
|
356
|
-
name: '@deepseek-ai/dsh-compaction-basic'
|
|
357
|
-
- id: command-compact
|
|
358
|
-
name: '@deepseek-ai/dsh-command-compact'
|
|
359
|
-
- id: tool-result-pruner
|
|
360
|
-
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
361
|
-
config:
|
|
362
|
-
thresholdChars: 8192
|
|
363
|
-
headChars: 4096
|
|
364
|
-
tailChars: 1024
|
|
365
|
-
- id: tool-ask-user
|
|
366
|
-
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
367
|
-
- id: skill-filesystem
|
|
368
|
-
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
369
|
-
config:
|
|
370
|
-
customSkillDirs:
|
|
371
|
-
- !!js process.getBuiltinModule('node:path').join(process.getBuiltinModule('node:path').dirname(process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('@deepseek-ai/dsh-agent-preset/package.json')), 'skills')
|
|
372
|
-
- id: tool-skill
|
|
373
|
-
name: '@deepseek-ai/dsh-tool-skill'
|
|
374
|
-
|
|
375
|
-
# 本包自带的宿主级插件:注册技能、会话隔离开关、静默运行开关。
|
|
376
|
-
# 放在预设声明之外,所以对全部模式生效(含内置预设)。
|
|
377
|
-
- insert:
|
|
378
|
-
- id: dev-modes-skills
|
|
379
|
-
name: 'dsh-dev-modes'
|
|
380
|
-
- id: dev-modes-session-lock
|
|
381
|
-
name: 'dsh-dev-modes/session-lock'
|
|
382
|
-
- id: dev-modes-quiet-run
|
|
383
|
-
name: 'dsh-dev-modes/quiet-run'
|
|
1
|
+
# Dev modes: one bundle declaring three Agent presets for DeepSeek Harness.
|
|
2
|
+
# Presets: swe (软件开发), game (游戏开发), discuss (只读讨论).
|
|
3
|
+
# Each block is the former standalone bundle patch, kept unchanged so preset
|
|
4
|
+
# ids, order and child rows stay stable. Bundled skills are registered by
|
|
5
|
+
# index.js from ./skills.
|
|
6
|
+
|
|
7
|
+
- insert:
|
|
8
|
+
- id: preset-swe
|
|
9
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
10
|
+
config:
|
|
11
|
+
id: swe
|
|
12
|
+
name: "软件开发"
|
|
13
|
+
description: "适用于真正改动仓库的开发任务:先读代码与规范,再小步实现,用项目自身的构建与测试验证,最后如实汇报改动与风险。不限技术栈。"
|
|
14
|
+
order: 10
|
|
15
|
+
plugins:
|
|
16
|
+
- id: persona
|
|
17
|
+
name: '@deepseek-ai/dsh-persona'
|
|
18
|
+
config:
|
|
19
|
+
prefix: |
|
|
20
|
+
You are a software engineer powered by the {{model}} model. You design, implement, test, and maintain software in the user's workspace.
|
|
21
|
+
|
|
22
|
+
How you work:
|
|
23
|
+
- Start from the repository, not from assumptions. Read AGENTS.md, the build and test configuration, and the code you are about to change; follow the patterns already there.
|
|
24
|
+
- For multi-file, non-obvious, or high-risk changes, open with a short plan and stated assumptions, then proceed unless the user asks to review it first. Use plan mode when the user asks for a plan.
|
|
25
|
+
- Change as little as correctness requires: preserve existing behaviour, style, public APIs, and dependency choices unless the task asks otherwise.
|
|
26
|
+
- Work in small verified steps. After each meaningful change, run the cheapest sufficient check the project provides (build, typecheck, lint, or tests). Never claim something works from reading code alone; when the project provides no check, say so plainly and do a manual smoke check instead of implying success.
|
|
27
|
+
- Once the approach is agreed, carry the task to a verified result instead of stopping at the first plausible diff; for UI, CLI, or API changes, exercise real behaviour, not only unit tests.
|
|
28
|
+
- Use subagents for breadth (research, parallel review), then integrate and verify their findings yourself; delegation never replaces verification.
|
|
29
|
+
- Be plain about risk: call out breaking changes, migrations, security-relevant edits, and follow-ups instead of hiding them.
|
|
30
|
+
- Never commit, push, force-push, rewrite history, or change credentials unless the user explicitly asks. Ask before anything irreversible: bulk deletion, history rewrites, or migrations that drop data.
|
|
31
|
+
- Destructive operations are a hard stop, even when the permission preset grants full access:
|
|
32
|
+
- Never delete, overwrite, move, or mass-edit anything outside the current workspace.
|
|
33
|
+
- Treat these as untouchable: drive roots (C:\, D:\), %USERPROFILE%, %APPDATA%, %LOCALAPPDATA%, %USERPROFILE%\.dsh, C:\Windows, C:\Program Files*, and any path that resolves to a user profile or system directory.
|
|
34
|
+
- Never build a cleanup or deletion path from an environment variable, `~`, a relative path, or a glob that can expand upward. Resolve it from the workspace root, print the absolute paths, the file count and the estimated size, and wait for the user's explicit confirmation before running.
|
|
35
|
+
- Clean only artifacts this project or this session created; prefer moving them to a quarantine folder under the workspace over deleting.
|
|
36
|
+
- If the scope is ambiguous or broader than the request, stop and ask. When in doubt, do nothing irreversible.
|
|
37
|
+
- Version control: before the first change, check whether the working directory is a Git repository. If it is, commit each finished step and report the commit hash and message. If it is not, say so and offer to run `git init` in the project directory — never initialize silently, never initialize a parent folder that holds several separate projects, and never re-initialize or nest a repository inside another one.
|
|
38
|
+
|
|
39
|
+
Write code, tests, and comments in the repository's conventions; write prose in the user's language.
|
|
40
|
+
- id: agent-instructions
|
|
41
|
+
name: '@deepseek-ai/dsh-agent-instructions'
|
|
42
|
+
config:
|
|
43
|
+
maxBytes: 65536
|
|
44
|
+
- id: time-context
|
|
45
|
+
name: '@deepseek-ai/dsh-time-context'
|
|
46
|
+
- id: tool-bash
|
|
47
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
48
|
+
disabled: !!js process.platform === 'win32'
|
|
49
|
+
- id: tool-pwsh
|
|
50
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
51
|
+
disabled: !!js process.platform !== 'win32'
|
|
52
|
+
- id: tool-fs
|
|
53
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
54
|
+
config:
|
|
55
|
+
# Set true to add the apply_patch tool beside edit.
|
|
56
|
+
applyPatch: false
|
|
57
|
+
- id: tool-fs-search
|
|
58
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
59
|
+
config:
|
|
60
|
+
sampleOverCapGlobResults: false
|
|
61
|
+
- id: tool-jobs
|
|
62
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
63
|
+
- id: command-goal
|
|
64
|
+
name: '@deepseek-ai/dsh-command-goal'
|
|
65
|
+
- id: tool-goal
|
|
66
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
67
|
+
- id: planning
|
|
68
|
+
name: cordis:group
|
|
69
|
+
group: true
|
|
70
|
+
isolate:
|
|
71
|
+
planMode: true
|
|
72
|
+
config:
|
|
73
|
+
- id: plan-mode
|
|
74
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
75
|
+
config:
|
|
76
|
+
section: |
|
|
77
|
+
You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
|
78
|
+
|
|
79
|
+
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
|
80
|
+
|
|
81
|
+
The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
|
|
82
|
+
|
|
83
|
+
Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
|
|
84
|
+
|
|
85
|
+
Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
|
|
86
|
+
|
|
87
|
+
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
|
|
88
|
+
- id: compaction
|
|
89
|
+
name: cordis:group
|
|
90
|
+
group: true
|
|
91
|
+
isolate:
|
|
92
|
+
compaction: true
|
|
93
|
+
toolResultPruner: true
|
|
94
|
+
config:
|
|
95
|
+
- id: compaction-basic
|
|
96
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
97
|
+
- id: command-compact
|
|
98
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
99
|
+
- id: tool-result-pruner
|
|
100
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
101
|
+
config:
|
|
102
|
+
thresholdChars: 8192
|
|
103
|
+
headChars: 4096
|
|
104
|
+
tailChars: 1024
|
|
105
|
+
- id: delegation
|
|
106
|
+
name: cordis:group
|
|
107
|
+
group: true
|
|
108
|
+
isolate:
|
|
109
|
+
workflowEngine: true
|
|
110
|
+
config:
|
|
111
|
+
- id: tool-subagent-control
|
|
112
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
113
|
+
config:
|
|
114
|
+
interrupt: false
|
|
115
|
+
- id: tool-subagent
|
|
116
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
117
|
+
config:
|
|
118
|
+
provider: spawn
|
|
119
|
+
toolName: subagent
|
|
120
|
+
modelSelection: true
|
|
121
|
+
modelDiscovery: true
|
|
122
|
+
- id: tool-subagent-fork
|
|
123
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
124
|
+
config:
|
|
125
|
+
provider: fork
|
|
126
|
+
toolName: subagent_fork
|
|
127
|
+
- id: workflow-ptc
|
|
128
|
+
name: '@deepseek-ai/dsh-workflow-ptc'
|
|
129
|
+
config:
|
|
130
|
+
provider: spawn
|
|
131
|
+
- id: tool-workflow
|
|
132
|
+
name: '@deepseek-ai/dsh-tool-workflow'
|
|
133
|
+
- id: tool-ask-user
|
|
134
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
135
|
+
- id: tool-todo
|
|
136
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
137
|
+
config:
|
|
138
|
+
allowParallelInProgress: true
|
|
139
|
+
- id: tool-web
|
|
140
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
141
|
+
config:
|
|
142
|
+
fetch: true
|
|
143
|
+
searchTimeoutMs: 60000
|
|
144
|
+
- id: skill-filesystem
|
|
145
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
146
|
+
config:
|
|
147
|
+
customSkillDirs:
|
|
148
|
+
- !!js process.getBuiltinModule('node:path').join(process.getBuiltinModule('node:path').dirname(process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('@deepseek-ai/dsh-agent-preset/package.json')), 'skills')
|
|
149
|
+
- id: tool-skill
|
|
150
|
+
name: '@deepseek-ai/dsh-tool-skill'
|
|
151
|
+
- id: present
|
|
152
|
+
name: '@deepseek-ai/dsh-tool-present'
|
|
153
|
+
|
|
154
|
+
|
|
155
|
+
- insert:
|
|
156
|
+
- id: preset-game
|
|
157
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
158
|
+
config:
|
|
159
|
+
id: game
|
|
160
|
+
name: "游戏开发"
|
|
161
|
+
description: "游戏玩法、关卡、手感调优、性能与导出发布时选它;一般软件功能与工具开发用「软件开发」。内置 Godot / Unity / Unreal / Cocos 工作流,其它引擎按同一流程适配。"
|
|
162
|
+
order: 11
|
|
163
|
+
plugins:
|
|
164
|
+
- id: persona
|
|
165
|
+
name: '@deepseek-ai/dsh-persona'
|
|
166
|
+
config:
|
|
167
|
+
prefix: |
|
|
168
|
+
You are a game developer powered by the {{model}} model. You build and maintain playable games in the user's workspace.
|
|
169
|
+
|
|
170
|
+
How you work:
|
|
171
|
+
- Start from the project, not from assumptions: read the engine project settings, the scenes and scripts that own the mechanic, input mapping, the asset pipeline, and any design notes before changing behaviour.
|
|
172
|
+
- Protect the core loop. Establish the game's core loop and acceptance criteria first; prototype the smallest playable version, verify it, then add content.
|
|
173
|
+
- Verify by playing, not by compiling. Run the game through the engine's own run or headless path, read logs, and capture a screenshot or state dump for anything visual; never claim "it works" or "it feels right" from reading code alone.
|
|
174
|
+
- Tune in batches, one hypothesis per test. Keep gameplay numbers explicit and inspectable (exported or config values), and record the parameters you changed together with the observed result.
|
|
175
|
+
- Measure before optimizing: frame time, draw calls, instance counts, memory. Fix the measured bottleneck, not a guessed one.
|
|
176
|
+
- Follow the project's engine idioms, scene and script conventions, and folder layout. Delete or rewrite only what you introduced yourself (prototype scenes, temp assets, throwaway files); ask before touching assets, scenes, or saves you did not create.
|
|
177
|
+
- Export work is reversible: update export presets, output paths, and build settings directly and report what changed.
|
|
178
|
+
- Use subagents for breadth (asset audits, parallel research), then integrate and verify their findings yourself; delegation never replaces verification.
|
|
179
|
+
- Be plain about risk: call out save-format, balance, input, and export-breaking changes, plus what remains unverified.
|
|
180
|
+
- Never commit, push, force-push, rewrite history, or change signing identity or credentials unless the user explicitly asks. Ask before anything irreversible: save-format migration or bulk deletion of content you did not create.
|
|
181
|
+
- Destructive operations are a hard stop, even when the permission preset grants full access:
|
|
182
|
+
- Never delete, overwrite, move, or mass-edit anything outside the current workspace.
|
|
183
|
+
- Treat these as untouchable: drive roots (C:\, D:\), %USERPROFILE%, %APPDATA%, %LOCALAPPDATA%, %USERPROFILE%\.dsh, C:\Windows, C:\Program Files*, and any path that resolves to a user profile or system directory.
|
|
184
|
+
- Never build a cleanup or deletion path from an environment variable, `~`, a relative path, or a glob that can expand upward. Resolve it from the workspace root, print the absolute paths, the file count and the estimated size, and wait for the user's explicit confirmation before running.
|
|
185
|
+
- Clean only artifacts this project or this session created; prefer moving them to a quarantine folder under the workspace over deleting.
|
|
186
|
+
- If the scope is ambiguous or broader than the request, stop and ask. When in doubt, do nothing irreversible.
|
|
187
|
+
- Version control: before the first change, check whether the working directory is a Git repository. If it is, commit each finished step and report the commit hash and message. If it is not, say so and offer to run `git init` in the project directory — never initialize silently, never initialize a parent folder that holds several separate projects, and never re-initialize or nest a repository inside another one.
|
|
188
|
+
|
|
189
|
+
Load the game-dev-delivery skill before any game change larger than a one-line fix; it is this mode's checklist. Identify the game engine from the project and load its skill too — game-godot, game-unity, game-unreal, or game-cocos — before engine-specific work. This persona is the non-negotiable subset — where a skill is more specific, follow the skill. Write code and assets in the project's conventions; write prose in the user's language.
|
|
190
|
+
- id: agent-instructions
|
|
191
|
+
name: '@deepseek-ai/dsh-agent-instructions'
|
|
192
|
+
config:
|
|
193
|
+
maxBytes: 65536
|
|
194
|
+
- id: time-context
|
|
195
|
+
name: '@deepseek-ai/dsh-time-context'
|
|
196
|
+
- id: tool-bash
|
|
197
|
+
name: '@deepseek-ai/dsh-tool-bash'
|
|
198
|
+
disabled: !!js process.platform === 'win32'
|
|
199
|
+
- id: tool-pwsh
|
|
200
|
+
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
201
|
+
disabled: !!js process.platform !== 'win32'
|
|
202
|
+
- id: tool-fs
|
|
203
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
204
|
+
config:
|
|
205
|
+
# Set true to add the apply_patch tool beside edit.
|
|
206
|
+
applyPatch: false
|
|
207
|
+
- id: tool-fs-search
|
|
208
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
209
|
+
config:
|
|
210
|
+
sampleOverCapGlobResults: false
|
|
211
|
+
- id: tool-jobs
|
|
212
|
+
name: '@deepseek-ai/dsh-tool-jobs'
|
|
213
|
+
- id: command-goal
|
|
214
|
+
name: '@deepseek-ai/dsh-command-goal'
|
|
215
|
+
- id: tool-goal
|
|
216
|
+
name: '@deepseek-ai/dsh-tool-goal'
|
|
217
|
+
- id: planning
|
|
218
|
+
name: cordis:group
|
|
219
|
+
group: true
|
|
220
|
+
isolate:
|
|
221
|
+
planMode: true
|
|
222
|
+
config:
|
|
223
|
+
- id: plan-mode
|
|
224
|
+
name: '@deepseek-ai/dsh-plan-mode'
|
|
225
|
+
config:
|
|
226
|
+
section: |
|
|
227
|
+
You are in plan mode. Stay in plan mode until the user approves your plan through exit_plan_mode or switches the session mode. Imperative language to implement changes means plan the implementation, not execute it. A user's conversational agreement — including an answer confirming something you asked — approves nothing and does not end plan mode; fold the confirmed decision into the plan and submit it through exit_plan_mode.
|
|
228
|
+
|
|
229
|
+
Explore first. Use non-mutating reads, searches, static analysis, and checks to ground the plan in the actual repository. Do not edit or write files, change configuration, run formatters or code generation that rewrites tracked files, commit, or otherwise carry out the plan. Prefer existing functions and patterns over new machinery.
|
|
230
|
+
|
|
231
|
+
The tool catalog stays the same across modes for request-cache stability. These plan-mode rules override any later tool description or guidance that suggests using mutation tools; those tools remain listed to keep the tool catalog unchanged. Do not use todo_write to track this planning phase: it tracks implementation after an approved plan, while the plan itself belongs in exit_plan_mode.
|
|
232
|
+
|
|
233
|
+
Resolve discoverable facts by inspection. Use ask_user_question only for user-owned choices or material ambiguity that inspection cannot answer. Do not ask the user where code lives or how current behavior works when you can find out.
|
|
234
|
+
|
|
235
|
+
Make the plan decision-complete: state the goal and success criteria; group implementation changes by subsystem; identify public API, schema, and data-flow changes; cover edge cases, failure modes, tests, acceptance criteria, and explicit assumptions. Keep it concise enough to review but detailed enough that another engineer can implement it without making design decisions.
|
|
236
|
+
|
|
237
|
+
When ready, call exit_plan_mode with the complete plan markdown, starting with a # title. Make exit_plan_mode the only and final tool call in that assistant response: it presents the plan for approval, and implementation begins only in a later step after approval. Do not paste the final plan as a plain reply or ask "should I proceed?" through prose or ask_user_question. If review rejects it, incorporate the feedback and present again. If the review channel is unavailable or aborted, stay in plan mode and ask the user to switch modes manually; do not proceed with implementation.
|
|
238
|
+
- id: compaction
|
|
239
|
+
name: cordis:group
|
|
240
|
+
group: true
|
|
241
|
+
isolate:
|
|
242
|
+
compaction: true
|
|
243
|
+
toolResultPruner: true
|
|
244
|
+
config:
|
|
245
|
+
- id: compaction-basic
|
|
246
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
247
|
+
- id: command-compact
|
|
248
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
249
|
+
- id: tool-result-pruner
|
|
250
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
251
|
+
config:
|
|
252
|
+
thresholdChars: 8192
|
|
253
|
+
headChars: 4096
|
|
254
|
+
tailChars: 1024
|
|
255
|
+
- id: delegation
|
|
256
|
+
name: cordis:group
|
|
257
|
+
group: true
|
|
258
|
+
isolate:
|
|
259
|
+
workflowEngine: true
|
|
260
|
+
config:
|
|
261
|
+
- id: tool-subagent-control
|
|
262
|
+
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
263
|
+
config:
|
|
264
|
+
interrupt: false
|
|
265
|
+
- id: tool-subagent
|
|
266
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
267
|
+
config:
|
|
268
|
+
provider: spawn
|
|
269
|
+
toolName: subagent
|
|
270
|
+
modelSelection: true
|
|
271
|
+
modelDiscovery: true
|
|
272
|
+
- id: tool-subagent-fork
|
|
273
|
+
name: '@deepseek-ai/dsh-tool-subagent'
|
|
274
|
+
config:
|
|
275
|
+
provider: fork
|
|
276
|
+
toolName: subagent_fork
|
|
277
|
+
- id: workflow-ptc
|
|
278
|
+
name: '@deepseek-ai/dsh-workflow-ptc'
|
|
279
|
+
config:
|
|
280
|
+
provider: spawn
|
|
281
|
+
- id: tool-workflow
|
|
282
|
+
name: '@deepseek-ai/dsh-tool-workflow'
|
|
283
|
+
- id: tool-ask-user
|
|
284
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
285
|
+
- id: tool-todo
|
|
286
|
+
name: '@deepseek-ai/dsh-tool-todo'
|
|
287
|
+
config:
|
|
288
|
+
allowParallelInProgress: true
|
|
289
|
+
- id: tool-web
|
|
290
|
+
name: '@deepseek-ai/dsh-tool-web'
|
|
291
|
+
config:
|
|
292
|
+
fetch: true
|
|
293
|
+
searchTimeoutMs: 60000
|
|
294
|
+
- id: skill-filesystem
|
|
295
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
296
|
+
config:
|
|
297
|
+
customSkillDirs:
|
|
298
|
+
- !!js process.getBuiltinModule('node:path').join(process.getBuiltinModule('node:path').dirname(process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('@deepseek-ai/dsh-agent-preset/package.json')), 'skills')
|
|
299
|
+
- id: tool-skill
|
|
300
|
+
name: '@deepseek-ai/dsh-tool-skill'
|
|
301
|
+
- id: present
|
|
302
|
+
name: '@deepseek-ai/dsh-tool-present'
|
|
303
|
+
|
|
304
|
+
|
|
305
|
+
- insert:
|
|
306
|
+
- id: preset-discuss
|
|
307
|
+
name: '@deepseek-ai/dsh-agent-preset'
|
|
308
|
+
config:
|
|
309
|
+
id: discuss
|
|
310
|
+
name: "只读讨论"
|
|
311
|
+
description: "只读讨论:能读代码文档、看图、搜索、提问,但不能写文件、执行命令或启动程序。适合方案讨论、只读代码审查与设计取舍;要真正改动或运行验证,切到「软件开发」(游戏相关选「游戏开发」)。"
|
|
312
|
+
order: 12
|
|
313
|
+
plugins:
|
|
314
|
+
- id: persona
|
|
315
|
+
name: '@deepseek-ai/dsh-persona'
|
|
316
|
+
config:
|
|
317
|
+
prefix: |
|
|
318
|
+
You are a thoughtful technical collaborator powered by the {{model}} model. You discuss, analyze, review, and explain; you never act on the user's system.
|
|
319
|
+
|
|
320
|
+
How you work:
|
|
321
|
+
- You have no tools that write or edit files, run commands you choose, install packages, launch programs, or delegate work. Never claim to have changed, created, run, fixed, or built anything, and never imply you did.
|
|
322
|
+
- You may read files and images, discover files with glob, search contents with grep, and load skills to ground the discussion. Prefer reading the real code over speculating, and keep what you verified separate from what you assume.
|
|
323
|
+
- Answer the question that was asked: explain the trade-offs, risks, and alternatives, then recommend one option with reasons.
|
|
324
|
+
- When an answer depends on something you cannot inspect, say what to check and how to check it instead of inventing it.
|
|
325
|
+
- When the user asks for a change, describe it precisely — files, functions, steps, and the check that proves it — as a paste-ready spec or a code block labeled NOT APPLIED, then tell them to choose 「软件开发」 (or 「游戏开发」 for game work) under Settings → Agent presets and start a new session, since this session keeps its mode. Do not attempt it yourself.
|
|
326
|
+
- Skills are reference only: where a skill instructs you to run, install, write, or launch something, that step cannot run here — describe it and hand it off. These rules outrank any skill.
|
|
327
|
+
- Keep responses focused and evidence-based; cite the file paths and lines you actually read.
|
|
328
|
+
- Respond in the user's language.
|
|
329
|
+
- id: agent-instructions
|
|
330
|
+
name: '@deepseek-ai/dsh-agent-instructions'
|
|
331
|
+
config:
|
|
332
|
+
maxBytes: 65536
|
|
333
|
+
- id: time-context
|
|
334
|
+
name: '@deepseek-ai/dsh-time-context'
|
|
335
|
+
- id: tool-fs
|
|
336
|
+
name: '@deepseek-ai/dsh-tool-fs'
|
|
337
|
+
config:
|
|
338
|
+
# Read-only: the write, edit and apply_patch tools are not mounted.
|
|
339
|
+
read: true
|
|
340
|
+
readImage: true
|
|
341
|
+
write: false
|
|
342
|
+
edit: false
|
|
343
|
+
applyPatch: false
|
|
344
|
+
- id: tool-fs-search
|
|
345
|
+
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
346
|
+
config:
|
|
347
|
+
sampleOverCapGlobResults: false
|
|
348
|
+
- id: compaction
|
|
349
|
+
name: cordis:group
|
|
350
|
+
group: true
|
|
351
|
+
isolate:
|
|
352
|
+
compaction: true
|
|
353
|
+
toolResultPruner: true
|
|
354
|
+
config:
|
|
355
|
+
- id: compaction-basic
|
|
356
|
+
name: '@deepseek-ai/dsh-compaction-basic'
|
|
357
|
+
- id: command-compact
|
|
358
|
+
name: '@deepseek-ai/dsh-command-compact'
|
|
359
|
+
- id: tool-result-pruner
|
|
360
|
+
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
361
|
+
config:
|
|
362
|
+
thresholdChars: 8192
|
|
363
|
+
headChars: 4096
|
|
364
|
+
tailChars: 1024
|
|
365
|
+
- id: tool-ask-user
|
|
366
|
+
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
367
|
+
- id: skill-filesystem
|
|
368
|
+
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
369
|
+
config:
|
|
370
|
+
customSkillDirs:
|
|
371
|
+
- !!js process.getBuiltinModule('node:path').join(process.getBuiltinModule('node:path').dirname(process.getBuiltinModule('node:module').createRequire(baseUrl).resolve('@deepseek-ai/dsh-agent-preset/package.json')), 'skills')
|
|
372
|
+
- id: tool-skill
|
|
373
|
+
name: '@deepseek-ai/dsh-tool-skill'
|
|
374
|
+
|
|
375
|
+
# 本包自带的宿主级插件:注册技能、会话隔离开关、静默运行开关。
|
|
376
|
+
# 放在预设声明之外,所以对全部模式生效(含内置预设)。
|
|
377
|
+
- insert:
|
|
378
|
+
- id: dev-modes-skills
|
|
379
|
+
name: 'dsh-dev-modes'
|
|
380
|
+
- id: dev-modes-session-lock
|
|
381
|
+
name: 'dsh-dev-modes/session-lock'
|
|
382
|
+
- id: dev-modes-quiet-run
|
|
383
|
+
name: 'dsh-dev-modes/quiet-run'
|
|
384
|
+
- id: dev-modes-session-delete
|
|
385
|
+
name: 'dsh-dev-modes/session-delete'
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "dsh-dev-modes",
|
|
3
|
-
"version": "1.1.
|
|
3
|
+
"version": "1.1.16",
|
|
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",
|
|
@@ -10,6 +10,7 @@
|
|
|
10
10
|
"./client": "./client.js",
|
|
11
11
|
"./session-lock": "./session-lock/index.js",
|
|
12
12
|
"./quiet-run": "./quiet-run/index.js",
|
|
13
|
+
"./session-delete": "./session-delete/index.js",
|
|
13
14
|
"./locale/*.json": "./locale/*.json",
|
|
14
15
|
"./icon": "./icon.svg"
|
|
15
16
|
},
|
|
@@ -19,6 +20,7 @@
|
|
|
19
20
|
"session-lock",
|
|
20
21
|
"helpers",
|
|
21
22
|
"quiet-run",
|
|
23
|
+
"session-delete",
|
|
22
24
|
"cordis.patch.yml",
|
|
23
25
|
"skills",
|
|
24
26
|
"locale/*.json",
|
|
@@ -48,13 +50,5 @@
|
|
|
48
50
|
"@deepseek-ai/dsh-client-ui-conversation"
|
|
49
51
|
]
|
|
50
52
|
}
|
|
51
|
-
},
|
|
52
|
-
"repository": {
|
|
53
|
-
"type": "git",
|
|
54
|
-
"url": "git+https://github.com/Qing8-Max/dsh-dev-modes.git"
|
|
55
|
-
},
|
|
56
|
-
"homepage": "https://github.com/Qing8-Max/dsh-dev-modes#readme",
|
|
57
|
-
"bugs": {
|
|
58
|
-
"url": "https://github.com/Qing8-Max/dsh-dev-modes/issues"
|
|
59
53
|
}
|
|
60
54
|
}
|
package/quiet-run/index.js
CHANGED
|
@@ -112,16 +112,13 @@ function ensureWatcher() {
|
|
|
112
112
|
if (!fs.existsSync(WATCHER)) return null;
|
|
113
113
|
|
|
114
114
|
const child = spawn(
|
|
115
|
-
'
|
|
115
|
+
'powershell.exe',
|
|
116
116
|
[
|
|
117
|
-
'/c',
|
|
118
|
-
'start',
|
|
119
|
-
'""',
|
|
120
|
-
'/min',
|
|
121
|
-
'powershell.exe',
|
|
122
117
|
'-NoProfile',
|
|
123
118
|
'-ExecutionPolicy',
|
|
124
119
|
'Bypass',
|
|
120
|
+
'-WindowStyle',
|
|
121
|
+
'Hidden',
|
|
125
122
|
'-File',
|
|
126
123
|
WATCHER,
|
|
127
124
|
'-FlagFile',
|
|
@@ -380,10 +377,35 @@ export function apply(ctx) {
|
|
|
380
377
|
res.end(JSON.stringify(obj));
|
|
381
378
|
};
|
|
382
379
|
|
|
380
|
+
/**
|
|
381
|
+
* 宿主认证:这些路由会读出/改写某个会话的静默状态,必须和 DSH 自己的 API 用同一道闸。
|
|
382
|
+
* `connection.requestRejection` 同时做 Host/Origin 检查与浏览器登录校验:
|
|
383
|
+
* 没有登录凭据、或来自别的站点,都拿不到 401/403 以外的结果。
|
|
384
|
+
* 拿不到这道闸(没有 connection 服务)时按失败关闭处理,不做"看来源地址"之类的猜测。
|
|
385
|
+
* @returns true 表示已经拒绝并写完响应,调用方直接 return。
|
|
386
|
+
*/
|
|
387
|
+
const rejectedByHost = (req, res) => {
|
|
388
|
+
let rejection;
|
|
389
|
+
try {
|
|
390
|
+
const connection = c.get('connection');
|
|
391
|
+
if (typeof connection?.requestRejection !== 'function') throw new Error('admission unavailable');
|
|
392
|
+
rejection = connection.requestRejection(req);
|
|
393
|
+
} catch {
|
|
394
|
+
sendJson(res, 503, { error: 'host admission unavailable' });
|
|
395
|
+
return true;
|
|
396
|
+
}
|
|
397
|
+
if (rejection !== undefined) {
|
|
398
|
+
sendJson(res, rejection === 401 ? 401 : 403, { error: 'unauthenticated' });
|
|
399
|
+
return true;
|
|
400
|
+
}
|
|
401
|
+
return false;
|
|
402
|
+
};
|
|
403
|
+
|
|
383
404
|
const state = c.webServer.register({
|
|
384
405
|
kind: 'exact',
|
|
385
406
|
path: '/dsh-quiet-run/state',
|
|
386
407
|
handler: async (req, res) => {
|
|
408
|
+
if (rejectedByHost(req, res)) return;
|
|
387
409
|
const url = new URL(req.url || '/', 'http://127.0.0.1');
|
|
388
410
|
const asked = url.searchParams.get('sessionId');
|
|
389
411
|
const sessionId = asked || activeSessionId;
|
|
@@ -407,6 +429,7 @@ export function apply(ctx) {
|
|
|
407
429
|
kind: 'exact',
|
|
408
430
|
path: '/dsh-quiet-run/set',
|
|
409
431
|
handler: async (req, res) => {
|
|
432
|
+
if (rejectedByHost(req, res)) return;
|
|
410
433
|
if (req.method !== 'POST') {
|
|
411
434
|
sendJson(res, 405, { error: 'POST only' });
|
|
412
435
|
return;
|
|
@@ -436,6 +459,7 @@ export function apply(ctx) {
|
|
|
436
459
|
kind: 'exact',
|
|
437
460
|
path: '/dsh-quiet-run/log',
|
|
438
461
|
handler: async (req, res) => {
|
|
462
|
+
if (rejectedByHost(req, res)) return;
|
|
439
463
|
let lines = [];
|
|
440
464
|
try {
|
|
441
465
|
lines = fs.readFileSync(LOG_FILE, 'utf8').trim().split('\n').slice(-60);
|
|
@@ -0,0 +1,151 @@
|
|
|
1
|
+
import fs from 'node:fs';
|
|
2
|
+
import os from 'node:os';
|
|
3
|
+
import path from 'node:path';
|
|
4
|
+
|
|
5
|
+
/**
|
|
6
|
+
* 会话删除(并入 dsh-dev-modes)。
|
|
7
|
+
*
|
|
8
|
+
* 设计原则:**不直接删,只隔离**。
|
|
9
|
+
* 会话目录整体移动到 `$DSH_HOME/sessions-trash/<时间戳>/`,
|
|
10
|
+
* 想找回随时移回;确认不要了再由用户手动清理。
|
|
11
|
+
*
|
|
12
|
+
* 端点:
|
|
13
|
+
* POST /dsh-session-delete/delete { sessionId } -> { ok, removed, trashPath }
|
|
14
|
+
* GET /dsh-session-delete/trash -> { entries: [...] }
|
|
15
|
+
*/
|
|
16
|
+
|
|
17
|
+
const HOME = process.env.DSH_HOME || path.join(os.homedir(), '.dsh');
|
|
18
|
+
const SESSIONS_DIR = path.join(HOME, 'sessions');
|
|
19
|
+
const TRASH_DIR = path.join(HOME, 'sessions-trash');
|
|
20
|
+
|
|
21
|
+
/** DSH 的会话 id 形如 session-<uuid>。 */
|
|
22
|
+
const SESSION_ID_RE = /^session-[0-9a-f]{8}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{4}-[0-9a-f]{12}$/;
|
|
23
|
+
|
|
24
|
+
function isInside(parent, child) {
|
|
25
|
+
const p = path.resolve(parent) + path.sep;
|
|
26
|
+
const c = path.resolve(child);
|
|
27
|
+
return c.startsWith(p);
|
|
28
|
+
}
|
|
29
|
+
|
|
30
|
+
/** 在所有工作区目录下找这个会话的目录(可能命中 0 或 1 个)。 */
|
|
31
|
+
function locateSessionDirs(sessionId) {
|
|
32
|
+
if (!fs.existsSync(SESSIONS_DIR)) return [];
|
|
33
|
+
const found = [];
|
|
34
|
+
for (const entry of fs.readdirSync(SESSIONS_DIR, { withFileTypes: true })) {
|
|
35
|
+
if (!entry.isDirectory()) continue;
|
|
36
|
+
const candidate = path.join(SESSIONS_DIR, entry.name, sessionId);
|
|
37
|
+
if (fs.existsSync(candidate) && fs.statSync(candidate).isDirectory()) found.push(candidate);
|
|
38
|
+
}
|
|
39
|
+
return found;
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
function timestamp() {
|
|
43
|
+
const d = new Date();
|
|
44
|
+
const p = (n) => String(n).padStart(2, '0');
|
|
45
|
+
return `${d.getFullYear()}${p(d.getMonth() + 1)}${p(d.getDate())}-${p(d.getHours())}${p(d.getMinutes())}${p(d.getSeconds())}`;
|
|
46
|
+
}
|
|
47
|
+
|
|
48
|
+
/** 把会话目录移动到隔离区;返回实际落点。 */
|
|
49
|
+
function quarantineSession(sessionId) {
|
|
50
|
+
if (!SESSION_ID_RE.test(sessionId)) throw new Error('invalid session id');
|
|
51
|
+
const dirs = locateSessionDirs(sessionId);
|
|
52
|
+
if (dirs.length === 0) return { removed: 0, trashPath: null };
|
|
53
|
+
|
|
54
|
+
const batch = path.join(TRASH_DIR, timestamp());
|
|
55
|
+
fs.mkdirSync(batch, { recursive: true });
|
|
56
|
+
|
|
57
|
+
let removed = 0;
|
|
58
|
+
let lastTarget = null;
|
|
59
|
+
for (const dir of dirs) {
|
|
60
|
+
// 双保险:只动 sessions 目录内的东西
|
|
61
|
+
if (!isInside(SESSIONS_DIR, dir)) throw new Error('refused: path outside sessions dir');
|
|
62
|
+
const workspaceName = path.basename(path.dirname(dir));
|
|
63
|
+
const target = path.join(batch, workspaceName + '__' + sessionId);
|
|
64
|
+
fs.renameSync(dir, target);
|
|
65
|
+
removed += 1;
|
|
66
|
+
lastTarget = target;
|
|
67
|
+
}
|
|
68
|
+
return { removed, trashPath: batch };
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
function listTrash() {
|
|
72
|
+
if (!fs.existsSync(TRASH_DIR)) return [];
|
|
73
|
+
const out = [];
|
|
74
|
+
for (const batch of fs.readdirSync(TRASH_DIR, { withFileTypes: true })) {
|
|
75
|
+
if (!batch.isDirectory()) continue;
|
|
76
|
+
const batchPath = path.join(TRASH_DIR, batch.name);
|
|
77
|
+
let items = [];
|
|
78
|
+
try {
|
|
79
|
+
items = fs.readdirSync(batchPath, { withFileTypes: true }).filter((e) => e.isDirectory()).map((e) => e.name);
|
|
80
|
+
} catch {
|
|
81
|
+
items = [];
|
|
82
|
+
}
|
|
83
|
+
out.push({ batch: batch.name, items });
|
|
84
|
+
}
|
|
85
|
+
return out.sort((a, b) => (a.batch < b.batch ? 1 : -1));
|
|
86
|
+
}
|
|
87
|
+
|
|
88
|
+
function readJsonBody(req) {
|
|
89
|
+
return new Promise((resolve) => {
|
|
90
|
+
let data = '';
|
|
91
|
+
req.on('data', (chunk) => {
|
|
92
|
+
data += chunk;
|
|
93
|
+
if (data.length > 1e5) req.destroy();
|
|
94
|
+
});
|
|
95
|
+
req.on('end', () => {
|
|
96
|
+
try {
|
|
97
|
+
resolve(data ? JSON.parse(data) : {});
|
|
98
|
+
} catch {
|
|
99
|
+
resolve({});
|
|
100
|
+
}
|
|
101
|
+
});
|
|
102
|
+
req.on('error', () => resolve({}));
|
|
103
|
+
});
|
|
104
|
+
}
|
|
105
|
+
|
|
106
|
+
export function apply(ctx) {
|
|
107
|
+
ctx.inject(['webServer'], (c) => {
|
|
108
|
+
c.effect(() => {
|
|
109
|
+
const sendJson = (res, status, obj) => {
|
|
110
|
+
res.writeHead(status, { 'content-type': 'application/json; charset=utf-8', 'cache-control': 'no-store' });
|
|
111
|
+
res.end(JSON.stringify(obj));
|
|
112
|
+
};
|
|
113
|
+
|
|
114
|
+
const del = c.webServer.register({
|
|
115
|
+
kind: 'exact',
|
|
116
|
+
path: '/dsh-session-delete/delete',
|
|
117
|
+
handler: async (req, res) => {
|
|
118
|
+
if (req.method !== 'POST') {
|
|
119
|
+
sendJson(res, 405, { ok: false, error: 'POST only' });
|
|
120
|
+
return;
|
|
121
|
+
}
|
|
122
|
+
try {
|
|
123
|
+
const body = await readJsonBody(req);
|
|
124
|
+
const sessionId = String(body.sessionId || '');
|
|
125
|
+
const result = quarantineSession(sessionId);
|
|
126
|
+
sendJson(res, 200, { ok: true, ...result });
|
|
127
|
+
} catch (err) {
|
|
128
|
+
sendJson(res, 400, { ok: false, error: String((err && err.message) || err) });
|
|
129
|
+
}
|
|
130
|
+
},
|
|
131
|
+
});
|
|
132
|
+
|
|
133
|
+
const trash = c.webServer.register({
|
|
134
|
+
kind: 'exact',
|
|
135
|
+
path: '/dsh-session-delete/trash',
|
|
136
|
+
handler: async (req, res) => {
|
|
137
|
+
try {
|
|
138
|
+
sendJson(res, 200, { ok: true, entries: listTrash() });
|
|
139
|
+
} catch (err) {
|
|
140
|
+
sendJson(res, 500, { ok: false, error: String((err && err.message) || err) });
|
|
141
|
+
}
|
|
142
|
+
},
|
|
143
|
+
});
|
|
144
|
+
|
|
145
|
+
return () => {
|
|
146
|
+
del();
|
|
147
|
+
trash();
|
|
148
|
+
};
|
|
149
|
+
});
|
|
150
|
+
});
|
|
151
|
+
}
|
package/session-lock/index.js
CHANGED
|
@@ -215,10 +215,35 @@ export function apply(ctx) {
|
|
|
215
215
|
res.end(JSON.stringify(obj));
|
|
216
216
|
};
|
|
217
217
|
|
|
218
|
+
/**
|
|
219
|
+
* 宿主认证:这两个路由会读出/改写某个会话的隔离状态,必须和 DSH 自己的 API 用同一道闸。
|
|
220
|
+
* `connection.requestRejection` 同时做 Host/Origin 检查与浏览器登录校验:
|
|
221
|
+
* 没有登录凭据、或来自别的站点,都拿不到 401/403 以外的结果。
|
|
222
|
+
* 拿不到这道闸(没有 connection 服务)时按失败关闭处理,不做"看来源地址"之类的猜测。
|
|
223
|
+
* @returns true 表示已经拒绝并写完响应,调用方直接 return。
|
|
224
|
+
*/
|
|
225
|
+
const rejectedByHost = (req, res) => {
|
|
226
|
+
let rejection;
|
|
227
|
+
try {
|
|
228
|
+
const connection = c.get('connection');
|
|
229
|
+
if (typeof connection?.requestRejection !== 'function') throw new Error('admission unavailable');
|
|
230
|
+
rejection = connection.requestRejection(req);
|
|
231
|
+
} catch {
|
|
232
|
+
sendJson(res, 503, { error: 'host admission unavailable' });
|
|
233
|
+
return true;
|
|
234
|
+
}
|
|
235
|
+
if (rejection !== undefined) {
|
|
236
|
+
sendJson(res, rejection === 401 ? 401 : 403, { error: 'unauthenticated' });
|
|
237
|
+
return true;
|
|
238
|
+
}
|
|
239
|
+
return false;
|
|
240
|
+
};
|
|
241
|
+
|
|
218
242
|
const state = c.webServer.register({
|
|
219
243
|
kind: 'exact',
|
|
220
244
|
path: '/dsh-session-lock/state',
|
|
221
245
|
handler: async (req, res) => {
|
|
246
|
+
if (rejectedByHost(req, res)) return;
|
|
222
247
|
const url = new URL(req.url || '/', 'http://127.0.0.1');
|
|
223
248
|
const asked = url.searchParams.get('sessionId');
|
|
224
249
|
const sessionId = asked || activeSessionId;
|
|
@@ -240,6 +265,7 @@ export function apply(ctx) {
|
|
|
240
265
|
kind: 'exact',
|
|
241
266
|
path: '/dsh-session-lock/set',
|
|
242
267
|
handler: async (req, res) => {
|
|
268
|
+
if (rejectedByHost(req, res)) return;
|
|
243
269
|
if (req.method !== 'POST') {
|
|
244
270
|
sendJson(res, 405, { error: 'POST only' });
|
|
245
271
|
return;
|