@uniswap/ai-toolkit-nx-claude 0.5.29 → 0.5.30-next.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/dist/cli-generator.cjs +28 -59
- package/dist/packages/ai-toolkit-nx-claude/src/cli-generator.d.ts +8 -10
- package/dist/packages/ai-toolkit-nx-claude/src/cli-generator.d.ts.map +1 -1
- package/dist/packages/ai-toolkit-nx-claude/src/index.d.ts +0 -1
- package/dist/packages/ai-toolkit-nx-claude/src/index.d.ts.map +1 -1
- package/generators.json +0 -15
- package/package.json +4 -35
- package/dist/content/agents/agnostic/CLAUDE.md +0 -282
- package/dist/content/agents/agnostic/agent-capability-analyst.md +0 -575
- package/dist/content/agents/agnostic/agent-optimizer.md +0 -396
- package/dist/content/agents/agnostic/agent-orchestrator.md +0 -475
- package/dist/content/agents/agnostic/cicd-agent.md +0 -301
- package/dist/content/agents/agnostic/claude-agent-discovery.md +0 -304
- package/dist/content/agents/agnostic/claude-docs-fact-checker.md +0 -435
- package/dist/content/agents/agnostic/claude-docs-initializer.md +0 -782
- package/dist/content/agents/agnostic/claude-docs-manager.md +0 -595
- package/dist/content/agents/agnostic/code-explainer.md +0 -269
- package/dist/content/agents/agnostic/code-generator.md +0 -785
- package/dist/content/agents/agnostic/commit-message-generator.md +0 -101
- package/dist/content/agents/agnostic/context-loader.md +0 -432
- package/dist/content/agents/agnostic/debug-assistant.md +0 -321
- package/dist/content/agents/agnostic/doc-writer.md +0 -536
- package/dist/content/agents/agnostic/feedback-collector.md +0 -165
- package/dist/content/agents/agnostic/infrastructure-agent.md +0 -406
- package/dist/content/agents/agnostic/migration-assistant.md +0 -489
- package/dist/content/agents/agnostic/pattern-learner.md +0 -481
- package/dist/content/agents/agnostic/performance-analyzer.md +0 -528
- package/dist/content/agents/agnostic/plan-reviewer.md +0 -173
- package/dist/content/agents/agnostic/planner.md +0 -235
- package/dist/content/agents/agnostic/pr-creator.md +0 -498
- package/dist/content/agents/agnostic/pr-reviewer.md +0 -142
- package/dist/content/agents/agnostic/prompt-engineer.md +0 -541
- package/dist/content/agents/agnostic/refactorer.md +0 -311
- package/dist/content/agents/agnostic/researcher.md +0 -349
- package/dist/content/agents/agnostic/security-analyzer.md +0 -1087
- package/dist/content/agents/agnostic/stack-splitter.md +0 -642
- package/dist/content/agents/agnostic/style-enforcer.md +0 -568
- package/dist/content/agents/agnostic/test-runner.md +0 -481
- package/dist/content/agents/agnostic/test-writer.md +0 -292
- package/dist/content/commands/agnostic/CLAUDE.md +0 -207
- package/dist/content/commands/agnostic/address-pr-issues.md +0 -205
- package/dist/content/commands/agnostic/auto-spec.md +0 -386
- package/dist/content/commands/agnostic/claude-docs.md +0 -409
- package/dist/content/commands/agnostic/claude-init-plus.md +0 -439
- package/dist/content/commands/agnostic/create-pr.md +0 -79
- package/dist/content/commands/agnostic/daily-standup.md +0 -185
- package/dist/content/commands/agnostic/deploy.md +0 -441
- package/dist/content/commands/agnostic/execute-plan.md +0 -167
- package/dist/content/commands/agnostic/explain-file.md +0 -303
- package/dist/content/commands/agnostic/explore.md +0 -82
- package/dist/content/commands/agnostic/fix-bug.md +0 -273
- package/dist/content/commands/agnostic/gen-tests.md +0 -185
- package/dist/content/commands/agnostic/generate-commit-message.md +0 -92
- package/dist/content/commands/agnostic/git-worktree-orchestrator.md +0 -647
- package/dist/content/commands/agnostic/implement-spec.md +0 -270
- package/dist/content/commands/agnostic/monitor.md +0 -581
- package/dist/content/commands/agnostic/perf-analyze.md +0 -214
- package/dist/content/commands/agnostic/plan.md +0 -453
- package/dist/content/commands/agnostic/refactor.md +0 -315
- package/dist/content/commands/agnostic/refine-linear-task.md +0 -575
- package/dist/content/commands/agnostic/research.md +0 -49
- package/dist/content/commands/agnostic/review-code.md +0 -321
- package/dist/content/commands/agnostic/review-plan.md +0 -109
- package/dist/content/commands/agnostic/review-pr.md +0 -393
- package/dist/content/commands/agnostic/split-stack.md +0 -705
- package/dist/content/commands/agnostic/update-claude-md.md +0 -401
- package/dist/content/commands/agnostic/work-through-pr-comments.md +0 -873
- package/dist/generators/add-agent/CLAUDE.md +0 -130
- package/dist/generators/add-agent/files/__name__.md.template +0 -37
- package/dist/generators/add-agent/generator.cjs +0 -640
- package/dist/generators/add-agent/schema.json +0 -59
- package/dist/generators/add-command/CLAUDE.md +0 -131
- package/dist/generators/add-command/files/__name__.md.template +0 -46
- package/dist/generators/add-command/generator.cjs +0 -643
- package/dist/generators/add-command/schema.json +0 -50
- package/dist/generators/files/src/index.ts.template +0 -1
- package/dist/generators/init/CLAUDE.md +0 -520
- package/dist/generators/init/generator.cjs +0 -3304
- package/dist/generators/init/schema.json +0 -180
- package/dist/packages/ai-toolkit-nx-claude/src/generators/add-agent/generator.d.ts +0 -5
- package/dist/packages/ai-toolkit-nx-claude/src/generators/add-agent/generator.d.ts.map +0 -1
- package/dist/packages/ai-toolkit-nx-claude/src/generators/add-command/generator.d.ts +0 -5
- package/dist/packages/ai-toolkit-nx-claude/src/generators/add-command/generator.d.ts.map +0 -1
- package/dist/packages/ai-toolkit-nx-claude/src/generators/init/generator.d.ts +0 -5
- package/dist/packages/ai-toolkit-nx-claude/src/generators/init/generator.d.ts.map +0 -1
- package/dist/packages/ai-toolkit-nx-claude/src/utils/auto-update-utils.d.ts +0 -30
- package/dist/packages/ai-toolkit-nx-claude/src/utils/auto-update-utils.d.ts.map +0 -1
|
@@ -1,643 +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-command/generator.ts
|
|
31
|
-
var generator_exports = {};
|
|
32
|
-
__export(generator_exports, {
|
|
33
|
-
addCommandGenerator: () => addCommandGenerator,
|
|
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-command/generator.ts
|
|
417
|
-
var import_js = require("@nx/js");
|
|
418
|
-
async function addCommandGenerator(tree, options) {
|
|
419
|
-
console.log("\u26A1 Add Command Generator");
|
|
420
|
-
const commandPackages = discoverCommandPackages(tree);
|
|
421
|
-
const packageChoices = [...commandPackages, "__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 && commandPackages.length > 0) {
|
|
428
|
-
options.package = commandPackages[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
|
-
`
|
|
444
|
-
\u{1F4E6} Creating new commands package: commands-${targetPackage}`
|
|
445
|
-
);
|
|
446
|
-
await (0, import_js.libraryGenerator)(tree, {
|
|
447
|
-
name: `commands-${targetPackage}`,
|
|
448
|
-
directory: `packages/commands/${targetPackage}`,
|
|
449
|
-
bundler: "tsc",
|
|
450
|
-
linter: "eslint",
|
|
451
|
-
unitTestRunner: "jest",
|
|
452
|
-
testEnvironment: "node",
|
|
453
|
-
skipFormat: true,
|
|
454
|
-
skipTsConfig: false,
|
|
455
|
-
strict: true,
|
|
456
|
-
publishable: true,
|
|
457
|
-
importPath: `@ai-toolkit/commands-${targetPackage}`
|
|
458
|
-
});
|
|
459
|
-
const packageJson = {
|
|
460
|
-
name: `@ai-toolkit/commands-${targetPackage}`,
|
|
461
|
-
version: "0.0.1",
|
|
462
|
-
description: normalizedOptions.newPackageDescription || `Command configurations for ${targetPackage}`,
|
|
463
|
-
main: "dist/index.js",
|
|
464
|
-
types: "dist/index.d.ts",
|
|
465
|
-
scripts: {
|
|
466
|
-
build: "tsc",
|
|
467
|
-
"generate-index": "tsx scripts/generate.ts"
|
|
468
|
-
},
|
|
469
|
-
dependencies: {
|
|
470
|
-
"@ai-toolkit/utils": "*"
|
|
471
|
-
},
|
|
472
|
-
devDependencies: {
|
|
473
|
-
tsx: "^4.7.0",
|
|
474
|
-
typescript: "^5.3.3"
|
|
475
|
-
}
|
|
476
|
-
};
|
|
477
|
-
tree.write(
|
|
478
|
-
(0, import_devkit.joinPathFragments)("packages", "commands", targetPackage, "package.json"),
|
|
479
|
-
JSON.stringify(packageJson, null, 2)
|
|
480
|
-
);
|
|
481
|
-
const generateScript = `import { generateIndex } from '@ai-toolkit/utils';
|
|
482
|
-
import * as path from 'path';
|
|
483
|
-
|
|
484
|
-
generateIndex({
|
|
485
|
-
sourceDir: path.join(__dirname, '../src'),
|
|
486
|
-
outputFile: path.join(__dirname, '../src/index.ts'),
|
|
487
|
-
type: 'commands',
|
|
488
|
-
});`;
|
|
489
|
-
tree.write(
|
|
490
|
-
(0, import_devkit.joinPathFragments)(
|
|
491
|
-
"packages",
|
|
492
|
-
"commands",
|
|
493
|
-
targetPackage,
|
|
494
|
-
"scripts",
|
|
495
|
-
"generate.ts"
|
|
496
|
-
),
|
|
497
|
-
generateScript
|
|
498
|
-
);
|
|
499
|
-
const readme = `# @ai-toolkit/commands-${targetPackage}
|
|
500
|
-
|
|
501
|
-
${normalizedOptions.newPackageDescription || `Command configurations for ${targetPackage}`}
|
|
502
|
-
|
|
503
|
-
## Overview
|
|
504
|
-
|
|
505
|
-
This package contains command configurations specific to ${targetPackage}.
|
|
506
|
-
|
|
507
|
-
## Usage
|
|
508
|
-
|
|
509
|
-
Install this package to access ${targetPackage}-specific commands in Claude Code:
|
|
510
|
-
|
|
511
|
-
\`\`\`bash
|
|
512
|
-
npx nx generate @uniswap/ai-toolkit-nx-claude:init
|
|
513
|
-
\`\`\`
|
|
514
|
-
|
|
515
|
-
Then select the commands from this package during the installation process.
|
|
516
|
-
|
|
517
|
-
## Available Commands
|
|
518
|
-
|
|
519
|
-
- \`${normalizedOptions.name}\`: ${normalizedOptions.description || "Description pending"}
|
|
520
|
-
|
|
521
|
-
## Development
|
|
522
|
-
|
|
523
|
-
To add new commands to this package:
|
|
524
|
-
|
|
525
|
-
\`\`\`bash
|
|
526
|
-
npx nx generate @uniswap/ai-toolkit-nx-claude:add-command
|
|
527
|
-
\`\`\`
|
|
528
|
-
|
|
529
|
-
After adding or modifying commands, regenerate the index:
|
|
530
|
-
|
|
531
|
-
\`\`\`bash
|
|
532
|
-
npx nx run @ai-toolkit/commands-${targetPackage}:generate-index
|
|
533
|
-
\`\`\``;
|
|
534
|
-
tree.write(
|
|
535
|
-
(0, import_devkit.joinPathFragments)("packages", "commands", targetPackage, "README.md"),
|
|
536
|
-
readme
|
|
537
|
-
);
|
|
538
|
-
} else {
|
|
539
|
-
targetPackage = normalizedOptions.package.replace("commands-", "");
|
|
540
|
-
}
|
|
541
|
-
const commandFileName = `${normalizedOptions.name}.md`;
|
|
542
|
-
const commandPath = (0, import_devkit.joinPathFragments)(
|
|
543
|
-
"packages",
|
|
544
|
-
"commands",
|
|
545
|
-
targetPackage,
|
|
546
|
-
"src"
|
|
547
|
-
);
|
|
548
|
-
if (tree.exists((0, import_devkit.joinPathFragments)(commandPath, commandFileName))) {
|
|
549
|
-
const overwrite = await promptForOverwrite(normalizedOptions.name);
|
|
550
|
-
if (!overwrite) {
|
|
551
|
-
console.log("\u274C Command creation cancelled");
|
|
552
|
-
return;
|
|
553
|
-
}
|
|
554
|
-
}
|
|
555
|
-
(0, import_devkit.generateFiles)(tree, path.join(__dirname, "files"), commandPath, {
|
|
556
|
-
...normalizedOptions,
|
|
557
|
-
name: normalizedOptions.name,
|
|
558
|
-
description: normalizedOptions.description || `${normalizedOptions.name} command`,
|
|
559
|
-
template: ""
|
|
560
|
-
});
|
|
561
|
-
await (0, import_devkit.formatFiles)(tree);
|
|
562
|
-
console.log(
|
|
563
|
-
`
|
|
564
|
-
\u2705 Command file created at: ${commandPath}/${commandFileName}`
|
|
565
|
-
);
|
|
566
|
-
console.log("\n\u{1F4DD} Next steps:");
|
|
567
|
-
console.log(
|
|
568
|
-
`1. Edit ${commandPath}/${commandFileName} and add your command instructions`
|
|
569
|
-
);
|
|
570
|
-
console.log(
|
|
571
|
-
"\n\u{1F4A1} The command file has TODO markers for you to fill in with your specific instructions."
|
|
572
|
-
);
|
|
573
|
-
const { spawn } = await import("child_process");
|
|
574
|
-
const runGenerateIndexTask = (tree2) => {
|
|
575
|
-
return () => {
|
|
576
|
-
console.log(`
|
|
577
|
-
\u{1F504} Updating package index...`);
|
|
578
|
-
return new Promise((resolve) => {
|
|
579
|
-
const child = spawn(
|
|
580
|
-
"npx",
|
|
581
|
-
["nx", "run", `@ai-toolkit/commands-${targetPackage}:generate-index`],
|
|
582
|
-
{
|
|
583
|
-
stdio: "inherit",
|
|
584
|
-
shell: true,
|
|
585
|
-
cwd: tree2.root
|
|
586
|
-
}
|
|
587
|
-
);
|
|
588
|
-
child.on("close", (code) => {
|
|
589
|
-
if (code === 0) {
|
|
590
|
-
console.log(`\u2705 Package index updated successfully`);
|
|
591
|
-
resolve();
|
|
592
|
-
} else {
|
|
593
|
-
console.warn(
|
|
594
|
-
`\u26A0\uFE0F Failed to update package index. You may need to run manually:`
|
|
595
|
-
);
|
|
596
|
-
console.warn(
|
|
597
|
-
` npx nx run @ai-toolkit/commands-${targetPackage}:generate-index`
|
|
598
|
-
);
|
|
599
|
-
resolve();
|
|
600
|
-
}
|
|
601
|
-
});
|
|
602
|
-
child.on("error", (error) => {
|
|
603
|
-
console.warn(`\u26A0\uFE0F Failed to update package index: ${error.message}`);
|
|
604
|
-
console.warn(
|
|
605
|
-
` Run manually: npx nx run @ai-toolkit/commands-${targetPackage}:generate-index`
|
|
606
|
-
);
|
|
607
|
-
resolve();
|
|
608
|
-
});
|
|
609
|
-
});
|
|
610
|
-
};
|
|
611
|
-
};
|
|
612
|
-
return runGenerateIndexTask(tree);
|
|
613
|
-
}
|
|
614
|
-
function discoverCommandPackages(tree) {
|
|
615
|
-
const packages = [];
|
|
616
|
-
const commandsDir = (0, import_devkit.joinPathFragments)("packages", "commands");
|
|
617
|
-
if (!tree.exists(commandsDir)) {
|
|
618
|
-
return packages;
|
|
619
|
-
}
|
|
620
|
-
const children = tree.children(commandsDir);
|
|
621
|
-
for (const child of children) {
|
|
622
|
-
const packagePath = (0, import_devkit.joinPathFragments)(commandsDir, child);
|
|
623
|
-
if (tree.exists((0, import_devkit.joinPathFragments)(packagePath, "package.json"))) {
|
|
624
|
-
packages.push(`commands-${child}`);
|
|
625
|
-
}
|
|
626
|
-
}
|
|
627
|
-
return packages;
|
|
628
|
-
}
|
|
629
|
-
async function promptForOverwrite(name) {
|
|
630
|
-
const { prompt: prompt2 } = await import("enquirer");
|
|
631
|
-
const response = await prompt2({
|
|
632
|
-
type: "confirm",
|
|
633
|
-
name: "overwrite",
|
|
634
|
-
message: `\u26A0\uFE0F Command "${name}" already exists. Overwrite?`,
|
|
635
|
-
initial: false
|
|
636
|
-
});
|
|
637
|
-
return response.overwrite;
|
|
638
|
-
}
|
|
639
|
-
var generator_default = addCommandGenerator;
|
|
640
|
-
// Annotate the CommonJS export names for ESM import in node:
|
|
641
|
-
0 && (module.exports = {
|
|
642
|
-
addCommandGenerator
|
|
643
|
-
});
|
|
@@ -1,50 +0,0 @@
|
|
|
1
|
-
{
|
|
2
|
-
"$schema": "https://json-schema.org/schema",
|
|
3
|
-
"$id": "AddCommand",
|
|
4
|
-
"title": "Add Command Generator",
|
|
5
|
-
"type": "object",
|
|
6
|
-
"properties": {
|
|
7
|
-
"package": {
|
|
8
|
-
"type": "string",
|
|
9
|
-
"description": "Target package for the command",
|
|
10
|
-
"prompt-message": "📦 Which package should this command be added to?"
|
|
11
|
-
},
|
|
12
|
-
"createNewPackage": {
|
|
13
|
-
"type": "boolean",
|
|
14
|
-
"description": "Create a new package for this command",
|
|
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 command file (without extension)",
|
|
36
|
-
"$default": {
|
|
37
|
-
"$source": "argv",
|
|
38
|
-
"index": 0
|
|
39
|
-
},
|
|
40
|
-
"prompt-message": "⚡ What should the command be called? (kebab-case, e.g., refactor-code):",
|
|
41
|
-
"pattern": "^[a-z][a-z0-9-]*$"
|
|
42
|
-
},
|
|
43
|
-
"description": {
|
|
44
|
-
"type": "string",
|
|
45
|
-
"description": "Brief description of what the command does",
|
|
46
|
-
"prompt-message": "💬 Brief description of what this command does:"
|
|
47
|
-
}
|
|
48
|
-
},
|
|
49
|
-
"required": []
|
|
50
|
-
}
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
const variable = "<%= name %>";
|