dsh-deep-ptc-mode 1.8.7 → 1.8.8

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/lib/client.js CHANGED
@@ -6,6 +6,9 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
6
6
  const dictionaries = {
7
7
  zh: {
8
8
  title: '深度 PTC', summary: '选择执行环境,应用于之后新建的深度 PTC 会话。',
9
+ presetName: '深度 PTC 模式',
10
+ presetDescription: '任务运行时可插话,按任务规模制定计划,意图不清时先提问。支持 WSL、PowerShell、Zsh 和 Bash。',
11
+ presetEnvironment: '当前环境:{env}', presetSafeMode: '当前为安全模式', presetOfficial: '官方默认',
9
12
  environment: '执行环境', auto: '自动(Windows:PowerShell;macOS:Zsh;Linux:Bash)',
10
13
  wsl: 'WSL Bash(Windows)', powershell: 'PowerShell(Windows)',
11
14
  zsh: 'Zsh(macOS / Linux)', bash: '原生 Bash(macOS / Linux)',
@@ -13,6 +16,7 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
13
16
  bashPathHint: '可填写 dsh-ops 随包的 Niubash。路径不可用时保留官方 Shell。受限模式请选 PowerShell。',
14
17
  distribution: 'WSL 发行版', distributionHint: '留空使用 Windows 的默认发行版,例如 Ubuntu。',
15
18
  shell: 'Shell 版本', shellAuto: '自动(沿用官方查找顺序)',
19
+ shellSystem: '{name}(系统自带)', shellPreview: 'PowerShell 7 预览版',
16
20
  shellHint: '只列出本机已发现的常见版本。文件消失后自动回退。WSL 仍只选择发行版。',
17
21
  sessions: '保存后请新建一个“深度PTC模式”会话。已有会话与后台任务保留原环境。',
18
22
  wslHint: 'WSL 暂不支持 Windows 的受限沙箱;受限调用会明确失败,不会自动切换或绕过限制。',
@@ -22,6 +26,9 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
22
26
  },
23
27
  en: {
24
28
  title: 'Deep PTC', summary: 'Choose the execution environment for new Deep PTC sessions.',
29
+ presetName: 'Deep PTC Mode',
30
+ presetDescription: 'Steer running tasks, plan according to task size, and clarify unclear requests. Supports WSL, PowerShell, Zsh, and Bash.',
31
+ presetEnvironment: 'Current environment: {env}', presetSafeMode: 'Safe mode is active', presetOfficial: 'Official default',
25
32
  environment: 'Execution environment', auto: 'Automatic (Windows: PowerShell; macOS: Zsh; Linux: Bash)',
26
33
  wsl: 'WSL Bash (Windows)', powershell: 'PowerShell (Windows)',
27
34
  zsh: 'Zsh (macOS / Linux)', bash: 'Native Bash (macOS / Linux)',
@@ -29,6 +36,7 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
29
36
  bashPathHint: 'You can use the Niubash bundled with dsh-ops. An unavailable path keeps the official shell. Choose PowerShell for confined work.',
30
37
  distribution: 'WSL distribution', distributionHint: 'Leave blank for the Windows default distribution, for example Ubuntu.',
31
38
  shell: 'Shell version', shellAuto: 'Automatic (official lookup)',
39
+ shellSystem: '{name} (system)', shellPreview: 'PowerShell 7 Preview',
32
40
  shellHint: 'Lists common executables found on this machine. A missing file falls back to automatic. WSL still selects a distribution only.',
33
41
  sessions: 'After saving, create a new Deep PTC session. Existing sessions and background jobs keep their environment.',
34
42
  wslHint: 'WSL does not support the confined Windows sandbox. Confined calls fail without execution or fallback.',
@@ -84,10 +92,10 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
84
92
  setEnvironment(latest.value?.environment ?? environment);
85
93
  setDistribution(latest.value?.wslDistribution ?? distribution.trim());
86
94
  setShellExecutable(latest.value?.shellExecutable ?? shellExecutable);
87
- setMessage(t('saved'));
95
+ setMessage('saved');
88
96
  } catch {
89
97
  draftRevision.current = form.getSnapshot().revision;
90
- setFailed(true); setMessage(t('failed'));
98
+ setFailed(true); setMessage('failed');
91
99
  } finally { setSaving(false); }
92
100
  }
93
101
  const effective = environment === 'auto'
@@ -123,11 +131,11 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
123
131
  h('select', { id: 'deep-ptc-shell', value: shellExecutable, disabled, style: control,
124
132
  onChange: event => { changed(); setShellExecutable(event.target.value); } },
125
133
  h('option', { value: '' }, t('shellAuto')),
126
- ...choices.map(item => h('option', { key: item.id, value: item.id }, item.label))),
134
+ ...choices.map(item => h('option', { key: item.id, value: item.id }, shellLabel(item.label, t)))),
127
135
  h('p', null, t('shellHint'))) : null,
