foxref-remote 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/dist/init.js +12 -6
- package/package.json +1 -1
package/dist/init.js
CHANGED
|
@@ -222,24 +222,30 @@ function initProject(projectDir, serverUrl = "https://foxref.lienly.com", apiKey
|
|
|
222
222
|
// Start fresh if corrupted
|
|
223
223
|
}
|
|
224
224
|
}
|
|
225
|
-
// Ensure hooks array
|
|
226
|
-
if (!Array.isArray(settings.hooks)) {
|
|
227
|
-
settings.hooks =
|
|
225
|
+
// Ensure hooks is a record keyed by event name (not an array)
|
|
226
|
+
if (!settings.hooks || typeof settings.hooks !== "object" || Array.isArray(settings.hooks)) {
|
|
227
|
+
settings.hooks = {};
|
|
228
228
|
}
|
|
229
229
|
const hooks = settings.hooks;
|
|
230
|
-
|
|
230
|
+
// Check if our hook is already registered under PreToolUse
|
|
231
|
+
const preToolUse = hooks.PreToolUse || [];
|
|
232
|
+
const hookExists = preToolUse.some((group) => {
|
|
233
|
+
const groupHooks = group.hooks;
|
|
234
|
+
return groupHooks?.some((h) => h.command && String(h.command).includes("foxref-remote-inject"));
|
|
235
|
+
});
|
|
231
236
|
if (!hookExists) {
|
|
232
|
-
|
|
237
|
+
preToolUse.push({
|
|
233
238
|
matcher: "Grep|Glob",
|
|
234
239
|
hooks: [
|
|
235
240
|
{
|
|
236
241
|
type: "command",
|
|
237
242
|
command: hookPath,
|
|
238
|
-
event: "PreToolUse",
|
|
239
243
|
timeout: 5000,
|
|
244
|
+
statusMessage: "FoxRef Remote: injecting code intelligence...",
|
|
240
245
|
},
|
|
241
246
|
],
|
|
242
247
|
});
|
|
248
|
+
hooks.PreToolUse = preToolUse;
|
|
243
249
|
(0, node_fs_1.writeFileSync)(settingsPath, JSON.stringify(settings, null, 2) + "\n");
|
|
244
250
|
console.log(` Updated: ${settingsPath} (added foxref hook)`);
|
|
245
251
|
}
|