perf(skills): cut skill tokens and load hooks from cached bytecode
Hooks start their script as __main__ from cached bytecode instead of recompiling it on every call, and the installer migrates registered old hook commands to that form. A disabled plugin is written as false instead of deleted, because a deleted key in settings.local.json lets a true in settings.json win; the auto-compact window drops to 300000. The coach hour prints one ready line chosen by the time of day instead of asking the agent to load the skill, kvb-cleanup moves its procedure into plan.md, and the token counter reads subagent transcripts too and counts with Counter and defaultdict instead of .get defaults. 🎯 Fix: 88 % 💥 Break: 8 % 💸 Tokens: – ⏱️ Velocity: – 🛡️ Security: 100 % 🏆 Score: 81 🚦 Gate: ⛔ fix 88 % < 90, break 8 % > 5 Created-with: https://s.veen.world/skills Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
1 parent
d695bb2b58
commit
6c63c364bd
13 files changed
+250
-130
No files matched your search
@@ -55,11 +55,12 @@ for (const [name, entry] of Object.entries(MARKETPLACES)) {
|
||||
}
|
||||
data.enabledPlugins = Object.assign(data.enabledPlugins || {}, PLUGINS);
|
||||
for (const [plugin, marketplace] of Object.entries(RETIRED_PLUGINS)) {
|
||||
delete data.enabledPlugins[plugin];
|
||||
// Trip-wire: this file can be settings.local.json; a deleted key there lets a true in settings.json win, a false overrides it.
|
||||
data.enabledPlugins[plugin] = false;
|
||||
delete data.extraKnownMarketplaces[marketplace];
|
||||
}
|
||||
data.env = data.env || {};
|
||||
if (!data.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW) data.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW = "500000";
|
||||
if (!data.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW) data.env.CLAUDE_CODE_AUTO_COMPACT_WINDOW = "300000";
|
||||
const PYTHON = "/usr/bin/python3 -I";
|
||||
const ABSOLUTE = { python3: PYTHON, bash: "/usr/bin/bash" };
|
||||
require("./council-deny").withCouncilDeny(data);
|
||||
@@ -129,15 +130,20 @@ const SCRIPT_HOOKS = [
|
||||
["kvb-org-perform/scripts/log.py", "PostToolUse", "Bash", "persist", {}],
|
||||
["kvb-agent-optimize/scripts/graph.py", "PreToolUse", null, "hook", { timeout: 30 }],
|
||||
];
|
||||
// Trip-wire: python3 recompiles the script it is started with on every call and caches only imported modules; loading it as __main__ by file path reuses its __pycache__.
|
||||
const AS_MAIN = `'import importlib.util as u,sys;s=u.spec_from_file_location("__main__",sys.argv[1]);m=u.module_from_spec(s);sys.argv=sys.argv[1:];sys.modules["__main__"]=m;s.loader.exec_module(m)'`;
|
||||
for (const [script, event, matcher, sub, extra] of SCRIPT_HOOKS) {
|
||||
data.hooks[event] = data.hooks[event] || [];
|
||||
const registered = data.hooks[event].some((entry) =>
|
||||
(entry.hooks || []).some((hook) =>
|
||||
String(hook.command).includes(script) && String(hook.command).endsWith(` ${sub}`)));
|
||||
if (registered) continue;
|
||||
const file = JSON.stringify(path.join(path.dirname(settingsPath), "skills", ...script.split("/")));
|
||||
// Trip-wire: python3 on a missing file exits 2, which blocks every prompt or tool call; the test makes it exit 1.
|
||||
const command = `[ -f ${file} ] && ${PYTHON} ${file} ${sub}`;
|
||||
const command = `[ -f ${file} ] && ${PYTHON} -c ${AS_MAIN} ${file} ${sub}`;
|
||||
const legacy = [`${PYTHON} ${file} ${sub}`, `[ -f ${file} ] && ${PYTHON} ${file} ${sub}`];
|
||||
const registered = data.hooks[event].flatMap((entry) => entry.hooks || []).find((hook) =>
|
||||
String(hook.command).includes(script) && String(hook.command).endsWith(` ${sub}`));
|
||||
if (registered) {
|
||||
if (legacy.includes(registered.command)) registered.command = command;
|
||||
continue;
|
||||
}
|
||||
const entry = { hooks: [{ type: "command", command, ...extra }] };
|
||||
data.hooks[event].push(matcher ? { matcher, ...entry } : entry);
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user