128
136
  h('p', null, t('sessions')),
129
137
  !state.writable ? h('p', { role: 'status' }, t('readOnly')) : null,
130
- message ? h('p', { role: failed ? 'alert' : 'status' }, message) : null,
138
+ message ? h('p', { role: failed ? 'alert' : 'status' }, t(message)) : null,
131
139
  h('button', { type: 'submit', disabled: disabled || (windowsBash && !shellExecutable.trim()),
132
140
  style: { justifySelf: 'start', padding: '7px 16px' } }, t(saving ? 'saving' : 'save')),
133
141
  );
@@ -135,9 +143,9 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
135
143
 
136
144
  function ToolStateControls({ sessionId, useProjection, reset, t }) {
137
145
  const [busy, setBusy] = React.useState(false);
138
- const [message, setMessage] = React.useState('');
146
+ const [message, setMessage] = React.useState(null);
139
147
  const generation = React.useRef(0);
140
- React.useEffect(() => { generation.current++; setBusy(false); setMessage(''); return () => { generation.current++; }; }, [sessionId]);
148
+ React.useEffect(() => { generation.current++; setBusy(false); setMessage(null); return () => { generation.current++; }; }, [sessionId]);
141
149
  let preset, state;
142
150
  try {
143
151
  if (typeof useProjection !== 'function') return null;
@@ -149,20 +157,23 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
149
157
  const failed = state && typeof state === 'object' ? state.report?.tools ?? [] : [];
150
158
  async function reload() {
151
159
  const current = generation.current;
152
- setBusy(true); setMessage('');
160
+ setBusy(true); setMessage(null);
153
161
  try {
154
162
  const outcome = await reset();
155
163
  if (current !== generation.current) return;
156
164
  if (outcome?.ok === false) throw new Error(outcome.error?.message);
157
165
  const reply = outcome?.ok === true ? outcome.value : outcome;
158
- if (reply === undefined) throw new Error(t('toolResetUnavailable'));
166
+ if (reply === undefined) {
167
+ setMessage({ key: 'toolResetFailed', reason: 'toolResetUnavailable' });
168
+ return;
169
+ }
159
170
  const result = reply?.result ?? reply;
160
171
  if (result?.kind !== 'success') throw new Error(result?.text);
161
- setMessage(t('toolResetDone'));
172
+ setMessage({ key: 'toolResetDone' });
162
173
  } catch (error) {
163
174
  if (current === generation.current) {
164
175
  const detail = String(error?.message ?? error ?? '').slice(0, 220);
165
- setMessage(detail ? `${t('toolResetFailed')} ${detail}` : t('toolResetFailed'));
176
+ setMessage({ key: 'toolResetFailed', detail });
166
177
  }
167
178
  }
168
179
  finally { if (current === generation.current) setBusy(false); }
@@ -175,8 +186,8 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
175
186
  h('ul', null, ...failed.map(row => h('li', { key: row.name }, h('code', null, row.name), ` — ${row.provider}`)))) : null,
176
187
  h('button', { type: 'button', className: 'dpt-btn dpt-btn-block', onClick: reload, disabled: busy, title: t('toolResetHint'), 'aria-busy': busy },
177
188
  busy ? t('toolResetBusy') : t('toolReset')),
178
- h('p', { className: 'dpt-side-note', role: 'status', 'data-tone': message ? (message === t('toolResetDone') ? 'ok' : 'error') : undefined },
179
- message || t('toolResetHint')));
189
+ h('p', { className: 'dpt-side-note', role: 'status', 'data-tone': message ? (message.key === 'toolResetDone' ? 'ok' : 'error') : undefined },
190
+ message ? [t(message.key), message.reason ? t(message.reason) : commandText(message.detail, t)].filter(Boolean).join(' ') : t('toolResetHint')));
180
191
  }
181
192
  Object.assign(dictionaries.zh, {
182
193
  visualEffects: '界面特效', visualEffectsHint: '使用外部主题或 UI 插件时,建议关闭此开关。',
@@ -184,6 +195,7 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
184
195
  jobRunning: '运行中', jobStopping: '正在停止', jobCompleted: '已完成', jobKilled: '已取消', jobFailed: '已失败',
185
196
  toolReset: '重载所有工具状态', toolResetBusy: '正在重载…', toolResetDone: '本对话工具状态已重载。',
186
197
  toolResetFailed: '未能重载工具状态。', toolResetUnavailable: '当前会话无法调用工具重载命令。',
198
+ commandNoSession: '当前没有活动对话。', commandWrongMode: '该功能仅在深度 PTC 会话中可用。', commandInvalidSkill: '无效的 Skill 卡片操作。',
187
199
  toolResetHint: '清除本对话的故障标记和按需加载选择;正在运行的任务继续执行。',
188
200
  toolFailures: '工具适配提醒', toolFailureHint: '以下外部工具调用失败,可能存在适配问题,已在本对话中禁用。任务会优先使用其他可用工具;未进一步排查故障原因。',
189
201
  });
