@codedrifters/configulator 0.0.153 → 0.0.154
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/lib/index.d.mts +681 -11
- package/lib/index.d.ts +673 -3
- package/lib/index.js +658 -26
- package/lib/index.js.map +1 -1
- package/lib/index.mjs +651 -26
- package/lib/index.mjs.map +1 -1
- package/package.json +1 -1
package/lib/index.mjs
CHANGED
|
@@ -172,14 +172,632 @@ var require_lib = __commonJS({
|
|
|
172
172
|
}
|
|
173
173
|
});
|
|
174
174
|
|
|
175
|
+
// src/agent/agent-config.ts
|
|
176
|
+
import { Component as Component3 } from "projen";
|
|
177
|
+
|
|
178
|
+
// src/agent/bundles/index.ts
|
|
179
|
+
var BUILT_IN_BUNDLES = [];
|
|
180
|
+
|
|
181
|
+
// src/agent/renderers/claude-renderer.ts
|
|
182
|
+
import { JsonFile } from "projen";
|
|
183
|
+
import { TextFile } from "projen/lib/textfile";
|
|
184
|
+
|
|
185
|
+
// src/agent/types.ts
|
|
186
|
+
var AGENT_RULE_SCOPE = {
|
|
187
|
+
ALWAYS: "always",
|
|
188
|
+
FILE_PATTERN: "file-pattern"
|
|
189
|
+
};
|
|
190
|
+
var AGENT_PLATFORM = {
|
|
191
|
+
CURSOR: "cursor",
|
|
192
|
+
CLAUDE: "claude",
|
|
193
|
+
CODEX: "codex",
|
|
194
|
+
COPILOT: "copilot"
|
|
195
|
+
};
|
|
196
|
+
var CLAUDE_RULE_TARGET = {
|
|
197
|
+
SCOPED_FILE: "scoped-file",
|
|
198
|
+
AGENTS_MD: "agents-md",
|
|
199
|
+
CLAUDE_MD: "claude-md"
|
|
200
|
+
};
|
|
201
|
+
var AGENT_MODEL = {
|
|
202
|
+
INHERIT: "inherit",
|
|
203
|
+
FAST: "fast",
|
|
204
|
+
BALANCED: "balanced",
|
|
205
|
+
POWERFUL: "powerful"
|
|
206
|
+
};
|
|
207
|
+
var MCP_TRANSPORT = {
|
|
208
|
+
STDIO: "stdio",
|
|
209
|
+
HTTP: "http",
|
|
210
|
+
SSE: "sse"
|
|
211
|
+
};
|
|
212
|
+
|
|
213
|
+
// src/agent/renderers/claude-renderer.ts
|
|
214
|
+
var GENERATED_MARKER = "<!-- ~~ Generated by @codedrifters/configulator. Edits welcome \u2014 please contribute improvements back. ~~ -->";
|
|
215
|
+
var ClaudeRenderer = class _ClaudeRenderer {
|
|
216
|
+
/**
|
|
217
|
+
* Render all Claude Code configuration files.
|
|
218
|
+
*/
|
|
219
|
+
static render(component, rules, skills, subAgents, mcpServers, settings) {
|
|
220
|
+
_ClaudeRenderer.renderClaudeMd(component, rules);
|
|
221
|
+
_ClaudeRenderer.renderScopedRules(component, rules);
|
|
222
|
+
_ClaudeRenderer.renderSettings(component, mcpServers, settings);
|
|
223
|
+
_ClaudeRenderer.renderSkills(component, skills);
|
|
224
|
+
_ClaudeRenderer.renderSubAgents(component, subAgents);
|
|
225
|
+
}
|
|
226
|
+
static renderClaudeMd(component, rules) {
|
|
227
|
+
const claudeMdRules = rules.filter((r) => {
|
|
228
|
+
if (r.platforms?.claude?.exclude) return false;
|
|
229
|
+
const target = r.platforms?.claude?.target ?? _ClaudeRenderer.defaultTarget(r);
|
|
230
|
+
return target === CLAUDE_RULE_TARGET.CLAUDE_MD;
|
|
231
|
+
});
|
|
232
|
+
if (claudeMdRules.length === 0) return;
|
|
233
|
+
const lines = [GENERATED_MARKER, ""];
|
|
234
|
+
for (let i = 0; i < claudeMdRules.length; i++) {
|
|
235
|
+
if (i > 0) lines.push("", "---", "");
|
|
236
|
+
lines.push(...claudeMdRules[i].content.split("\n"));
|
|
237
|
+
}
|
|
238
|
+
new TextFile(component, "CLAUDE.md", { lines });
|
|
239
|
+
}
|
|
240
|
+
static renderScopedRules(component, rules) {
|
|
241
|
+
const scopedRules = rules.filter((r) => {
|
|
242
|
+
if (r.platforms?.claude?.exclude) return false;
|
|
243
|
+
const target = r.platforms?.claude?.target ?? _ClaudeRenderer.defaultTarget(r);
|
|
244
|
+
return target === CLAUDE_RULE_TARGET.SCOPED_FILE;
|
|
245
|
+
});
|
|
246
|
+
for (const rule of scopedRules) {
|
|
247
|
+
const lines = [];
|
|
248
|
+
if (rule.filePatterns && rule.filePatterns.length > 0) {
|
|
249
|
+
lines.push("---");
|
|
250
|
+
lines.push("paths:");
|
|
251
|
+
for (const pattern of rule.filePatterns) {
|
|
252
|
+
lines.push(` - "${pattern}"`);
|
|
253
|
+
}
|
|
254
|
+
lines.push("---");
|
|
255
|
+
lines.push("");
|
|
256
|
+
}
|
|
257
|
+
lines.push(...rule.content.split("\n"));
|
|
258
|
+
new TextFile(component, `.claude/rules/${rule.name}.md`, { lines });
|
|
259
|
+
}
|
|
260
|
+
}
|
|
261
|
+
static renderSettings(component, mcpServers, settings) {
|
|
262
|
+
const obj = {};
|
|
263
|
+
let hasContent = false;
|
|
264
|
+
if (settings?.defaultMode) {
|
|
265
|
+
obj.defaultMode = settings.defaultMode;
|
|
266
|
+
hasContent = true;
|
|
267
|
+
}
|
|
268
|
+
if (settings?.permissions) {
|
|
269
|
+
const perms = {};
|
|
270
|
+
if (settings.permissions.allow?.length) {
|
|
271
|
+
perms.allow = [...settings.permissions.allow];
|
|
272
|
+
}
|
|
273
|
+
if (settings.permissions.deny?.length) {
|
|
274
|
+
perms.deny = [...settings.permissions.deny];
|
|
275
|
+
}
|
|
276
|
+
if (settings.permissions.ask?.length) {
|
|
277
|
+
perms.ask = [...settings.permissions.ask];
|
|
278
|
+
}
|
|
279
|
+
if (settings.permissions.additionalDirectories?.length) {
|
|
280
|
+
perms.additionalDirectories = [
|
|
281
|
+
...settings.permissions.additionalDirectories
|
|
282
|
+
];
|
|
283
|
+
}
|
|
284
|
+
if (Object.keys(perms).length > 0) {
|
|
285
|
+
obj.permissions = perms;
|
|
286
|
+
hasContent = true;
|
|
287
|
+
}
|
|
288
|
+
}
|
|
289
|
+
if (settings?.hooks) {
|
|
290
|
+
const hooks = {};
|
|
291
|
+
for (const [event, entries] of Object.entries(settings.hooks)) {
|
|
292
|
+
if (entries && entries.length > 0) {
|
|
293
|
+
hooks[event] = entries;
|
|
294
|
+
}
|
|
295
|
+
}
|
|
296
|
+
if (Object.keys(hooks).length > 0) {
|
|
297
|
+
obj.hooks = hooks;
|
|
298
|
+
hasContent = true;
|
|
299
|
+
}
|
|
300
|
+
}
|
|
301
|
+
const allMcpServers = {};
|
|
302
|
+
for (const [name, config] of Object.entries(mcpServers)) {
|
|
303
|
+
const server = {};
|
|
304
|
+
if (config.command) server.command = config.command;
|
|
305
|
+
if (config.args) server.args = [...config.args];
|
|
306
|
+
if (config.url) server.url = config.url;
|
|
307
|
+
if (config.env) server.env = { ...config.env };
|
|
308
|
+
allMcpServers[name] = server;
|
|
309
|
+
}
|
|
310
|
+
if (settings?.mcpServers) {
|
|
311
|
+
for (const [name, config] of Object.entries(settings.mcpServers)) {
|
|
312
|
+
const server = {};
|
|
313
|
+
if (config.command) server.command = config.command;
|
|
314
|
+
if (config.args) server.args = [...config.args];
|
|
315
|
+
if (config.url) server.url = config.url;
|
|
316
|
+
if (config.env) server.env = { ...config.env };
|
|
317
|
+
allMcpServers[name] = server;
|
|
318
|
+
}
|
|
319
|
+
}
|
|
320
|
+
if (Object.keys(allMcpServers).length > 0) {
|
|
321
|
+
obj.mcpServers = allMcpServers;
|
|
322
|
+
hasContent = true;
|
|
323
|
+
}
|
|
324
|
+
if (settings?.allowedMcpServers?.length) {
|
|
325
|
+
obj.allowedMcpServers = [...settings.allowedMcpServers];
|
|
326
|
+
hasContent = true;
|
|
327
|
+
}
|
|
328
|
+
if (settings?.env && Object.keys(settings.env).length > 0) {
|
|
329
|
+
obj.env = { ...settings.env };
|
|
330
|
+
hasContent = true;
|
|
331
|
+
}
|
|
332
|
+
if (settings?.sandbox) {
|
|
333
|
+
obj.sandbox = _ClaudeRenderer.buildSandboxObj(settings.sandbox);
|
|
334
|
+
hasContent = true;
|
|
335
|
+
}
|
|
336
|
+
if (settings?.autoMode) {
|
|
337
|
+
const autoMode = {};
|
|
338
|
+
if (settings.autoMode.environment?.length) {
|
|
339
|
+
autoMode.environment = [...settings.autoMode.environment];
|
|
340
|
+
}
|
|
341
|
+
if (settings.autoMode.allow?.length) {
|
|
342
|
+
autoMode.allow = [...settings.autoMode.allow];
|
|
343
|
+
}
|
|
344
|
+
if (settings.autoMode.soft_deny?.length) {
|
|
345
|
+
autoMode.soft_deny = [...settings.autoMode.soft_deny];
|
|
346
|
+
}
|
|
347
|
+
if (Object.keys(autoMode).length > 0) {
|
|
348
|
+
obj.autoMode = autoMode;
|
|
349
|
+
hasContent = true;
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
if (settings?.disableBypassPermissionsMode) {
|
|
353
|
+
obj.disableBypassPermissionsMode = settings.disableBypassPermissionsMode;
|
|
354
|
+
hasContent = true;
|
|
355
|
+
}
|
|
356
|
+
if (settings?.disableAutoMode) {
|
|
357
|
+
obj.disableAutoMode = settings.disableAutoMode;
|
|
358
|
+
hasContent = true;
|
|
359
|
+
}
|
|
360
|
+
if (settings?.disableAllHooks !== void 0) {
|
|
361
|
+
obj.disableAllHooks = settings.disableAllHooks;
|
|
362
|
+
hasContent = true;
|
|
363
|
+
}
|
|
364
|
+
if (settings?.excludeSensitivePatterns?.length) {
|
|
365
|
+
obj.excludeSensitivePatterns = [...settings.excludeSensitivePatterns];
|
|
366
|
+
hasContent = true;
|
|
367
|
+
}
|
|
368
|
+
if (settings?.attribution) {
|
|
369
|
+
obj.attribution = settings.attribution;
|
|
370
|
+
hasContent = true;
|
|
371
|
+
}
|
|
372
|
+
if (!hasContent) return;
|
|
373
|
+
new JsonFile(component, ".claude/settings.json", { obj });
|
|
374
|
+
}
|
|
375
|
+
static buildSandboxObj(sandbox) {
|
|
376
|
+
const obj = {};
|
|
377
|
+
if (sandbox.enabled !== void 0) obj.enabled = sandbox.enabled;
|
|
378
|
+
if (sandbox.mode) obj.mode = sandbox.mode;
|
|
379
|
+
if (sandbox.failIfUnavailable !== void 0) {
|
|
380
|
+
obj.failIfUnavailable = sandbox.failIfUnavailable;
|
|
381
|
+
}
|
|
382
|
+
if (sandbox.autoAllowBashIfSandboxed !== void 0) {
|
|
383
|
+
obj.autoAllowBashIfSandboxed = sandbox.autoAllowBashIfSandboxed;
|
|
384
|
+
}
|
|
385
|
+
if (sandbox.excludedCommands?.length) {
|
|
386
|
+
obj.excludedCommands = [...sandbox.excludedCommands];
|
|
387
|
+
}
|
|
388
|
+
if (sandbox.filesystem) {
|
|
389
|
+
const fs = {};
|
|
390
|
+
if (sandbox.filesystem.allowRead?.length) {
|
|
391
|
+
fs.allowRead = [...sandbox.filesystem.allowRead];
|
|
392
|
+
}
|
|
393
|
+
if (sandbox.filesystem.denyRead?.length) {
|
|
394
|
+
fs.denyRead = [...sandbox.filesystem.denyRead];
|
|
395
|
+
}
|
|
396
|
+
if (sandbox.filesystem.allowWrite?.length) {
|
|
397
|
+
fs.allowWrite = [...sandbox.filesystem.allowWrite];
|
|
398
|
+
}
|
|
399
|
+
if (sandbox.filesystem.denyWrite?.length) {
|
|
400
|
+
fs.denyWrite = [...sandbox.filesystem.denyWrite];
|
|
401
|
+
}
|
|
402
|
+
if (Object.keys(fs).length > 0) obj.filesystem = fs;
|
|
403
|
+
}
|
|
404
|
+
if (sandbox.network) {
|
|
405
|
+
const net = {};
|
|
406
|
+
if (sandbox.network.allowedDomains?.length) {
|
|
407
|
+
net.allowedDomains = [...sandbox.network.allowedDomains];
|
|
408
|
+
}
|
|
409
|
+
if (sandbox.network.denyDomains?.length) {
|
|
410
|
+
net.denyDomains = [...sandbox.network.denyDomains];
|
|
411
|
+
}
|
|
412
|
+
if (Object.keys(net).length > 0) obj.network = net;
|
|
413
|
+
}
|
|
414
|
+
return obj;
|
|
415
|
+
}
|
|
416
|
+
static renderSkills(component, skills) {
|
|
417
|
+
for (const skill of skills) {
|
|
418
|
+
const lines = [];
|
|
419
|
+
lines.push("---");
|
|
420
|
+
lines.push(`name: "${skill.name}"`);
|
|
421
|
+
lines.push(`description: "${skill.description}"`);
|
|
422
|
+
if (skill.disableModelInvocation) {
|
|
423
|
+
lines.push(`disable-model-invocation: true`);
|
|
424
|
+
}
|
|
425
|
+
if (skill.userInvocable === false) {
|
|
426
|
+
lines.push(`user-invocable: false`);
|
|
427
|
+
}
|
|
428
|
+
if (skill.model) {
|
|
429
|
+
lines.push(`model: "${skill.model}"`);
|
|
430
|
+
}
|
|
431
|
+
if (skill.effort) {
|
|
432
|
+
lines.push(`effort: "${skill.effort}"`);
|
|
433
|
+
}
|
|
434
|
+
if (skill.paths && skill.paths.length > 0) {
|
|
435
|
+
lines.push(`paths:`);
|
|
436
|
+
for (const p of skill.paths) {
|
|
437
|
+
lines.push(` - "${p}"`);
|
|
438
|
+
}
|
|
439
|
+
}
|
|
440
|
+
if (skill.allowedTools && skill.allowedTools.length > 0) {
|
|
441
|
+
lines.push(`allowed-tools:`);
|
|
442
|
+
for (const tool of skill.allowedTools) {
|
|
443
|
+
lines.push(` - "${tool}"`);
|
|
444
|
+
}
|
|
445
|
+
}
|
|
446
|
+
lines.push("---");
|
|
447
|
+
lines.push("");
|
|
448
|
+
lines.push(...skill.instructions.split("\n"));
|
|
449
|
+
new TextFile(component, `.claude/skills/${skill.name}/SKILL.md`, {
|
|
450
|
+
lines
|
|
451
|
+
});
|
|
452
|
+
}
|
|
453
|
+
}
|
|
454
|
+
static renderSubAgents(component, subAgents) {
|
|
455
|
+
for (const agent of subAgents) {
|
|
456
|
+
if (agent.platforms?.claude?.exclude) continue;
|
|
457
|
+
const lines = [];
|
|
458
|
+
lines.push("---");
|
|
459
|
+
lines.push(`name: ${agent.name}`);
|
|
460
|
+
lines.push(`description: >-`);
|
|
461
|
+
lines.push(` ${agent.description}`);
|
|
462
|
+
if (agent.model) {
|
|
463
|
+
lines.push(`model: ${agent.model}`);
|
|
464
|
+
}
|
|
465
|
+
if (agent.tools && agent.tools.length > 0) {
|
|
466
|
+
lines.push(`tools:`);
|
|
467
|
+
for (const tool of agent.tools) {
|
|
468
|
+
lines.push(` - "${tool}"`);
|
|
469
|
+
}
|
|
470
|
+
}
|
|
471
|
+
if (agent.maxTurns) {
|
|
472
|
+
lines.push(`max_turns: ${agent.maxTurns}`);
|
|
473
|
+
}
|
|
474
|
+
if (agent.platforms?.claude?.permissionMode) {
|
|
475
|
+
lines.push(`permission_mode: ${agent.platforms.claude.permissionMode}`);
|
|
476
|
+
}
|
|
477
|
+
if (agent.platforms?.claude?.isolation) {
|
|
478
|
+
lines.push(`isolation: ${agent.platforms.claude.isolation}`);
|
|
479
|
+
}
|
|
480
|
+
if (agent.platforms?.claude?.effort) {
|
|
481
|
+
lines.push(`effort: ${agent.platforms.claude.effort}`);
|
|
482
|
+
}
|
|
483
|
+
lines.push("---");
|
|
484
|
+
lines.push("");
|
|
485
|
+
lines.push(...agent.prompt.split("\n"));
|
|
486
|
+
new TextFile(component, `.claude/agents/${agent.name}.md`, { lines });
|
|
487
|
+
}
|
|
488
|
+
}
|
|
489
|
+
/**
|
|
490
|
+
* Determine the default Claude rule target based on rule scope.
|
|
491
|
+
* ALWAYS-scoped rules default to CLAUDE_MD; FILE_PATTERN rules default to SCOPED_FILE.
|
|
492
|
+
*/
|
|
493
|
+
static defaultTarget(rule) {
|
|
494
|
+
return rule.scope === AGENT_RULE_SCOPE.ALWAYS ? CLAUDE_RULE_TARGET.CLAUDE_MD : CLAUDE_RULE_TARGET.SCOPED_FILE;
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
|
|
498
|
+
// src/agent/renderers/codex-renderer.ts
|
|
499
|
+
var CodexRenderer = class {
|
|
500
|
+
static render(_component, _rules, _skills, _subAgents) {
|
|
501
|
+
}
|
|
502
|
+
};
|
|
503
|
+
|
|
504
|
+
// src/agent/renderers/copilot-renderer.ts
|
|
505
|
+
var CopilotRenderer = class {
|
|
506
|
+
static render(_component, _rules, _skills, _subAgents) {
|
|
507
|
+
}
|
|
508
|
+
};
|
|
509
|
+
|
|
510
|
+
// src/agent/renderers/cursor-renderer.ts
|
|
511
|
+
import { JsonFile as JsonFile2 } from "projen";
|
|
512
|
+
import { TextFile as TextFile2 } from "projen/lib/textfile";
|
|
513
|
+
var GENERATED_MARKER2 = "# ~~ Generated by @codedrifters/configulator. Edits welcome \u2014 please contribute improvements back. ~~";
|
|
514
|
+
var CursorRenderer = class _CursorRenderer {
|
|
515
|
+
/**
|
|
516
|
+
* Render all Cursor configuration files.
|
|
517
|
+
*/
|
|
518
|
+
static render(component, rules, skills, subAgents, mcpServers, settings) {
|
|
519
|
+
_CursorRenderer.renderRules(component, rules);
|
|
520
|
+
_CursorRenderer.renderSkills(component, skills);
|
|
521
|
+
_CursorRenderer.renderSubAgents(component, subAgents);
|
|
522
|
+
_CursorRenderer.renderMcpServers(component, mcpServers);
|
|
523
|
+
_CursorRenderer.renderHooks(component, settings);
|
|
524
|
+
_CursorRenderer.renderIgnoreFiles(component, settings);
|
|
525
|
+
}
|
|
526
|
+
static renderRules(component, rules) {
|
|
527
|
+
for (const rule of rules) {
|
|
528
|
+
if (rule.platforms?.cursor?.exclude) continue;
|
|
529
|
+
const lines = [];
|
|
530
|
+
const description = rule.platforms?.cursor?.description ?? rule.description;
|
|
531
|
+
const isAlways = rule.scope === AGENT_RULE_SCOPE.ALWAYS;
|
|
532
|
+
lines.push("---");
|
|
533
|
+
lines.push(`description: "${description}"`);
|
|
534
|
+
lines.push(`alwaysApply: ${isAlways}`);
|
|
535
|
+
if (!isAlways && rule.filePatterns && rule.filePatterns.length > 0) {
|
|
536
|
+
lines.push(`path: ${JSON.stringify([...rule.filePatterns])}`);
|
|
537
|
+
}
|
|
538
|
+
lines.push("---");
|
|
539
|
+
lines.push("");
|
|
540
|
+
lines.push(...rule.content.split("\n"));
|
|
541
|
+
new TextFile2(component, `.cursor/rules/${rule.name}.mdc`, { lines });
|
|
542
|
+
}
|
|
543
|
+
}
|
|
544
|
+
static renderSkills(component, skills) {
|
|
545
|
+
for (const skill of skills) {
|
|
546
|
+
const lines = [];
|
|
547
|
+
lines.push("---");
|
|
548
|
+
lines.push(`name: "${skill.name}"`);
|
|
549
|
+
lines.push(`description: "${skill.description}"`);
|
|
550
|
+
if (skill.disableModelInvocation) {
|
|
551
|
+
lines.push(`disable-model-invocation: true`);
|
|
552
|
+
}
|
|
553
|
+
if (skill.userInvocable === false) {
|
|
554
|
+
lines.push(`user-invocable: false`);
|
|
555
|
+
}
|
|
556
|
+
if (skill.allowedTools && skill.allowedTools.length > 0) {
|
|
557
|
+
lines.push(`allowed-tools:`);
|
|
558
|
+
for (const tool of skill.allowedTools) {
|
|
559
|
+
lines.push(` - "${tool}"`);
|
|
560
|
+
}
|
|
561
|
+
}
|
|
562
|
+
lines.push("---");
|
|
563
|
+
lines.push("");
|
|
564
|
+
lines.push(...skill.instructions.split("\n"));
|
|
565
|
+
new TextFile2(component, `.cursor/skills/${skill.name}/SKILL.md`, {
|
|
566
|
+
lines
|
|
567
|
+
});
|
|
568
|
+
}
|
|
569
|
+
}
|
|
570
|
+
static renderSubAgents(component, subAgents) {
|
|
571
|
+
for (const agent of subAgents) {
|
|
572
|
+
if (agent.platforms?.cursor?.exclude) continue;
|
|
573
|
+
const lines = [];
|
|
574
|
+
lines.push("---");
|
|
575
|
+
lines.push(`name: ${agent.name}`);
|
|
576
|
+
lines.push(`description: >-`);
|
|
577
|
+
lines.push(` ${agent.description}`);
|
|
578
|
+
if (agent.model) {
|
|
579
|
+
lines.push(`model: ${agent.model}`);
|
|
580
|
+
}
|
|
581
|
+
if (agent.platforms?.cursor?.readonly) {
|
|
582
|
+
lines.push(`readonly: true`);
|
|
583
|
+
}
|
|
584
|
+
if (agent.platforms?.cursor?.isBackground) {
|
|
585
|
+
lines.push(`is_background: true`);
|
|
586
|
+
}
|
|
587
|
+
lines.push("---");
|
|
588
|
+
lines.push("");
|
|
589
|
+
lines.push(...agent.prompt.split("\n"));
|
|
590
|
+
new TextFile2(component, `.cursor/agents/${agent.name}.md`, { lines });
|
|
591
|
+
}
|
|
592
|
+
}
|
|
593
|
+
static renderMcpServers(component, mcpServers) {
|
|
594
|
+
const serverNames = Object.keys(mcpServers);
|
|
595
|
+
if (serverNames.length === 0) return;
|
|
596
|
+
const obj = { mcpServers: {} };
|
|
597
|
+
const servers = obj.mcpServers;
|
|
598
|
+
for (const [name, config] of Object.entries(mcpServers)) {
|
|
599
|
+
const server = {};
|
|
600
|
+
if (config.command) server.command = config.command;
|
|
601
|
+
if (config.args) server.args = [...config.args];
|
|
602
|
+
if (config.url) server.url = config.url;
|
|
603
|
+
if (config.env) server.env = { ...config.env };
|
|
604
|
+
servers[name] = server;
|
|
605
|
+
}
|
|
606
|
+
new JsonFile2(component, ".cursor/mcp.json", { obj });
|
|
607
|
+
}
|
|
608
|
+
static renderHooks(component, settings) {
|
|
609
|
+
if (!settings?.hooks) return;
|
|
610
|
+
const hooks = {};
|
|
611
|
+
const {
|
|
612
|
+
beforeSubmitPrompt,
|
|
613
|
+
beforeShellExecution,
|
|
614
|
+
beforeMCPExecution,
|
|
615
|
+
beforeReadFile,
|
|
616
|
+
afterFileEdit,
|
|
617
|
+
stop
|
|
618
|
+
} = settings.hooks;
|
|
619
|
+
if (beforeSubmitPrompt?.length) {
|
|
620
|
+
hooks.beforeSubmitPrompt = beforeSubmitPrompt.map((h) => ({
|
|
621
|
+
command: h.command
|
|
622
|
+
}));
|
|
623
|
+
}
|
|
624
|
+
if (beforeShellExecution?.length) {
|
|
625
|
+
hooks.beforeShellExecution = beforeShellExecution.map((h) => ({
|
|
626
|
+
command: h.command
|
|
627
|
+
}));
|
|
628
|
+
}
|
|
629
|
+
if (beforeMCPExecution?.length) {
|
|
630
|
+
hooks.beforeMCPExecution = beforeMCPExecution.map((h) => ({
|
|
631
|
+
command: h.command
|
|
632
|
+
}));
|
|
633
|
+
}
|
|
634
|
+
if (beforeReadFile?.length) {
|
|
635
|
+
hooks.beforeReadFile = beforeReadFile.map((h) => ({
|
|
636
|
+
command: h.command
|
|
637
|
+
}));
|
|
638
|
+
}
|
|
639
|
+
if (afterFileEdit?.length) {
|
|
640
|
+
hooks.afterFileEdit = afterFileEdit.map((h) => ({ command: h.command }));
|
|
641
|
+
}
|
|
642
|
+
if (stop?.length) hooks.stop = stop.map((h) => ({ command: h.command }));
|
|
643
|
+
if (Object.keys(hooks).length === 0) return;
|
|
644
|
+
new JsonFile2(component, ".cursor/hooks.json", {
|
|
645
|
+
obj: { version: 1, hooks }
|
|
646
|
+
});
|
|
647
|
+
}
|
|
648
|
+
static renderIgnoreFiles(component, settings) {
|
|
649
|
+
if (settings?.ignorePatterns && settings.ignorePatterns.length > 0) {
|
|
650
|
+
new TextFile2(component, ".cursorignore", {
|
|
651
|
+
lines: [GENERATED_MARKER2, "", ...settings.ignorePatterns]
|
|
652
|
+
});
|
|
653
|
+
}
|
|
654
|
+
if (settings?.indexingIgnorePatterns && settings.indexingIgnorePatterns.length > 0) {
|
|
655
|
+
new TextFile2(component, ".cursorindexingignore", {
|
|
656
|
+
lines: [GENERATED_MARKER2, "", ...settings.indexingIgnorePatterns]
|
|
657
|
+
});
|
|
658
|
+
}
|
|
659
|
+
}
|
|
660
|
+
};
|
|
661
|
+
|
|
662
|
+
// src/agent/agent-config.ts
|
|
663
|
+
var AgentConfig = class _AgentConfig extends Component3 {
|
|
664
|
+
/**
|
|
665
|
+
* Find the AgentConfig component on a project.
|
|
666
|
+
*/
|
|
667
|
+
static of(project) {
|
|
668
|
+
const isAgentConfig = (c) => c instanceof _AgentConfig;
|
|
669
|
+
return project.components.find(isAgentConfig);
|
|
670
|
+
}
|
|
671
|
+
constructor(project, options = {}) {
|
|
672
|
+
super(project);
|
|
673
|
+
this.options = options;
|
|
674
|
+
}
|
|
675
|
+
preSynthesize() {
|
|
676
|
+
super.preSynthesize();
|
|
677
|
+
const platforms = this.resolvePlatforms();
|
|
678
|
+
const rules = this.resolveRules();
|
|
679
|
+
const skills = this.resolveSkills();
|
|
680
|
+
const subAgents = this.resolveSubAgents();
|
|
681
|
+
const mcpServers = this.options.mcpServers ?? {};
|
|
682
|
+
if (platforms.includes(AGENT_PLATFORM.CURSOR)) {
|
|
683
|
+
CursorRenderer.render(
|
|
684
|
+
this,
|
|
685
|
+
rules,
|
|
686
|
+
skills,
|
|
687
|
+
subAgents,
|
|
688
|
+
mcpServers,
|
|
689
|
+
this.options.cursorSettings
|
|
690
|
+
);
|
|
691
|
+
}
|
|
692
|
+
if (platforms.includes(AGENT_PLATFORM.CLAUDE)) {
|
|
693
|
+
ClaudeRenderer.render(
|
|
694
|
+
this,
|
|
695
|
+
rules,
|
|
696
|
+
skills,
|
|
697
|
+
subAgents,
|
|
698
|
+
mcpServers,
|
|
699
|
+
this.options.claudeSettings
|
|
700
|
+
);
|
|
701
|
+
}
|
|
702
|
+
if (platforms.includes(AGENT_PLATFORM.CODEX)) {
|
|
703
|
+
CodexRenderer.render(this, rules, skills, subAgents);
|
|
704
|
+
}
|
|
705
|
+
if (platforms.includes(AGENT_PLATFORM.COPILOT)) {
|
|
706
|
+
CopilotRenderer.render(this, rules, skills, subAgents);
|
|
707
|
+
}
|
|
708
|
+
}
|
|
709
|
+
resolvePlatforms() {
|
|
710
|
+
return this.options.platforms ?? [AGENT_PLATFORM.CURSOR, AGENT_PLATFORM.CLAUDE];
|
|
711
|
+
}
|
|
712
|
+
resolveRules() {
|
|
713
|
+
const ruleMap = /* @__PURE__ */ new Map();
|
|
714
|
+
if (this.options.autoDetectBundles !== false) {
|
|
715
|
+
for (const bundle of BUILT_IN_BUNDLES) {
|
|
716
|
+
if (this.options.excludeBundles?.includes(bundle.name)) continue;
|
|
717
|
+
if (bundle.appliesWhen(this.project)) {
|
|
718
|
+
for (const rule of bundle.rules) {
|
|
719
|
+
ruleMap.set(rule.name, rule);
|
|
720
|
+
}
|
|
721
|
+
}
|
|
722
|
+
}
|
|
723
|
+
}
|
|
724
|
+
if (this.options.includeBundles) {
|
|
725
|
+
for (const bundleName of this.options.includeBundles) {
|
|
726
|
+
const bundle = BUILT_IN_BUNDLES.find((b) => b.name === bundleName);
|
|
727
|
+
if (bundle) {
|
|
728
|
+
for (const rule of bundle.rules) {
|
|
729
|
+
ruleMap.set(rule.name, rule);
|
|
730
|
+
}
|
|
731
|
+
}
|
|
732
|
+
}
|
|
733
|
+
}
|
|
734
|
+
if (this.options.rules) {
|
|
735
|
+
for (const rule of this.options.rules) {
|
|
736
|
+
ruleMap.set(rule.name, rule);
|
|
737
|
+
}
|
|
738
|
+
}
|
|
739
|
+
if (this.options.excludeRules) {
|
|
740
|
+
for (const name of this.options.excludeRules) {
|
|
741
|
+
ruleMap.delete(name);
|
|
742
|
+
}
|
|
743
|
+
}
|
|
744
|
+
return [...ruleMap.values()].sort((a, b) => {
|
|
745
|
+
if (a.name === "project-overview") return -1;
|
|
746
|
+
if (b.name === "project-overview") return 1;
|
|
747
|
+
const tagA = a.tags?.[0] ?? "\uFFFF";
|
|
748
|
+
const tagB = b.tags?.[0] ?? "\uFFFF";
|
|
749
|
+
if (tagA !== tagB) return tagA.localeCompare(tagB);
|
|
750
|
+
return a.name.localeCompare(b.name);
|
|
751
|
+
});
|
|
752
|
+
}
|
|
753
|
+
resolveSkills() {
|
|
754
|
+
const skillMap = /* @__PURE__ */ new Map();
|
|
755
|
+
if (this.options.autoDetectBundles !== false) {
|
|
756
|
+
for (const bundle of BUILT_IN_BUNDLES) {
|
|
757
|
+
if (this.options.excludeBundles?.includes(bundle.name)) continue;
|
|
758
|
+
if (bundle.appliesWhen(this.project) && bundle.skills) {
|
|
759
|
+
for (const skill of bundle.skills) {
|
|
760
|
+
skillMap.set(skill.name, skill);
|
|
761
|
+
}
|
|
762
|
+
}
|
|
763
|
+
}
|
|
764
|
+
}
|
|
765
|
+
if (this.options.skills) {
|
|
766
|
+
for (const skill of this.options.skills) {
|
|
767
|
+
skillMap.set(skill.name, skill);
|
|
768
|
+
}
|
|
769
|
+
}
|
|
770
|
+
return [...skillMap.values()];
|
|
771
|
+
}
|
|
772
|
+
resolveSubAgents() {
|
|
773
|
+
const agentMap = /* @__PURE__ */ new Map();
|
|
774
|
+
if (this.options.autoDetectBundles !== false) {
|
|
775
|
+
for (const bundle of BUILT_IN_BUNDLES) {
|
|
776
|
+
if (this.options.excludeBundles?.includes(bundle.name)) continue;
|
|
777
|
+
if (bundle.appliesWhen(this.project) && bundle.subAgents) {
|
|
778
|
+
for (const agent of bundle.subAgents) {
|
|
779
|
+
agentMap.set(agent.name, agent);
|
|
780
|
+
}
|
|
781
|
+
}
|
|
782
|
+
}
|
|
783
|
+
}
|
|
784
|
+
if (this.options.subAgents) {
|
|
785
|
+
for (const agent of this.options.subAgents) {
|
|
786
|
+
agentMap.set(agent.name, agent);
|
|
787
|
+
}
|
|
788
|
+
}
|
|
789
|
+
return [...agentMap.values()];
|
|
790
|
+
}
|
|
791
|
+
};
|
|
792
|
+
|
|
175
793
|
// src/aws/aws-deployment-config.ts
|
|
176
794
|
var import_utils = __toESM(require_lib());
|
|
177
795
|
import { join, relative } from "path";
|
|
178
|
-
import { Component as
|
|
796
|
+
import { Component as Component6 } from "projen";
|
|
179
797
|
|
|
180
798
|
// src/turbo/turbo-repo-task.ts
|
|
181
|
-
import { Component } from "projen/lib";
|
|
182
|
-
var TurboRepoTask = class extends
|
|
799
|
+
import { Component as Component4 } from "projen/lib";
|
|
800
|
+
var TurboRepoTask = class extends Component4 {
|
|
183
801
|
constructor(project, options) {
|
|
184
802
|
super(project);
|
|
185
803
|
this.project = project;
|
|
@@ -218,11 +836,11 @@ var TurboRepoTask = class extends Component {
|
|
|
218
836
|
};
|
|
219
837
|
|
|
220
838
|
// src/turbo/turbo-repo.ts
|
|
221
|
-
import { Component as
|
|
839
|
+
import { Component as Component5, FileBase, JsonFile as JsonFile3 } from "projen/lib";
|
|
222
840
|
import { JobPermission } from "projen/lib/github/workflows-model";
|
|
223
841
|
var ROOT_TURBO_TASK_NAME = "turbo:build";
|
|
224
842
|
var ROOT_CI_TASK_NAME = "build:all";
|
|
225
|
-
var _TurboRepo = class _TurboRepo extends
|
|
843
|
+
var _TurboRepo = class _TurboRepo extends Component5 {
|
|
226
844
|
constructor(project, options = {}) {
|
|
227
845
|
super(project);
|
|
228
846
|
this.project = project;
|
|
@@ -372,7 +990,7 @@ var _TurboRepo = class _TurboRepo extends Component2 {
|
|
|
372
990
|
}
|
|
373
991
|
const fileName = "turbo.json";
|
|
374
992
|
this.project.addPackageIgnore(fileName);
|
|
375
|
-
new
|
|
993
|
+
new JsonFile3(this.project, fileName, {
|
|
376
994
|
obj: {
|
|
377
995
|
extends: this.extends.length ? this.extends : void 0,
|
|
378
996
|
globalDependencies: this.isRootProject && this.globalDependencies.length ? this.globalDependencies : void 0,
|
|
@@ -427,7 +1045,7 @@ _TurboRepo.buildWorkflowOptions = (remoteCacheOptions) => {
|
|
|
427
1045
|
var TurboRepo = _TurboRepo;
|
|
428
1046
|
|
|
429
1047
|
// src/aws/aws-deployment-config.ts
|
|
430
|
-
var AwsDeploymentConfig = class _AwsDeploymentConfig extends
|
|
1048
|
+
var AwsDeploymentConfig = class _AwsDeploymentConfig extends Component6 {
|
|
431
1049
|
constructor(project) {
|
|
432
1050
|
super(project);
|
|
433
1051
|
/**
|
|
@@ -544,8 +1162,8 @@ var AwsDeploymentConfig = class _AwsDeploymentConfig extends Component3 {
|
|
|
544
1162
|
|
|
545
1163
|
// src/aws/aws-deployment-target.ts
|
|
546
1164
|
var import_utils2 = __toESM(require_lib());
|
|
547
|
-
import { Component as
|
|
548
|
-
var AwsDeploymentTarget = class _AwsDeploymentTarget extends
|
|
1165
|
+
import { Component as Component7 } from "projen";
|
|
1166
|
+
var AwsDeploymentTarget = class _AwsDeploymentTarget extends Component7 {
|
|
549
1167
|
constructor(project, options) {
|
|
550
1168
|
super(project);
|
|
551
1169
|
/**
|
|
@@ -807,12 +1425,12 @@ var VERSION = {
|
|
|
807
1425
|
|
|
808
1426
|
// src/jsii/jsii-faker.ts
|
|
809
1427
|
import * as spec from "@jsii/spec";
|
|
810
|
-
import { Component as
|
|
1428
|
+
import { Component as Component8, JsonFile as JsonFile4 } from "projen";
|
|
811
1429
|
var ProjenBaseFqn = {
|
|
812
1430
|
TYPESCRIPT_PROJECT: "projen.typescript.TypeScriptProject",
|
|
813
1431
|
TYPESCRIPT_PROJECT_OPTIONS: "projen.typescript.TypeScriptProjectOptions"
|
|
814
1432
|
};
|
|
815
|
-
var JsiiFaker = class _JsiiFaker extends
|
|
1433
|
+
var JsiiFaker = class _JsiiFaker extends Component8 {
|
|
816
1434
|
constructor(project) {
|
|
817
1435
|
super(project);
|
|
818
1436
|
this.project = project;
|
|
@@ -823,7 +1441,7 @@ var JsiiFaker = class _JsiiFaker extends Component5 {
|
|
|
823
1441
|
};
|
|
824
1442
|
};
|
|
825
1443
|
this._assemblyName = this.project.package.packageName;
|
|
826
|
-
new
|
|
1444
|
+
new JsonFile4(project, ".jsii", {
|
|
827
1445
|
obj: () => {
|
|
828
1446
|
return {
|
|
829
1447
|
name: this._assemblyName,
|
|
@@ -862,7 +1480,7 @@ var JsiiFaker = class _JsiiFaker extends Component5 {
|
|
|
862
1480
|
|
|
863
1481
|
// src/pnpm/pnpm-workspace.ts
|
|
864
1482
|
import { relative as relative2 } from "path";
|
|
865
|
-
import { Component as
|
|
1483
|
+
import { Component as Component9, YamlFile } from "projen";
|
|
866
1484
|
var MIMIMUM_RELEASE_AGE = {
|
|
867
1485
|
ZERO_DAYS: 0,
|
|
868
1486
|
ONE_HOUR: 60,
|
|
@@ -876,7 +1494,7 @@ var MIMIMUM_RELEASE_AGE = {
|
|
|
876
1494
|
SIX_DAYS: 8640,
|
|
877
1495
|
ONE_WEEK: 10080
|
|
878
1496
|
};
|
|
879
|
-
var PnpmWorkspace = class _PnpmWorkspace extends
|
|
1497
|
+
var PnpmWorkspace = class _PnpmWorkspace extends Component9 {
|
|
880
1498
|
/**
|
|
881
1499
|
* Get the pnpm workspace component of a project. If it does not exist,
|
|
882
1500
|
* return undefined.
|
|
@@ -951,7 +1569,7 @@ import {
|
|
|
951
1569
|
import { merge as merge2 } from "ts-deepmerge";
|
|
952
1570
|
|
|
953
1571
|
// src/tasks/reset-task.ts
|
|
954
|
-
import { Component as
|
|
1572
|
+
import { Component as Component11 } from "projen";
|
|
955
1573
|
|
|
956
1574
|
// src/projects/typescript-project.ts
|
|
957
1575
|
import { typescript } from "projen";
|
|
@@ -964,10 +1582,10 @@ import { ReleaseTrigger } from "projen/lib/release";
|
|
|
964
1582
|
import { merge } from "ts-deepmerge";
|
|
965
1583
|
|
|
966
1584
|
// src/vitest/vitest-component.ts
|
|
967
|
-
import { Component as
|
|
1585
|
+
import { Component as Component10 } from "projen";
|
|
968
1586
|
import { Jest } from "projen/lib/javascript";
|
|
969
|
-
import { TextFile } from "projen/lib/textfile";
|
|
970
|
-
var Vitest = class _Vitest extends
|
|
1587
|
+
import { TextFile as TextFile3 } from "projen/lib/textfile";
|
|
1588
|
+
var Vitest = class _Vitest extends Component10 {
|
|
971
1589
|
constructor(project, options = {}) {
|
|
972
1590
|
super(project);
|
|
973
1591
|
this.project = project;
|
|
@@ -1023,7 +1641,7 @@ var Vitest = class _Vitest extends Component7 {
|
|
|
1023
1641
|
}
|
|
1024
1642
|
synthesizeConfig() {
|
|
1025
1643
|
this.project.tryRemoveFile(this.configFilePath);
|
|
1026
|
-
new
|
|
1644
|
+
new TextFile3(this, this.configFilePath, {
|
|
1027
1645
|
lines: this.renderConfig()
|
|
1028
1646
|
});
|
|
1029
1647
|
}
|
|
@@ -1214,7 +1832,7 @@ var TypeScriptProject = class extends typescript.TypeScriptProject {
|
|
|
1214
1832
|
};
|
|
1215
1833
|
|
|
1216
1834
|
// src/tasks/reset-task.ts
|
|
1217
|
-
var ResetTask = class _ResetTask extends
|
|
1835
|
+
var ResetTask = class _ResetTask extends Component11 {
|
|
1218
1836
|
constructor(project, options = {}) {
|
|
1219
1837
|
super(project);
|
|
1220
1838
|
this.project = project;
|
|
@@ -1287,8 +1905,8 @@ var ResetTask = class _ResetTask extends Component8 {
|
|
|
1287
1905
|
};
|
|
1288
1906
|
|
|
1289
1907
|
// src/vscode/vscode.ts
|
|
1290
|
-
import { Component as
|
|
1291
|
-
var VSCodeConfig = class extends
|
|
1908
|
+
import { Component as Component12, vscode } from "projen";
|
|
1909
|
+
var VSCodeConfig = class extends Component12 {
|
|
1292
1910
|
constructor(project) {
|
|
1293
1911
|
super(project);
|
|
1294
1912
|
const vsConfig = new vscode.VsCode(project);
|
|
@@ -1722,9 +2340,9 @@ var MonorepoProject = class extends TypeScriptAppProject {
|
|
|
1722
2340
|
|
|
1723
2341
|
// src/typescript/typescript-config.ts
|
|
1724
2342
|
import { relative as relative3 } from "path";
|
|
1725
|
-
import { Component as
|
|
2343
|
+
import { Component as Component13 } from "projen";
|
|
1726
2344
|
import { ensureRelativePathStartsWithDot } from "projen/lib/util/path";
|
|
1727
|
-
var TypeScriptConfig = class extends
|
|
2345
|
+
var TypeScriptConfig = class extends Component13 {
|
|
1728
2346
|
constructor(project) {
|
|
1729
2347
|
super(project);
|
|
1730
2348
|
let tsPaths = {};
|
|
@@ -1752,12 +2370,12 @@ var TypeScriptConfig = class extends Component10 {
|
|
|
1752
2370
|
|
|
1753
2371
|
// src/workflows/aws-deploy-workflow.ts
|
|
1754
2372
|
var import_utils3 = __toESM(require_lib());
|
|
1755
|
-
import { Component as
|
|
2373
|
+
import { Component as Component14 } from "projen";
|
|
1756
2374
|
import { BuildWorkflow } from "projen/lib/build";
|
|
1757
2375
|
import { GitHub } from "projen/lib/github";
|
|
1758
2376
|
import { JobPermission as JobPermission4 } from "projen/lib/github/workflows-model";
|
|
1759
2377
|
var PROD_DEPLOY_NAME = "prod-deploy";
|
|
1760
|
-
var AwsDeployWorkflow = class _AwsDeployWorkflow extends
|
|
2378
|
+
var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component14 {
|
|
1761
2379
|
constructor(project, options = {}) {
|
|
1762
2380
|
super(project);
|
|
1763
2381
|
this.project = project;
|
|
@@ -2021,11 +2639,18 @@ var AwsDeployWorkflow = class _AwsDeployWorkflow extends Component11 {
|
|
|
2021
2639
|
}
|
|
2022
2640
|
};
|
|
2023
2641
|
export {
|
|
2642
|
+
AGENT_MODEL,
|
|
2643
|
+
AGENT_PLATFORM,
|
|
2644
|
+
AGENT_RULE_SCOPE,
|
|
2645
|
+
AgentConfig,
|
|
2024
2646
|
AwsDeployWorkflow,
|
|
2025
2647
|
AwsDeploymentConfig,
|
|
2026
2648
|
AwsDeploymentTarget,
|
|
2649
|
+
BUILT_IN_BUNDLES,
|
|
2650
|
+
CLAUDE_RULE_TARGET,
|
|
2027
2651
|
COMPLETE_JOB_ID,
|
|
2028
2652
|
JsiiFaker,
|
|
2653
|
+
MCP_TRANSPORT,
|
|
2029
2654
|
MERGE_METHODS,
|
|
2030
2655
|
MIMIMUM_RELEASE_AGE,
|
|
2031
2656
|
MonorepoProject,
|