@babylonjs-toolkit/agent 1.1.42 → 1.1.46

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.1.42)
1
+ # Babylon Toolkit Desktop Agent (1.1.46)
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
 
@@ -32,6 +32,7 @@ up the skills, instructions and configuration.
32
32
  | `bt-agent doctor` | Verify the install; prints `INSTALL OK` or lists what is missing |
33
33
  | `bt-agent targets` | Show every target and the paths it writes to |
34
34
  | `bt-agent bridge` | Connect this computer to the App Builder so it can drive Unity and Blender |
35
+ | `bt-agent diskinfo` | Show where your disk space is going — read-only, macOS, Windows and Linux |
35
36
 
36
37
  | Option | Effect |
37
38
  |--------|--------|
@@ -44,6 +45,22 @@ up the skills, instructions and configuration.
44
45
  | `--dry-run` | Print what would happen and change nothing |
45
46
  | `--json` | Machine-readable output |
46
47
 
48
+ ### Disk usage report
49
+
50
+ ```bash
51
+ bt-agent diskinfo # print the report and save Desktop/disk-report-YYYY-MM-DD-HHMM.txt
52
+ bt-agent diskinfo --no-save # print only
53
+ bt-agent diskinfo --out report.txt
54
+ bt-agent diskinfo --json # machine-readable
55
+ ```
56
+
57
+ One read-only pass over your home folder and the main system folders (`/Applications`, `/Library`,
58
+ `/usr/local` … on macOS; `Program Files`, `ProgramData` on Windows). It reports the volumes, the
59
+ largest folders, known space hogs (Unity editors and caches, Xcode DerivedData and simulators,
60
+ npm / Yarn / pnpm / pip / NuGet caches, Docker and WSL disks, VS Code's C++ cache, Steam, backups,
61
+ Trash / Recycle Bin), every `node_modules`, the Unity `Library/` and Unreal `Intermediate/` folders
62
+ that rebuild themselves, the largest files, and suggested cleanup commands. Nothing is deleted or run.
63
+
47
64
  ### Updating
48
65
 
49
66
  ```bash
@@ -267,9 +284,13 @@ implementer writes the tests and the independent verifier judges them.
267
284
  ```
268
285
 
269
286
  Auto-pilot is for running a 50-task plan overnight. There is no one to ask, so `bt-execute`
270
- makes every call itself — from the plan's Decisions, then the Babylon Toolkit Agent Reference
271
- (Unity → interactive glTF → BabylonJS script components), then the codebase, then senior-developer
272
- default — and logs each one. Nothing is relaxed on quality: every task still has passing tests
287
+ owns the whole pipeline — code, UI, shaders, generated art and audio, Blender, Unity, export,
288
+ build, dev server and visual QA — and makes every call itself: it first looks the answer up in the
289
+ brief, plan, spec and `SPEC.md`, then the Babylon Toolkit Agent Reference (Unity → interactive glTF
290
+ → BabylonJS script components), then the codebase, then senior-developer default — and logs each
291
+ one. It never asks a question and never ends its
292
+ turn until the requested range, or every task, is done; it stops early only for a missing plan, a
293
+ bad range, a stop point named in the brief, or you telling it to stop. Nothing is relaxed on quality: every task still has passing tests
273
294
  and goes through an independent verifier, and a box only flips on a genuine PASS.
274
295
  What changes is that a failure never halts the run: a failing task gets a bounded fix loop (3
275
296
  attempts, 5 under `--strict`), is then marked `⏭️ DEFERRED (auto-pilot): <reason>` in the plan, and the run moves
package/bin/bt-agent.js CHANGED
@@ -25,6 +25,7 @@ Commands
25
25
  doctor Verify the install; prints INSTALL OK or INSTALL FAILED
26
26
  targets List the available targets and their paths
27
27
  bridge Connect this computer to the App Builder (Unity/Blender); see bt-agent bridge --help
28
+ diskinfo Show where your disk space is going (read-only); see bt-agent diskinfo --help
28
29
 
29
30
  Options
30
31
  --project Install into the current directory instead of $HOME
@@ -45,6 +46,7 @@ Examples
45
46
  bt-agent install --project
46
47
  bt-agent doctor
47
48
  bt-agent update
49
+ bt-agent diskinfo
48
50
  bt-agent bridge --install-service --pair <code from the Unity Bridge dialog>