@@ -193,6 +205,7 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
193
205
  jobRunning: 'Running', jobStopping: 'Stopping', jobCompleted: 'Completed', jobKilled: 'Canceled', jobFailed: 'Failed',
194
206
  toolReset: 'Reload all tool states', toolResetBusy: 'Reloading…', toolResetDone: 'Tool states reloaded for this conversation.',
195
207
  toolResetFailed: 'Could not reload tool states.', toolResetUnavailable: 'The reload command is unavailable in this conversation.',
208
+ commandNoSession: 'No active conversation.', commandWrongMode: 'This command is available in Deep PTC sessions only.', commandInvalidSkill: 'Invalid skill card command.',
196
209
  toolResetHint: 'Clear quarantine and on-demand selections in this conversation. Running jobs continue.',
197
210
  toolFailures: 'Tool compatibility notice', toolFailureHint: 'These external tools failed and may have compatibility issues. They are disabled in this conversation. Continue with working alternatives; no root-cause investigation was performed.',
198
211
  });
@@ -234,6 +247,15 @@ window.__ModuleLoader__.load({ id: 'dsh-deep-ptc-mode', factory: require => {
234
247
  // Placeholders are filled here, so the text is right whether or not the host locale interpolates.
235
248
  const fill = (text, values) => String(text).replace(/\{(\w+)\}/gu, (whole, key) => values[key] === undefined ? whole : String(values[key]));
236
249
  const tf = (t, key, values) => fill(t(key, values), values);
250
+ const commandMessageKeys = new Map([
251
+ ['No active conversation. / 当前没有活动对话。', 'commandNoSession'],
252
+ ['This command is available in Deep PTC sessions only. / 该功能仅在深度 PTC 会话中可用。', 'commandWrongMode'],
253
+ ['Invalid skill card command. / 无效的 Skill 卡片操作。', 'commandInvalidSkill'],
254
+ ]);
255
+ function commandText(text, t) {
256
+ const key = commandMessageKeys.get(text);
257
+ return key ? t(key) : text;
258
+ }
237
259
  let T = key => key;
238
260
  let hostCtx;
239
261
  let ReactDOM;
@@ -547,7 +569,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
547
569
  BUSY.bridge = on && (current?.busy === true || SESSIONS.working.get(current?.id) === true);
548
570
  applyBusy();
549
571
  if (on && !stopVisuals) {
550
- const cleanups = [watchSurfaces(), watchPalette(), watchInteractions(), watchFx()];
572
+ const cleanups = [watchSurfaces(), watchPalette(), watchInteractions(), watchFx(), watchDiagnostics()];
551
573
  stopVisuals = () => cleanups.reverse().forEach(cleanup => cleanup());
552
574
  } else if (!on) disableVisuals();
553
575
  };
@@ -693,7 +715,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
693
715
  }
694
716
  function watchPalette() {
695
717
  if (typeof document === 'undefined') return () => {};
696
- let backdrop = null, input = null, list = null, items = [], shown = [], index = 0;
718
+ let backdrop = null, panel, foot, input, list, items = [], shown = [], index = 0;
697
719
  const close = () => { backdrop?.remove(); backdrop = null; };
698
720
  function mark() {
699
721
  for (let at = 0; at < list.children.length; at++) list.children[at].setAttribute('aria-selected', at === index ? 'true' : 'false');
@@ -734,25 +756,29 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
734
756
  close();
735
757
  setTimeout(() => { try { item.run(); } catch (error) { console.warn(`[${PLUGIN}] palette action failed:`, error); } }, 30);
736
758
  }
737
- function open() {
759
+ function translatePalette() {
760
+ if (!backdrop) return;
761
+ panel.setAttribute('aria-label', T('palTitle'));
762
+ input.placeholder = T('palPlaceholder');
763
+ input.setAttribute('aria-label', input.placeholder);
764
+ foot.textContent = T('palFoot');
738
765
  items = paletteItems();
766
+ filter();
767
+ }
768
+ function open() {
739
769
  backdrop = document.createElement('div');
740
770
  backdrop.className = 'dpt-pal-backdrop';
741
771
  backdrop.setAttribute('data-dpt-palette', '');
742
- const panel = document.createElement('div');
772
+ panel = document.createElement('div');
743
773
  panel.className = 'dpt-pal';
744
774
  panel.setAttribute('role', 'dialog');
745
- panel.setAttribute('aria-label', T('palTitle'));
746
775
  input = document.createElement('input');
747
776
  input.className = 'dpt-pal-input';
748
- input.placeholder = T('palPlaceholder');
749
- input.setAttribute('aria-label', T('palPlaceholder'));
750
777
  list = document.createElement('div');
751
778
  list.className = 'dpt-pal-list';
752
779
  list.setAttribute('role', 'listbox');
753
- const foot = document.createElement('div');
780
+ foot = document.createElement('div');
754
781
  foot.className = 'dpt-pal-foot';
755
- foot.textContent = T('palFoot');
756
782
  panel.append(input, list, foot);
757
783
  backdrop.appendChild(panel);
758
784
  document.body.appendChild(backdrop);
@@ -765,7 +791,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
765
791
  else if (event.key === 'Enter') { event.preventDefault(); choose(index); }
766
792
  else if (event.key === 'Escape') { event.preventDefault(); close(); }
767
793
  });
768
- filter();
794
+ translatePalette();
769
795
  input.focus();
770
796
  }
771
797
  function onKey(event) {
@@ -776,7 +802,8 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
776
802
  if (backdrop) close(); else open();
777
803
  }
778
804
  document.addEventListener('keydown', onKey, true);
779
- return () => { document.removeEventListener('keydown', onKey, true); close(); };
805
+ const unsubscribe = hostCtx.locale.subscribe?.(translatePalette);
806
+ return () => { unsubscribe?.(); document.removeEventListener('keydown', onKey, true); close(); };
780
807
  }
