memorix 0.2.1 → 0.2.3
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/cli/index.js +273 -254
- package/dist/cli/index.js.map +1 -1
- package/dist/index.js +276 -3
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/cli/index.js
CHANGED
|
@@ -2427,6 +2427,258 @@ var init_engine2 = __esm({
|
|
|
2427
2427
|
}
|
|
2428
2428
|
});
|
|
2429
2429
|
|
|
2430
|
+
// src/hooks/installers/index.ts
|
|
2431
|
+
var installers_exports = {};
|
|
2432
|
+
__export(installers_exports, {
|
|
2433
|
+
detectInstalledAgents: () => detectInstalledAgents,
|
|
2434
|
+
getHookStatus: () => getHookStatus,
|
|
2435
|
+
installHooks: () => installHooks,
|
|
2436
|
+
uninstallHooks: () => uninstallHooks
|
|
2437
|
+
});
|
|
2438
|
+
import * as fs3 from "fs/promises";
|
|
2439
|
+
import * as path5 from "path";
|
|
2440
|
+
import * as os2 from "os";
|
|
2441
|
+
function generateClaudeConfig() {
|
|
2442
|
+
const hookEntry = {
|
|
2443
|
+
type: "command",
|
|
2444
|
+
command: `${HOOK_COMMAND} ${HOOK_ARGS.join(" ")}`,
|
|
2445
|
+
timeout: 10
|
|
2446
|
+
};
|
|
2447
|
+
return {
|
|
2448
|
+
hooks: {
|
|
2449
|
+
SessionStart: [hookEntry],
|
|
2450
|
+
PostToolUse: [hookEntry],
|
|
2451
|
+
UserPromptSubmit: [hookEntry],
|
|
2452
|
+
PreCompact: [hookEntry],
|
|
2453
|
+
Stop: [hookEntry]
|
|
2454
|
+
}
|
|
2455
|
+
};
|
|
2456
|
+
}
|
|
2457
|
+
function generateWindsurfConfig() {
|
|
2458
|
+
const hookEntry = {
|
|
2459
|
+
command: `${HOOK_COMMAND} ${HOOK_ARGS.join(" ")}`,
|
|
2460
|
+
timeout: 10
|
|
2461
|
+
};
|
|
2462
|
+
return {
|
|
2463
|
+
hooks: {
|
|
2464
|
+
post_write_code: [hookEntry],
|
|
2465
|
+
post_run_command: [hookEntry],
|
|
2466
|
+
post_mcp_tool_use: [hookEntry],
|
|
2467
|
+
pre_user_prompt: [hookEntry],
|
|
2468
|
+
post_cascade_response: [hookEntry]
|
|
2469
|
+
}
|
|
2470
|
+
};
|
|
2471
|
+
}
|
|
2472
|
+
function generateCursorConfig() {
|
|
2473
|
+
return {
|
|
2474
|
+
hooks: {
|
|
2475
|
+
beforeSubmitPrompt: {
|
|
2476
|
+
command: `${HOOK_COMMAND} ${HOOK_ARGS.join(" ")}`
|
|
2477
|
+
},
|
|
2478
|
+
afterFileEdit: {
|
|
2479
|
+
command: `${HOOK_COMMAND} ${HOOK_ARGS.join(" ")}`
|
|
2480
|
+
},
|
|
2481
|
+
stop: {
|
|
2482
|
+
command: `${HOOK_COMMAND} ${HOOK_ARGS.join(" ")}`
|
|
2483
|
+
}
|
|
2484
|
+
}
|
|
2485
|
+
};
|
|
2486
|
+
}
|
|
2487
|
+
function generateKiroHookFile() {
|
|
2488
|
+
return `---
|
|
2489
|
+
title: Memorix Auto-Memory
|
|
2490
|
+
description: Automatically record development context for cross-agent memory sharing
|
|
2491
|
+
event: file_saved
|
|
2492
|
+
filePattern: "**/*"
|
|
2493
|
+
---
|
|
2494
|
+
|
|
2495
|
+
Run the memorix hook command to analyze changes and store relevant memories:
|
|
2496
|
+
|
|
2497
|
+
\`\`\`bash
|
|
2498
|
+
memorix hook
|
|
2499
|
+
\`\`\`
|
|
2500
|
+
`;
|
|
2501
|
+
}
|
|
2502
|
+
function getProjectConfigPath(agent, projectRoot) {
|
|
2503
|
+
switch (agent) {
|
|
2504
|
+
case "claude":
|
|
2505
|
+
case "copilot":
|
|
2506
|
+
return path5.join(projectRoot, ".github", "hooks", "memorix.json");
|
|
2507
|
+
case "windsurf":
|
|
2508
|
+
return path5.join(projectRoot, ".windsurf", "hooks.json");
|
|
2509
|
+
case "cursor":
|
|
2510
|
+
return path5.join(projectRoot, ".cursor", "hooks.json");
|
|
2511
|
+
case "kiro":
|
|
2512
|
+
return path5.join(projectRoot, ".kiro", "hooks", "memorix.hook.md");
|
|
2513
|
+
case "codex":
|
|
2514
|
+
return path5.join(projectRoot, ".codex", "hooks.json");
|
|
2515
|
+
default:
|
|
2516
|
+
return path5.join(projectRoot, ".memorix", "hooks.json");
|
|
2517
|
+
}
|
|
2518
|
+
}
|
|
2519
|
+
function getGlobalConfigPath(agent) {
|
|
2520
|
+
const home = os2.homedir();
|
|
2521
|
+
switch (agent) {
|
|
2522
|
+
case "claude":
|
|
2523
|
+
case "copilot":
|
|
2524
|
+
return path5.join(home, ".claude", "settings.json");
|
|
2525
|
+
case "windsurf":
|
|
2526
|
+
return path5.join(home, ".codeium", "windsurf", "hooks.json");
|
|
2527
|
+
case "cursor":
|
|
2528
|
+
return path5.join(home, ".cursor", "hooks.json");
|
|
2529
|
+
default:
|
|
2530
|
+
return path5.join(home, ".memorix", "hooks.json");
|
|
2531
|
+
}
|
|
2532
|
+
}
|
|
2533
|
+
async function detectInstalledAgents() {
|
|
2534
|
+
const agents = [];
|
|
2535
|
+
const home = os2.homedir();
|
|
2536
|
+
const claudeDir = path5.join(home, ".claude");
|
|
2537
|
+
try {
|
|
2538
|
+
await fs3.access(claudeDir);
|
|
2539
|
+
agents.push("claude");
|
|
2540
|
+
} catch {
|
|
2541
|
+
}
|
|
2542
|
+
const windsurfDir = path5.join(home, ".codeium", "windsurf");
|
|
2543
|
+
try {
|
|
2544
|
+
await fs3.access(windsurfDir);
|
|
2545
|
+
agents.push("windsurf");
|
|
2546
|
+
} catch {
|
|
2547
|
+
}
|
|
2548
|
+
const cursorDir = path5.join(home, ".cursor");
|
|
2549
|
+
try {
|
|
2550
|
+
await fs3.access(cursorDir);
|
|
2551
|
+
agents.push("cursor");
|
|
2552
|
+
} catch {
|
|
2553
|
+
}
|
|
2554
|
+
if (!agents.includes("claude")) {
|
|
2555
|
+
const vscodeDir = path5.join(home, ".vscode");
|
|
2556
|
+
try {
|
|
2557
|
+
await fs3.access(vscodeDir);
|
|
2558
|
+
agents.push("copilot");
|
|
2559
|
+
} catch {
|
|
2560
|
+
}
|
|
2561
|
+
}
|
|
2562
|
+
const kiroConfig = path5.join(home, ".kiro");
|
|
2563
|
+
try {
|
|
2564
|
+
await fs3.access(kiroConfig);
|
|
2565
|
+
agents.push("kiro");
|
|
2566
|
+
} catch {
|
|
2567
|
+
}
|
|
2568
|
+
return agents;
|
|
2569
|
+
}
|
|
2570
|
+
async function installHooks(agent, projectRoot, global = false) {
|
|
2571
|
+
const configPath = global ? getGlobalConfigPath(agent) : getProjectConfigPath(agent, projectRoot);
|
|
2572
|
+
let generated;
|
|
2573
|
+
switch (agent) {
|
|
2574
|
+
case "claude":
|
|
2575
|
+
case "copilot":
|
|
2576
|
+
generated = generateClaudeConfig();
|
|
2577
|
+
break;
|
|
2578
|
+
case "windsurf":
|
|
2579
|
+
generated = generateWindsurfConfig();
|
|
2580
|
+
break;
|
|
2581
|
+
case "cursor":
|
|
2582
|
+
generated = generateCursorConfig();
|
|
2583
|
+
break;
|
|
2584
|
+
case "kiro":
|
|
2585
|
+
generated = generateKiroHookFile();
|
|
2586
|
+
break;
|
|
2587
|
+
default:
|
|
2588
|
+
generated = generateClaudeConfig();
|
|
2589
|
+
}
|
|
2590
|
+
await fs3.mkdir(path5.dirname(configPath), { recursive: true });
|
|
2591
|
+
if (agent === "kiro") {
|
|
2592
|
+
await fs3.writeFile(configPath, generated, "utf-8");
|
|
2593
|
+
} else {
|
|
2594
|
+
let existing = {};
|
|
2595
|
+
try {
|
|
2596
|
+
const content = await fs3.readFile(configPath, "utf-8");
|
|
2597
|
+
existing = JSON.parse(content);
|
|
2598
|
+
} catch {
|
|
2599
|
+
}
|
|
2600
|
+
const merged = {
|
|
2601
|
+
...existing,
|
|
2602
|
+
...generated
|
|
2603
|
+
};
|
|
2604
|
+
await fs3.writeFile(configPath, JSON.stringify(merged, null, 2), "utf-8");
|
|
2605
|
+
}
|
|
2606
|
+
const events = [];
|
|
2607
|
+
switch (agent) {
|
|
2608
|
+
case "claude":
|
|
2609
|
+
case "copilot":
|
|
2610
|
+
events.push("session_start", "post_tool", "user_prompt", "pre_compact", "session_end");
|
|
2611
|
+
break;
|
|
2612
|
+
case "windsurf":
|
|
2613
|
+
events.push("post_edit", "post_command", "post_tool", "user_prompt", "post_response");
|
|
2614
|
+
break;
|
|
2615
|
+
case "cursor":
|
|
2616
|
+
events.push("user_prompt", "post_edit", "session_end");
|
|
2617
|
+
break;
|
|
2618
|
+
case "kiro":
|
|
2619
|
+
events.push("post_edit");
|
|
2620
|
+
break;
|
|
2621
|
+
}
|
|
2622
|
+
return {
|
|
2623
|
+
agent,
|
|
2624
|
+
configPath,
|
|
2625
|
+
events,
|
|
2626
|
+
generated: typeof generated === "string" ? { content: generated } : generated
|
|
2627
|
+
};
|
|
2628
|
+
}
|
|
2629
|
+
async function uninstallHooks(agent, projectRoot, global = false) {
|
|
2630
|
+
const configPath = global ? getGlobalConfigPath(agent) : getProjectConfigPath(agent, projectRoot);
|
|
2631
|
+
try {
|
|
2632
|
+
if (agent === "kiro") {
|
|
2633
|
+
await fs3.unlink(configPath);
|
|
2634
|
+
} else {
|
|
2635
|
+
const content = await fs3.readFile(configPath, "utf-8");
|
|
2636
|
+
const config = JSON.parse(content);
|
|
2637
|
+
delete config.hooks;
|
|
2638
|
+
if (Object.keys(config).length === 0) {
|
|
2639
|
+
await fs3.unlink(configPath);
|
|
2640
|
+
} else {
|
|
2641
|
+
await fs3.writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
2642
|
+
}
|
|
2643
|
+
}
|
|
2644
|
+
return true;
|
|
2645
|
+
} catch {
|
|
2646
|
+
return false;
|
|
2647
|
+
}
|
|
2648
|
+
}
|
|
2649
|
+
async function getHookStatus(projectRoot) {
|
|
2650
|
+
const results = [];
|
|
2651
|
+
const agents = ["claude", "copilot", "windsurf", "cursor", "kiro", "codex"];
|
|
2652
|
+
for (const agent of agents) {
|
|
2653
|
+
const projectPath = getProjectConfigPath(agent, projectRoot);
|
|
2654
|
+
const globalPath = getGlobalConfigPath(agent);
|
|
2655
|
+
let installed = false;
|
|
2656
|
+
let usedPath = projectPath;
|
|
2657
|
+
try {
|
|
2658
|
+
await fs3.access(projectPath);
|
|
2659
|
+
installed = true;
|
|
2660
|
+
} catch {
|
|
2661
|
+
try {
|
|
2662
|
+
await fs3.access(globalPath);
|
|
2663
|
+
installed = true;
|
|
2664
|
+
usedPath = globalPath;
|
|
2665
|
+
} catch {
|
|
2666
|
+
}
|
|
2667
|
+
}
|
|
2668
|
+
results.push({ agent, installed, configPath: usedPath });
|
|
2669
|
+
}
|
|
2670
|
+
return results;
|
|
2671
|
+
}
|
|
2672
|
+
var HOOK_COMMAND, HOOK_ARGS;
|
|
2673
|
+
var init_installers = __esm({
|
|
2674
|
+
"src/hooks/installers/index.ts"() {
|
|
2675
|
+
"use strict";
|
|
2676
|
+
init_esm_shims();
|
|
2677
|
+
HOOK_COMMAND = "memorix";
|
|
2678
|
+
HOOK_ARGS = ["hook"];
|
|
2679
|
+
}
|
|
2680
|
+
});
|
|
2681
|
+
|
|
2430
2682
|
// src/memory/retention.ts
|
|
2431
2683
|
var retention_exports = {};
|
|
2432
2684
|
__export(retention_exports, {
|
|
@@ -2560,8 +2812,25 @@ async function createMemorixServer(cwd) {
|
|
|
2560
2812
|
if (reindexed > 0) {
|
|
2561
2813
|
console.error(`[memorix] Reindexed ${reindexed} observations for project: ${project.id}`);
|
|
2562
2814
|
}
|
|
2563
|
-
console.error(`[memorix] Project: ${project.id} (${project.name})`);
|
|
2564
|
-
console.error(`[memorix] Data dir: ${projectDir2}`);
|
|
2815
|
+
console.error(`[memorix] Project: ${project.id} (${project.name})`);
|
|
2816
|
+
console.error(`[memorix] Data dir: ${projectDir2}`);
|
|
2817
|
+
try {
|
|
2818
|
+
const { getHookStatus: getHookStatus2, installHooks: installHooks2, detectInstalledAgents: detectInstalledAgents2 } = await Promise.resolve().then(() => (init_installers(), installers_exports));
|
|
2819
|
+
const workDir = cwd ?? process.cwd();
|
|
2820
|
+
const statuses = await getHookStatus2(workDir);
|
|
2821
|
+
const anyInstalled = statuses.some((s) => s.installed);
|
|
2822
|
+
if (!anyInstalled) {
|
|
2823
|
+
const agents = await detectInstalledAgents2();
|
|
2824
|
+
for (const agent of agents) {
|
|
2825
|
+
try {
|
|
2826
|
+
const config = await installHooks2(agent, workDir);
|
|
2827
|
+
console.error(`[memorix] Auto-installed hooks for ${agent} \u2192 ${config.configPath}`);
|
|
2828
|
+
} catch {
|
|
2829
|
+
}
|
|
2830
|
+
}
|
|
2831
|
+
}
|
|
2832
|
+
} catch {
|
|
2833
|
+
}
|
|
2565
2834
|
const observationsFile = projectDir2 + "/observations.json";
|
|
2566
2835
|
let reloadDebounce = null;
|
|
2567
2836
|
try {
|
|
@@ -2569,6 +2838,7 @@ async function createMemorixServer(cwd) {
|
|
|
2569
2838
|
if (reloadDebounce) clearTimeout(reloadDebounce);
|
|
2570
2839
|
reloadDebounce = setTimeout(async () => {
|
|
2571
2840
|
try {
|
|
2841
|
+
await resetDb();
|
|
2572
2842
|
await initObservations(projectDir2);
|
|
2573
2843
|
const count2 = await reindexObservations();
|
|
2574
2844
|
if (count2 > 0) {
|
|
@@ -3083,6 +3353,7 @@ var init_server = __esm({
|
|
|
3083
3353
|
init_esm_shims();
|
|
3084
3354
|
init_graph();
|
|
3085
3355
|
init_observations();
|
|
3356
|
+
init_orama_store();
|
|
3086
3357
|
init_auto_relations();
|
|
3087
3358
|
init_entity_extractor();
|
|
3088
3359
|
init_engine();
|
|
@@ -3801,258 +4072,6 @@ var init_hook = __esm({
|
|
|
3801
4072
|
}
|
|
3802
4073
|
});
|
|
3803
4074
|
|
|
3804
|
-
// src/hooks/installers/index.ts
|
|
3805
|
-
var installers_exports = {};
|
|
3806
|
-
__export(installers_exports, {
|
|
3807
|
-
detectInstalledAgents: () => detectInstalledAgents,
|
|
3808
|
-
getHookStatus: () => getHookStatus,
|
|
3809
|
-
installHooks: () => installHooks,
|
|
3810
|
-
uninstallHooks: () => uninstallHooks
|
|
3811
|
-
});
|
|
3812
|
-
import * as fs3 from "fs/promises";
|
|
3813
|
-
import * as path5 from "path";
|
|
3814
|
-
import * as os2 from "os";
|
|
3815
|
-
function generateClaudeConfig() {
|
|
3816
|
-
const hookEntry = {
|
|
3817
|
-
type: "command",
|
|
3818
|
-
command: `${HOOK_COMMAND} ${HOOK_ARGS.join(" ")}`,
|
|
3819
|
-
timeout: 10
|
|
3820
|
-
};
|
|
3821
|
-
return {
|
|
3822
|
-
hooks: {
|
|
3823
|
-
SessionStart: [hookEntry],
|
|
3824
|
-
PostToolUse: [hookEntry],
|
|
3825
|
-
UserPromptSubmit: [hookEntry],
|
|
3826
|
-
PreCompact: [hookEntry],
|
|
3827
|
-
Stop: [hookEntry]
|
|
3828
|
-
}
|
|
3829
|
-
};
|
|
3830
|
-
}
|
|
3831
|
-
function generateWindsurfConfig() {
|
|
3832
|
-
const hookEntry = {
|
|
3833
|
-
command: `${HOOK_COMMAND} ${HOOK_ARGS.join(" ")}`,
|
|
3834
|
-
timeout: 10
|
|
3835
|
-
};
|
|
3836
|
-
return {
|
|
3837
|
-
hooks: {
|
|
3838
|
-
post_write_code: [hookEntry],
|
|
3839
|
-
post_run_command: [hookEntry],
|
|
3840
|
-
post_mcp_tool_use: [hookEntry],
|
|
3841
|
-
pre_user_prompt: [hookEntry],
|
|
3842
|
-
post_cascade_response: [hookEntry]
|
|
3843
|
-
}
|
|
3844
|
-
};
|
|
3845
|
-
}
|
|
3846
|
-
function generateCursorConfig() {
|
|
3847
|
-
return {
|
|
3848
|
-
hooks: {
|
|
3849
|
-
beforeSubmitPrompt: {
|
|
3850
|
-
command: `${HOOK_COMMAND} ${HOOK_ARGS.join(" ")}`
|
|
3851
|
-
},
|
|
3852
|
-
afterFileEdit: {
|
|
3853
|
-
command: `${HOOK_COMMAND} ${HOOK_ARGS.join(" ")}`
|
|
3854
|
-
},
|
|
3855
|
-
stop: {
|
|
3856
|
-
command: `${HOOK_COMMAND} ${HOOK_ARGS.join(" ")}`
|
|
3857
|
-
}
|
|
3858
|
-
}
|
|
3859
|
-
};
|
|
3860
|
-
}
|
|
3861
|
-
function generateKiroHookFile() {
|
|
3862
|
-
return `---
|
|
3863
|
-
title: Memorix Auto-Memory
|
|
3864
|
-
description: Automatically record development context for cross-agent memory sharing
|
|
3865
|
-
event: file_saved
|
|
3866
|
-
filePattern: "**/*"
|
|
3867
|
-
---
|
|
3868
|
-
|
|
3869
|
-
Run the memorix hook command to analyze changes and store relevant memories:
|
|
3870
|
-
|
|
3871
|
-
\`\`\`bash
|
|
3872
|
-
memorix hook
|
|
3873
|
-
\`\`\`
|
|
3874
|
-
`;
|
|
3875
|
-
}
|
|
3876
|
-
function getProjectConfigPath(agent, projectRoot) {
|
|
3877
|
-
switch (agent) {
|
|
3878
|
-
case "claude":
|
|
3879
|
-
case "copilot":
|
|
3880
|
-
return path5.join(projectRoot, ".github", "hooks", "memorix.json");
|
|
3881
|
-
case "windsurf":
|
|
3882
|
-
return path5.join(projectRoot, ".windsurf", "hooks.json");
|
|
3883
|
-
case "cursor":
|
|
3884
|
-
return path5.join(projectRoot, ".cursor", "hooks.json");
|
|
3885
|
-
case "kiro":
|
|
3886
|
-
return path5.join(projectRoot, ".kiro", "hooks", "memorix.hook.md");
|
|
3887
|
-
case "codex":
|
|
3888
|
-
return path5.join(projectRoot, ".codex", "hooks.json");
|
|
3889
|
-
default:
|
|
3890
|
-
return path5.join(projectRoot, ".memorix", "hooks.json");
|
|
3891
|
-
}
|
|
3892
|
-
}
|
|
3893
|
-
function getGlobalConfigPath(agent) {
|
|
3894
|
-
const home = os2.homedir();
|
|
3895
|
-
switch (agent) {
|
|
3896
|
-
case "claude":
|
|
3897
|
-
case "copilot":
|
|
3898
|
-
return path5.join(home, ".claude", "settings.json");
|
|
3899
|
-
case "windsurf":
|
|
3900
|
-
return path5.join(home, ".codeium", "windsurf", "hooks.json");
|
|
3901
|
-
case "cursor":
|
|
3902
|
-
return path5.join(home, ".cursor", "hooks.json");
|
|
3903
|
-
default:
|
|
3904
|
-
return path5.join(home, ".memorix", "hooks.json");
|
|
3905
|
-
}
|
|
3906
|
-
}
|
|
3907
|
-
async function detectInstalledAgents() {
|
|
3908
|
-
const agents = [];
|
|
3909
|
-
const home = os2.homedir();
|
|
3910
|
-
const claudeDir = path5.join(home, ".claude");
|
|
3911
|
-
try {
|
|
3912
|
-
await fs3.access(claudeDir);
|
|
3913
|
-
agents.push("claude");
|
|
3914
|
-
} catch {
|
|
3915
|
-
}
|
|
3916
|
-
const windsurfDir = path5.join(home, ".codeium", "windsurf");
|
|
3917
|
-
try {
|
|
3918
|
-
await fs3.access(windsurfDir);
|
|
3919
|
-
agents.push("windsurf");
|
|
3920
|
-
} catch {
|
|
3921
|
-
}
|
|
3922
|
-
const cursorDir = path5.join(home, ".cursor");
|
|
3923
|
-
try {
|
|
3924
|
-
await fs3.access(cursorDir);
|
|
3925
|
-
agents.push("cursor");
|
|
3926
|
-
} catch {
|
|
3927
|
-
}
|
|
3928
|
-
if (!agents.includes("claude")) {
|
|
3929
|
-
const vscodeDir = path5.join(home, ".vscode");
|
|
3930
|
-
try {
|
|
3931
|
-
await fs3.access(vscodeDir);
|
|
3932
|
-
agents.push("copilot");
|
|
3933
|
-
} catch {
|
|
3934
|
-
}
|
|
3935
|
-
}
|
|
3936
|
-
const kiroConfig = path5.join(home, ".kiro");
|
|
3937
|
-
try {
|
|
3938
|
-
await fs3.access(kiroConfig);
|
|
3939
|
-
agents.push("kiro");
|
|
3940
|
-
} catch {
|
|
3941
|
-
}
|
|
3942
|
-
return agents;
|
|
3943
|
-
}
|
|
3944
|
-
async function installHooks(agent, projectRoot, global = false) {
|
|
3945
|
-
const configPath = global ? getGlobalConfigPath(agent) : getProjectConfigPath(agent, projectRoot);
|
|
3946
|
-
let generated;
|
|
3947
|
-
switch (agent) {
|
|
3948
|
-
case "claude":
|
|
3949
|
-
case "copilot":
|
|
3950
|
-
generated = generateClaudeConfig();
|
|
3951
|
-
break;
|
|
3952
|
-
case "windsurf":
|
|
3953
|
-
generated = generateWindsurfConfig();
|
|
3954
|
-
break;
|
|
3955
|
-
case "cursor":
|
|
3956
|
-
generated = generateCursorConfig();
|
|
3957
|
-
break;
|
|
3958
|
-
case "kiro":
|
|
3959
|
-
generated = generateKiroHookFile();
|
|
3960
|
-
break;
|
|
3961
|
-
default:
|
|
3962
|
-
generated = generateClaudeConfig();
|
|
3963
|
-
}
|
|
3964
|
-
await fs3.mkdir(path5.dirname(configPath), { recursive: true });
|
|
3965
|
-
if (agent === "kiro") {
|
|
3966
|
-
await fs3.writeFile(configPath, generated, "utf-8");
|
|
3967
|
-
} else {
|
|
3968
|
-
let existing = {};
|
|
3969
|
-
try {
|
|
3970
|
-
const content = await fs3.readFile(configPath, "utf-8");
|
|
3971
|
-
existing = JSON.parse(content);
|
|
3972
|
-
} catch {
|
|
3973
|
-
}
|
|
3974
|
-
const merged = {
|
|
3975
|
-
...existing,
|
|
3976
|
-
...generated
|
|
3977
|
-
};
|
|
3978
|
-
await fs3.writeFile(configPath, JSON.stringify(merged, null, 2), "utf-8");
|
|
3979
|
-
}
|
|
3980
|
-
const events = [];
|
|
3981
|
-
switch (agent) {
|
|
3982
|
-
case "claude":
|
|
3983
|
-
case "copilot":
|
|
3984
|
-
events.push("session_start", "post_tool", "user_prompt", "pre_compact", "session_end");
|
|
3985
|
-
break;
|
|
3986
|
-
case "windsurf":
|
|
3987
|
-
events.push("post_edit", "post_command", "post_tool", "user_prompt", "post_response");
|
|
3988
|
-
break;
|
|
3989
|
-
case "cursor":
|
|
3990
|
-
events.push("user_prompt", "post_edit", "session_end");
|
|
3991
|
-
break;
|
|
3992
|
-
case "kiro":
|
|
3993
|
-
events.push("post_edit");
|
|
3994
|
-
break;
|
|
3995
|
-
}
|
|
3996
|
-
return {
|
|
3997
|
-
agent,
|
|
3998
|
-
configPath,
|
|
3999
|
-
events,
|
|
4000
|
-
generated: typeof generated === "string" ? { content: generated } : generated
|
|
4001
|
-
};
|
|
4002
|
-
}
|
|
4003
|
-
async function uninstallHooks(agent, projectRoot, global = false) {
|
|
4004
|
-
const configPath = global ? getGlobalConfigPath(agent) : getProjectConfigPath(agent, projectRoot);
|
|
4005
|
-
try {
|
|
4006
|
-
if (agent === "kiro") {
|
|
4007
|
-
await fs3.unlink(configPath);
|
|
4008
|
-
} else {
|
|
4009
|
-
const content = await fs3.readFile(configPath, "utf-8");
|
|
4010
|
-
const config = JSON.parse(content);
|
|
4011
|
-
delete config.hooks;
|
|
4012
|
-
if (Object.keys(config).length === 0) {
|
|
4013
|
-
await fs3.unlink(configPath);
|
|
4014
|
-
} else {
|
|
4015
|
-
await fs3.writeFile(configPath, JSON.stringify(config, null, 2), "utf-8");
|
|
4016
|
-
}
|
|
4017
|
-
}
|
|
4018
|
-
return true;
|
|
4019
|
-
} catch {
|
|
4020
|
-
return false;
|
|
4021
|
-
}
|
|
4022
|
-
}
|
|
4023
|
-
async function getHookStatus(projectRoot) {
|
|
4024
|
-
const results = [];
|
|
4025
|
-
const agents = ["claude", "copilot", "windsurf", "cursor", "kiro", "codex"];
|
|
4026
|
-
for (const agent of agents) {
|
|
4027
|
-
const projectPath = getProjectConfigPath(agent, projectRoot);
|
|
4028
|
-
const globalPath = getGlobalConfigPath(agent);
|
|
4029
|
-
let installed = false;
|
|
4030
|
-
let usedPath = projectPath;
|
|
4031
|
-
try {
|
|
4032
|
-
await fs3.access(projectPath);
|
|
4033
|
-
installed = true;
|
|
4034
|
-
} catch {
|
|
4035
|
-
try {
|
|
4036
|
-
await fs3.access(globalPath);
|
|
4037
|
-
installed = true;
|
|
4038
|
-
usedPath = globalPath;
|
|
4039
|
-
} catch {
|
|
4040
|
-
}
|
|
4041
|
-
}
|
|
4042
|
-
results.push({ agent, installed, configPath: usedPath });
|
|
4043
|
-
}
|
|
4044
|
-
return results;
|
|
4045
|
-
}
|
|
4046
|
-
var HOOK_COMMAND, HOOK_ARGS;
|
|
4047
|
-
var init_installers = __esm({
|
|
4048
|
-
"src/hooks/installers/index.ts"() {
|
|
4049
|
-
"use strict";
|
|
4050
|
-
init_esm_shims();
|
|
4051
|
-
HOOK_COMMAND = "memorix";
|
|
4052
|
-
HOOK_ARGS = ["hook"];
|
|
4053
|
-
}
|
|
4054
|
-
});
|
|
4055
|
-
|
|
4056
4075
|
// src/cli/commands/hooks-install.ts
|
|
4057
4076
|
var hooks_install_exports = {};
|
|
4058
4077
|
__export(hooks_install_exports, {
|