session-intelligence-cli 0.1.0 → 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/dist/setup.js +18 -10
- package/package.json +1 -1
package/dist/setup.js
CHANGED
|
@@ -13,15 +13,15 @@ function prompt(question) {
|
|
|
13
13
|
});
|
|
14
14
|
}
|
|
15
15
|
const HOOKS_CONFIG = {
|
|
16
|
-
SessionStart: [{ type: "command", command: "npx session-intelligence-cli report session-start" }],
|
|
17
|
-
Stop: [{ type: "command", command: "npx session-intelligence-cli report stop" }],
|
|
18
|
-
PostToolUse: [{ type: "command", command: "npx session-intelligence-cli report tool-use", timeout: 3000 }],
|
|
19
|
-
Notification: [{ type: "command", command: "npx session-intelligence-cli report notification" }],
|
|
20
|
-
SubagentStop: [{ type: "command", command: "npx session-intelligence-cli report subagent-stop", timeout: 3000 }],
|
|
16
|
+
SessionStart: [{ hooks: [{ type: "command", command: "npx session-intelligence-cli report session-start" }] }],
|
|
17
|
+
Stop: [{ hooks: [{ type: "command", command: "npx session-intelligence-cli report stop" }] }],
|
|
18
|
+
PostToolUse: [{ hooks: [{ type: "command", command: "npx session-intelligence-cli report tool-use", timeout: 3000 }] }],
|
|
19
|
+
Notification: [{ hooks: [{ type: "command", command: "npx session-intelligence-cli report notification" }] }],
|
|
20
|
+
SubagentStop: [{ hooks: [{ type: "command", command: "npx session-intelligence-cli report subagent-stop", timeout: 3000 }] }],
|
|
21
21
|
};
|
|
22
22
|
export async function setup() {
|
|
23
23
|
console.log("\n Session Intelligence — Setup\n");
|
|
24
|
-
const serverUrl = await prompt(" Server URL (
|
|
24
|
+
const serverUrl = await prompt(" Server URL (default: https://www.session-intelligence.com): ") || "https://www.session-intelligence.com";
|
|
25
25
|
const apiKey = await prompt(" API Key: ");
|
|
26
26
|
writeConfig({ apiKey, serverUrl });
|
|
27
27
|
console.log("\n Config saved to ~/.session-intelligence/config.json");
|
|
@@ -45,10 +45,18 @@ export async function setup() {
|
|
|
45
45
|
const existingHooks = (settings.hooks ?? {});
|
|
46
46
|
for (const [event, handlers] of Object.entries(HOOKS_CONFIG)) {
|
|
47
47
|
const existing = existingHooks[event] ?? [];
|
|
48
|
-
const alreadyInstalled = existing.some((h) =>
|
|
49
|
-
h !== null
|
|
50
|
-
|
|
51
|
-
h
|
|
48
|
+
const alreadyInstalled = existing.some((h) => {
|
|
49
|
+
if (typeof h !== "object" || h === null)
|
|
50
|
+
return false;
|
|
51
|
+
const entry = h;
|
|
52
|
+
if (Array.isArray(entry.hooks)) {
|
|
53
|
+
return entry.hooks.some((hook) => typeof hook === "object" &&
|
|
54
|
+
hook !== null &&
|
|
55
|
+
"command" in hook &&
|
|
56
|
+
String(hook.command).includes("session-intelligence"));
|
|
57
|
+
}
|
|
58
|
+
return false;
|
|
59
|
+
});
|
|
52
60
|
if (!alreadyInstalled) {
|
|
53
61
|
existingHooks[event] = [...existing, ...handlers];
|
|
54
62
|
}
|