781
808
 
782
809
  // Click ripple, magnetic send button, "/" focuses the composer, Alt+Up/Down switches sessions.
@@ -1161,6 +1188,88 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1161
1188
  const effectiveEnvironment = (environment, platform) => environment !== 'auto' ? environment
1162
1189
  : platform === 'win32' ? 'powershell' : platform === 'darwin' ? 'zsh' : 'bash';
1163
1190
  const envLabel = (value, t) => value === 'auto' ? t('envAuto') : ENV_SHORT[value] ?? value;
1191
+ function shellLabel(label, t) {
1192
+ if (label === 'PowerShell 7 Preview') return t('shellPreview');
1193
+ const system = /^(bash|zsh) \(system\)$/u.exec(label);
1194
+ return system ? tf(t, 'shellSystem', { name: system[1] }) : label;
1195
+ }
1196
+
1197
+ const PRESET_LABEL_SLOTS = [
1198
+ ['conversation.hero.agentPreset', undefined, 'useAgentPresetSeat', 'options'],
1199
+ ['conversation.session.header.actions', 'agent-preset', 'useAgentPresets', 'options'],
1200
+ ['settings.section', 'agent-presets', 'useAgentPresetSection', 'rows'],
1201
+ ];
1202
+
1203
+ function translatedPreset(row, t) {
1204
+ if (row?.id !== 'deep-ptc') return row;
1205
+ const name = t('presetName');
1206
+ const description = row.description ?? '';
1207
+ let status;
1208
+ if (description.endsWith('当前为安全模式')) status = t('presetSafeMode');
1209
+ else {
1210
+ // The preset derivation publishes the mounted environment in this suffix.
1211
+ const current = /当前环境:(\S+)(?: \(([^\n]*)\))?$/u.exec(description);
1212
+ if (current) {
1213
+ const shell = current[1] === '官方默认' ? t('presetOfficial') : envLabel(current[1], t);
1214
+ status = tf(t, 'presetEnvironment', { env: current[2] ? `${shell} (${current[2]})` : shell });
1215
+ }
1216
+ }
1217
+ return { ...row, name, description: [t('presetDescription'), status].filter(Boolean).join(' ') };
1218
+ }
1219
+
1220
+ function presetSnapshotTranslator(rowsKey, t) {
1221
+ const cache = new WeakMap();
1222
+ return snapshot => {
1223
+ if (!snapshot || typeof snapshot !== 'object') return snapshot;
1224
+ if (cache.has(snapshot)) return cache.get(snapshot);
1225
+ const rows = snapshot[rowsKey];
1226
+ const error = snapshot.error;
1227
+ const hasPreset = Array.isArray(rows) && rows.some(row => row.id === 'deep-ptc');
1228
+ const hasPresetError = error?.preset?.id === 'deep-ptc';
1229
+ const localized = hasPreset || hasPresetError ? {
1230
+ ...snapshot,
1231
+ ...(hasPreset ? { [rowsKey]: rows.map(row => translatedPreset(row, t)) } : {}),
1232
+ ...(hasPresetError ? { error: { ...error, preset: translatedPreset(error.preset, t) } } : {}),
1233
+ } : snapshot;
1234
+ cache.set(snapshot, localized);
1235
+ return localized;
1236
+ };
1237
+ }
1238
+
1239
+ // Keep the native picker and its actions. A higher-priority slot entry supplies localized
1240
+ // display snapshots only for our row, while the host owns the actual selection and preset.
1241
+ function installPresetLabels(slots, t, useLocaleRevision) {
1242
+ if (typeof slots.entriesOfSlot !== 'function' || typeof slots.entries !== 'function' || typeof slots.subscribe !== 'function') return;
1243
+ for (const [name, id, hook, rows] of PRESET_LABEL_SLOTS) {
1244
+ slots.inject(name, () => {
1245
+ let original;
1246
+ let dispose;
1247
+ const sync = () => {
1248
+ const entry = slots.entries(name).find(item => item.options?.id === id && (item.options?.priority ?? 0) === 0
1249
+ && item.locale === 'settings.agentPreset' && !item.children && !item.store && typeof item.component === 'function');
1250
+ if (entry === original) return;
1251
+ original = entry;
1252
+ dispose?.();
1253
+ dispose = undefined;
1254
+ if (!entry) return;
1255
+ function LocalizedPresetSlot(props) {
1256
+ const revision = useLocaleRevision();
1257
+ const translate = React.useMemo(() => presetSnapshotTranslator(rows, t), [revision]);
1258
+ const useRoster = props[hook];
1259
+ const useLocalizedRoster = React.useCallback((select, equal) => useRoster(
1260
+ snapshot => select(translate(snapshot)), equal), [useRoster, translate]);
1261
+ return h(entry.component, typeof useRoster === 'function' ? { ...props, [hook]: useLocalizedRoster } : props);
1262
+ }
1263
+ try {
1264
+ dispose = slots.register({ ...entry.options, name, priority: -1, locale: entry.locale, inject: entry.inject }, LocalizedPresetSlot);
1265
+ } catch { /* Another plugin may already own the presentation slot. */ }
1266
+ };
1267
+ const unsubscribe = slots.subscribe(name, sync);
1268
+ sync();
1269
+ return () => { unsubscribe(); dispose?.(); };
1270
+ });
1271
+ }
1272
+ }
1164
1273
 
