opencrater 0.1.9 → 0.2.0

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 -5
  2. package/package.json +1 -1
package/cli.js CHANGED
@@ -37,6 +37,13 @@ const CLAUDE_EVENTS = [
37
37
  "Elicitation", "ElicitationResult", "ConfigChange", "InstructionsLoaded",
38
38
  "WorktreeCreate", "WorktreeRemove", "CwdChanged", "FileChanged", "MessageDisplay",
39
39
  ];
40
+ // Gemini CLI hooks (verified HookEventName set, GA since v0.26.0):
41
+ // ~/.gemini/settings.json takes the same rule shape as Claude Code.
42
+ const GEMINI_EVENTS = [
43
+ "SessionStart", "SessionEnd", "BeforeAgent", "AfterAgent", "BeforeModel",
44
+ "AfterModel", "BeforeToolSelection", "BeforeTool", "AfterTool",
45
+ "PreCompress", "Notification",
46
+ ];
40
47
  const CODEX_EVENTS = [
41
48
  "SessionStart", "Stop", "UserPromptSubmit", "PreToolUse", "PostToolUse",
42
49
  "PermissionRequest", "PreCompact", "PostCompact",
@@ -64,6 +71,7 @@ const CODEX_HOOKS = path.join(
64
71
  process.env.CODEX_HOME || path.join(os.homedir(), ".codex"),
65
72
  "hooks.json",
66
73
  );
74
+ const GEMINI_SETTINGS = path.join(os.homedir(), ".gemini", "settings.json");
67
75
 
68
76
  function readJson(p) {
69
77
  try {
@@ -92,7 +100,9 @@ const isOurs = (rule) =>
92
100
  );
93
101
 
94
102
  function enableIn(file, host) {
95
- const events = host === "codex" ? CODEX_EVENTS : CLAUDE_EVENTS;
103
+ const events =
104
+ host === "codex" ? CODEX_EVENTS :
105
+ host === "gemini_cli" ? GEMINI_EVENTS : CLAUDE_EVENTS;
96
106
  const settings = readJson(file);
97
107
  if (!settings.hooks) settings.hooks = {};
98
108
  let changed = false;
@@ -251,11 +261,15 @@ if (cmd === "on" || cmd === "enable") {
251
261
  } else {
252
262
  console.log("· Codex not found — skipped");
253
263
  }
254
- if (hosts.openclaw) {
255
- console.log("✓ OpenClaw detected — native hook support is rolling out; cards will enable automatically.");
256
- }
257
264
  if (hosts.gemini_cli) {
258
- console.log("✓ Gemini CLI detected — native hook support is rolling out; cards will enable automatically.");
265
+ enableIn(GEMINI_SETTINGS, "gemini_cli");
266
+ console.log("✓ Gemini CLI detected — connected (" + GEMINI_SETTINGS + ")");
267
+ } else {
268
+ console.log("· Gemini CLI not found — skipped");
269
+ }
270
+ if (hosts.openclaw) {
271
+ console.log("· OpenClaw detected — its hooks run inside the gateway (no terminal");
272
+ console.log(" overlay surface); message-level sponsorship is on the roadmap.");
259
273
  }
260
274
  // Pre-install the local hook runtime (background): hooks then run via
261
275
  // plain node — no npx resolution latency, no cold-cache races.
@@ -279,6 +293,8 @@ if (cmd === "on" || cmd === "enable") {
279
293
  } else if (cmd === "off" || cmd === "disable") {
280
294
  const a = disableIn(CLAUDE_SETTINGS);
281
295
  const b = disableIn(CODEX_HOOKS);
296
+ const c = disableIn(GEMINI_SETTINGS);
297
+ void c;
282
298
  console.log(a || b ? "OpenCrater ads disabled. Publisher hooks (if any) were not touched." : "Nothing to remove — OpenCrater ads were not enabled.");
283
299
  } else if (cmd === "x" || cmd === "dismiss") {
284
300
  dismissNow();
@@ -288,8 +304,11 @@ if (cmd === "on" || cmd === "enable") {
288
304
  const hosts = detectHosts();
289
305
  const cc = statusIn(CLAUDE_SETTINGS);
290
306
  const cx = statusIn(CODEX_HOOKS);
307
+ const gm = statusIn(GEMINI_SETTINGS);
291
308
  console.log("Claude Code:", !hosts.claude_code ? "not installed" : cc.length ? "enabled (" + cc.length + " hooks)" : "detected — run: npx opencrater on");
292
309
  console.log("Codex: ", !hosts.codex ? "not installed" : cx.length ? "enabled (" + cx.length + " hooks)" : "detected — run: npx opencrater on");
310
+ console.log("Gemini CLI:", !hosts.gemini_cli ? "not installed" : gm.length ? "enabled (" + gm.length + " hooks)" : "detected — run: npx opencrater on");
311
+ if (hosts.openclaw) console.log("OpenClaw: detected — message-level sponsorship on the roadmap");
293
312
  } else {
294
313
  console.log("Usage: npx opencrater <on|off|status|x|show>");
295
314
  console.log(" x dismiss the sponsor card currently on screen");
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "opencrater",
3
- "version": "0.1.9",
3
+ "version": "0.2.0",
4
4
  "description": "OpenCrater — sponsor cards in Claude Code and Codex. Free, one command, opt out anytime.",
5
5
  "keywords": [
6
6
  "opencrater",