@uniswap/ai-toolkit-nx-claude 0.5.29 → 0.5.30-next.1

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 (87) hide show
  1. package/dist/cli-generator.cjs +28 -59
  2. package/dist/packages/ai-toolkit-nx-claude/src/cli-generator.d.ts +8 -10
  3. package/dist/packages/ai-toolkit-nx-claude/src/cli-generator.d.ts.map +1 -1
  4. package/dist/packages/ai-toolkit-nx-claude/src/index.d.ts +0 -1
  5. package/dist/packages/ai-toolkit-nx-claude/src/index.d.ts.map +1 -1
  6. package/generators.json +0 -15
  7. package/package.json +4 -35
  8. package/dist/content/agents/agnostic/CLAUDE.md +0 -282
  9. package/dist/content/agents/agnostic/agent-capability-analyst.md +0 -575
  10. package/dist/content/agents/agnostic/agent-optimizer.md +0 -396
  11. package/dist/content/agents/agnostic/agent-orchestrator.md +0 -475
  12. package/dist/content/agents/agnostic/cicd-agent.md +0 -301
  13. package/dist/content/agents/agnostic/claude-agent-discovery.md +0 -304
  14. package/dist/content/agents/agnostic/claude-docs-fact-checker.md +0 -435
  15. package/dist/content/agents/agnostic/claude-docs-initializer.md +0 -782
  16. package/dist/content/agents/agnostic/claude-docs-manager.md +0 -595
  17. package/dist/content/agents/agnostic/code-explainer.md +0 -269
  18. package/dist/content/agents/agnostic/code-generator.md +0 -785
  19. package/dist/content/agents/agnostic/commit-message-generator.md +0 -101
  20. package/dist/content/agents/agnostic/context-loader.md +0 -432
  21. package/dist/content/agents/agnostic/debug-assistant.md +0 -321
  22. package/dist/content/agents/agnostic/doc-writer.md +0 -536
  23. package/dist/content/agents/agnostic/feedback-collector.md +0 -165
  24. package/dist/content/agents/agnostic/infrastructure-agent.md +0 -406
  25. package/dist/content/agents/agnostic/migration-assistant.md +0 -489
  26. package/dist/content/agents/agnostic/pattern-learner.md +0 -481
  27. package/dist/content/agents/agnostic/performance-analyzer.md +0 -528
  28. package/dist/content/agents/agnostic/plan-reviewer.md +0 -173
  29. package/dist/content/agents/agnostic/planner.md +0 -235
  30. package/dist/content/agents/agnostic/pr-creator.md +0 -498
  31. package/dist/content/agents/agnostic/pr-reviewer.md +0 -142
  32. package/dist/content/agents/agnostic/prompt-engineer.md +0 -541
  33. package/dist/content/agents/agnostic/refactorer.md +0 -311
  34. package/dist/content/agents/agnostic/researcher.md +0 -349
  35. package/dist/content/agents/agnostic/security-analyzer.md +0 -1087
  36. package/dist/content/agents/agnostic/stack-splitter.md +0 -642
  37. package/dist/content/agents/agnostic/style-enforcer.md +0 -568
  38. package/dist/content/agents/agnostic/test-runner.md +0 -481
  39. package/dist/content/agents/agnostic/test-writer.md +0 -292
  40. package/dist/content/commands/agnostic/CLAUDE.md +0 -207
  41. package/dist/content/commands/agnostic/address-pr-issues.md +0 -205
  42. package/dist/content/commands/agnostic/auto-spec.md +0 -386
  43. package/dist/content/commands/agnostic/claude-docs.md +0 -409
  44. package/dist/content/commands/agnostic/claude-init-plus.md +0 -439
  45. package/dist/content/commands/agnostic/create-pr.md +0 -79
  46. package/dist/content/commands/agnostic/daily-standup.md +0 -185
  47. package/dist/content/commands/agnostic/deploy.md +0 -441
  48. package/dist/content/commands/agnostic/execute-plan.md +0 -167
  49. package/dist/content/commands/agnostic/explain-file.md +0 -303
  50. package/dist/content/commands/agnostic/explore.md +0 -82
  51. package/dist/content/commands/agnostic/fix-bug.md +0 -273
  52. package/dist/content/commands/agnostic/gen-tests.md +0 -185
  53. package/dist/content/commands/agnostic/generate-commit-message.md +0 -92
  54. package/dist/content/commands/agnostic/git-worktree-orchestrator.md +0 -647
  55. package/dist/content/commands/agnostic/implement-spec.md +0 -270
  56. package/dist/content/commands/agnostic/monitor.md +0 -581
  57. package/dist/content/commands/agnostic/perf-analyze.md +0 -214
  58. package/dist/content/commands/agnostic/plan.md +0 -453
  59. package/dist/content/commands/agnostic/refactor.md +0 -315
  60. package/dist/content/commands/agnostic/refine-linear-task.md +0 -575
  61. package/dist/content/commands/agnostic/research.md +0 -49
  62. package/dist/content/commands/agnostic/review-code.md +0 -321
  63. package/dist/content/commands/agnostic/review-plan.md +0 -109
  64. package/dist/content/commands/agnostic/review-pr.md +0 -393
  65. package/dist/content/commands/agnostic/split-stack.md +0 -705
  66. package/dist/content/commands/agnostic/update-claude-md.md +0 -401
  67. package/dist/content/commands/agnostic/work-through-pr-comments.md +0 -873
  68. package/dist/generators/add-agent/CLAUDE.md +0 -130
  69. package/dist/generators/add-agent/files/__name__.md.template +0 -37
  70. package/dist/generators/add-agent/generator.cjs +0 -640
  71. package/dist/generators/add-agent/schema.json +0 -59
  72. package/dist/generators/add-command/CLAUDE.md +0 -131
  73. package/dist/generators/add-command/files/__name__.md.template +0 -46
  74. package/dist/generators/add-command/generator.cjs +0 -643
  75. package/dist/generators/add-command/schema.json +0 -50
  76. package/dist/generators/files/src/index.ts.template +0 -1
  77. package/dist/generators/init/CLAUDE.md +0 -520
  78. package/dist/generators/init/generator.cjs +0 -3304
  79. package/dist/generators/init/schema.json +0 -180
  80. package/dist/packages/ai-toolkit-nx-claude/src/generators/add-agent/generator.d.ts +0 -5
  81. package/dist/packages/ai-toolkit-nx-claude/src/generators/add-agent/generator.d.ts.map +0 -1
  82. package/dist/packages/ai-toolkit-nx-claude/src/generators/add-command/generator.d.ts +0 -5
  83. package/dist/packages/ai-toolkit-nx-claude/src/generators/add-command/generator.d.ts.map +0 -1
  84. package/dist/packages/ai-toolkit-nx-claude/src/generators/init/generator.d.ts +0 -5
  85. package/dist/packages/ai-toolkit-nx-claude/src/generators/init/generator.d.ts.map +0 -1
  86. package/dist/packages/ai-toolkit-nx-claude/src/utils/auto-update-utils.d.ts +0 -30
  87. package/dist/packages/ai-toolkit-nx-claude/src/utils/auto-update-utils.d.ts.map +0 -1