1165
1274
  function useSettingsForm(form) {
1166
1275
  const subscribe = React.useCallback(listener => form ? form.subscribe(listener) : () => {}, [form]);
@@ -1191,10 +1300,10 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1191
1300
  try {
1192
1301
  const ok = await form.mutate(ops, form.getSnapshot().revision);
1193
1302
  if (!ok) throw new Error('rejected');
1194
- setMessage({ tone: 'ok', text: tf(t, 'envSaved', { env: label }) });
1303
+ setMessage({ tone: 'ok', label });
1195
1304
  return true;
1196
1305
  } catch {
1197
- setMessage({ tone: 'error', text: t('envFailed') });
1306
+ setMessage({ tone: 'error' });
1198
1307
  return false;
1199
1308
  } finally { setSaving(false); }
1200
1309
  }
@@ -1211,7 +1320,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1211
1320
  const ops = [{ op: 'set', path: ['environment'], value: next }];
1212
1321
  // A shell picked for another family would not apply; fall back to the official lookup.
1213
1322
  if (value.shellExecutable && current?.family !== family) ops.push({ op: 'set', path: ['shellExecutable'], value: '' });
1214
- void save(ops, envLabel(next, t));
1323
+ void save(ops, next === 'auto' ? { key: 'envAuto' } : envLabel(next, t));
1215
1324
  }
1216
1325
  async function saveDistribution(event) {
1217
1326
  event?.preventDefault?.();
@@ -1227,6 +1336,14 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1227
1336
  { op: 'set', path: ['shellExecutable'], value: next }], 'Bash')) setBashPath(undefined);
1228
1337
  }
1229
1338
  const familyChoices = choices.filter(item => item.family === effective);
1339
+ let note = t('envThisSession');
1340
+ if (message?.tone === 'error') note = t('envFailed');
1341
+ else if (message) {
1342
+ const label = message.label;
1343
+ const env = typeof label === 'string' ? label : label.key ? t(label.key) : shellLabel(label.shell, t);
1344
+ note = tf(t, 'envSaved', { env });
1345
+ } else if (!state.writable) note = t('readOnly');
1346
+ else if (environment === 'auto') note = tf(t, 'envAutoNow', { env: envLabel(effective, t) });
1230
1347
  return h('section', { className: 'dpt-side-section', 'aria-label': t('environment') },
1231
1348
  h('div', { className: 'dpt-side-label' }, h('span', null, t('environment')), h('span', { className: 'dpt-side-hint' }, t('envForNew'))),
1232
1349
  h('div', { className: 'dpt-seg', role: 'radiogroup', 'aria-label': t('environment') },
@@ -1248,10 +1365,9 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1248
1365
  !editingBash && effective !== 'wsl' && familyChoices.length > 0 ? h('div', { className: 'dpt-field' },
1249
1366
  h('select', { className: 'dpt-select', value: value.shellExecutable ?? '', disabled, 'aria-label': t('shell'), title: t('shellHint'),
1250
1367
  onChange: event => { const item = familyChoices.find(choice => choice.id === event.target.value);
1251
- void save([{ op: 'set', path: ['shellExecutable'], value: event.target.value }], item ? item.label : t('shellAuto')); } },
1252
- h('option', { value: '' }, t('shellAuto')), ...familyChoices.map(item => h('option', { key: item.id, value: item.id }, item.label)))) : null,
1253
- h('p', { className: 'dpt-side-note', role: 'status', 'data-tone': message?.tone },
1254
- message ? message.text : !state.writable ? t('readOnly') : environment === 'auto' ? tf(t, 'envAutoNow', { env: envLabel(effective, t) }) : t('envThisSession')));
1368
+ void save([{ op: 'set', path: ['shellExecutable'], value: event.target.value }], item ? { shell: item.label } : { key: 'shellAuto' }); } },
1369
+ h('option', { value: '' }, t('shellAuto')), ...familyChoices.map(item => h('option', { key: item.id, value: item.id }, shellLabel(item.label, t))))) : null,
1370
+ h('p', { className: 'dpt-side-note', role: 'status', 'data-tone': message?.tone }, note));
1255
1371
  }
