dsh-xdpool 2.6.5 → 2.6.6

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/package.json CHANGED
@@ -2,7 +2,7 @@
2
2
  "name": "dsh-xdpool",
3
3
  "displayName": "DSH XD Pool",
4
4
  "description": "One DSH model pool for every free quota you have: merge all locally signed-in WorkBuddy accounts with auto-failover, sign in to 13 vendors by QR/web, aggregate 76 vendors' free tiers, plus a usage dashboard, model routing, a local OpenAI-compatible gateway and a points-automation suite.",
5
- "version": "2.6.5",
5
+ "version": "2.6.6",
6
6
  "license": "MIT",
7
7
  "author": "XDTrees",
8
8
  "homepage": "https://github.com/XDTrees/dsh-xdpool#readme",
@@ -133,4 +133,4 @@
133
133
  "optional": true
134
134
  }
135
135
  }
136
- }
136
+ }
@@ -72,6 +72,32 @@ function resolvesFromEntry(name) {
72
72
  }
73
73
  }
74
74
 
75
+ /** The installed version of a package directory, or undefined when unreadable. */
76
+ function versionOf(dir) {
77
+ try {
78
+ const manifest = JSON.parse(readFileSync(join(dir, 'package.json'), 'utf8'))
79
+ return typeof manifest.version === 'string' ? manifest.version : undefined
80
+ } catch {
81
+ return undefined
82
+ }
83
+ }
84
+
85
+ /**
86
+ * The host's copy of a peer, if one can be found.
87
+ *
88
+ * Separate from `locate` because the two answer different questions: `locate` asks "is this
89
+ * importable", `hostCopyOf` asks "where is the host's own copy". The second is needed to
90
+ * detect a version MISMATCH, which is a failure mode `locate` cannot see — the package
91
+ * resolves perfectly well at the wrong generation.
92
+ */
93
+ function hostCopyOf(name) {
94
+ for (const root of hostRoots()) {
95
+ const candidate = join(root, name)
96
+ if (existsSync(join(candidate, 'package.json'))) return candidate
97
+ }
98
+ return undefined
99
+ }
100
+
75
101
  /**
76
102
  * The package directory for `name`, whether or not it can be imported right now.
77
103
  *
@@ -160,13 +186,65 @@ const HARNESS_BASES = [
160
186
  // Linux
161
187
  join(process.env['HOME'] ?? '', '.local', 'share', 'deepseek-harness'),
162
188
  '/opt/DeepSeek Harness',
163
- // Windows
189
+ // Windows, default locations
164
190
  typeof process.env['LOCALAPPDATA'] === 'string' ? join(process.env['LOCALAPPDATA'], 'Programs', 'DeepSeek Harness') : undefined,
165
191
  typeof process.env['LOCALAPPDATA'] === 'string' ? join(process.env['LOCALAPPDATA'], 'DeepSeek Harness') : undefined,
166
192
  typeof process.env['ProgramW6432'] === 'string' ? process.env['ProgramW6432'] : undefined,
167
193
  typeof process.env['PROGRAMFILES'] === 'string' ? process.env['PROGRAMFILES'] : undefined,
194
+ /**
195
+ * Windows, installed on another drive.
196
+ *
197
+ * Not a guess about this particular machine: it is derived from where the PROFILE lives.
198
+ * A DSH profile sits at `<harness data dir>/profiles/<name>`, and on Windows the data
199
+ * directory is often the harness's own folder — which is exactly the layout this repo
200
+ * was developed against (`D:\dsh-home\profiles\desktop` beside `D:\DeepSeek Harness`).
201
+ * When they are siblings, the harness is one segment up with a different name, so the
202
+ * sibling of the data dir is tried as a harness root too.
203
+ *
204
+ * A miss costs nothing, which is why deriving is preferable to hard-coding a drive letter.
205
+ */
206
+ ...siblingHarnessBases(),
168
207
  ]
169
208
 
