@babylonjs-toolkit/agent 1.2.15 → 1.2.16

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/README.md CHANGED
@@ -1,4 +1,4 @@
1
- # Babylon Toolkit Desktop Agent (1.2.15)
1
+ # Babylon Toolkit Desktop Agent (1.2.16)
2
2
 
3
3
  The desktop agent owns the entire pipeline end to end — frontend and UI design, gameplay code, shaders, generated art and audio, 3D models in headless Blender, whole game levels and prefabs in a terminal-driven Unity Editor, the interactive glTF export, the web build, the dev server, and visual QA by screenshotting both Unity and the running browser.
4
4
 
@@ -84,6 +84,7 @@ newer Reference.
84
84
  ```bash
85
85
  bt-agent diskinfo # print the report and save Desktop/disk-report-YYYY-MM-DD-HHMM.txt
86
86
  bt-agent diskinfo --no-save # print only
87
+ bt-agent diskinfo --folder ~/Documents/Repos # scan just this folder
87
88
  bt-agent diskinfo --out report.txt
88
89
  bt-agent diskinfo --json # machine-readable
89
90
  ```
@@ -95,6 +96,10 @@ npm / Yarn / pnpm / pip / NuGet caches, Docker and WSL disks, VS Code's C++ cach
95
96
  Trash / Recycle Bin), every `node_modules`, the Unity `Library/` and Unreal `Intermediate/` folders
96
97
  that rebuild themselves, the largest files, and suggested cleanup commands. Nothing is deleted or run.
97
98
 
99
+ `--folder <dir>` scans that one folder instead (`~` and relative paths work): its largest items,
100
+ the known space hogs, `node_modules`, Unity / Unreal projects and big files inside it — nothing
101
+ outside it is walked.
102
+
98
103
  ### Freeing ports
99
104
 
100
105
  ```bash
@@ -5,7 +5,7 @@ const os = require('os');
5
5
  const path = require('path');
6
6
 
7
7
  const { buildReport, formatReport, human } = require('./report');
8
- const { prettyPath } = require('../paths');
8
+ const { prettyPath, expandHome } = require('../paths');
9
9
 
10
10
  const USAGE = `
11
11
  bt-agent diskinfo — show where your disk space is going (macOS, Windows, Linux)
@@ -13,12 +13,19 @@ bt-agent diskinfo — show where your disk space is going (macOS, Windows, Linux
13
13
  Read-only: it walks your home folder and the main system folders once, then prints
14
14
  the biggest folders, known space hogs (Unity, Xcode, package caches, Docker ...),
15
15
  node_modules and Unity/Unreal folders that rebuild themselves, the largest files,
16
- and suggested cleanup commands. Nothing is deleted or run.
16
+ and suggested cleanup commands. Nothing is deleted or run. With --folder it walks
17
+ only that folder (and reports only what lies inside it).
17
18
 
18
19
  Usage
19
20
  bt-agent diskinfo [options]
20
21
 
22
+ Examples
23
+ bt-agent diskinfo
24
+ bt-agent diskinfo --folder ~/Documents/Repos
25
+ bt-agent diskinfo --folder D:\\Projects --no-save
26
+
21
27
  Options
28
+ --folder <dir> Scan only this folder instead of your home folder and the system folders
22
29
  --out <file> Save the report here (default: Desktop/disk-report-YYYY-MM-DD-HHMM.txt)
23
30
  --no-save Print only; do not save a copy
24
31
  --json Machine-readable output on stdout (saved only with --out)
@@ -26,7 +33,7 @@ Options
26
33
  `;
27
34
 
28
35
  function parseDiskInfoArgs(argv) {
29
- const opts = { json: false, save: true, out: null, help: false };
36
+ const opts = { json: false, save: true, out: null, folder: null, help: false };
30
37
  for (let i = 0; i < argv.length; i += 1) {
31
38
  const arg = argv[i];
32
39
  if (arg === '-h' || arg === '--help') opts.help = true;
@@ -36,11 +43,31 @@ function parseDiskInfoArgs(argv) {
36
43
  opts.out = argv[++i];
37
44
  if (!opts.out) throw new Error('--out needs a file path');
38
45
  } else if (arg.startsWith('--out=')) opts.out = arg.slice('--out='.length);
46
+ else if (arg === '--folder') {
47
+ opts.folder = argv[++i];
48
+ if (!opts.folder) throw new Error('--folder needs a folder path');
49
+ } else if (arg.startsWith('--folder=')) {
50
+ opts.folder = arg.slice('--folder='.length);
51
+ if (!opts.folder) throw new Error('--folder needs a folder path');
52
+ }
39
53
  else throw new Error(`Unknown option: ${arg}`);
40
54
  }
41
55
  return opts;
42
56
  }
43
57
 
58
+ /** Expand ~, resolve against the working directory, and require an existing folder. */
59
+ function resolveFolder(folder) {
60
+ const resolved = path.resolve(expandHome(folder));
61
+ let st;
62
+ try {
63
+ st = fs.statSync(resolved);
64
+ } catch {
65
+ throw new Error(`--folder: ${resolved} does not exist`);
66
+ }
67
+ if (!st.isDirectory()) throw new Error(`--folder: ${resolved} is not a folder`);
68
+ return resolved;
69
+ }
70
+
44
71
  function defaultReportPath(date = new Date()) {
45
72
  const desktop = path.join(os.homedir(), 'Desktop');
46
73
  const dir = fs.existsSync(desktop) ? desktop : os.homedir();
@@ -74,6 +101,7 @@ async function runDiskInfoCli(argv) {
74
101
  let opts;
75
102
  try {
76
103
  opts = parseDiskInfoArgs(argv);
104
+ if (opts.folder && !opts.help) opts.folder = resolveFolder(opts.folder);
77
105
  } catch (err) {
78
106
  console.error(`${err.message}\n\nRun \`bt-agent diskinfo --help\` for usage.`);