1256
1372
 
1257
1373
  const JOB_STATUS = new Map([
@@ -1418,9 +1534,9 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1418
1534
 
1419
1535
  // The skill switches run a host command, and the host logs every command. The log keeps it; the
1420
1536
  // conversation shows nothing for a success and a short line for a failure.
1421
- function SkillCommandRow({ node }) {
1537
+ function SkillCommandRow({ node, t }) {
1422
1538
  const outcome = node?.outcome;
1423
- if (outcome?.kind === 'error') return h('div', { className: 'dpt-command-error', role: 'status' }, outcome.text);
1539
+ if (outcome?.kind === 'error') return h('div', { className: 'dpt-command-error', role: 'status' }, commandText(outcome.text, t));
1424
1540
  return h('span', { hidden: true, 'data-dpt-hidden-command': SKILL_COMMAND_NAME });
1425
1541
  }
1426
1542
 
@@ -1435,21 +1551,28 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1435
1551
  function apply(ctx) {
1436
1552
  hostCtx = ctx;
1437
1553
  const t = ctx.locale.bind('deep-ptc');
1554
+ const subscribeLocale = listener => ctx.locale.subscribe?.(listener) ?? noSubscribe();
1555
+ const readLocale = () => ctx.locale.getSnapshot?.()?.revision ?? 0;
1556
+ const useLocaleRevision = () => React.useSyncExternalStore(subscribeLocale, readLocale, readLocale);
1557
+ function LocalizedSlot({ component, ...props }) {
1558
+ useLocaleRevision();
1559
+ return h(component, { ...props, t: props.t ?? t });
1560
+ }
1438
1561
  T = key => t(key);
1439
1562
  ctx.effect(() => ctx.locale.register('deep-ptc', dictionaries));
1563
+ installPresetLabels(ctx.slots, t, useLocaleRevision);
1440
1564
  ctx.effect(() => injectCss(), `${PLUGIN}: style`);
1441
1565
  ctx.effect(() => watchActiveSession(), `${PLUGIN}: active session`);
1442
- ctx.effect(() => watchDiagnostics(), `${PLUGIN}: diagnostics`);
1443
1566
  const form = ctx.configForms.get(NS);
1444
1567
  ctx.effect(() => ctx.configForms.whileServed([NS], () =>
1445
1568
  ctx.slots.inject('plugins.item', () => ctx.slots.register({
1446
1569
  name: 'plugins.item', id: 'deep-ptc', order: 41,
1447
1570
  label: () => t('title'), locale: 'deep-ptc',
1448
- }, props => h(Card, { ...props, form, t })))));
1571
+ }, props => h(LocalizedSlot, { ...props, form, component: Card })))));
1449
1572
  try {
1450
1573
  ctx.slots.inject('conversation.chat.commandview', () => ctx.slots.register({
1451
- name: 'conversation.chat.commandview', key: SKILL_COMMAND_NAME,
1452
- }, SkillCommandRow));
1574
+ name: 'conversation.chat.commandview', key: SKILL_COMMAND_NAME, locale: 'deep-ptc',
1575
+ }, props => h(LocalizedSlot, { ...props, component: SkillCommandRow })));
1453
1576
  } catch { /* without the renderer the host shows its generic command row */ }