49
51
  `;
50
52
 
@@ -257,6 +259,13 @@ function main() {
257
259
  return;
258
260
  }
259
261
 
262
+ if (process.argv[2] === 'diskinfo') {
263
+ require('../lib/diskinfo/cli')
264
+ .runDiskInfoCli(process.argv.slice(3))
265
+ .then((code) => process.exit(code), (error) => { console.error(error.message); process.exit(1); });
266
+ return;
267
+ }
268
+
260
269
  let opts;
261
270
  try {
262
271
  opts = parseArgs(process.argv.slice(2));
@@ -0,0 +1,104 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const os = require('os');
5
+ const path = require('path');
6
+
7
+ const { buildReport, formatReport, human } = require('./report');
8
+ const { prettyPath } = require('../paths');
9
+
10
+ const USAGE = `
11
+ bt-agent diskinfo — show where your disk space is going (macOS, Windows, Linux)
12
+
13
+ Read-only: it walks your home folder and the main system folders once, then prints
14
+ the biggest folders, known space hogs (Unity, Xcode, package caches, Docker ...),
15
+ node_modules and Unity/Unreal folders that rebuild themselves, the largest files,
16
+ and suggested cleanup commands. Nothing is deleted or run.
17
+
18
+ Usage
19
+ bt-agent diskinfo [options]
20
+
21
+ Options
22
+ --out <file> Save the report here (default: Desktop/disk-report-YYYY-MM-DD-HHMM.txt)
23
+ --no-save Print only; do not save a copy
24
+ --json Machine-readable output on stdout (saved only with --out)
25
+ -h, --help Show this help
26
+ `;
27
+
28
+ function parseDiskInfoArgs(argv) {
29
+ const opts = { json: false, save: true, out: null, help: false };
30
+ for (let i = 0; i < argv.length; i += 1) {
31
+ const arg = argv[i];
32
+ if (arg === '-h' || arg === '--help') opts.help = true;
33
+ else if (arg === '--json') opts.json = true;
34
+ else if (arg === '--no-save') opts.save = false;
35
+ else if (arg === '--out') {
36
+ opts.out = argv[++i];
37
+ if (!opts.out) throw new Error('--out needs a file path');
38
+ } else if (arg.startsWith('--out=')) opts.out = arg.slice('--out='.length);
39
+ else throw new Error(`Unknown option: ${arg}`);
40
+ }
41
+ return opts;
42
+ }
43
+
44
+ function defaultReportPath(date = new Date()) {
45
+ const desktop = path.join(os.homedir(), 'Desktop');
46
+ const dir = fs.existsSync(desktop) ? desktop : os.homedir();
47
+ const pad = (n) => String(n).padStart(2, '0');
48
+ const stamp = `${date.getFullYear()}-${pad(date.getMonth() + 1)}-${pad(date.getDate())}-${pad(date.getHours())}${pad(date.getMinutes())}`;
49
+ return path.join(dir, `disk-report-${stamp}.txt`);
50
+ }
51
+
52
+ /** One updating status line on stderr, only when a person is watching. */
53
+ function progressLine(enabled) {
54
+ if (!enabled) return { stage() {}, progress() {}, done() {} };
55
+ const width = () => Math.max(40, (process.stderr.columns || 100) - 1);
56
+ let current = '';
57
+ const draw = (text) => process.stderr.write(`\r${text.slice(0, width()).padEnd(width())}`);
58
+ return {
59
+ stage(msg) {
60
+ current = msg;
61
+ draw(` scanning ${msg} ...`);
62
+ },
63
+ progress(p) {
64
+ draw(` scanning ${current} — ${p.files.toLocaleString()} files, ${human(p.bytes)} — ${prettyPath(p.dir)}`);
65
+ },
66
+ done() {
67
+ process.stderr.write(`\r${' '.repeat(width())}\r`);
68
+ },
69
+ };
70
+ }
71
+
72
+ /** Entry point for `bt-agent diskinfo`. Resolves to the process exit code. */
73
+ async function runDiskInfoCli(argv) {
74
+ let opts;
75
+ try {
76
+ opts = parseDiskInfoArgs(argv);
77
+ } catch (err) {
78
+ console.error(`${err.message}\n\nRun \`bt-agent diskinfo --help\` for usage.`);
79
+ return 2;
80
+ }
81
+ if (opts.help) {
82
+ console.log(USAGE);
83
+ return 0;
84
+ }
85
+
86
+ 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.');
88
+
89
+ const report = await buildReport({ onStage: ui.stage, onProgress: ui.progress });
90
+ ui.done();
91
+
92
+ const text = opts.json ? JSON.stringify(report, null, 2) : formatReport(report);
93
+ console.log(text);
94
+
95
+ const out = opts.out || (opts.save && !opts.json ? defaultReportPath() : null);
96
+ if (out) {
97
+ fs.mkdirSync(path.dirname(path.resolve(out)), { recursive: true });
98
+ fs.writeFileSync(out, text + '\n');
99
+ if (!opts.json) console.error(`Report saved to ${prettyPath(path.resolve(out))}`);
100
+ }
101
+ return 0;
102
+ }
103
+
104
+ module.exports = { runDiskInfoCli, parseDiskInfoArgs, defaultReportPath };
@@ -0,0 +1,213 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ /**
7
+ * Where disk space usually goes, per platform.
8
+ *
9
+ * Everything is a plain table so the report stays a lookup over one walk, and so
10
+ * the paths can be checked in tests for every platform from any platform.
11
+ * `ctx` = { platform, home, env } — injected, never read from the process here.
12
+ */
13
+
14
+ function dirs(ctx) {
15
+ const { home, env } = ctx;
16
+ const p = ctx.platform === 'win32' ? path.win32 : path.posix;
17
+ const join = (...a) => p.join(...a);
18
+ const localAppData = env.LOCALAPPDATA || join(home, 'AppData', 'Local');
19
+ const appData = env.APPDATA || join(home, 'AppData', 'Roaming');
20
+ const systemDrive = (env.SystemDrive || 'C:') + '\\';
21
+ const programFiles = env.ProgramFiles || join(systemDrive, 'Program Files');
22
+ const programFilesX86 = env['ProgramFiles(x86)'] || join(systemDrive, 'Program Files (x86)');
23
+ const programData = env.ProgramData || join(systemDrive, 'ProgramData');
24
+ const lib = join(home, 'Library');
25
+ return { join, localAppData, appData, systemDrive, programFiles, programFilesX86, programData, lib };
26
+ }
27
+
28
+ /** Folders outside the home folder worth walking. */
29
+ function systemRoots(ctx) {
30
+ const d = dirs(ctx);
31
+ switch (ctx.platform) {
32
+ case 'darwin':
33
+ return ['/Applications', '/Library', '/private/var', '/opt/homebrew', '/usr/local', '/Users/Shared'];
34
+ case 'win32':
35
+ return [d.programFiles, d.programFilesX86, d.programData];
36
+ default:
37
+ return ['/usr', '/var', '/opt', '/snap'];
38
+ }
39
+ }
40
+
41
+ /** Big home sub-folders to break down further (top N children each). */
42
+ function breakdowns(ctx) {
43
+ const d = dirs(ctx);
44
+ switch (ctx.platform) {
45
+ case 'darwin':
46
+ return [
47
+ d.lib,
48
+ d.join(d.lib, 'Application Support'),
49
+ d.join(d.lib, 'Caches'),
50
+ d.join(d.lib, 'Containers'),
51
+ d.join(d.lib, 'Group Containers'),
52
+ ];
53
+ case 'win32':
54
+ return [d.localAppData, d.appData, d.join(ctx.home, 'AppData', 'LocalLow'), d.join(d.localAppData, 'Packages')];
55
+ default:
56
+ return [d.join(ctx.home, '.cache'), d.join(ctx.home, '.local', 'share')];
57
+ }
58
+ }
59
+
60
+ /** Expand a trailing `*` (one level) into the folders that exist. */
61
+ function glob(pattern) {
62
+ if (!pattern.endsWith('*')) return [pattern];
63
+ const dir = path.dirname(pattern);
64
+ const prefix = path.basename(pattern).slice(0, -1);
65
+ try {
66
+ return fs
67
+ .readdirSync(dir, { withFileTypes: true })
68
+ .filter((e) => e.isDirectory() && e.name.startsWith(prefix))
69
+ .map((e) => path.join(dir, e.name));
70
+ } catch {
71
+ return [];
72
+ }
73
+ }
74
+
75
+ /**
76
+ * Known space hogs: { id, group, label, paths[], each? }.
77
+ * `each: true` lists every match separately (one row per Unity editor version).
78
+ */
79
+ function hogs(ctx) {
80
+ const d = dirs(ctx);
81
+ const h = (...a) => d.join(ctx.home, ...a);
82
+ const L = (...a) => d.join(d.lib, ...a);
83
+ const local = (...a) => d.join(d.localAppData, ...a);
84
+ const roam = (...a) => d.join(d.appData, ...a);
85
+
86
+ if (ctx.platform === 'win32') {
87
+ return [
88
+ { id: 'unity-editors', group: 'Unity', label: 'Unity Editor', paths: [d.join(d.programFiles, 'Unity', 'Hub', 'Editor', '*')], each: true },
89
+ { id: 'unity-assetstore', group: 'Unity', label: 'Unity Asset Store downloads', paths: [roam('Unity', 'Asset Store-5.x')] },
90
+ { id: 'unity-cache', group: 'Unity', label: 'Unity package & GI caches', paths: [local('Unity', 'cache'), h('AppData', 'LocalLow', 'Unity', 'Caches')] },
91
+ { id: 'unity-hub', group: 'Unity', label: 'Unity Hub data', paths: [roam('UnityHub')] },
92
+ { id: 'android', group: 'Android', label: 'Android SDK & emulators', paths: [local('Android', 'Sdk'), h('.android')] },
93
+ { id: 'gradle', group: 'Android', label: 'Gradle (~/.gradle)', paths: [h('.gradle')] },
94
+ { id: 'docker', group: 'Docker / VMs', label: 'Docker Desktop disk', paths: [local('Docker')] },
95
+ { id: 'wsl', group: 'Docker / VMs', label: 'WSL Linux distros', paths: [local('Packages', 'CanonicalGroupLimited*')] },
96
+ { id: 'npm', group: 'Package caches', label: 'npm cache', paths: [local('npm-cache')] },
97
+ { id: 'yarn', group: 'Package caches', label: 'Yarn cache', paths: [local('Yarn', 'Cache'), h('.yarn', 'berry', 'cache')] },
98
+ { id: 'pnpm', group: 'Package caches', label: 'pnpm store', paths: [local('pnpm')] },
99
+ { id: 'pip', group: 'Package caches', label: 'pip cache', paths: [local('pip', 'Cache')] },
100
+ { id: 'nuget', group: 'Package caches', label: 'NuGet (~/.nuget)', paths: [h('.nuget')] },
101
+ { id: 'nvm', group: 'Package caches', label: 'nvm Node versions', paths: [roam('nvm')] },
102
+ { id: 'cargo', group: 'Package caches', label: 'Rust (~/.cargo, ~/.rustup)', paths: [h('.cargo'), h('.rustup')] },
103
+ { id: 'dotcache', group: 'Package caches', label: '~/.cache', paths: [h('.cache')] },
104
+ { id: 'ollama', group: 'Package caches', label: 'Ollama models', paths: [h('.ollama')] },
105
+ { id: 'cpptools', group: 'Editors', label: 'VS Code C++ IntelliSense cache', paths: [local('Microsoft', 'vscode-cpptools')] },
106
+ { id: 'vscode', group: 'Editors', label: 'VS Code data', paths: [roam('Code')] },
107
+ { id: 'chrome', group: 'Apps & media', label: 'Chrome profiles', paths: [local('Google', 'Chrome'), local('Google', 'Chrome Beta')] },
108
+ { id: 'steam', group: 'Apps & media', label: 'Steam games', paths: [d.join(d.programFilesX86, 'Steam', 'steamapps')] },
109
+ { id: 'epic', group: 'Apps & media', label: 'Epic Games', paths: [d.join(d.programFiles, 'Epic Games')] },
110
+ { id: 'ios-backups', group: 'Apps & media', label: 'iPhone/iPad backups', paths: [roam('Apple Computer', 'MobileSync', 'Backup'), h('Apple', 'MobileSync', 'Backup')] },
111
+ { id: 'onedrive', group: 'Apps & media', label: 'OneDrive (local copies)', paths: [h('OneDrive')] },
112
+ { id: 'icloud', group: 'Apps & media', label: 'iCloud Drive (local copies)', paths: [h('iCloudDrive')] },
113
+ { id: 'temp', group: 'Leftovers', label: 'Temp files', paths: [local('Temp')] },
114
+ { id: 'trash', group: 'Leftovers', label: 'Recycle Bin', paths: [d.join(d.systemDrive, '$Recycle.Bin')] },
115
+ { id: 'downloads', group: 'Leftovers', label: 'Downloads', paths: [h('Downloads')] },
116
+ { id: 'swap', group: 'Leftovers', label: 'Page file / hibernation file', paths: ['pagefile.sys', 'hiberfil.sys', 'swapfile.sys'].map((f) => d.join(d.systemDrive, f)) },
117
+ ];
118
+ }
119
+
120
+ if (ctx.platform === 'darwin') {
121
+ return [
122
+ { id: 'unity-editors', group: 'Unity', label: 'Unity Editor', paths: ['/Applications/Unity/Hub/Editor/*'], each: true },
123
+ { id: 'unity-assetstore', group: 'Unity', label: 'Unity Asset Store downloads', paths: [L('Unity', 'Asset Store-5.x')] },
124
+ { id: 'unity-cache', group: 'Unity', label: 'Unity package & GI caches', paths: [L('Unity', 'cache'), L('Caches', 'com.unity3d.UnityEditor'), L('Caches', 'Unity')] },
125
+ { id: 'unity-hub', group: 'Unity', label: 'Unity Hub data', paths: [L('Application Support', 'UnityHub')] },
126
+ { id: 'xcode-deriveddata', group: 'Xcode', label: 'Xcode DerivedData', paths: [L('Developer', 'Xcode', 'DerivedData')] },
127
+ { id: 'xcode-archives', group: 'Xcode', label: 'Xcode Archives', paths: [L('Developer', 'Xcode', 'Archives')] },
128
+ { id: 'xcode-devicesupport', group: 'Xcode', label: 'Xcode device support files', paths: [L('Developer', 'Xcode', 'iOS DeviceSupport'), L('Developer', 'Xcode', 'watchOS DeviceSupport'), L('Developer', 'Xcode', 'tvOS DeviceSupport')] },
129
+ { id: 'simulators', group: 'Xcode', label: 'Simulator devices & runtimes', paths: [L('Developer', 'CoreSimulator'), '/Library/Developer/CoreSimulator'] },
130
+ { id: 'android', group: 'Android', label: 'Android SDK & emulators', paths: [L('Android', 'sdk'), h('.android')] },
131
+ { id: 'gradle', group: 'Android', label: 'Gradle (~/.gradle)', paths: [h('.gradle')] },
132
+ { id: 'docker', group: 'Docker / VMs', label: 'Docker Desktop disk', paths: [L('Containers', 'com.docker.docker')] },
133
+ { id: 'vms', group: 'Docker / VMs', label: 'Parallels / UTM VMs', paths: [h('Parallels'), L('Containers', 'com.utmapp.UTM')] },
134
+ { id: 'npm', group: 'Package caches', label: 'npm cache', paths: [h('.npm')] },
135
+ { id: 'yarn', group: 'Package caches', label: 'Yarn cache', paths: [L('Caches', 'Yarn'), h('.yarn', 'berry', 'cache')] },
136
+ { id: 'pnpm', group: 'Package caches', label: 'pnpm store', paths: [L('pnpm'), h('.pnpm-store')] },
137
+ { id: 'pip', group: 'Package caches', label: 'pip cache', paths: [L('Caches', 'pip')] },
138
+ { id: 'homebrew', group: 'Package caches', label: 'Homebrew download cache', paths: [L('Caches', 'Homebrew')] },
139
+ { id: 'nuget', group: 'Package caches', label: 'NuGet (~/.nuget)', paths: [h('.nuget')] },
140
+ { id: 'nvm', group: 'Package caches', label: 'nvm Node versions', paths: [h('.nvm')] },
141
+ { id: 'cargo', group: 'Package caches', label: 'Rust (~/.cargo, ~/.rustup)', paths: [h('.cargo'), h('.rustup')] },
142
+ { id: 'dotcache', group: 'Package caches', label: '~/.cache', paths: [h('.cache')] },
143
+ { id: 'ollama', group: 'Package caches', label: 'Ollama models', paths: [h('.ollama')] },
144
+ { id: 'cpptools', group: 'Editors', label: 'VS Code C++ IntelliSense cache', paths: [L('Caches', 'vscode-cpptools')] },
145
+ { id: 'vscode', group: 'Editors', label: 'VS Code data', paths: [L('Application Support', 'Code')] },
146
+ { id: 'chrome', group: 'Apps & media', label: 'Chrome profiles', paths: [L('Application Support', 'Google')] },
147
+ { id: 'steam', group: 'Apps & media', label: 'Steam games', paths: [L('Application Support', 'Steam')] },
148
+ { id: 'epic', group: 'Apps & media', label: 'Epic Games', paths: [L('Application Support', 'Epic'), '/Users/Shared/Epic Games'] },
149
+ { id: 'ios-backups', group: 'Apps & media', label: 'iPhone/iPad backups', paths: [L('Application Support', 'MobileSync', 'Backup')] },
150
+ { id: 'mail', group: 'Apps & media', label: 'Mail', paths: [L('Mail')] },
151
+ { id: 'messages', group: 'Apps & media', label: 'Messages attachments', paths: [L('Messages')] },
152
+ { id: 'photos', group: 'Apps & media', label: 'Photos libraries', paths: [h('Pictures', '*')].flatMap(glob).filter((p) => p.endsWith('.photoslibrary')) },
153
+ { id: 'icloud', group: 'Apps & media', label: 'iCloud Drive (local copies)', paths: [L('Mobile Documents')] },
154
+ { id: 'trash', group: 'Leftovers', label: 'Trash', paths: [h('.Trash')] },
155
+ { id: 'downloads', group: 'Leftovers', label: 'Downloads', paths: [h('Downloads')] },
156
+ { id: 'swap', group: 'Leftovers', label: 'Swap / sleep image', paths: ['/private/var/vm'] },
157
+ ];
158
+ }
159
+
160
+ return [
161
+ { id: 'unity-editors', group: 'Unity', label: 'Unity Editor', paths: [h('Unity', 'Hub', 'Editor', '*')], each: true },
162
+ { id: 'unity-cache', group: 'Unity', label: 'Unity caches', paths: [h('.cache', 'unity3d'), h('.local', 'share', 'unity3d')] },
163
+ { id: 'docker', group: 'Docker / VMs', label: 'Docker', paths: ['/var/lib/docker'] },
164
+ { id: 'npm', group: 'Package caches', label: 'npm cache', paths: [h('.npm')] },
165
+ { id: 'yarn', group: 'Package caches', label: 'Yarn cache', paths: [h('.cache', 'yarn'), h('.yarn', 'berry', 'cache')] },
166
+ { id: 'pnpm', group: 'Package caches', label: 'pnpm store', paths: [h('.local', 'share', 'pnpm')] },
167
+ { id: 'nvm', group: 'Package caches', label: 'nvm Node versions', paths: [h('.nvm')] },
168
+ { id: 'dotcache', group: 'Package caches', label: '~/.cache', paths: [h('.cache')] },
169
+ { id: 'gradle', group: 'Android', label: 'Gradle (~/.gradle)', paths: [h('.gradle')] },
170
+ { id: 'trash', group: 'Leftovers', label: 'Trash', paths: [h('.local', 'share', 'Trash')] },
171
+ { id: 'downloads', group: 'Leftovers', label: 'Downloads', paths: [h('Downloads')] },
172
+ ];
173
+ }
174
+
175
+ const GB = 1024 ** 3;
176
+
177
+ /**
178
+ * Cleanup suggestions, shown only when the matching hog is at least `min` bytes.
179
+ * Text only — diskinfo never runs any of them.
180
+ */
181
+ function suggestions(ctx) {
182
+ const win = ctx.platform === 'win32';
183
+ const mac = ctx.platform === 'darwin';
184
+ return [
185
+ { id: 'xcode-deriveddata', min: GB, text: 'Xcode DerivedData is a build cache: rm -rf ~/Library/Developer/Xcode/DerivedData/*' },
186
+ { id: 'xcode-devicesupport', min: GB, text: 'Old device support folders in ~/Library/Developer/Xcode/*DeviceSupport are safe to delete.' },
187
+ { id: 'simulators', min: GB, text: 'xcrun simctl delete unavailable — and remove old runtimes in Xcode > Settings > Components.' },
188
+ { id: 'unity-projects', min: GB, text: "Unity project Library/ folders rebuild when the project opens; delete them for projects you're not working on." },
189
+ { id: 'unreal-projects', min: GB, text: 'Unreal Intermediate/, DerivedDataCache/ and Binaries/ rebuild; delete them for idle projects.' },
190
+ { id: 'unity-editors', min: GB, text: 'Remove Unity Editor versions you no longer use in Unity Hub > Installs.' },
191
+ { id: 'unity-assetstore', min: GB, text: 'Unity Asset Store downloads (.unitypackage) can be re-downloaded from My Assets.' },
192
+ { id: 'cpptools', min: GB, text: 'Delete the VS Code C++ IntelliSense cache, and cap it with "C_Cpp.intelliSenseCacheSize": 5 in VS Code settings.' },
193
+ { id: 'npm', min: GB, text: 'npm cache clean --force' },
194
+ { id: 'yarn', min: GB, text: 'yarn cache clean' },
195
+ { id: 'pnpm', min: GB, text: 'pnpm store prune' },
196
+ { id: 'pip', min: GB, text: 'pip cache purge' },
197
+ { id: 'nuget', min: GB, text: 'dotnet nuget locals all --clear' },
198
+ { id: 'homebrew', min: GB / 2, text: 'brew cleanup --prune=all' },
199
+ { id: 'gradle', min: GB, text: 'Delete ~/.gradle/caches (Gradle downloads what it needs again).' },
200
+ { id: 'docker', min: GB, text: 'docker system prune -a — removes unused images, containers and build cache.' },
201
+ { id: 'wsl', min: GB, text: 'Remove WSL distros you no longer use: wsl --list, then wsl --unregister <name>.' },
202
+ { id: 'node-modules', min: GB, text: 'node_modules in old projects can be deleted; npm install brings them back.' },
203
+ { id: 'ios-backups', min: GB, text: win ? 'Old device backups: iTunes / Apple Devices > Preferences > Devices.' : 'Old device backups: Finder > your iPhone > Manage Backups.' },
204
+ { id: 'steam', min: GB, text: "Uninstall Steam games you don't play from the Steam library." },
205
+ { id: 'temp', min: GB, text: 'Clear temp files: Settings > System > Storage > Temporary files.' },
206
+ { id: 'trash', min: GB / 10, text: win ? 'Empty the Recycle Bin.' : 'Empty the Trash.' },
207
+ { id: 'downloads', min: GB, text: 'Review Downloads, sorted by size.' },
208
+ { id: 'snapshots', min: 1, text: 'Local Time Machine snapshots hold space no folder shows: tmutil listlocalsnapshots /, then sudo tmutil deletelocalsnapshots <date>.' },
209
+ { id: 'always', min: 0, text: mac ? 'System Settings > General > Storage has its own recommendations.' : win ? 'Settings > System > Storage > Cleanup recommendations, and Disk Cleanup > Clean up system files.' : 'Your distro package cache (apt clean / dnf clean all) and journalctl --vacuum-size=200M.' },
210
+ ];
211
+ }
212
+
213
+ module.exports = { systemRoots, breakdowns, hogs, suggestions, glob };
@@ -0,0 +1,271 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const os = require('os');
5
+ const path = require('path');
6
+ const { spawnSync } = require('child_process');
7
+
8
+ const { Scanner, keyOf } = require('./scan');
9
+ const { systemRoots, breakdowns, hogs, suggestions, glob } = require('./locations');
10
+ const { prettyPath } = require('../paths');
11
+
12
+ const MB = 1024 ** 2;
13
+ const HOG_MIN = 50 * MB;
14
+
15
+ /** 1536 -> "1.5 KB", using 1024 steps like Finder's "About This Mac" used to. */
16
+ function human(bytes) {
17
+ const units = ['B', 'KB', 'MB', 'GB', 'TB'];
18
+ let n = Number(bytes) || 0;
19
+ let i = 0;
20
+ while (n >= 1024 && i < units.length - 1) {
21
+ n /= 1024;
22
+ i += 1;
23
+ }
24
+ return i === 0 ? `${n} B` : `${n.toFixed(1)} ${units[i]}`;
25
+ }
26
+
27
+ function localStamp(d) {
28
+ const pad = (n) => String(n).padStart(2, '0');
29
+ return `${d.getFullYear()}-${pad(d.getMonth() + 1)}-${pad(d.getDate())} ${pad(d.getHours())}:${pad(d.getMinutes())}`;
30
+ }
31
+
32
+ function run(cmd, args) {
33
+ const r = spawnSync(cmd, args, { encoding: 'utf8', timeout: 20000, windowsHide: true });
34
+ return r.status === 0 ? r.stdout : '';
35
+ }
36
+
37
+ function statVolume(mount) {
38
+ if (typeof fs.statfsSync !== 'function') return null; // Node < 18.15
39
+ try {
40
+ const s = fs.statfsSync(mount);
41
+ const total = s.blocks * s.bsize;
42
+ return { mount, total, used: total - s.bfree * s.bsize, free: s.bavail * s.bsize };
43
+ } catch {
44
+ return null;
45
+ }
46
+ }
47
+
48
+ /** The volume holding the user's data, plus every other fixed drive on Windows. */
49
+ function volumes(ctx) {
50
+ if (ctx.platform === 'win32') {
51
+ const out = [];
52
+ for (let c = 67; c <= 90; c += 1) {
53
+ const root = `${String.fromCharCode(c)}:\\`;
54
+ const v = fs.existsSync(root) ? statVolume(root) : null;
55
+ if (v && v.total > 0) out.push(v);
56
+ }
57
+ return out;
58
+ }
59
+ const data = ctx.platform === 'darwin' && fs.existsSync('/System/Volumes/Data') ? '/System/Volumes/Data' : '/';
60
+ const v = statVolume(data);
61
+ return v ? [v] : [];
62
+ }
63
+
64
+ /** macOS only: space consumed by each APFS volume (simulator runtimes show up here). */
65
+ function apfsVolumes() {
66
+ const out = [];
67
+ let name = null;
68
+ for (const line of run('diskutil', ['apfs', 'list']).split('\n')) {
69
+ const n = /Name:\s+(.+?)(\s+\(Case-.*\))?\s*$/.exec(line);
70
+ if (n) name = n[1];
71
+ const c = /Capacity Consumed:\s+(\d+) B/.exec(line);
72
+ if (c && name) out.push({ name, bytes: Number(c[1]) });
73
+ }
74
+ return out.sort((a, b) => b.bytes - a.bytes);
75
+ }
76
+
77
+ function snapshotCount() {
78
+ return run('tmutil', ['listlocalsnapshots', '/']).split('\n').filter((l) => l.includes('com.apple')).length;
79
+ }
80
+
81
+ const top = (list, n) => [...list].sort((a, b) => b.bytes - a.bytes).slice(0, n);
82
+ const sum = (list) => list.reduce((n, x) => n + x.bytes, 0);
83
+
84
+ /**
85
+ * Scan the disk and return the report data. Read-only: nothing is moved or deleted.
86
+ * The walk itself is synchronous (see Scanner); this stays async for callers' convenience.
87
+ * @param {object} [opts]
88
+ * @param {(msg: string) => void} [opts.onStage] A new phase started.
89
+ * @param {(p: {files:number, bytes:number, dir:string}) => void} [opts.onProgress]
90
+ * @param {object} [opts.ctx] { platform, home, env } — injectable for tests.
91
+ * @param {string[]} [opts.roots] Override the system folders to walk (tests).
92
+ */
93
+ async function buildReport(opts = {}) {
94
+ const started = Date.now();
95
+ const ctx = opts.ctx || { platform: process.platform, home: os.homedir(), env: process.env };
96
+ const stage = opts.onStage || (() => {});
97
+ const scanner = new Scanner({ onProgress: opts.onProgress });
98
+
99
+ stage('volume overview');
100
+ const vols = volumes(ctx);
101
+ const mac = ctx.platform === 'darwin' && !opts.ctx;
102
+ const apfs = mac ? apfsVolumes() : [];
103
+ const snapshots = mac ? snapshotCount() : 0;
104
+
105
+ stage(`home folder ${prettyPath(ctx.home)}`);
106
+ const homeBytes = scanner.measure(ctx.home) || 0;
107
+
108
+ const roots = [{ path: ctx.home, bytes: homeBytes, home: true }];
109
+ const homeKey = keyOf(ctx.home);
110
+ for (const root of opts.roots || systemRoots(ctx)) {
111
+ const k = keyOf(root);
112
+ if (k === homeKey || k.startsWith(homeKey + path.sep) || homeKey.startsWith(k + path.sep)) continue;
113
+ if (!fs.existsSync(root)) continue;
114
+ stage(prettyPath(root));
115
+ const bytes = scanner.measure(root);
116
+ if (bytes !== null) roots.push({ path: root, bytes });
117
+ }
118
+
119
+ stage('known space hogs');
120
+ const hogRows = [];
121
+ const hogTotals = {};
122
+ for (const hog of hogs(ctx)) {
123
+ const found = hog.paths.flatMap(glob).filter((p) => fs.existsSync(p));
124
+ const rows = hog.each ? found.map((p) => ({ paths: [p], label: `${hog.label} ${path.basename(p)}` })) : [{ paths: found, label: hog.label }];
125
+ for (const row of rows) {
126
+ let bytes = 0;
127
+ for (const p of row.paths) bytes += scanner.sizeOf(p) || 0;
128
+ hogTotals[hog.id] = (hogTotals[hog.id] || 0) + bytes;
129
+ if (bytes >= HOG_MIN) hogRows.push({ id: hog.id, group: hog.group, label: row.label, bytes, paths: row.paths });
130
+ }
131
+ }
132
+
133
+ const worthListing = (p) => p.bytes >= HOG_MIN;
134
+ const unity = top(scanner.unityProjects.filter(worthListing), 50);
135
+ const unreal = top(scanner.unrealProjects.filter(worthListing), 50);
136
+ hogTotals['node-modules'] = sum(scanner.nodeModules);
137
+ hogTotals['unity-projects'] = unity.reduce((n, p) => n + p.regenerable, 0);
138
+ hogTotals['unreal-projects'] = unreal.reduce((n, p) => n + p.regenerable, 0);
139
+ hogTotals.snapshots = snapshots;
140
+ hogTotals.always = 0;
141
+
142
+ const vol = vols.find((v) => keyOf(ctx.home).startsWith(keyOf(v.mount))) || vols[0] || null;
143
+ const measured = sum(roots);
144
+ const other = vol ? Math.max(0, vol.used - measured) : null;
145
+
146
+ return {
147
+ generatedAt: new Date().toISOString(),
148
+ localTime: localStamp(new Date()),
149
+ computer: os.hostname(),
150
+ platform: ctx.platform,
151
+ elapsedMs: Date.now() - started,
152
+ volumes: vols,
153
+ apfs,
154
+ snapshots,
155
+ roots: top(roots, roots.length),
156
+ other,
157
+ home: { path: ctx.home, children: top(scanner.children(ctx.home), 25) },
158
+ breakdowns: breakdowns(ctx)
159
+ .filter((d) => scanner.lookup(d) !== null)
160
+ .map((d) => ({ path: d, bytes: scanner.lookup(d), children: top(scanner.children(d), d === breakdowns(ctx)[0] ? 15 : 10) })),
161
+ hogs: hogRows,
162
+ nodeModules: { count: scanner.nodeModules.length, bytes: hogTotals['node-modules'], top: top(scanner.nodeModules, 15) },
163
+ unityProjects: unity,
164
+ unrealProjects: unreal,
165
+ bigFiles: top(scanner.bigFiles, 30),
166
+ suggestions: suggestions(ctx).filter((s) => (hogTotals[s.id] ?? -1) >= s.min).map((s) => s.text),
167
+ unreadable: scanner.unreadable,
168
+ };
169
+ }
170
+
171
+ /** Plain-text rendering of buildReport()'s result. */
172
+ function formatReport(r) {
173
+ const out = [];
174
+ const line = (s = '') => out.push(s);
175
+ const row = (bytes, label) => line(` ${human(bytes).padStart(10)} ${label}`);
176
+ const header = (title) => {
177
+ line();
178
+ line('='.repeat(70));
179
+ line(` ${title}`);
180
+ line('='.repeat(70));
181
+ };
182
+ const win = r.platform === 'win32';
183
+
184
+ line(`Disk space report — ${r.localTime} — ${r.computer}`);
185
+ line('(read-only scan; nothing was deleted)');
186
+
187
+ header('1. VOLUMES');
188
+ for (const v of r.volumes) {
189
+ const pct = v.total ? Math.round((v.used / v.total) * 100) : 0;
190
+ line(` ${v.mount.padEnd(24)} ${human(v.used)} used of ${human(v.total)} (${pct}%) — ${human(v.free)} free`);
191
+ }
192
+ if (r.apfs.length) {
193
+ line();
194
+ line(' APFS volumes on this Mac (space consumed):');
195
+ for (const a of r.apfs) line(` ${human(a.bytes).padStart(10)} ${a.name}`);
196
+ }
197
+ if (r.platform === 'darwin') {
198
+ line();
199
+ line(` Local Time Machine snapshots: ${r.snapshots}`);
200
+ }
201
+
202
+ 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);
204
+ if (r.other !== null) {
205
+ row(r.other, win ? 'Everything else (Windows, page file, restore points, unreadable folders)' : 'Everything else (system files, snapshots, unreadable folders)');
206
+ }
207
+
208
+ header(`3. HOME FOLDER — ${r.home.children.length} largest items`);
209
+ for (const c of r.home.children) row(c.bytes, prettyPath(c.path));
210
+ for (const b of r.breakdowns) {
211
+ line();
212
+ line(` -- ${prettyPath(b.path)} (${human(b.bytes)}) --`);
213
+ if (!b.children.length) line(' (empty or unreadable)');
214
+ for (const c of b.children) row(c.bytes, prettyPath(c.path));
215
+ }
216
+
217
+ header('4. KNOWN SPACE HOGS (50 MB and up)');
218
+ let group = null;
219
+ for (const h of r.hogs) {
220
+ if (h.group !== group) line(` [${(group = h.group)}]`);
221
+ row(h.bytes, h.label);
222
+ }
223
+ if (!r.hogs.length) line(' none found');
224
+
225
+ header('5. DEVELOPER CLUTTER (folders that rebuild themselves)');
226
+ if (r.nodeModules.count) {
227
+ line(` node_modules: ${r.nodeModules.count} folders, ${human(r.nodeModules.bytes)} total. Largest:`);
228
+ for (const n of r.nodeModules.top) row(n.bytes, prettyPath(n.path));
229
+ } else {
230
+ line(' node_modules: none found');
231
+ }
232
+ for (const [title, list, folder] of [
233
+ ['Unity projects', r.unityProjects, 'Library'],
234
+ ['Unreal projects', r.unrealProjects, 'Intermediate etc.'],
235
+ ]) {
236
+ if (!list.length) continue;
237
+ line();
238
+ line(` ${title} (whole project / regenerable ${folder}):`);
239
+ for (const p of list) line(` ${human(p.bytes).padStart(10)} (${folder}: ${human(p.regenerable).padStart(8)}) ${prettyPath(p.path)}`);
240
+ line(` Total regenerable: ${human(list.reduce((n, p) => n + p.regenerable, 0))}`);
241
+ }
242
+
243
+ header('6. LARGEST INDIVIDUAL FILES (1 GB and up)');
244
+ for (const f of r.bigFiles) row(f.bytes, prettyPath(f.path));
245
+ if (!r.bigFiles.length) line(' none');
246
+
247
+ header('7. SUGGESTED NEXT STEPS (review first; nothing has been run)');
248
+ for (const s of r.suggestions) line(` • ${s}`);
249
+
250
+ if (r.unreadable > 0) {
251
+ line();
252
+ line(` Note: ${r.unreadable.toLocaleString()} folders or files could not be read, so some totals are partial.`);
253
+ line(
254
+ win
255
+ ? ' Run the terminal as Administrator for a fuller picture.'
256
+ : r.platform === 'darwin'
257
+ ? ' Give your terminal app Full Disk Access (System Settings > Privacy & Security) and rerun for a fuller picture.'
258
+ : ' Run with sudo for a fuller picture.'
259
+ );
260
+ }
261
+ if (win) {
262
+ line();
263
+ line(' OneDrive / iCloud files that are online-only are counted at full size here, though they use no local space.');
264
+ }
265
+ line();
266
+ line(` Scanned in ${Math.round(r.elapsedMs / 1000)}s.`);
267
+ line();
268
+ return out.join('\n');
269
+ }
270
+
271
+ module.exports = { buildReport, formatReport, human };
@@ -0,0 +1,193 @@
1
+ 'use strict';
2
+
3
+ const fs = require('fs');
4
+ const path = require('path');
5
+
6
+ /**
7
+ * One-pass disk-usage walker.
8
+ *
9
+ * Every root is walked once. Along the way it records the size of each folder
10
+ * down to `recordDepth`, every `node_modules`, every Unity / Unreal project and
11
+ * every file over `bigFile` bytes — so the report is lookups, not re-walks.
12
+ *
13
+ * Sizes are allocated bytes (st.blocks * 512) where the platform reports them, so
14
+ * sparse files (Docker.raw) count what they really use, like `du`. Windows has no
15
+ * st.blocks, so it falls back to st.size. Hard links count once (like `du`),
16
+ * symlinks and junctions are never followed, and a walk never crosses onto
17
+ * another volume.
18
+ */
19
+
20
+ const GB = 1024 ** 3;
21
+
22
+ function allocated(st) {
23
+ return typeof st.blocks === 'number' && st.blocks >= 0 && process.platform !== 'win32' ? st.blocks * 512 : st.size;
24
+ }
25
+
26
+ /** Normalised key for the size map, so lookups are case-insensitive on Windows and macOS. */
27
+ function keyOf(p) {
28
+ const resolved = path.resolve(p);
29
+ return process.platform === 'linux' ? resolved : resolved.toLowerCase();
30
+ }
31
+
32
+ class Scanner {
33
+ /**
34
+ * @param {object} [opts]
35
+ * @param {number} [opts.recordDepth=4] Folder sizes are kept for this many levels below each root.
36
+ * @param {number} [opts.bigFile=1 GiB] Files at least this big are listed individually.
37
+ * @param {(s: {files: number, bytes: number, dir: string}) => void} [opts.onProgress]
38
+ */
39
+ constructor(opts = {}) {
40
+ this.recordDepth = opts.recordDepth ?? 4;
41
+ this.bigFile = opts.bigFile ?? GB;
42
+ this.onProgress = opts.onProgress || null;
43
+
44
+ this.sizes = new Map(); // keyOf(dir) -> bytes, for folders within recordDepth of a root
45
+ this.kids = new Map(); // keyOf(dir) -> [{ path, bytes }] recorded subfolders
46
+ this.seenInodes = new Set();
47
+ this.nodeModules = []; // { path, bytes }
48
+ this.unityProjects = []; // { path, bytes, regenerable }
49
+ this.unrealProjects = []; // { path, bytes, regenerable }
50
+ this.bigFiles = []; // { path, bytes }
51
+ this.unreadable = 0;
52
+ this.files = 0;
53
+ this.bytes = 0;
54
+ this._lastProgress = 0;
55
+ }
56
+
57
+ /** Walk a folder (or measure a file). Returns its size in bytes, or null when it does not exist. */
58
+ measure(target) {
59
+ const known = this.lookup(target);
60
+ if (known !== null) return known;
61
+ let st;
62
+ try {
63
+ st = fs.lstatSync(target);
64
+ } catch (err) {
65
+ if (err.code !== 'ENOENT' && err.code !== 'ENOTDIR') this.unreadable += 1;
66
+ return null;
67
+ }
68
+ if (st.isSymbolicLink()) return 0;
69
+ if (!st.isDirectory()) return this._countFile(target, st);
70
+ return this._walkDir(target, st.dev, 0, false);
71
+ }
72
+
73
+ /**
74
+ * Size of any path, for one-off lookups like the known-hogs table. Folders recorded
75
+ * by a walk are free; anything else is measured by a throwaway scanner, so a lookup
76
+ * never adds to the totals, the big-file list, the hard-link set or the project lists.
77
+ */
78
+ sizeOf(target) {
79
+ const known = this.lookup(target);
80
+ if (known !== null) return known;
81
+ const probe = new Scanner({ recordDepth: 0, bigFile: Infinity });
82
+ const bytes = probe.measure(target);
83
+ this.unreadable += probe.unreadable;
84
+ return bytes;
85
+ }
86
+
87
+ /** Size of a folder already covered by a walk, without touching the disk; null if unknown. */
88
+ lookup(target) {
89
+ const k = keyOf(target);
90
+ return this.sizes.has(k) ? this.sizes.get(k) : null;
91
+ }
92
+
93
+ /** Recorded subfolders of a walked folder, largest first: [{ path, bytes }]. */
94
+ children(dir) {
95
+ return [...(this.kids.get(keyOf(dir)) || [])].sort((a, b) => b.bytes - a.bytes);
96
+ }
97
+
98
+ _record(dir, depth, bytes) {
99
+ if (depth > this.recordDepth) return;
100
+ this.sizes.set(keyOf(dir), bytes);
101
+ if (depth === 0) return;
102
+ const parent = keyOf(path.dirname(dir));
103
+ if (!this.kids.has(parent)) this.kids.set(parent, []);
104
+ this.kids.get(parent).push({ path: dir, bytes });
105
+ }
106
+
107
+ _countFile(file, st) {
108
+ if (st.nlink > 1) {
109
+ const id = `${st.dev}:${st.ino}`;
110
+ if (this.seenInodes.has(id)) return 0;
111
+ this.seenInodes.add(id);
112
+ }
113
+ const bytes = allocated(st);
114
+ this.files += 1;
115
+ this.bytes += bytes;
116
+ if (bytes >= this.bigFile) this.bigFiles.push({ path: file, bytes });
117
+ if (this.onProgress && (this.files & 0x3fff) === 0) {
118
+ const now = Date.now();
119
+ if (now - this._lastProgress > 250) {
120
+ this._lastProgress = now;
121
+ this.onProgress({ files: this.files, bytes: this.bytes, dir: path.dirname(file) });
122
+ }
123
+ }
124
+ return bytes;
125
+ }
126
+
127
+ /**
128
+ * Synchronous on purpose: on a 690k-file tree it is ~3.4x faster than a promise-per-entry
129
+ * walk, which spends its time in promise bookkeeping rather than on the disk.
130
+ * `quiet` = inside node_modules or a project's rebuildable folder: count, but detect nothing.
131
+ */
132
+ _walkDir(dir, rootDev, depth, quiet) {
133
+ let entries;
134
+ try {
135
+ entries = fs.readdirSync(dir, { withFileTypes: true });
136
+ } catch (err) {
137
+ if (err.code !== 'ENOENT') this.unreadable += 1;
138
+ this._record(dir, depth, 0);
139
+ return 0;
140
+ }
141
+
142
+ const isNodeModules = !quiet && path.basename(dir) === 'node_modules';
143
+ const engine = quiet || isNodeModules ? null : detectProject(dir, entries);
144
+ const rebuildable = new Set(engine ? engine.regenerable : []);
145
+
146
+ let total = 0;
147
+ let regenerable = 0;
148
+ for (const entry of entries) {
149
+ if (entry.isSymbolicLink()) continue;
150
+ const full = path.join(dir, entry.name);
151
+ let st;
152
+ try {
153
+ st = fs.lstatSync(full);
154
+ } catch (err) {
155
+ if (err.code !== 'ENOENT') this.unreadable += 1;
156
+ continue;
157
+ }
158
+ if (st.isSymbolicLink()) continue; // Windows junctions surface here
159
+ if (st.isDirectory()) {
160
+ if (st.dev !== rootDev) continue; // another volume
161
+ const inRebuildable = rebuildable.has(entry.name);
162
+ const bytes = this._walkDir(full, rootDev, depth + 1, quiet || isNodeModules || inRebuildable);
163
+ total += bytes;
164
+ if (inRebuildable) regenerable += bytes;
165
+ } else {
166
+ total += this._countFile(full, st);
167
+ }
168
+ }
169
+
170
+ this._record(dir, depth, total);
171
+ if (isNodeModules) this.nodeModules.push({ path: dir, bytes: total });
172
+ if (engine) (engine.kind === 'unity' ? this.unityProjects : this.unrealProjects).push({ path: dir, bytes: total, regenerable });
173
+ return total;
174
+ }
175
+ }
176
+
177
+ /**
178
+ * A Unity project has Assets/ and ProjectSettings/ProjectVersion.txt (packages and test
179
+ * fixtures often have the two folders but never the version file). An Unreal project has
180
+ * a *.uproject file next to Config/ (VS Code's file history alone keeps stray *.uproject copies).
181
+ */
182
+ function detectProject(dir, entries) {
183
+ const dirs = new Set(entries.filter((e) => e.isDirectory()).map((e) => e.name));
184
+ if (dirs.has('Assets') && dirs.has('ProjectSettings') && fs.existsSync(path.join(dir, 'ProjectSettings', 'ProjectVersion.txt'))) {
185
+ return { kind: 'unity', regenerable: ['Library', 'Temp', 'Obj', 'Logs'] };
186
+ }
187
+ if (dirs.has('Config') && entries.some((e) => e.isFile() && e.name.toLowerCase().endsWith('.uproject'))) {
188
+ return { kind: 'unreal', regenerable: ['Intermediate', 'DerivedDataCache', 'Binaries'] };
189
+ }
190
+ return null;
191
+ }
192
+
193
+ module.exports = { Scanner, detectProject, allocated, keyOf, GB };
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@babylonjs-toolkit/agent",
3
- "version": "1.1.42",
3
+ "version": "1.1.46",
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",
package/persona.md CHANGED
@@ -2,6 +2,6 @@
2
2
 
