@babylonjs-toolkit/agent 1.1.64 → 1.1.66
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 +33 -4
- package/bin/bt-agent.js +64 -4
- package/lib/claude-settings.js +77 -0
- package/lib/doctor.js +36 -0
- package/lib/install.js +59 -3
- package/lib/persona.js +21 -2
- package/lib/reference.js +400 -0
- package/package.json +1 -1
- package/persona.md +1 -1
- package/scripts/postinstall.js +6 -0
- package/skills/bt-design/references/3d-hero-scroll.md +2 -2
- package/skills/bt-execute/SKILL.md +4 -4
- package/skills/bt-gauntlet/SKILL.md +2 -2
- package/skills/bt-gauntlet/references/unity-pipeline.md +1 -1
- package/skills/bt-gauntlet/references/workspace.md +1 -1
- package/skills/bt-plan/SKILL.md +2 -2
- package/skills/bt-prototype/SKILL.md +1 -1
- package/skills/bt-recon/SKILL.md +2 -2
- package/skills/bt-spec/SKILL.md +2 -2
package/README.md
CHANGED
|
@@ -1,4 +1,4 @@
|
|
|
1
|
-
# Babylon Toolkit Desktop Agent (1.1.
|
|
1
|
+
# Babylon Toolkit Desktop Agent (1.1.66)
|
|
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
|
|
|
@@ -18,9 +18,10 @@ npx @babylonjs-toolkit/agent install
|
|
|
18
18
|
```
|
|
19
19
|
|
|
20
20
|
That installs **every skill** into every skills directory and the **Agent Persona** into every
|
|
21
|
-
global instruction file, on macOS, Linux and Windows
|
|
22
|
-
|
|
23
|
-
|
|
21
|
+
global instruction file, on macOS, Linux and Windows, and downloads the **Agent Reference** with
|
|
22
|
+
all its sub-documents into `~/.claude/toolkit/reference/` (see *The local Agent Reference* below).
|
|
23
|
+
Codex targets also enable outbound network access in their workspace-write configuration.
|
|
24
|
+
Restart your agent session to pick up the skills, instructions and configuration.
|
|
24
25
|
|
|
25
26
|
### Commands
|
|
26
27
|
|
|
@@ -43,9 +44,37 @@ up the skills, instructions and configuration.
|
|
|
43
44
|
| `--no-persona` | Install skills only; leave instruction files alone |
|
|
44
45
|
| `--persona-only` | Install/refresh the Agent Persona only; do not copy skills |
|
|
45
46
|
| `--no-self-update` | `update` only: reinstall the bundled files; do not fetch npm |
|
|
47
|
+
| `--no-reference` | Do not download the Agent Reference; agents read it from GitHub |
|
|
48
|
+
| `--reference-from <dir>` | Install the Agent Reference from a local checkout instead of GitHub (offline, or to try unpublished Reference edits) |
|
|
46
49
|
| `--dry-run` | Print what would happen and change nothing |
|
|
47
50
|
| `--json` | Machine-readable output |
|
|
48
51
|
|
|
52
|
+
### The local Agent Reference
|
|
53
|
+
|
|
54
|
+
Agents read the [Agent Reference](https://github.com/babylontoolkit/agent) before any Babylon work.
|
|
55
|
+
`bt-agent install` and `bt-agent update` download it — `reference.md`, every sub-document, the training
|
|
56
|
+
examples and the 2.7 MB API declarations — into `~/.claude/toolkit/reference/`, beside the Unity helper
|
|
57
|
+
scripts the Reference keeps in `~/.claude/toolkit/` (a `--project` install uses `.claude/toolkit/reference/`
|
|
58
|
+
in the project). Every link into the Reference repo is rewritten to the local file — in the copy and in the
|
|
59
|
+
installed skills — and the Reference's `curl … -o ~/.claude/toolkit/…` download commands become `cp`
|
|
60
|
+
from the copy, so agents read files instead of fetching pages:
|
|
61
|
+
|
|
62
|
+
- **Faster and more reliable** — no network round trip per document, and no failed fetch stopping a run.
|
|
63
|
+
- **Fewer tokens** — an agent searches a large document and reads only the section it needs, where a
|
|
64
|
+
fetch is all or nothing (`unity-exporter-cli.md` and `unity-authoring-recipes.md` are about 30k tokens
|
|
65
|
+
each); and nothing reaches it summarized or cut short.
|
|
66
|
+
- **The same in every agent** — Claude Code, Codex, Copilot, Gemini CLI and Antigravity all read files.
|
|
67
|
+
- **In step with the skills** — the copy is the one the installed skills were written against.
|
|
68
|
+
|
|
69
|
+
The copy comes from GitHub at install time, not from the npm package, so a Reference edit reaches agents
|
|
70
|
+
with `bt-agent update` — no npm release needed. If the download fails, an existing copy is kept; with no
|
|
71
|
+
copy at all, the skills and persona keep the GitHub addresses and agents read the Reference from there.
|
|
72
|
+
The persona names the local folder and keeps GitHub as the fallback for any file that is missing.
|
|
73
|
+
Claude Code asks before reading outside the project, so a global install adds one read-only rule —
|
|
74
|
+
`Read(~/.claude/toolkit/reference/**)` — to `~/.claude/settings.json` (uninstall removes it, and only if
|
|
75
|
+
the installer added it). `bt-agent doctor` checks that every local link resolves and says when GitHub has a
|
|
76
|
+
newer Reference.
|
|
77
|
+
|
|
49
78
|
### Disk usage report
|
|
50
79
|
|
|
51
80
|
```bash
|
package/bin/bt-agent.js
CHANGED
|
@@ -12,7 +12,8 @@ const USAGE = `
|
|
|
12
12
|
@babylonjs-toolkit/agent ${version}
|
|
13
13
|
|
|
14
14
|
Installs the Babylon Toolkit agent skills and Agent Persona for every
|
|
15
|
-
supported AI client, on macOS, Linux and Windows
|
|
15
|
+
supported AI client, on macOS, Linux and Windows, with a local copy of
|
|
16
|
+
the Agent Reference in ~/.claude/toolkit/reference. Codex targets also
|
|
16
17
|
enable outbound network access in their workspace-write configuration.
|
|
17
18
|
|
|
18
19
|
Usage
|
|
@@ -36,6 +37,8 @@ Options
|
|
|
36
37
|
--persona-only Install/refresh the Agent Persona only; do not copy skills
|
|
37
38
|
--no-migrate Leave a legacy unmarked persona in place, do not convert it
|
|
38
39
|
--no-self-update update: reinstall the bundled files only; do not fetch npm
|
|
40
|
+
--no-reference Do not download the Agent Reference; agents read it from GitHub
|
|
41
|
+
--reference-from d Install the Agent Reference from a local checkout instead of GitHub
|
|
39
42
|
--dry-run Print what would happen; change nothing
|
|
40
43
|
--json Machine-readable output
|
|
41
44
|
-h, --help Show this help
|
|
@@ -63,6 +66,8 @@ function parseArgs(argv) {
|
|
|
63
66
|
skills: true,
|
|
64
67
|
migrate: true,
|
|
65
68
|
selfUpdate: true,
|
|
69
|
+
reference: true,
|
|
70
|
+
referenceFrom: null,
|
|
66
71
|
dryRun: false,
|
|
67
72
|
json: false,
|
|
68
73
|
help: false,
|
|
@@ -98,6 +103,13 @@ function parseArgs(argv) {
|
|
|
98
103
|
case '--no-self-update':
|
|
99
104
|
opts.selfUpdate = false;
|
|
100
105
|
break;
|
|
106
|
+
case '--no-reference':
|
|
107
|
+
opts.reference = false;
|
|
108
|
+
break;
|
|
109
|
+
case '--reference-from':
|
|
110
|
+
opts.referenceFrom = argv[++i] || null;
|
|
111
|
+
if (!opts.referenceFrom) throw new Error('--reference-from needs a folder');
|
|
112
|
+
break;
|
|
101
113
|
case '--dry-run':
|
|
102
114
|
opts.dryRun = true;
|
|
103
115
|
break;
|
|
@@ -108,7 +120,9 @@ function parseArgs(argv) {
|
|
|
108
120
|
opts.ids = String(argv[++i] || '').split(',').map((s) => s.trim()).filter(Boolean);
|
|
109
121
|
break;
|
|
110
122
|
default:
|
|
111
|
-
if (arg.startsWith('--
|
|
123
|
+
if (arg.startsWith('--reference-from=')) {
|
|
124
|
+
opts.referenceFrom = arg.slice('--reference-from='.length);
|
|
125
|
+
} else if (arg.startsWith('--targets=')) {
|
|
112
126
|
opts.ids = arg.slice('--targets='.length).split(',').map((s) => s.trim()).filter(Boolean);
|
|
113
127
|
} else if (arg.startsWith('-')) {
|
|
114
128
|
throw new Error(`Unknown option: ${arg}`);
|
|
@@ -150,6 +164,8 @@ function printInstall(report) {
|
|
|
150
164
|
if (entry.backup) console.log(` backup: ${prettyPath(entry.backup)}`);
|
|
151
165
|
}
|
|
152
166
|
|
|
167
|
+
printReference(report);
|
|
168
|
+
|
|
153
169
|
if (report.pruned.length) {
|
|
154
170
|
console.log('');
|
|
155
171
|
for (const p of report.pruned) console.log(` pruned ${prettyPath(p)} (no longer shipped)`);
|
|
@@ -166,6 +182,39 @@ function printInstall(report) {
|
|
|
166
182
|
}
|
|
167
183
|
}
|
|
168
184
|
|
|
185
|
+
function printReference(report) {
|
|
186
|
+
const entry = report.reference;
|
|
187
|
+
if (!entry) return;
|
|
188
|
+
const commit = entry.commit ? entry.commit.slice(0, 7) : 'unknown commit';
|
|
189
|
+
const where = ` reference ${prettyPath(entry.dir)}`;
|
|
190
|
+
switch (entry.status) {
|
|
191
|
+
case 'installed':
|
|
192
|
+
console.log(`${where} — ${entry.source}, ${commit}: ${entry.files} files, ${entry.rewrittenLinks + entry.rewrittenDownloads} links now local`);
|
|
193
|
+
break;
|
|
194
|
+
case 'kept':
|
|
195
|
+
console.log(`${where} — kept the existing copy (${commit}); could not refresh it: ${entry.reason}`);
|
|
196
|
+
break;
|
|
197
|
+
case 'unavailable':
|
|
198
|
+
console.log(`${where} — not installed: ${entry.reason}`);
|
|
199
|
+
console.log(' agents will read the Agent Reference from GitHub until `bt-agent update` succeeds');
|
|
200
|
+
break;
|
|
201
|
+
case 'would-install':
|
|
202
|
+
console.log(`${where} — would download ${entry.source}`);
|
|
203
|
+
break;
|
|
204
|
+
default:
|
|
205
|
+
console.log(`${where} — ${commit}`);
|
|
206
|
+
}
|
|
207
|
+
if (entry.links && entry.links.broken.length) {
|
|
208
|
+
console.log(` ${entry.links.broken.length} local link(s) do not resolve:`);
|
|
209
|
+
for (const broken of entry.links.broken) console.log(` ${broken}`);
|
|
210
|
+
}
|
|
211
|
+
for (const permission of report.permissions || []) {
|
|
212
|
+
if (permission.action === 'unchanged') continue;
|
|
213
|
+
console.log(` allow ${prettyPath(permission.file)} — ${permission.rule} ${permission.action}`);
|
|
214
|
+
if (permission.note) console.log(` ${permission.note}`);
|
|
215
|
+
}
|
|
216
|
+
}
|
|
217
|
+
|
|
169
218
|
function printSelfUpdate(result) {
|
|
170
219
|
switch (result.status) {
|
|
171
220
|
case 'upgraded':
|
|
@@ -225,6 +274,14 @@ function printDoctor(result) {
|
|
|
225
274
|
console.log('INSTALL FAILED — missing:');
|
|
226
275
|
for (const m of result.missing) console.log(` ${prettyPath(m)}`);
|
|
227
276
|
}
|
|
277
|
+
const ref = result.reference;
|
|
278
|
+
if (ref && ref.present) {
|
|
279
|
+
const freshness = ref.latest ? (ref.latest === ref.commit ? ', current with GitHub' : '') : '';
|
|
280
|
+
console.log(`\n reference ${prettyPath(ref.dir)} — ${ref.commit ? ref.commit.slice(0, 7) : 'unknown commit'}, ${ref.files} files, ${ref.links.checked} local links checked${freshness}`);
|
|
281
|
+
} else if (ref) {
|
|
282
|
+
console.log(`\n reference ${prettyPath(ref.dir)}`);
|
|
283
|
+
}
|
|
284
|
+
for (const warning of (ref && ref.warnings) || []) console.log(` ${warning}`);
|
|
228
285
|
}
|
|
229
286
|
|
|
230
287
|
function targetsJson(mode, projectRoot) {
|
|
@@ -295,6 +352,8 @@ function main() {
|
|
|
295
352
|
persona: opts.persona,
|
|
296
353
|
skills: opts.skills,
|
|
297
354
|
migrate: opts.migrate,
|
|
355
|
+
reference: opts.reference,
|
|
356
|
+
referenceFrom: opts.referenceFrom,
|
|
298
357
|
dryRun: opts.dryRun,
|
|
299
358
|
};
|
|
300
359
|
|
|
@@ -384,7 +443,8 @@ function main() {
|
|
|
384
443
|
} else if (!report.manifestFound) {
|
|
385
444
|
console.log('\nNothing to uninstall — no install manifest found.\n');
|
|
386
445
|
} else {
|
|
387
|
-
console.log(`\n${opts.dryRun ? 'Would remove' : 'Removed'} ${report.removed.length}
|
|
446
|
+
console.log(`\n${opts.dryRun ? 'Would remove' : 'Removed'} ${report.removed.length} folder(s) (skills and the local Agent Reference).`);
|
|
447
|
+
for (const p of report.permissions) if (p.action === 'removed') console.log(` allow ${prettyPath(p.file)} — ${p.rule} removed`);
|
|
388
448
|
for (const p of report.persona) console.log(` persona ${prettyPath(p.file)} — ${p.action}`);
|
|
389
449
|
console.log('');
|
|
390
450
|
}
|
|
@@ -392,7 +452,7 @@ function main() {
|
|
|
392
452
|
}
|
|
393
453
|
|
|
394
454
|
case 'doctor': {
|
|
395
|
-
const result = doctor(common);
|
|
455
|
+
const result = doctor({ ...common, checkRemote: true });
|
|
396
456
|
if (opts.json) console.log(JSON.stringify(result, null, 2));
|
|
397
457
|
else {
|
|
398
458
|
printDoctor(result);
|
|
@@ -0,0 +1,77 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const path = require('path');
|
|
5
|
+
|
|
6
|
+
/**
|
|
7
|
+
* Claude Code asks before reading a file outside the session's project. The local Agent Reference
|
|
8
|
+
* lives in the home folder, so without an allow rule every session would stop at its first read.
|
|
9
|
+
* This adds one read-only rule for that folder to Claude Code's settings — and removes only that
|
|
10
|
+
* rule on uninstall.
|
|
11
|
+
*/
|
|
12
|
+
|
|
13
|
+
function readSettings(file) {
|
|
14
|
+
if (!fs.existsSync(file)) return { settings: {}, exists: false };
|
|
15
|
+
const text = fs.readFileSync(file, 'utf8');
|
|
16
|
+
if (text.trim() === '') return { settings: {}, exists: true };
|
|
17
|
+
const settings = JSON.parse(text);
|
|
18
|
+
if (!settings || typeof settings !== 'object' || Array.isArray(settings)) throw new Error('settings are not a JSON object');
|
|
19
|
+
return { settings, exists: true };
|
|
20
|
+
}
|
|
21
|
+
|
|
22
|
+
function writeSettings(file, settings, exists) {
|
|
23
|
+
let backup = null;
|
|
24
|
+
if (exists) {
|
|
25
|
+
backup = `${file}.bak`;
|
|
26
|
+
fs.copyFileSync(file, backup);
|
|
27
|
+
}
|
|
28
|
+
fs.mkdirSync(path.dirname(file), { recursive: true });
|
|
29
|
+
fs.writeFileSync(file, JSON.stringify(settings, null, 2) + '\n', 'utf8');
|
|
30
|
+
return backup;
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
/** Add `rule` to `permissions.allow`. A settings file that is not valid JSON is left alone. */
|
|
34
|
+
function addAllowRule(file, rule, { dryRun = false } = {}) {
|
|
35
|
+
let current;
|
|
36
|
+
try {
|
|
37
|
+
current = readSettings(file);
|
|
38
|
+
} catch (error) {
|
|
39
|
+
return { file, rule, action: 'skipped', note: `not valid JSON (${error.message}) — add ${rule} to permissions.allow yourself` };
|
|
40
|
+
}
|
|
41
|
+
const { settings, exists } = current;
|
|
42
|
+
const permissions = settings.permissions && typeof settings.permissions === 'object' ? settings.permissions : {};
|
|
43
|
+
const allow = Array.isArray(permissions.allow) ? permissions.allow : [];
|
|
44
|
+
if (allow.includes(rule)) return { file, rule, action: 'unchanged' };
|
|
45
|
+
if (dryRun) return { file, rule, action: exists ? 'updated' : 'created' };
|
|
46
|
+
settings.permissions = { ...permissions, allow: [...allow, rule] };
|
|
47
|
+
const backup = writeSettings(file, settings, exists);
|
|
48
|
+
return { file, rule, action: exists ? 'updated' : 'created', backup };
|
|
49
|
+
}
|
|
50
|
+
|
|
51
|
+
/** Remove `rule` from `permissions.allow`, and nothing else. */
|
|
52
|
+
function removeAllowRule(file, rule, { dryRun = false } = {}) {
|
|
53
|
+
let current;
|
|
54
|
+
try {
|
|
55
|
+
current = readSettings(file);
|
|
56
|
+
} catch {
|
|
57
|
+
return { file, rule, action: 'skipped' };
|
|
58
|
+
}
|
|
59
|
+
const { settings, exists } = current;
|
|
60
|
+
const allow = settings.permissions && Array.isArray(settings.permissions.allow) ? settings.permissions.allow : [];
|
|
61
|
+
if (!exists || !allow.includes(rule)) return { file, rule, action: 'absent' };
|
|
62
|
+
if (dryRun) return { file, rule, action: 'removed' };
|
|
63
|
+
settings.permissions.allow = allow.filter((entry) => entry !== rule);
|
|
64
|
+
const backup = writeSettings(file, settings, exists);
|
|
65
|
+
return { file, rule, action: 'removed', backup };
|
|
66
|
+
}
|
|
67
|
+
|
|
68
|
+
function hasAllowRule(file, rule) {
|
|
69
|
+
try {
|
|
70
|
+
const allow = (readSettings(file).settings.permissions || {}).allow;
|
|
71
|
+
return Array.isArray(allow) && allow.includes(rule);
|
|
72
|
+
} catch {
|
|
73
|
+
return false;
|
|
74
|
+
}
|
|
75
|
+
}
|
|
76
|
+
|
|
77
|
+
module.exports = { addAllowRule, removeAllowRule, hasAllowRule };
|
package/lib/doctor.js
CHANGED
|
@@ -7,6 +7,9 @@ const { resolveTargets } = require('./targets');
|
|
|
7
7
|
const { listSkills } = require('./payload');
|
|
8
8
|
const { hasPersona } = require('./persona');
|
|
9
9
|
const { hasCodexNetwork } = require('./codex-config');
|
|
10
|
+
const { hasAllowRule } = require('./claude-settings');
|
|
11
|
+
const reference = require('./reference');
|
|
12
|
+
const { resolveTargetPath } = require('./paths');
|
|
10
13
|
const { readSettings } = require('./bridge/config');
|
|
11
14
|
const { serviceStatus, hostDeps } = require('./bridge/service');
|
|
12
15
|
const { discoverUnity } = require('./bridge/unity/discover');
|
|
@@ -28,6 +31,7 @@ function doctor(opts = {}) {
|
|
|
28
31
|
legacyCodex = false,
|
|
29
32
|
persona = true,
|
|
30
33
|
skills: checkSkills = true,
|
|
34
|
+
checkRemote = false,
|
|
31
35
|
} = opts;
|
|
32
36
|
|
|
33
37
|
const resolved = resolveTargets({ mode, projectRoot, ids, legacyCodex });
|
|
@@ -53,6 +57,8 @@ function doctor(opts = {}) {
|
|
|
53
57
|
if (!hasCodexNetwork(file)) missing.push(`${file} (sandbox_workspace_write.network_access = true)`);
|
|
54
58
|
}
|
|
55
59
|
|
|
60
|
+
const referenceReport = checkReference({ mode, projectRoot, resolved, skills, checkSkills, checkRemote });
|
|
61
|
+
|
|
56
62
|
// Informational only (D46): a user who only wants skills must still get INSTALL OK.
|
|
57
63
|
const { servers } = readSettings();
|
|
58
64
|
let unityCli = false;
|
|
@@ -83,6 +89,7 @@ function doctor(opts = {}) {
|
|
|
83
89
|
instructionFiles: resolved.instructionFiles.map((f) => f.file),
|
|
84
90
|
configFiles: resolved.configFiles.map((f) => f.file),
|
|
85
91
|
},
|
|
92
|
+
reference: referenceReport,
|
|
86
93
|
bridge: {
|
|
87
94
|
paired: servers.length > 0,
|
|
88
95
|
server: servers.length ? servers[0].server : null,
|
|
@@ -95,4 +102,33 @@ function doctor(opts = {}) {
|
|
|
95
102
|
};
|
|
96
103
|
}
|
|
97
104
|
|
|
105
|
+
/**
|
|
106
|
+
* The local Agent Reference — informational, never part of `ok`: without it agents read the Reference
|
|
107
|
+
* from GitHub. Reports the copy, every local link that does not resolve, a missing Claude Code allow
|
|
108
|
+
* rule, and (for `bt-agent doctor`) whether GitHub has moved on since the copy was made.
|
|
109
|
+
*/
|
|
110
|
+
function checkReference({ mode, projectRoot, resolved, skills, checkSkills, checkRemote }) {
|
|
111
|
+
const dir = reference.referenceDir(mode, projectRoot);
|
|
112
|
+
const metadata = reference.readMetadata(dir);
|
|
113
|
+
if (!metadata || !reference.isUsable(dir)) {
|
|
114
|
+
return { dir, present: false, warnings: ['not installed — agents read the Agent Reference from GitHub; run `bt-agent update`'] };
|
|
115
|
+
}
|
|
116
|
+
const folders = [dir, ...(checkSkills ? resolved.skillDirs.flatMap(({ dir: skillsDir }) => skills.map((skill) => path.join(skillsDir, skill.name))) : [])];
|
|
117
|
+
const links = reference.checkLinks(dir, folders);
|
|
118
|
+
const warnings = links.broken.map((entry) => `broken link: ${entry}`);
|
|
119
|
+
|
|
120
|
+
const claude = resolved.selected.find((target) => target.id === 'claude');
|
|
121
|
+
if (claude && mode === 'global') {
|
|
122
|
+
const settingsFile = path.join(path.dirname(resolveTargetPath(claude.global.instructions, mode, projectRoot)), 'settings.json');
|
|
123
|
+
if (!hasAllowRule(settingsFile, reference.CLAUDE_READ_RULE)) warnings.push(`${settingsFile} has no ${reference.CLAUDE_READ_RULE} — Claude Code will ask before each read`);
|
|
124
|
+
}
|
|
125
|
+
|
|
126
|
+
let latest = null;
|
|
127
|
+
if (checkRemote && metadata.commit) {
|
|
128
|
+
latest = reference.latestCommit();
|
|
129
|
+
if (latest && latest !== metadata.commit) warnings.push(`GitHub has a newer Agent Reference (${latest.slice(0, 7)}) — run \`bt-agent update\``);
|
|
130
|
+
}
|
|
131
|
+
return { dir, present: true, commit: metadata.commit, installedAt: metadata.installedAt, files: metadata.files, links, latest, warnings };
|
|
132
|
+
}
|
|
133
|
+
|
|
98
134
|
module.exports = { doctor };
|
package/lib/install.js
CHANGED
|
@@ -7,8 +7,10 @@ const { resolveTargets } = require('./targets');
|
|
|
7
7
|
const { listSkills, copyDir } = require('./payload');
|
|
8
8
|
const { applyPersona, removePersona, personaText } = require('./persona');
|
|
9
9
|
const { applyCodexConfig } = require('./codex-config');
|
|
10
|
+
const { addAllowRule, removeAllowRule } = require('./claude-settings');
|
|
11
|
+
const reference = require('./reference');
|
|
10
12
|
const manifest = require('./manifest');
|
|
11
|
-
const { manifestPath } = require('./paths');
|
|
13
|
+
const { manifestPath, resolveTargetPath } = require('./paths');
|
|
12
14
|
|
|
13
15
|
const { version } = require('../package.json');
|
|
14
16
|
|
|
@@ -16,6 +18,10 @@ const { version } = require('../package.json');
|
|
|
16
18
|
* Copy every shipped skill into every target skills directory, refresh the Agent
|
|
17
19
|
* Persona in every target instruction file, and record the result.
|
|
18
20
|
*
|
|
21
|
+
* With skills, the Agent Reference is downloaded into `~/.claude/toolkit/reference/` (see
|
|
22
|
+
* reference.js) and the installed skills and the persona point at that local copy. Without a
|
|
23
|
+
* usable copy they keep the GitHub addresses, so agents still work.
|
|
24
|
+
*
|
|
19
25
|
* Each skill folder is replaced wholesale (delete-then-copy) so files removed
|
|
20
26
|
* upstream do not linger, but only folder names this package ships are ever
|
|
21
27
|
* deleted — a user's own `bt-*` skill is untouched.
|
|
@@ -31,6 +37,8 @@ function install(opts = {}) {
|
|
|
31
37
|
migrate = true,
|
|
32
38
|
dryRun = false,
|
|
33
39
|
prune = true,
|
|
40
|
+
reference: installLocalReference = true,
|
|
41
|
+
referenceFrom = null,
|
|
34
42
|
} = opts;
|
|
35
43
|
|
|
36
44
|
if (!installSkills && !persona) {
|
|
@@ -51,9 +59,20 @@ function install(opts = {}) {
|
|
|
51
59
|
persona: [],
|
|
52
60
|
config: [],
|
|
53
61
|
pruned: [],
|
|
62
|
+
reference: null,
|
|
63
|
+
permissions: [],
|
|
54
64
|
manifest: manifestPath(mode, projectRoot),
|
|
55
65
|
};
|
|
56
66
|
|
|
67
|
+
// The Reference first: the skills and persona written below point at it only when it is usable.
|
|
68
|
+
const referenceDir = reference.referenceDir(mode, projectRoot);
|
|
69
|
+
if (installLocalReference && installSkills) {
|
|
70
|
+
report.reference = reference.installReference({ mode, projectRoot, from: referenceFrom, dryRun });
|
|
71
|
+
} else if (installLocalReference && reference.isUsable(referenceDir)) {
|
|
72
|
+
report.reference = { dir: referenceDir, status: 'unchanged', ...reference.readMetadata(referenceDir) };
|
|
73
|
+
}
|
|
74
|
+
const localReference = installLocalReference && !dryRun && reference.isUsable(referenceDir) ? referenceDir : null;
|
|
75
|
+
|
|
57
76
|
// Preflight every merge before changing installed skills or instructions.
|
|
58
77
|
for (const { file } of resolved.configFiles) applyCodexConfig(file, { dryRun: true });
|
|
59
78
|
for (const { file, targets } of resolved.configFiles) {
|
|
@@ -68,6 +87,7 @@ function install(opts = {}) {
|
|
|
68
87
|
if (!dryRun) {
|
|
69
88
|
fs.rmSync(dest, { recursive: true, force: true });
|
|
70
89
|
copyDir(skill.src, dest);
|
|
90
|
+
if (localReference) reference.rewriteFolder(dest, localReference);
|
|
71
91
|
}
|
|
72
92
|
}
|
|
73
93
|
|
|
@@ -86,8 +106,23 @@ function install(opts = {}) {
|
|
|
86
106
|
report.skillDirs.push({ dir, targets, skills: skills.map((s) => s.name) });
|
|
87
107
|
}
|
|
88
108
|
|
|
109
|
+
if (report.reference) {
|
|
110
|
+
report.reference.links = localReference
|
|
111
|
+
? reference.checkLinks(localReference, [localReference, ...report.skillDirs.flatMap(({ dir }) => report.skills.map((name) => path.join(dir, name)))])
|
|
112
|
+
: null;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
// Claude Code asks before reading outside the project; the global copy gets one read-only allow rule.
|
|
116
|
+
if (localReference && mode === 'global') {
|
|
117
|
+
const claude = resolved.selected.find((target) => target.id === 'claude');
|
|
118
|
+
if (claude) {
|
|
119
|
+
const settingsFile = path.join(path.dirname(resolveTargetPath(claude.global.instructions, mode, projectRoot)), 'settings.json');
|
|
120
|
+
report.permissions.push(addAllowRule(settingsFile, reference.CLAUDE_READ_RULE, { dryRun }));
|
|
121
|
+
}
|
|
122
|
+
}
|
|
123
|
+
|
|
89
124
|
if (persona) {
|
|
90
|
-
const text = personaText();
|
|
125
|
+
const text = personaText({ referenceDir: localReference });
|
|
91
126
|
for (const { file, targets } of resolved.instructionFiles) {
|
|
92
127
|
const result = applyPersona(file, { text, dryRun, migrate });
|
|
93
128
|
report.persona.push({ ...result, targets });
|
|
@@ -107,6 +142,11 @@ function install(opts = {}) {
|
|
|
107
142
|
skillDirs,
|
|
108
143
|
config: report.config,
|
|
109
144
|
persona: report.persona.map(({ file, action }) => ({ file, action })),
|
|
145
|
+
reference: report.reference && report.reference.status !== 'unavailable'
|
|
146
|
+
? { dir: report.reference.dir, commit: report.reference.commit || null, source: report.reference.source || null }
|
|
147
|
+
: (previous && previous.reference) || undefined,
|
|
148
|
+
// Kept across runs so uninstall can remove a rule an earlier install added.
|
|
149
|
+
permissions: mergePermissions(previous && previous.permissions, report.permissions),
|
|
110
150
|
});
|
|
111
151
|
}
|
|
112
152
|
|
|
@@ -122,7 +162,7 @@ function uninstall(opts = {}) {
|
|
|
122
162
|
const { mode = 'global', projectRoot = process.cwd(), dryRun = false, persona = true } = opts;
|
|
123
163
|
|
|
124
164
|
const previous = manifest.read(mode, projectRoot);
|
|
125
|
-
const report = { mode, dryRun, removed: [], persona: [], manifestFound: Boolean(previous) };
|
|
165
|
+
const report = { mode, dryRun, removed: [], persona: [], permissions: [], manifestFound: Boolean(previous) };
|
|
126
166
|
|
|
127
167
|
if (!previous) return report;
|
|
128
168
|
|
|
@@ -148,8 +188,24 @@ function uninstall(opts = {}) {
|
|
|
148
188
|
}
|
|
149
189
|
}
|
|
150
190
|
|
|
191
|
+
if (previous.reference && reference.removeReference(previous.reference.dir, { dryRun })) {
|
|
192
|
+
report.removed.push(previous.reference.dir);
|
|
193
|
+
}
|
|
194
|
+
for (const entry of previous.permissions || []) {
|
|
195
|
+
report.permissions.push(removeAllowRule(entry.file, entry.rule, { dryRun }));
|
|
196
|
+
}
|
|
197
|
+
|
|
151
198
|
if (!dryRun) manifest.remove(mode, projectRoot);
|
|
152
199
|
return report;
|
|
153
200
|
}
|
|
154
201
|
|
|
202
|
+
/** The allow rules this tool added, by file and rule, so uninstall removes exactly those. */
|
|
203
|
+
function mergePermissions(previous, current) {
|
|
204
|
+
const merged = new Map();
|
|
205
|
+
// A rule that was already there is the user's own (`unchanged`), so it is never recorded as ours.
|
|
206
|
+
const added = current.filter((entry) => ['created', 'updated'].includes(entry.action));
|
|
207
|
+
for (const entry of [...(previous || []), ...added]) merged.set(`${entry.file}\n${entry.rule}`, { file: entry.file, rule: entry.rule });
|
|
208
|
+
return [...merged.values()];
|
|
209
|
+
}
|
|
210
|
+
|
|
155
211
|
module.exports = { install, uninstall };
|
package/lib/persona.js
CHANGED
|
@@ -12,8 +12,27 @@ const END = '<!-- END BABYLON TOOLKIT PERSONA -->';
|
|
|
12
12
|
const LEGACY_SENTINEL = 'babylontoolkit/agent/main/reference.md';
|
|
13
13
|
const LEGACY_HEADING = '# Babylon Toolkit Agent Persona';
|
|
14
14
|
|
|
15
|
-
|
|
16
|
-
|
|
15
|
+
/**
|
|
16
|
+
* The persona as installed. With a local Agent Reference its links point at the local copy, and a
|
|
17
|
+
* paragraph after the opening one says so — keeping the GitHub address as the fallback, which is
|
|
18
|
+
* also what `hasPersona` recognises.
|
|
19
|
+
*/
|
|
20
|
+
function personaText({ referenceDir = null } = {}) {
|
|
21
|
+
const text = fs.readFileSync(personaFile(), 'utf8').trim();
|
|
22
|
+
if (!referenceDir) return text;
|
|
23
|
+
const { rewriteText, linkRoot, REFERENCE_URL_PREFIX } = require('./reference');
|
|
24
|
+
const root = linkRoot(referenceDir);
|
|
25
|
+
const localNote =
|
|
26
|
+
`The Agent Reference and every one of its sub-documents are installed locally in \`${root}/\` by bt-agent, ` +
|
|
27
|
+
'and every Agent Reference link — in the Reference itself and in the bt-* skills — points at a file there. ' +
|
|
28
|
+
'Read those files directly, never fetch them; search a large one (the API declarations in ' +
|
|
29
|
+
`\`${root}/training/declarations/babylon.toolkit.d.ts\` are 2.7 MB) and read only the part you need. ` +
|
|
30
|
+
`Only if a file there is missing, fetch the same path from ${REFERENCE_URL_PREFIX} instead ` +
|
|
31
|
+
`(the Reference itself is ${REFERENCE_URL_PREFIX}reference.md) and tell the user to run \`bt-agent update\`.`;
|
|
32
|
+
// After the heading and the opening paragraph, which names the Reference.
|
|
33
|
+
const blocks = rewriteText(text, referenceDir).text.split('\n\n');
|
|
34
|
+
const insertAt = blocks[0].startsWith('#') ? 2 : 1;
|
|
35
|
+
return [...blocks.slice(0, insertAt), localNote, ...blocks.slice(insertAt)].join('\n\n');
|
|
17
36
|
}
|
|
18
37
|
|
|
19
38
|
function renderBlock(text, eol) {
|
package/lib/reference.js
ADDED
|
@@ -0,0 +1,400 @@
|
|
|
1
|
+
'use strict';
|
|
2
|
+
|
|
3
|
+
const fs = require('fs');
|
|
4
|
+
const os = require('os');
|
|
5
|
+
const path = require('path');
|
|
6
|
+
const zlib = require('zlib');
|
|
7
|
+
const { execFileSync } = require('child_process');
|
|
8
|
+
|
|
9
|
+
/**
|
|
10
|
+
* The local Agent Reference.
|
|
11
|
+
*
|
|
12
|
+
* Agents used to fetch the Agent Reference and its sub-documents from GitHub on every session. A local
|
|
13
|
+
* copy is read faster, never fails a fetch, can be searched instead of read whole (the toolkit's API
|
|
14
|
+
* declarations alone are 2.7 MB), and stays in step with the installed skills. The copy is downloaded
|
|
15
|
+
* from GitHub at install time — not bundled in the npm package — so a Reference edit reaches agents
|
|
16
|
+
* with `bt-agent update`, without an npm release.
|
|
17
|
+
*
|
|
18
|
+
* Every link into the Reference repo is rewritten to the local file, in the copy and in the installed
|
|
19
|
+
* skills, so an agent simply reads the path it is given. The source repo is never changed, and the
|
|
20
|
+
* persona keeps the GitHub address as the fallback.
|
|
21
|
+
*/
|
|
22
|
+
|
|
23
|
+
const REFERENCE_REPO = 'babylontoolkit/agent';
|
|
24
|
+
const REFERENCE_BRANCH = 'main';
|
|
25
|
+
const REFERENCE_URL_PREFIX = `https://raw.githubusercontent.com/${REFERENCE_REPO}/${REFERENCE_BRANCH}/`;
|
|
26
|
+
const TARBALL_URL = `https://codeload.github.com/${REFERENCE_REPO}/tar.gz/refs/heads/${REFERENCE_BRANCH}`;
|
|
27
|
+
const LATEST_COMMIT_URL = `https://api.github.com/repos/${REFERENCE_REPO}/commits/${REFERENCE_BRANCH}`;
|
|
28
|
+
|
|
29
|
+
/** Written into the copy: where it came from, and what the rewrite found. */
|
|
30
|
+
const METADATA_FILE = '.bt-reference.json';
|
|
31
|
+
const DOWNLOAD_TIMEOUT_MS = 120000;
|
|
32
|
+
const LATEST_COMMIT_TIMEOUT_MS = 5000;
|
|
33
|
+
|
|
34
|
+
/** Only these files are rewritten and link-checked; everything else is copied as is. */
|
|
35
|
+
const TEXT_EXTENSIONS = new Set(['.md', '.txt', '.js', '.mjs', '.cjs', '.ts', '.json', '.sh', '.ps1', '.cs', '.py', '.html', '.css']);
|
|
36
|
+
/** Repo housekeeping that has no place in an agent's copy. */
|
|
37
|
+
const SKIPPED_TOP_LEVEL = new Set(['.git', '.github', '.gitignore', '.gitattributes', 'node_modules', '.DS_Store']);
|
|
38
|
+
|
|
39
|
+
// The characters that end a URL or path inside markdown, code spans, quotes and prose.
|
|
40
|
+
const PATH_CHARACTERS = "[^\\s)`\"'<>\\]]+";
|
|
41
|
+
const REFERENCE_URL_PATTERN = escapeRegExp(REFERENCE_URL_PREFIX);
|
|
42
|
+
|
|
43
|
+
/**
|
|
44
|
+
* `~/.claude/toolkit/reference/` — beside the Unity helper scripts the Reference already keeps in
|
|
45
|
+
* `~/.claude/toolkit/` — or `.claude/toolkit/reference/` in a project install. Only this subfolder is
|
|
46
|
+
* ever replaced or removed; the helper scripts next to it are left alone.
|
|
47
|
+
*/
|
|
48
|
+
function referenceDir(mode, projectRoot) {
|
|
49
|
+
const base = mode === 'project' ? path.resolve(projectRoot) : os.homedir();
|
|
50
|
+
return path.join(base, '.claude', 'toolkit', 'reference');
|
|
51
|
+
}
|
|
52
|
+
|
|
53
|
+
/** The Claude Code allow rule that lets sessions read the global copy without asking. */
|
|
54
|
+
const CLAUDE_READ_RULE = 'Read(~/.claude/toolkit/reference/**)';
|
|
55
|
+
|
|
56
|
+
/** The folder as agents see it in rewritten links: absolute, with forward slashes on every platform. */
|
|
57
|
+
function linkRoot(dir) {
|
|
58
|
+
return path.resolve(dir).split(path.sep).join('/');
|
|
59
|
+
}
|
|
60
|
+
|
|
61
|
+
function escapeRegExp(text) {
|
|
62
|
+
return text.replace(/[.*+?^${}()|[\]\\]/g, '\\$&');
|
|
63
|
+
}
|
|
64
|
+
|
|
65
|
+
/** Trailing sentence punctuation belongs to the prose, not to the path. */
|
|
66
|
+
function splitTrailingPunctuation(target) {
|
|
67
|
+
const match = /[.,;:!?]+$/.exec(target);
|
|
68
|
+
return match ? [target.slice(0, match.index), match[0]] : [target, ''];
|
|
69
|
+
}
|
|
70
|
+
|
|
71
|
+
/**
|
|
72
|
+
* Point every link into the Reference repo at the local copy.
|
|
73
|
+
*
|
|
74
|
+
* `curl -fsSL <url> -o <dest>` download commands become `cp "<local file>" <dest>`; every other
|
|
75
|
+
* occurrence — markdown links, bare URLs, code spans — becomes the absolute local path. A markdown
|
|
76
|
+
* link whose path contains a space is wrapped in `<…>` so it still parses.
|
|
77
|
+
*/
|
|
78
|
+
function rewriteText(text, dir) {
|
|
79
|
+
const root = linkRoot(dir);
|
|
80
|
+
let downloads = 0;
|
|
81
|
+
let links = 0;
|
|
82
|
+
|
|
83
|
+
const downloadPattern = new RegExp(`curl((?:\\s+-[A-Za-z-]+)*)\\s+${REFERENCE_URL_PATTERN}(${PATH_CHARACTERS})\\s+-o\\s+(\\S+)`, 'g');
|
|
84
|
+
let result = text.replace(downloadPattern, (whole, flags, target, destination) => {
|
|
85
|
+
downloads += 1;
|
|
86
|
+
return `cp "${root}/${target}" ${destination}`;
|
|
87
|
+
});
|
|
88
|
+
|
|
89
|
+
const linkPattern = new RegExp(`(\\]\\()?${REFERENCE_URL_PATTERN}(${PATH_CHARACTERS})`, 'g');
|
|
90
|
+
result = result.replace(linkPattern, (whole, markdownOpen, target) => {
|
|
91
|
+
links += 1;
|
|
92
|
+
const [cleanTarget, punctuation] = splitTrailingPunctuation(target);
|
|
93
|
+
const local = `${root}/${cleanTarget}`;
|
|
94
|
+
if (markdownOpen) return local.includes(' ') ? `](<${local}>${punctuation}` : `](${local}${punctuation}`;
|
|
95
|
+
return `${local}${punctuation}`;
|
|
96
|
+
});
|
|
97
|
+
|
|
98
|
+
return { text: result, downloads, links };
|
|
99
|
+
}
|
|
100
|
+
|
|
101
|
+
function isTextFile(file) {
|
|
102
|
+
return TEXT_EXTENSIONS.has(path.extname(file).toLowerCase());
|
|
103
|
+
}
|
|
104
|
+
|
|
105
|
+
function walkFiles(dir, prefix = '') {
|
|
106
|
+
const files = [];
|
|
107
|
+
for (const entry of fs.readdirSync(dir, { withFileTypes: true })) {
|
|
108
|
+
const relative = prefix ? `${prefix}/${entry.name}` : entry.name;
|
|
109
|
+
if (entry.isDirectory()) files.push(...walkFiles(path.join(dir, entry.name), relative));
|
|
110
|
+
else if (entry.isFile()) files.push(relative);
|
|
111
|
+
}
|
|
112
|
+
return files;
|
|
113
|
+
}
|
|
114
|
+
|
|
115
|
+
/** Rewrite every text file under `folder` that links into the Reference repo; returns the counts. */
|
|
116
|
+
function rewriteFolder(folder, dir) {
|
|
117
|
+
const totals = { files: 0, downloads: 0, links: 0 };
|
|
118
|
+
for (const relative of walkFiles(folder)) {
|
|
119
|
+
if (!isTextFile(relative)) continue;
|
|
120
|
+
const file = path.join(folder, relative);
|
|
121
|
+
const text = fs.readFileSync(file, 'utf8');
|
|
122
|
+
if (!text.includes(REFERENCE_URL_PREFIX)) continue;
|
|
123
|
+
const rewritten = rewriteText(text, dir);
|
|
124
|
+
fs.writeFileSync(file, rewritten.text, 'utf8');
|
|
125
|
+
totals.files += 1;
|
|
126
|
+
totals.downloads += rewritten.downloads;
|
|
127
|
+
totals.links += rewritten.links;
|
|
128
|
+
}
|
|
129
|
+
return totals;
|
|
130
|
+
}
|
|
131
|
+
|
|
132
|
+
/**
|
|
133
|
+
* Check every local link under the given folders resolves to a file in the copy.
|
|
134
|
+
* A renamed or deleted sub-document shows up here, at install time, instead of mid-run.
|
|
135
|
+
*/
|
|
136
|
+
function checkLinks(dir, folders) {
|
|
137
|
+
const root = linkRoot(dir);
|
|
138
|
+
const pattern = new RegExp(`${escapeRegExp(root)}/(${PATH_CHARACTERS})`, 'g');
|
|
139
|
+
const broken = new Set();
|
|
140
|
+
let checked = 0;
|
|
141
|
+
for (const folder of folders) {
|
|
142
|
+
if (!fs.existsSync(folder)) continue;
|
|
143
|
+
for (const relative of walkFiles(folder)) {
|
|
144
|
+
if (!isTextFile(relative)) continue;
|
|
145
|
+
const text = fs.readFileSync(path.join(folder, relative), 'utf8');
|
|
146
|
+
if (!text.includes(root)) continue;
|
|
147
|
+
for (const match of text.matchAll(pattern)) {
|
|
148
|
+
const target = splitTrailingPunctuation(match[1])[0].split('#')[0];
|
|
149
|
+
checked += 1;
|
|
150
|
+
if (!fs.existsSync(path.join(dir, ...target.split('/')))) broken.add(`${relative} → ${target}`);
|
|
151
|
+
}
|
|
152
|
+
}
|
|
153
|
+
}
|
|
154
|
+
return { checked, broken: [...broken] };
|
|
155
|
+
}
|
|
156
|
+
|
|
157
|
+
/* ===================== Download ===================== */
|
|
158
|
+
|
|
159
|
+
/**
|
|
160
|
+
* Download one URL to a file. Node's https first, in a helper process so the installer stays
|
|
161
|
+
* synchronous; then the system curl, which honours proxy settings Node ignores.
|
|
162
|
+
*/
|
|
163
|
+
function downloadFile(url, destination) {
|
|
164
|
+
const script = `
|
|
165
|
+
const https = require('https');
|
|
166
|
+
const fs = require('fs');
|
|
167
|
+
const [url, destination] = process.argv.slice(1);
|
|
168
|
+
function get(address, redirects) {
|
|
169
|
+
const request = https.get(address, { headers: { 'user-agent': 'bt-agent' } }, (response) => {
|
|
170
|
+
if ([301, 302, 303, 307, 308].includes(response.statusCode) && response.headers.location && redirects < 5) {
|
|
171
|
+
response.resume();
|
|
172
|
+
return get(new URL(response.headers.location, address).toString(), redirects + 1);
|
|
173
|
+
}
|
|
174
|
+
if (response.statusCode !== 200) { console.error('HTTP ' + response.statusCode); process.exit(2); }
|
|
175
|
+
const file = fs.createWriteStream(destination);
|
|
176
|
+
response.pipe(file);
|
|
177
|
+
file.on('finish', () => file.close(() => process.exit(0)));
|
|
178
|
+
});
|
|
179
|
+
request.setTimeout(${DOWNLOAD_TIMEOUT_MS}, () => request.destroy(new Error('timed out')));
|
|
180
|
+
request.on('error', (error) => { console.error(error.message); process.exit(3); });
|
|
181
|
+
}
|
|
182
|
+
get(url, 0);
|
|
183
|
+
`;
|
|
184
|
+
const errors = [];
|
|
185
|
+
try {
|
|
186
|
+
execFileSync(process.execPath, ['-e', script, url, destination], { stdio: ['ignore', 'ignore', 'pipe'], timeout: DOWNLOAD_TIMEOUT_MS + 5000 });
|
|
187
|
+
return;
|
|
188
|
+
} catch (error) {
|
|
189
|
+
errors.push(String((error.stderr && error.stderr.toString()) || error.message).trim());
|
|
190
|
+
}
|
|
191
|
+
try {
|
|
192
|
+
execFileSync('curl', ['-fsSL', '--max-time', String(DOWNLOAD_TIMEOUT_MS / 1000), '-o', destination, url], { stdio: ['ignore', 'ignore', 'pipe'] });
|
|
193
|
+
return;
|
|
194
|
+
} catch (error) {
|
|
195
|
+
errors.push(String((error.stderr && error.stderr.toString()) || error.message).trim());
|
|
196
|
+
}
|
|
197
|
+
throw new Error(errors.filter(Boolean).pop() || `could not download ${url}`);
|
|
198
|
+
}
|
|
199
|
+
|
|
200
|
+
/** The commit GitHub's branch now points at, or null when it cannot be reached quickly. */
|
|
201
|
+
function latestCommit() {
|
|
202
|
+
const script = `
|
|
203
|
+
const https = require('https');
|
|
204
|
+
const request = https.get(${JSON.stringify(LATEST_COMMIT_URL)}, { headers: { 'user-agent': 'bt-agent', accept: 'application/vnd.github.sha' } }, (response) => {
|
|
205
|
+
let body = '';
|
|
206
|
+
response.on('data', (chunk) => { body += chunk; });
|
|
207
|
+
response.on('end', () => process.stdout.write(response.statusCode === 200 ? body.trim() : ''));
|
|
208
|
+
});
|
|
209
|
+
request.setTimeout(${LATEST_COMMIT_TIMEOUT_MS}, () => request.destroy());
|
|
210
|
+
request.on('error', () => process.stdout.write(''));
|
|
211
|
+
`;
|
|
212
|
+
try {
|
|
213
|
+
const sha = execFileSync(process.execPath, ['-e', script], { encoding: 'utf8', timeout: LATEST_COMMIT_TIMEOUT_MS + 2000 }).trim();
|
|
214
|
+
return /^[0-9a-f]{40}$/.test(sha) ? sha : null;
|
|
215
|
+
} catch {
|
|
216
|
+
return null;
|
|
217
|
+
}
|
|
218
|
+
}
|
|
219
|
+
|
|
220
|
+
/* ===================== Tarball ===================== */
|
|
221
|
+
|
|
222
|
+
function nulTerminated(buffer, start, length) {
|
|
223
|
+
const field = buffer.subarray(start, start + length);
|
|
224
|
+
const end = field.indexOf(0);
|
|
225
|
+
return field.subarray(0, end === -1 ? field.length : end).toString('utf8');
|
|
226
|
+
}
|
|
227
|
+
|
|
228
|
+
/** `<length> <key>=<value>\n` records of a pax header. */
|
|
229
|
+
function paxRecords(body) {
|
|
230
|
+
const records = {};
|
|
231
|
+
let offset = 0;
|
|
232
|
+
while (offset < body.length) {
|
|
233
|
+
const space = body.indexOf(0x20, offset);
|
|
234
|
+
if (space === -1) break;
|
|
235
|
+
const length = parseInt(body.subarray(offset, space).toString('utf8'), 10);
|
|
236
|
+
if (!length) break;
|
|
237
|
+
const record = body.subarray(space + 1, offset + length - 1).toString('utf8');
|
|
238
|
+
const equals = record.indexOf('=');
|
|
239
|
+
if (equals !== -1) records[record.slice(0, equals)] = record.slice(equals + 1);
|
|
240
|
+
offset += length;
|
|
241
|
+
}
|
|
242
|
+
return records;
|
|
243
|
+
}
|
|
244
|
+
|
|
245
|
+
/**
|
|
246
|
+
* Read a gzipped tarball as GitHub serves it: regular files only, the top folder (`agent-main/`)
|
|
247
|
+
* stripped, and the commit taken from the pax global header GitHub writes.
|
|
248
|
+
*/
|
|
249
|
+
function readTarball(gzipped) {
|
|
250
|
+
const buffer = zlib.gunzipSync(gzipped);
|
|
251
|
+
const files = [];
|
|
252
|
+
let commit = null;
|
|
253
|
+
let longPath = null;
|
|
254
|
+
let offset = 0;
|
|
255
|
+
while (offset + 512 <= buffer.length) {
|
|
256
|
+
const header = buffer.subarray(offset, offset + 512);
|
|
257
|
+
if (header.every((byte) => byte === 0)) break;
|
|
258
|
+
const size = parseInt(nulTerminated(header, 124, 12).trim() || '0', 8);
|
|
259
|
+
const type = String.fromCharCode(header[156] || 48);
|
|
260
|
+
const body = buffer.subarray(offset + 512, offset + 512 + size);
|
|
261
|
+
offset += 512 + Math.ceil(size / 512) * 512;
|
|
262
|
+
|
|
263
|
+
if (type === 'g') {
|
|
264
|
+
const records = paxRecords(body);
|
|
265
|
+
if (/^[0-9a-f]{40}$/.test(records.comment || '')) commit = records.comment;
|
|
266
|
+
continue;
|
|
267
|
+
}
|
|
268
|
+
if (type === 'x') { longPath = paxRecords(body).path || null; continue; }
|
|
269
|
+
if (type === 'L') { longPath = nulTerminated(body, 0, body.length); continue; }
|
|
270
|
+
|
|
271
|
+
const prefix = nulTerminated(header, 345, 155);
|
|
272
|
+
const name = longPath || (prefix ? `${prefix}/${nulTerminated(header, 0, 100)}` : nulTerminated(header, 0, 100));
|
|
273
|
+
longPath = null;
|
|
274
|
+
if (type !== '0') continue;
|
|
275
|
+
const relative = name.split('/').slice(1).join('/');
|
|
276
|
+
if (relative) files.push({ path: relative, data: Buffer.from(body) });
|
|
277
|
+
}
|
|
278
|
+
return { commit, files };
|
|
279
|
+
}
|
|
280
|
+
|
|
281
|
+
/** A path from an archive or a folder that stays inside the copy and is not repo housekeeping. */
|
|
282
|
+
function keepPath(relative) {
|
|
283
|
+
const parts = relative.split('/');
|
|
284
|
+
if (parts.some((part) => part === '..' || part === '') || path.isAbsolute(relative)) return false;
|
|
285
|
+
return !SKIPPED_TOP_LEVEL.has(parts[0]) && parts[parts.length - 1] !== '.DS_Store';
|
|
286
|
+
}
|
|
287
|
+
|
|
288
|
+
/** A local checkout as the source (`--reference-from`), for offline installs and unreleased Reference edits. */
|
|
289
|
+
function readFolder(folder) {
|
|
290
|
+
if (!fs.existsSync(path.join(folder, 'reference.md'))) throw new Error(`${folder} has no reference.md`);
|
|
291
|
+
const files = walkFiles(folder)
|
|
292
|
+
.filter(keepPath)
|
|
293
|
+
.map((relative) => ({ path: relative, data: fs.readFileSync(path.join(folder, ...relative.split('/'))) }));
|
|
294
|
+
let commit = null;
|
|
295
|
+
try {
|
|
296
|
+
commit = execFileSync('git', ['-C', folder, 'rev-parse', 'HEAD'], { encoding: 'utf8', stdio: ['ignore', 'pipe', 'ignore'] }).trim();
|
|
297
|
+
} catch {
|
|
298
|
+
/* not a git checkout */
|
|
299
|
+
}
|
|
300
|
+
return { commit, files };
|
|
301
|
+
}
|
|
302
|
+
|
|
303
|
+
/* ===================== Install ===================== */
|
|
304
|
+
|
|
305
|
+
function readMetadata(dir) {
|
|
306
|
+
try {
|
|
307
|
+
return JSON.parse(fs.readFileSync(path.join(dir, METADATA_FILE), 'utf8'));
|
|
308
|
+
} catch {
|
|
309
|
+
return null;
|
|
310
|
+
}
|
|
311
|
+
}
|
|
312
|
+
|
|
313
|
+
/** A copy agents can use: the metadata and the Reference itself are both there. */
|
|
314
|
+
function isUsable(dir) {
|
|
315
|
+
return Boolean(readMetadata(dir)) && fs.existsSync(path.join(dir, 'reference.md'));
|
|
316
|
+
}
|
|
317
|
+
|
|
318
|
+
/**
|
|
319
|
+
* Download (or copy) the Reference into its folder, rewrite its links and check them.
|
|
320
|
+
* The new copy is built beside the old one and swapped in only when complete; when the download
|
|
321
|
+
* fails, an existing copy is kept and agents keep reading it.
|
|
322
|
+
*/
|
|
323
|
+
function installReference({ mode = 'global', projectRoot = process.cwd(), from = null, dryRun = false } = {}) {
|
|
324
|
+
const dir = referenceDir(mode, projectRoot);
|
|
325
|
+
const source = from ? path.resolve(from) : `${REFERENCE_REPO}@${REFERENCE_BRANCH}`;
|
|
326
|
+
if (dryRun) return { dir, status: 'would-install', source };
|
|
327
|
+
|
|
328
|
+
let archive;
|
|
329
|
+
try {
|
|
330
|
+
if (from) archive = readFolder(path.resolve(from));
|
|
331
|
+
else {
|
|
332
|
+
const temporary = path.join(fs.mkdtempSync(path.join(os.tmpdir(), 'bt-reference-')), 'reference.tar.gz');
|
|
333
|
+
try {
|
|
334
|
+
downloadFile(TARBALL_URL, temporary);
|
|
335
|
+
archive = readTarball(fs.readFileSync(temporary));
|
|
336
|
+
} finally {
|
|
337
|
+
fs.rmSync(path.dirname(temporary), { recursive: true, force: true });
|
|
338
|
+
}
|
|
339
|
+
}
|
|
340
|
+
if (!archive.files.some((file) => file.path === 'reference.md')) throw new Error('the download has no reference.md');
|
|
341
|
+
} catch (error) {
|
|
342
|
+
const reason = error.message.split('\n').filter(Boolean).pop();
|
|
343
|
+
if (isUsable(dir)) return { dir, status: 'kept', source, reason, ...readMetadata(dir) };
|
|
344
|
+
return { dir, status: 'unavailable', source, reason };
|
|
345
|
+
}
|
|
346
|
+
|
|
347
|
+
const staging = `${dir}.staging-${process.pid}`;
|
|
348
|
+
fs.rmSync(staging, { recursive: true, force: true });
|
|
349
|
+
const files = archive.files.filter((file) => keepPath(file.path));
|
|
350
|
+
for (const file of files) {
|
|
351
|
+
const target = path.join(staging, ...file.path.split('/'));
|
|
352
|
+
fs.mkdirSync(path.dirname(target), { recursive: true });
|
|
353
|
+
fs.writeFileSync(target, file.data);
|
|
354
|
+
}
|
|
355
|
+
// Links are rewritten to the final folder, not the staging one, so they are right once swapped in.
|
|
356
|
+
const rewrite = rewriteFolder(staging, dir);
|
|
357
|
+
// A project install keeps the copy out of the project's git without touching its .gitignore.
|
|
358
|
+
fs.writeFileSync(path.join(staging, '.gitignore'), '*\n');
|
|
359
|
+
|
|
360
|
+
const metadata = {
|
|
361
|
+
repo: REFERENCE_REPO,
|
|
362
|
+
branch: REFERENCE_BRANCH,
|
|
363
|
+
source,
|
|
364
|
+
commit: archive.commit,
|
|
365
|
+
installedAt: new Date().toISOString(),
|
|
366
|
+
files: files.length,
|
|
367
|
+
rewrittenFiles: rewrite.files,
|
|
368
|
+
rewrittenLinks: rewrite.links,
|
|
369
|
+
rewrittenDownloads: rewrite.downloads,
|
|
370
|
+
};
|
|
371
|
+
fs.writeFileSync(path.join(staging, METADATA_FILE), JSON.stringify(metadata, null, 2) + '\n');
|
|
372
|
+
|
|
373
|
+
fs.rmSync(dir, { recursive: true, force: true });
|
|
374
|
+
fs.mkdirSync(path.dirname(dir), { recursive: true });
|
|
375
|
+
fs.renameSync(staging, dir);
|
|
376
|
+
return { dir, status: 'installed', ...metadata };
|
|
377
|
+
}
|
|
378
|
+
|
|
379
|
+
function removeReference(dir, { dryRun = false } = {}) {
|
|
380
|
+
if (!dir || !fs.existsSync(dir)) return false;
|
|
381
|
+
if (!dryRun) fs.rmSync(dir, { recursive: true, force: true });
|
|
382
|
+
return true;
|
|
383
|
+
}
|
|
384
|
+
|
|
385
|
+
module.exports = {
|
|
386
|
+
REFERENCE_URL_PREFIX,
|
|
387
|
+
METADATA_FILE,
|
|
388
|
+
CLAUDE_READ_RULE,
|
|
389
|
+
referenceDir,
|
|
390
|
+
linkRoot,
|
|
391
|
+
rewriteText,
|
|
392
|
+
rewriteFolder,
|
|
393
|
+
checkLinks,
|
|
394
|
+
readTarball,
|
|
395
|
+
readMetadata,
|
|
396
|
+
isUsable,
|
|
397
|
+
latestCommit,
|
|
398
|
+
installReference,
|
|
399
|
+
removeReference,
|
|
400
|
+
};
|
package/package.json
CHANGED
package/persona.md
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
# Babylon Toolkit Agent Persona
|
|
2
2
|
|
|
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
|
|
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 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 it cannot be read, 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 reading the Reference again — the orchestrator has already read it, and reading it again in every subagent adds time, not rigor.
|
|
4
4
|
|
|
5
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
|
|
package/scripts/postinstall.js
CHANGED
|
@@ -35,6 +35,12 @@ function main() {
|
|
|
35
35
|
for (const p of report.persona) console.log(` persona ${p.file} — ${p.action}`);
|
|
36
36
|
|
|
37
37
|
for (const c of report.config) console.log(` config ${c.file} — ${c.action} (network_access = true)`);
|
|
38
|
+
if (report.reference) {
|
|
39
|
+
const ref = report.reference;
|
|
40
|
+
console.log(ref.status === 'installed' || ref.status === 'kept'
|
|
41
|
+
? ` reference ${ref.dir} — ${ref.status === 'kept' ? 'kept the existing copy' : `${ref.files} files`}`
|
|
42
|
+
: ` reference not installed (${ref.reason}) — agents read it from GitHub; run \`bt-agent update\` later`);
|
|
43
|
+
}
|
|
38
44
|
|
|
39
45
|
console.log(check.ok ? '\nINSTALL OK' : '\nINSTALL INCOMPLETE — run `bt-agent doctor` for details');
|
|
40
46
|
console.log('\nRestart your agent session so the skills, persona and Codex configuration are picked up.\n');
|
|
@@ -80,12 +80,12 @@ CLI** → the model's own built-in image/video generation → any other configur
|
|
|
80
80
|
image/video tool. The parameter names below (`reference_paths`, `image_paths`,
|
|
81
81
|
`out_path`) are KIE/Kling's; map them to your backend (Higgsfield mapping below).
|
|
82
82
|
|
|
83
|
-
> **If using the KIE MCP servers** (Babylon Toolkit projects):
|
|
83
|
+
> **If using the KIE MCP servers** (Babylon Toolkit projects): read the
|
|
84
84
|
> Babylon Toolkit Agent Reference and its `web-kie-servers.md` sub-document
|
|
85
85
|
> first (per CLAUDE.md). Those servers read the key from `.env` — a file named
|
|
86
86
|
> `env` is ignored.
|
|
87
87
|
|
|
88
|
-
> **If using the Higgsfield CLI** (`@higgsfield/cli`):
|
|
88
|
+
> **If using the Higgsfield CLI** (`@higgsfield/cli`): read the Agent
|
|
89
89
|
> Reference's `web-higgsfield-cli.md` sub-document first. Install the CLI
|
|
90
90
|
> locally (`npm i -D @higgsfield/cli`) and the reference's download wrapper as
|
|
91
91
|
> `scripts/hf-generate.mjs`. The CLI only returns CDN URLs; the wrapper saves
|
|
@@ -33,8 +33,8 @@ Run tasks from a plan: build each one with its tests, have an independent verifi
|
|
|
33
33
|
|
|
34
34
|
- **TIME MATTERS** — on by default; `--no-time-limit` turns it off. Treat the arguments as ending with `TIME MATTERS`: the user is waiting on this run, so finish quickly — follow the *Work fast* rules below to the letter, take the direct route to each task's Acceptance, and do not re-read what you already have. Begin every implementer and verifier prompt with `TIME MATTERS.` Print `⏱️ [bt-execute] TIME MATTERS` at the start (`--no-time-limit`: print `⏱️ [bt-execute] No time limit`, and do not add it). Speed never relaxes tests, the independent verifier, live checks, or "tick only on PASS".
|
|
35
35
|
- **Scope.** Implement only the selected task(s). No "while I'm here" work on other tasks. Ambiguous, or blocked by an unfinished task → stop and tell the user *(auto-pilot: decide and log it)*.
|
|
36
|
-
- **Open the run before anything else.** The first actions of every run — before
|
|
37
|
-
- **Read the docs once.** For Babylon work, if you have not read the Agent Reference this session,
|
|
36
|
+
- **Open the run before anything else.** The first actions of every run — before reading docs, reading code, checking the repo or any other pre-flight work — are, in order: take the clock; append the `⏱ Run <n> start` line to the run log; sync the dashboard with the plan and set `status: "in-progress"` (*Run start* under *Feature folder and dashboard*); write the live file (`role: "orchestrator"`, `title: "Starting run <n> — <what you are checking first>"`); and launch the watchdog in the background (*Never let the dashboard go stale*). From then on the pre-flight work is narrated in the live file like any other step. Until the run is opened the dashboard still shows the last run's end state — a user who restarts a run and refreshes must see it running within a minute, not after the pre-flight is over.
|
|
37
|
+
- **Read the docs once.** For Babylon work, if you have not read the Agent Reference this session, read it once — https://raw.githubusercontent.com/babylontoolkit/agent/main/reference.md — plus only the sub-documents the plan's tasks need, searching a large one for the part you need rather than reading it whole. It is the authority for conventions and API. Cannot be read → stop and tell the user *(auto-pilot: retry 3×, then continue on what you know and log it)*. Read the plan's checklist and the parts of `SPEC.md` the tasks touch; re-read after a context compaction.
|
|
38
38
|
- **SPEC.md** constrains how you build. If the code and SPEC.md disagree, stop and tell the user *(auto-pilot: decide which is right, fix SPEC.md in the same task, log it)*. When a task changes architecture, a system, a convention or a dependency, SPEC.md must end up matching — normally the plan's final `Update SPEC.md` task; if the plan has none, do it anyway; a new dependency is recorded in SPEC.md by the task that introduces it. Follow SPEC.md's "How to update this spec". **Write the product, never the procedure** — no capture protocols, tool lists, ledgers or gates: recorded there, they become a bar every later feature must clear.
|
|
39
39
|
- **Say what you are doing** — one short line at each task and phase boundary, and before anything slow.
|
|
40
40
|
- **Clock every run** — auto-pilot or not, so bt-plan's time estimates can be recalibrated from real runs. Take every time from the shell (`date '+%Y-%m-%d %H:%M %Z'`, local time), never from memory, the conversation or a tool result's UTC timestamp. Append to the run log `documents/<slug>_autopilot.md` beside the plan (a legacy plan keeps its existing `<plan-basename>_autopilot.md`; an interactive run writes only these lines and its task lines):
|
|
@@ -60,7 +60,7 @@ Work in **phases**: a `### Phase N` group in the plan, or — if the plan has no
|
|
|
60
60
|
|
|
61
61
|
For a task built on a sibling skill (e.g. bt-design's 3D-Hero-Scroll), give the verifier the relevant part of that skill *(where skills load through a tool: `load_skill` + `read_skill_resource`; where they are files: the skills directory this skill was loaded from, e.g. `~/.claude/skills/`, `~/.agents/skills/` or the project's equivalent)* — its documented options (e.g. `sweep: page` really reaches the document bottom) are part of Acceptance.
|
|
62
62
|
|
|
63
|
-
**Every subagent gets a brief, not homework:** the task block(s), the plan Decisions / Design Reference entries they cite, the SPEC.md parts touched, the Agent Reference excerpts needed (with
|
|
63
|
+
**Every subagent gets a brief, not homework:** the task block(s), the plan Decisions / Design Reference entries they cite, the SPEC.md parts touched, the Agent Reference excerpts needed (with their links) — **always including the full `Coding Practices — ENFORCED` section**, since implementers write to it and verifiers fail work that breaks it — the test command and the feature folder's `tests/` path, the `snapshots/` path and *Snapshots tell the story* (for any phase with visible output), the dashboard and live file paths with the per-task update rules from *Feature folder and dashboard* (with `--verbose`, the `details` fields that role writes), the project's agent instructions, the *Work fast* rules below, and: *"Do not read the Agent Reference or SPEC.md in full — the parts you need are here, and this overrides any standing instruction to read it first. Read one sub-document (search it for the API, never the whole file) only if you hit an API this brief does not cover, and say which."*
|
|
64
64
|
|
|
65
65
|
## Feature folder and dashboard
|
|
66
66
|
|
|
@@ -148,7 +148,7 @@ An unattended run: **nobody is there to answer, and nothing waits for anyone's a
|
|
|
148
148
|
|
|
149
149
|
- **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.
|
|
150
150
|
- **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.
|
|
151
|
-
- **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.
|
|
151
|
+
- **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. An Agent Reference that cannot be read → 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.
|
|
152
152
|
- After a compaction, re-read the plan and the run log and continue from the first unticked, undeferred task.
|
|
153
153
|
|
|
154
154
|
### Keep moving
|
|
@@ -67,11 +67,11 @@ Downgrading is not a neutral choice. A critic that is the same context which jus
|
|
|
67
67
|
|
|
68
68
|
## ⚠️ Required Reading Before Any Babylon Work
|
|
69
69
|
|
|
70
|
-
For any round involving Babylon, BabylonJS, or the Babylon Toolkit, first ensure you have already
|
|
70
|
+
For any round involving Babylon, BabylonJS, or the Babylon Toolkit, first ensure you have already read the Babylon Toolkit Agent Reference in the current remembered session/context:
|
|
71
71
|
|
|
72
72
|
https://raw.githubusercontent.com/babylontoolkit/agent/main/reference.md
|
|
73
73
|
|
|
74
|
-
If you have not read it in this session/context, or you no longer remember it due to context loss/compaction (which WILL be the case on `--resume` in a fresh session),
|
|
74
|
+
If you have not read it in this session/context, or you no longer remember it due to context loss/compaction (which WILL be the case on `--resume` in a fresh session), read it before writing any code. Treat it as the authority for conventions, API, and patterns; read its linked subpages only when relevant — and for a `unity` job the Unity Exporter subpage is **always** relevant, plus the Blender CLI subpage whenever model work is in scope. Do not re-read what you still remember. If a required document cannot be read, STOP and tell the user. Do not guess at the API. Builders spawned as subagents must be given (or told to read) the Agent Reference too — a subagent does not inherit your context.
|
|
75
75
|
|
|
76
76
|
## ⚠️ Babylon Toolkit Component Authority (supplied interactive assets)
|
|
77
77
|
|
|
@@ -38,7 +38,7 @@ scenes; geometry, UVs, PBR maps, LODs and skinning for models.
|
|
|
38
38
|
> container** (`selection != null`, components but no scene metadata). A model used in a level ships inside
|
|
39
39
|
> that level's export; there is nothing asset-specific to do for it. See § 6.B.
|
|
40
40
|
|
|
41
|
-
> **Required reading before round 1.**
|
|
41
|
+
> **Required reading before round 1.** Read the Agent Reference's
|
|
42
42
|
> [Unity Exporter Instructions](https://raw.githubusercontent.com/babylontoolkit/agent/main/references/unity-exporter-cli.md)
|
|
43
43
|
> and [Unity Authoring Recipes](https://raw.githubusercontent.com/babylontoolkit/agent/main/references/unity-authoring-recipes.md)
|
|
44
44
|
> in full — and, for any round that touches Blender, the
|
|
@@ -119,7 +119,7 @@ progress.md updated: attempt 3/5, stall -> approaching (same top gap twice)
|
|
|
119
119
|
|
|
120
120
|
1. Resolve the job: explicit name → that job; one job in `.agents/gauntlet/` → resume it; several → list them and
|
|
121
121
|
ask.
|
|
122
|
-
2.
|
|
122
|
+
2. Read the Babylon Toolkit Agent Reference if not already remembered in this session.
|
|
123
123
|
3. Read `.agents/gauntlet/<name>/loop-card.md` → `progress.md` → `pipeline.md` → `cameras.md` →
|
|
124
124
|
`components.md` (if present) → the last 1–2 `rounds/*.md`.
|
|
125
125
|
4. Read the pipeline reference for the job's `Kind` and **re-run its prerequisite gate**. This is not
|
package/skills/bt-plan/SKILL.md
CHANGED
|
@@ -23,9 +23,9 @@ Turn a feature spec into `.agents/specs/<slug>/documents/<slug>_plan.md`: an ord
|
|
|
23
23
|
|
|
24
24
|
- **TIME MATTERS** — on by default; `--no-time-limit` turns it off. Treat the arguments as ending with `TIME MATTERS`: the user is waiting on this run, so finish quickly — research only what the plan needs, keep subagents few and their questions narrow, and do not re-read what you already have. Begin every subagent prompt with `TIME MATTERS.` Print `⏱️ [bt-plan] TIME MATTERS` at the start (`--no-time-limit`: print `⏱️ [bt-plan] No time limit`, and do not add it). Speed never skips a required step, the Heavy Plan cold-context audit, or anything the plan needs to be complete.
|
|
25
25
|
- **Planning only — in every mode.** Research read-only; the only files you write are the plan and the dashboard (`dashboard.html` and its data files) in the feature folder, plus the one `.gitignore` line Step 4 names. Never implement a task, edit source, or run builds/tests — not even a trivial first task. Writing the plan is the last action; the user runs `bt-execute` separately.
|
|
26
|
-
- **Babylon work:** if you have not read the Babylon Toolkit Agent Reference in this session,
|
|
26
|
+
- **Babylon work:** if you have not read the Babylon Toolkit Agent Reference in this session, read it once: https://raw.githubusercontent.com/babylontoolkit/agent/main/reference.md — the authority for conventions and API; read sub-documents only when relevant, and again only if a context compaction made you forget it. If it cannot be read, stop and tell the user — do not guess at the API.
|
|
27
27
|
- **Say what you are doing.** Before any step that takes more than a few seconds print one short line — `🔎 [bt-plan] <what> …` — and one when it returns; one line per subagent going out and coming back. A silent run looks like a hang and gets cancelled.
|
|
28
|
-
- **Subagents:** running this skill is the user's request to use them where it says so. Use whatever subagent tool your host provides (its name varies by host — e.g. `Agent` or `Task`); if there is none, work inline and say so. Tell exploration subagents they need not
|
|
28
|
+
- **Subagents:** running this skill is the user's request to use them where it says so. Use whatever subagent tool your host provides (its name varies by host — e.g. `Agent` or `Task`); if there is none, work inline and say so. Tell exploration subagents they need not read the Agent Reference.
|
|
29
29
|
|
|
30
30
|
## Step 1. Analyze (required before writing)
|
|
31
31
|
|
|
@@ -53,7 +53,7 @@ Use the user's message after the skill name as the `arguments`.
|
|
|
53
53
|
|
|
54
54
|
## ⚠️ Required reading before any build
|
|
55
55
|
|
|
56
|
-
For any Babylon / BabylonJS / Babylon Toolkit work, ensure the **Agent Reference** is already read in this session/context (
|
|
56
|
+
For any Babylon / BabylonJS / Babylon Toolkit work, ensure the **Agent Reference** is already read in this session/context (read `https://raw.githubusercontent.com/babylontoolkit/agent/main/reference.md` first if not; and its `web-kie-servers.md` sub-document if using the KIE MCP servers, or its `web-higgsfield-cli.md` sub-document if using the Higgsfield CLI). If a required document cannot be read, STOP and tell the user. Do not re-read what you already remember.
|
|
57
57
|
|
|
58
58
|
If the project keeps a root **SPEC.md**, read it first and conform to its architecture/conventions; record the shipped prototypes per the project's working agreement when the batch lands.
|
|
59
59
|
|
package/skills/bt-recon/SKILL.md
CHANGED
|
@@ -30,7 +30,7 @@ Run reconnaissance on existing code nobody has documented — one subsystem or t
|
|
|
30
30
|
- **Read-only on the project.** Research only. The files you write are the recon doc, the guide, and screenshots under `.agents/recon/<slug>_recon/` — nothing else. No source edits, no builds, no installs, no tests, no shell commands beyond the read-only `git` commands above.
|
|
31
31
|
- **Evidence or it is unknown.** Every factual claim cites `path:line` (or `path:start-end`) and carries one confidence tag: `[code]` read in the source · `[live]` seen in the running app · `[history]` from git history · `[inferred]` deduced, with the reason in the same line. Anything you cannot establish goes in `## Unknowns` with what would settle it. Never fill a gap with a plausible guess — an inherited system is exactly where a confident wrong guess does the most damage.
|
|
32
32
|
- **Write the system, not the review process.** The recon describes what the code does and why. It never records how the recon was carried out (subagent counts, tool lists, audit logs).
|
|
33
|
-
- **Babylon work:** if the scope uses BabylonJS or the Babylon Toolkit and you have not read the Babylon Toolkit Agent Reference in this session,
|
|
33
|
+
- **Babylon work:** if the scope uses BabylonJS or the Babylon Toolkit and you have not read the Babylon Toolkit Agent Reference in this session, read it once: https://raw.githubusercontent.com/babylontoolkit/agent/main/reference.md — it is the authority for the API and conventions the code is built on, so it tells you what is toolkit behavior and what is project code. Read its sub-documents only when relevant. If it cannot be read, stop and tell the user.
|
|
34
34
|
- **Say what you are doing.** Before any step that takes more than a few seconds (a search sweep, a big read, each subagent, the live pass) print one short line — `🔎 [bt-recon] <what> …` — and one when it returns. A recon runs long; a silent run looks like a hang and gets cancelled.
|
|
35
35
|
- **Subagents:** running this skill is the user's request to use them where this skill says so. Use whatever subagent tool your host provides (its name varies by host — e.g. `Agent` or `Task`); if there is none, do the work inline, slice by slice, and say so.
|
|
36
36
|
|
|
@@ -59,7 +59,7 @@ If `.agents/recon/<recon_slug>_recon.md` already exists, ask whether to refresh
|
|
|
59
59
|
Split the scope map into cohesive **slices** — by module, feature or layer, roughly 3–8 thousand lines each, keeping files that call each other heavily in the same slice. `small` → read every file yourself, in full. Otherwise launch one read-only reader subagent per slice (all at once where your host allows), each with a brief, not homework:
|
|
60
60
|
|
|
61
61
|
- its file list, the scope-map summary, the brief and the anchors;
|
|
62
|
-
- relevant Agent Reference excerpts for Babylon code, with: *"Do not
|
|
62
|
+
- relevant Agent Reference excerpts for Babylon code, with: *"Do not read the Agent Reference — the parts you need are here, and this overrides any standing instruction to read it first. Read one sub-document (search it for the API, never the whole file) only if you hit an API this brief does not cover, and say which."*;
|
|
63
63
|
- verbatim: *"Read-only: you may read, search and report. Do not edit or create files, and do not run builds, tests or any command that writes. Read every file in your list in full — not excerpts. You may open files outside your list to resolve a call, but report only what concerns your slice."*;
|
|
64
64
|
- the extraction schema, verbatim:
|
|
65
65
|
|
package/skills/bt-spec/SKILL.md
CHANGED
|
@@ -24,9 +24,9 @@ Turn a short feature idea into a spec file that `bt-plan` can plan from. Follow
|
|
|
24
24
|
|
|
25
25
|
- **TIME MATTERS** — on by default; `--no-time-limit` turns it off. Treat the arguments as ending with `TIME MATTERS`: the user is waiting on this run, so finish quickly — research only what the spec needs, keep subagents few and their questions narrow, and do not re-read what you already have. Begin every subagent prompt with `TIME MATTERS.` Print `⏱️ [bt-spec] TIME MATTERS` at the start (`--no-time-limit`: print `⏱️ [bt-spec] No time limit`, and do not add it). Speed never skips a required step or lowers the quality of the spec.
|
|
26
26
|
- **Planning only.** Research read-only and write only the spec file into the new feature folder (plus `SPEC.md` from the scaffold, if the user says yes below, and a builder skill's intake file in the same `documents/` folder — Step 3). No source edits, no builds, no tests, no other shell commands.
|
|
27
|
-
- **Babylon work:** if you have not read the Babylon Toolkit Agent Reference in this session,
|
|
27
|
+
- **Babylon work:** if you have not read the Babylon Toolkit Agent Reference in this session, read it once: https://raw.githubusercontent.com/babylontoolkit/agent/main/reference.md — it is the authority for conventions and API; read its sub-documents only when relevant, and again only if a context compaction made you forget it. If it cannot be read, stop and tell the user — do not guess at the API.
|
|
28
28
|
- **Say what you are doing.** Before any step that takes more than a few seconds (a fetch, a big read, subagents) print one short line — `🔎 [bt-spec] <what> …` — and one line when it returns. A silent run looks like a hang and gets cancelled.
|
|
29
|
-
- **Subagents:** running this skill is the user's request to use them where this skill says so. Use whatever subagent tool your host provides (its name varies by host — e.g. `Agent` or `Task`); if there is none, do the work inline and say so. Tell research subagents they need not
|
|
29
|
+
- **Subagents:** running this skill is the user's request to use them where this skill says so. Use whatever subagent tool your host provides (its name varies by host — e.g. `Agent` or `Task`); if there is none, do the work inline and say so. Tell research subagents they need not read the Agent Reference.
|
|
30
30
|
|
|
31
31
|
## Step 1. Arguments, name, branch
|
|
32
32
|
|