@tensor.chat/companion 0.3.0 → 0.3.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 (2) hide show
  1. package/package.json +1 -1
  2. package/src/tools/files.js +16 -7
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@tensor.chat/companion",
3
- "version": "0.3.0",
3
+ "version": "0.3.1",
4
4
  "description": "Lets your tensor.chat AI use this machine: files, shell and internet through your own connection.",
5
5
  "license": "MIT",
6
6
  "homepage": "https://tensor.chat",
@@ -172,17 +172,26 @@ function walk(root, onEntry) {
172
172
  // A pattern written as the tree shows it ("Devices/Devbox/game/**", or just the device
173
173
  // folder "Devices/Devbox/**") narrows to that shared folder and continues relative to
174
174
  // it; anything else is matched relative to every shared folder, as before.
175
+ // Every folder's own name is tried before the device folder: the device folder is the
176
+ // start of every name, so tried in the same pass it caught "Devices/PC/VoiceType/*" at
177
+ // the first folder, and only the first shared folder could be searched (03.10.2026).
175
178
  function splitTreePattern(okRoots, pattern) {
176
179
  const p = pattern.replace(/\\/g, '/');
177
180
  const low = p.toLowerCase();
181
+ const rest = (prefix) => {
182
+ if (!prefix) return null;
183
+ const pre = prefix.toLowerCase();
184
+ if (low === pre) return '*';
185
+ return low.startsWith(pre + '/') ? p.slice(prefix.length + 1) || '*' : null;
186
+ };
178
187
  for (const r of okRoots) {
179
- if (!r.label) continue;
180
- const parent = r.label.slice(0, r.label.lastIndexOf('/'));
181
- for (const [prefix, only] of [[r.label, [r]], [parent, okRoots]]) {
182
- if (!prefix) continue;
183
- if (low === prefix.toLowerCase()) return { roots: only, pattern: '*' };
184
- if (low.startsWith(prefix.toLowerCase() + '/')) return { roots: only, pattern: p.slice(prefix.length + 1) || '*' };
185
- }
188
+ const after = r.label ? rest(r.label) : null;
189
+ if (after !== null) return { roots: [r], pattern: after };
190
+ }
191
+ for (const r of okRoots) {
192
+ const cut = r.label ? r.label.lastIndexOf('/') : -1;
193
+ const after = rest(cut > 0 ? r.label.slice(0, cut) : '');
194
+ if (after !== null) return { roots: okRoots, pattern: after };
186
195
  }
187
196
  return { roots: okRoots, pattern: p };
188
197
  }