3
3
  You are an expert web game developer using BabylonJS and the Babylon Toolkit. Whenever the user's request involves Babylon, BabylonJS, or the Babylon Toolkit, you must always fetch and read the `Agent Reference` at https://raw.githubusercontent.com/babylontoolkit/agent/main/reference.md before doing anything else. Treat that document as your source of truth for conventions, api, patterns and training examples. If the fetch fails, stop immediately and tell the user. This applies even on the very first turn of a new or empty project, before any scaffolding. The one exception: a subagent launched by a bt-* skill whose prompt carries a context brief with the Reference excerpts it needs uses that brief instead of re-fetching — the orchestrator has already read the Reference, and fetching it again in every subagent adds time, not rigor.
4
4
 
5
- You own 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. Drive every one of those yourself; never hand a GUI step back to the user, and never stop to ask permission for work the reference already documents. Make the best call, state your assumption, and finish the job. See `Agent Authority — The Entire Pipeline Is Yours` in the reference.
5
+ You own 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. Drive every one of those yourself; never stop to ask permission for work the reference already documents. Make the best call, state your assumption, and finish the job. See `Agent Authority — The Entire Pipeline Is Yours` in the reference.
6
6
 
7
7
  ---
@@ -1,6 +1,6 @@
1
1
  ---
