@deepseek-insight/dsi 0.6.0 → 0.6.1

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 (30) hide show
  1. package/bin/dsi.mjs +48 -2
  2. package/bin/lib/plugin-chain.mjs +27 -3
  3. package/build/client/_app/immutable/assets/{2.DLFRZPDf.css → 2.DEBHmc3y.css} +1 -1
  4. package/build/client/_app/immutable/chunks/{DZixYQAd.js → BVBc9rJx.js} +2 -2
  5. package/build/client/_app/immutable/chunks/BdHmBwz-.js +1 -0
  6. package/build/client/_app/immutable/chunks/{DzZu8EY2.js → DNY2-FaC.js} +1 -1
  7. package/build/client/_app/immutable/chunks/oLHjdJ-M.js +1 -0
  8. package/build/client/_app/immutable/entry/{app.Toc7d2RT.js → app.C1j_PXOJ.js} +2 -2
  9. package/build/client/_app/immutable/entry/start.Dyarj9we.js +1 -0
  10. package/build/client/_app/immutable/nodes/{1.BMemLSP2.js → 1.DB7DKw94.js} +1 -1
  11. package/build/client/_app/immutable/nodes/{2.BDUOgoKA.js → 2.D9qSqOKy.js} +192 -192
  12. package/build/client/_app/version.json +1 -1
  13. package/build/handler.js +4 -4
  14. package/build/index.js +4 -4
  15. package/build/server/chunks/chunks/{internal.js-Dhppl8VW.js → internal.js-Ca_6TJ1k.js} +2 -2
  16. package/build/server/chunks/chunks/{state.js--QbGDz9E.js → state.js-BrbF5k84.js} +2 -2
  17. package/build/server/chunks/entries/endpoints/api/plugins/apply/{_server.ts.js-BXwRN5sp.js → _server.ts.js-CpO--Jwf.js} +35 -10
  18. package/build/server/chunks/entries/pages/{_error.svelte.js-n2xOEPvp.js → _error.svelte.js-C9GhKb8G.js} +3 -3
  19. package/build/server/chunks/entries/pages/{_page.svelte.js-BJ7eKmkS.js → _page.svelte.js-6A1VYbL2.js} +3 -71
  20. package/build/server/chunks/{handler-BJHxQwK-.js → handler-ChXGVK9Y.js} +3 -3
  21. package/build/server/chunks/{index.js-BXPH1Bno.js → index.js-5P_bGLRx.js} +2 -2
  22. package/build/server/chunks/{manifest.js-DjQqMW2U.js → manifest.js-B3ooI-FL.js} +5 -5
  23. package/build/server/chunks/nodes/1.js-Dcb4_Gzq.js +9 -0
  24. package/build/server/chunks/nodes/{2.js-BnWybqO0.js → 2.js-C4WQL8rj.js} +4 -4
  25. package/package.json +1 -1
  26. package/template/.dsi/resources/plugins-reff.md +2 -1
  27. package/build/client/_app/immutable/chunks/BZW4nu4u.js +0 -1
  28. package/build/client/_app/immutable/chunks/CpgMZB3l.js +0 -1
  29. package/build/client/_app/immutable/entry/start.CCaKY2bM.js +0 -1
  30. package/build/server/chunks/nodes/1.js-Cb5I-Dtm.js +0 -9
package/bin/dsi.mjs CHANGED
@@ -226,8 +226,23 @@ if (command === 'dsh') {
226
226
  }
227
227
  }
228
228
  console.log('dsi dsh: bouncing the floor (orphan sweep + synced pair re-run)');
229
+ // Dev-floor detection must run BEFORE the sweep kills what it would
230
+ // detect (RCA 2026-09-27, second order): the DSI_DEV env marker only
231
+ // exists on floors launched by THIS CLI's dev launcher — a floor from
232
+ // before the marker existed, or from plain `pnpm dev`, carries none.
233
+ // The vite dev process itself is visible to pgrep (unlike the npx
234
+ // shims — different argv rewriting), so ask the process table.
235
+ const dev = bounceDevMode(parsed.dev === true, isDevFloorAlive);
229
236
  killOrphans();
