@uniswap/ai-toolkit-nx-claude 0.5.30-next.2 → 0.5.30-next.4

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 (23) hide show
  1. package/README.md +28 -27
  2. package/dist/cli-generator.cjs +4 -10
  3. package/dist/index.cjs +15 -845
  4. package/dist/packages/ai-toolkit-nx-claude/src/cli-generator.d.ts +1 -2
  5. package/dist/packages/ai-toolkit-nx-claude/src/cli-generator.d.ts.map +1 -1
  6. package/dist/packages/ai-toolkit-nx-claude/src/index.d.ts +0 -1
  7. package/dist/packages/ai-toolkit-nx-claude/src/index.d.ts.map +1 -1
  8. package/generators.json +0 -5
  9. package/package.json +2 -3
  10. package/dist/generators/hooks/CLAUDE.md +0 -378
  11. package/dist/generators/hooks/README.md +0 -220
  12. package/dist/generators/hooks/generator.cjs +0 -1265
  13. package/dist/generators/hooks/schema.json +0 -41
  14. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/cli-parser.d.ts +0 -2
  15. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/cli-parser.d.ts.map +0 -1
  16. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/dependency-checker.d.ts +0 -46
  17. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/dependency-checker.d.ts.map +0 -1
  18. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/generator.d.ts +0 -9
  19. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/generator.d.ts.map +0 -1
  20. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/install-orchestrator.d.ts +0 -55
  21. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/install-orchestrator.d.ts.map +0 -1
  22. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/repo-manager.d.ts +0 -63
  23. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/repo-manager.d.ts.map +0 -1
package/dist/index.cjs CHANGED
@@ -131,10 +131,10 @@ async function validateAddonRequirements(addonId) {
131
131
  }
132
132
  }
