agentlane 0.0.0 → 0.4.0-rc.2
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/CHANGELOG.md +118 -0
- package/LICENSE +27 -0
- package/README.md +167 -2
- package/dist/agents/claude-plugin.js +79 -0
- package/dist/agents/cli.js +258 -0
- package/dist/agents/detect.js +88 -0
- package/dist/agents/init.js +251 -0
- package/dist/agents/launcher.js +32 -0
- package/dist/agents/package.js +119 -0
- package/dist/agents/skills.js +59 -0
- package/dist/agents/toml.js +325 -0
- package/dist/agents/wiring-check.js +117 -0
- package/dist/agents/wiring.js +374 -0
- package/dist/bench/host.js +104 -0
- package/dist/bench/live.js +511 -0
- package/dist/bench/mcp-client.js +91 -0
- package/dist/bench/model.js +15 -0
- package/dist/bench/report.js +162 -0
- package/dist/bench/run.js +121 -0
- package/dist/bench/schedule.js +140 -0
- package/dist/bench/stats.js +59 -0
- package/dist/bench-cli.js +167 -0
- package/dist/browser/aria.js +184 -0
- package/dist/browser/control.js +203 -0
- package/dist/browser/env.js +118 -0
- package/dist/browser/evidence.js +44 -0
- package/dist/browser/install.js +361 -0
- package/dist/browser/kinds.js +10 -0
- package/dist/browser/lane-browser.js +224 -0
- package/dist/browser/libraries.js +56 -0
- package/dist/browser/paths.js +29 -0
- package/dist/browser/release.js +121 -0
- package/dist/browser/screen.js +19 -0
- package/dist/browser/signin.js +154 -0
- package/dist/browser/stop.js +163 -0
- package/dist/browser/tools.js +25 -0
- package/dist/cache/build.js +154 -0
- package/dist/cache/config.js +186 -0
- package/dist/cache/index.js +4 -0
- package/dist/cache/key.js +196 -0
- package/dist/cache/store.js +303 -0
- package/dist/cli.js +178 -0
- package/dist/clock.js +4 -0
- package/dist/devices/adb.js +160 -0
- package/dist/devices/android.js +214 -0
- package/dist/devices/backend.js +7 -0
- package/dist/devices/bundler.js +46 -0
- package/dist/devices/common.js +51 -0
- package/dist/devices/controls.js +65 -0
- package/dist/devices/dial.js +56 -0
- package/dist/devices/emulator.js +396 -0
- package/dist/devices/hygiene.js +202 -0
- package/dist/devices/index.js +5 -0
- package/dist/devices/launch.js +76 -0
- package/dist/devices/simctl.js +119 -0
- package/dist/devices/tools.js +1 -0
- package/dist/devices/variant.js +99 -0
- package/dist/devices/xcrun.js +265 -0
- package/dist/driver/absence.js +54 -0
- package/dist/driver/caller.js +51 -0
- package/dist/driver/client.js +312 -0
- package/dist/driver/diff.js +180 -0
- package/dist/driver/elements.js +70 -0
- package/dist/driver/engine-main.js +13 -0
- package/dist/driver/engine.js +499 -0
- package/dist/driver/errors.js +11 -0
- package/dist/driver/exec.js +66 -0
- package/dist/driver/failure.js +156 -0
- package/dist/driver/flow.js +94 -0
- package/dist/driver/idle.js +100 -0
- package/dist/driver/images.js +68 -0
- package/dist/driver/install.js +272 -0
- package/dist/driver/lock.js +101 -0
- package/dist/driver/look.js +223 -0
- package/dist/driver/maestro-child.js +194 -0
- package/dist/driver/maestro-runs.js +46 -0
- package/dist/driver/paths.js +105 -0
- package/dist/driver/pixels.js +144 -0
- package/dist/driver/plan.js +108 -0
- package/dist/driver/release.js +7 -0
- package/dist/driver/runner.js +42 -0
- package/dist/driver/selector.js +91 -0
- package/dist/driver/session.js +474 -0
- package/dist/driver/suggest.js +86 -0
- package/dist/driver/supervisor.js +251 -0
- package/dist/driver/tree.js +426 -0
- package/dist/driver-cli.js +865 -0
- package/dist/evidence/device.js +177 -0
- package/dist/evidence/evidence.js +304 -0
- package/dist/evidence/files.js +92 -0
- package/dist/hooks/env.js +81 -0
- package/dist/hooks/run.js +101 -0
- package/dist/mcp/server.js +69 -0
- package/dist/mcp/tools.js +246 -0
- package/dist/name.js +22 -0
- package/dist/plugin/aims.js +465 -0
- package/dist/plugin/conventions.js +73 -0
- package/dist/plugin/guard.js +163 -0
- package/dist/plugin/hook-cli.js +216 -0
- package/dist/plugin/session-name.js +28 -0
- package/dist/plugin/shell.js +254 -0
- package/dist/processes.js +77 -0
- package/dist/project/config.js +316 -0
- package/dist/project/schema.js +335 -0
- package/dist/project/validate.js +224 -0
- package/dist/registry/config.js +142 -0
- package/dist/registry/format.js +22 -0
- package/dist/registry/owner.js +265 -0
- package/dist/registry/paths.js +50 -0
- package/dist/registry/ports.js +26 -0
- package/dist/registry/prune.js +160 -0
- package/dist/registry/refusal.js +53 -0
- package/dist/registry/registry.js +1027 -0
- package/dist/registry/resources.js +117 -0
- package/dist/registry/rows.js +115 -0
- package/dist/registry/status.js +85 -0
- package/dist/registry/store.js +274 -0
- package/dist/registry/types.js +1 -0
- package/dist/registry-cli.js +544 -0
- package/dist/services/services.js +268 -0
- package/dist/services/system.js +189 -0
- package/dist/up/deps.js +1 -0
- package/dist/up/doctor.js +424 -0
- package/dist/up/exec.js +133 -0
- package/dist/up/lane-files.js +75 -0
- package/dist/up/lane-services.js +38 -0
- package/dist/up/maestro-env.js +172 -0
- package/dist/up/preflight.js +232 -0
- package/dist/up/release.js +148 -0
- package/dist/up/resources.js +178 -0
- package/dist/up/restart.js +87 -0
- package/dist/up/setup.js +28 -0
- package/dist/up/up.js +610 -0
- package/dist/up-cli.js +258 -0
- package/dist/usage.js +16 -0
- package/package.json +58 -3
- package/schema/agentlane.schema.json +675 -0
- package/skills/create-verification-skill/LICENSE +21 -0
- package/skills/create-verification-skill/SKILL.md +88 -0
- package/skills/dev-loop/LICENSE +21 -0
- package/skills/dev-loop/SKILL.md +61 -0
- package/skills/device/SKILL.md +8 -0
- package/skills/drive/SKILL.md +64 -0
- package/skills/maintain-verification-skill/LICENSE +21 -0
- package/skills/maintain-verification-skill/SKILL.md +42 -0
- package/skills/setup/SKILL.md +80 -0
|
@@ -0,0 +1,374 @@
|
|
|
1
|
+
import { FORMER, TOOL } from "../name.js";
|
|
2
|
+
import { CLAUDE_SETTINGS } from "./claude-plugin.js";
|
|
3
|
+
import { hookCommand, isToolkitHook, mcpLaunch } from "./launcher.js";
|
|
4
|
+
import { stubOf } from "./skills.js";
|
|
5
|
+
export const SKILLS = '.agents/skills';
|
|
6
|
+
export const CLAUDE_SKILLS = '.claude/skills';
|
|
7
|
+
const CLAUDE_HOOK_EVENTS = ['PreToolUse', 'SessionEnd'];
|
|
8
|
+
function object(doc, key) {
|
|
9
|
+
const value = doc[key] ?? {};
|
|
10
|
+
if (typeof value !== 'object' || Array.isArray(value))
|
|
11
|
+
return `its ${key} is not an object`;
|
|
12
|
+
doc[key] = value;
|
|
13
|
+
return value;
|
|
14
|
+
}
|
|
15
|
+
function list(doc, key) {
|
|
16
|
+
const value = doc[key] ?? [];
|
|
17
|
+
if (!Array.isArray(value))
|
|
18
|
+
return `${key} is not a list`;
|
|
19
|
+
doc[key] = value;
|
|
20
|
+
return value;
|
|
21
|
+
}
|
|
22
|
+
function isObject(value) {
|
|
23
|
+
return typeof value === 'object' && value !== null && !Array.isArray(value);
|
|
24
|
+
}
|
|
25
|
+
export function formerServerIn(servers) {
|
|
26
|
+
return isObject(servers) && JSON.stringify(servers[FORMER.tool] ?? null).includes(FORMER.cli);
|
|
27
|
+
}
|
|
28
|
+
function mcpEdit(file, agent) {
|
|
29
|
+
const ours = mcpLaunch();
|
|
30
|
+
return {
|
|
31
|
+
kind: 'json',
|
|
32
|
+
file,
|
|
33
|
+
agent,
|
|
34
|
+
part: 'MCP server',
|
|
35
|
+
apply: doc => {
|
|
36
|
+
const servers = object(doc, 'mcpServers');
|
|
37
|
+
if (typeof servers === 'string')
|
|
38
|
+
return servers;
|
|
39
|
+
const former = formerServerIn(servers) ? servers[FORMER.tool] : undefined;
|
|
40
|
+
const current = servers[TOOL] ?? former;
|
|
41
|
+
const kept = isObject(current) ? current : {};
|
|
42
|
+
if (former !== undefined)
|
|
43
|
+
Reflect.deleteProperty(servers, FORMER.tool);
|
|
44
|
+
servers[TOOL] = { ...kept, ...ours };
|
|
45
|
+
return null;
|
|
46
|
+
},
|
|
47
|
+
present: doc => {
|
|
48
|
+
const servers = doc.mcpServers;
|
|
49
|
+
return (isObject(servers) && TOOL in servers) || formerServerIn(servers);
|
|
50
|
+
},
|
|
51
|
+
};
|
|
52
|
+
}
|
|
53
|
+
function hasToolkitHook(entry) {
|
|
54
|
+
if (typeof entry !== 'object' || entry === null)
|
|
55
|
+
return false;
|
|
56
|
+
const fields = entry;
|
|
57
|
+
if (isToolkitHook(fields.command) || isToolkitHook(fields.bash))
|
|
58
|
+
return true;
|
|
59
|
+
return Array.isArray(fields.hooks) && fields.hooks.some(hasToolkitHook);
|
|
60
|
+
}
|
|
61
|
+
function eventEntries(doc, event) {
|
|
62
|
+
const hooks = object(doc, 'hooks');
|
|
63
|
+
if (typeof hooks === 'string')
|
|
64
|
+
return hooks;
|
|
65
|
+
return list(hooks, event);
|
|
66
|
+
}
|
|
67
|
+
function hookEdit(file, agent, part, event, entry, fields = {}) {
|
|
68
|
+
return {
|
|
69
|
+
kind: 'json',
|
|
70
|
+
file,
|
|
71
|
+
agent,
|
|
72
|
+
part,
|
|
73
|
+
apply: doc => {
|
|
74
|
+
for (const [key, value] of Object.entries(fields))
|
|
75
|
+
doc[key] ??= value;
|
|
76
|
+
const entries = eventEntries(doc, event);
|
|
77
|
+
if (typeof entries === 'string')
|
|
78
|
+
return entries;
|
|
79
|
+
const ours = entries.filter(hasToolkitHook);
|
|
80
|
+
if (ours.length === 1 && JSON.stringify(ours[0]) === JSON.stringify(entry))
|
|
81
|
+
return null;
|
|
82
|
+
const rest = entries.filter(e => !hasToolkitHook(e));
|
|
83
|
+
entries.splice(0, entries.length, ...rest, entry);
|
|
84
|
+
return null;
|
|
85
|
+
},
|
|
86
|
+
present: doc => {
|
|
87
|
+
const hooks = doc.hooks;
|
|
88
|
+
if (typeof hooks !== 'object' || hooks === null)
|
|
89
|
+
return false;
|
|
90
|
+
const entries = hooks[event];
|
|
91
|
+
return Array.isArray(entries) && entries.some(hasToolkitHook);
|
|
92
|
+
},
|
|
93
|
+
};
|
|
94
|
+
}
|
|
95
|
+
function command(agent, event, extra = {}) {
|
|
96
|
+
return { type: 'command', command: hookCommand(agent, event), ...extra };
|
|
97
|
+
}
|
|
98
|
+
export function disablesOurServer(doc) {
|
|
99
|
+
const disabled = doc.disabledMcpjsonServers;
|
|
100
|
+
return Array.isArray(disabled) && (disabled.includes(TOOL) || disabled.includes(FORMER.tool));
|
|
101
|
+
}
|
|
102
|
+
function claudeEdits() {
|
|
103
|
+
return [
|
|
104
|
+
mcpEdit('.mcp.json', 'claude'),
|
|
105
|
+
{
|
|
106
|
+
kind: 'json',
|
|
107
|
+
file: CLAUDE_SETTINGS,
|
|
108
|
+
agent: 'claude',
|
|
109
|
+
part: 'MCP server',
|
|
110
|
+
apply: doc => {
|
|
111
|
+
if (!disablesOurServer(doc))
|
|
112
|
+
return null;
|
|
113
|
+
const rest = doc.disabledMcpjsonServers.filter(name => name !== TOOL && name !== FORMER.tool);
|
|
114
|
+
if (rest.length > 0)
|
|
115
|
+
doc.disabledMcpjsonServers = rest;
|
|
116
|
+
else
|
|
117
|
+
delete doc.disabledMcpjsonServers;
|
|
118
|
+
return null;
|
|
119
|
+
},
|
|
120
|
+
present: () => false,
|
|
121
|
+
},
|
|
122
|
+
hookEdit(CLAUDE_SETTINGS, 'claude', 'guard hook', 'PreToolUse', {
|
|
123
|
+
matcher: 'Bash|Monitor',
|
|
124
|
+
hooks: [command('claude', 'pre-tool-use', { timeout: 30 })],
|
|
125
|
+
}),
|
|
126
|
+
hookEdit(CLAUDE_SETTINGS, 'claude', 'release hook', 'SessionEnd', {
|
|
127
|
+
matcher: 'prompt_input_exit|logout|other',
|
|
128
|
+
hooks: [command('claude', 'session-end', { timeout: 10 })],
|
|
129
|
+
}),
|
|
130
|
+
];
|
|
131
|
+
}
|
|
132
|
+
export function hasClaudeHooks(doc) {
|
|
133
|
+
const hooks = doc.hooks;
|
|
134
|
+
if (typeof hooks !== 'object' || hooks === null)
|
|
135
|
+
return false;
|
|
136
|
+
return CLAUDE_HOOK_EVENTS.some(event => {
|
|
137
|
+
const entries = hooks[event];
|
|
138
|
+
return Array.isArray(entries) && entries.some(hasToolkitHook);
|
|
139
|
+
});
|
|
140
|
+
}
|
|
141
|
+
function claudePluginEdits(disableServer) {
|
|
142
|
+
const disable = {
|
|
143
|
+
kind: 'json',
|
|
144
|
+
file: CLAUDE_SETTINGS,
|
|
145
|
+
agent: 'claude',
|
|
146
|
+
part: 'plugin',
|
|
147
|
+
apply: doc => {
|
|
148
|
+
const disabled = list(doc, 'disabledMcpjsonServers');
|
|
149
|
+
if (typeof disabled === 'string')
|
|
150
|
+
return disabled;
|
|
151
|
+
const former = disabled.indexOf(FORMER.tool);
|
|
152
|
+
if (former !== -1)
|
|
153
|
+
disabled.splice(former, 1);
|
|
154
|
+
if (!disabled.includes(TOOL))
|
|
155
|
+
disabled.push(TOOL);
|
|
156
|
+
return null;
|
|
157
|
+
},
|
|
158
|
+
present: doc => pluginEnabled(doc) || disablesOurServer(doc),
|
|
159
|
+
};
|
|
160
|
+
const removeHooks = {
|
|
161
|
+
kind: 'json',
|
|
162
|
+
file: CLAUDE_SETTINGS,
|
|
163
|
+
agent: 'claude',
|
|
164
|
+
part: 'plugin',
|
|
165
|
+
apply: doc => {
|
|
166
|
+
if (!hasClaudeHooks(doc))
|
|
167
|
+
return null;
|
|
168
|
+
const kept = Object.entries(doc.hooks).flatMap(([event, entries]) => {
|
|
169
|
+
if (!CLAUDE_HOOK_EVENTS.includes(event) || !Array.isArray(entries))
|
|
170
|
+
return [[event, entries]];
|
|
171
|
+
const rest = entries.filter(entry => !hasToolkitHook(entry));
|
|
172
|
+
return rest.length > 0 ? [[event, rest]] : [];
|
|
173
|
+
});
|
|
174
|
+
if (kept.length > 0)
|
|
175
|
+
doc.hooks = Object.fromEntries(kept);
|
|
176
|
+
else
|
|
177
|
+
delete doc.hooks;
|
|
178
|
+
return null;
|
|
179
|
+
},
|
|
180
|
+
present: hasClaudeHooks,
|
|
181
|
+
};
|
|
182
|
+
const rename = {
|
|
183
|
+
kind: 'json',
|
|
184
|
+
file: CLAUDE_SETTINGS,
|
|
185
|
+
agent: 'claude',
|
|
186
|
+
part: 'plugin',
|
|
187
|
+
apply: doc => {
|
|
188
|
+
renameFormerPlugin(doc);
|
|
189
|
+
return null;
|
|
190
|
+
},
|
|
191
|
+
present: doc => formerPluginKeys(doc).length > 0,
|
|
192
|
+
};
|
|
193
|
+
return disableServer ? [rename, disable, removeHooks] : [rename, removeHooks];
|
|
194
|
+
}
|
|
195
|
+
export function pluginEnabled(settings) {
|
|
196
|
+
const enabled = settings.enabledPlugins;
|
|
197
|
+
if (!isObject(enabled))
|
|
198
|
+
return false;
|
|
199
|
+
return Object.entries(enabled).some(([key, on]) => key.startsWith(`${TOOL}@`) && on === true);
|
|
200
|
+
}
|
|
201
|
+
export function formerPluginKeys(settings) {
|
|
202
|
+
const enabled = settings?.enabledPlugins;
|
|
203
|
+
return isObject(enabled) ? Object.keys(enabled).filter(key => key.startsWith(`${FORMER.tool}@`)) : [];
|
|
204
|
+
}
|
|
205
|
+
/** Enables the plugin under this version's name where settings enabled 0.2.x's, and renames its marketplace with it. */
|
|
206
|
+
function renameFormerPlugin(doc) {
|
|
207
|
+
const enabled = doc.enabledPlugins;
|
|
208
|
+
if (!isObject(enabled))
|
|
209
|
+
return;
|
|
210
|
+
const marketplaces = doc.extraKnownMarketplaces;
|
|
211
|
+
for (const key of formerPluginKeys(doc)) {
|
|
212
|
+
const marketplace = key.slice(FORMER.tool.length + 1);
|
|
213
|
+
const renamed = marketplace === FORMER.tool ? TOOL : marketplace;
|
|
214
|
+
enabled[`${TOOL}@${renamed}`] ??= enabled[key];
|
|
215
|
+
Reflect.deleteProperty(enabled, key);
|
|
216
|
+
if (renamed !== marketplace && isObject(marketplaces) && marketplace in marketplaces) {
|
|
217
|
+
marketplaces[renamed] ??= marketplaces[marketplace];
|
|
218
|
+
Reflect.deleteProperty(marketplaces, marketplace);
|
|
219
|
+
}
|
|
220
|
+
}
|
|
221
|
+
}
|
|
222
|
+
function codexEdits() {
|
|
223
|
+
const { command: launcher, args } = mcpLaunch();
|
|
224
|
+
return [
|
|
225
|
+
{
|
|
226
|
+
kind: 'toml',
|
|
227
|
+
file: '.codex/config.toml',
|
|
228
|
+
agent: 'codex',
|
|
229
|
+
part: 'MCP server',
|
|
230
|
+
table: ['mcp_servers', FORMER.tool],
|
|
231
|
+
body: null,
|
|
232
|
+
},
|
|
233
|
+
{
|
|
234
|
+
kind: 'toml',
|
|
235
|
+
file: '.codex/config.toml',
|
|
236
|
+
agent: 'codex',
|
|
237
|
+
part: 'MCP server',
|
|
238
|
+
table: ['mcp_servers', TOOL],
|
|
239
|
+
body: `command = ${JSON.stringify(launcher)}\nargs = [${args.map(a => JSON.stringify(a)).join(', ')}]`,
|
|
240
|
+
},
|
|
241
|
+
hookEdit('.codex/hooks.json', 'codex', 'guard hook', 'PreToolUse', {
|
|
242
|
+
matcher: 'Bash',
|
|
243
|
+
hooks: [command('codex', 'pre-tool-use', { timeout: 30 })],
|
|
244
|
+
}),
|
|
245
|
+
hookEdit('.codex/hooks.json', 'codex', 'release hook', 'SessionEnd', {
|
|
246
|
+
hooks: [command('codex', 'session-end', { timeout: 3 })],
|
|
247
|
+
}),
|
|
248
|
+
];
|
|
249
|
+
}
|
|
250
|
+
function cursorEdits() {
|
|
251
|
+
const version = { version: 1 };
|
|
252
|
+
return [
|
|
253
|
+
mcpEdit('.cursor/mcp.json', 'cursor'),
|
|
254
|
+
hookEdit('.cursor/hooks.json', 'cursor', 'guard hook', 'beforeShellExecution', { command: hookCommand('cursor', 'pre-tool-use'), timeout: 30 }, version),
|
|
255
|
+
hookEdit('.cursor/hooks.json', 'cursor', 'release hook', 'sessionEnd', { command: hookCommand('cursor', 'session-end'), timeout: 10 }, version),
|
|
256
|
+
];
|
|
257
|
+
}
|
|
258
|
+
function removeToolkitHooks(doc) {
|
|
259
|
+
const hooks = doc.hooks;
|
|
260
|
+
if (!isObject(hooks))
|
|
261
|
+
return;
|
|
262
|
+
for (const [event, entries] of Object.entries(hooks)) {
|
|
263
|
+
if (!Array.isArray(entries))
|
|
264
|
+
continue;
|
|
265
|
+
const rest = entries.filter(entry => !hasToolkitHook(entry));
|
|
266
|
+
if (rest.length > 0)
|
|
267
|
+
hooks[event] = rest;
|
|
268
|
+
else
|
|
269
|
+
Reflect.deleteProperty(hooks, event);
|
|
270
|
+
}
|
|
271
|
+
}
|
|
272
|
+
function copilotEdits() {
|
|
273
|
+
const file = `.github/hooks/${TOOL}.json`;
|
|
274
|
+
const version = { version: 1 };
|
|
275
|
+
const former = {
|
|
276
|
+
kind: 'json',
|
|
277
|
+
file: `.github/hooks/${FORMER.tool}.json`,
|
|
278
|
+
agent: 'copilot',
|
|
279
|
+
part: 'guard hook',
|
|
280
|
+
cleanup: true,
|
|
281
|
+
apply: doc => {
|
|
282
|
+
removeToolkitHooks(doc);
|
|
283
|
+
return null;
|
|
284
|
+
},
|
|
285
|
+
present: doc => isObject(doc.hooks) && Object.values(doc.hooks).some(e => Array.isArray(e) && e.some(hasToolkitHook)),
|
|
286
|
+
emptied: doc => Object.keys(doc).every(key => key === 'version' || (key === 'hooks' && isObject(doc.hooks) && Object.keys(doc.hooks).length === 0)),
|
|
287
|
+
};
|
|
288
|
+
return [
|
|
289
|
+
former,
|
|
290
|
+
mcpEdit('.mcp.json', 'copilot'),
|
|
291
|
+
hookEdit(file, 'copilot', 'guard hook', 'preToolUse', { type: 'command', bash: hookCommand('copilot', 'pre-tool-use'), timeoutSec: 30 }, version),
|
|
292
|
+
hookEdit(file, 'copilot', 'release hook', 'sessionEnd', { type: 'command', bash: hookCommand('copilot', 'session-end'), timeoutSec: 10 }, version),
|
|
293
|
+
];
|
|
294
|
+
}
|
|
295
|
+
function geminiEdits() {
|
|
296
|
+
const file = '.gemini/settings.json';
|
|
297
|
+
return [
|
|
298
|
+
mcpEdit(file, 'gemini'),
|
|
299
|
+
hookEdit(file, 'gemini', 'guard hook', 'BeforeTool', {
|
|
300
|
+
matcher: 'run_shell_command',
|
|
301
|
+
hooks: [command('gemini', 'pre-tool-use', { name: `${TOOL}-guard`, timeout: 30_000 })],
|
|
302
|
+
}),
|
|
303
|
+
hookEdit(file, 'gemini', 'release hook', 'SessionEnd', {
|
|
304
|
+
hooks: [command('gemini', 'session-end', { name: `${TOOL}-release`, timeout: 10_000 })],
|
|
305
|
+
}),
|
|
306
|
+
];
|
|
307
|
+
}
|
|
308
|
+
function antigravityEdits() {
|
|
309
|
+
const ours = {
|
|
310
|
+
PreToolUse: [{ matcher: 'run_command', hooks: [command('antigravity', 'pre-tool-use', { timeout: 30 })] }],
|
|
311
|
+
};
|
|
312
|
+
return [
|
|
313
|
+
mcpEdit('.agents/mcp_config.json', 'antigravity'),
|
|
314
|
+
{
|
|
315
|
+
kind: 'json',
|
|
316
|
+
file: '.agents/hooks.json',
|
|
317
|
+
agent: 'antigravity',
|
|
318
|
+
part: 'guard hook',
|
|
319
|
+
apply: doc => {
|
|
320
|
+
Reflect.deleteProperty(doc, FORMER.tool);
|
|
321
|
+
doc[TOOL] = ours;
|
|
322
|
+
return null;
|
|
323
|
+
},
|
|
324
|
+
present: doc => TOOL in doc || FORMER.tool in doc,
|
|
325
|
+
},
|
|
326
|
+
];
|
|
327
|
+
}
|
|
328
|
+
export function agentEdits(agent, claudePlugin, disableServer = true) {
|
|
329
|
+
switch (agent) {
|
|
330
|
+
case 'claude':
|
|
331
|
+
return claudePlugin ? claudePluginEdits(disableServer) : claudeEdits();
|
|
332
|
+
case 'codex':
|
|
333
|
+
return codexEdits();
|
|
334
|
+
case 'cursor':
|
|
335
|
+
return cursorEdits();
|
|
336
|
+
case 'copilot':
|
|
337
|
+
return copilotEdits();
|
|
338
|
+
case 'gemini':
|
|
339
|
+
return geminiEdits();
|
|
340
|
+
case 'antigravity':
|
|
341
|
+
return antigravityEdits();
|
|
342
|
+
}
|
|
343
|
+
}
|
|
344
|
+
export function stubEdits(skills) {
|
|
345
|
+
return skills.map(skill => ({
|
|
346
|
+
kind: 'stub',
|
|
347
|
+
file: `${SKILLS}/${skill.name}/SKILL.md`,
|
|
348
|
+
agent: null,
|
|
349
|
+
part: 'skills',
|
|
350
|
+
skill: skill.name,
|
|
351
|
+
content: stubOf(skill),
|
|
352
|
+
}));
|
|
353
|
+
}
|
|
354
|
+
export function unlinkEdit(name) {
|
|
355
|
+
return {
|
|
356
|
+
kind: 'unlink',
|
|
357
|
+
file: `${CLAUDE_SKILLS}/${name}`,
|
|
358
|
+
agent: 'claude',
|
|
359
|
+
part: 'skill the plugin brings',
|
|
360
|
+
skill: name,
|
|
361
|
+
target: `../../${SKILLS}/${name}`,
|
|
362
|
+
};
|
|
363
|
+
}
|
|
364
|
+
export function mirrorEdit(name, source) {
|
|
365
|
+
return {
|
|
366
|
+
kind: 'link',
|
|
367
|
+
file: `${CLAUDE_SKILLS}/${name}`,
|
|
368
|
+
agent: 'claude',
|
|
369
|
+
part: 'skills',
|
|
370
|
+
skill: name,
|
|
371
|
+
target: `../../${SKILLS}/${name}`,
|
|
372
|
+
source,
|
|
373
|
+
};
|
|
374
|
+
}
|
|
@@ -0,0 +1,104 @@
|
|
|
1
|
+
import { spawnSync } from 'node:child_process';
|
|
2
|
+
import fs from 'node:fs';
|
|
3
|
+
import os from 'node:os';
|
|
4
|
+
import path from 'node:path';
|
|
5
|
+
import { findJdk17, installedMaestro, MAESTRO_OVERRIDE_ENV, sha256Of } from "../driver/install.js";
|
|
6
|
+
import { MAESTRO_RELEASE } from "../driver/release.js";
|
|
7
|
+
export const PACKAGE_ROOT = path.resolve(import.meta.dirname, '..', '..');
|
|
8
|
+
function read(command, args, timeoutMs = 20_000) {
|
|
9
|
+
const result = spawnSync(command, args, { encoding: 'utf8', timeout: timeoutMs });
|
|
10
|
+
if (result.error || result.status !== 0)
|
|
11
|
+
return null;
|
|
12
|
+
return result.stdout.trim();
|
|
13
|
+
}
|
|
14
|
+
function sysctl(name) {
|
|
15
|
+
return read('/usr/sbin/sysctl', ['-n', name]);
|
|
16
|
+
}
|
|
17
|
+
export function collectHost() {
|
|
18
|
+
const runtimes = [];
|
|
19
|
+
const listed = read('xcrun', ['simctl', 'list', 'runtimes', '-j'], 60_000);
|
|
20
|
+
if (listed) {
|
|
21
|
+
const parsed = JSON.parse(listed);
|
|
22
|
+
for (const r of parsed.runtimes ?? []) {
|
|
23
|
+
if (r.isAvailable !== false)
|
|
24
|
+
runtimes.push(`${r.name ?? '?'} (${r.buildversion ?? '?'})`);
|
|
25
|
+
}
|
|
26
|
+
}
|
|
27
|
+
const memsize = Number(sysctl('hw.memsize') ?? os.totalmem());
|
|
28
|
+
const product = read('/usr/bin/sw_vers', ['-productVersion']);
|
|
29
|
+
const build = read('/usr/bin/sw_vers', ['-buildVersion']);
|
|
30
|
+
return {
|
|
31
|
+
model: sysctl('hw.model') ?? 'unknown',
|
|
32
|
+
chip: sysctl('machdep.cpu.brand_string') ?? os.cpus()[0]?.model ?? 'unknown',
|
|
33
|
+
cores: os.cpus().length,
|
|
34
|
+
memoryGb: Math.round(memsize / 2 ** 30),
|
|
35
|
+
macos: product ? `${product} (${build ?? '?'})` : `${os.type()} ${os.release()}`,
|
|
36
|
+
xcode: (read('xcodebuild', ['-version']) ?? 'not found').replace(/\n/g, ', '),
|
|
37
|
+
runtimes,
|
|
38
|
+
node: process.version,
|
|
39
|
+
};
|
|
40
|
+
}
|
|
41
|
+
const PRESSURE_LEVELS = { '1': 'normal', '2': 'warn', '4': 'critical' };
|
|
42
|
+
export function parseSwapUsedMb(text) {
|
|
43
|
+
const used = text ? /used = ([\d.]+)M/.exec(text)?.[1] : undefined;
|
|
44
|
+
return used === undefined ? null : Number(used);
|
|
45
|
+
}
|
|
46
|
+
export function parseFreePercent(text) {
|
|
47
|
+
const free = text ? /free percentage: (\d+)%/.exec(text)?.[1] : undefined;
|
|
48
|
+
return free === undefined ? null : Number(free);
|
|
49
|
+
}
|
|
50
|
+
export function sampleLoad() {
|
|
51
|
+
const [one = 0, five = 0, fifteen = 0] = os.loadavg();
|
|
52
|
+
const level = sysctl('kern.memorystatus_vm_pressure_level');
|
|
53
|
+
return {
|
|
54
|
+
at: new Date().toISOString(),
|
|
55
|
+
loadavg: [one, five, fifteen],
|
|
56
|
+
pressure: (level === null ? undefined : PRESSURE_LEVELS[level]) ?? 'unknown',
|
|
57
|
+
memoryFreePercent: parseFreePercent(read('/usr/bin/memory_pressure', ['-Q'])),
|
|
58
|
+
swapUsedMb: parseSwapUsedMb(sysctl('vm.swapusage')),
|
|
59
|
+
};
|
|
60
|
+
}
|
|
61
|
+
export function collectToolkit() {
|
|
62
|
+
const manifest = JSON.parse(fs.readFileSync(path.join(PACKAGE_ROOT, 'package.json'), 'utf8'));
|
|
63
|
+
const commit = read('git', ['-C', PACKAGE_ROOT, 'rev-parse', 'HEAD']);
|
|
64
|
+
const status = commit === null ? null : read('git', ['-C', PACKAGE_ROOT, 'status', '--porcelain', '--untracked-files=no']);
|
|
65
|
+
return { version: manifest.version, commit, dirty: status === null ? null : status !== '' };
|
|
66
|
+
}
|
|
67
|
+
export async function collectMaestro(env) {
|
|
68
|
+
const override = env[MAESTRO_OVERRIDE_ENV];
|
|
69
|
+
const binary = override ?? installedMaestro(env)?.binary ?? null;
|
|
70
|
+
let jarSha256 = null;
|
|
71
|
+
let binarySha256 = null;
|
|
72
|
+
let reportedVersion = null;
|
|
73
|
+
if (binary && fs.existsSync(binary)) {
|
|
74
|
+
binarySha256 = await sha256Of(binary);
|
|
75
|
+
const lib = path.join(path.dirname(path.dirname(binary)), 'lib');
|
|
76
|
+
const jar = fs.existsSync(lib) ? fs.readdirSync(lib).find(f => /^maestro-cli-.*\.jar$/.test(f)) : undefined;
|
|
77
|
+
if (jar)
|
|
78
|
+
jarSha256 = await sha256Of(path.join(lib, jar));
|
|
79
|
+
const jdk = await findJdk17(env).catch(() => null);
|
|
80
|
+
if (jdk) {
|
|
81
|
+
const ran = spawnSync(binary, ['--version'], {
|
|
82
|
+
encoding: 'utf8',
|
|
83
|
+
timeout: 60_000,
|
|
84
|
+
env: { ...env, JAVA_HOME: jdk.javaHome, MAESTRO_CLI_NO_ANALYTICS: '1', MAESTRO_DISABLE_UPDATE_CHECK: 'true' },
|
|
85
|
+
});
|
|
86
|
+
const line = ran.stdout
|
|
87
|
+
.split('\n')
|
|
88
|
+
.map(l => l.trim())
|
|
89
|
+
.filter(l => l !== '')
|
|
90
|
+
.at(-1);
|
|
91
|
+
if (ran.status === 0 && line)
|
|
92
|
+
reportedVersion = line;
|
|
93
|
+
}
|
|
94
|
+
}
|
|
95
|
+
return {
|
|
96
|
+
version: MAESTRO_RELEASE.version,
|
|
97
|
+
binary,
|
|
98
|
+
override: override !== undefined,
|
|
99
|
+
releaseSha256: MAESTRO_RELEASE.sha256,
|
|
100
|
+
binarySha256,
|
|
101
|
+
jarSha256,
|
|
102
|
+
reportedVersion,
|
|
103
|
+
};
|
|
104
|
+
}
|