rulesync 3.31.0 → 3.33.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/README.md +29 -0
- package/dist/index.cjs +1292 -835
- package/dist/index.js +1283 -826
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -252,17 +252,18 @@ var ALL_TOOL_TARGETS = [
|
|
|
252
252
|
"antigravity",
|
|
253
253
|
"augmentcode",
|
|
254
254
|
"augmentcode-legacy",
|
|
255
|
-
"copilot",
|
|
256
|
-
"cursor",
|
|
257
|
-
"cline",
|
|
258
255
|
"claudecode",
|
|
256
|
+
"claudecode-legacy",
|
|
257
|
+
"cline",
|
|
259
258
|
"codexcli",
|
|
259
|
+
"copilot",
|
|
260
|
+
"cursor",
|
|
261
|
+
"geminicli",
|
|
262
|
+
"junie",
|
|
263
|
+
"kiro",
|
|
260
264
|
"opencode",
|
|
261
265
|
"qwencode",
|
|
262
266
|
"roo",
|
|
263
|
-
"geminicli",
|
|
264
|
-
"kiro",
|
|
265
|
-
"junie",
|
|
266
267
|
"warp",
|
|
267
268
|
"windsurf"
|
|
268
269
|
];
|
|
@@ -295,6 +296,11 @@ var ConfigFileSchema = import_mini3.z.object({
|
|
|
295
296
|
...import_mini3.z.partial(ConfigParamsSchema).shape
|
|
296
297
|
});
|
|
297
298
|
var RequiredConfigParamsSchema = import_mini3.z.required(ConfigParamsSchema);
|
|
299
|
+
var CONFLICTING_TARGET_PAIRS = [
|
|
300
|
+
["augmentcode", "augmentcode-legacy"],
|
|
301
|
+
["claudecode", "claudecode-legacy"]
|
|
302
|
+
];
|
|
303
|
+
var LEGACY_TARGETS = ["augmentcode-legacy", "claudecode-legacy"];
|
|
298
304
|
var Config = class {
|
|
299
305
|
baseDirs;
|
|
300
306
|
targets;
|
|
@@ -321,6 +327,7 @@ var Config = class {
|
|
|
321
327
|
experimentalSimulateCommands,
|
|
322
328
|
experimentalSimulateSubagents
|
|
323
329
|
}) {
|
|
330
|
+
this.validateConflictingTargets(targets);
|
|
324
331
|
this.baseDirs = baseDirs;
|
|
325
332
|
this.targets = targets;
|
|
326
333
|
this.features = features;
|
|
@@ -332,12 +339,26 @@ var Config = class {
|
|
|
332
339
|
this.simulateSkills = simulateSkills ?? false;
|
|
333
340
|
this.modularMcp = modularMcp ?? false;
|
|
334
341
|
}
|
|
342
|
+
validateConflictingTargets(targets) {
|
|
343
|
+
for (const [target1, target2] of CONFLICTING_TARGET_PAIRS) {
|
|
344
|
+
const hasTarget1 = targets.includes(target1);
|
|
345
|
+
const hasTarget2 = targets.includes(target2);
|
|
346
|
+
if (hasTarget1 && hasTarget2) {
|
|
347
|
+
throw new Error(
|
|
348
|
+
`Conflicting targets: '${target1}' and '${target2}' cannot be used together. Please choose one.`
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
335
353
|
getBaseDirs() {
|
|
336
354
|
return this.baseDirs;
|
|
337
355
|
}
|
|
338
356
|
getTargets() {
|
|
339
357
|
if (this.targets.includes("*")) {
|
|
340
|
-
return
|
|
358
|
+
return ALL_TOOL_TARGETS.filter(
|
|
359
|
+
// eslint-disable-next-line no-type-assertion/no-type-assertion
|
|
360
|
+
(target) => !LEGACY_TARGETS.includes(target)
|
|
361
|
+
);
|
|
341
362
|
}
|
|
342
363
|
return this.targets.filter((target) => target !== "*");
|
|
343
364
|
}
|
|
@@ -3515,6 +3536,12 @@ var CodexcliMcp = class _CodexcliMcp extends ToolMcp {
|
|
|
3515
3536
|
|
|
3516
3537
|
// src/features/mcp/copilot-mcp.ts
|
|
3517
3538
|
var import_node_path35 = require("path");
|
|
3539
|
+
function convertToCopilotFormat(mcpServers) {
|
|
3540
|
+
return { servers: mcpServers };
|
|
3541
|
+
}
|
|
3542
|
+
function convertFromCopilotFormat(copilotConfig) {
|
|
3543
|
+
return copilotConfig.servers ?? {};
|
|
3544
|
+
}
|
|
3518
3545
|
var CopilotMcp = class _CopilotMcp extends ToolMcp {
|
|
3519
3546
|
json;
|
|
3520
3547
|
constructor(params) {
|
|
@@ -3554,16 +3581,20 @@ var CopilotMcp = class _CopilotMcp extends ToolMcp {
|
|
|
3554
3581
|
rulesyncMcp,
|
|
3555
3582
|
validate = true
|
|
3556
3583
|
}) {
|
|
3584
|
+
const copilotConfig = convertToCopilotFormat(rulesyncMcp.getMcpServers());
|
|
3557
3585
|
return new _CopilotMcp({
|
|
3558
3586
|
baseDir,
|
|
3559
3587
|
relativeDirPath: this.getSettablePaths().relativeDirPath,
|
|
3560
3588
|
relativeFilePath: this.getSettablePaths().relativeFilePath,
|
|
3561
|
-
fileContent:
|
|
3589
|
+
fileContent: JSON.stringify(copilotConfig, null, 2),
|
|
3562
3590
|
validate
|
|
3563
3591
|
});
|
|
3564
3592
|
}
|
|
3565
3593
|
toRulesyncMcp() {
|
|
3566
|
-
|
|
3594
|
+
const mcpServers = convertFromCopilotFormat(this.json);
|
|
3595
|
+
return this.toRulesyncMcpDefault({
|
|
3596
|
+
fileContent: JSON.stringify({ mcpServers }, null, 2)
|
|
3597
|
+
});
|
|
3567
3598
|
}
|
|
3568
3599
|
validate() {
|
|
3569
3600
|
return { success: true, error: null };
|
|
@@ -3947,6 +3978,37 @@ var OpencodeMcp = class _OpencodeMcp extends ToolMcp {
|
|
|
3947
3978
|
|
|
3948
3979
|
// src/features/mcp/roo-mcp.ts
|
|
3949
3980
|
var import_node_path40 = require("path");
|
|
3981
|
+
function isRooMcpServers(value) {
|
|
3982
|
+
return value !== void 0 && value !== null && typeof value === "object";
|
|
3983
|
+
}
|
|
3984
|
+
function convertToRooFormat(mcpServers) {
|
|
3985
|
+
return Object.fromEntries(
|
|
3986
|
+
Object.entries(mcpServers).map(([serverName, serverConfig]) => {
|
|
3987
|
+
const converted = { ...serverConfig };
|
|
3988
|
+
if (serverConfig.type === "http") {
|
|
3989
|
+
converted.type = "streamable-http";
|
|
3990
|
+
}
|
|
3991
|
+
if (serverConfig.transport === "http") {
|
|
3992
|
+
converted.transport = "streamable-http";
|
|
3993
|
+
}
|
|
3994
|
+
return [serverName, converted];
|
|
3995
|
+
})
|
|
3996
|
+
);
|
|
3997
|
+
}
|
|
3998
|
+
function convertFromRooFormat(mcpServers) {
|
|
3999
|
+
return Object.fromEntries(
|
|
4000
|
+
Object.entries(mcpServers).map(([serverName, serverConfig]) => {
|
|
4001
|
+
const converted = { ...serverConfig };
|
|
4002
|
+
if (serverConfig.type === "streamable-http") {
|
|
4003
|
+
converted.type = "http";
|
|
4004
|
+
}
|
|
4005
|
+
if (serverConfig.transport === "streamable-http") {
|
|
4006
|
+
converted.transport = "http";
|
|
4007
|
+
}
|
|
4008
|
+
return [serverName, converted];
|
|
4009
|
+
})
|
|
4010
|
+
);
|
|
4011
|
+
}
|
|
3950
4012
|
var RooMcp = class _RooMcp extends ToolMcp {
|
|
3951
4013
|
json;
|
|
3952
4014
|
constructor(params) {
|
|
@@ -3986,7 +4048,9 @@ var RooMcp = class _RooMcp extends ToolMcp {
|
|
|
3986
4048
|
rulesyncMcp,
|
|
3987
4049
|
validate = true
|
|
3988
4050
|
}) {
|
|
3989
|
-
const
|
|
4051
|
+
const mcpServers = rulesyncMcp.getMcpServers();
|
|
4052
|
+
const convertedMcpServers = convertToRooFormat(mcpServers);
|
|
4053
|
+
const fileContent = JSON.stringify({ mcpServers: convertedMcpServers }, null, 2);
|
|
3990
4054
|
return new _RooMcp({
|
|
3991
4055
|
baseDir,
|
|
3992
4056
|
relativeDirPath: this.getSettablePaths().relativeDirPath,
|
|
@@ -3996,7 +4060,11 @@ var RooMcp = class _RooMcp extends ToolMcp {
|
|
|
3996
4060
|
});
|
|
3997
4061
|
}
|
|
3998
4062
|
toRulesyncMcp() {
|
|
3999
|
-
|
|
4063
|
+
const rawMcpServers = isRooMcpServers(this.json.mcpServers) ? this.json.mcpServers : {};
|
|
4064
|
+
const convertedMcpServers = convertFromRooFormat(rawMcpServers);
|
|
4065
|
+
return this.toRulesyncMcpDefault({
|
|
4066
|
+
fileContent: JSON.stringify({ mcpServers: convertedMcpServers }, null, 2)
|
|
4067
|
+
});
|
|
4000
4068
|
}
|
|
4001
4069
|
validate() {
|
|
4002
4070
|
return { success: true, error: null };
|
|
@@ -4237,21 +4305,23 @@ var McpProcessor = class extends FeatureProcessor {
|
|
|
4237
4305
|
};
|
|
4238
4306
|
|
|
4239
4307
|
// src/features/rules/rules-processor.ts
|
|
4240
|
-
var
|
|
4308
|
+
var import_node_path84 = require("path");
|
|
4241
4309
|
var import_toon = require("@toon-format/toon");
|
|
4242
|
-
var
|
|
4243
|
-
|
|
4244
|
-
// src/features/skills/codexcli-skill.ts
|
|
4245
|
-
var import_node_path44 = require("path");
|
|
4246
|
-
var import_mini20 = require("zod/mini");
|
|
4310
|
+
var import_mini33 = require("zod/mini");
|
|
4247
4311
|
|
|
4248
4312
|
// src/constants/general.ts
|
|
4249
4313
|
var SKILL_FILE_NAME = "SKILL.md";
|
|
4250
4314
|
|
|
4251
|
-
// src/features/skills/
|
|
4252
|
-
var
|
|
4315
|
+
// src/features/skills/agentsmd-skill.ts
|
|
4316
|
+
var import_node_path44 = require("path");
|
|
4317
|
+
|
|
4318
|
+
// src/features/skills/simulated-skill.ts
|
|
4319
|
+
var import_node_path43 = require("path");
|
|
4253
4320
|
var import_mini19 = require("zod/mini");
|
|
4254
4321
|
|
|
4322
|
+
// src/features/skills/tool-skill.ts
|
|
4323
|
+
var import_node_path42 = require("path");
|
|
4324
|
+
|
|
4255
4325
|
// src/types/ai-dir.ts
|
|
4256
4326
|
var import_node_path41 = __toESM(require("path"), 1);
|
|
4257
4327
|
var AiDir = class {
|
|
@@ -4364,113 +4434,7 @@ var AiDir = class {
|
|
|
4364
4434
|
}
|
|
4365
4435
|
};
|
|
4366
4436
|
|
|
4367
|
-
// src/features/skills/rulesync-skill.ts
|
|
4368
|
-
var RulesyncSkillFrontmatterSchemaInternal = import_mini19.z.object({
|
|
4369
|
-
name: import_mini19.z.string(),
|
|
4370
|
-
description: import_mini19.z.string(),
|
|
4371
|
-
targets: import_mini19.z._default(RulesyncTargetsSchema, ["*"]),
|
|
4372
|
-
claudecode: import_mini19.z.optional(
|
|
4373
|
-
import_mini19.z.object({
|
|
4374
|
-
"allowed-tools": import_mini19.z.optional(import_mini19.z.array(import_mini19.z.string()))
|
|
4375
|
-
})
|
|
4376
|
-
)
|
|
4377
|
-
});
|
|
4378
|
-
var RulesyncSkillFrontmatterSchema = RulesyncSkillFrontmatterSchemaInternal;
|
|
4379
|
-
var RulesyncSkill = class _RulesyncSkill extends AiDir {
|
|
4380
|
-
constructor({
|
|
4381
|
-
baseDir = process.cwd(),
|
|
4382
|
-
relativeDirPath = RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
4383
|
-
dirName,
|
|
4384
|
-
frontmatter,
|
|
4385
|
-
body,
|
|
4386
|
-
otherFiles = [],
|
|
4387
|
-
validate = true,
|
|
4388
|
-
global = false
|
|
4389
|
-
}) {
|
|
4390
|
-
super({
|
|
4391
|
-
baseDir,
|
|
4392
|
-
relativeDirPath,
|
|
4393
|
-
dirName,
|
|
4394
|
-
mainFile: {
|
|
4395
|
-
name: SKILL_FILE_NAME,
|
|
4396
|
-
body,
|
|
4397
|
-
frontmatter: { ...frontmatter }
|
|
4398
|
-
},
|
|
4399
|
-
otherFiles,
|
|
4400
|
-
global
|
|
4401
|
-
});
|
|
4402
|
-
if (validate) {
|
|
4403
|
-
const result = this.validate();
|
|
4404
|
-
if (!result.success) {
|
|
4405
|
-
throw result.error;
|
|
4406
|
-
}
|
|
4407
|
-
}
|
|
4408
|
-
}
|
|
4409
|
-
static getSettablePaths() {
|
|
4410
|
-
return {
|
|
4411
|
-
relativeDirPath: RULESYNC_SKILLS_RELATIVE_DIR_PATH
|
|
4412
|
-
};
|
|
4413
|
-
}
|
|
4414
|
-
getFrontmatter() {
|
|
4415
|
-
if (!this.mainFile?.frontmatter) {
|
|
4416
|
-
throw new Error("Frontmatter is not defined");
|
|
4417
|
-
}
|
|
4418
|
-
const result = RulesyncSkillFrontmatterSchema.parse(this.mainFile.frontmatter);
|
|
4419
|
-
return result;
|
|
4420
|
-
}
|
|
4421
|
-
getBody() {
|
|
4422
|
-
return this.mainFile?.body ?? "";
|
|
4423
|
-
}
|
|
4424
|
-
validate() {
|
|
4425
|
-
const result = RulesyncSkillFrontmatterSchema.safeParse(this.mainFile?.frontmatter);
|
|
4426
|
-
if (!result.success) {
|
|
4427
|
-
return {
|
|
4428
|
-
success: false,
|
|
4429
|
-
error: new Error(
|
|
4430
|
-
`Invalid frontmatter in ${this.getDirPath()}: ${formatError(result.error)}`
|
|
4431
|
-
)
|
|
4432
|
-
};
|
|
4433
|
-
}
|
|
4434
|
-
return { success: true, error: null };
|
|
4435
|
-
}
|
|
4436
|
-
static async fromDir({
|
|
4437
|
-
baseDir = process.cwd(),
|
|
4438
|
-
relativeDirPath = RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
4439
|
-
dirName,
|
|
4440
|
-
global = false
|
|
4441
|
-
}) {
|
|
4442
|
-
const skillDirPath = (0, import_node_path42.join)(baseDir, relativeDirPath, dirName);
|
|
4443
|
-
const skillFilePath = (0, import_node_path42.join)(skillDirPath, SKILL_FILE_NAME);
|
|
4444
|
-
if (!await fileExists(skillFilePath)) {
|
|
4445
|
-
throw new Error(`${SKILL_FILE_NAME} not found in ${skillDirPath}`);
|
|
4446
|
-
}
|
|
4447
|
-
const fileContent = await readFileContent(skillFilePath);
|
|
4448
|
-
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
4449
|
-
const result = RulesyncSkillFrontmatterSchema.safeParse(frontmatter);
|
|
4450
|
-
if (!result.success) {
|
|
4451
|
-
throw new Error(`Invalid frontmatter in ${skillFilePath}: ${formatError(result.error)}`);
|
|
4452
|
-
}
|
|
4453
|
-
const otherFiles = await this.collectOtherFiles(
|
|
4454
|
-
baseDir,
|
|
4455
|
-
relativeDirPath,
|
|
4456
|
-
dirName,
|
|
4457
|
-
SKILL_FILE_NAME
|
|
4458
|
-
);
|
|
4459
|
-
return new _RulesyncSkill({
|
|
4460
|
-
baseDir,
|
|
4461
|
-
relativeDirPath,
|
|
4462
|
-
dirName,
|
|
4463
|
-
frontmatter: result.data,
|
|
4464
|
-
body: content.trim(),
|
|
4465
|
-
otherFiles,
|
|
4466
|
-
validate: true,
|
|
4467
|
-
global
|
|
4468
|
-
});
|
|
4469
|
-
}
|
|
4470
|
-
};
|
|
4471
|
-
|
|
4472
4437
|
// src/features/skills/tool-skill.ts
|
|
4473
|
-
var import_node_path43 = require("path");
|
|
4474
4438
|
var ToolSkill = class extends AiDir {
|
|
4475
4439
|
/**
|
|
4476
4440
|
* Get the settable paths for this tool's skill directories.
|
|
@@ -4544,8 +4508,8 @@ var ToolSkill = class extends AiDir {
|
|
|
4544
4508
|
}) {
|
|
4545
4509
|
const settablePaths = getSettablePaths({ global });
|
|
4546
4510
|
const actualRelativeDirPath = relativeDirPath ?? settablePaths.relativeDirPath;
|
|
4547
|
-
const skillDirPath = (0,
|
|
4548
|
-
const skillFilePath = (0,
|
|
4511
|
+
const skillDirPath = (0, import_node_path42.join)(baseDir, actualRelativeDirPath, dirName);
|
|
4512
|
+
const skillFilePath = (0, import_node_path42.join)(skillDirPath, SKILL_FILE_NAME);
|
|
4549
4513
|
if (!await fileExists(skillFilePath)) {
|
|
4550
4514
|
throw new Error(`${SKILL_FILE_NAME} not found in ${skillDirPath}`);
|
|
4551
4515
|
}
|
|
@@ -4569,21 +4533,22 @@ var ToolSkill = class extends AiDir {
|
|
|
4569
4533
|
}
|
|
4570
4534
|
};
|
|
4571
4535
|
|
|
4572
|
-
// src/features/skills/
|
|
4573
|
-
var
|
|
4574
|
-
name:
|
|
4575
|
-
description:
|
|
4536
|
+
// src/features/skills/simulated-skill.ts
|
|
4537
|
+
var SimulatedSkillFrontmatterSchema = import_mini19.z.object({
|
|
4538
|
+
name: import_mini19.z.string(),
|
|
4539
|
+
description: import_mini19.z.string()
|
|
4576
4540
|
});
|
|
4577
|
-
var
|
|
4541
|
+
var SimulatedSkill = class extends ToolSkill {
|
|
4542
|
+
frontmatter;
|
|
4543
|
+
body;
|
|
4578
4544
|
constructor({
|
|
4579
4545
|
baseDir = process.cwd(),
|
|
4580
|
-
relativeDirPath
|
|
4546
|
+
relativeDirPath,
|
|
4581
4547
|
dirName,
|
|
4582
4548
|
frontmatter,
|
|
4583
4549
|
body,
|
|
4584
4550
|
otherFiles = [],
|
|
4585
|
-
validate = true
|
|
4586
|
-
global = false
|
|
4551
|
+
validate = true
|
|
4587
4552
|
}) {
|
|
4588
4553
|
super({
|
|
4589
4554
|
baseDir,
|
|
@@ -4595,42 +4560,37 @@ var CodexCliSkill = class _CodexCliSkill extends ToolSkill {
|
|
|
4595
4560
|
frontmatter: { ...frontmatter }
|
|
4596
4561
|
},
|
|
4597
4562
|
otherFiles,
|
|
4598
|
-
global
|
|
4563
|
+
global: false
|
|
4564
|
+
// Simulated skills are project mode only
|
|
4599
4565
|
});
|
|
4600
4566
|
if (validate) {
|
|
4601
|
-
const result =
|
|
4567
|
+
const result = SimulatedSkillFrontmatterSchema.safeParse(frontmatter);
|
|
4602
4568
|
if (!result.success) {
|
|
4603
|
-
throw
|
|
4569
|
+
throw new Error(
|
|
4570
|
+
`Invalid frontmatter in ${(0, import_node_path43.join)(relativeDirPath, dirName)}: ${formatError(result.error)}`
|
|
4571
|
+
);
|
|
4604
4572
|
}
|
|
4605
4573
|
}
|
|
4574
|
+
this.frontmatter = frontmatter;
|
|
4575
|
+
this.body = body;
|
|
4606
4576
|
}
|
|
4607
|
-
|
|
4608
|
-
|
|
4609
|
-
throw new Error("CodexCliSkill only supports global mode. Please pass { global: true }.");
|
|
4610
|
-
}
|
|
4611
|
-
return {
|
|
4612
|
-
relativeDirPath: (0, import_node_path44.join)(".codex", "skills")
|
|
4613
|
-
};
|
|
4577
|
+
getBody() {
|
|
4578
|
+
return this.body;
|
|
4614
4579
|
}
|
|
4615
4580
|
getFrontmatter() {
|
|
4616
|
-
|
|
4617
|
-
throw new Error("Frontmatter is not defined");
|
|
4618
|
-
}
|
|
4619
|
-
const result = CodexCliSkillFrontmatterSchema.parse(this.mainFile.frontmatter);
|
|
4620
|
-
return result;
|
|
4581
|
+
return this.frontmatter;
|
|
4621
4582
|
}
|
|
4622
|
-
|
|
4623
|
-
|
|
4583
|
+
toRulesyncSkill() {
|
|
4584
|
+
throw new Error("Not implemented because it is a SIMULATED skill.");
|
|
4624
4585
|
}
|
|
4625
4586
|
validate() {
|
|
4626
|
-
if (!this.
|
|
4627
|
-
return {
|
|
4628
|
-
success: false,
|
|
4629
|
-
error: new Error(`${this.getDirPath()}: ${SKILL_FILE_NAME} file does not exist`)
|
|
4630
|
-
};
|
|
4587
|
+
if (!this.frontmatter) {
|
|
4588
|
+
return { success: true, error: null };
|
|
4631
4589
|
}
|
|
4632
|
-
const result =
|
|
4633
|
-
if (
|
|
4590
|
+
const result = SimulatedSkillFrontmatterSchema.safeParse(this.frontmatter);
|
|
4591
|
+
if (result.success) {
|
|
4592
|
+
return { success: true, error: null };
|
|
4593
|
+
} else {
|
|
4634
4594
|
return {
|
|
4635
4595
|
success: false,
|
|
4636
4596
|
error: new Error(
|
|
@@ -4638,98 +4598,141 @@ var CodexCliSkill = class _CodexCliSkill extends ToolSkill {
|
|
|
4638
4598
|
)
|
|
4639
4599
|
};
|
|
4640
4600
|
}
|
|
4641
|
-
return { success: true, error: null };
|
|
4642
|
-
}
|
|
4643
|
-
toRulesyncSkill() {
|
|
4644
|
-
const frontmatter = this.getFrontmatter();
|
|
4645
|
-
const rulesyncFrontmatter = {
|
|
4646
|
-
name: frontmatter.name,
|
|
4647
|
-
description: frontmatter.description,
|
|
4648
|
-
targets: ["*"]
|
|
4649
|
-
};
|
|
4650
|
-
return new RulesyncSkill({
|
|
4651
|
-
baseDir: this.baseDir,
|
|
4652
|
-
relativeDirPath: this.relativeDirPath,
|
|
4653
|
-
dirName: this.getDirName(),
|
|
4654
|
-
frontmatter: rulesyncFrontmatter,
|
|
4655
|
-
body: this.getBody(),
|
|
4656
|
-
otherFiles: this.getOtherFiles(),
|
|
4657
|
-
validate: true,
|
|
4658
|
-
global: this.global
|
|
4659
|
-
});
|
|
4660
4601
|
}
|
|
4661
|
-
static
|
|
4602
|
+
static fromRulesyncSkillDefault({
|
|
4662
4603
|
rulesyncSkill,
|
|
4663
|
-
validate = true
|
|
4664
|
-
global = false
|
|
4604
|
+
validate = true
|
|
4665
4605
|
}) {
|
|
4666
|
-
const settablePaths = _CodexCliSkill.getSettablePaths({ global });
|
|
4667
4606
|
const rulesyncFrontmatter = rulesyncSkill.getFrontmatter();
|
|
4668
|
-
const
|
|
4607
|
+
const simulatedFrontmatter = {
|
|
4669
4608
|
name: rulesyncFrontmatter.name,
|
|
4670
4609
|
description: rulesyncFrontmatter.description
|
|
4671
4610
|
};
|
|
4672
|
-
return
|
|
4611
|
+
return {
|
|
4673
4612
|
baseDir: rulesyncSkill.getBaseDir(),
|
|
4674
|
-
relativeDirPath:
|
|
4613
|
+
relativeDirPath: this.getSettablePaths().relativeDirPath,
|
|
4675
4614
|
dirName: rulesyncSkill.getDirName(),
|
|
4676
|
-
frontmatter:
|
|
4615
|
+
frontmatter: simulatedFrontmatter,
|
|
4677
4616
|
body: rulesyncSkill.getBody(),
|
|
4678
4617
|
otherFiles: rulesyncSkill.getOtherFiles(),
|
|
4679
|
-
validate
|
|
4680
|
-
|
|
4681
|
-
});
|
|
4618
|
+
validate
|
|
4619
|
+
};
|
|
4682
4620
|
}
|
|
4683
|
-
static
|
|
4684
|
-
|
|
4685
|
-
|
|
4686
|
-
|
|
4687
|
-
|
|
4688
|
-
const
|
|
4689
|
-
|
|
4690
|
-
|
|
4691
|
-
|
|
4692
|
-
|
|
4621
|
+
static async fromDirDefault({
|
|
4622
|
+
baseDir = process.cwd(),
|
|
4623
|
+
relativeDirPath,
|
|
4624
|
+
dirName
|
|
4625
|
+
}) {
|
|
4626
|
+
const settablePaths = this.getSettablePaths();
|
|
4627
|
+
const actualRelativeDirPath = relativeDirPath ?? settablePaths.relativeDirPath;
|
|
4628
|
+
const skillDirPath = (0, import_node_path43.join)(baseDir, actualRelativeDirPath, dirName);
|
|
4629
|
+
const skillFilePath = (0, import_node_path43.join)(skillDirPath, SKILL_FILE_NAME);
|
|
4630
|
+
if (!await fileExists(skillFilePath)) {
|
|
4631
|
+
throw new Error(`${SKILL_FILE_NAME} not found in ${skillDirPath}`);
|
|
4632
|
+
}
|
|
4633
|
+
const fileContent = await readFileContent(skillFilePath);
|
|
4634
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
4635
|
+
const result = SimulatedSkillFrontmatterSchema.safeParse(frontmatter);
|
|
4693
4636
|
if (!result.success) {
|
|
4694
|
-
|
|
4695
|
-
throw new Error(
|
|
4696
|
-
`Invalid frontmatter in ${(0, import_node_path44.join)(skillDirPath, SKILL_FILE_NAME)}: ${formatError(result.error)}`
|
|
4697
|
-
);
|
|
4637
|
+
throw new Error(`Invalid frontmatter in ${skillFilePath}: ${formatError(result.error)}`);
|
|
4698
4638
|
}
|
|
4699
|
-
|
|
4700
|
-
baseDir
|
|
4701
|
-
|
|
4702
|
-
dirName
|
|
4639
|
+
const otherFiles = await this.collectOtherFiles(
|
|
4640
|
+
baseDir,
|
|
4641
|
+
actualRelativeDirPath,
|
|
4642
|
+
dirName,
|
|
4643
|
+
SKILL_FILE_NAME
|
|
4644
|
+
);
|
|
4645
|
+
return {
|
|
4646
|
+
baseDir,
|
|
4647
|
+
relativeDirPath: actualRelativeDirPath,
|
|
4648
|
+
dirName,
|
|
4703
4649
|
frontmatter: result.data,
|
|
4704
|
-
body:
|
|
4705
|
-
otherFiles
|
|
4706
|
-
validate: true
|
|
4707
|
-
|
|
4650
|
+
body: content.trim(),
|
|
4651
|
+
otherFiles,
|
|
4652
|
+
validate: true
|
|
4653
|
+
};
|
|
4654
|
+
}
|
|
4655
|
+
/**
|
|
4656
|
+
* Check if a RulesyncSkill should be converted to this simulated skill type.
|
|
4657
|
+
* Uses the targets field in the RulesyncSkill frontmatter to determine targeting.
|
|
4658
|
+
*/
|
|
4659
|
+
static isTargetedByRulesyncSkillDefault({
|
|
4660
|
+
rulesyncSkill,
|
|
4661
|
+
toolTarget
|
|
4662
|
+
}) {
|
|
4663
|
+
const frontmatter = rulesyncSkill.getFrontmatter();
|
|
4664
|
+
const targets = frontmatter.targets;
|
|
4665
|
+
if (targets.includes("*")) {
|
|
4666
|
+
return true;
|
|
4667
|
+
}
|
|
4668
|
+
return targets.includes(toolTarget);
|
|
4669
|
+
}
|
|
4670
|
+
/**
|
|
4671
|
+
* Get the settable paths for this tool's skill directories.
|
|
4672
|
+
* Must be implemented by concrete subclasses.
|
|
4673
|
+
*/
|
|
4674
|
+
static getSettablePaths(_options) {
|
|
4675
|
+
throw new Error("Please implement this method in the subclass.");
|
|
4676
|
+
}
|
|
4677
|
+
};
|
|
4678
|
+
|
|
4679
|
+
// src/features/skills/agentsmd-skill.ts
|
|
4680
|
+
var AgentsmdSkill = class _AgentsmdSkill extends SimulatedSkill {
|
|
4681
|
+
static getSettablePaths(options) {
|
|
4682
|
+
if (options?.global) {
|
|
4683
|
+
throw new Error("AgentsmdSkill does not support global mode.");
|
|
4684
|
+
}
|
|
4685
|
+
return {
|
|
4686
|
+
relativeDirPath: (0, import_node_path44.join)(".agents", "skills")
|
|
4687
|
+
};
|
|
4688
|
+
}
|
|
4689
|
+
static async fromDir(params) {
|
|
4690
|
+
const baseParams = await this.fromDirDefault(params);
|
|
4691
|
+
return new _AgentsmdSkill(baseParams);
|
|
4692
|
+
}
|
|
4693
|
+
static fromRulesyncSkill(params) {
|
|
4694
|
+
const baseParams = {
|
|
4695
|
+
...this.fromRulesyncSkillDefault(params),
|
|
4696
|
+
relativeDirPath: this.getSettablePaths().relativeDirPath
|
|
4697
|
+
};
|
|
4698
|
+
return new _AgentsmdSkill(baseParams);
|
|
4699
|
+
}
|
|
4700
|
+
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
4701
|
+
return this.isTargetedByRulesyncSkillDefault({
|
|
4702
|
+
rulesyncSkill,
|
|
4703
|
+
toolTarget: "agentsmd"
|
|
4708
4704
|
});
|
|
4709
4705
|
}
|
|
4710
4706
|
};
|
|
4711
4707
|
|
|
4712
|
-
// src/features/skills/
|
|
4708
|
+
// src/features/skills/codexcli-skill.ts
|
|
4713
4709
|
var import_node_path46 = require("path");
|
|
4710
|
+
var import_mini21 = require("zod/mini");
|
|
4714
4711
|
|
|
4715
|
-
// src/features/skills/
|
|
4712
|
+
// src/features/skills/rulesync-skill.ts
|
|
4716
4713
|
var import_node_path45 = require("path");
|
|
4717
|
-
var
|
|
4718
|
-
var
|
|
4719
|
-
name:
|
|
4720
|
-
description:
|
|
4714
|
+
var import_mini20 = require("zod/mini");
|
|
4715
|
+
var RulesyncSkillFrontmatterSchemaInternal = import_mini20.z.object({
|
|
4716
|
+
name: import_mini20.z.string(),
|
|
4717
|
+
description: import_mini20.z.string(),
|
|
4718
|
+
targets: import_mini20.z._default(RulesyncTargetsSchema, ["*"]),
|
|
4719
|
+
claudecode: import_mini20.z.optional(
|
|
4720
|
+
import_mini20.z.object({
|
|
4721
|
+
"allowed-tools": import_mini20.z.optional(import_mini20.z.array(import_mini20.z.string()))
|
|
4722
|
+
})
|
|
4723
|
+
)
|
|
4721
4724
|
});
|
|
4722
|
-
var
|
|
4723
|
-
|
|
4724
|
-
body;
|
|
4725
|
+
var RulesyncSkillFrontmatterSchema = RulesyncSkillFrontmatterSchemaInternal;
|
|
4726
|
+
var RulesyncSkill = class _RulesyncSkill extends AiDir {
|
|
4725
4727
|
constructor({
|
|
4726
4728
|
baseDir = process.cwd(),
|
|
4727
|
-
relativeDirPath,
|
|
4729
|
+
relativeDirPath = RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
4728
4730
|
dirName,
|
|
4729
4731
|
frontmatter,
|
|
4730
4732
|
body,
|
|
4731
4733
|
otherFiles = [],
|
|
4732
|
-
validate = true
|
|
4734
|
+
validate = true,
|
|
4735
|
+
global = false
|
|
4733
4736
|
}) {
|
|
4734
4737
|
super({
|
|
4735
4738
|
baseDir,
|
|
@@ -4741,37 +4744,33 @@ var SimulatedSkill = class extends ToolSkill {
|
|
|
4741
4744
|
frontmatter: { ...frontmatter }
|
|
4742
4745
|
},
|
|
4743
4746
|
otherFiles,
|
|
4744
|
-
global
|
|
4745
|
-
// Simulated skills are project mode only
|
|
4747
|
+
global
|
|
4746
4748
|
});
|
|
4747
4749
|
if (validate) {
|
|
4748
|
-
const result =
|
|
4750
|
+
const result = this.validate();
|
|
4749
4751
|
if (!result.success) {
|
|
4750
|
-
throw
|
|
4751
|
-
`Invalid frontmatter in ${(0, import_node_path45.join)(relativeDirPath, dirName)}: ${formatError(result.error)}`
|
|
4752
|
-
);
|
|
4752
|
+
throw result.error;
|
|
4753
4753
|
}
|
|
4754
4754
|
}
|
|
4755
|
-
this.frontmatter = frontmatter;
|
|
4756
|
-
this.body = body;
|
|
4757
4755
|
}
|
|
4758
|
-
|
|
4759
|
-
return
|
|
4756
|
+
static getSettablePaths() {
|
|
4757
|
+
return {
|
|
4758
|
+
relativeDirPath: RULESYNC_SKILLS_RELATIVE_DIR_PATH
|
|
4759
|
+
};
|
|
4760
4760
|
}
|
|
4761
4761
|
getFrontmatter() {
|
|
4762
|
-
|
|
4762
|
+
if (!this.mainFile?.frontmatter) {
|
|
4763
|
+
throw new Error("Frontmatter is not defined");
|
|
4764
|
+
}
|
|
4765
|
+
const result = RulesyncSkillFrontmatterSchema.parse(this.mainFile.frontmatter);
|
|
4766
|
+
return result;
|
|
4763
4767
|
}
|
|
4764
|
-
|
|
4765
|
-
|
|
4768
|
+
getBody() {
|
|
4769
|
+
return this.mainFile?.body ?? "";
|
|
4766
4770
|
}
|
|
4767
4771
|
validate() {
|
|
4768
|
-
|
|
4769
|
-
|
|
4770
|
-
}
|
|
4771
|
-
const result = SimulatedSkillFrontmatterSchema.safeParse(this.frontmatter);
|
|
4772
|
-
if (result.success) {
|
|
4773
|
-
return { success: true, error: null };
|
|
4774
|
-
} else {
|
|
4772
|
+
const result = RulesyncSkillFrontmatterSchema.safeParse(this.mainFile?.frontmatter);
|
|
4773
|
+
if (!result.success) {
|
|
4775
4774
|
return {
|
|
4776
4775
|
success: false,
|
|
4777
4776
|
error: new Error(
|
|
@@ -4779,92 +4778,193 @@ var SimulatedSkill = class extends ToolSkill {
|
|
|
4779
4778
|
)
|
|
4780
4779
|
};
|
|
4781
4780
|
}
|
|
4781
|
+
return { success: true, error: null };
|
|
4782
4782
|
}
|
|
4783
|
-
static
|
|
4784
|
-
rulesyncSkill,
|
|
4785
|
-
validate = true
|
|
4786
|
-
}) {
|
|
4787
|
-
const rulesyncFrontmatter = rulesyncSkill.getFrontmatter();
|
|
4788
|
-
const simulatedFrontmatter = {
|
|
4789
|
-
name: rulesyncFrontmatter.name,
|
|
4790
|
-
description: rulesyncFrontmatter.description
|
|
4791
|
-
};
|
|
4792
|
-
return {
|
|
4793
|
-
baseDir: rulesyncSkill.getBaseDir(),
|
|
4794
|
-
relativeDirPath: this.getSettablePaths().relativeDirPath,
|
|
4795
|
-
dirName: rulesyncSkill.getDirName(),
|
|
4796
|
-
frontmatter: simulatedFrontmatter,
|
|
4797
|
-
body: rulesyncSkill.getBody(),
|
|
4798
|
-
otherFiles: rulesyncSkill.getOtherFiles(),
|
|
4799
|
-
validate
|
|
4800
|
-
};
|
|
4801
|
-
}
|
|
4802
|
-
static async fromDirDefault({
|
|
4783
|
+
static async fromDir({
|
|
4803
4784
|
baseDir = process.cwd(),
|
|
4804
|
-
relativeDirPath,
|
|
4805
|
-
dirName
|
|
4785
|
+
relativeDirPath = RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
4786
|
+
dirName,
|
|
4787
|
+
global = false
|
|
4806
4788
|
}) {
|
|
4807
|
-
const
|
|
4808
|
-
const actualRelativeDirPath = relativeDirPath ?? settablePaths.relativeDirPath;
|
|
4809
|
-
const skillDirPath = (0, import_node_path45.join)(baseDir, actualRelativeDirPath, dirName);
|
|
4789
|
+
const skillDirPath = (0, import_node_path45.join)(baseDir, relativeDirPath, dirName);
|
|
4810
4790
|
const skillFilePath = (0, import_node_path45.join)(skillDirPath, SKILL_FILE_NAME);
|
|
4811
4791
|
if (!await fileExists(skillFilePath)) {
|
|
4812
4792
|
throw new Error(`${SKILL_FILE_NAME} not found in ${skillDirPath}`);
|
|
4813
4793
|
}
|
|
4814
4794
|
const fileContent = await readFileContent(skillFilePath);
|
|
4815
4795
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
4816
|
-
const result =
|
|
4796
|
+
const result = RulesyncSkillFrontmatterSchema.safeParse(frontmatter);
|
|
4817
4797
|
if (!result.success) {
|
|
4818
4798
|
throw new Error(`Invalid frontmatter in ${skillFilePath}: ${formatError(result.error)}`);
|
|
4819
4799
|
}
|
|
4820
4800
|
const otherFiles = await this.collectOtherFiles(
|
|
4821
4801
|
baseDir,
|
|
4822
|
-
|
|
4802
|
+
relativeDirPath,
|
|
4823
4803
|
dirName,
|
|
4824
4804
|
SKILL_FILE_NAME
|
|
4825
4805
|
);
|
|
4826
|
-
return {
|
|
4806
|
+
return new _RulesyncSkill({
|
|
4827
4807
|
baseDir,
|
|
4828
|
-
relativeDirPath
|
|
4808
|
+
relativeDirPath,
|
|
4829
4809
|
dirName,
|
|
4830
4810
|
frontmatter: result.data,
|
|
4831
4811
|
body: content.trim(),
|
|
4832
4812
|
otherFiles,
|
|
4833
|
-
validate: true
|
|
4813
|
+
validate: true,
|
|
4814
|
+
global
|
|
4815
|
+
});
|
|
4816
|
+
}
|
|
4817
|
+
};
|
|
4818
|
+
|
|
4819
|
+
// src/features/skills/codexcli-skill.ts
|
|
4820
|
+
var CodexCliSkillFrontmatterSchema = import_mini21.z.object({
|
|
4821
|
+
name: import_mini21.z.string(),
|
|
4822
|
+
description: import_mini21.z.string()
|
|
4823
|
+
});
|
|
4824
|
+
var CodexCliSkill = class _CodexCliSkill extends ToolSkill {
|
|
4825
|
+
constructor({
|
|
4826
|
+
baseDir = process.cwd(),
|
|
4827
|
+
relativeDirPath = (0, import_node_path46.join)(".codex", "skills"),
|
|
4828
|
+
dirName,
|
|
4829
|
+
frontmatter,
|
|
4830
|
+
body,
|
|
4831
|
+
otherFiles = [],
|
|
4832
|
+
validate = true,
|
|
4833
|
+
global = false
|
|
4834
|
+
}) {
|
|
4835
|
+
super({
|
|
4836
|
+
baseDir,
|
|
4837
|
+
relativeDirPath,
|
|
4838
|
+
dirName,
|
|
4839
|
+
mainFile: {
|
|
4840
|
+
name: SKILL_FILE_NAME,
|
|
4841
|
+
body,
|
|
4842
|
+
frontmatter: { ...frontmatter }
|
|
4843
|
+
},
|
|
4844
|
+
otherFiles,
|
|
4845
|
+
global
|
|
4846
|
+
});
|
|
4847
|
+
if (validate) {
|
|
4848
|
+
const result = this.validate();
|
|
4849
|
+
if (!result.success) {
|
|
4850
|
+
throw result.error;
|
|
4851
|
+
}
|
|
4852
|
+
}
|
|
4853
|
+
}
|
|
4854
|
+
static getSettablePaths({ global = false } = {}) {
|
|
4855
|
+
if (!global) {
|
|
4856
|
+
throw new Error("CodexCliSkill only supports global mode. Please pass { global: true }.");
|
|
4857
|
+
}
|
|
4858
|
+
return {
|
|
4859
|
+
relativeDirPath: (0, import_node_path46.join)(".codex", "skills")
|
|
4834
4860
|
};
|
|
4835
4861
|
}
|
|
4836
|
-
|
|
4837
|
-
|
|
4838
|
-
|
|
4839
|
-
|
|
4840
|
-
|
|
4862
|
+
getFrontmatter() {
|
|
4863
|
+
if (!this.mainFile?.frontmatter) {
|
|
4864
|
+
throw new Error("Frontmatter is not defined");
|
|
4865
|
+
}
|
|
4866
|
+
const result = CodexCliSkillFrontmatterSchema.parse(this.mainFile.frontmatter);
|
|
4867
|
+
return result;
|
|
4868
|
+
}
|
|
4869
|
+
getBody() {
|
|
4870
|
+
return this.mainFile?.body ?? "";
|
|
4871
|
+
}
|
|
4872
|
+
validate() {
|
|
4873
|
+
if (!this.mainFile) {
|
|
4874
|
+
return {
|
|
4875
|
+
success: false,
|
|
4876
|
+
error: new Error(`${this.getDirPath()}: ${SKILL_FILE_NAME} file does not exist`)
|
|
4877
|
+
};
|
|
4878
|
+
}
|
|
4879
|
+
const result = CodexCliSkillFrontmatterSchema.safeParse(this.mainFile.frontmatter);
|
|
4880
|
+
if (!result.success) {
|
|
4881
|
+
return {
|
|
4882
|
+
success: false,
|
|
4883
|
+
error: new Error(
|
|
4884
|
+
`Invalid frontmatter in ${this.getDirPath()}: ${formatError(result.error)}`
|
|
4885
|
+
)
|
|
4886
|
+
};
|
|
4887
|
+
}
|
|
4888
|
+
return { success: true, error: null };
|
|
4889
|
+
}
|
|
4890
|
+
toRulesyncSkill() {
|
|
4891
|
+
const frontmatter = this.getFrontmatter();
|
|
4892
|
+
const rulesyncFrontmatter = {
|
|
4893
|
+
name: frontmatter.name,
|
|
4894
|
+
description: frontmatter.description,
|
|
4895
|
+
targets: ["*"]
|
|
4896
|
+
};
|
|
4897
|
+
return new RulesyncSkill({
|
|
4898
|
+
baseDir: this.baseDir,
|
|
4899
|
+
relativeDirPath: this.relativeDirPath,
|
|
4900
|
+
dirName: this.getDirName(),
|
|
4901
|
+
frontmatter: rulesyncFrontmatter,
|
|
4902
|
+
body: this.getBody(),
|
|
4903
|
+
otherFiles: this.getOtherFiles(),
|
|
4904
|
+
validate: true,
|
|
4905
|
+
global: this.global
|
|
4906
|
+
});
|
|
4907
|
+
}
|
|
4908
|
+
static fromRulesyncSkill({
|
|
4841
4909
|
rulesyncSkill,
|
|
4842
|
-
|
|
4910
|
+
validate = true,
|
|
4911
|
+
global = false
|
|
4843
4912
|
}) {
|
|
4844
|
-
const
|
|
4845
|
-
const
|
|
4846
|
-
|
|
4847
|
-
|
|
4848
|
-
|
|
4849
|
-
|
|
4913
|
+
const settablePaths = _CodexCliSkill.getSettablePaths({ global });
|
|
4914
|
+
const rulesyncFrontmatter = rulesyncSkill.getFrontmatter();
|
|
4915
|
+
const codexFrontmatter = {
|
|
4916
|
+
name: rulesyncFrontmatter.name,
|
|
4917
|
+
description: rulesyncFrontmatter.description
|
|
4918
|
+
};
|
|
4919
|
+
return new _CodexCliSkill({
|
|
4920
|
+
baseDir: rulesyncSkill.getBaseDir(),
|
|
4921
|
+
relativeDirPath: settablePaths.relativeDirPath,
|
|
4922
|
+
dirName: rulesyncSkill.getDirName(),
|
|
4923
|
+
frontmatter: codexFrontmatter,
|
|
4924
|
+
body: rulesyncSkill.getBody(),
|
|
4925
|
+
otherFiles: rulesyncSkill.getOtherFiles(),
|
|
4926
|
+
validate,
|
|
4927
|
+
global
|
|
4928
|
+
});
|
|
4850
4929
|
}
|
|
4851
|
-
|
|
4852
|
-
|
|
4853
|
-
|
|
4854
|
-
|
|
4855
|
-
static
|
|
4856
|
-
|
|
4930
|
+
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
4931
|
+
const targets = rulesyncSkill.getFrontmatter().targets;
|
|
4932
|
+
return targets.includes("*") || targets.includes("codexcli");
|
|
4933
|
+
}
|
|
4934
|
+
static async fromDir(params) {
|
|
4935
|
+
const loaded = await this.loadSkillDirContent({
|
|
4936
|
+
...params,
|
|
4937
|
+
getSettablePaths: _CodexCliSkill.getSettablePaths
|
|
4938
|
+
});
|
|
4939
|
+
const result = CodexCliSkillFrontmatterSchema.safeParse(loaded.frontmatter);
|
|
4940
|
+
if (!result.success) {
|
|
4941
|
+
const skillDirPath = (0, import_node_path46.join)(loaded.baseDir, loaded.relativeDirPath, loaded.dirName);
|
|
4942
|
+
throw new Error(
|
|
4943
|
+
`Invalid frontmatter in ${(0, import_node_path46.join)(skillDirPath, SKILL_FILE_NAME)}: ${formatError(result.error)}`
|
|
4944
|
+
);
|
|
4945
|
+
}
|
|
4946
|
+
return new _CodexCliSkill({
|
|
4947
|
+
baseDir: loaded.baseDir,
|
|
4948
|
+
relativeDirPath: loaded.relativeDirPath,
|
|
4949
|
+
dirName: loaded.dirName,
|
|
4950
|
+
frontmatter: result.data,
|
|
4951
|
+
body: loaded.body,
|
|
4952
|
+
otherFiles: loaded.otherFiles,
|
|
4953
|
+
validate: true,
|
|
4954
|
+
global: loaded.global
|
|
4955
|
+
});
|
|
4857
4956
|
}
|
|
4858
4957
|
};
|
|
4859
4958
|
|
|
4860
4959
|
// src/features/skills/copilot-skill.ts
|
|
4960
|
+
var import_node_path47 = require("path");
|
|
4861
4961
|
var CopilotSkill = class _CopilotSkill extends SimulatedSkill {
|
|
4862
4962
|
static getSettablePaths(options) {
|
|
4863
4963
|
if (options?.global) {
|
|
4864
4964
|
throw new Error("CopilotSkill does not support global mode.");
|
|
4865
4965
|
}
|
|
4866
4966
|
return {
|
|
4867
|
-
relativeDirPath: (0,
|
|
4967
|
+
relativeDirPath: (0, import_node_path47.join)(".github", "skills")
|
|
4868
4968
|
};
|
|
4869
4969
|
}
|
|
4870
4970
|
static async fromDir(params) {
|
|
@@ -4887,14 +4987,14 @@ var CopilotSkill = class _CopilotSkill extends SimulatedSkill {
|
|
|
4887
4987
|
};
|
|
4888
4988
|
|
|
4889
4989
|
// src/features/skills/cursor-skill.ts
|
|
4890
|
-
var
|
|
4990
|
+
var import_node_path48 = require("path");
|
|
4891
4991
|
var CursorSkill = class _CursorSkill extends SimulatedSkill {
|
|
4892
4992
|
static getSettablePaths(options) {
|
|
4893
4993
|
if (options?.global) {
|
|
4894
4994
|
throw new Error("CursorSkill does not support global mode.");
|
|
4895
4995
|
}
|
|
4896
4996
|
return {
|
|
4897
|
-
relativeDirPath: (0,
|
|
4997
|
+
relativeDirPath: (0, import_node_path48.join)(".cursor", "skills")
|
|
4898
4998
|
};
|
|
4899
4999
|
}
|
|
4900
5000
|
static async fromDir(params) {
|
|
@@ -4906,12 +5006,42 @@ var CursorSkill = class _CursorSkill extends SimulatedSkill {
|
|
|
4906
5006
|
...this.fromRulesyncSkillDefault(params),
|
|
4907
5007
|
relativeDirPath: this.getSettablePaths().relativeDirPath
|
|
4908
5008
|
};
|
|
4909
|
-
return new _CursorSkill(baseParams);
|
|
5009
|
+
return new _CursorSkill(baseParams);
|
|
5010
|
+
}
|
|
5011
|
+
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
5012
|
+
return this.isTargetedByRulesyncSkillDefault({
|
|
5013
|
+
rulesyncSkill,
|
|
5014
|
+
toolTarget: "cursor"
|
|
5015
|
+
});
|
|
5016
|
+
}
|
|
5017
|
+
};
|
|
5018
|
+
|
|
5019
|
+
// src/features/skills/geminicli-skill.ts
|
|
5020
|
+
var import_node_path49 = require("path");
|
|
5021
|
+
var GeminiCliSkill = class _GeminiCliSkill extends SimulatedSkill {
|
|
5022
|
+
static getSettablePaths(options) {
|
|
5023
|
+
if (options?.global) {
|
|
5024
|
+
throw new Error("GeminiCliSkill does not support global mode.");
|
|
5025
|
+
}
|
|
5026
|
+
return {
|
|
5027
|
+
relativeDirPath: (0, import_node_path49.join)(".gemini", "skills")
|
|
5028
|
+
};
|
|
5029
|
+
}
|
|
5030
|
+
static async fromDir(params) {
|
|
5031
|
+
const baseParams = await this.fromDirDefault(params);
|
|
5032
|
+
return new _GeminiCliSkill(baseParams);
|
|
5033
|
+
}
|
|
5034
|
+
static fromRulesyncSkill(params) {
|
|
5035
|
+
const baseParams = {
|
|
5036
|
+
...this.fromRulesyncSkillDefault(params),
|
|
5037
|
+
relativeDirPath: this.getSettablePaths().relativeDirPath
|
|
5038
|
+
};
|
|
5039
|
+
return new _GeminiCliSkill(baseParams);
|
|
4910
5040
|
}
|
|
4911
5041
|
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
4912
5042
|
return this.isTargetedByRulesyncSkillDefault({
|
|
4913
5043
|
rulesyncSkill,
|
|
4914
|
-
toolTarget: "
|
|
5044
|
+
toolTarget: "geminicli"
|
|
4915
5045
|
});
|
|
4916
5046
|
}
|
|
4917
5047
|
};
|
|
@@ -4921,7 +5051,7 @@ var import_node_path52 = require("path");
|
|
|
4921
5051
|
var import_mini23 = require("zod/mini");
|
|
4922
5052
|
|
|
4923
5053
|
// src/types/dir-feature-processor.ts
|
|
4924
|
-
var
|
|
5054
|
+
var import_node_path50 = require("path");
|
|
4925
5055
|
var DirFeatureProcessor = class {
|
|
4926
5056
|
baseDir;
|
|
4927
5057
|
constructor({ baseDir = process.cwd() }) {
|
|
@@ -4943,14 +5073,14 @@ var DirFeatureProcessor = class {
|
|
|
4943
5073
|
await ensureDir(dirPath);
|
|
4944
5074
|
const mainFile = aiDir.getMainFile();
|
|
4945
5075
|
if (mainFile) {
|
|
4946
|
-
const mainFilePath = (0,
|
|
5076
|
+
const mainFilePath = (0, import_node_path50.join)(dirPath, mainFile.name);
|
|
4947
5077
|
const content = stringifyFrontmatter(mainFile.body, mainFile.frontmatter);
|
|
4948
5078
|
const contentWithNewline = addTrailingNewline(content);
|
|
4949
5079
|
await writeFileContent(mainFilePath, contentWithNewline);
|
|
4950
5080
|
}
|
|
4951
5081
|
const otherFiles = aiDir.getOtherFiles();
|
|
4952
5082
|
for (const file of otherFiles) {
|
|
4953
|
-
const filePath = (0,
|
|
5083
|
+
const filePath = (0, import_node_path50.join)(dirPath, file.relativeFilePathToDirPath);
|
|
4954
5084
|
const contentWithNewline = addTrailingNewline(file.fileBuffer.toString("utf-8"));
|
|
4955
5085
|
await writeFileContent(filePath, contentWithNewline);
|
|
4956
5086
|
}
|
|
@@ -4964,38 +5094,8 @@ var DirFeatureProcessor = class {
|
|
|
4964
5094
|
}
|
|
4965
5095
|
};
|
|
4966
5096
|
|
|
4967
|
-
// src/features/skills/agentsmd-skill.ts
|
|
4968
|
-
var import_node_path49 = require("path");
|
|
4969
|
-
var AgentsmdSkill = class _AgentsmdSkill extends SimulatedSkill {
|
|
4970
|
-
static getSettablePaths(options) {
|
|
4971
|
-
if (options?.global) {
|
|
4972
|
-
throw new Error("AgentsmdSkill does not support global mode.");
|
|
4973
|
-
}
|
|
4974
|
-
return {
|
|
4975
|
-
relativeDirPath: (0, import_node_path49.join)(".agents", "skills")
|
|
4976
|
-
};
|
|
4977
|
-
}
|
|
4978
|
-
static async fromDir(params) {
|
|
4979
|
-
const baseParams = await this.fromDirDefault(params);
|
|
4980
|
-
return new _AgentsmdSkill(baseParams);
|
|
4981
|
-
}
|
|
4982
|
-
static fromRulesyncSkill(params) {
|
|
4983
|
-
const baseParams = {
|
|
4984
|
-
...this.fromRulesyncSkillDefault(params),
|
|
4985
|
-
relativeDirPath: this.getSettablePaths().relativeDirPath
|
|
4986
|
-
};
|
|
4987
|
-
return new _AgentsmdSkill(baseParams);
|
|
4988
|
-
}
|
|
4989
|
-
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
4990
|
-
return this.isTargetedByRulesyncSkillDefault({
|
|
4991
|
-
rulesyncSkill,
|
|
4992
|
-
toolTarget: "agentsmd"
|
|
4993
|
-
});
|
|
4994
|
-
}
|
|
4995
|
-
};
|
|
4996
|
-
|
|
4997
5097
|
// src/features/skills/claudecode-skill.ts
|
|
4998
|
-
var
|
|
5098
|
+
var import_node_path51 = require("path");
|
|
4999
5099
|
var import_mini22 = require("zod/mini");
|
|
5000
5100
|
var ClaudecodeSkillFrontmatterSchema = import_mini22.z.object({
|
|
5001
5101
|
name: import_mini22.z.string(),
|
|
@@ -5005,7 +5105,7 @@ var ClaudecodeSkillFrontmatterSchema = import_mini22.z.object({
|
|
|
5005
5105
|
var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
|
|
5006
5106
|
constructor({
|
|
5007
5107
|
baseDir = process.cwd(),
|
|
5008
|
-
relativeDirPath = (0,
|
|
5108
|
+
relativeDirPath = (0, import_node_path51.join)(".claude", "skills"),
|
|
5009
5109
|
dirName,
|
|
5010
5110
|
frontmatter,
|
|
5011
5111
|
body,
|
|
@@ -5036,7 +5136,7 @@ var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
|
|
|
5036
5136
|
global: _global = false
|
|
5037
5137
|
} = {}) {
|
|
5038
5138
|
return {
|
|
5039
|
-
relativeDirPath: (0,
|
|
5139
|
+
relativeDirPath: (0, import_node_path51.join)(".claude", "skills")
|
|
5040
5140
|
};
|
|
5041
5141
|
}
|
|
5042
5142
|
getFrontmatter() {
|
|
@@ -5123,9 +5223,9 @@ var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
|
|
|
5123
5223
|
});
|
|
5124
5224
|
const result = ClaudecodeSkillFrontmatterSchema.safeParse(loaded.frontmatter);
|
|
5125
5225
|
if (!result.success) {
|
|
5126
|
-
const skillDirPath = (0,
|
|
5226
|
+
const skillDirPath = (0, import_node_path51.join)(loaded.baseDir, loaded.relativeDirPath, loaded.dirName);
|
|
5127
5227
|
throw new Error(
|
|
5128
|
-
`Invalid frontmatter in ${(0,
|
|
5228
|
+
`Invalid frontmatter in ${(0, import_node_path51.join)(skillDirPath, SKILL_FILE_NAME)}: ${formatError(result.error)}`
|
|
5129
5229
|
);
|
|
5130
5230
|
}
|
|
5131
5231
|
return new _ClaudecodeSkill({
|
|
@@ -5141,36 +5241,6 @@ var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
|
|
|
5141
5241
|
}
|
|
5142
5242
|
};
|
|
5143
5243
|
|
|
5144
|
-
// src/features/skills/geminicli-skill.ts
|
|
5145
|
-
var import_node_path51 = require("path");
|
|
5146
|
-
var GeminiCliSkill = class _GeminiCliSkill extends SimulatedSkill {
|
|
5147
|
-
static getSettablePaths(options) {
|
|
5148
|
-
if (options?.global) {
|
|
5149
|
-
throw new Error("GeminiCliSkill does not support global mode.");
|
|
5150
|
-
}
|
|
5151
|
-
return {
|
|
5152
|
-
relativeDirPath: (0, import_node_path51.join)(".gemini", "skills")
|
|
5153
|
-
};
|
|
5154
|
-
}
|
|
5155
|
-
static async fromDir(params) {
|
|
5156
|
-
const baseParams = await this.fromDirDefault(params);
|
|
5157
|
-
return new _GeminiCliSkill(baseParams);
|
|
5158
|
-
}
|
|
5159
|
-
static fromRulesyncSkill(params) {
|
|
5160
|
-
const baseParams = {
|
|
5161
|
-
...this.fromRulesyncSkillDefault(params),
|
|
5162
|
-
relativeDirPath: this.getSettablePaths().relativeDirPath
|
|
5163
|
-
};
|
|
5164
|
-
return new _GeminiCliSkill(baseParams);
|
|
5165
|
-
}
|
|
5166
|
-
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
5167
|
-
return this.isTargetedByRulesyncSkillDefault({
|
|
5168
|
-
rulesyncSkill,
|
|
5169
|
-
toolTarget: "geminicli"
|
|
5170
|
-
});
|
|
5171
|
-
}
|
|
5172
|
-
};
|
|
5173
|
-
|
|
5174
5244
|
// src/features/skills/skills-processor.ts
|
|
5175
5245
|
var skillsProcessorToolTargetTuple = [
|
|
5176
5246
|
"agentsmd",
|
|
@@ -6085,6 +6155,13 @@ var RulesyncRuleFrontmatterSchema = import_mini28.z.object({
|
|
|
6085
6155
|
subprojectPath: import_mini28.z.optional(import_mini28.z.string())
|
|
6086
6156
|
})
|
|
6087
6157
|
),
|
|
6158
|
+
claudecode: import_mini28.z.optional(
|
|
6159
|
+
import_mini28.z.object({
|
|
6160
|
+
// Glob patterns for conditional rules (takes precedence over globs)
|
|
6161
|
+
// @example "src/**/*.ts, tests/**/*.test.ts"
|
|
6162
|
+
paths: import_mini28.z.optional(import_mini28.z.string())
|
|
6163
|
+
})
|
|
6164
|
+
),
|
|
6088
6165
|
cursor: import_mini28.z.optional(
|
|
6089
6166
|
import_mini28.z.object({
|
|
6090
6167
|
alwaysApply: import_mini28.z.optional(import_mini28.z.boolean()),
|
|
@@ -6648,9 +6725,9 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
6648
6725
|
}
|
|
6649
6726
|
};
|
|
6650
6727
|
|
|
6651
|
-
// src/features/rules/claudecode-rule.ts
|
|
6728
|
+
// src/features/rules/claudecode-legacy-rule.ts
|
|
6652
6729
|
var import_node_path70 = require("path");
|
|
6653
|
-
var
|
|
6730
|
+
var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
6654
6731
|
static getSettablePaths({
|
|
6655
6732
|
global
|
|
6656
6733
|
} = {}) {
|
|
@@ -6685,7 +6762,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
6685
6762
|
const fileContent2 = await readFileContent(
|
|
6686
6763
|
(0, import_node_path70.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
6687
6764
|
);
|
|
6688
|
-
return new
|
|
6765
|
+
return new _ClaudecodeLegacyRule({
|
|
6689
6766
|
baseDir,
|
|
6690
6767
|
relativeDirPath: paths.root.relativeDirPath,
|
|
6691
6768
|
relativeFilePath: paths.root.relativeFilePath,
|
|
@@ -6699,7 +6776,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
6699
6776
|
}
|
|
6700
6777
|
const relativePath = (0, import_node_path70.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
6701
6778
|
const fileContent = await readFileContent((0, import_node_path70.join)(baseDir, relativePath));
|
|
6702
|
-
return new
|
|
6779
|
+
return new _ClaudecodeLegacyRule({
|
|
6703
6780
|
baseDir,
|
|
6704
6781
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
6705
6782
|
relativeFilePath,
|
|
@@ -6715,7 +6792,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
6715
6792
|
global = false
|
|
6716
6793
|
}) {
|
|
6717
6794
|
const paths = this.getSettablePaths({ global });
|
|
6718
|
-
return new
|
|
6795
|
+
return new _ClaudecodeLegacyRule(
|
|
6719
6796
|
this.buildToolRuleParamsDefault({
|
|
6720
6797
|
baseDir,
|
|
6721
6798
|
rulesyncRule,
|
|
@@ -6734,16 +6811,208 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
6734
6811
|
static isTargetedByRulesyncRule(rulesyncRule) {
|
|
6735
6812
|
return this.isTargetedByRulesyncRuleDefault({
|
|
6736
6813
|
rulesyncRule,
|
|
6737
|
-
toolTarget: "claudecode"
|
|
6814
|
+
toolTarget: "claudecode-legacy"
|
|
6738
6815
|
});
|
|
6739
6816
|
}
|
|
6740
6817
|
};
|
|
6741
6818
|
|
|
6742
|
-
// src/features/rules/
|
|
6819
|
+
// src/features/rules/claudecode-rule.ts
|
|
6743
6820
|
var import_node_path71 = require("path");
|
|
6744
6821
|
var import_mini29 = require("zod/mini");
|
|
6745
|
-
var
|
|
6746
|
-
|
|
6822
|
+
var ClaudecodeRuleFrontmatterSchema = import_mini29.z.object({
|
|
6823
|
+
paths: import_mini29.z.optional(import_mini29.z.string())
|
|
6824
|
+
});
|
|
6825
|
+
var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
6826
|
+
frontmatter;
|
|
6827
|
+
body;
|
|
6828
|
+
static getSettablePaths({
|
|
6829
|
+
global
|
|
6830
|
+
} = {}) {
|
|
6831
|
+
if (global) {
|
|
6832
|
+
return {
|
|
6833
|
+
root: {
|
|
6834
|
+
relativeDirPath: ".claude",
|
|
6835
|
+
relativeFilePath: "CLAUDE.md"
|
|
6836
|
+
}
|
|
6837
|
+
};
|
|
6838
|
+
}
|
|
6839
|
+
return {
|
|
6840
|
+
root: {
|
|
6841
|
+
relativeDirPath: ".claude",
|
|
6842
|
+
relativeFilePath: "CLAUDE.md"
|
|
6843
|
+
},
|
|
6844
|
+
nonRoot: {
|
|
6845
|
+
relativeDirPath: (0, import_node_path71.join)(".claude", "rules")
|
|
6846
|
+
}
|
|
6847
|
+
};
|
|
6848
|
+
}
|
|
6849
|
+
constructor({ frontmatter, body, ...rest }) {
|
|
6850
|
+
if (rest.validate) {
|
|
6851
|
+
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
6852
|
+
if (!result.success) {
|
|
6853
|
+
throw new Error(
|
|
6854
|
+
`Invalid frontmatter in ${(0, import_node_path71.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6855
|
+
);
|
|
6856
|
+
}
|
|
6857
|
+
}
|
|
6858
|
+
super({
|
|
6859
|
+
...rest,
|
|
6860
|
+
// Root file: no frontmatter; Non-root file: with optional paths frontmatter
|
|
6861
|
+
fileContent: rest.root ? body : _ClaudecodeRule.generateFileContent(body, frontmatter)
|
|
6862
|
+
});
|
|
6863
|
+
this.frontmatter = frontmatter;
|
|
6864
|
+
this.body = body;
|
|
6865
|
+
}
|
|
6866
|
+
static generateFileContent(body, frontmatter) {
|
|
6867
|
+
if (frontmatter.paths) {
|
|
6868
|
+
return stringifyFrontmatter(body, { paths: frontmatter.paths });
|
|
6869
|
+
}
|
|
6870
|
+
return body;
|
|
6871
|
+
}
|
|
6872
|
+
static async fromFile({
|
|
6873
|
+
baseDir = process.cwd(),
|
|
6874
|
+
relativeFilePath,
|
|
6875
|
+
validate = true,
|
|
6876
|
+
global = false
|
|
6877
|
+
}) {
|
|
6878
|
+
const paths = this.getSettablePaths({ global });
|
|
6879
|
+
const isRoot = relativeFilePath === paths.root.relativeFilePath;
|
|
6880
|
+
if (isRoot) {
|
|
6881
|
+
const fileContent2 = await readFileContent(
|
|
6882
|
+
(0, import_node_path71.join)(baseDir, paths.root.relativeDirPath, paths.root.relativeFilePath)
|
|
6883
|
+
);
|
|
6884
|
+
return new _ClaudecodeRule({
|
|
6885
|
+
baseDir,
|
|
6886
|
+
relativeDirPath: paths.root.relativeDirPath,
|
|
6887
|
+
relativeFilePath: paths.root.relativeFilePath,
|
|
6888
|
+
frontmatter: {},
|
|
6889
|
+
body: fileContent2.trim(),
|
|
6890
|
+
validate,
|
|
6891
|
+
root: true
|
|
6892
|
+
});
|
|
6893
|
+
}
|
|
6894
|
+
if (!paths.nonRoot) {
|
|
6895
|
+
throw new Error("nonRoot path is not set");
|
|
6896
|
+
}
|
|
6897
|
+
const relativePath = (0, import_node_path71.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
6898
|
+
const fileContent = await readFileContent((0, import_node_path71.join)(baseDir, relativePath));
|
|
6899
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
6900
|
+
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
6901
|
+
if (!result.success) {
|
|
6902
|
+
throw new Error(
|
|
6903
|
+
`Invalid frontmatter in ${(0, import_node_path71.join)(baseDir, relativePath)}: ${formatError(result.error)}`
|
|
6904
|
+
);
|
|
6905
|
+
}
|
|
6906
|
+
return new _ClaudecodeRule({
|
|
6907
|
+
baseDir,
|
|
6908
|
+
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
6909
|
+
relativeFilePath,
|
|
6910
|
+
frontmatter: result.data,
|
|
6911
|
+
body: content.trim(),
|
|
6912
|
+
validate,
|
|
6913
|
+
root: false
|
|
6914
|
+
});
|
|
6915
|
+
}
|
|
6916
|
+
static fromRulesyncRule({
|
|
6917
|
+
baseDir = process.cwd(),
|
|
6918
|
+
rulesyncRule,
|
|
6919
|
+
validate = true,
|
|
6920
|
+
global = false
|
|
6921
|
+
}) {
|
|
6922
|
+
const rulesyncFrontmatter = rulesyncRule.getFrontmatter();
|
|
6923
|
+
const root = rulesyncFrontmatter.root ?? false;
|
|
6924
|
+
const paths = this.getSettablePaths({ global });
|
|
6925
|
+
const claudecodePaths = rulesyncFrontmatter.claudecode?.paths;
|
|
6926
|
+
const globs = rulesyncFrontmatter.globs;
|
|
6927
|
+
const pathsValue = claudecodePaths ?? (globs?.length ? globs.join(", ") : void 0);
|
|
6928
|
+
const claudecodeFrontmatter = {
|
|
6929
|
+
paths: root ? void 0 : pathsValue
|
|
6930
|
+
};
|
|
6931
|
+
const body = rulesyncRule.getBody();
|
|
6932
|
+
if (root) {
|
|
6933
|
+
return new _ClaudecodeRule({
|
|
6934
|
+
baseDir,
|
|
6935
|
+
frontmatter: claudecodeFrontmatter,
|
|
6936
|
+
body,
|
|
6937
|
+
relativeDirPath: paths.root.relativeDirPath,
|
|
6938
|
+
relativeFilePath: paths.root.relativeFilePath,
|
|
6939
|
+
validate,
|
|
6940
|
+
root
|
|
6941
|
+
});
|
|
6942
|
+
}
|
|
6943
|
+
if (!paths.nonRoot) {
|
|
6944
|
+
throw new Error("nonRoot path is not set");
|
|
6945
|
+
}
|
|
6946
|
+
return new _ClaudecodeRule({
|
|
6947
|
+
baseDir,
|
|
6948
|
+
frontmatter: claudecodeFrontmatter,
|
|
6949
|
+
body,
|
|
6950
|
+
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
6951
|
+
relativeFilePath: rulesyncRule.getRelativeFilePath(),
|
|
6952
|
+
validate,
|
|
6953
|
+
root
|
|
6954
|
+
});
|
|
6955
|
+
}
|
|
6956
|
+
toRulesyncRule() {
|
|
6957
|
+
let globs;
|
|
6958
|
+
if (this.isRoot()) {
|
|
6959
|
+
globs = ["**/*"];
|
|
6960
|
+
} else if (this.frontmatter.paths) {
|
|
6961
|
+
globs = this.frontmatter.paths.split(",").map((g) => g.trim());
|
|
6962
|
+
}
|
|
6963
|
+
const rulesyncFrontmatter = {
|
|
6964
|
+
targets: ["*"],
|
|
6965
|
+
root: this.isRoot(),
|
|
6966
|
+
description: this.description,
|
|
6967
|
+
globs,
|
|
6968
|
+
...this.frontmatter.paths && {
|
|
6969
|
+
claudecode: { paths: this.frontmatter.paths }
|
|
6970
|
+
}
|
|
6971
|
+
};
|
|
6972
|
+
return new RulesyncRule({
|
|
6973
|
+
baseDir: this.getBaseDir(),
|
|
6974
|
+
frontmatter: rulesyncFrontmatter,
|
|
6975
|
+
body: this.body,
|
|
6976
|
+
relativeDirPath: RULESYNC_RULES_RELATIVE_DIR_PATH,
|
|
6977
|
+
relativeFilePath: this.getRelativeFilePath(),
|
|
6978
|
+
validate: true
|
|
6979
|
+
});
|
|
6980
|
+
}
|
|
6981
|
+
validate() {
|
|
6982
|
+
if (!this.frontmatter) {
|
|
6983
|
+
return { success: true, error: null };
|
|
6984
|
+
}
|
|
6985
|
+
const result = ClaudecodeRuleFrontmatterSchema.safeParse(this.frontmatter);
|
|
6986
|
+
if (result.success) {
|
|
6987
|
+
return { success: true, error: null };
|
|
6988
|
+
} else {
|
|
6989
|
+
return {
|
|
6990
|
+
success: false,
|
|
6991
|
+
error: new Error(
|
|
6992
|
+
`Invalid frontmatter in ${(0, import_node_path71.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6993
|
+
)
|
|
6994
|
+
};
|
|
6995
|
+
}
|
|
6996
|
+
}
|
|
6997
|
+
getFrontmatter() {
|
|
6998
|
+
return this.frontmatter;
|
|
6999
|
+
}
|
|
7000
|
+
getBody() {
|
|
7001
|
+
return this.body;
|
|
7002
|
+
}
|
|
7003
|
+
static isTargetedByRulesyncRule(rulesyncRule) {
|
|
7004
|
+
return this.isTargetedByRulesyncRuleDefault({
|
|
7005
|
+
rulesyncRule,
|
|
7006
|
+
toolTarget: "claudecode"
|
|
7007
|
+
});
|
|
7008
|
+
}
|
|
7009
|
+
};
|
|
7010
|
+
|
|
7011
|
+
// src/features/rules/cline-rule.ts
|
|
7012
|
+
var import_node_path72 = require("path");
|
|
7013
|
+
var import_mini30 = require("zod/mini");
|
|
7014
|
+
var ClineRuleFrontmatterSchema = import_mini30.z.object({
|
|
7015
|
+
description: import_mini30.z.string()
|
|
6747
7016
|
});
|
|
6748
7017
|
var ClineRule = class _ClineRule extends ToolRule {
|
|
6749
7018
|
static getSettablePaths() {
|
|
@@ -6785,7 +7054,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
6785
7054
|
validate = true
|
|
6786
7055
|
}) {
|
|
6787
7056
|
const fileContent = await readFileContent(
|
|
6788
|
-
(0,
|
|
7057
|
+
(0, import_node_path72.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
6789
7058
|
);
|
|
6790
7059
|
return new _ClineRule({
|
|
6791
7060
|
baseDir,
|
|
@@ -6798,7 +7067,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
6798
7067
|
};
|
|
6799
7068
|
|
|
6800
7069
|
// src/features/rules/codexcli-rule.ts
|
|
6801
|
-
var
|
|
7070
|
+
var import_node_path73 = require("path");
|
|
6802
7071
|
var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
6803
7072
|
static getSettablePaths({
|
|
6804
7073
|
global
|
|
@@ -6817,7 +7086,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
6817
7086
|
relativeFilePath: "AGENTS.md"
|
|
6818
7087
|
},
|
|
6819
7088
|
nonRoot: {
|
|
6820
|
-
relativeDirPath: (0,
|
|
7089
|
+
relativeDirPath: (0, import_node_path73.join)(".codex", "memories")
|
|
6821
7090
|
}
|
|
6822
7091
|
};
|
|
6823
7092
|
}
|
|
@@ -6832,7 +7101,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
6832
7101
|
if (isRoot) {
|
|
6833
7102
|
const relativePath2 = paths.root.relativeFilePath;
|
|
6834
7103
|
const fileContent2 = await readFileContent(
|
|
6835
|
-
(0,
|
|
7104
|
+
(0, import_node_path73.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
6836
7105
|
);
|
|
6837
7106
|
return new _CodexcliRule({
|
|
6838
7107
|
baseDir,
|
|
@@ -6846,8 +7115,8 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
6846
7115
|
if (!paths.nonRoot) {
|
|
6847
7116
|
throw new Error("nonRoot path is not set");
|
|
6848
7117
|
}
|
|
6849
|
-
const relativePath = (0,
|
|
6850
|
-
const fileContent = await readFileContent((0,
|
|
7118
|
+
const relativePath = (0, import_node_path73.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
7119
|
+
const fileContent = await readFileContent((0, import_node_path73.join)(baseDir, relativePath));
|
|
6851
7120
|
return new _CodexcliRule({
|
|
6852
7121
|
baseDir,
|
|
6853
7122
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -6889,12 +7158,12 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
6889
7158
|
};
|
|
6890
7159
|
|
|
6891
7160
|
// src/features/rules/copilot-rule.ts
|
|
6892
|
-
var
|
|
6893
|
-
var
|
|
6894
|
-
var CopilotRuleFrontmatterSchema =
|
|
6895
|
-
description:
|
|
6896
|
-
applyTo:
|
|
6897
|
-
excludeAgent:
|
|
7161
|
+
var import_node_path74 = require("path");
|
|
7162
|
+
var import_mini31 = require("zod/mini");
|
|
7163
|
+
var CopilotRuleFrontmatterSchema = import_mini31.z.object({
|
|
7164
|
+
description: import_mini31.z.optional(import_mini31.z.string()),
|
|
7165
|
+
applyTo: import_mini31.z.optional(import_mini31.z.string()),
|
|
7166
|
+
excludeAgent: import_mini31.z.optional(import_mini31.z.union([import_mini31.z.literal("code-review"), import_mini31.z.literal("coding-agent")]))
|
|
6898
7167
|
});
|
|
6899
7168
|
var CopilotRule = class _CopilotRule extends ToolRule {
|
|
6900
7169
|
frontmatter;
|
|
@@ -6906,7 +7175,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
6906
7175
|
relativeFilePath: "copilot-instructions.md"
|
|
6907
7176
|
},
|
|
6908
7177
|
nonRoot: {
|
|
6909
|
-
relativeDirPath: (0,
|
|
7178
|
+
relativeDirPath: (0, import_node_path74.join)(".github", "instructions")
|
|
6910
7179
|
}
|
|
6911
7180
|
};
|
|
6912
7181
|
}
|
|
@@ -6915,7 +7184,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
6915
7184
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
6916
7185
|
if (!result.success) {
|
|
6917
7186
|
throw new Error(
|
|
6918
|
-
`Invalid frontmatter in ${(0,
|
|
7187
|
+
`Invalid frontmatter in ${(0, import_node_path74.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6919
7188
|
);
|
|
6920
7189
|
}
|
|
6921
7190
|
}
|
|
@@ -6997,11 +7266,11 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
6997
7266
|
validate = true
|
|
6998
7267
|
}) {
|
|
6999
7268
|
const isRoot = relativeFilePath === "copilot-instructions.md";
|
|
7000
|
-
const relativePath = isRoot ? (0,
|
|
7269
|
+
const relativePath = isRoot ? (0, import_node_path74.join)(
|
|
7001
7270
|
this.getSettablePaths().root.relativeDirPath,
|
|
7002
7271
|
this.getSettablePaths().root.relativeFilePath
|
|
7003
|
-
) : (0,
|
|
7004
|
-
const fileContent = await readFileContent((0,
|
|
7272
|
+
) : (0, import_node_path74.join)(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
7273
|
+
const fileContent = await readFileContent((0, import_node_path74.join)(baseDir, relativePath));
|
|
7005
7274
|
if (isRoot) {
|
|
7006
7275
|
return new _CopilotRule({
|
|
7007
7276
|
baseDir,
|
|
@@ -7017,7 +7286,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
7017
7286
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7018
7287
|
if (!result.success) {
|
|
7019
7288
|
throw new Error(
|
|
7020
|
-
`Invalid frontmatter in ${(0,
|
|
7289
|
+
`Invalid frontmatter in ${(0, import_node_path74.join)(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
7021
7290
|
);
|
|
7022
7291
|
}
|
|
7023
7292
|
return new _CopilotRule({
|
|
@@ -7041,7 +7310,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
7041
7310
|
return {
|
|
7042
7311
|
success: false,
|
|
7043
7312
|
error: new Error(
|
|
7044
|
-
`Invalid frontmatter in ${(0,
|
|
7313
|
+
`Invalid frontmatter in ${(0, import_node_path74.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
7045
7314
|
)
|
|
7046
7315
|
};
|
|
7047
7316
|
}
|
|
@@ -7061,12 +7330,12 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
7061
7330
|
};
|
|
7062
7331
|
|
|
7063
7332
|
// src/features/rules/cursor-rule.ts
|
|
7064
|
-
var
|
|
7065
|
-
var
|
|
7066
|
-
var CursorRuleFrontmatterSchema =
|
|
7067
|
-
description:
|
|
7068
|
-
globs:
|
|
7069
|
-
alwaysApply:
|
|
7333
|
+
var import_node_path75 = require("path");
|
|
7334
|
+
var import_mini32 = require("zod/mini");
|
|
7335
|
+
var CursorRuleFrontmatterSchema = import_mini32.z.object({
|
|
7336
|
+
description: import_mini32.z.optional(import_mini32.z.string()),
|
|
7337
|
+
globs: import_mini32.z.optional(import_mini32.z.string()),
|
|
7338
|
+
alwaysApply: import_mini32.z.optional(import_mini32.z.boolean())
|
|
7070
7339
|
});
|
|
7071
7340
|
var CursorRule = class _CursorRule extends ToolRule {
|
|
7072
7341
|
frontmatter;
|
|
@@ -7074,7 +7343,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
7074
7343
|
static getSettablePaths() {
|
|
7075
7344
|
return {
|
|
7076
7345
|
nonRoot: {
|
|
7077
|
-
relativeDirPath: (0,
|
|
7346
|
+
relativeDirPath: (0, import_node_path75.join)(".cursor", "rules")
|
|
7078
7347
|
}
|
|
7079
7348
|
};
|
|
7080
7349
|
}
|
|
@@ -7083,7 +7352,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
7083
7352
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7084
7353
|
if (!result.success) {
|
|
7085
7354
|
throw new Error(
|
|
7086
|
-
`Invalid frontmatter in ${(0,
|
|
7355
|
+
`Invalid frontmatter in ${(0, import_node_path75.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
7087
7356
|
);
|
|
7088
7357
|
}
|
|
7089
7358
|
}
|
|
@@ -7200,19 +7469,19 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
7200
7469
|
validate = true
|
|
7201
7470
|
}) {
|
|
7202
7471
|
const fileContent = await readFileContent(
|
|
7203
|
-
(0,
|
|
7472
|
+
(0, import_node_path75.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7204
7473
|
);
|
|
7205
7474
|
const { frontmatter, body: content } = _CursorRule.parseCursorFrontmatter(fileContent);
|
|
7206
7475
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7207
7476
|
if (!result.success) {
|
|
7208
7477
|
throw new Error(
|
|
7209
|
-
`Invalid frontmatter in ${(0,
|
|
7478
|
+
`Invalid frontmatter in ${(0, import_node_path75.join)(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
7210
7479
|
);
|
|
7211
7480
|
}
|
|
7212
7481
|
return new _CursorRule({
|
|
7213
7482
|
baseDir,
|
|
7214
7483
|
relativeDirPath: this.getSettablePaths().nonRoot.relativeDirPath,
|
|
7215
|
-
relativeFilePath: (0,
|
|
7484
|
+
relativeFilePath: (0, import_node_path75.basename)(relativeFilePath),
|
|
7216
7485
|
frontmatter: result.data,
|
|
7217
7486
|
body: content.trim(),
|
|
7218
7487
|
validate
|
|
@@ -7229,7 +7498,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
7229
7498
|
return {
|
|
7230
7499
|
success: false,
|
|
7231
7500
|
error: new Error(
|
|
7232
|
-
`Invalid frontmatter in ${(0,
|
|
7501
|
+
`Invalid frontmatter in ${(0, import_node_path75.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
7233
7502
|
)
|
|
7234
7503
|
};
|
|
7235
7504
|
}
|
|
@@ -7249,7 +7518,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
7249
7518
|
};
|
|
7250
7519
|
|
|
7251
7520
|
// src/features/rules/geminicli-rule.ts
|
|
7252
|
-
var
|
|
7521
|
+
var import_node_path76 = require("path");
|
|
7253
7522
|
var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
7254
7523
|
static getSettablePaths({
|
|
7255
7524
|
global
|
|
@@ -7268,7 +7537,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
7268
7537
|
relativeFilePath: "GEMINI.md"
|
|
7269
7538
|
},
|
|
7270
7539
|
nonRoot: {
|
|
7271
|
-
relativeDirPath: (0,
|
|
7540
|
+
relativeDirPath: (0, import_node_path76.join)(".gemini", "memories")
|
|
7272
7541
|
}
|
|
7273
7542
|
};
|
|
7274
7543
|
}
|
|
@@ -7283,7 +7552,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
7283
7552
|
if (isRoot) {
|
|
7284
7553
|
const relativePath2 = paths.root.relativeFilePath;
|
|
7285
7554
|
const fileContent2 = await readFileContent(
|
|
7286
|
-
(0,
|
|
7555
|
+
(0, import_node_path76.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
7287
7556
|
);
|
|
7288
7557
|
return new _GeminiCliRule({
|
|
7289
7558
|
baseDir,
|
|
@@ -7297,8 +7566,8 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
7297
7566
|
if (!paths.nonRoot) {
|
|
7298
7567
|
throw new Error("nonRoot path is not set");
|
|
7299
7568
|
}
|
|
7300
|
-
const relativePath = (0,
|
|
7301
|
-
const fileContent = await readFileContent((0,
|
|
7569
|
+
const relativePath = (0, import_node_path76.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
7570
|
+
const fileContent = await readFileContent((0, import_node_path76.join)(baseDir, relativePath));
|
|
7302
7571
|
return new _GeminiCliRule({
|
|
7303
7572
|
baseDir,
|
|
7304
7573
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -7340,7 +7609,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
7340
7609
|
};
|
|
7341
7610
|
|
|
7342
7611
|
// src/features/rules/junie-rule.ts
|
|
7343
|
-
var
|
|
7612
|
+
var import_node_path77 = require("path");
|
|
7344
7613
|
var JunieRule = class _JunieRule extends ToolRule {
|
|
7345
7614
|
static getSettablePaths() {
|
|
7346
7615
|
return {
|
|
@@ -7349,7 +7618,7 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
7349
7618
|
relativeFilePath: "guidelines.md"
|
|
7350
7619
|
},
|
|
7351
7620
|
nonRoot: {
|
|
7352
|
-
relativeDirPath: (0,
|
|
7621
|
+
relativeDirPath: (0, import_node_path77.join)(".junie", "memories")
|
|
7353
7622
|
}
|
|
7354
7623
|
};
|
|
7355
7624
|
}
|
|
@@ -7359,8 +7628,8 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
7359
7628
|
validate = true
|
|
7360
7629
|
}) {
|
|
7361
7630
|
const isRoot = relativeFilePath === "guidelines.md";
|
|
7362
|
-
const relativePath = isRoot ? "guidelines.md" : (0,
|
|
7363
|
-
const fileContent = await readFileContent((0,
|
|
7631
|
+
const relativePath = isRoot ? "guidelines.md" : (0, import_node_path77.join)(".junie", "memories", relativeFilePath);
|
|
7632
|
+
const fileContent = await readFileContent((0, import_node_path77.join)(baseDir, relativePath));
|
|
7364
7633
|
return new _JunieRule({
|
|
7365
7634
|
baseDir,
|
|
7366
7635
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -7400,12 +7669,12 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
7400
7669
|
};
|
|
7401
7670
|
|
|
7402
7671
|
// src/features/rules/kiro-rule.ts
|
|
7403
|
-
var
|
|
7672
|
+
var import_node_path78 = require("path");
|
|
7404
7673
|
var KiroRule = class _KiroRule extends ToolRule {
|
|
7405
7674
|
static getSettablePaths() {
|
|
7406
7675
|
return {
|
|
7407
7676
|
nonRoot: {
|
|
7408
|
-
relativeDirPath: (0,
|
|
7677
|
+
relativeDirPath: (0, import_node_path78.join)(".kiro", "steering")
|
|
7409
7678
|
}
|
|
7410
7679
|
};
|
|
7411
7680
|
}
|
|
@@ -7415,7 +7684,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
7415
7684
|
validate = true
|
|
7416
7685
|
}) {
|
|
7417
7686
|
const fileContent = await readFileContent(
|
|
7418
|
-
(0,
|
|
7687
|
+
(0, import_node_path78.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7419
7688
|
);
|
|
7420
7689
|
return new _KiroRule({
|
|
7421
7690
|
baseDir,
|
|
@@ -7455,7 +7724,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
7455
7724
|
};
|
|
7456
7725
|
|
|
7457
7726
|
// src/features/rules/opencode-rule.ts
|
|
7458
|
-
var
|
|
7727
|
+
var import_node_path79 = require("path");
|
|
7459
7728
|
var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
7460
7729
|
static getSettablePaths() {
|
|
7461
7730
|
return {
|
|
@@ -7464,7 +7733,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
7464
7733
|
relativeFilePath: "AGENTS.md"
|
|
7465
7734
|
},
|
|
7466
7735
|
nonRoot: {
|
|
7467
|
-
relativeDirPath: (0,
|
|
7736
|
+
relativeDirPath: (0, import_node_path79.join)(".opencode", "memories")
|
|
7468
7737
|
}
|
|
7469
7738
|
};
|
|
7470
7739
|
}
|
|
@@ -7474,8 +7743,8 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
7474
7743
|
validate = true
|
|
7475
7744
|
}) {
|
|
7476
7745
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
7477
|
-
const relativePath = isRoot ? "AGENTS.md" : (0,
|
|
7478
|
-
const fileContent = await readFileContent((0,
|
|
7746
|
+
const relativePath = isRoot ? "AGENTS.md" : (0, import_node_path79.join)(".opencode", "memories", relativeFilePath);
|
|
7747
|
+
const fileContent = await readFileContent((0, import_node_path79.join)(baseDir, relativePath));
|
|
7479
7748
|
return new _OpenCodeRule({
|
|
7480
7749
|
baseDir,
|
|
7481
7750
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -7515,7 +7784,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
7515
7784
|
};
|
|
7516
7785
|
|
|
7517
7786
|
// src/features/rules/qwencode-rule.ts
|
|
7518
|
-
var
|
|
7787
|
+
var import_node_path80 = require("path");
|
|
7519
7788
|
var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
7520
7789
|
static getSettablePaths() {
|
|
7521
7790
|
return {
|
|
@@ -7524,7 +7793,7 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
7524
7793
|
relativeFilePath: "QWEN.md"
|
|
7525
7794
|
},
|
|
7526
7795
|
nonRoot: {
|
|
7527
|
-
relativeDirPath: (0,
|
|
7796
|
+
relativeDirPath: (0, import_node_path80.join)(".qwen", "memories")
|
|
7528
7797
|
}
|
|
7529
7798
|
};
|
|
7530
7799
|
}
|
|
@@ -7534,8 +7803,8 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
7534
7803
|
validate = true
|
|
7535
7804
|
}) {
|
|
7536
7805
|
const isRoot = relativeFilePath === "QWEN.md";
|
|
7537
|
-
const relativePath = isRoot ? "QWEN.md" : (0,
|
|
7538
|
-
const fileContent = await readFileContent((0,
|
|
7806
|
+
const relativePath = isRoot ? "QWEN.md" : (0, import_node_path80.join)(".qwen", "memories", relativeFilePath);
|
|
7807
|
+
const fileContent = await readFileContent((0, import_node_path80.join)(baseDir, relativePath));
|
|
7539
7808
|
return new _QwencodeRule({
|
|
7540
7809
|
baseDir,
|
|
7541
7810
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -7572,12 +7841,12 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
7572
7841
|
};
|
|
7573
7842
|
|
|
7574
7843
|
// src/features/rules/roo-rule.ts
|
|
7575
|
-
var
|
|
7844
|
+
var import_node_path81 = require("path");
|
|
7576
7845
|
var RooRule = class _RooRule extends ToolRule {
|
|
7577
7846
|
static getSettablePaths() {
|
|
7578
7847
|
return {
|
|
7579
7848
|
nonRoot: {
|
|
7580
|
-
relativeDirPath: (0,
|
|
7849
|
+
relativeDirPath: (0, import_node_path81.join)(".roo", "rules")
|
|
7581
7850
|
}
|
|
7582
7851
|
};
|
|
7583
7852
|
}
|
|
@@ -7587,7 +7856,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
7587
7856
|
validate = true
|
|
7588
7857
|
}) {
|
|
7589
7858
|
const fileContent = await readFileContent(
|
|
7590
|
-
(0,
|
|
7859
|
+
(0, import_node_path81.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7591
7860
|
);
|
|
7592
7861
|
return new _RooRule({
|
|
7593
7862
|
baseDir,
|
|
@@ -7642,7 +7911,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
7642
7911
|
};
|
|
7643
7912
|
|
|
7644
7913
|
// src/features/rules/warp-rule.ts
|
|
7645
|
-
var
|
|
7914
|
+
var import_node_path82 = require("path");
|
|
7646
7915
|
var WarpRule = class _WarpRule extends ToolRule {
|
|
7647
7916
|
constructor({ fileContent, root, ...rest }) {
|
|
7648
7917
|
super({
|
|
@@ -7658,7 +7927,7 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
7658
7927
|
relativeFilePath: "WARP.md"
|
|
7659
7928
|
},
|
|
7660
7929
|
nonRoot: {
|
|
7661
|
-
relativeDirPath: (0,
|
|
7930
|
+
relativeDirPath: (0, import_node_path82.join)(".warp", "memories")
|
|
7662
7931
|
}
|
|
7663
7932
|
};
|
|
7664
7933
|
}
|
|
@@ -7668,8 +7937,8 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
7668
7937
|
validate = true
|
|
7669
7938
|
}) {
|
|
7670
7939
|
const isRoot = relativeFilePath === this.getSettablePaths().root.relativeFilePath;
|
|
7671
|
-
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath : (0,
|
|
7672
|
-
const fileContent = await readFileContent((0,
|
|
7940
|
+
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath : (0, import_node_path82.join)(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
7941
|
+
const fileContent = await readFileContent((0, import_node_path82.join)(baseDir, relativePath));
|
|
7673
7942
|
return new _WarpRule({
|
|
7674
7943
|
baseDir,
|
|
7675
7944
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : ".warp",
|
|
@@ -7709,12 +7978,12 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
7709
7978
|
};
|
|
7710
7979
|
|
|
7711
7980
|
// src/features/rules/windsurf-rule.ts
|
|
7712
|
-
var
|
|
7981
|
+
var import_node_path83 = require("path");
|
|
7713
7982
|
var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
7714
7983
|
static getSettablePaths() {
|
|
7715
7984
|
return {
|
|
7716
7985
|
nonRoot: {
|
|
7717
|
-
relativeDirPath: (0,
|
|
7986
|
+
relativeDirPath: (0, import_node_path83.join)(".windsurf", "rules")
|
|
7718
7987
|
}
|
|
7719
7988
|
};
|
|
7720
7989
|
}
|
|
@@ -7724,7 +7993,7 @@ var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
|
7724
7993
|
validate = true
|
|
7725
7994
|
}) {
|
|
7726
7995
|
const fileContent = await readFileContent(
|
|
7727
|
-
(0,
|
|
7996
|
+
(0, import_node_path83.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7728
7997
|
);
|
|
7729
7998
|
return new _WindsurfRule({
|
|
7730
7999
|
baseDir,
|
|
@@ -7770,6 +8039,7 @@ var rulesProcessorToolTargets = [
|
|
|
7770
8039
|
"augmentcode",
|
|
7771
8040
|
"augmentcode-legacy",
|
|
7772
8041
|
"claudecode",
|
|
8042
|
+
"claudecode-legacy",
|
|
7773
8043
|
"cline",
|
|
7774
8044
|
"codexcli",
|
|
7775
8045
|
"copilot",
|
|
@@ -7783,32 +8053,197 @@ var rulesProcessorToolTargets = [
|
|
|
7783
8053
|
"warp",
|
|
7784
8054
|
"windsurf"
|
|
7785
8055
|
];
|
|
7786
|
-
var RulesProcessorToolTargetSchema =
|
|
7787
|
-
var rulesProcessorToolTargetsGlobal = [
|
|
7788
|
-
"claudecode",
|
|
7789
|
-
"codexcli",
|
|
7790
|
-
"geminicli"
|
|
7791
|
-
];
|
|
8056
|
+
var RulesProcessorToolTargetSchema = import_mini33.z.enum(rulesProcessorToolTargets);
|
|
7792
8057
|
var toolRuleFactories = /* @__PURE__ */ new Map([
|
|
7793
|
-
[
|
|
7794
|
-
|
|
7795
|
-
|
|
7796
|
-
|
|
7797
|
-
|
|
7798
|
-
|
|
7799
|
-
|
|
7800
|
-
|
|
7801
|
-
|
|
7802
|
-
|
|
7803
|
-
|
|
7804
|
-
|
|
7805
|
-
|
|
7806
|
-
|
|
7807
|
-
|
|
7808
|
-
|
|
7809
|
-
[
|
|
7810
|
-
|
|
8058
|
+
[
|
|
8059
|
+
"agentsmd",
|
|
8060
|
+
{
|
|
8061
|
+
class: AgentsMdRule,
|
|
8062
|
+
meta: {
|
|
8063
|
+
extension: "md",
|
|
8064
|
+
supportsGlobal: false,
|
|
8065
|
+
ruleDiscoveryMode: "toon",
|
|
8066
|
+
additionalConventions: {
|
|
8067
|
+
commands: { commandClass: AgentsmdCommand },
|
|
8068
|
+
subagents: { subagentClass: AgentsmdSubagent },
|
|
8069
|
+
skills: { skillClass: AgentsmdSkill }
|
|
8070
|
+
}
|
|
8071
|
+
}
|
|
8072
|
+
}
|
|
8073
|
+
],
|
|
8074
|
+
[
|
|
8075
|
+
"amazonqcli",
|
|
8076
|
+
{
|
|
8077
|
+
class: AmazonQCliRule,
|
|
8078
|
+
meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
|
|
8079
|
+
}
|
|
8080
|
+
],
|
|
8081
|
+
[
|
|
8082
|
+
"antigravity",
|
|
8083
|
+
{
|
|
8084
|
+
class: AntigravityRule,
|
|
8085
|
+
meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
|
|
8086
|
+
}
|
|
8087
|
+
],
|
|
8088
|
+
[
|
|
8089
|
+
"augmentcode",
|
|
8090
|
+
{
|
|
8091
|
+
class: AugmentcodeRule,
|
|
8092
|
+
meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
|
|
8093
|
+
}
|
|
8094
|
+
],
|
|
8095
|
+
[
|
|
8096
|
+
"augmentcode-legacy",
|
|
8097
|
+
{
|
|
8098
|
+
class: AugmentcodeLegacyRule,
|
|
8099
|
+
meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
|
|
8100
|
+
}
|
|
8101
|
+
],
|
|
8102
|
+
[
|
|
8103
|
+
"claudecode",
|
|
8104
|
+
{
|
|
8105
|
+
class: ClaudecodeRule,
|
|
8106
|
+
meta: { extension: "md", supportsGlobal: true, ruleDiscoveryMode: "auto" }
|
|
8107
|
+
}
|
|
8108
|
+
],
|
|
8109
|
+
[
|
|
8110
|
+
"claudecode-legacy",
|
|
8111
|
+
{
|
|
8112
|
+
class: ClaudecodeLegacyRule,
|
|
8113
|
+
meta: { extension: "md", supportsGlobal: true, ruleDiscoveryMode: "claudecode-legacy" }
|
|
8114
|
+
}
|
|
8115
|
+
],
|
|
8116
|
+
[
|
|
8117
|
+
"cline",
|
|
8118
|
+
{
|
|
8119
|
+
class: ClineRule,
|
|
8120
|
+
meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
|
|
8121
|
+
}
|
|
8122
|
+
],
|
|
8123
|
+
[
|
|
8124
|
+
"codexcli",
|
|
8125
|
+
{
|
|
8126
|
+
class: CodexcliRule,
|
|
8127
|
+
meta: {
|
|
8128
|
+
extension: "md",
|
|
8129
|
+
supportsGlobal: true,
|
|
8130
|
+
ruleDiscoveryMode: "toon",
|
|
8131
|
+
additionalConventions: {
|
|
8132
|
+
subagents: { subagentClass: CodexCliSubagent },
|
|
8133
|
+
skills: { skillClass: CodexCliSkill, globalOnly: true }
|
|
8134
|
+
}
|
|
8135
|
+
}
|
|
8136
|
+
}
|
|
8137
|
+
],
|
|
8138
|
+
[
|
|
8139
|
+
"copilot",
|
|
8140
|
+
{
|
|
8141
|
+
class: CopilotRule,
|
|
8142
|
+
meta: {
|
|
8143
|
+
extension: "md",
|
|
8144
|
+
supportsGlobal: false,
|
|
8145
|
+
ruleDiscoveryMode: "auto",
|
|
8146
|
+
additionalConventions: {
|
|
8147
|
+
commands: { commandClass: CopilotCommand },
|
|
8148
|
+
subagents: { subagentClass: CopilotSubagent },
|
|
8149
|
+
skills: { skillClass: CopilotSkill }
|
|
8150
|
+
}
|
|
8151
|
+
}
|
|
8152
|
+
}
|
|
8153
|
+
],
|
|
8154
|
+
[
|
|
8155
|
+
"cursor",
|
|
8156
|
+
{
|
|
8157
|
+
class: CursorRule,
|
|
8158
|
+
meta: {
|
|
8159
|
+
extension: "mdc",
|
|
8160
|
+
supportsGlobal: false,
|
|
8161
|
+
ruleDiscoveryMode: "auto",
|
|
8162
|
+
additionalConventions: {
|
|
8163
|
+
commands: { commandClass: CursorCommand },
|
|
8164
|
+
subagents: { subagentClass: CursorSubagent },
|
|
8165
|
+
skills: { skillClass: CursorSkill }
|
|
8166
|
+
},
|
|
8167
|
+
createsSeparateConventionsRule: true
|
|
8168
|
+
}
|
|
8169
|
+
}
|
|
8170
|
+
],
|
|
8171
|
+
[
|
|
8172
|
+
"geminicli",
|
|
8173
|
+
{
|
|
8174
|
+
class: GeminiCliRule,
|
|
8175
|
+
meta: {
|
|
8176
|
+
extension: "md",
|
|
8177
|
+
supportsGlobal: true,
|
|
8178
|
+
ruleDiscoveryMode: "toon",
|
|
8179
|
+
additionalConventions: {
|
|
8180
|
+
commands: { commandClass: GeminiCliCommand },
|
|
8181
|
+
subagents: { subagentClass: GeminiCliSubagent },
|
|
8182
|
+
skills: { skillClass: GeminiCliSkill }
|
|
8183
|
+
}
|
|
8184
|
+
}
|
|
8185
|
+
}
|
|
8186
|
+
],
|
|
8187
|
+
[
|
|
8188
|
+
"junie",
|
|
8189
|
+
{
|
|
8190
|
+
class: JunieRule,
|
|
8191
|
+
meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
|
|
8192
|
+
}
|
|
8193
|
+
],
|
|
8194
|
+
[
|
|
8195
|
+
"kiro",
|
|
8196
|
+
{
|
|
8197
|
+
class: KiroRule,
|
|
8198
|
+
meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
|
|
8199
|
+
}
|
|
8200
|
+
],
|
|
8201
|
+
[
|
|
8202
|
+
"opencode",
|
|
8203
|
+
{
|
|
8204
|
+
class: OpenCodeRule,
|
|
8205
|
+
meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
|
|
8206
|
+
}
|
|
8207
|
+
],
|
|
8208
|
+
[
|
|
8209
|
+
"qwencode",
|
|
8210
|
+
{
|
|
8211
|
+
class: QwencodeRule,
|
|
8212
|
+
meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
|
|
8213
|
+
}
|
|
8214
|
+
],
|
|
8215
|
+
[
|
|
8216
|
+
"roo",
|
|
8217
|
+
{
|
|
8218
|
+
class: RooRule,
|
|
8219
|
+
meta: {
|
|
8220
|
+
extension: "md",
|
|
8221
|
+
supportsGlobal: false,
|
|
8222
|
+
ruleDiscoveryMode: "auto",
|
|
8223
|
+
additionalConventions: {
|
|
8224
|
+
commands: { commandClass: RooCommand },
|
|
8225
|
+
subagents: { subagentClass: RooSubagent }
|
|
8226
|
+
},
|
|
8227
|
+
createsSeparateConventionsRule: true
|
|
8228
|
+
}
|
|
8229
|
+
}
|
|
8230
|
+
],
|
|
8231
|
+
[
|
|
8232
|
+
"warp",
|
|
8233
|
+
{
|
|
8234
|
+
class: WarpRule,
|
|
8235
|
+
meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "toon" }
|
|
8236
|
+
}
|
|
8237
|
+
],
|
|
8238
|
+
[
|
|
8239
|
+
"windsurf",
|
|
8240
|
+
{
|
|
8241
|
+
class: WindsurfRule,
|
|
8242
|
+
meta: { extension: "md", supportsGlobal: false, ruleDiscoveryMode: "auto" }
|
|
8243
|
+
}
|
|
8244
|
+
]
|
|
7811
8245
|
]);
|
|
8246
|
+
var rulesProcessorToolTargetsGlobal = Array.from(toolRuleFactories.entries()).filter(([_, factory]) => factory.meta.supportsGlobal).map(([target]) => target);
|
|
7812
8247
|
var defaultGetFactory6 = (target) => {
|
|
7813
8248
|
const factory = toolRuleFactories.get(target);
|
|
7814
8249
|
if (!factory) {
|
|
@@ -7823,6 +8258,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7823
8258
|
simulateSkills;
|
|
7824
8259
|
global;
|
|
7825
8260
|
getFactory;
|
|
8261
|
+
skills;
|
|
7826
8262
|
constructor({
|
|
7827
8263
|
baseDir = process.cwd(),
|
|
7828
8264
|
toolTarget,
|
|
@@ -7830,7 +8266,8 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7830
8266
|
simulateSubagents = false,
|
|
7831
8267
|
simulateSkills = false,
|
|
7832
8268
|
global = false,
|
|
7833
|
-
getFactory = defaultGetFactory6
|
|
8269
|
+
getFactory = defaultGetFactory6,
|
|
8270
|
+
skills
|
|
7834
8271
|
}) {
|
|
7835
8272
|
super({ baseDir });
|
|
7836
8273
|
const result = RulesProcessorToolTargetSchema.safeParse(toolTarget);
|
|
@@ -7845,12 +8282,14 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7845
8282
|
this.simulateSubagents = simulateSubagents;
|
|
7846
8283
|
this.simulateSkills = simulateSkills;
|
|
7847
8284
|
this.getFactory = getFactory;
|
|
8285
|
+
this.skills = skills;
|
|
7848
8286
|
}
|
|
7849
8287
|
async convertRulesyncFilesToToolFiles(rulesyncFiles) {
|
|
7850
8288
|
const rulesyncRules = rulesyncFiles.filter(
|
|
7851
8289
|
(file) => file instanceof RulesyncRule
|
|
7852
8290
|
);
|
|
7853
8291
|
const factory = this.getFactory(this.toolTarget);
|
|
8292
|
+
const { meta } = factory;
|
|
7854
8293
|
const toolRules = rulesyncRules.map((rulesyncRule) => {
|
|
7855
8294
|
if (!factory.class.isTargetedByRulesyncRule(rulesyncRule)) {
|
|
7856
8295
|
return null;
|
|
@@ -7863,150 +8302,105 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7863
8302
|
});
|
|
7864
8303
|
}).filter((rule) => rule !== null);
|
|
7865
8304
|
const isSimulated = this.simulateCommands || this.simulateSubagents || this.simulateSkills;
|
|
7866
|
-
if (isSimulated &&
|
|
7867
|
-
|
|
7868
|
-
|
|
7869
|
-
|
|
7870
|
-
|
|
7871
|
-
|
|
7872
|
-
|
|
7873
|
-
|
|
7874
|
-
|
|
7875
|
-
|
|
7876
|
-
relativeDirPath:
|
|
7877
|
-
|
|
7878
|
-
|
|
7879
|
-
|
|
7880
|
-
|
|
7881
|
-
|
|
7882
|
-
|
|
7883
|
-
|
|
7884
|
-
|
|
7885
|
-
|
|
7886
|
-
|
|
7887
|
-
|
|
7888
|
-
|
|
7889
|
-
toolRules.push(
|
|
7890
|
-
new RooRule({
|
|
7891
|
-
baseDir: this.baseDir,
|
|
7892
|
-
relativeDirPath: RooRule.getSettablePaths().nonRoot.relativeDirPath,
|
|
7893
|
-
relativeFilePath: "additional-conventions.md",
|
|
7894
|
-
fileContent: this.generateAdditionalConventionsSection({
|
|
7895
|
-
commands: { relativeDirPath: RooCommand.getSettablePaths().relativeDirPath },
|
|
7896
|
-
subagents: {
|
|
7897
|
-
relativeDirPath: RooSubagent.getSettablePaths().relativeDirPath
|
|
7898
|
-
}
|
|
7899
|
-
}),
|
|
7900
|
-
validate: true
|
|
7901
|
-
})
|
|
7902
|
-
);
|
|
8305
|
+
if (isSimulated && meta.createsSeparateConventionsRule && meta.additionalConventions) {
|
|
8306
|
+
const conventionsContent = this.generateAdditionalConventionsSectionFromMeta(meta);
|
|
8307
|
+
const settablePaths = factory.class.getSettablePaths();
|
|
8308
|
+
const nonRootPath = "nonRoot" in settablePaths ? settablePaths.nonRoot : null;
|
|
8309
|
+
if (nonRootPath) {
|
|
8310
|
+
toolRules.push(
|
|
8311
|
+
factory.class.fromRulesyncRule({
|
|
8312
|
+
baseDir: this.baseDir,
|
|
8313
|
+
rulesyncRule: new RulesyncRule({
|
|
8314
|
+
baseDir: this.baseDir,
|
|
8315
|
+
relativeDirPath: nonRootPath.relativeDirPath,
|
|
8316
|
+
relativeFilePath: "additional-conventions.md",
|
|
8317
|
+
frontmatter: {
|
|
8318
|
+
root: false,
|
|
8319
|
+
targets: [this.toolTarget]
|
|
8320
|
+
},
|
|
8321
|
+
body: conventionsContent
|
|
8322
|
+
}),
|
|
8323
|
+
validate: true,
|
|
8324
|
+
global: this.global
|
|
8325
|
+
})
|
|
8326
|
+
);
|
|
8327
|
+
}
|
|
7903
8328
|
}
|
|
7904
8329
|
const rootRuleIndex = toolRules.findIndex((rule) => rule.isRoot());
|
|
7905
8330
|
if (rootRuleIndex === -1) {
|
|
7906
8331
|
return toolRules;
|
|
7907
8332
|
}
|
|
7908
|
-
|
|
7909
|
-
|
|
7910
|
-
|
|
7911
|
-
|
|
7912
|
-
|
|
7913
|
-
|
|
7914
|
-
|
|
7915
|
-
|
|
7916
|
-
|
|
7917
|
-
|
|
7918
|
-
|
|
7919
|
-
|
|
7920
|
-
|
|
7921
|
-
|
|
7922
|
-
|
|
7923
|
-
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
|
|
7932
|
-
|
|
7933
|
-
|
|
7934
|
-
|
|
7935
|
-
|
|
7936
|
-
|
|
7937
|
-
|
|
7938
|
-
|
|
7939
|
-
|
|
7940
|
-
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
...this.global && {
|
|
7944
|
-
skills: {
|
|
7945
|
-
relativeDirPath: CodexCliSkill.getSettablePaths({ global: this.global }).relativeDirPath
|
|
7946
|
-
}
|
|
7947
|
-
}
|
|
7948
|
-
}) + rootRule.getFileContent()
|
|
7949
|
-
);
|
|
7950
|
-
return toolRules;
|
|
7951
|
-
}
|
|
7952
|
-
case "copilot": {
|
|
7953
|
-
const rootRule = toolRules[rootRuleIndex];
|
|
7954
|
-
rootRule?.setFileContent(
|
|
7955
|
-
this.generateAdditionalConventionsSection({
|
|
7956
|
-
commands: { relativeDirPath: CopilotCommand.getSettablePaths().relativeDirPath },
|
|
7957
|
-
subagents: {
|
|
7958
|
-
relativeDirPath: CopilotSubagent.getSettablePaths().relativeDirPath
|
|
7959
|
-
},
|
|
7960
|
-
skills: {
|
|
7961
|
-
relativeDirPath: CopilotSkill.getSettablePaths().relativeDirPath
|
|
7962
|
-
}
|
|
7963
|
-
}) + rootRule.getFileContent()
|
|
7964
|
-
);
|
|
7965
|
-
return toolRules;
|
|
7966
|
-
}
|
|
7967
|
-
case "geminicli": {
|
|
7968
|
-
const rootRule = toolRules[rootRuleIndex];
|
|
7969
|
-
rootRule?.setFileContent(
|
|
7970
|
-
this.generateToonReferencesSection(toolRules) + this.generateAdditionalConventionsSection({
|
|
7971
|
-
commands: { relativeDirPath: GeminiCliCommand.getSettablePaths().relativeDirPath },
|
|
7972
|
-
subagents: {
|
|
7973
|
-
relativeDirPath: GeminiCliSubagent.getSettablePaths().relativeDirPath
|
|
7974
|
-
}
|
|
7975
|
-
}) + rootRule.getFileContent()
|
|
7976
|
-
);
|
|
7977
|
-
return toolRules;
|
|
7978
|
-
}
|
|
7979
|
-
case "kiro": {
|
|
7980
|
-
const rootRule = toolRules[rootRuleIndex];
|
|
7981
|
-
rootRule?.setFileContent(
|
|
7982
|
-
this.generateToonReferencesSection(toolRules) + rootRule.getFileContent()
|
|
7983
|
-
);
|
|
7984
|
-
return toolRules;
|
|
7985
|
-
}
|
|
7986
|
-
case "opencode": {
|
|
7987
|
-
const rootRule = toolRules[rootRuleIndex];
|
|
7988
|
-
rootRule?.setFileContent(
|
|
7989
|
-
this.generateToonReferencesSection(toolRules) + rootRule.getFileContent()
|
|
7990
|
-
);
|
|
7991
|
-
return toolRules;
|
|
7992
|
-
}
|
|
7993
|
-
case "qwencode": {
|
|
7994
|
-
const rootRule = toolRules[rootRuleIndex];
|
|
7995
|
-
rootRule?.setFileContent(
|
|
7996
|
-
this.generateToonReferencesSection(toolRules) + rootRule.getFileContent()
|
|
7997
|
-
);
|
|
7998
|
-
return toolRules;
|
|
7999
|
-
}
|
|
8000
|
-
case "warp": {
|
|
8001
|
-
const rootRule = toolRules[rootRuleIndex];
|
|
8002
|
-
rootRule?.setFileContent(
|
|
8003
|
-
this.generateToonReferencesSection(toolRules) + rootRule.getFileContent()
|
|
8004
|
-
);
|
|
8005
|
-
return toolRules;
|
|
8006
|
-
}
|
|
8333
|
+
const rootRule = toolRules[rootRuleIndex];
|
|
8334
|
+
if (!rootRule) {
|
|
8335
|
+
return toolRules;
|
|
8336
|
+
}
|
|
8337
|
+
const referenceSection = this.generateReferenceSectionFromMeta(meta, toolRules);
|
|
8338
|
+
const conventionsSection = !meta.createsSeparateConventionsRule && meta.additionalConventions ? this.generateAdditionalConventionsSectionFromMeta(meta) : "";
|
|
8339
|
+
const newContent = referenceSection + conventionsSection + rootRule.getFileContent();
|
|
8340
|
+
rootRule.setFileContent(newContent);
|
|
8341
|
+
return toolRules;
|
|
8342
|
+
}
|
|
8343
|
+
buildSkillList(skillClass) {
|
|
8344
|
+
if (!this.skills) return [];
|
|
8345
|
+
const toolRelativeDirPath = skillClass.getSettablePaths({
|
|
8346
|
+
global: this.global
|
|
8347
|
+
}).relativeDirPath;
|
|
8348
|
+
return this.skills.filter((skill) => skillClass.isTargetedByRulesyncSkill(skill)).map((skill) => {
|
|
8349
|
+
const frontmatter = skill.getFrontmatter();
|
|
8350
|
+
const relativePath = (0, import_node_path84.join)(toolRelativeDirPath, skill.getDirName(), SKILL_FILE_NAME);
|
|
8351
|
+
return {
|
|
8352
|
+
name: frontmatter.name,
|
|
8353
|
+
description: frontmatter.description,
|
|
8354
|
+
path: relativePath
|
|
8355
|
+
};
|
|
8356
|
+
});
|
|
8357
|
+
}
|
|
8358
|
+
/**
|
|
8359
|
+
* Generate reference section based on meta configuration.
|
|
8360
|
+
*/
|
|
8361
|
+
generateReferenceSectionFromMeta(meta, toolRules) {
|
|
8362
|
+
switch (meta.ruleDiscoveryMode) {
|
|
8363
|
+
case "toon":
|
|
8364
|
+
return this.generateToonReferencesSection(toolRules);
|
|
8365
|
+
case "claudecode-legacy":
|
|
8366
|
+
return this.generateReferencesSection(toolRules);
|
|
8367
|
+
case "auto":
|
|
8007
8368
|
default:
|
|
8008
|
-
return
|
|
8369
|
+
return "";
|
|
8370
|
+
}
|
|
8371
|
+
}
|
|
8372
|
+
/**
|
|
8373
|
+
* Generate additional conventions section based on meta configuration.
|
|
8374
|
+
*/
|
|
8375
|
+
generateAdditionalConventionsSectionFromMeta(meta) {
|
|
8376
|
+
const { additionalConventions } = meta;
|
|
8377
|
+
if (!additionalConventions) {
|
|
8378
|
+
return "";
|
|
8379
|
+
}
|
|
8380
|
+
const conventions = {};
|
|
8381
|
+
if (additionalConventions.commands) {
|
|
8382
|
+
const { commandClass } = additionalConventions.commands;
|
|
8383
|
+
const relativeDirPath = commandClass.getSettablePaths({
|
|
8384
|
+
global: this.global
|
|
8385
|
+
}).relativeDirPath;
|
|
8386
|
+
conventions.commands = { relativeDirPath };
|
|
8387
|
+
}
|
|
8388
|
+
if (additionalConventions.subagents) {
|
|
8389
|
+
const { subagentClass } = additionalConventions.subagents;
|
|
8390
|
+
const relativeDirPath = subagentClass.getSettablePaths({
|
|
8391
|
+
global: this.global
|
|
8392
|
+
}).relativeDirPath;
|
|
8393
|
+
conventions.subagents = { relativeDirPath };
|
|
8394
|
+
}
|
|
8395
|
+
if (additionalConventions.skills) {
|
|
8396
|
+
const { skillClass, globalOnly } = additionalConventions.skills;
|
|
8397
|
+
if (!globalOnly || this.global) {
|
|
8398
|
+
conventions.skills = {
|
|
8399
|
+
skillList: this.buildSkillList(skillClass)
|
|
8400
|
+
};
|
|
8401
|
+
}
|
|
8009
8402
|
}
|
|
8403
|
+
return this.generateAdditionalConventionsSection(conventions);
|
|
8010
8404
|
}
|
|
8011
8405
|
async convertToolFilesToRulesyncFiles(toolFiles) {
|
|
8012
8406
|
const toolRules = toolFiles.filter((file) => file instanceof ToolRule);
|
|
@@ -8020,10 +8414,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
8020
8414
|
* Load and parse rulesync rule files from .rulesync/rules/ directory
|
|
8021
8415
|
*/
|
|
8022
8416
|
async loadRulesyncFiles() {
|
|
8023
|
-
const files = await findFilesByGlobs((0,
|
|
8417
|
+
const files = await findFilesByGlobs((0, import_node_path84.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md"));
|
|
8024
8418
|
logger.debug(`Found ${files.length} rulesync files`);
|
|
8025
8419
|
const rulesyncRules = await Promise.all(
|
|
8026
|
-
files.map((file) => RulesyncRule.fromFile({ relativeFilePath: (0,
|
|
8420
|
+
files.map((file) => RulesyncRule.fromFile({ relativeFilePath: (0, import_node_path84.basename)(file) }))
|
|
8027
8421
|
);
|
|
8028
8422
|
const rootRules = rulesyncRules.filter((rule) => rule.getFrontmatter().root);
|
|
8029
8423
|
if (rootRules.length > 1) {
|
|
@@ -8041,10 +8435,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
8041
8435
|
return rulesyncRules;
|
|
8042
8436
|
}
|
|
8043
8437
|
async loadRulesyncFilesLegacy() {
|
|
8044
|
-
const legacyFiles = await findFilesByGlobs((0,
|
|
8438
|
+
const legacyFiles = await findFilesByGlobs((0, import_node_path84.join)(RULESYNC_RELATIVE_DIR_PATH, "*.md"));
|
|
8045
8439
|
logger.debug(`Found ${legacyFiles.length} legacy rulesync files`);
|
|
8046
8440
|
return Promise.all(
|
|
8047
|
-
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath: (0,
|
|
8441
|
+
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath: (0, import_node_path84.basename)(file) }))
|
|
8048
8442
|
);
|
|
8049
8443
|
}
|
|
8050
8444
|
/**
|
|
@@ -8062,7 +8456,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
8062
8456
|
return [];
|
|
8063
8457
|
}
|
|
8064
8458
|
const rootFilePaths = await findFilesByGlobs(
|
|
8065
|
-
(0,
|
|
8459
|
+
(0, import_node_path84.join)(
|
|
8066
8460
|
this.baseDir,
|
|
8067
8461
|
settablePaths.root.relativeDirPath ?? ".",
|
|
8068
8462
|
settablePaths.root.relativeFilePath
|
|
@@ -8072,7 +8466,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
8072
8466
|
rootFilePaths.map(
|
|
8073
8467
|
(filePath) => factory.class.fromFile({
|
|
8074
8468
|
baseDir: this.baseDir,
|
|
8075
|
-
relativeFilePath: (0,
|
|
8469
|
+
relativeFilePath: (0, import_node_path84.basename)(filePath),
|
|
8076
8470
|
global: this.global
|
|
8077
8471
|
})
|
|
8078
8472
|
)
|
|
@@ -8084,13 +8478,13 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
8084
8478
|
return [];
|
|
8085
8479
|
}
|
|
8086
8480
|
const nonRootFilePaths = await findFilesByGlobs(
|
|
8087
|
-
(0,
|
|
8481
|
+
(0, import_node_path84.join)(this.baseDir, settablePaths.nonRoot.relativeDirPath, `*.${factory.meta.extension}`)
|
|
8088
8482
|
);
|
|
8089
8483
|
return await Promise.all(
|
|
8090
8484
|
nonRootFilePaths.map(
|
|
8091
8485
|
(filePath) => factory.class.fromFile({
|
|
8092
8486
|
baseDir: this.baseDir,
|
|
8093
|
-
relativeFilePath: (0,
|
|
8487
|
+
relativeFilePath: (0, import_node_path84.basename)(filePath),
|
|
8094
8488
|
global: this.global
|
|
8095
8489
|
})
|
|
8096
8490
|
)
|
|
@@ -8183,23 +8577,15 @@ s/<command> [arguments]
|
|
|
8183
8577
|
This syntax employs a double slash (\`s/\`) to prevent conflicts with built-in slash commands.
|
|
8184
8578
|
The \`s\` in \`s/\` stands for *simulate*. Because custom slash commands are not built-in, this syntax provides a pseudo way to invoke them.
|
|
8185
8579
|
|
|
8186
|
-
When users call a custom slash command, you have to look for the markdown file, \`${(0,
|
|
8580
|
+
When users call a custom slash command, you have to look for the markdown file, \`${(0, import_node_path84.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "{command}.md")}\`, then execute the contents of that file as the block of operations.` : "";
|
|
8187
8581
|
const subagentsSection = subagents ? `## Simulated Subagents
|
|
8188
8582
|
|
|
8189
8583
|
Simulated subagents are specialized AI assistants that can be invoked to handle specific types of tasks. In this case, it can be appear something like custom slash commands simply. Simulated subagents can be called by custom slash commands.
|
|
8190
8584
|
|
|
8191
|
-
When users call a simulated subagent, it will look for the corresponding markdown file, \`${(0,
|
|
8585
|
+
When users call a simulated subagent, it will look for the corresponding markdown file, \`${(0, import_node_path84.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "{subagent}.md")}\`, and execute its contents as the block of operations.
|
|
8192
8586
|
|
|
8193
|
-
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${(0,
|
|
8194
|
-
const skillsSection = skills ?
|
|
8195
|
-
|
|
8196
|
-
Simulated skills are specialized capabilities that can be invoked to handle specific types of tasks.
|
|
8197
|
-
|
|
8198
|
-
When users invoke a simulated skill, look for the corresponding SKILL.md file in \`${(0, import_node_path83.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "{skill}/SKILL.md")}\` and execute its contents as the block of operations.
|
|
8199
|
-
|
|
8200
|
-
For example, if the user instructs \`Use the skill example-skill to achieve something\`, look for \`${(0, import_node_path83.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "example-skill/SKILL.md")}\` and execute its contents.
|
|
8201
|
-
|
|
8202
|
-
Additionally, you should proactively consider using available skills when they would help accomplish a task more effectively, even if the user doesn't explicitly request them.` : "";
|
|
8587
|
+
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${(0, import_node_path84.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "planner.md")}\`, and execute its contents as the block of operations.` : "";
|
|
8588
|
+
const skillsSection = skills ? this.generateSkillsSection(skills) : "";
|
|
8203
8589
|
const result = [
|
|
8204
8590
|
overview,
|
|
8205
8591
|
...this.simulateCommands && CommandsProcessor.getToolTargetsSimulated().includes(this.toolTarget) ? [commandsSection] : [],
|
|
@@ -8208,6 +8594,21 @@ Additionally, you should proactively consider using available skills when they w
|
|
|
8208
8594
|
].join("\n\n") + "\n\n";
|
|
8209
8595
|
return result;
|
|
8210
8596
|
}
|
|
8597
|
+
generateSkillsSection(skills) {
|
|
8598
|
+
if (!skills.skillList || skills.skillList.length === 0) {
|
|
8599
|
+
return "";
|
|
8600
|
+
}
|
|
8601
|
+
const skillListWithAtPrefix = skills.skillList.map((skill) => ({
|
|
8602
|
+
...skill,
|
|
8603
|
+
path: `@${skill.path}`
|
|
8604
|
+
}));
|
|
8605
|
+
const toonContent = (0, import_toon.encode)({ skillList: skillListWithAtPrefix });
|
|
8606
|
+
return `## Simulated Skills
|
|
8607
|
+
|
|
8608
|
+
Simulated skills are specialized capabilities that can be invoked to handle specific types of tasks. When you determine that a skill would be helpful for the current task, read the corresponding SKILL.md file and execute its instructions.
|
|
8609
|
+
|
|
8610
|
+
${toonContent}`;
|
|
8611
|
+
}
|
|
8211
8612
|
};
|
|
8212
8613
|
|
|
8213
8614
|
// src/cli/commands/generate.ts
|
|
@@ -8220,13 +8621,15 @@ async function generateCommand(options) {
|
|
|
8220
8621
|
process.exit(1);
|
|
8221
8622
|
}
|
|
8222
8623
|
logger.info(`Base directories: ${config.getBaseDirs().join(", ")}`);
|
|
8223
|
-
const totalRulesOutputs = await generateRules(config);
|
|
8224
8624
|
const totalIgnoreOutputs = await generateIgnore(config);
|
|
8225
8625
|
const totalMcpOutputs = await generateMcp(config);
|
|
8226
8626
|
const totalCommandOutputs = await generateCommands(config);
|
|
8227
8627
|
const totalSubagentOutputs = await generateSubagents(config);
|
|
8228
|
-
const
|
|
8229
|
-
const
|
|
8628
|
+
const skillsResult = await generateSkills(config);
|
|
8629
|
+
const totalRulesOutputs = await generateRules(config, {
|
|
8630
|
+
skills: skillsResult.skills
|
|
8631
|
+
});
|
|
8632
|
+
const totalGenerated = totalRulesOutputs + totalMcpOutputs + totalCommandOutputs + totalIgnoreOutputs + totalSubagentOutputs + skillsResult.totalOutputs;
|
|
8230
8633
|
if (totalGenerated === 0) {
|
|
8231
8634
|
const enabledFeatures = config.getFeatures().join(", ");
|
|
8232
8635
|
logger.warn(`\u26A0\uFE0F No files generated for enabled features: ${enabledFeatures}`);
|
|
@@ -8239,11 +8642,11 @@ async function generateCommand(options) {
|
|
|
8239
8642
|
if (totalMcpOutputs > 0) parts.push(`${totalMcpOutputs} MCP files`);
|
|
8240
8643
|
if (totalCommandOutputs > 0) parts.push(`${totalCommandOutputs} commands`);
|
|
8241
8644
|
if (totalSubagentOutputs > 0) parts.push(`${totalSubagentOutputs} subagents`);
|
|
8242
|
-
if (
|
|
8645
|
+
if (skillsResult.totalOutputs > 0) parts.push(`${skillsResult.totalOutputs} skills`);
|
|
8243
8646
|
logger.success(`\u{1F389} All done! Generated ${totalGenerated} file(s) total (${parts.join(" + ")})`);
|
|
8244
8647
|
}
|
|
8245
8648
|
}
|
|
8246
|
-
async function generateRules(config) {
|
|
8649
|
+
async function generateRules(config, options) {
|
|
8247
8650
|
if (!config.getFeatures().includes("rules")) {
|
|
8248
8651
|
logger.debug("Skipping rule generation (not in --features)");
|
|
8249
8652
|
return 0;
|
|
@@ -8262,7 +8665,8 @@ async function generateRules(config) {
|
|
|
8262
8665
|
global: config.getGlobal(),
|
|
8263
8666
|
simulateCommands: config.getSimulateCommands(),
|
|
8264
8667
|
simulateSubagents: config.getSimulateSubagents(),
|
|
8265
|
-
simulateSkills: config.getSimulateSkills()
|
|
8668
|
+
simulateSkills: config.getSimulateSkills(),
|
|
8669
|
+
skills: options?.skills
|
|
8266
8670
|
});
|
|
8267
8671
|
if (config.getDelete()) {
|
|
8268
8672
|
const oldToolFiles = await processor.loadToolFiles({ forDeletion: true });
|
|
@@ -8426,9 +8830,10 @@ async function generateSubagents(config) {
|
|
|
8426
8830
|
async function generateSkills(config) {
|
|
8427
8831
|
if (!config.getFeatures().includes("skills")) {
|
|
8428
8832
|
logger.debug("Skipping skill generation (not in --features)");
|
|
8429
|
-
return 0;
|
|
8833
|
+
return { totalOutputs: 0, skills: [] };
|
|
8430
8834
|
}
|
|
8431
8835
|
let totalSkillOutputs = 0;
|
|
8836
|
+
const allSkills = [];
|
|
8432
8837
|
logger.info("Generating skill files...");
|
|
8433
8838
|
const toolTargets = (0, import_es_toolkit2.intersection)(
|
|
8434
8839
|
config.getTargets(),
|
|
@@ -8449,112 +8854,164 @@ async function generateSkills(config) {
|
|
|
8449
8854
|
await processor.removeAiDirs(oldToolDirs);
|
|
8450
8855
|
}
|
|
8451
8856
|
const rulesyncDirs = await processor.loadRulesyncDirs();
|
|
8857
|
+
for (const rulesyncDir of rulesyncDirs) {
|
|
8858
|
+
if (rulesyncDir instanceof RulesyncSkill) {
|
|
8859
|
+
allSkills.push(rulesyncDir);
|
|
8860
|
+
}
|
|
8861
|
+
}
|
|
8452
8862
|
const toolDirs = await processor.convertRulesyncDirsToToolDirs(rulesyncDirs);
|
|
8453
8863
|
const writtenCount = await processor.writeAiDirs(toolDirs);
|
|
8454
8864
|
totalSkillOutputs += writtenCount;
|
|
8455
8865
|
logger.success(`Generated ${writtenCount} ${toolTarget} skill(s) in ${baseDir}`);
|
|
8456
8866
|
}
|
|
8457
8867
|
}
|
|
8458
|
-
return totalSkillOutputs;
|
|
8868
|
+
return { totalOutputs: totalSkillOutputs, skills: allSkills };
|
|
8459
8869
|
}
|
|
8460
8870
|
|
|
8461
8871
|
// src/cli/commands/gitignore.ts
|
|
8462
|
-
var
|
|
8872
|
+
var import_node_path85 = require("path");
|
|
8873
|
+
var RULESYNC_HEADER = "# Generated by Rulesync";
|
|
8874
|
+
var LEGACY_RULESYNC_HEADER = "# Generated by rulesync - AI tool configuration files";
|
|
8875
|
+
var RULESYNC_IGNORE_ENTRIES = [
|
|
8876
|
+
// AGENTS.md
|
|
8877
|
+
"**/AGENTS.md",
|
|
8878
|
+
"**/.agents/",
|
|
8879
|
+
// Amazon Q
|
|
8880
|
+
"**/.amazonq/",
|
|
8881
|
+
// Augment
|
|
8882
|
+
"**/.augmentignore",
|
|
8883
|
+
"**/.augment/rules/",
|
|
8884
|
+
"**/.augment-guidelines",
|
|
8885
|
+
// Claude Code
|
|
8886
|
+
"**/CLAUDE.md",
|
|
8887
|
+
"**/.claude/CLAUDE.md",
|
|
8888
|
+
"**/.claude/memories/",
|
|
8889
|
+
"**/.claude/rules/",
|
|
8890
|
+
"**/.claude/commands/",
|
|
8891
|
+
"**/.claude/agents/",
|
|
8892
|
+
"**/.claude/skills/",
|
|
8893
|
+
"**/.claude/settings.local.json",
|
|
8894
|
+
"**/.mcp.json",
|
|
8895
|
+
// Cline
|
|
8896
|
+
"**/.clinerules/",
|
|
8897
|
+
"**/.clineignore",
|
|
8898
|
+
"**/.cline/mcp.json",
|
|
8899
|
+
// Codex
|
|
8900
|
+
"**/.codexignore",
|
|
8901
|
+
"**/.codex/",
|
|
8902
|
+
"**/.codex/skills/",
|
|
8903
|
+
// Cursor
|
|
8904
|
+
"**/.cursor/",
|
|
8905
|
+
"**/.cursorignore",
|
|
8906
|
+
// Gemini
|
|
8907
|
+
"**/GEMINI.md",
|
|
8908
|
+
"**/.gemini/memories/",
|
|
8909
|
+
"**/.gemini/commands/",
|
|
8910
|
+
"**/.gemini/subagents/",
|
|
8911
|
+
"**/.gemini/skills/",
|
|
8912
|
+
"**/.geminiignore",
|
|
8913
|
+
// GitHub Copilot
|
|
8914
|
+
"**/.github/copilot-instructions.md",
|
|
8915
|
+
"**/.github/instructions/",
|
|
8916
|
+
"**/.github/prompts/",
|
|
8917
|
+
"**/.github/subagents/",
|
|
8918
|
+
"**/.github/skills/",
|
|
8919
|
+
"**/.vscode/mcp.json",
|
|
8920
|
+
// Junie
|
|
8921
|
+
"**/.junie/guidelines.md",
|
|
8922
|
+
"**/.junie/mcp.json",
|
|
8923
|
+
// Kiro
|
|
8924
|
+
"**/.kiro/steering/",
|
|
8925
|
+
"**/.aiignore",
|
|
8926
|
+
// OpenCode
|
|
8927
|
+
"**/.opencode/memories/",
|
|
8928
|
+
"**/.opencode/command/",
|
|
8929
|
+
"**/opencode.json",
|
|
8930
|
+
// Qwen
|
|
8931
|
+
"**/QWEN.md",
|
|
8932
|
+
"**/.qwen/memories/",
|
|
8933
|
+
// Roo
|
|
8934
|
+
"**/.roo/rules/",
|
|
8935
|
+
"**/.rooignore",
|
|
8936
|
+
"**/.roo/mcp.json",
|
|
8937
|
+
"**/.roo/subagents/",
|
|
8938
|
+
// Warp
|
|
8939
|
+
"**/.warp/",
|
|
8940
|
+
"**/WARP.md",
|
|
8941
|
+
// Others
|
|
8942
|
+
"**/modular-mcp.json",
|
|
8943
|
+
"!.rulesync/.aiignore"
|
|
8944
|
+
];
|
|
8945
|
+
var isRulesyncHeader = (line) => {
|
|
8946
|
+
const trimmed = line.trim();
|
|
8947
|
+
return trimmed === RULESYNC_HEADER || trimmed === LEGACY_RULESYNC_HEADER;
|
|
8948
|
+
};
|
|
8949
|
+
var isRulesyncEntry = (line) => {
|
|
8950
|
+
const trimmed = line.trim();
|
|
8951
|
+
if (trimmed === "" || isRulesyncHeader(line)) {
|
|
8952
|
+
return false;
|
|
8953
|
+
}
|
|
8954
|
+
return RULESYNC_IGNORE_ENTRIES.includes(trimmed);
|
|
8955
|
+
};
|
|
8956
|
+
var removeExistingRulesyncEntries = (content) => {
|
|
8957
|
+
const lines = content.split("\n");
|
|
8958
|
+
const filteredLines = [];
|
|
8959
|
+
let inRulesyncBlock = false;
|
|
8960
|
+
let consecutiveEmptyLines = 0;
|
|
8961
|
+
for (const line of lines) {
|
|
8962
|
+
const trimmed = line.trim();
|
|
8963
|
+
if (isRulesyncHeader(line)) {
|
|
8964
|
+
inRulesyncBlock = true;
|
|
8965
|
+
continue;
|
|
8966
|
+
}
|
|
8967
|
+
if (inRulesyncBlock) {
|
|
8968
|
+
if (trimmed === "") {
|
|
8969
|
+
consecutiveEmptyLines++;
|
|
8970
|
+
if (consecutiveEmptyLines >= 2) {
|
|
8971
|
+
inRulesyncBlock = false;
|
|
8972
|
+
consecutiveEmptyLines = 0;
|
|
8973
|
+
}
|
|
8974
|
+
continue;
|
|
8975
|
+
}
|
|
8976
|
+
if (isRulesyncEntry(line)) {
|
|
8977
|
+
consecutiveEmptyLines = 0;
|
|
8978
|
+
continue;
|
|
8979
|
+
}
|
|
8980
|
+
inRulesyncBlock = false;
|
|
8981
|
+
consecutiveEmptyLines = 0;
|
|
8982
|
+
}
|
|
8983
|
+
if (isRulesyncEntry(line)) {
|
|
8984
|
+
continue;
|
|
8985
|
+
}
|
|
8986
|
+
filteredLines.push(line);
|
|
8987
|
+
}
|
|
8988
|
+
let result = filteredLines.join("\n");
|
|
8989
|
+
while (result.endsWith("\n\n")) {
|
|
8990
|
+
result = result.slice(0, -1);
|
|
8991
|
+
}
|
|
8992
|
+
return result;
|
|
8993
|
+
};
|
|
8463
8994
|
var gitignoreCommand = async () => {
|
|
8464
|
-
const gitignorePath = (0,
|
|
8465
|
-
const rulesFilesToIgnore = [
|
|
8466
|
-
"# Generated by rulesync - AI tool configuration files",
|
|
8467
|
-
// AGENTS.md
|
|
8468
|
-
"**/AGENTS.md",
|
|
8469
|
-
"**/.agents/",
|
|
8470
|
-
// Amazon Q
|
|
8471
|
-
"**/.amazonq/",
|
|
8472
|
-
// Augment
|
|
8473
|
-
"**/.augmentignore",
|
|
8474
|
-
"**/.augment/rules/",
|
|
8475
|
-
"**/.augment-guidelines",
|
|
8476
|
-
// Claude Code
|
|
8477
|
-
"**/CLAUDE.md",
|
|
8478
|
-
"**/.claude/memories/",
|
|
8479
|
-
"**/.claude/commands/",
|
|
8480
|
-
"**/.claude/agents/",
|
|
8481
|
-
"**/.claude/skills/",
|
|
8482
|
-
"**/.claude/settings.local.json",
|
|
8483
|
-
"**/.mcp.json",
|
|
8484
|
-
// Cline
|
|
8485
|
-
"**/.clinerules/",
|
|
8486
|
-
"**/.clineignore",
|
|
8487
|
-
"**/.cline/mcp.json",
|
|
8488
|
-
// Codex
|
|
8489
|
-
"**/.codexignore",
|
|
8490
|
-
"**/.codex/",
|
|
8491
|
-
"**/.codex/skills/",
|
|
8492
|
-
// Cursor
|
|
8493
|
-
"**/.cursor/",
|
|
8494
|
-
"**/.cursorignore",
|
|
8495
|
-
// Gemini
|
|
8496
|
-
"**/GEMINI.md",
|
|
8497
|
-
"**/.gemini/memories/",
|
|
8498
|
-
"**/.gemini/commands/",
|
|
8499
|
-
"**/.gemini/subagents/",
|
|
8500
|
-
"**/.gemini/skills/",
|
|
8501
|
-
// GitHub Copilot
|
|
8502
|
-
"**/.github/copilot-instructions.md",
|
|
8503
|
-
"**/.github/instructions/",
|
|
8504
|
-
"**/.github/prompts/",
|
|
8505
|
-
"**/.github/subagents/",
|
|
8506
|
-
"**/.github/skills/",
|
|
8507
|
-
"**/.vscode/mcp.json",
|
|
8508
|
-
// Junie
|
|
8509
|
-
"**/.junie/guidelines.md",
|
|
8510
|
-
"**/.junie/mcp.json",
|
|
8511
|
-
// Kiro
|
|
8512
|
-
"**/.kiro/steering/",
|
|
8513
|
-
"**/.aiignore",
|
|
8514
|
-
// OpenCode
|
|
8515
|
-
"**/.opencode/memories/",
|
|
8516
|
-
"**/.opencode/command/",
|
|
8517
|
-
"**/opencode.json",
|
|
8518
|
-
// Qwen
|
|
8519
|
-
"**/QWEN.md",
|
|
8520
|
-
"**/.qwen/memories/",
|
|
8521
|
-
// Roo
|
|
8522
|
-
"**/.roo/rules/",
|
|
8523
|
-
"**/.rooignore",
|
|
8524
|
-
"**/.roo/mcp.json",
|
|
8525
|
-
"**/.roo/subagents/",
|
|
8526
|
-
// Warp
|
|
8527
|
-
"**/.warp/",
|
|
8528
|
-
"**/WARP.md",
|
|
8529
|
-
// Others
|
|
8530
|
-
"**/modular-mcp.json",
|
|
8531
|
-
"!.rulesync/.aiignore"
|
|
8532
|
-
];
|
|
8995
|
+
const gitignorePath = (0, import_node_path85.join)(process.cwd(), ".gitignore");
|
|
8533
8996
|
let gitignoreContent = "";
|
|
8534
8997
|
if (await fileExists(gitignorePath)) {
|
|
8535
8998
|
gitignoreContent = await readFileContent(gitignorePath);
|
|
8536
8999
|
}
|
|
8537
|
-
const
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
9000
|
+
const cleanedContent = removeExistingRulesyncEntries(gitignoreContent);
|
|
9001
|
+
const rulesyncBlock = [RULESYNC_HEADER, ...RULESYNC_IGNORE_ENTRIES].join("\n");
|
|
9002
|
+
const newContent = cleanedContent.trim() ? `${cleanedContent.trimEnd()}
|
|
9003
|
+
|
|
9004
|
+
${rulesyncBlock}
|
|
9005
|
+
` : `${rulesyncBlock}
|
|
9006
|
+
`;
|
|
9007
|
+
if (gitignoreContent === newContent) {
|
|
8544
9008
|
logger.success(".gitignore is already up to date");
|
|
8545
9009
|
return;
|
|
8546
9010
|
}
|
|
8547
|
-
const newContent = gitignoreContent ? `${gitignoreContent.trimEnd()}
|
|
8548
|
-
|
|
8549
|
-
${linesToAdd.join("\n")}
|
|
8550
|
-
` : `${linesToAdd.join("\n")}
|
|
8551
|
-
`;
|
|
8552
9011
|
await writeFileContent(gitignorePath, newContent);
|
|
8553
|
-
logger.success(
|
|
8554
|
-
for (const
|
|
8555
|
-
|
|
8556
|
-
logger.info(` ${line}`);
|
|
8557
|
-
}
|
|
9012
|
+
logger.success("Updated .gitignore with rulesync entries:");
|
|
9013
|
+
for (const entry of RULESYNC_IGNORE_ENTRIES) {
|
|
9014
|
+
logger.info(` ${entry}`);
|
|
8558
9015
|
}
|
|
8559
9016
|
};
|
|
8560
9017
|
|
|
@@ -8734,7 +9191,7 @@ async function importSkills(config, tool) {
|
|
|
8734
9191
|
}
|
|
8735
9192
|
|
|
8736
9193
|
// src/cli/commands/init.ts
|
|
8737
|
-
var
|
|
9194
|
+
var import_node_path86 = require("path");
|
|
8738
9195
|
async function initCommand() {
|
|
8739
9196
|
logger.info("Initializing rulesync...");
|
|
8740
9197
|
await ensureDir(RULESYNC_RELATIVE_DIR_PATH);
|
|
@@ -8897,14 +9354,14 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
8897
9354
|
await ensureDir(commandPaths.relativeDirPath);
|
|
8898
9355
|
await ensureDir(subagentPaths.relativeDirPath);
|
|
8899
9356
|
await ensureDir(ignorePaths.recommended.relativeDirPath);
|
|
8900
|
-
const ruleFilepath = (0,
|
|
9357
|
+
const ruleFilepath = (0, import_node_path86.join)(rulePaths.recommended.relativeDirPath, sampleRuleFile.filename);
|
|
8901
9358
|
if (!await fileExists(ruleFilepath)) {
|
|
8902
9359
|
await writeFileContent(ruleFilepath, sampleRuleFile.content);
|
|
8903
9360
|
logger.success(`Created ${ruleFilepath}`);
|
|
8904
9361
|
} else {
|
|
8905
9362
|
logger.info(`Skipped ${ruleFilepath} (already exists)`);
|
|
8906
9363
|
}
|
|
8907
|
-
const mcpFilepath = (0,
|
|
9364
|
+
const mcpFilepath = (0, import_node_path86.join)(
|
|
8908
9365
|
mcpPaths.recommended.relativeDirPath,
|
|
8909
9366
|
mcpPaths.recommended.relativeFilePath
|
|
8910
9367
|
);
|
|
@@ -8914,21 +9371,21 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
8914
9371
|
} else {
|
|
8915
9372
|
logger.info(`Skipped ${mcpFilepath} (already exists)`);
|
|
8916
9373
|
}
|
|
8917
|
-
const commandFilepath = (0,
|
|
9374
|
+
const commandFilepath = (0, import_node_path86.join)(commandPaths.relativeDirPath, sampleCommandFile.filename);
|
|
8918
9375
|
if (!await fileExists(commandFilepath)) {
|
|
8919
9376
|
await writeFileContent(commandFilepath, sampleCommandFile.content);
|
|
8920
9377
|
logger.success(`Created ${commandFilepath}`);
|
|
8921
9378
|
} else {
|
|
8922
9379
|
logger.info(`Skipped ${commandFilepath} (already exists)`);
|
|
8923
9380
|
}
|
|
8924
|
-
const subagentFilepath = (0,
|
|
9381
|
+
const subagentFilepath = (0, import_node_path86.join)(subagentPaths.relativeDirPath, sampleSubagentFile.filename);
|
|
8925
9382
|
if (!await fileExists(subagentFilepath)) {
|
|
8926
9383
|
await writeFileContent(subagentFilepath, sampleSubagentFile.content);
|
|
8927
9384
|
logger.success(`Created ${subagentFilepath}`);
|
|
8928
9385
|
} else {
|
|
8929
9386
|
logger.info(`Skipped ${subagentFilepath} (already exists)`);
|
|
8930
9387
|
}
|
|
8931
|
-
const ignoreFilepath = (0,
|
|
9388
|
+
const ignoreFilepath = (0, import_node_path86.join)(
|
|
8932
9389
|
ignorePaths.recommended.relativeDirPath,
|
|
8933
9390
|
ignorePaths.recommended.relativeFilePath
|
|
8934
9391
|
);
|
|
@@ -8944,12 +9401,12 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
8944
9401
|
var import_fastmcp = require("fastmcp");
|
|
8945
9402
|
|
|
8946
9403
|
// src/mcp/commands.ts
|
|
8947
|
-
var
|
|
8948
|
-
var
|
|
9404
|
+
var import_node_path87 = require("path");
|
|
9405
|
+
var import_mini34 = require("zod/mini");
|
|
8949
9406
|
var maxCommandSizeBytes = 1024 * 1024;
|
|
8950
9407
|
var maxCommandsCount = 1e3;
|
|
8951
9408
|
async function listCommands() {
|
|
8952
|
-
const commandsDir = (0,
|
|
9409
|
+
const commandsDir = (0, import_node_path87.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
8953
9410
|
try {
|
|
8954
9411
|
const files = await listDirectoryFiles(commandsDir);
|
|
8955
9412
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -8961,7 +9418,7 @@ async function listCommands() {
|
|
|
8961
9418
|
});
|
|
8962
9419
|
const frontmatter = command.getFrontmatter();
|
|
8963
9420
|
return {
|
|
8964
|
-
relativePathFromCwd: (0,
|
|
9421
|
+
relativePathFromCwd: (0, import_node_path87.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, file),
|
|
8965
9422
|
frontmatter
|
|
8966
9423
|
};
|
|
8967
9424
|
} catch (error) {
|
|
@@ -8981,13 +9438,13 @@ async function getCommand({ relativePathFromCwd }) {
|
|
|
8981
9438
|
relativePath: relativePathFromCwd,
|
|
8982
9439
|
intendedRootDir: process.cwd()
|
|
8983
9440
|
});
|
|
8984
|
-
const filename = (0,
|
|
9441
|
+
const filename = (0, import_node_path87.basename)(relativePathFromCwd);
|
|
8985
9442
|
try {
|
|
8986
9443
|
const command = await RulesyncCommand.fromFile({
|
|
8987
9444
|
relativeFilePath: filename
|
|
8988
9445
|
});
|
|
8989
9446
|
return {
|
|
8990
|
-
relativePathFromCwd: (0,
|
|
9447
|
+
relativePathFromCwd: (0, import_node_path87.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
8991
9448
|
frontmatter: command.getFrontmatter(),
|
|
8992
9449
|
body: command.getBody()
|
|
8993
9450
|
};
|
|
@@ -9006,7 +9463,7 @@ async function putCommand({
|
|
|
9006
9463
|
relativePath: relativePathFromCwd,
|
|
9007
9464
|
intendedRootDir: process.cwd()
|
|
9008
9465
|
});
|
|
9009
|
-
const filename = (0,
|
|
9466
|
+
const filename = (0, import_node_path87.basename)(relativePathFromCwd);
|
|
9010
9467
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
9011
9468
|
if (estimatedSize > maxCommandSizeBytes) {
|
|
9012
9469
|
throw new Error(
|
|
@@ -9016,7 +9473,7 @@ async function putCommand({
|
|
|
9016
9473
|
try {
|
|
9017
9474
|
const existingCommands = await listCommands();
|
|
9018
9475
|
const isUpdate = existingCommands.some(
|
|
9019
|
-
(command2) => command2.relativePathFromCwd === (0,
|
|
9476
|
+
(command2) => command2.relativePathFromCwd === (0, import_node_path87.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
9020
9477
|
);
|
|
9021
9478
|
if (!isUpdate && existingCommands.length >= maxCommandsCount) {
|
|
9022
9479
|
throw new Error(`Maximum number of commands (${maxCommandsCount}) reached`);
|
|
@@ -9031,11 +9488,11 @@ async function putCommand({
|
|
|
9031
9488
|
fileContent,
|
|
9032
9489
|
validate: true
|
|
9033
9490
|
});
|
|
9034
|
-
const commandsDir = (0,
|
|
9491
|
+
const commandsDir = (0, import_node_path87.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
9035
9492
|
await ensureDir(commandsDir);
|
|
9036
9493
|
await writeFileContent(command.getFilePath(), command.getFileContent());
|
|
9037
9494
|
return {
|
|
9038
|
-
relativePathFromCwd: (0,
|
|
9495
|
+
relativePathFromCwd: (0, import_node_path87.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
9039
9496
|
frontmatter: command.getFrontmatter(),
|
|
9040
9497
|
body: command.getBody()
|
|
9041
9498
|
};
|
|
@@ -9050,12 +9507,12 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
9050
9507
|
relativePath: relativePathFromCwd,
|
|
9051
9508
|
intendedRootDir: process.cwd()
|
|
9052
9509
|
});
|
|
9053
|
-
const filename = (0,
|
|
9054
|
-
const fullPath = (0,
|
|
9510
|
+
const filename = (0, import_node_path87.basename)(relativePathFromCwd);
|
|
9511
|
+
const fullPath = (0, import_node_path87.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename);
|
|
9055
9512
|
try {
|
|
9056
9513
|
await removeFile(fullPath);
|
|
9057
9514
|
return {
|
|
9058
|
-
relativePathFromCwd: (0,
|
|
9515
|
+
relativePathFromCwd: (0, import_node_path87.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
9059
9516
|
};
|
|
9060
9517
|
} catch (error) {
|
|
9061
9518
|
throw new Error(`Failed to delete command file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -9064,23 +9521,23 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
9064
9521
|
}
|
|
9065
9522
|
}
|
|
9066
9523
|
var commandToolSchemas = {
|
|
9067
|
-
listCommands:
|
|
9068
|
-
getCommand:
|
|
9069
|
-
relativePathFromCwd:
|
|
9524
|
+
listCommands: import_mini34.z.object({}),
|
|
9525
|
+
getCommand: import_mini34.z.object({
|
|
9526
|
+
relativePathFromCwd: import_mini34.z.string()
|
|
9070
9527
|
}),
|
|
9071
|
-
putCommand:
|
|
9072
|
-
relativePathFromCwd:
|
|
9528
|
+
putCommand: import_mini34.z.object({
|
|
9529
|
+
relativePathFromCwd: import_mini34.z.string(),
|
|
9073
9530
|
frontmatter: RulesyncCommandFrontmatterSchema,
|
|
9074
|
-
body:
|
|
9531
|
+
body: import_mini34.z.string()
|
|
9075
9532
|
}),
|
|
9076
|
-
deleteCommand:
|
|
9077
|
-
relativePathFromCwd:
|
|
9533
|
+
deleteCommand: import_mini34.z.object({
|
|
9534
|
+
relativePathFromCwd: import_mini34.z.string()
|
|
9078
9535
|
})
|
|
9079
9536
|
};
|
|
9080
9537
|
var commandTools = {
|
|
9081
9538
|
listCommands: {
|
|
9082
9539
|
name: "listCommands",
|
|
9083
|
-
description: `List all commands from ${(0,
|
|
9540
|
+
description: `List all commands from ${(0, import_node_path87.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
9084
9541
|
parameters: commandToolSchemas.listCommands,
|
|
9085
9542
|
execute: async () => {
|
|
9086
9543
|
const commands = await listCommands();
|
|
@@ -9122,11 +9579,11 @@ var commandTools = {
|
|
|
9122
9579
|
};
|
|
9123
9580
|
|
|
9124
9581
|
// src/mcp/ignore.ts
|
|
9125
|
-
var
|
|
9126
|
-
var
|
|
9582
|
+
var import_node_path88 = require("path");
|
|
9583
|
+
var import_mini35 = require("zod/mini");
|
|
9127
9584
|
var maxIgnoreFileSizeBytes = 100 * 1024;
|
|
9128
9585
|
async function getIgnoreFile() {
|
|
9129
|
-
const ignoreFilePath = (0,
|
|
9586
|
+
const ignoreFilePath = (0, import_node_path88.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
9130
9587
|
try {
|
|
9131
9588
|
const content = await readFileContent(ignoreFilePath);
|
|
9132
9589
|
return {
|
|
@@ -9140,7 +9597,7 @@ async function getIgnoreFile() {
|
|
|
9140
9597
|
}
|
|
9141
9598
|
}
|
|
9142
9599
|
async function putIgnoreFile({ content }) {
|
|
9143
|
-
const ignoreFilePath = (0,
|
|
9600
|
+
const ignoreFilePath = (0, import_node_path88.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
9144
9601
|
const contentSizeBytes = Buffer.byteLength(content, "utf8");
|
|
9145
9602
|
if (contentSizeBytes > maxIgnoreFileSizeBytes) {
|
|
9146
9603
|
throw new Error(
|
|
@@ -9161,8 +9618,8 @@ async function putIgnoreFile({ content }) {
|
|
|
9161
9618
|
}
|
|
9162
9619
|
}
|
|
9163
9620
|
async function deleteIgnoreFile() {
|
|
9164
|
-
const aiignorePath = (0,
|
|
9165
|
-
const legacyIgnorePath = (0,
|
|
9621
|
+
const aiignorePath = (0, import_node_path88.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
9622
|
+
const legacyIgnorePath = (0, import_node_path88.join)(process.cwd(), RULESYNC_IGNORE_RELATIVE_FILE_PATH);
|
|
9166
9623
|
try {
|
|
9167
9624
|
await Promise.all([removeFile(aiignorePath), removeFile(legacyIgnorePath)]);
|
|
9168
9625
|
return {
|
|
@@ -9180,11 +9637,11 @@ async function deleteIgnoreFile() {
|
|
|
9180
9637
|
}
|
|
9181
9638
|
}
|
|
9182
9639
|
var ignoreToolSchemas = {
|
|
9183
|
-
getIgnoreFile:
|
|
9184
|
-
putIgnoreFile:
|
|
9185
|
-
content:
|
|
9640
|
+
getIgnoreFile: import_mini35.z.object({}),
|
|
9641
|
+
putIgnoreFile: import_mini35.z.object({
|
|
9642
|
+
content: import_mini35.z.string()
|
|
9186
9643
|
}),
|
|
9187
|
-
deleteIgnoreFile:
|
|
9644
|
+
deleteIgnoreFile: import_mini35.z.object({})
|
|
9188
9645
|
};
|
|
9189
9646
|
var ignoreTools = {
|
|
9190
9647
|
getIgnoreFile: {
|
|
@@ -9217,8 +9674,8 @@ var ignoreTools = {
|
|
|
9217
9674
|
};
|
|
9218
9675
|
|
|
9219
9676
|
// src/mcp/mcp.ts
|
|
9220
|
-
var
|
|
9221
|
-
var
|
|
9677
|
+
var import_node_path89 = require("path");
|
|
9678
|
+
var import_mini36 = require("zod/mini");
|
|
9222
9679
|
var maxMcpSizeBytes = 1024 * 1024;
|
|
9223
9680
|
async function getMcpFile() {
|
|
9224
9681
|
const config = await ConfigResolver.resolve({});
|
|
@@ -9227,7 +9684,7 @@ async function getMcpFile() {
|
|
|
9227
9684
|
validate: true,
|
|
9228
9685
|
modularMcp: config.getModularMcp()
|
|
9229
9686
|
});
|
|
9230
|
-
const relativePathFromCwd = (0,
|
|
9687
|
+
const relativePathFromCwd = (0, import_node_path89.join)(
|
|
9231
9688
|
rulesyncMcp.getRelativeDirPath(),
|
|
9232
9689
|
rulesyncMcp.getRelativeFilePath()
|
|
9233
9690
|
);
|
|
@@ -9260,7 +9717,7 @@ async function putMcpFile({ content }) {
|
|
|
9260
9717
|
const paths = RulesyncMcp.getSettablePaths();
|
|
9261
9718
|
const relativeDirPath = paths.recommended.relativeDirPath;
|
|
9262
9719
|
const relativeFilePath = paths.recommended.relativeFilePath;
|
|
9263
|
-
const fullPath = (0,
|
|
9720
|
+
const fullPath = (0, import_node_path89.join)(baseDir, relativeDirPath, relativeFilePath);
|
|
9264
9721
|
const rulesyncMcp = new RulesyncMcp({
|
|
9265
9722
|
baseDir,
|
|
9266
9723
|
relativeDirPath,
|
|
@@ -9269,9 +9726,9 @@ async function putMcpFile({ content }) {
|
|
|
9269
9726
|
validate: true,
|
|
9270
9727
|
modularMcp: config.getModularMcp()
|
|
9271
9728
|
});
|
|
9272
|
-
await ensureDir((0,
|
|
9729
|
+
await ensureDir((0, import_node_path89.join)(baseDir, relativeDirPath));
|
|
9273
9730
|
await writeFileContent(fullPath, content);
|
|
9274
|
-
const relativePathFromCwd = (0,
|
|
9731
|
+
const relativePathFromCwd = (0, import_node_path89.join)(relativeDirPath, relativeFilePath);
|
|
9275
9732
|
return {
|
|
9276
9733
|
relativePathFromCwd,
|
|
9277
9734
|
content: rulesyncMcp.getFileContent()
|
|
@@ -9286,15 +9743,15 @@ async function deleteMcpFile() {
|
|
|
9286
9743
|
try {
|
|
9287
9744
|
const baseDir = process.cwd();
|
|
9288
9745
|
const paths = RulesyncMcp.getSettablePaths();
|
|
9289
|
-
const recommendedPath = (0,
|
|
9746
|
+
const recommendedPath = (0, import_node_path89.join)(
|
|
9290
9747
|
baseDir,
|
|
9291
9748
|
paths.recommended.relativeDirPath,
|
|
9292
9749
|
paths.recommended.relativeFilePath
|
|
9293
9750
|
);
|
|
9294
|
-
const legacyPath = (0,
|
|
9751
|
+
const legacyPath = (0, import_node_path89.join)(baseDir, paths.legacy.relativeDirPath, paths.legacy.relativeFilePath);
|
|
9295
9752
|
await removeFile(recommendedPath);
|
|
9296
9753
|
await removeFile(legacyPath);
|
|
9297
|
-
const relativePathFromCwd = (0,
|
|
9754
|
+
const relativePathFromCwd = (0, import_node_path89.join)(
|
|
9298
9755
|
paths.recommended.relativeDirPath,
|
|
9299
9756
|
paths.recommended.relativeFilePath
|
|
9300
9757
|
);
|
|
@@ -9308,11 +9765,11 @@ async function deleteMcpFile() {
|
|
|
9308
9765
|
}
|
|
9309
9766
|
}
|
|
9310
9767
|
var mcpToolSchemas = {
|
|
9311
|
-
getMcpFile:
|
|
9312
|
-
putMcpFile:
|
|
9313
|
-
content:
|
|
9768
|
+
getMcpFile: import_mini36.z.object({}),
|
|
9769
|
+
putMcpFile: import_mini36.z.object({
|
|
9770
|
+
content: import_mini36.z.string()
|
|
9314
9771
|
}),
|
|
9315
|
-
deleteMcpFile:
|
|
9772
|
+
deleteMcpFile: import_mini36.z.object({})
|
|
9316
9773
|
};
|
|
9317
9774
|
var mcpTools = {
|
|
9318
9775
|
getMcpFile: {
|
|
@@ -9345,12 +9802,12 @@ var mcpTools = {
|
|
|
9345
9802
|
};
|
|
9346
9803
|
|
|
9347
9804
|
// src/mcp/rules.ts
|
|
9348
|
-
var
|
|
9349
|
-
var
|
|
9805
|
+
var import_node_path90 = require("path");
|
|
9806
|
+
var import_mini37 = require("zod/mini");
|
|
9350
9807
|
var maxRuleSizeBytes = 1024 * 1024;
|
|
9351
9808
|
var maxRulesCount = 1e3;
|
|
9352
9809
|
async function listRules() {
|
|
9353
|
-
const rulesDir = (0,
|
|
9810
|
+
const rulesDir = (0, import_node_path90.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
9354
9811
|
try {
|
|
9355
9812
|
const files = await listDirectoryFiles(rulesDir);
|
|
9356
9813
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -9363,7 +9820,7 @@ async function listRules() {
|
|
|
9363
9820
|
});
|
|
9364
9821
|
const frontmatter = rule.getFrontmatter();
|
|
9365
9822
|
return {
|
|
9366
|
-
relativePathFromCwd: (0,
|
|
9823
|
+
relativePathFromCwd: (0, import_node_path90.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, file),
|
|
9367
9824
|
frontmatter
|
|
9368
9825
|
};
|
|
9369
9826
|
} catch (error) {
|
|
@@ -9383,14 +9840,14 @@ async function getRule({ relativePathFromCwd }) {
|
|
|
9383
9840
|
relativePath: relativePathFromCwd,
|
|
9384
9841
|
intendedRootDir: process.cwd()
|
|
9385
9842
|
});
|
|
9386
|
-
const filename = (0,
|
|
9843
|
+
const filename = (0, import_node_path90.basename)(relativePathFromCwd);
|
|
9387
9844
|
try {
|
|
9388
9845
|
const rule = await RulesyncRule.fromFile({
|
|
9389
9846
|
relativeFilePath: filename,
|
|
9390
9847
|
validate: true
|
|
9391
9848
|
});
|
|
9392
9849
|
return {
|
|
9393
|
-
relativePathFromCwd: (0,
|
|
9850
|
+
relativePathFromCwd: (0, import_node_path90.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
9394
9851
|
frontmatter: rule.getFrontmatter(),
|
|
9395
9852
|
body: rule.getBody()
|
|
9396
9853
|
};
|
|
@@ -9409,7 +9866,7 @@ async function putRule({
|
|
|
9409
9866
|
relativePath: relativePathFromCwd,
|
|
9410
9867
|
intendedRootDir: process.cwd()
|
|
9411
9868
|
});
|
|
9412
|
-
const filename = (0,
|
|
9869
|
+
const filename = (0, import_node_path90.basename)(relativePathFromCwd);
|
|
9413
9870
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
9414
9871
|
if (estimatedSize > maxRuleSizeBytes) {
|
|
9415
9872
|
throw new Error(
|
|
@@ -9419,7 +9876,7 @@ async function putRule({
|
|
|
9419
9876
|
try {
|
|
9420
9877
|
const existingRules = await listRules();
|
|
9421
9878
|
const isUpdate = existingRules.some(
|
|
9422
|
-
(rule2) => rule2.relativePathFromCwd === (0,
|
|
9879
|
+
(rule2) => rule2.relativePathFromCwd === (0, import_node_path90.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
9423
9880
|
);
|
|
9424
9881
|
if (!isUpdate && existingRules.length >= maxRulesCount) {
|
|
9425
9882
|
throw new Error(`Maximum number of rules (${maxRulesCount}) reached`);
|
|
@@ -9432,11 +9889,11 @@ async function putRule({
|
|
|
9432
9889
|
body,
|
|
9433
9890
|
validate: true
|
|
9434
9891
|
});
|
|
9435
|
-
const rulesDir = (0,
|
|
9892
|
+
const rulesDir = (0, import_node_path90.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
9436
9893
|
await ensureDir(rulesDir);
|
|
9437
9894
|
await writeFileContent(rule.getFilePath(), rule.getFileContent());
|
|
9438
9895
|
return {
|
|
9439
|
-
relativePathFromCwd: (0,
|
|
9896
|
+
relativePathFromCwd: (0, import_node_path90.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
9440
9897
|
frontmatter: rule.getFrontmatter(),
|
|
9441
9898
|
body: rule.getBody()
|
|
9442
9899
|
};
|
|
@@ -9451,12 +9908,12 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
9451
9908
|
relativePath: relativePathFromCwd,
|
|
9452
9909
|
intendedRootDir: process.cwd()
|
|
9453
9910
|
});
|
|
9454
|
-
const filename = (0,
|
|
9455
|
-
const fullPath = (0,
|
|
9911
|
+
const filename = (0, import_node_path90.basename)(relativePathFromCwd);
|
|
9912
|
+
const fullPath = (0, import_node_path90.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH, filename);
|
|
9456
9913
|
try {
|
|
9457
9914
|
await removeFile(fullPath);
|
|
9458
9915
|
return {
|
|
9459
|
-
relativePathFromCwd: (0,
|
|
9916
|
+
relativePathFromCwd: (0, import_node_path90.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
9460
9917
|
};
|
|
9461
9918
|
} catch (error) {
|
|
9462
9919
|
throw new Error(`Failed to delete rule file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -9465,23 +9922,23 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
9465
9922
|
}
|
|
9466
9923
|
}
|
|
9467
9924
|
var ruleToolSchemas = {
|
|
9468
|
-
listRules:
|
|
9469
|
-
getRule:
|
|
9470
|
-
relativePathFromCwd:
|
|
9925
|
+
listRules: import_mini37.z.object({}),
|
|
9926
|
+
getRule: import_mini37.z.object({
|
|
9927
|
+
relativePathFromCwd: import_mini37.z.string()
|
|
9471
9928
|
}),
|
|
9472
|
-
putRule:
|
|
9473
|
-
relativePathFromCwd:
|
|
9929
|
+
putRule: import_mini37.z.object({
|
|
9930
|
+
relativePathFromCwd: import_mini37.z.string(),
|
|
9474
9931
|
frontmatter: RulesyncRuleFrontmatterSchema,
|
|
9475
|
-
body:
|
|
9932
|
+
body: import_mini37.z.string()
|
|
9476
9933
|
}),
|
|
9477
|
-
deleteRule:
|
|
9478
|
-
relativePathFromCwd:
|
|
9934
|
+
deleteRule: import_mini37.z.object({
|
|
9935
|
+
relativePathFromCwd: import_mini37.z.string()
|
|
9479
9936
|
})
|
|
9480
9937
|
};
|
|
9481
9938
|
var ruleTools = {
|
|
9482
9939
|
listRules: {
|
|
9483
9940
|
name: "listRules",
|
|
9484
|
-
description: `List all rules from ${(0,
|
|
9941
|
+
description: `List all rules from ${(0, import_node_path90.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
9485
9942
|
parameters: ruleToolSchemas.listRules,
|
|
9486
9943
|
execute: async () => {
|
|
9487
9944
|
const rules = await listRules();
|
|
@@ -9523,8 +9980,8 @@ var ruleTools = {
|
|
|
9523
9980
|
};
|
|
9524
9981
|
|
|
9525
9982
|
// src/mcp/skills.ts
|
|
9526
|
-
var
|
|
9527
|
-
var
|
|
9983
|
+
var import_node_path91 = require("path");
|
|
9984
|
+
var import_mini38 = require("zod/mini");
|
|
9528
9985
|
var maxSkillSizeBytes = 1024 * 1024;
|
|
9529
9986
|
var maxSkillsCount = 1e3;
|
|
9530
9987
|
function aiDirFileToMcpSkillFile(file) {
|
|
@@ -9540,19 +9997,19 @@ function mcpSkillFileToAiDirFile(file) {
|
|
|
9540
9997
|
};
|
|
9541
9998
|
}
|
|
9542
9999
|
function extractDirName(relativeDirPathFromCwd) {
|
|
9543
|
-
const dirName = (0,
|
|
10000
|
+
const dirName = (0, import_node_path91.basename)(relativeDirPathFromCwd);
|
|
9544
10001
|
if (!dirName) {
|
|
9545
10002
|
throw new Error(`Invalid path: ${relativeDirPathFromCwd}`);
|
|
9546
10003
|
}
|
|
9547
10004
|
return dirName;
|
|
9548
10005
|
}
|
|
9549
10006
|
async function listSkills() {
|
|
9550
|
-
const skillsDir = (0,
|
|
10007
|
+
const skillsDir = (0, import_node_path91.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH);
|
|
9551
10008
|
try {
|
|
9552
|
-
const skillDirPaths = await findFilesByGlobs((0,
|
|
10009
|
+
const skillDirPaths = await findFilesByGlobs((0, import_node_path91.join)(skillsDir, "*"), { type: "dir" });
|
|
9553
10010
|
const skills = await Promise.all(
|
|
9554
10011
|
skillDirPaths.map(async (dirPath) => {
|
|
9555
|
-
const dirName = (0,
|
|
10012
|
+
const dirName = (0, import_node_path91.basename)(dirPath);
|
|
9556
10013
|
if (!dirName) return null;
|
|
9557
10014
|
try {
|
|
9558
10015
|
const skill = await RulesyncSkill.fromDir({
|
|
@@ -9560,7 +10017,7 @@ async function listSkills() {
|
|
|
9560
10017
|
});
|
|
9561
10018
|
const frontmatter = skill.getFrontmatter();
|
|
9562
10019
|
return {
|
|
9563
|
-
relativeDirPathFromCwd: (0,
|
|
10020
|
+
relativeDirPathFromCwd: (0, import_node_path91.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
9564
10021
|
frontmatter
|
|
9565
10022
|
};
|
|
9566
10023
|
} catch (error) {
|
|
@@ -9586,7 +10043,7 @@ async function getSkill({ relativeDirPathFromCwd }) {
|
|
|
9586
10043
|
dirName
|
|
9587
10044
|
});
|
|
9588
10045
|
return {
|
|
9589
|
-
relativeDirPathFromCwd: (0,
|
|
10046
|
+
relativeDirPathFromCwd: (0, import_node_path91.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
9590
10047
|
frontmatter: skill.getFrontmatter(),
|
|
9591
10048
|
body: skill.getBody(),
|
|
9592
10049
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -9620,7 +10077,7 @@ async function putSkill({
|
|
|
9620
10077
|
try {
|
|
9621
10078
|
const existingSkills = await listSkills();
|
|
9622
10079
|
const isUpdate = existingSkills.some(
|
|
9623
|
-
(skill2) => skill2.relativeDirPathFromCwd === (0,
|
|
10080
|
+
(skill2) => skill2.relativeDirPathFromCwd === (0, import_node_path91.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
9624
10081
|
);
|
|
9625
10082
|
if (!isUpdate && existingSkills.length >= maxSkillsCount) {
|
|
9626
10083
|
throw new Error(`Maximum number of skills (${maxSkillsCount}) reached`);
|
|
@@ -9635,9 +10092,9 @@ async function putSkill({
|
|
|
9635
10092
|
otherFiles: aiDirFiles,
|
|
9636
10093
|
validate: true
|
|
9637
10094
|
});
|
|
9638
|
-
const skillDirPath = (0,
|
|
10095
|
+
const skillDirPath = (0, import_node_path91.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
9639
10096
|
await ensureDir(skillDirPath);
|
|
9640
|
-
const skillFilePath = (0,
|
|
10097
|
+
const skillFilePath = (0, import_node_path91.join)(skillDirPath, SKILL_FILE_NAME);
|
|
9641
10098
|
const skillFileContent = stringifyFrontmatter(body, frontmatter);
|
|
9642
10099
|
await writeFileContent(skillFilePath, skillFileContent);
|
|
9643
10100
|
for (const file of otherFiles) {
|
|
@@ -9645,15 +10102,15 @@ async function putSkill({
|
|
|
9645
10102
|
relativePath: file.name,
|
|
9646
10103
|
intendedRootDir: skillDirPath
|
|
9647
10104
|
});
|
|
9648
|
-
const filePath = (0,
|
|
9649
|
-
const fileDir = (0,
|
|
10105
|
+
const filePath = (0, import_node_path91.join)(skillDirPath, file.name);
|
|
10106
|
+
const fileDir = (0, import_node_path91.join)(skillDirPath, (0, import_node_path91.dirname)(file.name));
|
|
9650
10107
|
if (fileDir !== skillDirPath) {
|
|
9651
10108
|
await ensureDir(fileDir);
|
|
9652
10109
|
}
|
|
9653
10110
|
await writeFileContent(filePath, file.body);
|
|
9654
10111
|
}
|
|
9655
10112
|
return {
|
|
9656
|
-
relativeDirPathFromCwd: (0,
|
|
10113
|
+
relativeDirPathFromCwd: (0, import_node_path91.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
9657
10114
|
frontmatter: skill.getFrontmatter(),
|
|
9658
10115
|
body: skill.getBody(),
|
|
9659
10116
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -9675,13 +10132,13 @@ async function deleteSkill({
|
|
|
9675
10132
|
intendedRootDir: process.cwd()
|
|
9676
10133
|
});
|
|
9677
10134
|
const dirName = extractDirName(relativeDirPathFromCwd);
|
|
9678
|
-
const skillDirPath = (0,
|
|
10135
|
+
const skillDirPath = (0, import_node_path91.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
9679
10136
|
try {
|
|
9680
10137
|
if (await directoryExists(skillDirPath)) {
|
|
9681
10138
|
await removeDirectory(skillDirPath);
|
|
9682
10139
|
}
|
|
9683
10140
|
return {
|
|
9684
|
-
relativeDirPathFromCwd: (0,
|
|
10141
|
+
relativeDirPathFromCwd: (0, import_node_path91.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
9685
10142
|
};
|
|
9686
10143
|
} catch (error) {
|
|
9687
10144
|
throw new Error(
|
|
@@ -9692,29 +10149,29 @@ async function deleteSkill({
|
|
|
9692
10149
|
);
|
|
9693
10150
|
}
|
|
9694
10151
|
}
|
|
9695
|
-
var McpSkillFileSchema =
|
|
9696
|
-
name:
|
|
9697
|
-
body:
|
|
10152
|
+
var McpSkillFileSchema = import_mini38.z.object({
|
|
10153
|
+
name: import_mini38.z.string(),
|
|
10154
|
+
body: import_mini38.z.string()
|
|
9698
10155
|
});
|
|
9699
10156
|
var skillToolSchemas = {
|
|
9700
|
-
listSkills:
|
|
9701
|
-
getSkill:
|
|
9702
|
-
relativeDirPathFromCwd:
|
|
10157
|
+
listSkills: import_mini38.z.object({}),
|
|
10158
|
+
getSkill: import_mini38.z.object({
|
|
10159
|
+
relativeDirPathFromCwd: import_mini38.z.string()
|
|
9703
10160
|
}),
|
|
9704
|
-
putSkill:
|
|
9705
|
-
relativeDirPathFromCwd:
|
|
10161
|
+
putSkill: import_mini38.z.object({
|
|
10162
|
+
relativeDirPathFromCwd: import_mini38.z.string(),
|
|
9706
10163
|
frontmatter: RulesyncSkillFrontmatterSchema,
|
|
9707
|
-
body:
|
|
9708
|
-
otherFiles:
|
|
10164
|
+
body: import_mini38.z.string(),
|
|
10165
|
+
otherFiles: import_mini38.z.optional(import_mini38.z.array(McpSkillFileSchema))
|
|
9709
10166
|
}),
|
|
9710
|
-
deleteSkill:
|
|
9711
|
-
relativeDirPathFromCwd:
|
|
10167
|
+
deleteSkill: import_mini38.z.object({
|
|
10168
|
+
relativeDirPathFromCwd: import_mini38.z.string()
|
|
9712
10169
|
})
|
|
9713
10170
|
};
|
|
9714
10171
|
var skillTools = {
|
|
9715
10172
|
listSkills: {
|
|
9716
10173
|
name: "listSkills",
|
|
9717
|
-
description: `List all skills from ${(0,
|
|
10174
|
+
description: `List all skills from ${(0, import_node_path91.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "*", SKILL_FILE_NAME)} with their frontmatter.`,
|
|
9718
10175
|
parameters: skillToolSchemas.listSkills,
|
|
9719
10176
|
execute: async () => {
|
|
9720
10177
|
const skills = await listSkills();
|
|
@@ -9757,12 +10214,12 @@ var skillTools = {
|
|
|
9757
10214
|
};
|
|
9758
10215
|
|
|
9759
10216
|
// src/mcp/subagents.ts
|
|
9760
|
-
var
|
|
9761
|
-
var
|
|
10217
|
+
var import_node_path92 = require("path");
|
|
10218
|
+
var import_mini39 = require("zod/mini");
|
|
9762
10219
|
var maxSubagentSizeBytes = 1024 * 1024;
|
|
9763
10220
|
var maxSubagentsCount = 1e3;
|
|
9764
10221
|
async function listSubagents() {
|
|
9765
|
-
const subagentsDir = (0,
|
|
10222
|
+
const subagentsDir = (0, import_node_path92.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
9766
10223
|
try {
|
|
9767
10224
|
const files = await listDirectoryFiles(subagentsDir);
|
|
9768
10225
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -9775,7 +10232,7 @@ async function listSubagents() {
|
|
|
9775
10232
|
});
|
|
9776
10233
|
const frontmatter = subagent.getFrontmatter();
|
|
9777
10234
|
return {
|
|
9778
|
-
relativePathFromCwd: (0,
|
|
10235
|
+
relativePathFromCwd: (0, import_node_path92.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, file),
|
|
9779
10236
|
frontmatter
|
|
9780
10237
|
};
|
|
9781
10238
|
} catch (error) {
|
|
@@ -9797,14 +10254,14 @@ async function getSubagent({ relativePathFromCwd }) {
|
|
|
9797
10254
|
relativePath: relativePathFromCwd,
|
|
9798
10255
|
intendedRootDir: process.cwd()
|
|
9799
10256
|
});
|
|
9800
|
-
const filename = (0,
|
|
10257
|
+
const filename = (0, import_node_path92.basename)(relativePathFromCwd);
|
|
9801
10258
|
try {
|
|
9802
10259
|
const subagent = await RulesyncSubagent.fromFile({
|
|
9803
10260
|
relativeFilePath: filename,
|
|
9804
10261
|
validate: true
|
|
9805
10262
|
});
|
|
9806
10263
|
return {
|
|
9807
|
-
relativePathFromCwd: (0,
|
|
10264
|
+
relativePathFromCwd: (0, import_node_path92.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
9808
10265
|
frontmatter: subagent.getFrontmatter(),
|
|
9809
10266
|
body: subagent.getBody()
|
|
9810
10267
|
};
|
|
@@ -9823,7 +10280,7 @@ async function putSubagent({
|
|
|
9823
10280
|
relativePath: relativePathFromCwd,
|
|
9824
10281
|
intendedRootDir: process.cwd()
|
|
9825
10282
|
});
|
|
9826
|
-
const filename = (0,
|
|
10283
|
+
const filename = (0, import_node_path92.basename)(relativePathFromCwd);
|
|
9827
10284
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
9828
10285
|
if (estimatedSize > maxSubagentSizeBytes) {
|
|
9829
10286
|
throw new Error(
|
|
@@ -9833,7 +10290,7 @@ async function putSubagent({
|
|
|
9833
10290
|
try {
|
|
9834
10291
|
const existingSubagents = await listSubagents();
|
|
9835
10292
|
const isUpdate = existingSubagents.some(
|
|
9836
|
-
(subagent2) => subagent2.relativePathFromCwd === (0,
|
|
10293
|
+
(subagent2) => subagent2.relativePathFromCwd === (0, import_node_path92.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
9837
10294
|
);
|
|
9838
10295
|
if (!isUpdate && existingSubagents.length >= maxSubagentsCount) {
|
|
9839
10296
|
throw new Error(`Maximum number of subagents (${maxSubagentsCount}) reached`);
|
|
@@ -9846,11 +10303,11 @@ async function putSubagent({
|
|
|
9846
10303
|
body,
|
|
9847
10304
|
validate: true
|
|
9848
10305
|
});
|
|
9849
|
-
const subagentsDir = (0,
|
|
10306
|
+
const subagentsDir = (0, import_node_path92.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
9850
10307
|
await ensureDir(subagentsDir);
|
|
9851
10308
|
await writeFileContent(subagent.getFilePath(), subagent.getFileContent());
|
|
9852
10309
|
return {
|
|
9853
|
-
relativePathFromCwd: (0,
|
|
10310
|
+
relativePathFromCwd: (0, import_node_path92.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
9854
10311
|
frontmatter: subagent.getFrontmatter(),
|
|
9855
10312
|
body: subagent.getBody()
|
|
9856
10313
|
};
|
|
@@ -9865,12 +10322,12 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
9865
10322
|
relativePath: relativePathFromCwd,
|
|
9866
10323
|
intendedRootDir: process.cwd()
|
|
9867
10324
|
});
|
|
9868
|
-
const filename = (0,
|
|
9869
|
-
const fullPath = (0,
|
|
10325
|
+
const filename = (0, import_node_path92.basename)(relativePathFromCwd);
|
|
10326
|
+
const fullPath = (0, import_node_path92.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename);
|
|
9870
10327
|
try {
|
|
9871
10328
|
await removeFile(fullPath);
|
|
9872
10329
|
return {
|
|
9873
|
-
relativePathFromCwd: (0,
|
|
10330
|
+
relativePathFromCwd: (0, import_node_path92.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
9874
10331
|
};
|
|
9875
10332
|
} catch (error) {
|
|
9876
10333
|
throw new Error(
|
|
@@ -9882,23 +10339,23 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
9882
10339
|
}
|
|
9883
10340
|
}
|
|
9884
10341
|
var subagentToolSchemas = {
|
|
9885
|
-
listSubagents:
|
|
9886
|
-
getSubagent:
|
|
9887
|
-
relativePathFromCwd:
|
|
10342
|
+
listSubagents: import_mini39.z.object({}),
|
|
10343
|
+
getSubagent: import_mini39.z.object({
|
|
10344
|
+
relativePathFromCwd: import_mini39.z.string()
|
|
9888
10345
|
}),
|
|
9889
|
-
putSubagent:
|
|
9890
|
-
relativePathFromCwd:
|
|
10346
|
+
putSubagent: import_mini39.z.object({
|
|
10347
|
+
relativePathFromCwd: import_mini39.z.string(),
|
|
9891
10348
|
frontmatter: RulesyncSubagentFrontmatterSchema,
|
|
9892
|
-
body:
|
|
10349
|
+
body: import_mini39.z.string()
|
|
9893
10350
|
}),
|
|
9894
|
-
deleteSubagent:
|
|
9895
|
-
relativePathFromCwd:
|
|
10351
|
+
deleteSubagent: import_mini39.z.object({
|
|
10352
|
+
relativePathFromCwd: import_mini39.z.string()
|
|
9896
10353
|
})
|
|
9897
10354
|
};
|
|
9898
10355
|
var subagentTools = {
|
|
9899
10356
|
listSubagents: {
|
|
9900
10357
|
name: "listSubagents",
|
|
9901
|
-
description: `List all subagents from ${(0,
|
|
10358
|
+
description: `List all subagents from ${(0, import_node_path92.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
9902
10359
|
parameters: subagentToolSchemas.listSubagents,
|
|
9903
10360
|
execute: async () => {
|
|
9904
10361
|
const subagents = await listSubagents();
|
|
@@ -9976,7 +10433,7 @@ async function mcpCommand({ version }) {
|
|
|
9976
10433
|
}
|
|
9977
10434
|
|
|
9978
10435
|
// src/cli/index.ts
|
|
9979
|
-
var getVersion = () => "3.
|
|
10436
|
+
var getVersion = () => "3.33.0";
|
|
9980
10437
|
var main = async () => {
|
|
9981
10438
|
const program = new import_commander.Command();
|
|
9982
10439
|
const version = getVersion();
|