dsh-tg-bridge 1.19.7 → 1.19.8

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/package.json +1 -1
  2. package/sync-runtime.mjs +27 -6
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "dsh-tg-bridge",
3
- "version": "1.19.7",
3
+ "version": "1.19.8",
4
4
  "description": "Telegram bridge for DeepSeek Harness: text, voice, photos and project-per-topic sessions without opening the desktop app",
5
5
  "type": "module",
6
6
  "main": "plugin-bridge.mjs",
package/sync-runtime.mjs CHANGED
@@ -22,15 +22,36 @@ const target = flag > -1 && process.argv[flag + 1]
22
22
  if (!existsSync(target)) mkdirSync(target, { recursive: true });
23
23
 
24
24
  const stamp = new Date().toISOString().replace(/[:.]/g, '').slice(0, 15);
25
- const names = readdirSync(here).filter((name) => name.endsWith('.mjs') || name === 'package.json');
25
+ // Copy what `package.json` says the package is made of, not just the root .mjs
26
+ // files: a module in a subdirectory (`i18n/en.mjs`) is imported by name, so a
27
+ // root-only sync leaves the runtime with an import that cannot resolve and the
28
+ // bridge refuses to start after `/restart confirm`. Directories are copied
29
+ // recursively, and everything else in the runtime (config, state, logs) is left
30
+ // alone because it is not in `files[]`.
31
+ const entries = JSON.parse(readFileSync(join(here, 'package.json'), 'utf8')).files || [];
26
32
  let copied = 0;
27
-
28
- for (const name of names) {
29
- if (name === 'sync-runtime.mjs') continue;
30
- const to = join(target, name);
33
+ const copyOne = (from, to) => {
31
34
  if (existsSync(to)) copyFileSync(to, `${to}.bak-${stamp}`);
32
- copyFileSync(join(here, name), to);
35
+ mkdirSync(dirname(to), { recursive: true });
36
+ copyFileSync(from, to);
33
37
  copied += 1;
38
+ };
39
+
40
+ const copyTree = (fromDir, toDir) => {
41
+ for (const name of readdirSync(fromDir, { withFileTypes: true })) {
42
+ const from = join(fromDir, name.name);
43
+ const to = join(toDir, name.name);
44
+ if (name.isDirectory()) copyTree(from, to);
45
+ else copyOne(from, to);
46
+ }
47
+ };
48
+
49
+ // package.json is not in files[] (npm adds it itself) but /version reads it.
50
+ for (const entry of ['package.json', ...entries]) {
51
+ const from = join(here, entry);
52
+ if (!existsSync(from)) continue;
53
+ if (entry.endsWith('/')) copyTree(from, join(target, entry.replace(/\/$/, '')));
54
+ else copyOne(from, join(target, entry));
34
55
  }
35
56
 
36
57
  const version = (() => {