79
107
  return 2;
@@ -84,9 +112,15 @@ async function runDiskInfoCli(argv) {
84
112
  }
85
113
 
86
114
  const ui = progressLine(!opts.json && process.stderr.isTTY);
87
- if (!opts.json) console.error('Scanning disk usage — this can take a few minutes on a full disk.');
115
+ if (!opts.json) {
116
+ console.error(
117
+ opts.folder
118
+ ? `Scanning disk usage in ${prettyPath(opts.folder)} — this can take a while on a big folder.`
119
+ : 'Scanning disk usage — this can take a few minutes on a full disk.'
120
+ );
121
+ }
88
122
 
89
- const report = await buildReport({ onStage: ui.stage, onProgress: ui.progress });
123
+ const report = await buildReport({ folder: opts.folder, onStage: ui.stage, onProgress: ui.progress });
90
124
  ui.done();
91
125
 
92
126
  const text = opts.json ? JSON.stringify(report, null, 2) : formatReport(report);
@@ -101,4 +135,4 @@ async function runDiskInfoCli(argv) {
101
135
  return 0;
102
136
  }
103
137
 
104
- module.exports = { runDiskInfoCli, parseDiskInfoArgs, defaultReportPath };
138
+ module.exports = { runDiskInfoCli, parseDiskInfoArgs, resolveFolder, defaultReportPath };
@@ -89,25 +89,33 @@ const sum = (list) => list.reduce((n, x) => n + x.bytes, 0);
89
89
  * @param {(p: {files:number, bytes:number, dir:string}) => void} [opts.onProgress]
90
90
  * @param {object} [opts.ctx] { platform, home, env } — injectable for tests.
91
91
  * @param {string[]} [opts.roots] Override the system folders to walk (tests).
92
+ * @param {string} [opts.folder] Scan only this folder instead of the home folder and the
93
+ * system folders; hogs and breakdowns outside it are left out.
92
94
  */