209
+ /**
210
+ * Harness roots that can be derived from where this profile lives.
211
+ *
212
+ * `D:\dsh-home\profiles\desktop\node_modules\dsh-xdpool` → walk up to the data directory,
213
+ * then try every plausible sibling. Cheap, and it is the only way to find a harness on a
214
+ * non-default drive without asking the user to set an environment variable.
215
+ *
216
+ * Several levels are tried because the two layouts in the wild differ:
217
+ *
218
+ * - `<dataDir>/profiles/<name>` — the data dir's PARENT holds the harness
219
+ * (`D:\dsh-home` beside `D:\DeepSeek Harness`)
220
+ * - the harness IS the data dir's parent — some installs put profiles inside the app
221
+ *
222
+ * A miss costs nothing, which is why deriving beats hard-coding a drive letter.
223
+ */
224
+ function siblingHarnessBases() {
225
+ const out = []
226
+ let dir = PACKAGE_ROOT
227
+ let dataDir
228
+ for (let i = 0; i < 8; i += 1) {
229
+ dir = dirname(dir)
230
+ if (dir === dirname(dir)) break
231
+ // `<x>/profiles/...` means `<x>` is the data directory.
232
+ if (dirname(dir).endsWith('profiles')) { dataDir = dirname(dir); break }
233
+ if (dir.endsWith('profiles')) { dataDir = dirname(dir); break }
234
+ }
235
+ const start = dataDir ?? resolve(PACKAGE_ROOT, '..', '..', '..')
236
+ // Walk up a few levels from the data directory, offering a sibling at each.
237
+ let cursor = start
238
+ for (let i = 0; i < 3; i += 1) {
239
+ out.push(join(cursor, 'DeepSeek Harness'))
240
+ const parent = dirname(cursor)
241
+ if (parent === cursor) break
242
+ out.push(join(parent, 'DeepSeek Harness'))
243
+ cursor = parent
244
+ }
245
+ return out
246
+ }
247
+
170
248
  /** Whether this is a source checkout rather than an installed package. */
171
249
  const IS_SOURCE_CHECKOUT = existsSync(join(PACKAGE_ROOT, 'src'))
172
250
 
@@ -176,16 +254,36 @@ const notFound = []
176
254
  const failed = []
177
255
 
178
256
  for (const name of peerNames()) {
179
- // Already resolvable: leave it alone. Someone who installed a peer deliberately keeps
180
- // control, and re-linking would overwrite that choice. This check is also what makes the
181
- // script idempotent — a second run must not rebuild links it made the first time.
182
- if (locate(name) !== undefined) { alreadyResolved.push(name); continue }
183
- let target
184
- for (const root of hostRoots()) {
185
- const candidate = join(root, name)
186
- // `existsSync` cannot see inside `app.asar`; on a packaged host this simply misses and
187
- // the peer is reported as not found, which is no longer fatal.
188
- if (existsSync(join(candidate, 'package.json'))) { target = candidate; break }
257
+ /**
258
+ * A peer that resolves is only acceptable if its VERSION matches the host's.
259
+ *
260
+ * Resolvability alone is not the contract that matters. `@earendil-works/pi-ai` shipped
261
+ * from a `devDependency` at 0.85.1 while the host ran 1.1.0, and the plugin's own
262
+ * `warnOnPiAiGenerationMismatch` documents the result: two copies on one call chain throw
263
+ * at the adapter seam and the host reports every turn as a non-retryable `PI_AI_ERROR`.
264
+ * The package resolved fine — at the wrong generation.
265
+ *
266
+ * So when the host has a copy and ours differs, the host's copy WINS. That is the whole
267
+ * point of treating these as peer dependencies: the host owns them, and a second
268
+ * generation beside it is a defect rather than a choice.
269
+ */
270
+ const current = locate(name)
271
+ const hostCopy = hostCopyOf(name)
272
+ const hostVersion = hostCopy === undefined ? undefined : versionOf(hostCopy)
273
+ const ours = current === undefined ? undefined : versionOf(current)
274
+ if (current !== undefined && (hostVersion === undefined || ours === hostVersion)) {
275
+ alreadyResolved.push(name)
276
+ continue
277
+ }
278
+ // A mismatch is reported below through `relinked` when the host copy is linked.
279
+ let target = hostCopy
280
+ if (target === undefined) {
281
+ for (const root of hostRoots()) {
282
+ const candidate = join(root, name)
283
+ // `existsSync` cannot see inside `app.asar`; on a packaged host this simply misses and
284
+ // the peer is reported as not found, which is no longer fatal.
285
+ if (existsSync(join(candidate, 'package.json'))) { target = candidate; break }
286
+ }
189
287
  }
190
288
  if (target === undefined) { notFound.push(name); continue }
191
289
  const dest = join(PACKAGE_ROOT, 'node_modules', name)
@@ -197,7 +295,7 @@ for (const name of peerNames()) {
197
295
  // Junction on Windows because creating a real symlink needs elevation there; a
198
296
  // junction needs none and behaves the same for directory reads.
199
297
  symlinkSync(target, dest, process.platform === 'win32' ? 'junction' : 'dir')
200
- linked.push(`${name} → ${target}`)
298
+ linked.push(`${name} → ${target}${ours === undefined ? '' : ` (was ${ours}, host has ${hostVersion ?? '?'})`}`)
201
299
  } catch (error) {
202
300
  failed.push(`${name} (${error instanceof Error ? error.message : String(error)})`)
203
301
  }