@@ -1,640 +0,0 @@
1
- "use strict";
2
- var __create = Object.create;
3
- var __defProp = Object.defineProperty;
4
- var __getOwnPropDesc = Object.getOwnPropertyDescriptor;
5
- var __getOwnPropNames = Object.getOwnPropertyNames;
6
- var __getProtoOf = Object.getPrototypeOf;
7
- var __hasOwnProp = Object.prototype.hasOwnProperty;
8
- var __export = (target, all) => {
9
- for (var name in all)
10
- __defProp(target, name, { get: all[name], enumerable: true });
11
- };
12
- var __copyProps = (to, from, except, desc) => {
13
- if (from && typeof from === "object" || typeof from === "function") {
14
- for (let key of __getOwnPropNames(from))
15
- if (!__hasOwnProp.call(to, key) && key !== except)
16
- __defProp(to, key, { get: () => from[key], enumerable: !(desc = __getOwnPropDesc(from, key)) || desc.enumerable });
17
- }
18
- return to;
19
- };
20
- var __toESM = (mod, isNodeMode, target) => (target = mod != null ? __create(__getProtoOf(mod)) : {}, __copyProps(
21
- // If the importer is in node compatibility mode or this is not an ESM
22
- // file that has been converted to a CommonJS file using a Babel-
23
- // compatible transform (i.e. "__esModule" has not been set), then set
24
- // "default" to the CommonJS "module.exports" for node compatibility.
25
- isNodeMode || !mod || !mod.__esModule ? __defProp(target, "default", { value: mod, enumerable: true }) : target,
26
- mod
27
- ));
28
- var __toCommonJS = (mod) => __copyProps(__defProp({}, "__esModule", { value: true }), mod);
29
-
30
- // packages/ai-toolkit-nx-claude/src/generators/add-agent/generator.ts
31
- var generator_exports = {};
32
- __export(generator_exports, {
33
- addAgentGenerator: () => addAgentGenerator,
34
- default: () => generator_default
35
- });
36
- module.exports = __toCommonJS(generator_exports);
37
- var import_devkit = require("@nx/devkit");
38
- var path = __toESM(require("path"));
39
-
40
- // packages/ai-toolkit-nx-claude/src/utils/prompt-utils.ts
41
- var import_enquirer = require("enquirer");
42
- var fs = __toESM(require("fs"));
43
- async function promptForMissingOptions(options, schemaPath, context = {}, explicitlyProvidedOptions) {
44
- let schema;
45
- if (typeof schemaPath === "string") {
46
- const schemaContent = fs.readFileSync(schemaPath, "utf-8");
47
- schema = JSON.parse(schemaContent);
48
- } else {
49
- schema = schemaPath;
50
- }
51
- const result = { ...options };
52
- if (result["no-interactive"] || result.noInteractive || result["non-interactive"] || result.nonInteractive) {
53
- for (const [key, property] of Object.entries(schema.properties)) {
54
- if (result[key] === void 0 && property.default !== void 0) {
55
- result[key] = property.default;
56
- }
57
- }
58
- return result;
59
- }
60
- for (const [key, property] of Object.entries(schema.properties)) {
61
- let wasExplicitlyProvided = false;
62
- if (explicitlyProvidedOptions) {
63
- if (explicitlyProvidedOptions instanceof Map) {
64
- wasExplicitlyProvided = explicitlyProvidedOptions.has(key) || explicitlyProvidedOptions.has(key.replace(/-/g, ""));
65
- } else {
66
- wasExplicitlyProvided = explicitlyProvidedOptions.has(key) || explicitlyProvidedOptions.has(key.replace(/-/g, ""));
67
- }
68
- }
69
- if (property["x-skip-prompt"]) {
70
- if (result[key] === void 0 && property.default !== void 0) {
71
- result[key] = property.default;
72
- }
73
- continue;
74
- }
75
- const shouldPrompt = property["always-prompt"] ? (
76
- // For always-prompt fields, only skip if value was explicitly provided
77
- !wasExplicitlyProvided
78
- ) : (
79
- // For regular fields (backward compatibility with x-prompt),
80
- // skip if value exists at all (provided or defaulted)
81
- (result[key] === void 0 || result[key] === null) && !wasExplicitlyProvided
82
- );
83
- if (!shouldPrompt) {
84
- continue;
85
- }
86
- if (key === "confirmLocalPath") {
87
- if (result.installationType !== "local") {
88
- continue;
89
- }
90
- }
91
- if (key === "nonInteractive" || key === "non-interactive" || key === "no-interactive" || key === "noInteractive") {
92
- continue;
93
- }
94
- if (key === "force") {
95
- continue;
96
- }
97
- if (property["prompt-when"]) {
98
- const shouldShow = evaluatePromptCondition(property["prompt-when"], result);
99
- if (!shouldShow) {
100
- continue;
101
- }
102
- }
103
- const promptResult = await promptForProperty(key, property, context, result);
104
- if (promptResult !== void 0) {
105
- result[key] = promptResult;
106
- if (key === "installMode" && promptResult === "default") {
107
- result.installationType = "global";
108
- result.installCommands = true;
109
- result.installAgents = true;
110
- result.installHooks = true;
111
- result.hooksMode = "sound";
112
- result.installAddons = true;
113
- result.dry = false;
114
- result.commandSelectionMode = "all";
115
- result.agentSelectionMode = "all";
116
- result.addonSelectionMode = "all";
117
- if (context.defaultCommands) {
118
- result.commands = context.defaultCommands;
119
- }
120
- if (context.defaultAgents) {
121
- result.agents = context.defaultAgents;
122
- }
123
- if (explicitlyProvidedOptions instanceof Map) {
124
- explicitlyProvidedOptions.set("installMode", "default");
125
- explicitlyProvidedOptions.set("installationType", "global");
126
- explicitlyProvidedOptions.set("installCommands", true);
127
- explicitlyProvidedOptions.set("installAgents", true);
128
- explicitlyProvidedOptions.set("installHooks", true);
129
- explicitlyProvidedOptions.set("hooksMode", "sound");
130
- explicitlyProvidedOptions.set("installAddons", true);
131
- explicitlyProvidedOptions.set("dry", false);
132
- explicitlyProvidedOptions.set("commandSelectionMode", "all");
133
- explicitlyProvidedOptions.set("agentSelectionMode", "all");
134
- explicitlyProvidedOptions.set("addonSelectionMode", "all");
135
- if (context.defaultCommands) {
136
- explicitlyProvidedOptions.set("commands", context.defaultCommands);
137
- }
138
- if (context.defaultAgents) {
139
- explicitlyProvidedOptions.set("agents", context.defaultAgents);
140
- }
141
- }
142
- }
143
- if (key === "confirmLocalPath" && result.installationType === "local" && promptResult === false) {
144
- throw new Error("Installation cancelled - please run from your project root");
145
- }
146
- }
147
- }
148
- return result;
149
- }
150
- async function promptForProperty(key, property, context, currentValues) {
151
- const promptMessage = getPromptMessage(key, property);
152
- const promptType = property["prompt-type"] || (property.type === "boolean" ? "confirm" : property.enum ? "select" : property.type === "string" ? "input" : null);
153
- if (promptType === "confirm" || property.type === "boolean") {
154
- const { value } = await (0, import_enquirer.prompt)({
155
- type: "confirm",
156
- name: "value",
157
- message: promptMessage,
158
- initial: property.default ?? false
159
- });
160
- return value;
161
- }
162
- if (promptType === "list" && property["prompt-items"]) {
163
- const { value } = await (0, import_enquirer.prompt)({
164
- type: "select",
165
- name: "value",
166
- message: promptMessage,
167
- choices: property["prompt-items"].map((item) => ({
168
- name: item.value,
169
- value: item.value,
170
- message: item.label
171
- }))
172
- });
173
- return value;
174
- }
175
- if (property.enum || key === "package" && context.availablePackages) {
176
- const choices = property.enum || context.availablePackages || [];
177
- const { value } = await (0, import_enquirer.prompt)({
178
- type: "select",
179
- name: "value",
180
- message: promptMessage,
181
- choices: choices.map((choice) => {
182
- if (key === "package" && choice === "__create_new__") {
183
- return {
184
- name: "__create_new__",
185
- value: "__create_new__",
186
- message: "\u2795 Create new package"
187
- };
188
- }
189
- if (key === "package") {
190
- return { name: choice, value: choice, message: `\u{1F4E6} ${choice}` };
191
- }
192
- return { name: choice, value: choice };
193
- })
194
- });
195
- return value;
196
- }
197
- if (property.type === "array") {
198
- if (key === "commands" && context.availableCommands) {
199
- const installationType = currentValues?.installationType;
200
- let existingSet;
201
- let otherLocationSet;
202
- if (installationType === "global") {
203
- existingSet = context.globalExistingCommands;
204
- otherLocationSet = context.localExistingCommands;
205
- } else if (installationType === "local") {
206
- existingSet = context.localExistingCommands;
207
- otherLocationSet = context.globalExistingCommands;
208
- }
209
- return await promptMultiSelectWithAll(
210
- promptMessage,
211
- context.availableCommands,
212
- "commands",
213
- context.commandDescriptions,
214
- existingSet,
215
- otherLocationSet,
216
- installationType
217
- );
218
- }
219
- if (key === "agents" && context.availableAgents) {
220
- const installationType = currentValues?.installationType;
221
- let existingSet;
222
- let otherLocationSet;
223
- if (installationType === "global") {
224
- existingSet = context.globalExistingAgents;
225
- otherLocationSet = context.localExistingAgents;
226
- } else if (installationType === "local") {
227
- existingSet = context.localExistingAgents;
228
- otherLocationSet = context.globalExistingAgents;
229
- }
230
- return await promptMultiSelectWithAll(
231
- promptMessage,
232
- context.availableAgents,
233
- "agents",
234
- context.agentDescriptions,
235
- existingSet,
236
- otherLocationSet,
237
- installationType
238
- );
239
- }
240
- if (key === "skills" && context.availableSkills) {
241
- const installationType = currentValues?.installationType;
242
- let existingSet;
243
- let otherLocationSet;
244
- if (installationType === "global") {
245
- existingSet = context.globalExistingSkills;
246
- otherLocationSet = context.localExistingSkills;
247
- } else if (installationType === "local") {
248
- existingSet = context.localExistingSkills;
249
- otherLocationSet = context.globalExistingSkills;
250
- }
251
- return await promptMultiSelectWithAll(
252
- promptMessage,
253
- context.availableSkills,
254
- "skills",
255
- context.skillDescriptions,
256
- existingSet,
257
- otherLocationSet,
258
- installationType
259
- );
260
- }
261
- if (key === "addons" && context.availableAddons) {
262
- return await promptMultiSelectWithAll(
263
- promptMessage,
264
- context.availableAddons,
265
- "addons",
266
- context.addonDescriptions,
267
- void 0,
268
- // No existing set for addons
269
- void 0,
270
- // No other location set for addons
271
- void 0
272
- // No installation type for addons
273
- );
274
- }
275
- return [];
276
- }
277
- if (property.type === "string") {
278
- if (key === "targetPath") {
279
- const { value: value2 } = await (0, import_enquirer.prompt)({
280
- type: "input",
281
- name: "value",
282
- message: promptMessage,
283
- initial: process.cwd()
284
- });
285
- return value2;
286
- }
287
- const { value } = await (0, import_enquirer.prompt)({
288
- type: "input",
289
- name: "value",
290
- message: promptMessage,
291
- initial: property.default ?? ""
292
- });
293
- return value;
294
- }
295
- return void 0;
296
- }
297
- async function promptMultiSelectWithAll(message, choices, type, descriptions, existingItems, otherLocationItems, installationType) {
298
- const displayChoices = choices.map((choice) => {
299
- let display = descriptions?.[choice] ? `${choice}: ${descriptions[choice]}` : choice;
300
- const indicators = [];
301
- if (existingItems?.has(choice)) {
302
- indicators.push("will overwrite");
303
- }
304
- if (otherLocationItems?.has(choice)) {
305
- const otherLocation = installationType === "global" ? "locally" : "globally";
306
- indicators.push(`exists ${otherLocation}`);
307
- }
308
- if (indicators.length > 0) {
309
- display += ` (${indicators.join(", ")})`;
310
- }
311
- return display;
312
- });
313
- const response = await (0, import_enquirer.prompt)({
314
- type: "multiselect",
315
- name: "selected",
316
- message,
317
- choices: displayChoices,
318
- initial: displayChoices.map((_, index) => index),
319
- // Select all by default
320
- hint: "Use <space> to select, <a> to toggle all, <return> to submit",
321
- validate: (value) => {
322
- if (value.length === 0) {
323
- return `Please select at least one ${type.slice(0, -1)}`;
324
- }
325
- return true;
326
- }
327
- });
328
- const selected = response.selected || [];
329
- const actualSelections = [];
330
- for (const selection of selected) {
331
- const colonIndex = selection.indexOf(":");
332
- const parenIndex = selection.indexOf("(");
333
- let endIndex = selection.length;
334
- if (colonIndex > -1 && (parenIndex === -1 || colonIndex < parenIndex)) {
335
- endIndex = colonIndex;
336
- } else if (parenIndex > -1 && (colonIndex === -1 || parenIndex < colonIndex)) {
337
- endIndex = parenIndex;
338
- }
339
- const name = selection.substring(0, endIndex).trim();
340
- if (name && !actualSelections.includes(name)) {
341
- actualSelections.push(name);
342
- }
343
- }
344
- return actualSelections;
345
- }
346
- function getPromptMessage(key, property) {
347
- if (property["prompt-message"]) {
348
- return property["prompt-message"];
349
- }
350
- if (property["x-prompt"]) {
351
- if (typeof property["x-prompt"] === "string") {
352
- return property["x-prompt"];
353
- }
354
- if (property["x-prompt"].message) {
355
- return property["x-prompt"].message;
356
- }
357
- }
358
- const description = property.description || "";
359
- switch (key) {
360
- case "installationType":
361
- return "Would you like to install agents and commands globally or locally?";
362
- case "confirmLocalPath":
363
- return "Are you running this from the root of your project?";
364
- case "commands":
365
- return "Select commands to install (use <space> to select, <a> to toggle all):";
366
- case "agents":
367
- return "Select agents to install (use <space> to select, <a> to toggle all):";
368
- case "force":
369
- return "Overwrite existing installation?";
370
- default:
371
- return description || `Enter value for ${key}:`;
372
- }
373
- }
374
- function evaluatePromptCondition(condition, context) {
375
- if (condition.includes(" && ")) {
376
- const parts = condition.split(" && ");
377
- return parts.every((part) => evaluateSingleCondition(part.trim(), context));
378
- }
379
- if (condition.includes(" || ")) {
380
- const parts = condition.split(" || ");
381
- return parts.some((part) => evaluateSingleCondition(part.trim(), context));
382
- }
383
- return evaluateSingleCondition(condition, context);
384
- }
385
- function evaluateSingleCondition(condition, context) {
386
- const parts = condition.split(" ");
387
- if (parts.length < 3) {
388
- return false;
389
- }
390
- const field = parts[0];
391
- const operator = parts[1];
392
- const value = parts.slice(2).join(" ").replace(/['"]/g, "");
393
- const fieldValue = context[field];
394
- switch (operator) {
395
- case "===":
396
- if (value === "true") {
397
- return fieldValue === true;
398
- }
399
- if (value === "false") {
400
- return fieldValue === false;
401
- }
402
- return String(fieldValue) === value;
403
- case "!==":
404
- if (value === "true") {
405
- return fieldValue !== true;
406
- }
407
- if (value === "false") {
408
- return fieldValue !== false;
409
- }
410
- return String(fieldValue) !== value;
411
- default:
412
- return false;
413
- }
414
- }
415
-
416
- // packages/ai-toolkit-nx-claude/src/generators/add-agent/generator.ts
417
- var import_js = require("@nx/js");
418
- async function addAgentGenerator(tree, options) {
419
- console.log("\u{1F916} Add Agent Generator");
420
- const agentPackages = discoverAgentPackages(tree);
421
- const packageChoices = [...agentPackages, "__create_new__"];
422
- const schemaPath = path.join(__dirname, "schema.json");
423
- const context = {
424
- availablePackages: packageChoices
425
- };
426
- if (options["no-interactive"] || options.noInteractive) {
427
- if (!options.package && agentPackages.length > 0) {
428
- options.package = agentPackages[0];
429
- }
430
- }
431
- const normalizedOptions = await promptForMissingOptions(
432
- options,
433
- schemaPath,
434
- context
435
- );
436
- let targetPackage;
437
- if (normalizedOptions.package === "__create_new__" || normalizedOptions.createNewPackage) {
438
- if (!normalizedOptions.newPackageName) {
439
- throw new Error("New package name is required");
440
- }
441
- targetPackage = normalizedOptions.newPackageName;
442
- console.log(`
443
- \u{1F4E6} Creating new agents package: agents-${targetPackage}`);
444
- await (0, import_js.libraryGenerator)(tree, {
445
- name: `agents-${targetPackage}`,
446
- directory: `packages/agents/${targetPackage}`,
447
- bundler: "tsc",
448
- linter: "eslint",
449
- unitTestRunner: "jest",
450
- testEnvironment: "node",
451
- skipFormat: true,
452
- skipTsConfig: false,
453
- strict: true,
454
- publishable: true,
455
- importPath: `@ai-toolkit/agents-${targetPackage}`
456
- });
457
- const packageJson = {
458
- name: `@ai-toolkit/agents-${targetPackage}`,
459
- version: "0.0.1",
460
- description: normalizedOptions.newPackageDescription || `Agent configurations for ${targetPackage}`,
461
- main: "dist/index.js",
462
- types: "dist/index.d.ts",
463
- scripts: {
464
- build: "tsc",
465
- "generate-index": "tsx scripts/generate.ts"
466
- },
467
- dependencies: {
468
- "@ai-toolkit/utils": "*"
469
- },
470
- devDependencies: {
471
- tsx: "^4.7.0",
472
- typescript: "^5.3.3"
473
- }
474
- };
475
- tree.write(
476
- (0, import_devkit.joinPathFragments)("packages", "agents", targetPackage, "package.json"),
477
- JSON.stringify(packageJson, null, 2)
478
- );
479
- const generateScript = `import { generateIndex } from '@ai-toolkit/utils';
480
- import * as path from 'path';
481
-
482
- generateIndex({
483
- sourceDir: path.join(__dirname, '../src'),
484
- outputFile: path.join(__dirname, '../src/index.ts'),
485
- type: 'agents',
486
- });`;
487
- tree.write(
488
- (0, import_devkit.joinPathFragments)(
489
- "packages",
490
- "agents",
491
- targetPackage,
492
- "scripts",
493
- "generate.ts"
494
- ),
495
- generateScript
496
- );
497
- const readme = `# @ai-toolkit/agents-${targetPackage}
498
-
499
- ${normalizedOptions.newPackageDescription || `Agent configurations for ${targetPackage}`}
500
-
501
- ## Overview
502
-
503
- This package contains agent configurations specific to ${targetPackage}.
504
-
505
- ## Usage
506
-
507
- Install this package to access ${targetPackage}-specific agents in Claude Code:
508
-
509
- \`\`\`bash
510
- npx nx generate @uniswap/ai-toolkit-nx-claude:init
511
- \`\`\`
512
-
513
- Then select the agents from this package during the installation process.
514
-
515
- ## Available Agents
516
-
517
- - \`${normalizedOptions.name}\`: ${normalizedOptions.description || "Description pending"}
518
-
519
- ## Development
520
-
521
- To add new agents to this package:
522
-
523
- \`\`\`bash
524
- npx nx generate @uniswap/ai-toolkit-nx-claude:add-agent
525
- \`\`\`
526
-
527
- After adding or modifying agents, regenerate the index:
528
-
529
- \`\`\`bash
530
- npx nx run @ai-toolkit/agents-${targetPackage}:generate-index
531
- \`\`\``;
532
- tree.write(
533
- (0, import_devkit.joinPathFragments)("packages", "agents", targetPackage, "README.md"),
534
- readme
535
- );
536
- } else {
537
- targetPackage = normalizedOptions.package.replace("agents-", "");
538
- }
539
- const agentFileName = `${normalizedOptions.name}.md`;
540
- const agentPath = (0, import_devkit.joinPathFragments)(
541
- "packages",
542
- "agents",
543
- targetPackage,
544
- "src"
545
- );
546
- if (tree.exists((0, import_devkit.joinPathFragments)(agentPath, agentFileName))) {
547
- const overwrite = await promptForOverwrite(normalizedOptions.name);
548
- if (!overwrite) {
549
- console.log("\u274C Agent creation cancelled");
550
- return;
551
- }
552
- }
553
- (0, import_devkit.generateFiles)(tree, path.join(__dirname, "files"), agentPath, {
554
- ...normalizedOptions,
555
- name: normalizedOptions.name,
556
- description: normalizedOptions.description || `${normalizedOptions.name} agent`,
557
- model: normalizedOptions.model,
558
- template: ""
559
- });
560
- await (0, import_devkit.formatFiles)(tree);
561
- console.log(`
562
- \u2705 Agent file created at: ${agentPath}/${agentFileName}`);
563
- console.log("\n\u{1F4DD} Next steps:");
564
- console.log(
565
- `1. Edit ${agentPath}/${agentFileName} and add your agent instructions`
566
- );
567
- console.log(
568
- "\n\u{1F4A1} The agent file has TODO markers for you to fill in with your specific instructions."
569
- );
570
- const { spawn } = await import("child_process");
571
- const runGenerateIndexTask = (tree2) => {
572
- return () => {
573
- console.log(`
574
- \u{1F504} Updating package index...`);
575
- return new Promise((resolve) => {
576
- const child = spawn(
577
- "npx",
578
- ["nx", "run", `@ai-toolkit/agents-${targetPackage}:generate-index`],
579
- {
580
- stdio: "inherit",
581
- shell: true,
582
- cwd: tree2.root
583
- }
584
- );
585
- child.on("close", (code) => {
586
- if (code === 0) {
587
- console.log(`\u2705 Package index updated successfully`);
588
- resolve();
589
- } else {
590
- console.warn(
591
- `\u26A0\uFE0F Failed to update package index. You may need to run manually:`
592
- );
593
- console.warn(
594
- ` npx nx run @ai-toolkit/agents-${targetPackage}:generate-index`
595
- );
596
- resolve();
597
- }
598
- });
599
- child.on("error", (error) => {
600
- console.warn(`\u26A0\uFE0F Failed to update package index: ${error.message}`);
601
- console.warn(
602
- ` Run manually: npx nx run @ai-toolkit/agents-${targetPackage}:generate-index`
603
- );
604
- resolve();
605
- });
606
- });
607
- };
608
- };
609
- return runGenerateIndexTask(tree);
610
- }
611
- function discoverAgentPackages(tree) {
612
- const packages = [];
613
- const agentsDir = (0, import_devkit.joinPathFragments)("packages", "agents");
614
- if (!tree.exists(agentsDir)) {
615
- return packages;
616
- }
617
- const children = tree.children(agentsDir);
618
- for (const child of children) {
619
- const packagePath = (0, import_devkit.joinPathFragments)(agentsDir, child);
620
- if (tree.exists((0, import_devkit.joinPathFragments)(packagePath, "package.json"))) {
621
- packages.push(`agents-${child}`);
622
- }
623
- }
624
- return packages;
625
- }
626
- async function promptForOverwrite(name) {
627
- const { prompt: prompt2 } = await import("enquirer");
628
- const response = await prompt2({
629
- type: "confirm",
630
- name: "overwrite",
631
- message: `\u26A0\uFE0F Agent "${name}" already exists. Overwrite?`,
632
- initial: false
633
- });
634
- return response.overwrite;
635
- }
636
- var generator_default = addAgentGenerator;
637
- // Annotate the CommonJS export names for ESM import in node:
638
- 0 && (module.exports = {
639
- addAgentGenerator
640
- });
@@ -1,59 +0,0 @@
1
- {
2
- "$schema": "https://json-schema.org/schema",
3
- "$id": "AddAgent",
4
- "title": "Add Agent Generator",
5
- "type": "object",
6
- "properties": {
7
- "package": {
8
- "type": "string",
9
- "description": "Target package for the agent",
10
- "prompt-message": "📦 Which package should this agent be added to?"
11
- },
12
- "createNewPackage": {
13
- "type": "boolean",
14
- "description": "Create a new package for this agent",
15
- "default": false,
16
- "prompt-message": "➕ Would you like to create a new package instead?",
17
- "prompt-type": "confirm",
18
- "prompt-when": "package === '__create_new__'"
19
- },
20
- "newPackageName": {
21
- "type": "string",
22
- "description": "Name of the new package (e.g., backend, frontend, typescript)",
23
- "prompt-message": "📝 Enter the name for the new package (e.g., backend, frontend, typescript):",
24
- "prompt-when": "createNewPackage === true",
25
- "pattern": "^[a-z][a-z0-9-]*$"
26
- },
27
- "newPackageDescription": {
28
- "type": "string",
29
- "description": "Description of the new package",
30
- "prompt-message": "📄 Enter a description for the new package:",
31
- "prompt-when": "createNewPackage === true"
32
- },
33
- "name": {
34
- "type": "string",
35
- "description": "Name of the agent file (without extension)",
36
- "$default": {
37
- "$source": "argv",
38
- "index": 0
39
- },
40
- "prompt-message": "🤖 What should the agent be called? (kebab-case, e.g., code-reviewer):",
41
- "pattern": "^[a-z][a-z0-9-]*$"
42
- },
43
- "description": {
44
- "type": "string",
45
- "description": "Brief description of what the agent does",
46
- "prompt-message": "💬 Brief description of what this agent does:"
47
- },
48
- "model": {
49
- "type": "string",
50
- "description": "The AI model to use for this agent",
51
- "enum": ["sonnet-4.5", "opus-4.1", "haiku-4.5"],
52
- "x-prompt": {
53
- "message": "🧠 Which AI model should this agent use?",
54
- "type": "list"
55
- }
56
- }
57
- },
58
- "required": []
59
- }