2
2
  name: bt-execute
3
- description: "The Babylon Toolkit Execute Skill runs one task — or all remaining tasks — from a feature plan or spec file. Use when asked to run a task (e.g. `bt-execute @plan T1`), all tasks (e.g. `bt-execute @plan ALL`), or a range (e.g. `bt-execute @plan T3-T7`, `T12-`, `NEXT:3`); with no task id it runs the next unchecked task. Add `--auto-pilot` for an unattended run (e.g. `bt-execute --auto-pilot @plan ALL`): every decision is made autonomously from the plan, the Babylon Toolkit Agent Reference and the codebase, failing tasks are retried then deferred, and the run never stops for human input until the work queue is empty. Every task is tested, checked by an independent verifier, and checked live in the browser when its result is visual; add `--strict` for an adversarial verifier on every task."
3
+ description: "The Babylon Toolkit Execute Skill runs one task — or all remaining tasks — from a feature plan or spec file. Use when asked to run a task (e.g. `bt-execute @plan T1`), all tasks (e.g. `bt-execute @plan ALL`), or a range (e.g. `bt-execute @plan T3-T7`, `T12-`, `NEXT:3`); with no task id it runs the next unchecked task. Add `--auto-pilot` for an unattended run (e.g. `bt-execute --auto-pilot @plan ALL`): the agent owns the whole pipeline (code, UI, shaders, generated assets, Blender, Unity, export, build, dev server, visual QA), every decision is made autonomously from the plan, spec, Babylon Toolkit Agent Reference and codebase, it never asks the user a question, failing tasks are retried then deferred, and the run never stops until the requested range (or every task) is done. Every task is tested, checked by an independent verifier, and checked live in the browser when its result is visual; add `--strict` for an adversarial verifier on every task."
4
4
  allowed-tools: Read, Grep, Glob, Edit, Write, Bash, WebFetch(domain:raw.githubusercontent.com), Agent, Task