133
133
  if (addon.requirements?.commands) {
134
- const { execSync: execSync6 } = require("child_process");
134
+ const { execSync: execSync3 } = require("child_process");
135
135
  for (const cmd of addon.requirements.commands) {
136
136
  try {
137
- execSync6(`which ${cmd}`, { stdio: "ignore" });
137
+ execSync3(`which ${cmd}`, { stdio: "ignore" });
138
138
  } catch {
139
139
  errors.push(`Required command '${cmd}' not found`);
140
140
  }
@@ -341,14 +341,12 @@ var require_schema = __commonJS({
341
341
  // packages/ai-toolkit-nx-claude/src/index.ts
342
342
  var index_exports = {};
343
343
  __export(index_exports, {
344
- addonsGenerator: () => generator,
345
- hooksGenerator: () => generator_default
344
+ addonsGenerator: () => generator
346
345
  });
347
346
  module.exports = __toCommonJS(index_exports);
348
347
 
349
- // packages/ai-toolkit-nx-claude/src/generators/hooks/generator.ts
350
- var import_devkit4 = require("@nx/devkit");
351
- var path3 = __toESM(require("path"));
348
+ // packages/ai-toolkit-nx-claude/src/generators/addons/generator.ts
349
+ var import_devkit = require("@nx/devkit");
352
350
 
353
351
  // packages/ai-toolkit-nx-claude/src/utils/prompt-utils.ts
354
352
  var import_enquirer = require("enquirer");
@@ -726,708 +724,7 @@ function evaluateSingleCondition(condition, context) {
726
724
  }
727
725
  }
728
726
 
729
- // packages/ai-toolkit-nx-claude/src/generators/hooks/dependency-checker.ts
730
- var import_child_process = require("child_process");
731
- var import_devkit = require("@nx/devkit");
732
- function commandExists(command) {
733
- try {
734
- (0, import_child_process.execSync)(`which ${command}`, { stdio: "ignore" });
735
- return true;
736
- } catch {
737
- return false;
738
- }
739
- }
740
- function getCommandVersion(command, versionFlag = "--version") {
741
- try {
742
- const output = (0, import_child_process.execSync)(`${command} ${versionFlag}`, {
743
- encoding: "utf-8",
744
- stdio: "pipe"
745
- }).trim();
746
- const versionMatch = output.match(/(\d+\.\d+\.\d+)/);
747
- return versionMatch ? versionMatch[1] : output.split("\n")[0];
748
- } catch {
749
- return void 0;
750
- }
751
- }
752
- function checkDependencies() {
753
- const status = {
754
- hasNode: false,
755
- hasNpm: false,
756
- hasGit: false,
757
- missingDependencies: []
758
- };
759
- if (commandExists("node")) {
760
- status.hasNode = true;
761
- status.nodeVersion = getCommandVersion("node");
762
- } else {
763
- status.missingDependencies.push("Node.js");
764
- }
765
- if (commandExists("npm")) {
766
- status.hasNpm = true;
767
- status.npmVersion = getCommandVersion("npm");
768
- } else {
769
- status.missingDependencies.push("npm");
770
- }
771
- if (commandExists("git")) {
772
- status.hasGit = true;
773
- status.gitVersion = getCommandVersion("git");
774
- } else {
775
- status.missingDependencies.push("Git");
776
- }
777
- return status;
778
- }
779
- function logDependencyStatus(status) {
780
- import_devkit.logger.info("\u{1F4CB} Dependency Check Results:");
781
- if (status.hasNode) {
782
- import_devkit.logger.info(` \u2705 Node.js: ${status.nodeVersion || "installed"}`);
783
- } else {
784
- import_devkit.logger.error(" \u274C Node.js: not found");
785
- }
786
- if (status.hasNpm) {
787
- import_devkit.logger.info(` \u2705 npm: ${status.npmVersion || "installed"}`);
788
- } else {
789
- import_devkit.logger.error(" \u274C npm: not found");
790
- }
791
- if (status.hasGit) {
792
- import_devkit.logger.info(` \u2705 Git: ${status.gitVersion || "installed"}`);
793
- } else {
794
- import_devkit.logger.error(" \u274C Git: not found");
795
- }
796
- }
797
- function hasAllDependencies(status) {
798
- return status.missingDependencies.length === 0;
799
- }
800
- function getInstallInstructions(missingDeps) {
801
- const instructions = [];
802
- if (missingDeps.includes("Node.js") || missingDeps.includes("npm")) {
803
- instructions.push(
804
- "\u{1F4E6} Node.js and npm:",
805
- " \u2022 macOS: brew install node",
806
- " \u2022 Linux: sudo apt-get install nodejs npm",
807
- " \u2022 Windows: Download from https://nodejs.org/",
808
- ""
809
- );
810
- }
811
- if (missingDeps.includes("Git")) {
812
- instructions.push(
813
- "\u{1F4E6} Git:",
814
- " \u2022 macOS: brew install git",
815
- " \u2022 Linux: sudo apt-get install git",
816
- " \u2022 Windows: Download from https://git-scm.com/",
817
- ""
818
- );
819
- }
820
- return instructions.join("\n");
821
- }
822
- function validateVersions(status) {
823
- const MIN_NODE_VERSION = "16.0.0";
824
- const MIN_NPM_VERSION = "7.0.0";
825
- const MIN_GIT_VERSION = "2.0.0";
826
- const compareVersions = (current, minimum) => {
827
- if (!current) return false;
828
- const currentParts = current.split(".").map(Number);
829
- const minimumParts = minimum.split(".").map(Number);
830
- for (let i = 0; i < minimumParts.length; i++) {
831
- if (currentParts[i] > minimumParts[i]) return true;
832
- if (currentParts[i] < minimumParts[i]) return false;
833
- }
834
- return true;
835
- };
836
- if (status.hasNode && !compareVersions(status.nodeVersion, MIN_NODE_VERSION)) {
837
- import_devkit.logger.warn(
838
- `\u26A0\uFE0F Node.js version ${status.nodeVersion} is below minimum required version ${MIN_NODE_VERSION}`
839
- );
840
- return false;
841
- }
842
- if (status.hasNpm && !compareVersions(status.npmVersion, MIN_NPM_VERSION)) {
843
- import_devkit.logger.warn(
844
- `\u26A0\uFE0F npm version ${status.npmVersion} is below minimum required version ${MIN_NPM_VERSION}`
845
- );
846
- return false;
847
- }
848
- if (status.hasGit && !compareVersions(status.gitVersion, MIN_GIT_VERSION)) {
849
- import_devkit.logger.warn(
850
- `\u26A0\uFE0F Git version ${status.gitVersion} is below minimum required version ${MIN_GIT_VERSION}`
851
- );
852
- return false;
853
- }
854
- return true;
855
- }
856
- async function checkAndValidateDependencies() {
857
- const status = checkDependencies();
858
- logDependencyStatus(status);
859
- if (!hasAllDependencies(status)) {
860
- import_devkit.logger.error("\n\u274C Missing required dependencies:");
861
- import_devkit.logger.info(getInstallInstructions(status.missingDependencies));
862
- return false;
863
- }
864
- if (!validateVersions(status)) {
865
- import_devkit.logger.error(
866
- "\n\u274C Some dependencies do not meet minimum version requirements"
867
- );
868
- import_devkit.logger.info("Please update the affected tools to continue.");
869
- return false;
870
- }
871
- import_devkit.logger.info("\n\u2705 All dependencies satisfied!");
872
- return true;
873
- }
874
-
875
- // packages/ai-toolkit-nx-claude/src/generators/hooks/repo-manager.ts
876
- var import_child_process2 = require("child_process");
877
- var import_devkit2 = require("@nx/devkit");
878
- var fs2 = __toESM(require("fs"));
879
- var path = __toESM(require("path"));
880
- var os = __toESM(require("os"));
881
- var DEFAULT_REPO_URL = "https://github.com/pascalporedda/awesome-claude-code.git";
882
- function getRepoPath(customPath) {
883
- if (customPath) {
884
- return customPath;
885
- }
886
- return path.join(os.tmpdir(), "claude-hooks-temp");
887
- }
888
- function isGitRepository(repoPath) {
889
- try {
890
- if (!fs2.existsSync(repoPath)) {
891
- return false;
892
- }
893
- (0, import_child_process2.execSync)("git rev-parse --git-dir", {
894
- cwd: repoPath,
895
- stdio: "ignore"
896
- });
897
- return true;
898
- } catch {
899
- return false;
900
- }
901
- }
902
- function getCurrentBranch(repoPath) {
903
- try {
904
- const branch = (0, import_child_process2.execSync)("git rev-parse --abbrev-ref HEAD", {
905
- cwd: repoPath,
906
- encoding: "utf-8"
907
- }).trim();
908
- return branch;
909
- } catch {
910
- return void 0;
911
- }
912
- }
913
- function getLastCommit(repoPath) {
914
- try {
915
- const commit = (0, import_child_process2.execSync)("git rev-parse HEAD", {
916
- cwd: repoPath,
917
- encoding: "utf-8"
918
- }).trim();
919
- return commit.substring(0, 7);
920
- } catch {
921
- return void 0;
922
- }
923
- }
924
- function isDirty(repoPath) {
925
- try {
926
- const status = (0, import_child_process2.execSync)("git status --porcelain", {
927
- cwd: repoPath,
928
- encoding: "utf-8"
929
- }).trim();
930
- return status.length > 0;
931
- } catch {
932
- return false;
933
- }
934
- }
935
- function getRemoteUrl(repoPath) {
936
- try {
937
- const url = (0, import_child_process2.execSync)("git config --get remote.origin.url", {
938
- cwd: repoPath,
939
- encoding: "utf-8"
940
- }).trim();
941
- return url;
942
- } catch {
943
- return void 0;
944
- }
945
- }
946
- function getRepoStatus(repoPath) {
947
- const exists = fs2.existsSync(repoPath);
948
- const isGit = exists && isGitRepository(repoPath);
949
- const status = {
950
- exists,
951
- path: repoPath,
952
- isGitRepo: isGit
953
- };
954
- if (isGit) {
955
- status.currentBranch = getCurrentBranch(repoPath);
956
- status.lastCommit = getLastCommit(repoPath);
957
- status.isDirty = isDirty(repoPath);
958
- status.remoteUrl = getRemoteUrl(repoPath);
959
- }
960
- return status;
961
- }
962
- async function cloneRepository(repoUrl = DEFAULT_REPO_URL, targetPath, verbose = false) {
963
- const repoPath = getRepoPath(targetPath);
964
- try {
965
- if (fs2.existsSync(repoPath)) {
966
- import_devkit2.logger.warn(`Directory already exists: ${repoPath}`);
967
- if (isGitRepository(repoPath)) {
968
- import_devkit2.logger.info("Existing git repository found");
969
- return true;
970
- } else {
971
- import_devkit2.logger.info("Removing non-git directory...");
972
- fs2.rmSync(repoPath, { recursive: true, force: true });
973
- }
974
- }
975
- import_devkit2.logger.info(`\u{1F4E5} Downloading notification hooks...`);
976
- try {
977
- (0, import_child_process2.execSync)(`git clone ${repoUrl} "${repoPath}"`, {
978
- stdio: verbose ? "inherit" : "ignore"
979
- });
980
- import_devkit2.logger.info("\u2705 Download complete");
981
- return true;
982
- } catch (httpsError) {
983
- if (repoUrl === DEFAULT_REPO_URL) {
984
- import_devkit2.logger.warn("HTTPS clone failed, trying SSH...");
985
- const sshUrl = "git@github.com:pascalporedda/awesome-claude-code.git";
986
- try {
987
- (0, import_child_process2.execSync)(`git clone ${sshUrl} "${repoPath}"`, {
988
- stdio: verbose ? "inherit" : "ignore"
989
- });
990
- import_devkit2.logger.info("\u2705 Download complete via SSH");
991
- return true;
992
- } catch (sshError) {
993
- import_devkit2.logger.error("\u274C Both HTTPS and SSH clone attempts failed");
994
- throw sshError;
995
- }
996
- } else {
997
- throw httpsError;
998
- }
999
- }
1000
- } catch (error) {
1001
- import_devkit2.logger.error(`\u274C Failed to download hooks: ${error}`);
1002
- return false;
1003
- }
1004
- }
1005
- async function updateRepository(repoPath, verbose = false) {
1006
- try {
1007
- if (!isGitRepository(repoPath)) {
1008
- import_devkit2.logger.error("Not a git repository");
1009
- return false;
1010
- }
1011
- if (isDirty(repoPath)) {
1012
- import_devkit2.logger.warn("\u26A0\uFE0F Repository has uncommitted changes");
1013
- import_devkit2.logger.info("Stashing changes...");
1014
- (0, import_child_process2.execSync)("git stash", {
1015
- cwd: repoPath,
1016
- stdio: verbose ? "inherit" : "ignore"
1017
- });
1018
- }
1019
- import_devkit2.logger.info("\u{1F4E5} Updating to latest version...");
1020
- (0, import_child_process2.execSync)("git fetch origin", {
1021
- cwd: repoPath,
1022
- stdio: verbose ? "inherit" : "ignore"
1023
- });
1024
- (0, import_child_process2.execSync)("git pull origin main", {
1025
- cwd: repoPath,
1026
- stdio: verbose ? "inherit" : "ignore"
1027
- });
1028
- import_devkit2.logger.info("\u2705 Update complete");
1029
- return true;
1030
- } catch (error) {
1031
- import_devkit2.logger.error(`\u274C Failed to update: ${error}`);
1032
- return false;
1033
- }
1034
- }
1035
- function cleanupRepository(repoPath) {
1036
- try {
1037
- if (fs2.existsSync(repoPath)) {
1038
- fs2.rmSync(repoPath, { recursive: true, force: true });
1039
- import_devkit2.logger.info("\u{1F9F9} Temporary files cleaned up");
1040
- return true;
1041
- }
1042
- return true;
1043
- } catch (error) {
1044
- import_devkit2.logger.error(`\u274C Failed to cleanup: ${error}`);
1045
- return false;
1046
- }
1047
- }
1048
- async function ensureRepository(options) {
1049
- const repoUrl = options.repoUrl || DEFAULT_REPO_URL;
1050
- const repoPath = getRepoPath(options.targetPath);
1051
- const status = getRepoStatus(repoPath);
1052
- if (options.verbose) {
1053
- import_devkit2.logger.info("Repository status:");
1054
- import_devkit2.logger.info(` Path: ${status.path}`);
1055
- import_devkit2.logger.info(` Exists: ${status.exists}`);
1056
- import_devkit2.logger.info(` Is Git Repo: ${status.isGitRepo}`);
1057
- if (status.isGitRepo) {
1058
- import_devkit2.logger.info(` Branch: ${status.currentBranch}`);
1059
- import_devkit2.logger.info(` Last Commit: ${status.lastCommit}`);
1060
- import_devkit2.logger.info(` Has Changes: ${status.isDirty}`);
1061
- import_devkit2.logger.info(` Remote URL: ${status.remoteUrl}`);
1062
- }
1063
- }
1064
- if (status.exists && status.isGitRepo) {
1065
- if (status.remoteUrl && !status.remoteUrl.includes("awesome-claude-code")) {
1066
- cleanupRepository(repoPath);
1067
- const cloned2 = await cloneRepository(
1068
- DEFAULT_REPO_URL,
1069
- options.targetPath,
1070
- options.verbose
1071
- );
1072
- if (!cloned2) {
1073
- return null;
1074
- }
1075
- return repoPath;
1076
- }
1077
- const updated = await updateRepository(repoPath, options.verbose);
1078
- if (!updated) {
1079
- import_devkit2.logger.warn("\u26A0\uFE0F Failed to update, using existing version");
1080
- }
1081
- return repoPath;
1082
- }
1083
- const cloned = await cloneRepository(
1084
- repoUrl,
1085
- options.targetPath,
1086
- options.verbose
1087
- );
1088
- if (!cloned) {
1089
- return null;
1090
- }
1091
- return repoPath;
1092
- }
1093
-
1094
- // packages/ai-toolkit-nx-claude/src/generators/hooks/install-orchestrator.ts
1095
- var import_child_process3 = require("child_process");
1096
- var import_devkit3 = require("@nx/devkit");
1097
- var path2 = __toESM(require("path"));
1098
- var fs3 = __toESM(require("fs"));
1099
- var os2 = __toESM(require("os"));
1100
- var ROOT_CLAUDE_DIR = path2.join(os2.homedir(), ".claude");
1101
- var HOOKS_DIR = path2.join(ROOT_CLAUDE_DIR, "hooks");
1102
- function backupExistingHooks(verbose = false) {
1103
- if (!fs3.existsSync(HOOKS_DIR)) {
1104
- if (verbose) {
1105
- import_devkit3.logger.info("No existing hooks to backup");
1106
- }
1107
- return null;
1108
- }
1109
- const timestamp = (/* @__PURE__ */ new Date()).toISOString().replace(/[:.]/g, "-");
1110
- const backupDir = path2.join(ROOT_CLAUDE_DIR, `hooks-backup-${timestamp}`);
1111
- try {
1112
- if (verbose) {
1113
- import_devkit3.logger.info(`\u{1F4E6} Creating backup at: ${backupDir}`);
1114
- }
1115
- fs3.mkdirSync(backupDir, { recursive: true });
1116
- (0, import_child_process3.execSync)(`cp -r "${HOOKS_DIR}"/* "${backupDir}"/`, {
1117
- stdio: verbose ? "inherit" : "ignore"
1118
- });
1119
- const settingsPath = path2.join(ROOT_CLAUDE_DIR, "settings.json");
1120
- if (fs3.existsSync(settingsPath)) {
1121
- const backupSettingsPath = path2.join(backupDir, "settings.json.backup");
1122
- fs3.copyFileSync(settingsPath, backupSettingsPath);
1123
- }
1124
- import_devkit3.logger.info(`\u2705 Backup created at: ${backupDir}`);
1125
- return backupDir;
1126
- } catch (error) {
1127
- import_devkit3.logger.error(`\u274C Failed to create backup: ${error}`);
1128
- return null;
1129
- }
1130
- }
1131
- async function executeInstallScript(scriptPath, options) {
1132
- return new Promise((resolve) => {
1133
- try {
1134
- if (options.dryRun) {
1135
- import_devkit3.logger.info("\u{1F50D} DRY RUN: Would execute install script with defaults");
1136
- resolve(true);
1137
- return;
1138
- }
1139
- import_devkit3.logger.info("\u{1F680} Running hook installation...");
1140
- const repoDir = path2.dirname(scriptPath);
1141
- const child = (0, import_child_process3.spawn)("bash", [scriptPath], {
1142
- stdio: ["pipe", options.verbose ? "inherit" : "pipe", "inherit"],
1143
- shell: true,
1144
- cwd: repoDir
1145
- // Set working directory to the repo directory
1146
- });
1147
- if (child.stdin) {
1148
- child.stdin.write("1\n");
1149
- child.stdin.end();
1150
- }
1151
- child.on("close", (code) => {
1152
- if (code === 0) {
1153
- import_devkit3.logger.info("\u2705 Installation script completed successfully");
1154
- resolve(true);
1155
- } else {
1156
- import_devkit3.logger.error(`\u274C Installation script exited with code ${code}`);
1157
- resolve(false);
1158
- }
1159
- });
1160
- child.on("error", (error) => {
1161
- import_devkit3.logger.error(`\u274C Failed to execute install script: ${error}`);
1162
- resolve(false);
1163
- });
1164
- } catch (error) {
1165
- import_devkit3.logger.error(`\u274C Error executing install script: ${error}`);
1166
- resolve(false);
1167
- }
1168
- });
1169
- }
1170
- function fixHookPaths(verbose = false) {
1171
- const settingsPath = path2.join(ROOT_CLAUDE_DIR, "settings.json");
1172
- if (!fs3.existsSync(settingsPath)) {
1173
- if (verbose) {
1174
- import_devkit3.logger.warn("\u26A0\uFE0F settings.json not found - cannot fix paths");
1175
- }
1176
- return false;
1177
- }
1178
- try {
1179
- const settings = JSON.parse(fs3.readFileSync(settingsPath, "utf-8"));
1180
- if (!settings.hooks) {
1181
- if (verbose) {
1182
- import_devkit3.logger.warn("\u26A0\uFE0F No hooks configuration found in settings.json");
1183
- }
1184
- return false;
1185
- }
1186
- const homeDir = os2.homedir();
1187
- let modified = false;
1188
- const fixPathInHooks = (hookArray) => {
1189
- for (const hookConfig of hookArray) {
1190
- if (hookConfig.hooks && Array.isArray(hookConfig.hooks)) {
1191
- for (const hook of hookConfig.hooks) {
1192
- if (hook.command && typeof hook.command === "string") {
1193
- if (hook.command.includes(homeDir)) {
1194
- hook.command = hook.command.replace(homeDir, "~");
1195
- modified = true;
1196
- }
1197
- const pathMatch = hook.command.match(/\/(Users|home)\/[^/]+\/\.claude\/hooks\//);
1198
- if (pathMatch) {
1199
- hook.command = hook.command.replace(pathMatch[0], "~/.claude/hooks/");
1200
- modified = true;
1201
- }
1202
- }
1203
- }
1204
- }
1205
- }
1206
- };
1207
- const hookTypes = ["Notification", "Stop", "SubagentStop", "PreToolUse", "PostToolUse"];
1208
- for (const hookType of hookTypes) {
1209
- if (settings.hooks[hookType] && Array.isArray(settings.hooks[hookType])) {
1210
- fixPathInHooks(settings.hooks[hookType]);
1211
- }
1212
- }
1213
- if (modified) {
1214
- fs3.writeFileSync(settingsPath, JSON.stringify(settings, null, 2));
1215
- if (verbose) {
1216
- import_devkit3.logger.info("\u2705 Fixed hook paths to use ~ expansion for Docker compatibility");
1217
- }
1218
- return true;
1219
- }
1220
- return true;
1221
- } catch (error) {
1222
- import_devkit3.logger.error(`\u274C Failed to fix hook paths: ${error}`);
1223
- return false;
1224
- }
1225
- }
1226
- function verifyInstallation() {
1227
- const expectedFiles = ["notification.ts", "stop.ts", "subagent_stop.ts"];
1228
- const installedFiles = [];
1229
- const missingFiles = [];
1230
- for (const file of expectedFiles) {
1231
- const filePath = path2.join(HOOKS_DIR, file);
1232
- if (fs3.existsSync(filePath)) {
1233
- installedFiles.push(filePath);
1234
- } else {
1235
- missingFiles.push(file);
1236
- }
1237
- }
1238
- if (missingFiles.length > 0) {
1239
- import_devkit3.logger.warn(`\u26A0\uFE0F Missing expected files: ${missingFiles.join(", ")}`);
1240
- return null;
1241
- }
1242
- const settingsPath = path2.join(ROOT_CLAUDE_DIR, "settings.json");
1243
- if (!fs3.existsSync(settingsPath)) {
1244
- import_devkit3.logger.warn("\u26A0\uFE0F settings.json not found");
1245
- return null;
1246
- }
1247
- try {
1248
- const settings = JSON.parse(fs3.readFileSync(settingsPath, "utf-8"));
1249
- if (!settings.hooks) {
1250
- import_devkit3.logger.warn("\u26A0\uFE0F No hooks configuration found in settings.json");
1251
- return null;
1252
- }
1253
- import_devkit3.logger.info("\u2705 Installation verified successfully");
1254
- return installedFiles;
1255
- } catch (error) {
1256
- import_devkit3.logger.error(`\u274C Failed to verify settings.json: ${error}`);
1257
- return null;
1258
- }
1259
- }
1260
- async function runInstallation(repoPath, options) {
1261
- const result = {
1262
- success: false,
1263
- installedPath: HOOKS_DIR
1264
- };
1265
- try {
1266
- const installScriptPath = path2.join(repoPath, "install-global.sh");
1267
- if (!fs3.existsSync(installScriptPath)) {
1268
- throw new Error(`Install script not found at: ${installScriptPath}`);
1269
- }
1270
- (0, import_child_process3.execSync)(`chmod +x "${installScriptPath}"`, { stdio: "ignore" });
1271
- if (options.backupExisting) {
1272
- const backupPath = backupExistingHooks(options.verbose);
1273
- if (backupPath) {
1274
- result.backupPath = backupPath;
1275
- }
1276
- }
1277
- const installSuccess = await executeInstallScript(
1278
- installScriptPath,
1279
- options
1280
- );
1281
- if (!installSuccess) {
1282
- throw new Error("Installation script failed");
1283
- }
1284
- const installedFiles = verifyInstallation();
1285
- if (!installedFiles) {
1286
- throw new Error("Installation verification failed");
1287
- }
1288
- fixHookPaths(options.verbose);
1289
- result.success = true;
1290
- result.installedFiles = installedFiles;
1291
- import_devkit3.logger.info("\n\u{1F4CB} Installation Summary:");
1292
- import_devkit3.logger.info(` \u2705 Hooks installed to: ${result.installedPath}`);
1293
- if (result.backupPath) {
1294
- import_devkit3.logger.info(` \u2705 Backup created at: ${result.backupPath}`);
1295
- }
1296
- import_devkit3.logger.info(` \u2705 Files installed: ${installedFiles.length}`);
1297
- return result;
1298
- } catch (error) {
1299
- result.error = error instanceof Error ? error.message : String(error);
1300
- import_devkit3.logger.error(`\u274C Installation failed: ${result.error}`);
1301
- if (result.backupPath && !options.dryRun) {
1302
- import_devkit3.logger.info("\u{1F504} Attempting to restore backup...");
1303
- await restoreBackup(result.backupPath);
1304
- }
1305
- return result;
1306
- }
1307
- }
1308
- async function restoreBackup(backupPath) {
1309
- try {
1310
- if (fs3.existsSync(HOOKS_DIR)) {
1311
- fs3.rmSync(HOOKS_DIR, { recursive: true, force: true });
1312
- }
1313
- fs3.mkdirSync(HOOKS_DIR, { recursive: true });
1314
- (0, import_child_process3.execSync)(`cp -r "${backupPath}"/* "${HOOKS_DIR}"/`, {
1315
- stdio: "ignore"
1316
- });
1317
- const backupSettingsPath = path2.join(backupPath, "settings.json.backup");
1318
- if (fs3.existsSync(backupSettingsPath)) {
1319
- const settingsPath = path2.join(ROOT_CLAUDE_DIR, "settings.json");
1320
- fs3.copyFileSync(backupSettingsPath, settingsPath);
1321
- }
1322
- import_devkit3.logger.info("\u2705 Backup restored successfully");
1323
- return true;
1324
- } catch (error) {
1325
- import_devkit3.logger.error(`\u274C Failed to restore backup: ${error}`);
1326
- return false;
1327
- }
1328
- }
1329
- async function testHooks() {
1330
- try {
1331
- import_devkit3.logger.info("\u{1F9EA} Testing installed hooks...");
1332
- const testPayload = {
1333
- hook_event_name: "Notification",
1334
- session_id: "test-session",
1335
- timestamp: (/* @__PURE__ */ new Date()).toISOString(),
1336
- cwd: process.cwd()
1337
- };
1338
- const notificationHook = path2.join(HOOKS_DIR, "notification.ts");
1339
- if (!fs3.existsSync(notificationHook)) {
1340
- import_devkit3.logger.error("\u274C Notification hook not found");
1341
- return false;
1342
- }
1343
- const command = `echo '${JSON.stringify(
1344
- testPayload
1345
- )}' | npx tsx "${notificationHook}" --notify`;
1346
- import_devkit3.logger.info("\u{1F514} Triggering test notification...");
1347
- (0, import_child_process3.execSync)(command, { stdio: "inherit" });
1348
- import_devkit3.logger.info("\u2705 Hook test completed successfully");
1349
- import_devkit3.logger.info("You should have heard a notification sound/speech");
1350
- return true;
1351
- } catch (error) {
1352
- import_devkit3.logger.error(`\u274C Hook test failed: ${error}`);
1353
- return false;
1354
- }
1355
- }
1356
-
1357
727
  // packages/ai-toolkit-nx-claude/src/utils/cli-parser.ts
1358
- function getExplicitlyProvidedOptions(options) {
1359
- const providedOptions = /* @__PURE__ */ new Map();
1360
- const args = process.argv;
1361
- for (let i = 0; i < args.length; i++) {
1362
- const arg = args[i];
1363
- if (arg.startsWith("--")) {
1364
- if (arg.includes("=")) {
1365
- const [flagPart, ...valueParts] = arg.split("=");
1366
- const flagName = flagPart.slice(2);
1367
- const value = valueParts.join("=");
1368
- const camelCaseName = flagName.replace(
1369
- /-([a-z])/g,
1370
- (_, letter) => letter.toUpperCase()
1371
- );
1372
- const parsedValue = parseValue(value);
1373
- providedOptions.set(flagName, parsedValue);
1374
- providedOptions.set(camelCaseName, parsedValue);
1375
- } else {
1376
- const flagName = arg.slice(2);
1377
- const camelCaseName = flagName.replace(
1378
- /-([a-z])/g,
1379
- (_, letter) => letter.toUpperCase()
1380
- );
1381
- if (i + 1 < args.length && !args[i + 1].startsWith("-")) {
1382
- const value = args[i + 1];
1383
- const parsedValue = parseValue(value);
1384
- providedOptions.set(flagName, parsedValue);
1385
- providedOptions.set(camelCaseName, parsedValue);
1386
- i++;
1387
- } else {
1388
- providedOptions.set(flagName, true);
1389
- providedOptions.set(camelCaseName, true);
1390
- }
1391
- }
1392
- } else if (arg.startsWith("-") && !arg.startsWith("--") && arg.length === 2) {
1393
- const shortFlagMap = {
1394
- d: "dry-run",
1395
- v: "verbose",
1396
- f: "force",
1397
- h: "help"
1398
- };
1399
- const shortFlag = arg.slice(1);
1400
- if (shortFlagMap[shortFlag]) {
1401
- const longFlag = shortFlagMap[shortFlag];
1402
- const camelCaseName = longFlag.replace(
1403
- /-([a-z])/g,
1404
- (_, letter) => letter.toUpperCase()
1405
- );
1406
- providedOptions.set(longFlag, true);
1407
- providedOptions.set(camelCaseName, true);
1408
- }
1409
- }
1410
- }
1411
- if (options) {
1412
- for (const [key, value] of Object.entries(options)) {
1413
- providedOptions.set(key, value);
1414
- }
1415
- }
1416
- return providedOptions;
1417
- }
1418
- function parseValue(value) {
1419
- if (value === "true") return true;
1420
- if (value === "false") return false;
1421
- if (/^-?\d+$/.test(value)) {
1422
- return parseInt(value, 10);
1423
- }
1424
- if (/^-?\d*\.\d+$/.test(value)) {
1425
- return parseFloat(value);
1426
- }
1427
- if (value === "null") return null;
1428
- if (value === "undefined") return void 0;
1429
- return value;
1430
- }
1431
728
  function isNxDryRunProvided() {
1432
729
  const args = process.argv;
1433
730
  return (
@@ -1448,142 +745,16 @@ function isNxNoInteractiveProvided() {
1448
745
  );
1449
746
  }
1450
747
 
1451
- // packages/ai-toolkit-nx-claude/src/generators/hooks/generator.ts
1452
- async function hooksGenerator(tree, options) {
1453
- import_devkit4.logger.info("\u{1F3AF} Claude Code Hooks Generator");
1454
- import_devkit4.logger.info("Installing notification hooks for Claude Code...\n");
1455
- import_devkit4.logger.info("\u{1F4CB} Step 1: Checking dependencies...");
1456
- const depsOk = await checkAndValidateDependencies();
1457
- if (!depsOk && !options.force) {
1458
- import_devkit4.logger.error(
1459
- "\u274C Missing required dependencies. Install them and try again."
1460
- );
1461
- import_devkit4.logger.info("Use --force to skip dependency checks (not recommended)");
1462
- return;
1463
- }
1464
- const schemaPath = path3.join(__dirname, "schema.json");
1465
- let normalizedOptions;
1466
- if (options.installMode === "default") {
1467
- normalizedOptions = {
1468
- backup: options.backup !== false,
1469
- // Default to true unless explicitly false
1470
- dry: options.dry || false,
1471
- force: options.force || false,
1472
- verbose: options.verbose || false,
1473
- installMode: "default"
1474
- };
1475
- } else {
1476
- const explicitlyProvided = getExplicitlyProvidedOptions(options);
1477
- const nxDryRunProvided = isNxDryRunProvided();
1478
- if (nxDryRunProvided) {
1479
- options.dry = true;
1480
- explicitlyProvided.set("dry", true);
1481
- }
1482
- const nxNoInteractiveProvided = isNxNoInteractiveProvided();
1483
- const optionsWithNoInteractive = {
1484
- ...options,
1485
- "no-interactive": nxNoInteractiveProvided
1486
- };
1487
- try {
1488
- normalizedOptions = await promptForMissingOptions(
1489
- optionsWithNoInteractive,
1490
- schemaPath,
1491
- {},
1492
- // context for multi-select (not used here)
1493
- explicitlyProvided
1494
- // pass the explicitly provided options
1495
- );
1496
- } catch (error) {
1497
- if (error.message?.includes("Installation cancelled")) {
1498
- import_devkit4.logger.warn(`\u274C ${error.message}`);
1499
- return;
1500
- }
1501
- throw error;
1502
- }
1503
- }
1504
- const isDryRun = normalizedOptions.dry;
1505
- if (isDryRun) {
1506
- import_devkit4.logger.info("\n\u{1F50D} DRY RUN MODE - No changes will be made");
1507
- import_devkit4.logger.info("The following would be performed:");
1508
- import_devkit4.logger.info(` 1. Download latest notification hooks`);
1509
- import_devkit4.logger.info(` 2. Configure notification hooks`);
1510
- import_devkit4.logger.info(` 3. Install hooks to ~/.claude/hooks/`);
1511
- import_devkit4.logger.info(` 4. Update ~/.claude/settings.json`);
1512
- if (normalizedOptions.backup) {
1513
- import_devkit4.logger.info(` 5. Create backup of existing configuration`);
1514
- }
1515
- return;
1516
- }
1517
- import_devkit4.logger.info("\n\u{1F4E6} Step 2: Downloading notification hooks...");
1518
- const repoPath = await ensureRepository({
1519
- update: true,
1520
- // Always update to latest
1521
- verbose: normalizedOptions.verbose
1522
- });
1523
- if (!repoPath) {
1524
- import_devkit4.logger.error("\u274C Failed to prepare repository");
1525
- return;
1526
- }
1527
- import_devkit4.logger.info(`\u2705 Repository ready at: ${repoPath}`);
1528
- import_devkit4.logger.info("\n\u{1F680} Step 3: Installing hooks...");
1529
- const installResult = await runInstallation(repoPath, {
1530
- backupExisting: normalizedOptions.backup !== false,
1531
- verbose: normalizedOptions.verbose || false,
1532
- dryRun: isDryRun
1533
- });
1534
- if (!installResult.success) {
1535
- import_devkit4.logger.error("\u274C Installation failed");
1536
- if (installResult.error) {
1537
- import_devkit4.logger.error(`Error: ${installResult.error}`);
1538
- }
1539
- if (!normalizedOptions.verbose) {
1540
- cleanupRepository(repoPath);
1541
- }
1542
- return;
1543
- }
1544
- const shouldTest = !isDryRun && normalizedOptions.verbose;
1545
- if (shouldTest) {
1546
- import_devkit4.logger.info("\n\u{1F9EA} Step 4: Testing installation...");
1547
- const { prompt: prompt2 } = await import("enquirer");
1548
- const { runTest } = await prompt2({
1549
- type: "confirm",
1550
- name: "runTest",
1551
- message: "Would you like to test the hooks now?",
1552
- initial: true
1553
- });
1554
- if (runTest) {
1555
- await testHooks();
1556
- }
1557
- }
1558
- if (!normalizedOptions.verbose) {
1559
- import_devkit4.logger.info("\n\u{1F9F9} Cleaning up temporary files...");
1560
- cleanupRepository(repoPath);
1561
- }
1562
- await (0, import_devkit4.formatFiles)(tree);
1563
- import_devkit4.logger.info("\n\u2728 SUCCESS! Claude Code hooks installed successfully!");
1564
- import_devkit4.logger.info("\n\u{1F4DA} Next Steps:");
1565
- import_devkit4.logger.info(" 1. Start a Claude Code session");
1566
- import_devkit4.logger.info(" 2. When Claude needs your input, you'll hear a notification");
1567
- import_devkit4.logger.info(" 3. Check ~/.claude/logs/ for event logs (if enabled)");
1568
- if (installResult.backupPath) {
1569
- import_devkit4.logger.info(`
1570
- \u{1F4BE} Backup saved at: ${installResult.backupPath}`);
1571
- }
1572
- import_devkit4.logger.info("\n\u{1F389} Happy coding with Claude!");
1573
- }
1574
- var generator_default = hooksGenerator;
1575
-
1576
748
  // packages/ai-toolkit-nx-claude/src/generators/addons/generator.ts
1577
- var import_devkit5 = require("@nx/devkit");
1578
749
  init_addon_registry();
1579
750
 
1580
751
  // packages/ai-toolkit-nx-claude/src/generators/addons/claude-mcp-installer.ts
1581
- var import_child_process4 = require("child_process");
752
+ var import_child_process = require("child_process");
1582
753
  init_addon_registry();
1583
754
  async function installMcpServer(options) {
1584
755
  const { addon, additionalArgs = [], dryRun = false, installationType = "global" } = options;
1585
756
  try {
1586
- (0, import_child_process4.execSync)("claude --version", { stdio: "ignore" });
757
+ (0, import_child_process.execSync)("claude --version", { stdio: "ignore" });
1587
758
  } catch {
1588
759
  return {
1589
760
  success: false,
@@ -1638,7 +809,7 @@ async function installMcpServer(options) {
1638
809
  try {
1639
810
  console.log(`
1640
811
  \u{1F527} Installing MCP server (attempt ${attempts}/${maxAttempts})...`);
1641
- const output = (0, import_child_process4.execSync)(command, {
812
+ const output = (0, import_child_process.execSync)(command, {
1642
813
  encoding: "utf-8",
1643
814
  stdio: "pipe"
1644
815
  });
@@ -1683,16 +854,16 @@ async function installMcpServer(options) {
1683
854
  }
1684
855
 
1685
856
  // packages/ai-toolkit-nx-claude/src/generators/addons/aws-log-analyzer-setup.ts
1686
- var import_child_process5 = require("child_process");
857
+ var import_child_process2 = require("child_process");
1687
858
  var import_fs2 = require("fs");
1688
859
  var import_path2 = require("path");
1689
860
  var import_os2 = require("os");
1690
- async function cloneRepository2(repositoryUrl, targetDir) {
861
+ async function cloneRepository(repositoryUrl, targetDir) {
1691
862
  try {
1692
863
  if (!(0, import_fs2.existsSync)(targetDir)) {
1693
864
  (0, import_fs2.mkdirSync)(targetDir, { recursive: true });
1694
865
  }
1695
- (0, import_child_process5.execSync)(`git clone --depth 1 "${repositoryUrl}" "${targetDir}"`, {
866
+ (0, import_child_process2.execSync)(`git clone --depth 1 "${repositoryUrl}" "${targetDir}"`, {
1696
867
  stdio: "pipe",
1697
868
  encoding: "utf8"
1698
869
  });
@@ -1770,7 +941,7 @@ async function setupAwsLogAnalyzer(options) {
1770
941
  console.log("\u{1F4C1} Creating installation directory...");
1771
942
  (0, import_fs2.mkdirSync)(targetPath, { recursive: true });
1772
943
  console.log("\u{1F504} Cloning AWS Log Analyzer repository...");
1773
- const cloneResult = await cloneRepository2(
944
+ const cloneResult = await cloneRepository(
1774
945
  "https://github.com/awslabs/Log-Analyzer-with-MCP.git",
1775
946
  targetPath
1776
947
  );
@@ -1783,7 +954,7 @@ async function setupAwsLogAnalyzer(options) {
1783
954
  }
1784
955
  console.log("\u{1F4E6} Installing Python dependencies with uv...");
1785
956
  try {
1786
- (0, import_child_process5.execSync)("uv sync", {
957
+ (0, import_child_process2.execSync)("uv sync", {
1787
958
  cwd: targetPath,
1788
959
  stdio: "inherit",
1789
960
  encoding: "utf8"
@@ -1854,7 +1025,7 @@ async function generator(tree, schema) {
1854
1025
  return;
1855
1026
  }
1856
1027
  await installSelectedAddons(tree, options);
1857
- await (0, import_devkit5.formatFiles)(tree);
1028
+ await (0, import_devkit.formatFiles)(tree);
1858
1029
  }
1859
1030
  async function installSelectedAddons(tree, options) {
1860
1031
  const selectedAddonIds = options.addons || [];
@@ -2081,6 +1252,5 @@ function showGeneralMcpInstructions(installedAddons) {
2081
1252
  }
2082
1253
  // Annotate the CommonJS export names for ESM import in node:
2083
1254
  0 && (module.exports = {
2084
- addonsGenerator,
2085
- hooksGenerator
1255
+ addonsGenerator
2086
1256
  });