93
95
  async function buildReport(opts = {}) {
94
96
  const started = Date.now();
95
97
  const ctx = opts.ctx || { platform: process.platform, home: os.homedir(), env: process.env };
96
98
  const stage = opts.onStage || (() => {});
97
99
  const scanner = new Scanner({ onProgress: opts.onProgress });
100
+ const folder = opts.folder ? path.resolve(opts.folder) : null;
101
+ const base = folder || ctx.home;
102
+ const baseKey = keyOf(base);
103
+ const basePrefix = baseKey.endsWith(path.sep) ? baseKey : baseKey + path.sep;
104
+ // In folder mode every lookup stays inside the folder, so nothing else on the disk is walked.
105
+ const inScope = (p) => !folder || keyOf(p) === baseKey || keyOf(p).startsWith(basePrefix);
98
106
 
99
107
  stage('volume overview');
100
108
  const vols = volumes(ctx);
101
- const mac = ctx.platform === 'darwin' && !opts.ctx;
109
+ const mac = ctx.platform === 'darwin' && !opts.ctx && !folder;
102
110
  const apfs = mac ? apfsVolumes() : [];
103
111
  const snapshots = mac ? snapshotCount() : 0;
104
112
 
105
- stage(`home folder ${prettyPath(ctx.home)}`);
106
- const homeBytes = scanner.measure(ctx.home) || 0;
113
+ stage(folder ? `folder ${prettyPath(folder)}` : `home folder ${prettyPath(ctx.home)}`);
114
+ const baseBytes = scanner.measure(base) || 0;
107
115
 
108
- const roots = [{ path: ctx.home, bytes: homeBytes, home: true }];
116
+ const roots = [folder ? { path: folder, bytes: baseBytes, folder: true } : { path: ctx.home, bytes: baseBytes, home: true }];
109
117
  const homeKey = keyOf(ctx.home);
110
- for (const root of opts.roots || systemRoots(ctx)) {
118
+ for (const root of folder ? [] : opts.roots || systemRoots(ctx)) {
111
119
  const k = keyOf(root);
112
120
  if (k === homeKey || k.startsWith(homeKey + path.sep) || homeKey.startsWith(k + path.sep)) continue;
113
121
  if (!fs.existsSync(root)) continue;
@@ -120,7 +128,8 @@ async function buildReport(opts = {}) {
120
128
  const hogRows = [];
121
129
  const hogTotals = {};
122
130
  for (const hog of hogs(ctx)) {
123
- const found = hog.paths.flatMap(glob).filter((p) => fs.existsSync(p));
131
+ const found = hog.paths.flatMap(glob).filter((p) => inScope(p) && fs.existsSync(p));
132
+ if (!found.length) continue;
124
133
  const rows = hog.each ? found.map((p) => ({ paths: [p], label: `${hog.label} ${path.basename(p)}` })) : [{ paths: found, label: hog.label }];
125
134
  for (const row of rows) {
126
135
  let bytes = 0;
@@ -137,11 +146,12 @@ async function buildReport(opts = {}) {
137
146
  hogTotals['unity-projects'] = unity.reduce((n, p) => n + p.regenerable, 0);
138
147
  hogTotals['unreal-projects'] = unreal.reduce((n, p) => n + p.regenerable, 0);
139
148
  hogTotals.snapshots = snapshots;
140
- hogTotals.always = 0;
149
+ if (!folder) hogTotals.always = 0; // the system-wide tip only fits a whole-disk scan
141
150
 
142
- const vol = vols.find((v) => keyOf(ctx.home).startsWith(keyOf(v.mount))) || vols[0] || null;
151
+ const vol = vols.find((v) => baseKey.startsWith(keyOf(v.mount))) || vols[0] || null;
143
152
  const measured = sum(roots);
144
- const other = vol ? Math.max(0, vol.used - measured) : null;
153
+ const other = vol && !folder ? Math.max(0, vol.used - measured) : null;
154
+ const breakdownDirs = breakdowns(ctx).filter((d) => inScope(d) && keyOf(d) !== baseKey);
145
155
 
146
156
  return {
147
157
  generatedAt: new Date().toISOString(),
@@ -152,10 +162,11 @@ async function buildReport(opts = {}) {
152
162
  volumes: vols,
153
163
  apfs,
154
164
  snapshots,
165
+ folder,
155
166
  roots: top(roots, roots.length),
156
167
  other,
157
- home: { path: ctx.home, children: top(scanner.children(ctx.home), 25) },
158
- breakdowns: breakdowns(ctx)
168
+ home: { path: base, children: top(scanner.children(base), 25) },
169
+ breakdowns: breakdownDirs
159
170
  .filter((d) => scanner.lookup(d) !== null)
160
171
  .map((d) => ({ path: d, bytes: scanner.lookup(d), children: top(scanner.children(d), d === breakdowns(ctx)[0] ? 15 : 10) })),
161
172
  hogs: hogRows,
@@ -182,7 +193,7 @@ function formatReport(r) {
182
193
  const win = r.platform === 'win32';
183
194
 
184
195
  line(`Disk space report — ${r.localTime} — ${r.computer}`);
185
- line('(read-only scan; nothing was deleted)');
196
+ line(r.folder ? `(read-only scan of ${prettyPath(r.folder)} only; nothing was deleted)` : '(read-only scan; nothing was deleted)');
186
197
 
187
198
  header('1. VOLUMES');
188
199
  for (const v of r.volumes) {
@@ -194,18 +205,20 @@ function formatReport(r) {
194
205
  line(' APFS volumes on this Mac (space consumed):');
195
206
  for (const a of r.apfs) line(` ${human(a.bytes).padStart(10)} ${a.name}`);
196
207
  }
197
- if (r.platform === 'darwin') {
208
+ if (r.platform === 'darwin' && !r.folder) {
198
209
  line();
199
210
  line(` Local Time Machine snapshots: ${r.snapshots}`);
200
211
  }
201
212
 
202
213
  header('2. TOP-LEVEL BREAKDOWN (largest first)');
203
- for (const root of r.roots) row(root.bytes, root.home ? `${prettyPath(root.path)} (your home folder)` : root.path);
214
+ for (const root of r.roots) {
215
+ row(root.bytes, root.home ? `${prettyPath(root.path)} (your home folder)` : root.folder ? `${prettyPath(root.path)} (scanned folder)` : root.path);
216
+ }
204
217
  if (r.other !== null) {
205
218
  row(r.other, win ? 'Everything else (Windows, page file, restore points, unreadable folders)' : 'Everything else (system files, snapshots, unreadable folders)');
206
219
  }
207
220
 
208
- header(`3. HOME FOLDER — ${r.home.children.length} largest items`);
221
+ header(`3. ${r.folder ? `FOLDER ${prettyPath(r.folder)}` : 'HOME FOLDER'} — ${r.home.children.length} largest items`);
209
222
  for (const c of r.home.children) row(c.bytes, prettyPath(c.path));
210
223
  for (const b of r.breakdowns) {
211
224
  line();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs-toolkit/agent",
3
- "version": "1.2.15",
3
+ "version": "1.2.16",
4
4
  "description": "Installs the Babylon Toolkit Desktop Agent for Claude Code, Codex, GitHub Copilot, Gemini CLI and Antigravity.",
5
5
  "keywords": [
6
6
  "babylonjs",