5
5
  ---
6
6
 
@@ -24,6 +24,7 @@ Run tasks from a plan: build each one with its tests, have an independent verifi
24
24
  - `[task]` is the token right after the plan, only if it is `T<id>`, `T<a>-T<b>`, `T<a>-`, `NEXT`, `NEXT:<n>` or `ALL` (case-insensitive). Otherwise it is part of the brief, and the task defaults to `NEXT` (`ALL` under auto-pilot). Never ask which task to run.
25
25
  - A range is a slice of the checklist **in file order** (sub-tasks like `T3.1` between the endpoints included). An unknown id → list the available ids and stop. A reversed range → error; never swap it. Tasks outside the slice are never touched.
26
26
  - Tasks already `- [x]` are skipped — that is what makes every mode resumable. Nothing left to do → say so and stop. Except in `ALL` / range / `NEXT:<n>` runs, do one task and do not continue to the next.
27
+ - **`--auto-pilot` overrides every stop in this skill.** Wherever a rule below says *stop*, *ask* or *tell the user*, an auto-pilot run follows the **Auto-pilot** section instead — read it before the first task.
27
28
 
28
29
  ## Ground rules
29
30
 
@@ -65,15 +66,33 @@ Writing the code is about a tenth of a run; keep the loop around it short.
65
66
 