1454
1577
  try {
1455
1578
  // Each conversation header reports which session is on screen and whether it works.
@@ -1461,23 +1584,23 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1461
1584
  ctx.inject?.(['remote', 'remote.commands'], child => {
1462
1585
  try {
1463
1586
  child.slots.inject('conversation.chat.turnTail', () => child.slots.register({
1464
- name: 'conversation.chat.turnTail', id: 'deep-ptc-skills', order: 20,
1587
+ name: 'conversation.chat.turnTail', id: 'deep-ptc-skills', order: 20, locale: 'deep-ptc',
1465
1588
  inject: sessionId => ({
1466
1589
  setSkill: (name, enabled) => runSkillCommand(child, sessionId, { action: 'set', name, enabled }),
1467
1590
  setAll: enabled => runSkillCommand(child, sessionId, { action: 'all', enabled }),
1468
1591
  }),
1469
- }, props => h(SkillTail, { ...props, t })));
1592
+ }, props => h(LocalizedSlot, { ...props, component: SkillTail })));
1470
1593
  } catch { /* a broken card must not take the conversation with it */ }
1471
1594
  try {
1472
1595
  // The side card draws beside the conversation through a portal; nothing shows under the composer.
1473
1596
  child.slots.inject('conversation.composer.dock', () => child.slots.register({
1474
- name: 'conversation.composer.dock', id: 'deep-ptc-side', order: 89,
1597
+ name: 'conversation.composer.dock', id: 'deep-ptc-side', order: 89, locale: 'deep-ptc',
1475
1598
  inject: sessionId => {
1476
1599
  const jobs = child.get?.('jobs');
1477
1600
  const props = {
1478
1601
  reset: () => {
1479
1602
  const execute = child.remote?.commands?.execute;
1480
- if (typeof execute !== 'function') return Promise.resolve({ ok: false, error: { message: 'unavailable' } });
1603
+ if (typeof execute !== 'function') return Promise.resolve({ ok: true, value: undefined });
1481
1604
  return execute(sessionId, '/deep-ptc-reset-tools', []);
1482
1605
  },
1483
1606
  };
@@ -1487,7 +1610,7 @@ ${ON}[data-dpt-busy] [data-dpt-send]::after{content:"";position:absolute;inset:-
1487
1610
  }
1488
1611
  return props;
1489
1612
  },
1490
- }, props => h(SideCardHost, { ...props, form, t })));
1613
+ }, props => h(LocalizedSlot, { ...props, form, component: SideCardHost })));
1491
1614
  } catch { /* the composer stays usable when this slot cannot register */ }
1492
1615
  });
1493
1616
  } catch { /* the composer stays usable when this slot cannot register */ }
package/lib/executor.mjs CHANGED
@@ -1,6 +1,6 @@
1
1
  import z from '@deepseek-ai/schemastery';
2
2
  import { importHost, pluginOf } from './host.mjs';
3
- import { assertExecutionPolicy, shellArgv } from './model.mjs';
3
+ import { extensible, mappedExecutor } from './mapped-shell.mjs';
4
4
 
5
5
  export const name = 'deep-ptc-mapped-executor';
6
6
  export const inject = [];
@@ -13,54 +13,9 @@ export const Config = z.object({
13
13
  options: z.any(),
14
14
  });
15
15
 
16
- function argvOf(environment, spec, distribution, executable) {
17
- return shellArgv(environment, spec, distribution, process.platform, executable);
18
- }
19
-
20
- // Extend the official bash executor: its process handles, output retention, cancellation, jobs,
21
- // sandbox and Config stay official; only the argv that starts the shell changes.
22
- export function mappedExecutor(Base, environment, distribution = '', executable = '') {
23
- const explicit = typeof executable === 'string' && executable !== '';
24
- return class MappedShellExecutor extends Base {
25
- async execute(spec) {
26
- assertExecutionPolicy(environment, spec.sandboxPolicy);
27
- if (spec.sandboxPolicy.mode !== 'danger-full-access') return super.execute(spec);
28
- const process = await super.executeArgv(spec, argvOf(environment, spec, distribution, executable));
29
- return Base.decorateResult(process, result => ({
30
- ...result, sandbox: { mode: spec.sandboxPolicy.mode, denied: false },
31
- }));
32
- }
33
-
34
- // Current sandboxes enter through run/start. Confined calls use confine, so the chosen
35
- // binary stays inside the official sandbox. Full access keeps the same denial stamp as before.
36
- async run(spec) {
37
- if (!explicit || typeof super.run !== 'function') return super.run?.call(this, spec) ?? this.execute(spec);
38
- assertExecutionPolicy(environment, spec.sandboxPolicy);
39
- if (spec.sandboxPolicy?.mode !== 'danger-full-access') return super.run(spec);
40
- if (typeof super.runArgv !== 'function') return this.execute(spec);
41
- const result = await super.runArgv(spec, argvOf(environment, spec, distribution, executable));
42
- return { ...result, sandbox: { mode: spec.sandboxPolicy.mode, denied: false } };
43
- }
44
-
45
- start(spec) {
46
- if (!explicit || typeof super.start !== 'function') return super.start?.call(this, spec);
47
- assertExecutionPolicy(environment, spec.sandboxPolicy);
48
- if (spec.sandboxPolicy?.mode !== 'danger-full-access') return super.start(spec);
49
- if (typeof this.startArgv !== 'function') return super.start(spec);
50
- return this.startArgv(spec, argvOf(environment, spec, distribution, executable));
51
- }
52
-
53
- confine(command, policy, signal) {
54
- assertExecutionPolicy(environment, policy);
55
- return this.ctx.sandbox.confine(argvOf(environment,
56
- { command, workdir: policy.workspaceRoot }, distribution, executable), policy, signal);
57
- }
58
- };
59
- }
60
-
61
16
  export async function apply(ctx, config) {
62
17
  const Base = pluginOf(await importHost(config.base));
63
- if (typeof Base !== 'function' || typeof Base.decorateResult !== 'function' || typeof Base.prototype.executeArgv !== 'function')
18
+ if (!extensible(Base))
64
19
  throw new Error(`${config.base} no longer exposes the executor API Deep PTC extends; choose PowerShell or native Bash`);
65
20
  ctx.plugin(mappedExecutor(Base, config.environment, config.wslDistribution, config.shellExecutable), config.options);
66
21
  }
