@uniswap/ai-toolkit-nx-claude 0.5.7-next.10

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 (107) hide show
  1. package/README.md +60 -0
  2. package/dist/cli-generator.cjs +447 -0
  3. package/dist/content/agents/agnostic/agent-capability-analyst.md +575 -0
  4. package/dist/content/agents/agnostic/agent-optimizer.md +396 -0
  5. package/dist/content/agents/agnostic/agent-orchestrator.md +475 -0
  6. package/dist/content/agents/agnostic/cicd-agent.md +301 -0
  7. package/dist/content/agents/agnostic/claude-agent-discovery.md +304 -0
  8. package/dist/content/agents/agnostic/code-explainer.md +269 -0
  9. package/dist/content/agents/agnostic/code-generator.md +785 -0
  10. package/dist/content/agents/agnostic/commit-message-generator.md +101 -0
  11. package/dist/content/agents/agnostic/context-loader.md +419 -0
  12. package/dist/content/agents/agnostic/debug-assistant.md +316 -0
  13. package/dist/content/agents/agnostic/doc-writer.md +539 -0
  14. package/dist/content/agents/agnostic/feedback-collector.md +165 -0
  15. package/dist/content/agents/agnostic/infrastructure-agent.md +406 -0
  16. package/dist/content/agents/agnostic/migration-assistant.md +489 -0
  17. package/dist/content/agents/agnostic/pattern-learner.md +481 -0
  18. package/dist/content/agents/agnostic/performance-analyzer.md +528 -0
  19. package/dist/content/agents/agnostic/plan-reviewer.md +144 -0
  20. package/dist/content/agents/agnostic/planner.md +246 -0
  21. package/dist/content/agents/agnostic/pr-creator.md +494 -0
  22. package/dist/content/agents/agnostic/prompt-engineer.md +541 -0
  23. package/dist/content/agents/agnostic/refactorer.md +311 -0
  24. package/dist/content/agents/agnostic/researcher.md +347 -0
  25. package/dist/content/agents/agnostic/security-analyzer.md +1087 -0
  26. package/dist/content/agents/agnostic/style-enforcer.md +568 -0
  27. package/dist/content/agents/agnostic/test-runner.md +481 -0
  28. package/dist/content/agents/agnostic/test-writer.md +292 -0
  29. package/dist/content/commands/agnostic/auto-spec.md +386 -0
  30. package/dist/content/commands/agnostic/create-pr.md +79 -0
  31. package/dist/content/commands/agnostic/deploy.md +441 -0
  32. package/dist/content/commands/agnostic/execute-plan.md +367 -0
  33. package/dist/content/commands/agnostic/explain-file.md +303 -0
  34. package/dist/content/commands/agnostic/explore.md +82 -0
  35. package/dist/content/commands/agnostic/fix-bug.md +273 -0
  36. package/dist/content/commands/agnostic/gen-tests.md +185 -0
  37. package/dist/content/commands/agnostic/generate-commit-message.md +92 -0
  38. package/dist/content/commands/agnostic/implement-spec.md +270 -0
  39. package/dist/content/commands/agnostic/monitor.md +581 -0
  40. package/dist/content/commands/agnostic/plan.md +335 -0
  41. package/dist/content/commands/agnostic/refactor.md +315 -0
  42. package/dist/content/commands/agnostic/research.md +49 -0
  43. package/dist/content/commands/agnostic/review-code.md +321 -0
  44. package/dist/content/commands/agnostic/review-plan.md +110 -0
  45. package/dist/content/commands/agnostic/review-pr.md +393 -0
  46. package/dist/generators/add-agent/files/__name__.md.template +37 -0
  47. package/dist/generators/add-agent/generator.cjs +534 -0
  48. package/dist/generators/add-agent/schema.json +59 -0
  49. package/dist/generators/add-command/files/__name__.md.template +46 -0
  50. package/dist/generators/add-command/generator.cjs +537 -0
  51. package/dist/generators/add-command/schema.json +50 -0
  52. package/dist/generators/addons/generator.cjs +1285 -0
  53. package/dist/generators/addons/schema.json +55 -0
  54. package/dist/generators/files/src/index.ts.template +1 -0
  55. package/dist/generators/hooks/CLAUDE.md +326 -0
  56. package/dist/generators/hooks/README.md +220 -0
  57. package/dist/generators/hooks/generator.cjs +1086 -0
  58. package/dist/generators/hooks/schema.json +38 -0
  59. package/dist/generators/init/CLAUDE.md +291 -0
  60. package/dist/generators/init/generator.cjs +1268 -0
  61. package/dist/generators/init/schema.json +82 -0
  62. package/dist/generators/init/setup-github-packages.sh +132 -0
  63. package/dist/generators/setup-registry-proxy/README.md +111 -0
  64. package/dist/generators/setup-registry-proxy/files/uniswap-ai-toolkit.__shell__rc.template +178 -0
  65. package/dist/generators/setup-registry-proxy/generator.cjs +227 -0
  66. package/dist/generators/setup-registry-proxy/schema.json +43 -0
  67. package/dist/index.cjs +1 -0
  68. package/dist/packages/ai-toolkit-nx-claude/src/cli-generator.d.ts +16 -0
  69. package/dist/packages/ai-toolkit-nx-claude/src/cli-generator.d.ts.map +1 -0
  70. package/dist/packages/ai-toolkit-nx-claude/src/cli-utils.d.ts +6 -0
  71. package/dist/packages/ai-toolkit-nx-claude/src/cli-utils.d.ts.map +1 -0
  72. package/dist/packages/ai-toolkit-nx-claude/src/generators/add-agent/generator.d.ts +5 -0
  73. package/dist/packages/ai-toolkit-nx-claude/src/generators/add-agent/generator.d.ts.map +1 -0
  74. package/dist/packages/ai-toolkit-nx-claude/src/generators/add-command/generator.d.ts +5 -0
  75. package/dist/packages/ai-toolkit-nx-claude/src/generators/add-command/generator.d.ts.map +1 -0
  76. package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/addon-registry.d.ts +76 -0
  77. package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/addon-registry.d.ts.map +1 -0
  78. package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/claude-mcp-installer.d.ts +47 -0
  79. package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/claude-mcp-installer.d.ts.map +1 -0
  80. package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/generator.d.ts +7 -0
  81. package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/generator.d.ts.map +1 -0
  82. package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/github-auth.d.ts +36 -0
  83. package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/github-auth.d.ts.map +1 -0
  84. package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/spec-workflow-setup.d.ts +52 -0
  85. package/dist/packages/ai-toolkit-nx-claude/src/generators/addons/spec-workflow-setup.d.ts.map +1 -0
  86. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/cli-parser.d.ts +2 -0
  87. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/cli-parser.d.ts.map +1 -0
  88. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/dependency-checker.d.ts +46 -0
  89. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/dependency-checker.d.ts.map +1 -0
  90. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/generator.d.ts +9 -0
  91. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/generator.d.ts.map +1 -0
  92. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/install-orchestrator.d.ts +55 -0
  93. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/install-orchestrator.d.ts.map +1 -0
  94. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/repo-manager.d.ts +63 -0
  95. package/dist/packages/ai-toolkit-nx-claude/src/generators/hooks/repo-manager.d.ts.map +1 -0
  96. package/dist/packages/ai-toolkit-nx-claude/src/generators/init/generator.d.ts +5 -0
  97. package/dist/packages/ai-toolkit-nx-claude/src/generators/init/generator.d.ts.map +1 -0
  98. package/dist/packages/ai-toolkit-nx-claude/src/generators/setup-registry-proxy/generator.d.ts +5 -0
  99. package/dist/packages/ai-toolkit-nx-claude/src/generators/setup-registry-proxy/generator.d.ts.map +1 -0
  100. package/dist/packages/ai-toolkit-nx-claude/src/index.d.ts +2 -0
  101. package/dist/packages/ai-toolkit-nx-claude/src/index.d.ts.map +1 -0
  102. package/dist/packages/ai-toolkit-nx-claude/src/utils/cli-parser.d.ts +15 -0
  103. package/dist/packages/ai-toolkit-nx-claude/src/utils/cli-parser.d.ts.map +1 -0
  104. package/dist/packages/ai-toolkit-nx-claude/src/utils/prompt-utils.d.ts +42 -0
  105. package/dist/packages/ai-toolkit-nx-claude/src/utils/prompt-utils.d.ts.map +1 -0
  106. package/generators.json +34 -0
  107. package/package.json +166 -0