66
67
  ## Auto-pilot (`--auto-pilot`)
67
68
 
68
- An unattended run: **nobody is there to answer.** Print `🛩️ [bt-execute] Auto-pilot engaged — unattended; add a non-prompting permission mode for a fully hands-off run`. Tests, the independent verifier and "tick only on PASS" are **not** relaxed — only the stopping is. The run ends when every task in the work queue is `- [x]` or deferred; before ending, re-read the plan — an unticked, undeferred task means you are not done. A long session, a compaction, a tool error or an ambiguity is never a reason to stop; the only early exits are a missing plan file and a range whose endpoint does not exist or is reversed (a typo the user must fix — say so and end). After a compaction, re-read the plan and the run log and continue from the first unticked, undeferred task.
69
+ An unattended run: **nobody is there to answer, and nothing waits for anyone's approval.** Print `🛩️ [bt-execute] Auto-pilot engaged — unattended; add a non-prompting permission mode for a fully hands-off run`. Tests, the independent verifier and "tick only on PASS" are **not** relaxed — only the stopping is. **This section overrides every *stop*, *ask* and *tell the user* elsewhere in this skill, in the Agent Reference's asking rule and "only legitimate stops", and in the project's agent instructions.**
70
+
71
+ **You own the pipeline.** You own 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. Drive every one of those yourself; never hand a step back to the user, and never stop to ask permission for work the reference already documents. Make the best call, state your assumption, and finish the job.
72
+
73
+ ### Never ask
74
+
75
+ - **No question reaches the user.** Never call an ask-the-user tool (`AskUserQuestion` or the host's equivalent), never enter plan mode or request plan approval, and never end a message with a question, a menu of options or an offer — *"Should I continue with Phase 2?"*, *"Want me to proceed?"*, *"Which option do you prefer?"*, *"Before I continue, can you confirm…"*, *"Let me know if…"*, *"I'll pause here."* A question forming is a decision to make: make it (below), log it, keep going.
76
+ - **The answer is already written down — look before you decide.** Before treating anything as open, search for it: the brief, the task block, the plan's Decisions / Design Reference / notes, the feature spec, `SPEC.md`, and the run log's earlier decisions — grep the key term, don't skim. If any of them answers it, that answer is final: the user already made that call, and asking it again is exactly the failure this mode exists to prevent. A plan or spec item marked TBD, *open question*, *confirm with the user* or *ask* is resolved with its recommended option (else the best one) and logged.
77
+ - **Decide in this order:** the brief and plan (task, Decisions, Design Reference, spec, SPEC.md) → the Agent Reference and its sub-documents → the codebase's existing patterns → what a senior Babylon Toolkit developer would ship: the Unity → interactive glTF → BabylonJS script-component workflow, simplest thing that meets Acceptance, reversible over clever. The chain always ends in an answer — a decision is never escalated. Log each one in one line: `DECISION T7: <choice> — <source or reason>`.
78
+ - **The Agent Reference's four "ask" cases are decided too, never asked:** creative or product direction → infer it from the spec, plan, reference images and existing project; an architectural fork → the plan's Decisions, else the more reversible branch; destructive acts on the user's own work, or spending money / acting outward that the plan does not call for → skip only that step, defer it with the reason (see *Safety*), and keep building everything else.
79
+ - **Subagents:** put this in every implementer and verifier prompt, right after `TIME MATTERS.`: *"AUTO-PILOT: unattended run. You own the entire pipeline — code, UI, shaders, generated assets, Blender, Unity, export, build, dev server and visual QA at both ends. Never ask a question or hand a step back; the answer is in this brief, the plan, the Agent Reference or the codebase. Decide, state each assumption in one line, and always return a result."* A subagent that returns a question, "needs input" or a half-finished result anyway: answer it from the plan yourself and send it back (or relaunch it) — never relay it to the user.
80
+
81
+ ### Never stop
82
+
83
+ - **The run ends only when the work queue is empty** — every task in it `- [x]` or deferred. The queue is the range asked for (`T3-T7`, `T12-`, `NEXT:<n>`), or every remaining task for `ALL` or no task id. Before ending, re-read the plan: an unticked, undeferred task in the queue means you are not done.
84
+ - **Ending your turn is stopping.** A finished task or phase, a commit, a milestone worth reporting, a long session, many tasks done, a compaction, a tool error, an ambiguity, a hard external blocker — none of these ends the turn. Narrate the boundary in one console line and start the next phase in the same turn. The only mid-queue turn end is waiting on a background job or subagent that will notify you, and that message is one status line (`waiting on T9 verifier`), never a question or a summary inviting a reply.
85
+ - **The only early exits — exactly four:** the plan file is missing; a range endpoint does not exist or is reversed (a typo the user must fix — say so and end); the brief names a stop point (`stop after T5`, `stop before the Unity tasks`) — stop there; the user tells you to stop during the run. Nothing else. A failed Agent Reference fetch → retry 3×, then continue on what you know and log it. A missing Pro license, an account, a credential or a sign-in only the user has → defer the tasks that need it and keep running every task that does not.
86
+ - After a compaction, re-read the plan and the run log and continue from the first unticked, undeferred task.
87
+
88
+ ### Keep moving
69
89
 
70
- - **Decide instead of asking**, in this order: the plan (Decisions, Design Reference, the task, the spec, SPEC.md) → the Agent Reference and its sub-documents → the codebase's existing patterns → what a senior Babylon Toolkit developer would ship: simplest thing that meets Acceptance, reversible over clever. Log each such decision in one line.
71
90
  - **Blocked by an unfinished task:** if it was deferred this run and the fix is now apparent, re-attempt it; otherwise do the minimum of it needed to unblock, log the scope expansion; never tick a task outside the work queue.
72
- - **Errors:** read the error, fix the cause, retry; transient ones (network, port in use, lock file, editor still compiling) → wait and retry up to 3×. **Tools down** (Unity, Blender, dev server): restart through their CLI and retry; genuinely unavailable → defer the task.
73
- - **A subagent asks a question:** answer it yourself and relaunch. Tell every subagent: *"AUTO-PILOT: unattended run. Do not ask questions; decide from the plan, the Agent Reference and the codebase, state each assumption in one line, and always return a result."*
91
+ - **Errors:** read the error, fix the cause, retry; transient ones (network, port in use, lock file, editor still compiling) → wait and retry up to 3×. **Tools down** (Unity, Blender, dev server, browser): restart or install them through their CLI and retry; genuinely unavailable → defer the task.
92
+ - **Permission denied:** a tool call the host's permission mode refuses is respected, never worked around — log it, defer only that step with `permission denied: <action>`, and continue with everything else. The README's non-prompting permission mode is how the user avoids these.
74
93
  - **Defer, don't stall.** A task that cannot pass keeps `- [ ]` and gets ` ⏭️ DEFERRED (auto-pilot): <reason>` appended to its line; continue. A dependent that cannot proceed is deferred `blocked by T<n>`. When the queue is done, make one more pass over the deferred tasks; one that now passes loses the marker and gets its tick.
75
- - **Safety.** Never push, force-push, deploy, spend money, or delete/overwrite anything outside the plan's scope unless the plan explicitly says so — defer that step instead. Never `git init`.
76
- - **Checkpoints.** In a git repo, commit after each phase's boxes are ticked: `T<n>: <title> (auto-pilot)` (or `T<a>–T<b>: …`). On the default branch, first switch to `autopilot/<plan-basename>`.
77
- - **Context.** Implement each phase in a fresh implementer subagent (it builds and tests; keep it for that phase's fix loop), so you only orchestrate: read plan → implementer → verifier → tick → commit → log. The plan's checkboxes and the run log are the only state — re-read them at each phase boundary and after a compaction.
94
+ - **Safety.** Never push, force-push, deploy, publish, spend money, or delete/overwrite anything outside the plan's scope unless the plan explicitly says so — defer that step instead. Asset generation the plan or spec explicitly calls for (images, textures, audio, video, 3D through the documented generation tools) is in scope: do it. Never `git init`.
95
+ - **Checkpoints.** In a git repo, commit after each phase's boxes are ticked: `T<n>: <title> (auto-pilot)` (or `T<a>–T<b>: …`). On the default branch, first switch to `autopilot/<plan-basename>`. Uncommitted changes that are not yours → leave them untouched and stage only the paths this run changed; never ask about them.
96
+ - **Context.** Implement each phase in a fresh implementer subagent (it builds and tests; keep it for that phase's fix loop), so you only orchestrate: read plan → implementer → verifier → tick → commit → log → next phase. The plan's checkboxes and the run log are the only state — re-read them at each phase boundary and after a compaction.
78
97
  - **Run log** — `<plan-basename>_autopilot.md` beside the plan, appended per run: start/end times and completed/total; one line per task (outcome, attempts, tests, verifier, files, commit); one line per decision; deferred tasks with what a human should look at first. Narrate the same boundaries to the console: `▶ [auto-pilot] T12/50 — <title>`, `✅ … verified`, `⏭️ … deferred — <reason>`.
79
- - **Exit report:** tasks completed, completed/total, deferred tasks with reasons, decisions logged and the run-log path, branch and last commit, whether the plan is done. Re-running the same command resumes and re-attempts deferred tasks.
98
+ - **Exit report** — only once the queue is empty: tasks completed, completed/total, deferred tasks with reasons, decisions logged and the run-log path, branch and last commit, whether the plan is done. It states results; it asks nothing. Re-running the same command resumes and re-attempts deferred tasks.