@zhangfengshun/dsh-remote-ssh 2.0.1 → 2.0.3

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.
Files changed (2) hide show
  1. package/lib/index.js +10 -9
  2. package/package.json +1 -1
package/lib/index.js CHANGED
@@ -12,13 +12,14 @@ import z from "schemastery";
12
12
  import { defineTool } from "@deepseek-ai/dsh-tools";
13
13
  import { settingsNamespace } from "@deepseek-ai/dsh-settings";
14
14
  import { mkdir, rm, writeFile, readFile, opendir, stat, open, rename, readdir } from "node:fs/promises";
15
+ import { existsSync, readFileSync } from "node:fs";
15
16
  import { homedir } from "node:os";
16
- import { join } from "node:path";
17
+ import { join, dirname } from "node:path";
17
18
 
18
19
  /** Plugin identity for cordis.yml rows. */
19
20
  const name = "@zhangfengshun/dsh-remote-ssh";
20
21
  /** Services required before mounting. */
21
- const inject = ["webServer", "subprocess", "tools", "sessions", "webRuntime"];
22
+ const inject = ["webServer", "subprocess", "tools"];
22
23
  /** Composition config schema(本插件暂无配置项)。 */
23
24
  const Config = z.object({});
24
25
 
@@ -1402,10 +1403,9 @@ function apply(ctx, config) {
1402
1403
  function readRemoteInfoSync(mirrorCwd) {
1403
1404
  if (!mirrorCwd) return null;
1404
1405
  try {
1405
- const fs2 = require("fs");
1406
- const jsonPath = require("path").join(mirrorCwd, ".remote-ssh.json");
1407
- if (fs2.existsSync(jsonPath)) {
1408
- return JSON.parse(fs2.readFileSync(jsonPath, "utf8"));
1406
+ const jsonPath = join(mirrorCwd, ".remote-ssh.json");
1407
+ if (existsSync(jsonPath)) {
1408
+ return JSON.parse(readFileSync(jsonPath, "utf8"));
1409
1409
  }
1410
1410
  } catch (e) {}
1411
1411
  return null;
@@ -1480,7 +1480,7 @@ function apply(ctx, config) {
1480
1480
  async function localWriteFile(path, content) {
1481
1481
  const tmp = path + ".dsh-rssh-tmp-" + process.pid;
1482
1482
  try {
1483
- await mkdir(require("path").dirname(path), { recursive: true });
1483
+ await mkdir(dirname(path), { recursive: true });
1484
1484
  await writeFile(tmp, content, "utf8");
1485
1485
  await rename(tmp, path);
1486
1486
  } catch (e) {
@@ -1560,8 +1560,9 @@ function apply(ctx, config) {
1560
1560
  // 获取会话 cwd
1561
1561
  const sessionId = payload && payload.sessionId;
1562
1562
  let sessionCwd = payload && payload.cwd;
1563
- if ((!sessionCwd || sessionCwd === "") && sessionId && ctx.sessions) {
1564
- const session = ctx.sessions.get(sessionId);
1563
+ if ((!sessionCwd || sessionCwd === "") && sessionId) {
1564
+ const sessions = ctx.get("sessions");
1565
+ const session = sessions ? sessions.get(sessionId) : null;
1565
1566
  sessionCwd = session && session.header && session.header.cwd;
1566
1567
  }
1567
1568
  // 如果 sessionCwd 还是空,尝试用 payload.path 的父目录(文件操作时 path 是文件路径)
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@zhangfengshun/dsh-remote-ssh",
3
- "version": "2.0.1",
3
+ "version": "2.0.3",
4
4
  "description": "DSH web plugin: VSCode Remote-SSH-like remote development (SSH to supercomputers/servers, remote workspace, file explorer, integrated terminal), integrated with dsh-better-sidebar and DSH settings.",
5
5
  "keywords": [
6
6
  "dsh",