package/README.md ADDED
@@ -0,0 +1,60 @@
1
+ # @uniswap/ai-toolkit-nx-claude
2
+
3
+ This package provides Nx generators for setting up and managing Claude Code configurations, commands, agents, and notification hooks.
4
+
5
+ ## Installation
6
+
7
+ This package is published to GitHub Packages and requires authentication to access. Ensure you have a GitHub personal access token with appropriate scopes configured in your npm settings. More information available in the root README.md file.
8
+
9
+ ````bash
10
+
11
+ ## Usage
12
+
13
+ ### Run Default Generator
14
+
15
+ ```bash
16
+ npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest
17
+ ````
18
+
19
+ ### Run Specific Generators
20
+
21
+ Each generator can be run directly using colon syntax:
22
+
23
+ ```bash
24
+ # One-shot installer for Claude Code configs
25
+ npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest init
26
+
27
+ # Install notification hooks
28
+ npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest hooks
29
+
30
+ # Setup shell proxy for GitHub registry routing
31
+ npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest setup-registry-proxy
32
+
33
+ # Install and configure Claude Code addons
34
+ npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest addons
35
+
36
+ # Add a new command to packages
37
+ npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest add-command
38
+
39
+ # Add a new agent to packages
40
+ npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest add-agent
41
+ ```
42
+
43
+ ### List Available Generators
44
+
45
+ ```bash
46
+ npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest --list
47
+ ```
48
+
49
+ ## Available Generators
50
+
51
+ - **init** - One-shot installer for Claude Code configs
52
+ - **hooks** - Install Claude Code notification hooks
53
+ - **setup-registry-proxy** - Setup shell proxy for routing @uniswap/ai-toolkit\* packages to GitHub registry
54
+ - **addons** - Install and configure Claude Code addons including MCP servers
55
+ - **add-command** - Add a new Claude Code command to existing or new packages
56
+ - **add-agent** - Add a new Claude Code agent to existing or new packages
57
+
58
+ ## Building
59
+
60
+ Run `nx build ai-toolkit-nx-claude` to build the library.
@@ -0,0 +1,447 @@
1
+ #!/usr/bin/env node
2
+ "use strict";
3
+ var __create = Object.create;
4
+ var __defProp = Object.defineProperty;
5
+ var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
6
+ var __getOwnPropNames = Object.getOwnPropertyNames;
7
+ var __getProtoOf = Object.getPrototypeOf;
8
+ var __hasOwnProp = Object.prototype.hasOwnProperty;
9
+ var __copyProps = (to, from, except, desc) => {
10
+ if (from && typeof from === "object" || typeof from === "function") {
11
+ for (let key of __getOwnPropNames(from))
12
+ if (!__hasOwnProp.call(to, key) && key !== except)
13
+ __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
14
+ }
15
+ return to;
16
+ };
17
+ var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
18
+ // If the importer is in node compatibility mode or this is not an ESM
19
+ // file that has been converted to a CommonJS file using a Babel-
20
+ // compatible transform (i.e. "__esModule" has not been set), then set
21
+ // "default" to the CommonJS "module.exports" for node compatibility.
22
+ isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
23
+ mod
24
+ ));
25
+
26
+ // packages/ai-toolkit-nx-claude/src/cli-utils.ts
27
+ var import_child_process = require("child_process");
28
+ var path = __toESM(require("path"));
29
+ var fs = __toESM(require("fs"));
30
+ async function handleNxExecution(generatorName, args) {
31
+ if (args.includes("--help") || args.includes("-h")) {
32
+ console.log(
33
+ `Usage: npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest ${generatorName}`
34
+ );
35
+ console.log(
36
+ `
37
+ This command runs the nx-claude ${generatorName} generator.`
38
+ );
39
+ console.log("\nOptions are handled interactively during execution.");
40
+ console.log("\nFor more information, see the package documentation.");
41
+ process.exit(0);
42
+ }
43
+ const isStandalone = shouldRunStandalone();
44
+ if (isStandalone) {
45
+ await runGeneratorDirectly(generatorName, args);
46
+ } else {
47
+ try {
48
+ const nxArgs = [
49
+ "nx",
50
+ "generate",
51
+ `@uniswap/ai-toolkit-nx-claude:${generatorName}`,
52
+ ...args
53
+ ];
54
+ (0, import_child_process.execSync)(nxArgs.join(" "), {
55
+ stdio: "inherit",
56
+ cwd: process.cwd()
57
+ });
58
+ } catch (error) {
59
+ handleExecutionError(error, generatorName);
60
+ }
61
+ }
62
+ }
63
+ function handleExecutionError(error, generatorName) {
64
+ if (error.code === "403" || error.message?.includes("Forbidden") || error.message?.includes("unauthorized")) {
65
+ console.error("\n\u274C Authentication Error");
66
+ console.error(
67
+ "\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"
68
+ );
69
+ console.error("You do not have permission to access this package.");
70
+ console.error(
71
+ "\nThis package is restricted to members of the Uniswap GitHub organization."
72
+ );
73
+ console.error("\nTo gain access:");
74
+ console.error(
75
+ "1. Verify you are a member of the Uniswap organization on GitHub"
76
+ );
77
+ console.error(
78
+ '2. Check that your npm token has the required "read:packages" scope'
79
+ );
80
+ console.error(
81
+ "\nFor more information, see: https://docs.github.com/en/packages/working-with-a-github-packages-registry/working-with-the-npm-registry#authenticating-to-github-packages"
82
+ );
83
+ console.error(
84
+ "\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"
85
+ );
86
+ } else if (error.code === "404" || error.message?.includes("Not Found")) {
87
+ console.error("\n\u274C Package Not Found");
88
+ console.error(
89
+ "\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"
90
+ );
91
+ console.error(
92
+ "The package @uniswap/ai-toolkit-nx-claude could not be found."
93
+ );
94
+ console.error("\nThis may be because:");
95
+ console.error("1. The package has not been published yet");
96
+ console.error(
97
+ "2. You are not authenticated properly (check your GitHub PAT)"
98
+ );
99
+ console.error("\nTry running:");
100
+ console.error(
101
+ ' echo "//npm.pkg.github.com/:_authToken=YOUR_GITHUB_TOKEN" >> ~/.npmrc'
102
+ );
103
+ console.error(
104
+ "\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"
105
+ );
106
+ } else if (error.code === "ENOENT") {
107
+ console.error("\n\u274C Nx CLI Not Found");
108
+ console.error(
109
+ "\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"
110
+ );
111
+ console.error("The Nx CLI is required but not installed.");
112
+ console.error("\nPlease install Nx globally:");
113
+ console.error(" npm install -g nx");
114
+ console.error("\nOr use npx to run without installing:");
115
+ console.error(
116
+ ` npx nx generate @uniswap/ai-toolkit-nx-claude@latest ${generatorName}`
117
+ );
118
+ console.error(
119
+ "\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501\u2501"
120
+ );
121
+ } else {
122
+ process.exit(error.status || 1);
123
+ }
124
+ process.exit(1);
125
+ }
126
+ function shouldRunStandalone() {
127
+ const scriptPath = process.argv[1];
128
+ const isInAiToolkitWorkspace = scriptPath.includes(
129
+ "/ai-toolkit/packages/ai-toolkit-nx-claude/"
130
+ );
131
+ if (!isInAiToolkitWorkspace) {
132
+ return true;
133
+ }
134
+ const cwd = process.cwd();
135
+ const hasNxJson = fs.existsSync(path.join(cwd, "nx.json"));
136
+ return !hasNxJson || !cwd.includes("/ai-toolkit");
137
+ }
138
+ async function runGeneratorDirectly(generatorName, args) {
139
+ try {
140
+ const generatorFunctionMap = {
141
+ init: "initGenerator",
142
+ hooks: "hooksGenerator",
143
+ "setup-registry-proxy": "setupRegistryProxyGenerator",
144
+ addons: "addonsGenerator",
145
+ "add-command": "addCommandGenerator",
146
+ "add-agent": "addAgentGenerator"
147
+ };
148
+ const generatorFnName = generatorFunctionMap[generatorName];
149
+ if (!generatorFnName) {
150
+ console.error(`
151
+ \u274C Generator '${generatorName}' not found`);
152
+ console.error(
153
+ `Available generators: ${Object.keys(generatorFunctionMap).join(", ")}`
154
+ );
155
+ process.exit(1);
156
+ }
157
+ const jsPath = path.join(
158
+ __dirname,
159
+ "generators",
160
+ generatorName,
161
+ "generator.js"
162
+ );
163
+ const cjsPath = path.join(
164
+ __dirname,
165
+ "generators",
166
+ generatorName,
167
+ "generator.cjs"
168
+ );
169
+ const generatorPath = fs.existsSync(jsPath) ? jsPath : cjsPath;
170
+ if (!fs.existsSync(generatorPath)) {
171
+ console.error(`
172
+ \u274C Generator file not found at: ${jsPath}`);
173
+ console.error(`Also tried: ${cjsPath}`);
174
+ console.error(`Current __dirname: ${__dirname}`);
175
+ console.error(`Looking for generator: ${generatorName}`);
176
+ const generatorsDir = path.join(__dirname, "generators");
177
+ if (fs.existsSync(generatorsDir)) {
178
+ console.error(`
179
+ Contents of generators directory:`);
180
+ const dirs = fs.readdirSync(generatorsDir);
181
+ dirs.forEach((dir) => {
182
+ const genPath = path.join(generatorsDir, dir);
183
+ if (fs.statSync(genPath).isDirectory()) {
184
+ const genFile = path.join(genPath, "generator.js");
185
+ console.error(
186
+ ` ${dir}: ${fs.existsSync(genFile) ? "\u2713 generator.js exists" : "\u2717 generator.js missing"}`
187
+ );
188
+ }
189
+ });
190
+ } else {
191
+ console.error(`Generators directory not found at: ${generatorsDir}`);
192
+ }
193
+ throw new Error(`Generator file not found: ${generatorName}`);
194
+ }
195
+ const generatorModule = require(generatorPath);
196
+ let generator = generatorModule[generatorFnName];
197
+ if (!generator && generatorModule.default) {
198
+ generator = generatorModule.default;
199
+ }
200
+ if (!generator && typeof generatorModule === "function") {
201
+ generator = generatorModule;
202
+ }
203
+ if (!generator || typeof generator !== "function") {
204
+ const moduleExports = Object.keys(generatorModule);
205
+ console.error(`
206
+ \u274C Generator function not found for '${generatorName}'`);
207
+ console.error(`Expected function name: ${generatorFnName}`);
208
+ console.error(`Available exports: ${moduleExports.join(", ")}`);
209
+ console.error(
210
+ `Export types: ${moduleExports.map((key) => `${key}: ${typeof generatorModule[key]}`).join(", ")}`
211
+ );
212
+ console.error(`
213
+ \u274C Generator '${generatorName}' not found`);
214
+ console.error(
215
+ `Available generators: ${Object.keys(generatorFunctionMap).filter((g) => g !== generatorName).join(", ")}`
216
+ );
217
+ process.exit(1);
218
+ }
219
+ const options = parseCliArgs(args);
220
+ const tree = createStandaloneTree();
221
+ await generator(tree, options);
222
+ await applyTreeChanges(tree);
223
+ } catch (error) {
224
+ if (error.code === "MODULE_NOT_FOUND" || error.message?.includes("Cannot find module") || error.message?.includes("Generator file not found")) {
225
+ console.error(`
226
+ \u274C Failed to load generator '${generatorName}'`);
227
+ if (!error.message?.includes("Generator file not found")) {
228
+ console.error(`Error details: ${error.message}`);
229
+ }
230
+ console.error(
231
+ "\nThis may indicate a packaging or installation issue with the npm package."
232
+ );
233
+ console.error(
234
+ "Please report this issue at: https://github.com/uniswap/ai-toolkit/issues"
235
+ );
236
+ process.exit(1);
237
+ }
238
+ console.error(`Error running generator '${generatorName}':`, error.message);
239
+ if (process.env.DEBUG) {
240
+ console.error(error.stack);
241
+ }
242
+ process.exit(1);
243
+ }
244
+ }
245
+ function parseCliArgs(args) {
246
+ const options = {};
247
+ for (let i = 0; i < args.length; i++) {
248
+ const arg = args[i];
249
+ if (arg.startsWith("--")) {
250
+ let key = arg.slice(2);
251
+ const nextArg = args[i + 1];
252
+ let value = true;
253
+ if (key.includes("=")) {
254
+ const [k, v] = key.split("=");
255
+ key = k;
256
+ value = v;
257
+ } else if (nextArg && !nextArg.startsWith("--")) {
258
+ value = nextArg;
259
+ i++;
260
+ }
261
+ const camelKey = key.replace(
262
+ /-([a-z])/g,
263
+ (_, letter) => letter.toUpperCase()
264
+ );
265
+ if (camelKey.startsWith("no") && camelKey.length > 2) {
266
+ const actualKey = camelKey[2].toLowerCase() + camelKey.slice(3);
267
+ if (actualKey === "interactive") {
268
+ options["nonInteractive"] = true;
269
+ } else {
270
+ options[actualKey] = false;
271
+ }
272
+ } else {
273
+ options[camelKey] = value;
274
+ }
275
+ }
276
+ }
277
+ return options;
278
+ }
279
+ function createStandaloneTree() {
280
+ const changes = /* @__PURE__ */ new Map();
281
+ return {
282
+ root: process.cwd(),
283
+ read(filePath) {
284
+ const fullPath = path.join(process.cwd(), filePath);
285
+ if (fs.existsSync(fullPath)) {
286
+ return fs.readFileSync(fullPath);
287
+ }
288
+ return null;
289
+ },
290
+ write(filePath, content) {
291
+ changes.set(filePath, { content: content.toString(), mode: "update" });
292
+ },
293
+ exists(filePath) {
294
+ const fullPath = path.join(process.cwd(), filePath);
295
+ return fs.existsSync(fullPath);
296
+ },
297
+ delete(filePath) {
298
+ changes.set(filePath, { content: "", mode: "delete" });
299
+ },
300
+ isFile(filePath) {
301
+ const fullPath = path.join(process.cwd(), filePath);
302
+ return fs.existsSync(fullPath) && fs.statSync(fullPath).isFile();
303
+ },
304
+ children(dirPath) {
305
+ const fullPath = path.join(process.cwd(), dirPath);
306
+ if (fs.existsSync(fullPath) && fs.statSync(fullPath).isDirectory()) {
307
+ return fs.readdirSync(fullPath);
308
+ }
309
+ return [];
310
+ },
311
+ // Store changes for later application
312
+ _changes: changes
313
+ };
314
+ }
315
+ async function applyTreeChanges(tree) {
316
+ for (const [filePath, change] of tree._changes.entries()) {
317
+ const fullPath = path.join(process.cwd(), filePath);
318
+ if (change.mode === "delete") {
319
+ if (fs.existsSync(fullPath)) {
320
+ fs.unlinkSync(fullPath);
321
+ }
322
+ } else {
323
+ const dir = path.dirname(fullPath);
324
+ if (!fs.existsSync(dir)) {
325
+ fs.mkdirSync(dir, { recursive: true });
326
+ }
327
+ fs.writeFileSync(fullPath, change.content);
328
+ }
329
+ }
330
+ }
331
+
332
+ // packages/ai-toolkit-nx-claude/src/cli-generator.ts
333
+ var import_enquirer = require("enquirer");
334
+ var path2 = __toESM(require("path"));
335
+ var fs2 = __toESM(require("fs"));
336
+ function isInAiToolkitRepo() {
337
+ const cwd = process.cwd();
338
+ const scriptPath = process.argv[1];
339
+ const isInAiToolkit = cwd.includes("/ai-toolkit") || scriptPath.includes("/ai-toolkit/") || fs2.existsSync(path2.join(cwd, "package.json")) && JSON.parse(fs2.readFileSync(path2.join(cwd, "package.json"), "utf-8")).name === "@ai-toolkit/source";
340
+ return isInAiToolkit;
341
+ }
342
+ var GENERATORS = {
343
+ init: "One-shot installer for Claude Code configs",
344
+ hooks: "Install Claude Code notification hooks",
345
+ addons: "Install and configure Claude Code addons including MCP servers",
346
+ "setup-registry-proxy": "Setup shell proxy for routing @uniswap/ai-toolkit* packages to GitHub registry"
347
+ };
348
+ var ALL_GENERATORS = isInAiToolkitRepo() ? {
349
+ ...GENERATORS,
350
+ "add-command": "Add a new Claude Code command to existing or new packages",
351
+ "add-agent": "Add a new Claude Code agent to existing or new packages"
352
+ } : GENERATORS;
353
+ function getGeneratorName(args) {
354
+ if (args.length > 0 && !args[0].startsWith("-")) {
355
+ const generatorName = args[0];
356
+ if (generatorName in ALL_GENERATORS) {
357
+ return generatorName;
358
+ }
359
+ console.error(`
360
+ \u274C Unknown generator: '${generatorName}'
361
+ `);
362
+ console.error("Available generators:");
363
+ Object.entries(ALL_GENERATORS).forEach(([name, description]) => {
364
+ console.error(` \u2022 ${name}: ${description}`);
365
+ });
366
+ process.exit(1);
367
+ }
368
+ return null;
369
+ }
370
+ async function selectGeneratorInteractively() {
371
+ console.log("\n\u{1F3AF} AI Toolkit NX Claude Generator\n");
372
+ console.log("Select a generator to run:\n");
373
+ const availableGenerators = isInAiToolkitRepo() ? ALL_GENERATORS : GENERATORS;
374
+ const choices = Object.entries(availableGenerators).map(([value, label]) => ({
375
+ message: `${value.padEnd(25)} - ${label}`,
376
+ name: value
377
+ // name is the actual value that gets returned
378
+ }));
379
+ const response = await (0, import_enquirer.prompt)({
380
+ type: "select",
381
+ name: "generator",
382
+ message: "Which generator would you like to use?",
383
+ choices
384
+ });
385
+ return response.generator;
386
+ }
387
+ async function main() {
388
+ const args = process.argv.slice(2);
389
+ let generatorName = getGeneratorName(args);
390
+ const processedArgs = args.length > 0 && !args[0].startsWith("-") && args[0] in ALL_GENERATORS ? args.slice(1) : args;
391
+ if (processedArgs.includes("--list") || processedArgs.includes("-l")) {
392
+ console.log("Available generators:\n");
393
+ Object.entries(ALL_GENERATORS).forEach(([name, description]) => {
394
+ console.log(` ${name.padEnd(25)} ${description}`);
395
+ });
396
+ console.log("\nUsage:");
397
+ console.log(
398
+ " npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest [generator]"
399
+ );
400
+ console.log("\nExamples:");
401
+ console.log(
402
+ " npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest init"
403
+ );
404
+ console.log(
405
+ " npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest hooks"
406
+ );
407
+ process.exit(0);
408
+ }
409
+ if (processedArgs.includes("--help") || processedArgs.includes("-h")) {
410
+ if (generatorName) {
411
+ console.log(
412
+ `Usage: npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest ${generatorName}`
413
+ );
414
+ console.log(
415
+ `
416
+ This command runs the nx-claude ${generatorName} generator.`
417
+ );
418
+ } else {
419
+ console.log(
420
+ "Usage: npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest [generator]"
421
+ );
422
+ console.log("\nRun without arguments for interactive mode.");
423
+ }
424
+ console.log("\nTo see all available generators, run with --list");
425
+ console.log("\nTo run a specific generator:");
426
+ console.log(
427
+ " npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest [generator]"
428
+ );
429
+ console.log("\nOptions are handled interactively during execution.");
430
+ console.log("\nFor more information, see the package documentation.");
431
+ process.exit(0);
432
+ }
433
+ if (!generatorName && processedArgs.length === 0) {
434
+ generatorName = await selectGeneratorInteractively();
435
+ console.log("");
436
+ }
437
+ if (!generatorName) {
438
+ console.error("\n\u274C No generator specified.");
439
+ console.error(
440
+ "\nUsage: npx --@uniswap:registry=https://npm.pkg.github.com @uniswap/ai-toolkit-nx-claude@latest [generator]"
441
+ );
442
+ console.error("\nRun with --list to see available generators.");
443
+ process.exit(1);
444
+ }
445
+ await handleNxExecution(generatorName, processedArgs);
446
+ }
447
+ main().catch(console.error);