clisponsor 1.0.5 → 1.0.6

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/bin/clisponsor.mjs +35 -14
  2. package/package.json +1 -1
@@ -15,6 +15,7 @@ const DEFAULT_SERVE_BASE_URL =
15
15
  const DEFAULT_BACKEND_BASE_URL = process.env.CLISPONSOR_BACKEND_BASE_URL || "https://backend.clisponsor.com";
16
16
  const HOOK_VERSION = "1.0.0";
17
17
  const NETWORK_TIMEOUT_MS = 3000;
18
+ const ANTIGRAVITY_EVENTS = ["PreInvocation", "UserPromptSubmit", "PostInvocation", "Stop"];
18
19
 
19
20
  function argValue(name) {
20
21
  const prefix = `${name}=`;
@@ -157,15 +158,15 @@ function commandExists(command) {
157
158
 
158
159
  function isClisponsorCommand(value) {
159
160
  return (
160
- typeof value === "string" &&
161
- (value.includes("clisponsor_claude_hook.mjs") ||
162
- value.includes("clisponsor_gemini_hook.mjs") ||
163
- value.includes("clisponsor_antigravity_hook.mjs") ||
164
- value.includes(`${path.sep}.clisponsor${path.sep}`) ||
165
- value.includes("/.clisponsor/") ||
166
- value.includes("\\.clisponsor\\"))
167
- );
168
- }
161
+ typeof value === "string" &&
162
+ (value.includes("clisponsor_claude_hook.mjs") ||
163
+ value.includes("clisponsor_gemini_hook.mjs") ||
164
+ value.includes("clisponsor_antigravity_hook.mjs") ||
165
+ value.includes(`${path.sep}.clisponsor${path.sep}`) ||
166
+ value.includes("/.clisponsor/") ||
167
+ value.includes("\\.clisponsor\\"))
168
+ );
169
+ }
169
170
 
170
171
  function isClisponsorHookEntry(entry) {
171
172
  if (!isPlainObject(entry)) return false;
@@ -262,6 +263,29 @@ function removeClaudeCommandHooks(settings) {
262
263
  return changed;
263
264
  }
264
265
 
266
+ function setAntigravityCommandHooks(settings, hookPath) {
267
+ removeClaudeCommandHooks(settings);
268
+ settings.clisponsor = Object.fromEntries(
269
+ ANTIGRAVITY_EVENTS.map((eventName) => [
270
+ eventName,
271
+ [
272
+ {
273
+ type: "command",
274
+ command: `node ${JSON.stringify(hookPath)} ${eventName}`,
275
+ timeout: 5,
276
+ },
277
+ ],
278
+ ]),
279
+ );
280
+ }
281
+
282
+ function removeAntigravityCommandHooks(settings) {
283
+ const removedLegacyHooks = removeClaudeCommandHooks(settings);
284
+ const removedNativeHooks = Object.hasOwn(settings, "clisponsor");
285
+ if (removedNativeHooks) delete settings.clisponsor;
286
+ return removedLegacyHooks || removedNativeHooks;
287
+ }
288
+
265
289
  async function registerDevice() {
266
290
  const email = positionalArg(3);
267
291
  if (!email) {
@@ -462,10 +486,7 @@ function installAntigravity() {
462
486
 
463
487
  const hooksPath = path.join(HOME, ".gemini", "config", "hooks.json");
464
488
  const hooksConfig = readEditableJson(hooksPath, {});
465
- addGeminiCommandHook(hooksConfig, "PreInvocation", "*", `node ${JSON.stringify(hookPath)} PreInvocation`);
466
- addGeminiCommandHook(hooksConfig, "UserPromptSubmit", "*", `node ${JSON.stringify(hookPath)} UserPromptSubmit`);
467
- addGeminiCommandHook(hooksConfig, "PostInvocation", "*", `node ${JSON.stringify(hookPath)} PostInvocation`);
468
- addGeminiCommandHook(hooksConfig, "Stop", "*", `node ${JSON.stringify(hookPath)} Stop`);
489
+ setAntigravityCommandHooks(hooksConfig, hookPath);
469
490
  writeJson(hooksPath, hooksConfig);
470
491
  console.log(`Updated ${hooksPath}`);
471
492
  console.log("Antigravity CLI hook installed.");
@@ -528,7 +549,7 @@ function uninstallGemini() {
528
549
  function uninstallAntigravity() {
529
550
  const hooksPath = path.join(HOME, ".gemini", "config", "hooks.json");
530
551
  const hooksConfig = readEditableJson(hooksPath, {});
531
- if (removeClaudeCommandHooks(hooksConfig)) {
552
+ if (removeAntigravityCommandHooks(hooksConfig)) {
532
553
  writeJson(hooksPath, hooksConfig);
533
554
  console.log(`Removed CLIsponsor hooks from ${hooksPath}`);
534
555
  } else {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "clisponsor",
3
- "version": "1.0.5",
3
+ "version": "1.0.6",
4
4
  "description": "CLIsponsor installer for Codex, Claude Code, and Gemini sponsored CLI placements.",
5
5
  "type": "module",
6
6
  "engines": {