paseo-dsh 0.2.20 → 0.2.22

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/index.client.tsx CHANGED
@@ -1,15 +1,53 @@
1
1
  import type { PluginClientContext } from "@getpaseo/plugin/client";
2
+ import { guardCleanup, report } from "./client/guard";
3
+ import { DshPluginsPage } from "./client/dsh-plugins-page";
4
+ import { persistentLabel } from "./client/labels";
2
5
  import { contributeStreamStats } from "./client/stream-stats";
3
6
  import { contributeTimelineSettings } from "./client/settings-screen";
4
7
  import { contributeTimeline } from "./client/timeline";
5
8
 
6
- export default function contribute(client: PluginClientContext) {
9
+ /**
10
+ * The icon travels as inline SVG rather than a Lucide name: the app ships a
11
+ * pruned icon set, and a name it does not know is rejected while the host
12
+ * registers the sidebar row.
13
+ */
14
+ const PLUGIN_ICON = {
15
+ svg: '<svg xmlns="http://www.w3.org/2000/svg" viewBox="0 0 24 24" fill="none" stroke="currentColor" stroke-width="2" stroke-linecap="round" stroke-linejoin="round"><rect width="7" height="7" x="14" y="3" rx="1"/><path d="M10 21V8a1 1 0 0 0-1-1H4a1 1 0 0 0-1 1v12a1 1 0 0 0 1 1h12a1 1 0 0 0 1-1v-5a1 1 0 0 0-1-1H3"/></svg>',
16
+ };
17
+
18
+ function buildContributions(client: PluginClientContext) {
19
+ const title = persistentLabel("plugins.page.title");
7
20
  const cleanups = [
8
- contributeStreamStats(client),
9
- contributeTimeline(client),
10
- contributeTimelineSettings(client),
21
+ guardCleanup("stream stats", () => contributeStreamStats(client)),
22
+ guardCleanup("timeline", () => contributeTimeline(client)),
23
+ guardCleanup("timeline settings", () => contributeTimelineSettings(client)),
24
+ guardCleanup("plugins screen", () => client.addScreen({
25
+ id: "dsh-plugins",
26
+ title,
27
+ Component: DshPluginsPage,
28
+ })),
29
+ guardCleanup("plugins sidebar", () => client.addSidebarItem({
30
+ id: "dsh-plugins",
31
+ title,
32
+ icon: PLUGIN_ICON,
33
+ surface: "dsh-plugins",
34
+ })),
11
35
  ];
12
36
  return () => {
13
37
  for (const cleanup of cleanups) cleanup();
14
38
  };
15
39
  }
40
+
41
+ /**
42
+ * Nothing this entry point does may reach the host as an exception: release
43
+ * Hermes reports an uncaught plugin error as fatal and closes the whole app,
44
+ * including for users who never opened a DSH screen.
45
+ */
46
+ export default function contribute(client: PluginClientContext) {
47
+ try {
48
+ return buildContributions(client);
49
+ } catch (error) {
50
+ report("plugin client entry", error);
51
+ return () => {};
52
+ }
53
+ }
package/index.server.ts CHANGED
@@ -4,6 +4,8 @@ import type { PluginServerContext } from "@getpaseo/plugin/server";
4
4
  import { imagePreviewRpc } from "./shared/image-preview";
5
5
  import { timelineStyleSettings } from "./shared/settings";
6
6
  import { ensurePaseoProfile } from "./server/bootstrap";
7
+ import { DshPlugins } from "./server/dsh-plugins";
8
+ import { registerDshPluginsRpc } from "./server/dsh-plugins-rpc";
7
9
  import { createDshProvider } from "./server/provider";
8
10
 
9
11
  /**
@@ -14,6 +16,9 @@ import { createDshProvider } from "./server/provider";
14
16
  * bundle it carries (see server/bootstrap.ts). Provisioning is best-effort —
15
17
  * a filesystem failure is logged and the provider still registers, so the
16
18
  * failure surfaces as an honest error when a session tries to start `dsh`.
19
+ *
20
+ * The DSH Plugins page is registered even when provisioning fails: it opens on
21
+ * the profile path and shows the real error, instead of disappearing.
17
22
  */
18
23
  const MAX_IMAGE_BYTES = 12 * 1024 * 1024;
19
24
  const HARD_MAX_IMAGE_BYTES = 64 * 1024 * 1024;
@@ -45,17 +50,28 @@ export default function contribute(server: PluginServerContext) {
45
50
 
46
51
  server.registerSettings(timelineStyleSettings);
47
52
  server.handle(imagePreviewRpc, async (input) => {
48
- const empty = { dataUri: null, mime: null, error: null, bytes: null, limit: MAX_IMAGE_BYTES, tooLarge: false };
53
+ // The daemon answers with a code, never a sentence: the app picks the
54
+ // language, and `errorDetail` carries the raw reason the operating system
55
+ // gave so a real failure is still readable.
56
+ const empty = {
57
+ dataUri: null,
58
+ mime: null,
59
+ errorCode: null,
60
+ errorDetail: null,
61
+ bytes: null,
62
+ limit: MAX_IMAGE_BYTES,
63
+ tooLarge: false,
64
+ } as const;
49
65
  const absolute = isAbsolute(input.path) ? input.path : resolve(input.cwd || process.cwd(), input.path);
50
66
  const mime = IMAGE_MIME[extname(absolute).toLowerCase()];
51
67
  if (mime === undefined) {
52
- return { ...empty, error: "不支持的图片格式" };
68
+ return { ...empty, errorCode: "unsupported-format" as const };
53
69
  }
54
70
  try {
55
71
  const entry = await stat(absolute);
56
- if (!entry.isFile()) return { ...empty, mime, error: "不是文件" };
72
+ if (!entry.isFile()) return { ...empty, mime, errorCode: "not-file" as const };
57
73
  if (entry.size > HARD_MAX_IMAGE_BYTES) {
58
- return { ...empty, mime, bytes: entry.size, error: "图片超过 64MB 硬上限,无法预览" };
74
+ return { ...empty, mime, bytes: entry.size, errorCode: "too-large-hard" as const };
59
75
  }
60
76
  if (entry.size > MAX_IMAGE_BYTES && input.allowLarge !== true) {
61
77
  return {
@@ -63,7 +79,7 @@ export default function contribute(server: PluginServerContext) {
63
79
  mime,
64
80
  bytes: entry.size,
65
81
  tooLarge: true,
66
- error: `图片较大(${(entry.size / 1024 / 1024).toFixed(1)}MB,超过 12MB 预览上限)`,
82
+ errorCode: "too-large" as const,
67
83
  };
68
84
  }
69
85
  const bytes = await readFile(absolute);
@@ -77,10 +93,17 @@ export default function contribute(server: PluginServerContext) {
77
93
  return {
78
94
  ...empty,
79
95
  mime,
80
- error: error instanceof Error ? error.message : String(error),
96
+ errorCode: "unreadable" as const,
97
+ errorDetail: error instanceof Error ? error.message : String(error),
81
98
  };
82
99
  }
83
100
  });
101
+
102
+ const manager = new DshPlugins();
103
+ const disposePlugins = registerDshPluginsRpc(server, manager);
84
104
  server.registerProvider(createDshProvider());
85
- return () => {};
105
+
106
+ return () => {
107
+ disposePlugins();
108
+ };
86
109
  }
package/package.json CHANGED
@@ -1,7 +1,7 @@
1
1
  {
2
2
  "name": "paseo-dsh",
3
- "version": "0.2.20",
4
- "description": "DeepSeek Harness (dsh) as a native Paseo provider: question cards, plan mode, thinking levels, steering, images and a real slash menu. 把 DeepSeek Harness 接成 Paseo 原生 provider。",
3
+ "version": "0.2.22",
4
+ "description": "DeepSeek Harness (dsh) as a native Paseo provider: question cards, plan mode, thinking levels, steering, images, a slash menu, permissions and presets.",
5
5
  "keywords": [
6
6
  "paseo",
7
7
  "paseo-plugin",
@@ -32,6 +32,7 @@
32
32
  "icon.svg",
33
33
  "README.md",
34
34
  "OVERVIEW.md",
35
+ "OVERVIEW.zh-CN.md",
35
36
  "LICENSE",
36
37
  "THIRD-PARTY-NOTICES.md",
37
38
  "index.client.tsx",
@@ -39,13 +40,14 @@
39
40
  ],
40
41
  "scripts": {
41
42
  "generate": "node scripts/generate-bridge-assets.mjs",
42
- "prepack": "node scripts/generate-bridge-assets.mjs",
43
+ "prepack": "node scripts/generate-bridge-assets.mjs && node scripts/check-locales.mjs",
43
44
  "typecheck": "tsc --noEmit",
44
45
  "test:process": "node --test test/process.test.cjs",
45
- "test": "node --test test/*.test.cjs"
46
+ "test": "node --test test/*.test.cjs && node scripts/check-locales.mjs",
47
+ "check:locales": "node scripts/check-locales.mjs"
46
48
  },
47
49
  "peerDependencies": {
48
- "@getpaseo/plugin": ">=0.9.2"
50
+ "@getpaseo/plugin": ">=0.16.0"
49
51
  },
50
52
  "peerDependenciesMeta": {
51
53
  "@getpaseo/plugin": {
@@ -53,7 +55,7 @@
53
55
  }
54
56
  },
55
57
  "devDependencies": {
56
- "@getpaseo/plugin": "0.9.2",
58
+ "@getpaseo/plugin": "^0.16.0",
57
59
  "@types/node": "^22.10.2",
58
60
  "@types/react": "^19.3.0",
59
61
  "typescript": "^5.9.3",
package/paseo-plugin.json CHANGED
@@ -1,7 +1,13 @@
1
1
  {
2
2
  "id": "dsh-paseo",
3
- "description": "DeepSeek Harness (dsh) as a native Paseo provider: question cards, plan mode, thinking levels, steering, images, a slash menu, permissions and presets. 把 DeepSeek Harness 接成 Paseo 原生 provider:提问卡片、计划模式、思考档位、插话、图片、斜杠菜单、权限与预设。",
3
+ "name": "DeepSeek Harness",
4
+ "description": "DeepSeek Harness (dsh) as a native Paseo provider: question cards, plan mode, thinking levels, steering, images, a slash menu, permissions and presets.",
5
+ "translations": {
6
+ "zh-CN": {
7
+ "description": "把 DeepSeek Harness(dsh)接成 Paseo 原生 provider:提问卡片、计划模式、思考档位、插话、图片、斜杠菜单、权限与预设。"
8
+ }
9
+ },
4
10
  "requirements": {
5
- "paseo": ">=0.9.2"
11
+ "paseo": ">=0.16.0"
6
12
  }
7
13
  }
@@ -36,10 +36,16 @@ export function profileName(): string {
36
36
  return process.env.DSH_PASEO_PROFILE ?? "paseo";
37
37
  }
38
38
 
39
- function dshHome(): string {
39
+ /** Root that holds every DSH profile; `DSH_HOME` overrides `~/.dsh`. */
40
+ export function dshHomeDir(): string {
40
41
  return process.env.DSH_HOME ?? join(homedir(), ".dsh");
41
42
  }
42
43
 
44
+ /** Directory of one profile, without creating or reading it. */
45
+ export function profileDir(profile: string = profileName(), home: string = dshHomeDir()): string {
46
+ return join(home, "profiles", profile);
47
+ }
48
+
43
49
  function profilePackageJson(profile: string): string {
44
50
  return `${JSON.stringify(
45
51
  {
@@ -74,7 +80,7 @@ export interface ProvisionResult {
74
80
  */
75
81
  export function ensurePaseoProfile(): ProvisionResult {
76
82
  const profile = profileName();
77
- const dir = join(dshHome(), "profiles", profile);
83
+ const dir = profileDir(profile);
78
84
  mkdirSync(join(dir, "node_modules"), { recursive: true });
79
85
 
80
86
  // The profile's own files belong to the user: create a missing one, but never