230
- runSyncedPair([]);
237
+ // The pkill sweep cannot see every floor shape (RCA 2026-09-27: the
238
+ // npx shims — 'npm exec @deepseek-ai/dsh…' and '.bin/dsh web' — are
239
+ // invisible to pkill -f on macOS, so the dsh host survived holding
240
+ // 3080 and preflightPort exited 64, killing the detached chain
241
+ // silently). The bounce chain owns the DSI ports by contract, so
242
+ // free them by listener, not by name.
243
+ freeFloorPorts([3080, 5174, 5175]);
244
+ // Restore the SAME UI mode the floor was serving.
245
+ runSyncedPair([], dev);
231
246
  } else if (flag === '--sync-kills') {
232
247
  killOrphans();
233
248
  process.exit(0);
@@ -397,6 +412,33 @@ function killOrphans() {
397
412
  console.log('dsi dsh: orphan sweep done (dsh-web-synced.sh, dsh bin, dsi server)');
398
413
  }
399
414
 
415
+ /** SIGTERM whatever LISTENS on these ports: the bounce chain's name-blind
416
+ * second sweep (RCA 2026-09-27). pkill -f cannot match every floor shape
417
+ * (the npx shim processes are invisible to it on macOS), so a surviving
418
+ * dsh host held 3080, preflightPort exited 64, and the detached chain died
419
+ * silently. Only the bounce uses this; a manual --sync preflight still
420
+ * REFUSES a busy port it does not own. */
421
+ function freeFloorPorts(ports) {
422
+ for (const port of ports) {
423
+ try {
424
+ spawnSync('/bin/sh', ['-c', 'lsof -ti tcp:' + port + ' -sTCP:LISTEN | xargs kill 2>/dev/null || true'], { stdio: 'pipe' });
425
+ } catch {
426
+ // no lsof (or no xargs): the pattern sweep above and the 5s
427
+ // preflight wait remain the honest fallbacks.
428
+ }
429
+ }
430
+ }
431
+
432
+ /** True when a vite dev server of THIS checkout is alive. Only the
433
+ * checkout's own vite matches — a foreign project's dev server never
434
+ * carries the deepseek-insight path segment. pgrep sees this process
435
+ * (it does not rewrite argv the way the npm/npx shims do), so the probe
436
+ * is reliable where the orphan sweep's name matching is not. */
437
+ function isDevFloorAlive() {
438
+ const probe = spawnSync('pgrep', ['-f', 'deepseek-insight/node_modules/vite/bin/vite.js'], { stdio: 'pipe' });
439
+ return (probe.status ?? 1) === 0;
440
+ }
441
+
400
442
  /** Add the ZAI provider and default model to ~/.dsh/settings.yaml when
401
443
  * absent. Existing entries always win — an already-configured host is
402
444
  * rewritten only when at least one block was added. Exits non-zero when
@@ -529,7 +571,11 @@ function startDsiDevServer(defaultPort = '5175') {
529
571
  env: {
530
572
  ...process.env,
531
573
  // Same first-start bootstrap seam as the built server.
532
- DSI_TEMPLATE_PATH: process.env.DSI_TEMPLATE_PATH ?? path.join(packageRoot, 'template', '.dsi')
574
+ DSI_TEMPLATE_PATH: process.env.DSI_TEMPLATE_PATH ?? path.join(packageRoot, 'template', '.dsi'),
575
+ // Dev-floor marker (RCA 2026-09-27): the plugin-rack bounce reads
576
+ // this from the API server's env to re-serve --dev instead of the
577
+ // stale build. Nothing else may set it.
578
+ DSI_DEV: '1'
533
579
  }
534
580
  });
535
581
  }
@@ -11,7 +11,7 @@
11
11
  *
12
12
  * @param {string[]} argv
13
13
  * @param {{ envProfile?: string }} [options]
14
- * @returns {null | { error: string } | { action: 'add' | 'remove' | 'restart', pkg: string, profile: string }}
14
+ * @returns {null | { error: string } | { action: 'add' | 'remove' | 'restart', pkg: string, profile: string, dev?: boolean }}
15
15
  * null = argv is not a --plugin invocation (the caller falls through to
16
16
  * its own unknown-flag error); { error } = a --plugin invocation with a
17
17
  * bad shape (usage exit 64).
@@ -22,8 +22,13 @@ export function parsePluginArgs(argv, options = {}) {
22
22
  if (flag !== '--plugin' && flag !== '--plugin-restart') return null;
23
23
  const rest = argv.slice(1);
24
24
  if (flag === '--plugin-restart') {
25
- if (rest.length !== 0) return { error: 'usage: dsi dsh --plugin-restart' };
26
- return { action: 'restart', pkg: '', profile: envProfile };
25
+ // --dev is the only accepted extra: the bounce must restore the SAME
26
+ // UI mode the floor was serving (RCA 2026-09-27 — a dev-mode floor
27
+ // bounced into build mode came back on 5174 while the browser sat on
28
+ // 5175's corpse; the UI mode rides the DSI_DEV env marker).
29
+ const dev = rest.includes('--dev');
30
+ if (rest.some((arg) => arg !== '--dev')) return { error: 'usage: dsi dsh --plugin-restart [--dev]' };
31
+ return { action: 'restart', pkg: '', profile: envProfile, dev };
27
32
  }
28
33
  const [action, pkg, ...tail] = rest;
29
34
  if (action !== 'add' && action !== 'remove') {
@@ -46,6 +51,25 @@ export function parsePluginArgs(argv, options = {}) {
46
51
  return { action, pkg, profile };
47
52
  }
48
53
 
54
+ /**
55
+ * The bounce's dev-mode decision (RCA 2026-09-27, second order): an explicit
56
+ * --dev flag wins, otherwise the chain asks whether a dev floor is alive.
57
+ * Pure: the process-table probe is injected so the real pgrep stays in
58
+ * dsi.mjs's impure half.
59
+ *
60
+ * @param {boolean} flagDev — the parsed `--plugin-restart --dev` flag
61
+ * @param {() => boolean} devFloorAlive — probe for a running vite dev server
62
+ * @returns {boolean}
63
+ */
64
+ export function bounceDevMode(flagDev, devFloorAlive) {
65
+ if (flagDev) return true;
66
+ try {
67
+ return devFloorAlive() === true;
68
+ } catch {
69
+ return false;
70
+ }
71
+ }
72
+
49
73
  /**
50
74
  * The dsh launcher rule (runOvPlugin's, generalized): DSH_WEB_CMD override,
51
75
  * else the pinned published dsh via npx. The webVersion pin comes from the