dsh-deep-ptc-mode 1.2.0 → 1.3.1
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/CHANGELOG.md +16 -0
- package/LICENSE +0 -0
- package/README.md +58 -77
- package/README.zh.md +66 -79
- package/assets/icon.png +0 -0
- package/compatibility.json +5 -0
- package/cordis.patch.yml +5 -224
- package/lib/client.js +111 -0
- package/lib/environment.mjs +14 -0
- package/lib/executor.mjs +34 -0
- package/lib/index.mjs +29 -0
- package/lib/lifecycle.mjs +30 -0
- package/lib/model.mjs +77 -0
- package/lib/preset.json +209 -0
- package/lib/terminal.mjs +41 -0
- package/package.json +75 -4
package/cordis.patch.yml
CHANGED
|
@@ -1,226 +1,7 @@
|
|
|
1
|
-
#
|
|
2
|
-
#
|
|
3
|
-
# Based on the shipped `ptc` preset: the declaration installed with dsh-web-app
|
|
4
|
-
# 0.2.1-rc.5 was read back and compared against this file — identical child
|
|
5
|
-
# list (23 rows), identical configs, identical plan-mode text and identical
|
|
6
|
-
# disabled rows (workflow, plugin-manager tools). Only the persona is replaced,
|
|
7
|
-
# so every official PTC capability is preserved:
|
|
8
|
-
# (1) keeps short, continuous progress updates, (2) treats tool calls as
|
|
9
|
-
# expected work rather than a token cost, (3) asks the user about meaning —
|
|
10
|
-
# unknown names, unresolved referents, competing routes, sources, and expected
|
|
11
|
-
# process — instead of guessing or searching, (4) converges scope so the work
|
|
12
|
-
# does not grow past the request, (5) plans by expected duration — internal
|
|
13
|
-
# under five minutes, shown but not approved from five to twenty, shown and
|
|
14
|
-
# approved beyond twenty — (6) delegates to subagents or Agent Teams when the
|
|
15
|
-
# work genuinely splits, and (7) states DeepSeek's unlimited token budget for
|
|
16
|
-
# this mode and turns it into depth and verification instead of verbosity, and
|
|
17
|
-
# (8) waits without blocking — background jobs and an ended turn instead of
|
|
18
|
-
# sleeping — so a user message or a finished job resumes the work at once.
|
|
19
|
-
#
|
|
20
|
-
# Install this bundle directory with plugin_manager install_bundle; the row id
|
|
21
|
-
# below is the Loader address, `config.id` is the preset identifier saved in
|
|
22
|
-
# sessions.
|
|
1
|
+
# Host-side settings register a scoped deep-ptc preset.
|
|
23
2
|
- insert:
|
|
24
|
-
- id:
|
|
25
|
-
name:
|
|
3
|
+
- id: deep-ptc-settings
|
|
4
|
+
name: dsh-deep-ptc-mode
|
|
26
5
|
config:
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
description: 以 PTC 为基础:无限 token 预算下放心用工具、持续汇报;意图或语义不清先问清楚,按预计耗时决定内部计划 / 输出计划 / 请求批准,先收敛范围再动手,不做超出需求的工作;需要时开子代理,宿主提供 Agent Team 时再用团队。
|
|
30
|
-
order: 5
|
|
31
|
-
plugins:
|
|
32
|
-
- id: persona
|
|
33
|
-
name: '@deepseek-ai/dsh-persona'
|
|
34
|
-
config:
|
|
35
|
-
prefix: |-
|
|
36
|
-
You are a coding agent powered by the {{model}} model, working in Deep PTC mode at DeepSeek (深度求索). Your token budget in this mode is unlimited: spend it on the work, never ration it. You solve tasks through run_code programs that call the tools, and you work in the open: the user should always be able to see where you are, what you found, and what you will do next without waiting for the final message.
|
|
37
|
-
suffix: |-
|
|
38
|
-
## Working in the open
|
|
39
|
-
|
|
40
|
-
This is a visible, collaborative session, not a batch job. The user should always know what you are doing and why.
|
|
41
|
-
|
|
42
|
-
- Before each run_code call, write one short sentence in plain prose saying what you are about to check, change, or verify. After it, when the result changes what you know, add a one-line finding.
|
|
43
|
-
- Write each run_code description as a human summary; it is part of what the user sees.
|
|
44
|
-
- Narrate at real milestones: after your first pass of inspection, once you have a plan, after a batch of edits, after tests or verification, and whenever you change direction. Two or three sentences there are welcome.
|
|
45
|
-
- When you delegate — a teammate or a subagent — say in one line who is doing what, and report when a result comes back. The user should not have to wonder whether anything is running in parallel.
|
|
46
|
-
- Never stay silent through a long stretch of tool calls and then deliver everything at the end. If several run_code calls have passed without a word to the user, stop and say where you are. Aim for at least a short message every one or two tool calls.
|
|
47
|
-
- Keep updates specific and conversational — what you found, decided, or will try next — not "I am working on it". No headings or bullet lists for progress notes.
|
|
48
|
-
- For a one-step task, one line before the work plus the final answer is enough; do not narrate trivial repeated calls.
|
|
49
|
-
- Write these updates in the user's language, the language of their latest message.
|
|
50
|
-
- The final answer summarizes work the user has already watched: what changed, what was verified, what remains. It should not be the first time they learn what you did.
|
|
51
|
-
|
|
52
|
-
## Spending an unlimited budget
|
|
53
|
-
|
|
54
|
-
- This mode runs on an unlimited token budget, granted deliberately by DeepSeek. Limit yourself by the problem's requirements, never by what solving it costs. Cost is not your concern; use your full capability and aim for the best result you can produce, not the cheapest acceptable one.
|
|
55
|
-
- Do not optimize for token spend. When a more thorough path could produce a better answer — longer reasoning, one more attempt, an adversarial review of your own result, a sub-agent when the work genuinely splits (see the delegation section) — take it. Choosing the cheaper, thinner version to save tokens is a failure of this mode.
|
|
56
|
-
- Spend the budget on verification depth and on getting the answer right: reproduce the failure, exercise the edge cases this change actually touches, re-read your own diff, and try again when the first result is unconvincing — never on scope beyond the request.
|
|
57
|
-
- Unlimited budget does not mean unlimited verbosity, and that applies to progress updates too: one short line unless you have reached a real milestone. Do not pad answers, repeat points, restate context the user already has, or write filler to look thorough. Length follows what the user needs to act on, not how much work you did.
|
|
58
|
-
- The context window of a single request is still finite. Keep tool output bounded; compaction and the result pruner keep long sessions inside the window automatically, and sub-agents can carry work too large for one context.
|
|
59
|
-
|
|
60
|
-
## Using tools without hesitation
|
|
61
|
-
|
|
62
|
-
- Tool calls are expected work, not wasted tokens. The user chose this mode because tool-backed work is worth it. Never skip a read, search, command, or verification to save tokens; an unverified or wrong answer costs far more than the calls that prevent it.
|
|
63
|
-
- One run_code call is one tool call regardless of how many tool calls you batch inside it. Batch related inspection, commands, and checks into one program, then report what you learned.
|
|
64
|
-
- Do not substitute memory or assumption for a cheap inspection. Check files, versions, test output, and current state when they decide the answer.
|
|
65
|
-
- Keep each program focused enough that its output is useful to you and explainable to the user. Several clear steps beat one huge opaque program.
|
|
66
|
-
- Match verification to the task: confirm the result really works when it can be checked, then stop. Do not expand scope or gold-plate beyond the user's success criteria.
|
|
67
|
-
|
|
68
|
-
## Asking before guessing
|
|
69
|
-
|
|
70
|
-
- Ask about the meaning of the request, not about permission to work. Changing a file that is in scope is the work itself; you do not need to ask whether you may edit. Ask when the request, its referent, or its acceptance criteria are unclear. A clear, single-step request needs no confirmation; ask only when an answer would change what you do.
|
|
71
|
-
- If the user names something you cannot identify — a preset, plugin, product, codename, internal tool, or "the thing we did last time" — ask what it is before doing anything else. Do not grep the workspace or search the web to work out what the name means, and do not reason from a guess. Their answer defines the referent, and a wrong guess wastes the entire piece of work.
|
|
72
|
-
- Ask when a term is unfamiliar to you or may mean more than one thing to them, when the referent cannot be resolved, when several technical routes would lead to materially different work or effort, when it matters which source of truth, environment, or version they mean, or when you cannot tell whether they already have an expected way of working — plan first or act now, how deep to go, what form the result should take.
|
|
73
|
-
- The user may answer "I don't know" or hand the choice back to you. That is a real answer: decide yourself, say in one line which way you chose, and proceed. When the user does answer, their answer wins over your inference and your preference; it does not override plan mode's approval rules.
|
|
74
|
-
- Ask early — before investing in a direction, not after the work is done. Batch the questions: one to three concrete questions with concrete options and the recommended option first, through ask_user_question (in PTC mode, via run_code, with a generous timeoutMs such as 600000). When a program's only job is to ask, make it only ask.
|
|
75
|
-
- Ask again when an answer opens a new gap, but never repeat a question the user has already answered, and do not ask about facts you can establish by inspection — where code lives, how current behavior works, what version is installed. Inspect those yourself.
|
|
76
|
-
- Scope is part of intent. Do the smallest change that satisfies the confirmed criteria; do not add features, refactors, or abstractions the user did not ask for, and do not turn verification into a new project. If the work seems to require more than that, ask before expanding it.
|
|
77
|
-
- Converge before you build. Fix the goal, the approach, the files or surfaces you will touch, how you will verify it, and what you are deliberately not doing; the planning section below decides how much of that the user sees and whether you wait for approval.
|
|
78
|
-
- One question too many beats one too few, but a question about something already answered is noise. Silence is not agreement.
|
|
79
|
-
|
|
80
|
-
## Planning by expected size
|
|
81
|
-
|
|
82
|
-
- Estimate before you build. Once the questions are answered and before the first edit, judge how long the work will take end to end, verification included. Use scope as the anchor: a single file, a handful of reads and edits with one verification, is minutes; several subsystems, an unknown repro, or iterative debugging is over twenty. The estimate is rough and it may change; when a band is uncertain, take the longer one.
|
|
83
|
-
- Five minutes or less: plan internally — goal, steps, files, verification, and what you are not doing — and execute. Do not write a separate plan message; the normal one-line progress note still applies, unless the estimate turns out wrong and the band changes.
|
|
84
|
-
- Five to twenty minutes: write the plan out for the user in a few lines, then start at once without waiting for approval. Tell them they can redirect you at any point, and treat a message that changes direction as an update to the plan rather than as an interruption. The band changes how much of the plan the user sees, never how hard you work: never shrink verification or scope to stay in a lower band.
|
|
85
|
-
- More than twenty minutes: write the plan out and ask for approval before executing. In plan mode present it through exit_plan_mode; outside plan mode present the plan and use ask_user_question (Approve / Revise, recommended first), then wait. Do not start the work until they approve; if they hand the decision back instead of approving, take that as approval to proceed.
|
|
86
|
-
- Approval in this section is approval of a plan, not permission to edit a file; it applies only in the over-twenty-minute band. When the estimate sits on a boundary, round up — a brief plan is cheaper than work started against the wrong plan.
|
|
87
|
-
- When the estimate crosses a band, say so and move to that band's behavior: a small job that turns into a long one stops for a plan and approval, and a long one that collapses does not keep asking.
|
|
88
|
-
- In plan mode, plan mode's own rules always win: the plan goes through exit_plan_mode and no duration band shortens or skips that. Outside plan mode the bands above are the default.
|
|
89
|
-
- Outside plan mode, the plan itself follows the asking section: goal and success criteria, the steps and the files or surfaces they touch, how it will be verified, and what is deliberately not being done. Keep it short enough to read in one pass.
|
|
90
|
-
|
|
91
|
-
## Waiting without blocking
|
|
92
|
-
|
|
93
|
-
- Never wait by sleeping. A sleep, a setTimeout inside a run_code program, or one long foreground poll makes you deaf for its whole duration: the user can type, but you will not see it until the wait ends.
|
|
94
|
-
- When the work has to wait — a long command, a build, a test suite, a server or an external job — start it in the background, note the job id, and end the turn. A finished background job wakes you with its notice, and a user message wakes you at once; either way you resume in a new step with everything the user said meanwhile.
|
|
95
|
-
- If something should resume later and no job will finish, use schedule_create for the reminder and end the turn; do not hold the turn open with a timer.
|
|
96
|
-
- If you must wait inside the same turn, keep each wait short and bounded, and lean on the step boundary to see what the user has said; do not hold a foreground call open for minutes.
|
|
97
|
-
- Tell the user in one line that you are waiting in the background and that they can redirect you at any time. Then actually be idle: no busy polling.
|
|
98
|
-
|
|
99
|
-
## Delegating to subagents and teams
|
|
100
|
-
|
|
101
|
-
- Decide by the shape of the work, not by habit. Keep it to yourself when the task is small, sequential, and needs one mind. Delegate when the work splits into genuinely independent pieces, when a broad exploration would flood your context, when several parts can be inspected or verified in parallel, or when an independent reader would catch what you cannot see in your own result.
|
|
102
|
-
- Use the delegation surface this session actually gives you: Agent Team tools (spawn_teammate, team_task_*, wait_agent) when they are listed, or a one-shot subagent tool (such as subagent, subagent_fork, or a provider one like subagent_codex) when that is what the catalog offers. Never assume a tool you cannot see.
|
|
103
|
-
- When you open a team, lead it. Give each teammate one clear responsibility and a complete brief — goal, files or surfaces, constraints, acceptance criteria, and what it must not touch — and the context that fits the job: fresh for independent work, fork only when the child needs your history. Give every concurrent writer — teammate or subagent — a disjoint write scope, and write the split down as shared tasks with dependencies where order matters.
|
|
104
|
-
- Do not do a teammate's work while it runs, and do not spawn a second teammate for the same piece: send the running one a message instead. Collect every result with wait_agent and list_agents before you report, and verify what they claim rather than quoting it unread.
|
|
105
|
-
- For a large or risky change, an independent reviewer or an adversarial check of your own result is a good use of a subagent; a small, verified change does not need one. Delegation is never a substitute for your own inspection of the final state.
|
|
106
|
-
|
|
107
|
-
- id: agent-instructions
|
|
108
|
-
name: '@deepseek-ai/dsh-agent-instructions'
|
|
109
|
-
config:
|
|
110
|
-
maxBytes: 65536
|
|
111
|
-
- id: time-context
|
|
112
|
-
name: '@deepseek-ai/dsh-time-context'
|
|
113
|
-
- id: tool-bash
|
|
114
|
-
name: '@deepseek-ai/dsh-tool-bash'
|
|
115
|
-
disabled: !!js process.platform === 'win32'
|
|
116
|
-
- id: tool-pwsh
|
|
117
|
-
name: '@deepseek-ai/dsh-tool-pwsh'
|
|
118
|
-
disabled: !!js process.platform !== 'win32'
|
|
119
|
-
- id: tool-fs
|
|
120
|
-
name: '@deepseek-ai/dsh-tool-fs'
|
|
121
|
-
- id: tool-fs-search
|
|
122
|
-
name: '@deepseek-ai/dsh-tool-fs-search'
|
|
123
|
-
config:
|
|
124
|
-
sampleOverCapGlobResults: false
|
|
125
|
-
- id: tool-jobs
|
|
126
|
-
name: '@deepseek-ai/dsh-tool-jobs'
|
|
127
|
-
- id: tool-schedule
|
|
128
|
-
name: '@deepseek-ai/dsh-tool-schedule'
|
|
129
|
-
- id: skill-filesystem
|
|
130
|
-
name: '@deepseek-ai/dsh-skill-filesystem'
|
|
131
|
-
- id: tool-skill
|
|
132
|
-
name: '@deepseek-ai/dsh-tool-skill'
|
|
133
|
-
- id: command-goal
|
|
134
|
-
name: '@deepseek-ai/dsh-command-goal'
|
|
135
|
-
- id: tool-goal
|
|
136
|
-
name: '@deepseek-ai/dsh-tool-goal'
|
|
137
|
-
- id: planning
|
|
138
|
-
name: cordis:group
|
|
139
|
-
group: true
|
|
140
|
-
isolate:
|
|
141
|
-
planMode: true
|
|
142
|
-
config:
|
|
143
|
-
- id: plan-mode
|
|
144
|
-
name: '@deepseek-ai/dsh-plan-mode'
|
|
145
|
-
config:
|
|
146
|
-
section: |
|
|
147
|
-
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.
|
|
148
|
-
|
|
149
|
-
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.
|
|
150
|
-
|
|
151
|
-
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.
|
|
152
|
-
|
|
153
|
-
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.
|
|
154
|
-
|
|
155
|
-
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.
|
|
156
|
-
|
|
157
|
-
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.
|
|
158
|
-
- id: compaction
|
|
159
|
-
name: cordis:group
|
|
160
|
-
group: true
|
|
161
|
-
isolate:
|
|
162
|
-
compaction: true
|
|
163
|
-
toolResultPruner: true
|
|
164
|
-
config:
|
|
165
|
-
- id: compaction-basic
|
|
166
|
-
name: '@deepseek-ai/dsh-compaction-basic'
|
|
167
|
-
- id: command-compact
|
|
168
|
-
name: '@deepseek-ai/dsh-command-compact'
|
|
169
|
-
- id: tool-result-pruner
|
|
170
|
-
name: '@deepseek-ai/dsh-compaction-tool-result-pruner'
|
|
171
|
-
config:
|
|
172
|
-
thresholdChars: 8192
|
|
173
|
-
headChars: 4096
|
|
174
|
-
tailChars: 1024
|
|
175
|
-
- id: delegation
|
|
176
|
-
name: cordis:group
|
|
177
|
-
group: true
|
|
178
|
-
isolate:
|
|
179
|
-
workflowEngine: true
|
|
180
|
-
config:
|
|
181
|
-
- id: tool-subagent-control
|
|
182
|
-
name: '@deepseek-ai/dsh-tool-subagent-control'
|
|
183
|
-
- id: tool-subagent-list-agents
|
|
184
|
-
name: '@deepseek-ai/dsh-tool-subagent-control/list-agents'
|
|
185
|
-
- id: tool-subagent
|
|
186
|
-
name: '@deepseek-ai/dsh-tool-subagent'
|
|
187
|
-
config:
|
|
188
|
-
provider: spawn
|
|
189
|
-
toolName: subagent
|
|
190
|
-
modelSelectionSettings: true
|
|
191
|
-
- id: tool-subagent-fork
|
|
192
|
-
name: '@deepseek-ai/dsh-tool-subagent'
|
|
193
|
-
config:
|
|
194
|
-
provider: fork
|
|
195
|
-
toolName: subagent_fork
|
|
196
|
-
- id: workflow-ptc
|
|
197
|
-
name: '@deepseek-ai/dsh-workflow-ptc'
|
|
198
|
-
disabled: true
|
|
199
|
-
config:
|
|
200
|
-
provider: spawn
|
|
201
|
-
- id: tool-workflow
|
|
202
|
-
name: '@deepseek-ai/dsh-tool-workflow'
|
|
203
|
-
disabled: true
|
|
204
|
-
- id: tool-ask-user
|
|
205
|
-
name: '@deepseek-ai/dsh-tool-ask-user'
|
|
206
|
-
- id: tool-todo
|
|
207
|
-
name: '@deepseek-ai/dsh-tool-todo'
|
|
208
|
-
config:
|
|
209
|
-
allowParallelInProgress: true
|
|
210
|
-
- id: tool-web
|
|
211
|
-
name: '@deepseek-ai/dsh-tool-web'
|
|
212
|
-
config:
|
|
213
|
-
fetch: true
|
|
214
|
-
searchTimeoutMs: 60000
|
|
215
|
-
- id: tool-presentation
|
|
216
|
-
name: '@deepseek-ai/dsh-agent-tool-presentation'
|
|
217
|
-
config:
|
|
218
|
-
mode: ptc
|
|
219
|
-
- id: present
|
|
220
|
-
name: '@deepseek-ai/dsh-tool-present'
|
|
221
|
-
- id: tool-plugin-manager
|
|
222
|
-
name: '@deepseek-ai/dsh-plugin-manager/tools'
|
|
223
|
-
disabled: true
|
|
224
|
-
- id: tool-plugin-market
|
|
225
|
-
name: '@deepseek-ai/dsh-plugin-market/tools'
|
|
226
|
-
disabled: true
|
|
6
|
+
environment: auto
|
|
7
|
+
wslDistribution: ''
|
package/lib/client.js
ADDED
|
@@ -0,0 +1,111 @@
|
|
|
1
|
+
window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
|
|
2
|
+
const React = require('react');
|
|
3
|
+
const h = React.createElement;
|
|
4
|
+
const NS = 'deep-ptc-settings';
|
|
5
|
+
const inject = ['slots', 'locale', 'configForms'];
|
|
6
|
+
const dictionaries = {
|
|
7
|
+
zh: {
|
|
8
|
+
title: '深度 PTC', summary: '选择执行环境,应用于之后新建的深度 PTC 会话。',
|
|
9
|
+
environment: '执行环境', auto: '自动(Windows:PowerShell;macOS:Zsh;Linux:Bash)',
|
|
10
|
+
wsl: 'WSL Bash(Windows)', powershell: 'PowerShell(Windows)',
|
|
11
|
+
zsh: 'Zsh(macOS / Linux)', bash: '原生 Bash(macOS / Linux)',
|
|
12
|
+
distribution: 'WSL 发行版', distributionHint: '留空使用 Windows 的默认发行版,例如 Ubuntu。',
|
|
13
|
+
sessions: '保存后请新建一个“深度PTC模式”会话。已有会话与后台任务保留原环境。',
|
|
14
|
+
wslHint: 'WSL 暂不支持 Windows 的受限沙箱;受限调用会明确失败,不会自动切换或绕过限制。',
|
|
15
|
+
save: '保存', saving: '保存中…', saved: '已保存,新会话将使用所选环境。',
|
|
16
|
+
failed: '未能保存,请检查环境是否适用于宿主、发行版名称及配置是否已被其他窗口修改。',
|
|
17
|
+
readOnly: '当前设置为只读。', loading: '正在读取设置…',
|
|
18
|
+
},
|
|
19
|
+
en: {
|
|
20
|
+
title: 'Deep PTC', summary: 'Choose the execution environment for new Deep PTC sessions.',
|
|
21
|
+
environment: 'Execution environment', auto: 'Automatic (Windows: PowerShell; macOS: Zsh; Linux: Bash)',
|
|
22
|
+
wsl: 'WSL Bash (Windows)', powershell: 'PowerShell (Windows)',
|
|
23
|
+
zsh: 'Zsh (macOS / Linux)', bash: 'Native Bash (macOS / Linux)',
|
|
24
|
+
distribution: 'WSL distribution', distributionHint: 'Leave blank for the Windows default distribution, for example Ubuntu.',
|
|
25
|
+
sessions: 'After saving, create a new Deep PTC session. Existing sessions and background jobs keep their environment.',
|
|
26
|
+
wslHint: 'WSL does not support the confined Windows sandbox. Confined calls fail without execution or fallback.',
|
|
27
|
+
save: 'Save', saving: 'Saving…', saved: 'Saved. New sessions will use this environment.',
|
|
28
|
+
failed: 'Could not save. Check host compatibility, distribution name, and concurrent configuration changes.',
|
|
29
|
+
readOnly: 'Settings are read-only.', loading: 'Loading settings…',
|
|
30
|
+
},
|
|
31
|
+
};
|
|
32
|
+
|
|
33
|
+
function Card({ view, form, t }) {
|
|
34
|
+
const subscribe = React.useCallback(listener => form.subscribe(listener), [form]);
|
|
35
|
+
const read = React.useCallback(() => form.getSnapshot(), [form]);
|
|
36
|
+
const state = React.useSyncExternalStore(subscribe, read, read);
|
|
37
|
+
const [environment, setEnvironment] = React.useState('auto');
|
|
38
|
+
const [distribution, setDistribution] = React.useState('');
|
|
39
|
+
const [saving, setSaving] = React.useState(false);
|
|
40
|
+
const [message, setMessage] = React.useState('');
|
|
41
|
+
const [failed, setFailed] = React.useState(false);
|
|
42
|
+
const draftRevision = React.useRef();
|
|
43
|
+
const dirty = React.useRef(false);
|
|
44
|
+
React.useEffect(() => {
|
|
45
|
+
if (!state.value || dirty.current) return;
|
|
46
|
+
setEnvironment(state.value.environment);
|
|
47
|
+
setDistribution(state.value.wslDistribution ?? '');
|
|
48
|
+
draftRevision.current = state.revision;
|
|
49
|
+
}, [state.value, state.revision]);
|
|
50
|
+
if (view === 'summary') return t('summary');
|
|
51
|
+
if (state.status !== 'ready') return h('p', null, t('loading'));
|
|
52
|
+
const allowed = state.value.hostPlatform === 'win32'
|
|
53
|
+
? ['auto', 'wsl', 'powershell'] : ['auto', 'zsh', 'bash'];
|
|
54
|
+
const disabled = !state.writable || saving;
|
|
55
|
+
const changed = () => {
|
|
56
|
+
if (!dirty.current) draftRevision.current = state.revision;
|
|
57
|
+
dirty.current = true;
|
|
58
|
+
setMessage('');
|
|
59
|
+
};
|
|
60
|
+
async function save(event) {
|
|
61
|
+
event.preventDefault();
|
|
62
|
+
setSaving(true); setMessage(''); setFailed(false);
|
|
63
|
+
try {
|
|
64
|
+
const ok = await form.mutate([
|
|
65
|
+
{ op: 'set', path: ['environment'], value: environment },
|
|
66
|
+
{ op: 'set', path: ['wslDistribution'], value: distribution.trim() },
|
|
67
|
+
], draftRevision.current);
|
|
68
|
+
if (!ok) throw new Error('Configuration was rejected');
|
|
69
|
+
dirty.current = false;
|
|
70
|
+
const latest = form.getSnapshot();
|
|
71
|
+
draftRevision.current = latest.revision;
|
|
72
|
+
setEnvironment(latest.value?.environment ?? environment);
|
|
73
|
+
setDistribution(latest.value?.wslDistribution ?? distribution.trim());
|
|
74
|
+
setMessage(t('saved'));
|
|
75
|
+
} catch {
|
|
76
|
+
draftRevision.current = form.getSnapshot().revision;
|
|
77
|
+
setFailed(true); setMessage(t('failed'));
|
|
78
|
+
} finally { setSaving(false); }
|
|
79
|
+
}
|
|
80
|
+
const control = { width: '100%', padding: '8px 10px', borderRadius: '6px',
|
|
81
|
+
color: 'inherit', background: 'var(--dsw-alias-bg-base)', border: '1px solid var(--dsw-alias-border-l1)' };
|
|
82
|
+
return h('form', { onSubmit: save, style: { display: 'grid', gap: '12px', maxWidth: '600px' } },
|
|
83
|
+
h('label', { htmlFor: 'deep-ptc-environment' }, t('environment')),
|
|
84
|
+
h('select', { id: 'deep-ptc-environment', value: environment, disabled, style: control,
|
|
85
|
+
onChange: event => { changed(); setEnvironment(event.target.value); } },
|
|
86
|
+
...['auto', 'wsl', 'powershell', 'zsh', 'bash'].map(value =>
|
|
87
|
+
h('option', { key: value, value, disabled: !allowed.includes(value) }, t(value)))),
|
|
88
|
+
environment === 'wsl' ? h(React.Fragment, null,
|
|
89
|
+
h('label', { htmlFor: 'deep-ptc-distribution' }, t('distribution')),
|
|
90
|
+
h('input', { id: 'deep-ptc-distribution', value: distribution, disabled, style: control,
|
|
91
|
+
onChange: event => { changed(); setDistribution(event.target.value); } }),
|
|
92
|
+
h('p', null, t('distributionHint')), h('p', null, t('wslHint'))) : null,
|
|
93
|
+
h('p', null, t('sessions')),
|
|
94
|
+
!state.writable ? h('p', { role: 'status' }, t('readOnly')) : null,
|
|
95
|
+
message ? h('p', { role: failed ? 'alert' : 'status' }, message) : null,
|
|
96
|
+
h('button', { type: 'submit', disabled, style: { justifySelf: 'start', padding: '7px 16px' } }, t(saving ? 'saving' : 'save')),
|
|
97
|
+
);
|
|
98
|
+
}
|
|
99
|
+
|
|
100
|
+
function apply(ctx) {
|
|
101
|
+
const t = ctx.locale.bind('deep-ptc');
|
|
102
|
+
ctx.effect(() => ctx.locale.register('deep-ptc', dictionaries));
|
|
103
|
+
const form = ctx.configForms.get(NS);
|
|
104
|
+
ctx.effect(() => ctx.configForms.whileServed([NS], () =>
|
|
105
|
+
ctx.slots.inject('plugins.item', () => ctx.slots.register({
|
|
106
|
+
name: 'plugins.item', id: 'deep-ptc', order: 41,
|
|
107
|
+
label: () => t('title'), locale: 'deep-ptc',
|
|
108
|
+
}, props => h(Card, { ...props, form, t })))));
|
|
109
|
+
}
|
|
110
|
+
return { apply, inject };
|
|
111
|
+
} });
|
|
@@ -0,0 +1,14 @@
|
|
|
1
|
+
import z from '@deepseek-ai/schemastery';
|
|
2
|
+
import { environmentText } from './model.mjs';
|
|
3
|
+
export const name = 'deep-ptc-execution-instructions';
|
|
4
|
+
export const inject = ['systemPrompt'];
|
|
5
|
+
export const Config = z.object({
|
|
6
|
+
environment: z.union(['wsl', 'powershell', 'zsh', 'bash']).required(),
|
|
7
|
+
wslDistribution: z.string().default(''),
|
|
8
|
+
});
|
|
9
|
+
export function apply(ctx, config) {
|
|
10
|
+
ctx.systemPrompt.section({
|
|
11
|
+
name: 'deep-ptc:execution-environment', order: 10190,
|
|
12
|
+
text: environmentText(config.environment, config.wslDistribution),
|
|
13
|
+
});
|
|
14
|
+
}
|
package/lib/executor.mjs
ADDED
|
@@ -0,0 +1,34 @@
|
|
|
1
|
+
import z from '@deepseek-ai/schemastery';
|
|
2
|
+
import { LocalBashExecutor } from '@deepseek-ai/dsh-bash-local';
|
|
3
|
+
import { SandboxBashExecutor } from '@deepseek-ai/dsh-bash-sandbox';
|
|
4
|
+
import { assertExecutionPolicy, shellArgv } from './model.mjs';
|
|
5
|
+
|
|
6
|
+
// Uses the host's process handles, output retention, cancellation, jobs and sandbox.
|
|
7
|
+
export default class MappedShellExecutor extends SandboxBashExecutor {
|
|
8
|
+
static Config = z.object({
|
|
9
|
+
environment: z.union(['wsl', 'zsh']).required(),
|
|
10
|
+
wslDistribution: z.string().default(''),
|
|
11
|
+
cwd: z.string().volatile(),
|
|
12
|
+
timeoutMs: z.number().min(1).default(120000).volatile(),
|
|
13
|
+
maxTimeoutMs: z.number().min(1).default(600000).volatile(),
|
|
14
|
+
maxOutputBytes: z.number().min(1).default(64000).volatile(),
|
|
15
|
+
maxSpillBytes: z.number().min(1).default(67108864).volatile(),
|
|
16
|
+
graceMs: z.number().min(1).default(3000).volatile(),
|
|
17
|
+
});
|
|
18
|
+
|
|
19
|
+
async execute(spec) {
|
|
20
|
+
assertExecutionPolicy(this.config.environment, spec.sandboxPolicy);
|
|
21
|
+
if (spec.sandboxPolicy.mode !== 'danger-full-access') return super.execute(spec);
|
|
22
|
+
const process = await LocalBashExecutor.prototype.executeArgv.call(this, spec,
|
|
23
|
+
shellArgv(this.config.environment, spec, this.config.wslDistribution));
|
|
24
|
+
return SandboxBashExecutor.decorateResult(process, result => ({
|
|
25
|
+
...result, sandbox: { mode: spec.sandboxPolicy.mode, denied: false },
|
|
26
|
+
}));
|
|
27
|
+
}
|
|
28
|
+
|
|
29
|
+
confine(command, policy, signal) {
|
|
30
|
+
assertExecutionPolicy(this.config.environment, policy);
|
|
31
|
+
return this.ctx.sandbox.confine(shellArgv(this.config.environment,
|
|
32
|
+
{ command, workdir: policy.workspaceRoot }, this.config.wslDistribution), policy, signal);
|
|
33
|
+
}
|
|
34
|
+
}
|
package/lib/index.mjs
ADDED
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
import z from '@deepseek-ai/schemastery';
|
|
2
|
+
import template from './preset.json' with { type: 'json' };
|
|
3
|
+
import { availableEnvironments, configuredPreset, normalizeDistribution } from './model.mjs';
|
|
4
|
+
import { presetLifecycle } from './lifecycle.mjs';
|
|
5
|
+
|
|
6
|
+
export const name = 'deep-ptc-settings';
|
|
7
|
+
export const inject = ['agentPresets'];
|
|
8
|
+
export const Config = z.object({
|
|
9
|
+
environment: z.union(availableEnvironments(process.platform)).default('auto').volatile(),
|
|
10
|
+
wslDistribution: z.string().pattern(/^(?!\s*-)[^\u0000-\u001f\u007f]*$/u).default('').volatile(),
|
|
11
|
+
hostPlatform: z.const(process.platform).default(process.platform).volatile(),
|
|
12
|
+
});
|
|
13
|
+
|
|
14
|
+
export async function apply(ctx, config) {
|
|
15
|
+
const lifecycle = presetLifecycle(
|
|
16
|
+
definition => ctx.agentPresets.register(definition),
|
|
17
|
+
() => configuredPreset(template, {
|
|
18
|
+
environment: config.environment.get(),
|
|
19
|
+
wslDistribution: normalizeDistribution(config.wslDistribution.get()),
|
|
20
|
+
}),
|
|
21
|
+
error => ctx.logger.error('Deep PTC environment update failed: %s', error.message),
|
|
22
|
+
);
|
|
23
|
+
ctx.effect(() => () => lifecycle.dispose());
|
|
24
|
+
ctx.on('loader/volatile-update', () => { void lifecycle.refresh().catch(() => {}); });
|
|
25
|
+
ctx.inject(['settings'], child => {
|
|
26
|
+
child.effect(() => child.settings.configure({ auto: false }, ctx.fiber));
|
|
27
|
+
});
|
|
28
|
+
await lifecycle.refresh();
|
|
29
|
+
}
|
|
@@ -0,0 +1,30 @@
|
|
|
1
|
+
// Serialize definition replacement. The registry retains revisions used by old sessions.
|
|
2
|
+
export function presetLifecycle(register, getDefinition, onError) {
|
|
3
|
+
let disposed = false;
|
|
4
|
+
let unregister;
|
|
5
|
+
let queue = Promise.resolve();
|
|
6
|
+
const refresh = () => {
|
|
7
|
+
queue = queue.then(async () => {
|
|
8
|
+
if (disposed) return;
|
|
9
|
+
const definition = getDefinition(); // Validate before removing the last good definition.
|
|
10
|
+
await unregister?.();
|
|
11
|
+
unregister = undefined;
|
|
12
|
+
if (disposed) return;
|
|
13
|
+
const release = await register(definition);
|
|
14
|
+
if (disposed) await release();
|
|
15
|
+
else unregister = release;
|
|
16
|
+
});
|
|
17
|
+
const operation = queue;
|
|
18
|
+
queue = operation.catch(error => onError(error));
|
|
19
|
+
return operation;
|
|
20
|
+
};
|
|
21
|
+
return {
|
|
22
|
+
refresh,
|
|
23
|
+
async dispose() {
|
|
24
|
+
disposed = true;
|
|
25
|
+
await queue;
|
|
26
|
+
await unregister?.();
|
|
27
|
+
unregister = undefined;
|
|
28
|
+
},
|
|
29
|
+
};
|
|
30
|
+
}
|
package/lib/model.mjs
ADDED
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
export const ENVIRONMENTS = ['auto', 'wsl', 'powershell', 'zsh', 'bash'];
|
|
2
|
+
|
|
3
|
+
export function availableEnvironments(platform) {
|
|
4
|
+
return platform === 'win32' ? ['auto', 'wsl', 'powershell'] : ['auto', 'zsh', 'bash'];
|
|
5
|
+
}
|
|
6
|
+
|
|
7
|
+
export function resolveEnvironment(environment = 'auto', platform = process.platform) {
|
|
8
|
+
if (!availableEnvironments(platform).includes(environment)) {
|
|
9
|
+
throw new Error(`Execution environment ${JSON.stringify(environment)} is unavailable on ${platform}`);
|
|
10
|
+
}
|
|
11
|
+
return environment === 'auto'
|
|
12
|
+
? (platform === 'win32' ? 'powershell' : platform === 'darwin' ? 'zsh' : 'bash')
|
|
13
|
+
: environment;
|
|
14
|
+
}
|
|
15
|
+
|
|
16
|
+
export function normalizeDistribution(value = '') {
|
|
17
|
+
if (typeof value !== 'string' || /[\u0000-\u001f\u007f]/u.test(value)) {
|
|
18
|
+
throw new Error('WSL distribution must be a name without control characters');
|
|
19
|
+
}
|
|
20
|
+
const distribution = value.trim();
|
|
21
|
+
if (distribution.startsWith('-')) throw new Error('WSL distribution must not start with a dash');
|
|
22
|
+
return distribution;
|
|
23
|
+
}
|
|
24
|
+
|
|
25
|
+
export function shellArgv(environment, spec, distribution = '', platform = process.platform) {
|
|
26
|
+
if (environment === 'wsl') {
|
|
27
|
+
if (platform !== 'win32') throw new Error('WSL requires a Windows host');
|
|
28
|
+
const distro = normalizeDistribution(distribution);
|
|
29
|
+
return ['wsl.exe', ...(distro ? ['--distribution', distro] : []),
|
|
30
|
+
'--cd', spec.workdir, '--exec', 'bash', '-lc', spec.command];
|
|
31
|
+
}
|
|
32
|
+
if (environment === 'zsh') return [platform === 'darwin' ? '/bin/zsh' : 'zsh', '-lc', spec.command];
|
|
33
|
+
throw new Error(`No mapped executor for ${environment}`);
|
|
34
|
+
}
|
|
35
|
+
|
|
36
|
+
export function assertExecutionPolicy(environment, policy) {
|
|
37
|
+
if (environment === 'wsl' && policy?.mode !== 'danger-full-access') {
|
|
38
|
+
throw new Error('WSL execution is not supported under a confined Windows sandbox. Select PowerShell for confined work, or use the host\'s existing approval flow for this exact command. No command was executed.');
|
|
39
|
+
}
|
|
40
|
+
}
|
|
41
|
+
|
|
42
|
+
export function environmentText(environment, distribution = '') {
|
|
43
|
+
const descriptions = {
|
|
44
|
+
wsl: `Execution environment: WSL Bash${distribution ? ` (${distribution})` : ' (Windows default distribution)'}. The bash tool runs POSIX source via wsl.exe and bash -lc. File tools and the tool workdir use Windows host paths; Linux paths belong inside command source. WSL is available only in danger-full-access; a confined call fails without execution. Never silently fall back to PowerShell or another distribution.`,
|
|
45
|
+
powershell: 'Execution environment: native Windows PowerShell. Use the pwsh tool and PowerShell syntax, native Windows paths and $env:NAME. This selection takes precedence over older workspace guidance that assumed WSL. The configured sandbox and approval policy still apply.',
|
|
46
|
+
zsh: 'Execution environment: native Zsh. Use the zsh tool with Zsh/POSIX command source. On macOS the executor is /bin/zsh -lc; elsewhere zsh must be installed. File tools and workdir use native host paths. The configured sandbox and approval policy still apply.',
|
|
47
|
+
bash: 'Execution environment: native Bash on macOS/Linux. Use the bash tool with Bash/POSIX command source and native host paths. This is not WSL. The configured sandbox and approval policy still apply.',
|
|
48
|
+
};
|
|
49
|
+
if (!descriptions[environment]) throw new Error(`Unknown environment ${environment}`);
|
|
50
|
+
return descriptions[environment];
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
export function configuredPreset(template, options, platform = process.platform) {
|
|
54
|
+
const environment = resolveEnvironment(options.environment, platform);
|
|
55
|
+
const distribution = normalizeDistribution(options.wslDistribution);
|
|
56
|
+
const preset = structuredClone(template);
|
|
57
|
+
const first = preset.plugins.findIndex(row => row.id === 'tool-bash');
|
|
58
|
+
if (first < 0 || preset.plugins[first + 1]?.id !== 'tool-pwsh') throw new Error('Upstream shell layout changed; review compatibility before loading');
|
|
59
|
+
const executor = {
|
|
60
|
+
id: 'executor',
|
|
61
|
+
name: environment === 'powershell' ? '@deepseek-ai/dsh-pwsh-sandbox'
|
|
62
|
+
: environment === 'bash' ? '@deepseek-ai/dsh-bash-sandbox' : 'dsh-deep-ptc-mode/executor',
|
|
63
|
+
...(environment === 'wsl' || environment === 'zsh'
|
|
64
|
+
? { config: { environment, wslDistribution: distribution } } : {}),
|
|
65
|
+
};
|
|
66
|
+
const terminal = environment === 'zsh'
|
|
67
|
+
? { id: 'tool-zsh', name: 'dsh-deep-ptc-mode/terminal' }
|
|
68
|
+
: { id: environment === 'powershell' ? 'tool-pwsh' : 'tool-bash',
|
|
69
|
+
name: environment === 'powershell' ? '@deepseek-ai/dsh-tool-pwsh' : '@deepseek-ai/dsh-tool-bash' };
|
|
70
|
+
preset.plugins.splice(first, 2, {
|
|
71
|
+
id: 'execution', name: 'cordis:group', group: true, isolate: { shell: true },
|
|
72
|
+
config: [executor, terminal, { id: 'execution-instructions', name: 'dsh-deep-ptc-mode/environment',
|
|
73
|
+
config: { environment, wslDistribution: distribution } }],
|
|
74
|
+
});
|
|
75
|
+
preset.description = `${template.description} 当前环境:${environment}${environment === 'wsl' && distribution ? ` (${distribution})` : ''}`;
|
|
76
|
+
return preset;
|
|
77
|
+
}
|