package/lib/index.mjs CHANGED
@@ -4,6 +4,7 @@ import { spawnSync } from 'node:child_process';
4
4
  import { existsSync, readFileSync, statSync } from 'node:fs';
5
5
  import { fileURLToPath } from 'node:url';
6
6
  import { CREATIVE_PRESET_ID } from './creative.mjs';
7
+ import { extensible } from './mapped-shell.mjs';
7
8
  import { normalizePreferences } from './tool-policy.mjs';
8
9
  import { availableEnvironments, BASE_SNAPSHOT, DEFAULT_FOREGROUND_SECONDS, deriveDeepPtc, normalizeDistribution, resolveEnvironment } from './model.mjs';
9
10
  import { discoverShells, resolveShellExecutable, resolveWindowsBash, shellNote } from './shells.mjs';
@@ -102,8 +103,7 @@ function officialExecutors(ctx) {
102
103
  async function canExtend(ctx, executor) {
103
104
  try {
104
105
  const Base = pluginOf(await importHost(executor.name));
105
- if (typeof Base === 'function' && typeof Base.decorateResult === 'function'
106
- && typeof Base.prototype.executeArgv === 'function') return true;
106
+ if (extensible(Base)) return true;
107
107
  ctx.logger.warn('Deep PTC: %s no longer exposes the executor API WSL/Zsh extend', executor.name);
108
108
  } catch (error) {
109
109
  ctx.logger.warn('Deep PTC: cannot load %s (%s)', executor.name, error.message);
@@ -0,0 +1,39 @@
1
+ // The WSL/Zsh/Bash shell as a subclass of the official bash executor. This module has no host
2
+ // dependency, so the class is testable against a stand-in base; executor.mjs mounts it.
3
+ import { assertExecutionPolicy, shellArgv } from './model.mjs';
4
+
5
+ function argvOf(environment, spec, distribution, executable) {
6
+ return shellArgv(environment, spec, distribution, process.platform, executable);
7
+ }
8
+
9
+ /** The executor surface this module extends; an installation without it keeps the official shell rows. */
10
+ export function extensible(Base) {
11
+ return typeof Base === 'function' && typeof Base.decorateResult === 'function'
12
+ && typeof Base.prototype?.executeArgv === 'function';
13
+ }
14
+
15
+ // Extend the official bash executor: its process handles, output retention, cancellation, jobs,
16
+ // sandbox and Config stay official; only the argv that starts the shell changes. The class adds no
17
+ // method the official executor lacks, so the host sees the surface it expects.
18
+ export function mappedExecutor(Base, environment, distribution = '', executable = '') {
19
+ return class MappedShellExecutor extends Base {
20
+ // The single entry point of the official executor. Full access starts the chosen shell directly
21
+ // and stamps the result as the official executor would; a confined call takes the official path,
22
+ // which reaches confine() below.
23
+ async execute(spec) {
24
+ assertExecutionPolicy(environment, spec.sandboxPolicy);
25
+ if (spec.sandboxPolicy.mode !== 'danger-full-access') return super.execute(spec);
26
+ const handle = await super.executeArgv(spec, argvOf(environment, spec, distribution, executable));
27
+ return Base.decorateResult(handle, result => ({
28
+ ...result, sandbox: { mode: spec.sandboxPolicy.mode, denied: false },
29
+ }));
30
+ }
31
+
32
+ // The chosen shell stays inside the official sandbox.
33
+ confine(command, policy, signal) {
34
+ assertExecutionPolicy(environment, policy);
35
+ return this.ctx.sandbox.confine(argvOf(environment,
36
+ { command, workdir: policy.workspaceRoot }, distribution, executable), policy, signal);
37
+ }
38
+ };
39
+ }