opencrater 0.1.1 → 0.1.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/cli.js +23 -4
- package/package.json +1 -1
package/cli.js
CHANGED
|
@@ -25,7 +25,22 @@ const os = require("node:os");
|
|
|
25
25
|
|
|
26
26
|
const KEY = "ock_MUFntM66VEbx7e7fKoQr2a43VBx762rHkKw1G8vj";
|
|
27
27
|
const PKG = "opencrater";
|
|
28
|
-
|
|
28
|
+
// EVERY host hook is registered as a trigger; the SDK + platform decide
|
|
29
|
+
// which ones actually render (recommended session-edge hooks by default,
|
|
30
|
+
// remotely tunable). Registering everything also feeds the recommendation
|
|
31
|
+
// engine's anonymized topic signal so cards match what you're working on.
|
|
32
|
+
const CLAUDE_EVENTS = [
|
|
33
|
+
"SessionStart", "SessionEnd", "Stop", "StopFailure", "SubagentStart", "SubagentStop",
|
|
34
|
+
"Notification", "PreToolUse", "PostToolUse", "PostToolUseFailure", "PostToolBatch",
|
|
35
|
+
"PermissionRequest", "PermissionDenied", "UserPromptSubmit", "UserPromptExpansion",
|
|
36
|
+
"PreCompact", "PostCompact", "TaskCreated", "TaskCompleted", "Setup", "TeammateIdle",
|
|
37
|
+
"Elicitation", "ElicitationResult", "ConfigChange", "InstructionsLoaded",
|
|
38
|
+
"WorktreeCreate", "WorktreeRemove", "CwdChanged", "FileChanged", "MessageDisplay",
|
|
39
|
+
];
|
|
40
|
+
const CODEX_EVENTS = [
|
|
41
|
+
"SessionStart", "Stop", "UserPromptSubmit", "PreToolUse", "PostToolUse",
|
|
42
|
+
"PermissionRequest", "PreCompact", "PostCompact",
|
|
43
|
+
];
|
|
29
44
|
const MARKER = "--package " + PKG + " "; // identifies OUR hook entries only
|
|
30
45
|
|
|
31
46
|
const cmdFor = (event, host) =>
|
|
@@ -65,10 +80,11 @@ const isOurs = (rule) =>
|
|
|
65
80
|
);
|
|
66
81
|
|
|
67
82
|
function enableIn(file, host) {
|
|
83
|
+
const events = host === "codex" ? CODEX_EVENTS : CLAUDE_EVENTS;
|
|
68
84
|
const settings = readJson(file);
|
|
69
85
|
if (!settings.hooks) settings.hooks = {};
|
|
70
86
|
let changed = false;
|
|
71
|
-
for (const event of
|
|
87
|
+
for (const event of events) {
|
|
72
88
|
const list = Array.isArray(settings.hooks[event]) ? settings.hooks[event] : [];
|
|
73
89
|
const desired = {
|
|
74
90
|
matcher: "",
|
|
@@ -121,8 +137,11 @@ const cmd = process.argv[2] || "status";
|
|
|
121
137
|
if (cmd === "on" || cmd === "enable") {
|
|
122
138
|
enableIn(CLAUDE_SETTINGS, "claude_code");
|
|
123
139
|
enableIn(CODEX_HOOKS, "codex");
|
|
124
|
-
console.log("OpenCrater ads enabled for Claude Code + Codex
|
|
125
|
-
console.log("
|
|
140
|
+
console.log("OpenCrater ads enabled for Claude Code + Codex.");
|
|
141
|
+
console.log("All hooks registered as triggers; cards render only at session edges");
|
|
142
|
+
console.log("(SessionStart, Stop, SessionEnd, Notification) with a machine-wide frequency cap.");
|
|
143
|
+
console.log("Ads are personalized to what you're working on via anonymized keywords");
|
|
144
|
+
console.log("(never raw prompts, paths, or secrets).");
|
|
126
145
|
console.log("Turn off anytime: npx opencrater off (or OPENCRATER_DISABLE=1)");
|
|
127
146
|
} else if (cmd === "off" || cmd === "disable") {
|
|
128
147
|
const a = disableIn(CLAUDE_SETTINGS);
|