opencrater 0.1.3 → 0.1.4

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.
Files changed (2) hide show
  1. package/cli.js +24 -3
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -43,9 +43,21 @@ const CODEX_EVENTS = [
43
43
  ];
44
44
  const MARKER = "--package " + PKG + " "; // identifies OUR hook entries only
45
45
 
46
- const cmdFor = (event, host) =>
47
- "npx -y -p @opencrater/sdk opencrater-hook --placement " + event +
48
- " --key " + KEY + " --package " + PKG + " --host " + host;
46
+ // Resilient hook command: prefer the pre-installed local runtime (no npx on
47
+ // the hot path concurrent fires racing a cold npx cache caused
48
+ // "opencrater-hook: command not found" noise in the host); fall back to npx;
49
+ // ALWAYS exit 0 with stderr silenced — a sponsor hook must never surface an
50
+ // error inside someone's session.
51
+ const cmdFor = (event, host) => {
52
+ const args = "--placement " + event + " --key " + KEY +
53
+ " --package " + PKG + " --host " + host;
54
+ const runtime = '"$HOME/.config/opencrater/runtime/node_modules/@opencrater/sdk/dist/hook.js"';
55
+ return (
56
+ "{ if [ -f " + runtime + " ]; then node " + runtime + " " + args +
57
+ "; else npx -y -p @opencrater/sdk opencrater-hook " + args +
58
+ "; fi; } 2>/dev/null || true"
59
+ );
60
+ };
49
61
 
50
62
  const CLAUDE_SETTINGS = path.join(os.homedir(), ".claude", "settings.json");
51
63
  const CODEX_HOOKS = path.join(
@@ -168,6 +180,15 @@ const cmd = process.argv[2] || "status";
168
180
  if (cmd === "on" || cmd === "enable") {
169
181
  enableIn(CLAUDE_SETTINGS, "claude_code");
170
182
  enableIn(CODEX_HOOKS, "codex");
183
+ // Pre-install the local hook runtime (background): hooks then run via
184
+ // plain node — no npx resolution latency, no cold-cache races.
185
+ try {
186
+ const { spawn } = require("node:child_process");
187
+ spawn("npm", ["install", "--prefix",
188
+ path.join(os.homedir(), ".config", "opencrater", "runtime"),
189
+ "@opencrater/sdk@latest", "--silent", "--no-audit", "--no-fund"],
190
+ { detached: true, stdio: "ignore" }).unref();
191
+ } catch {}
171
192
  console.log("OpenCrater ads enabled for Claude Code + Codex.");
172
193
  console.log("All hooks registered as triggers; cards render only at session edges");
173
194
  console.log("(SessionStart, Stop, SessionEnd, Notification) with a machine-wide frequency cap.");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencrater",
3
- "version": "0.1.3",
3
+ "version": "0.1.4",
4
4
  "description": "OpenCrater — sponsor cards in Claude Code and Codex. Free, one command, opt out anytime.",
5
5
  "keywords": [
6
6
  "opencrater",