dsh-diff-approval 0.37.3 → 0.37.4

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/index.js CHANGED
@@ -3,10 +3,64 @@ import { mkdir, readFile, readdir, rename, rm, stat, writeFile } from "node:fs/p
3
3
  import { basename, dirname, isAbsolute, join, relative, resolve, sep } from "node:path";
4
4
  import { randomUUID } from "node:crypto";
5
5
  import { fileURLToPath } from "node:url";
6
- import { dshHomePath, expandHomePath } from "@deepseek-ai/dsh-home-paths";
6
+ import { homedir } from "node:os";
7
7
  import "@deepseek-ai/cordis";
8
8
  import { spawn } from "node:child_process";
9
9
  import { existsSync, realpathSync } from "node:fs";
10
+ //#region lib/types/home-paths.js
11
+ /**
12
+ * The harness-home path helpers this plugin needs, kept LOCAL on purpose.
13
+ *
14
+ * They used to be imported from `@deepseek-ai/dsh-home-paths`, but that package is part of the HOST core, not a
15
+ * library a plugin may ship: declaring it in `dependencies` makes pnpm hoist a second copy into the profile's
16
+ * top-level `node_modules`, where the host's own row can resolve it instead of its matching copy — the host's
17
+ * version gate then disables that row and every service injecting it (issue #10). These two helpers are a few
18
+ * lines with a stable contract, so owning them here removes the shadowing risk entirely.
19
+ *
20
+ * Semantics mirror the host package (v0.1.0-rc):
21
+ * - the harness home is an explicit configured path, else a NON-EMPTY `$DSH_HOME`, else `~/.dsh`;
22
+ * - `~`, `~/…` and `~\…` expand against the operating-system home; any other path is returned untouched;
23
+ * - the result is normalized to an absolute path before joining.
24
+ *
25
+ * @module dsh-diff-approval/src/home-paths
26
+ */
27
+ /** Directory name used for the default harness home under the OS home. */
28
+ const DSH_HOME_DIR_NAME = ".dsh";
29
+ /** Environment variable that overrides the default harness home. */
30
+ const DSH_HOME_ENV = "DSH_HOME";
31
+ /**
32
+ * Expand the supported tilde prefixes against the operating-system home.
33
+ * @param path - a configured path that may begin with `~`, `~/`, or `~\`.
34
+ * @returns the expanded path, or the original value when no supported prefix is present.
35
+ */
36
+ function expandHomePath(path) {
37
+ if (path === "~") return homedir();
38
+ if (path.startsWith("~/") || path.startsWith("~\\")) return join(homedir(), path.slice(2));
39
+ return path;
40
+ }
41
+ /**
42
+ * Resolve the single-root harness home.
43
+ *
44
+ * Precedence, highest first: an explicit configured path, a non-empty `$DSH_HOME`, then `~/.dsh`. A blank or
45
+ * whitespace-only `$DSH_HOME` is treated as unset, so it can never resolve the home to the current directory.
46
+ * @param configured - explicit harness-home override with the highest precedence.
47
+ * @param env - environment mapping used to read `$DSH_HOME` (test seam; defaults to the process environment).
48
+ * @returns the normalized absolute harness home path.
49
+ */
50
+ function resolveDshHome(configured, env = process.env) {
51
+ const fromEnv = env[DSH_HOME_ENV];
52
+ const candidate = configured ?? (fromEnv !== void 0 && fromEnv.trim().length > 0 ? fromEnv : join(homedir(), DSH_HOME_DIR_NAME));
53
+ return resolve(expandHomePath(candidate));
54
+ }
55
+ /**
56
+ * Join path segments onto the resolved harness home.
57
+ * @param segments - path segments appended to the harness home; an empty list returns the home itself.
58
+ * @returns the normalized absolute joined path.
59
+ */
60
+ function dshHomePath(...segments) {
61
+ return join(resolveDshHome(), ...segments);
62
+ }
63
+ //#endregion
10
64
  //#region node_modules/.pnpm/@deepseek-ai+cosmokit@1.8.2/node_modules/@deepseek-ai/cosmokit/lib/index.js
11
65
  /** Return true when a value is `null` or `undefined`. */
12
66
  function isNullable(value) {
@@ -0,0 +1,38 @@
1
+ /**
2
+ * The harness-home path helpers this plugin needs, kept LOCAL on purpose.
3
+ *
4
+ * They used to be imported from `@deepseek-ai/dsh-home-paths`, but that package is part of the HOST core, not a
5
+ * library a plugin may ship: declaring it in `dependencies` makes pnpm hoist a second copy into the profile's
6
+ * top-level `node_modules`, where the host's own row can resolve it instead of its matching copy — the host's
7
+ * version gate then disables that row and every service injecting it (issue #10). These two helpers are a few
8
+ * lines with a stable contract, so owning them here removes the shadowing risk entirely.
9
+ *
10
+ * Semantics mirror the host package (v0.1.0-rc):
11
+ * - the harness home is an explicit configured path, else a NON-EMPTY `$DSH_HOME`, else `~/.dsh`;
12
+ * - `~`, `~/…` and `~\…` expand against the operating-system home; any other path is returned untouched;
13
+ * - the result is normalized to an absolute path before joining.
14
+ *
15
+ * @module dsh-diff-approval/src/home-paths
16
+ */
17
+ /**
18
+ * Expand the supported tilde prefixes against the operating-system home.
19
+ * @param path - a configured path that may begin with `~`, `~/`, or `~\`.
20
+ * @returns the expanded path, or the original value when no supported prefix is present.
21
+ */
22
+ export declare function expandHomePath(path: string): string;
23
+ /**
24
+ * Resolve the single-root harness home.
25
+ *
26
+ * Precedence, highest first: an explicit configured path, a non-empty `$DSH_HOME`, then `~/.dsh`. A blank or
27
+ * whitespace-only `$DSH_HOME` is treated as unset, so it can never resolve the home to the current directory.
28
+ * @param configured - explicit harness-home override with the highest precedence.
29
+ * @param env - environment mapping used to read `$DSH_HOME` (test seam; defaults to the process environment).
30
+ * @returns the normalized absolute harness home path.
31
+ */
32
+ export declare function resolveDshHome(configured?: string, env?: NodeJS.ProcessEnv): string;
33
+ /**
34
+ * Join path segments onto the resolved harness home.
35
+ * @param segments - path segments appended to the harness home; an empty list returns the home itself.
36
+ * @returns the normalized absolute joined path.
37
+ */
38
+ export declare function dshHomePath(...segments: string[]): string;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-diff-approval",
3
- "version": "0.37.3",
3
+ "version": "0.37.4",
4
4
  "description": "DeepSeek Harness plugin: pending-edit review with whole-file diff and Keep/Revert",
5
5
  "packageManager": "pnpm@11.21.0",
6
6
  "author": "Wu Zhiwei",
@@ -70,7 +70,6 @@
70
70
  },
71
71
  "license": "MIT",
72
72
  "dependencies": {
73
- "@deepseek-ai/dsh-home-paths": "^0.1.0-rc.5",
74
73
  "@shikijs/langs": "^4.4.3",
75
74
  "diff": "^9.0.0",
76
75
  "dompurify": "^3.4.15",