rulesync 3.30.0 → 3.32.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 +37 -2
- package/dist/index.cjs +1177 -732
- package/dist/index.js +1173 -728
- package/package.json +7 -7
package/dist/index.js
CHANGED
|
@@ -229,17 +229,18 @@ var ALL_TOOL_TARGETS = [
|
|
|
229
229
|
"antigravity",
|
|
230
230
|
"augmentcode",
|
|
231
231
|
"augmentcode-legacy",
|
|
232
|
-
"copilot",
|
|
233
|
-
"cursor",
|
|
234
|
-
"cline",
|
|
235
232
|
"claudecode",
|
|
233
|
+
"claudecode-legacy",
|
|
234
|
+
"cline",
|
|
236
235
|
"codexcli",
|
|
236
|
+
"copilot",
|
|
237
|
+
"cursor",
|
|
238
|
+
"geminicli",
|
|
239
|
+
"junie",
|
|
240
|
+
"kiro",
|
|
237
241
|
"opencode",
|
|
238
242
|
"qwencode",
|
|
239
243
|
"roo",
|
|
240
|
-
"geminicli",
|
|
241
|
-
"kiro",
|
|
242
|
-
"junie",
|
|
243
244
|
"warp",
|
|
244
245
|
"windsurf"
|
|
245
246
|
];
|
|
@@ -272,6 +273,11 @@ var ConfigFileSchema = z3.object({
|
|
|
272
273
|
...z3.partial(ConfigParamsSchema).shape
|
|
273
274
|
});
|
|
274
275
|
var RequiredConfigParamsSchema = z3.required(ConfigParamsSchema);
|
|
276
|
+
var CONFLICTING_TARGET_PAIRS = [
|
|
277
|
+
["augmentcode", "augmentcode-legacy"],
|
|
278
|
+
["claudecode", "claudecode-legacy"]
|
|
279
|
+
];
|
|
280
|
+
var LEGACY_TARGETS = ["augmentcode-legacy", "claudecode-legacy"];
|
|
275
281
|
var Config = class {
|
|
276
282
|
baseDirs;
|
|
277
283
|
targets;
|
|
@@ -298,6 +304,7 @@ var Config = class {
|
|
|
298
304
|
experimentalSimulateCommands,
|
|
299
305
|
experimentalSimulateSubagents
|
|
300
306
|
}) {
|
|
307
|
+
this.validateConflictingTargets(targets);
|
|
301
308
|
this.baseDirs = baseDirs;
|
|
302
309
|
this.targets = targets;
|
|
303
310
|
this.features = features;
|
|
@@ -309,12 +316,26 @@ var Config = class {
|
|
|
309
316
|
this.simulateSkills = simulateSkills ?? false;
|
|
310
317
|
this.modularMcp = modularMcp ?? false;
|
|
311
318
|
}
|
|
319
|
+
validateConflictingTargets(targets) {
|
|
320
|
+
for (const [target1, target2] of CONFLICTING_TARGET_PAIRS) {
|
|
321
|
+
const hasTarget1 = targets.includes(target1);
|
|
322
|
+
const hasTarget2 = targets.includes(target2);
|
|
323
|
+
if (hasTarget1 && hasTarget2) {
|
|
324
|
+
throw new Error(
|
|
325
|
+
`Conflicting targets: '${target1}' and '${target2}' cannot be used together. Please choose one.`
|
|
326
|
+
);
|
|
327
|
+
}
|
|
328
|
+
}
|
|
329
|
+
}
|
|
312
330
|
getBaseDirs() {
|
|
313
331
|
return this.baseDirs;
|
|
314
332
|
}
|
|
315
333
|
getTargets() {
|
|
316
334
|
if (this.targets.includes("*")) {
|
|
317
|
-
return
|
|
335
|
+
return ALL_TOOL_TARGETS.filter(
|
|
336
|
+
// eslint-disable-next-line no-type-assertion/no-type-assertion
|
|
337
|
+
(target) => !LEGACY_TARGETS.includes(target)
|
|
338
|
+
);
|
|
318
339
|
}
|
|
319
340
|
return this.targets.filter((target) => target !== "*");
|
|
320
341
|
}
|
|
@@ -4214,20 +4235,21 @@ var McpProcessor = class extends FeatureProcessor {
|
|
|
4214
4235
|
};
|
|
4215
4236
|
|
|
4216
4237
|
// src/features/rules/rules-processor.ts
|
|
4217
|
-
import { basename as basename21, join as
|
|
4218
|
-
import {
|
|
4219
|
-
import { z as
|
|
4238
|
+
import { basename as basename21, join as join82 } from "path";
|
|
4239
|
+
import { encode } from "@toon-format/toon";
|
|
4240
|
+
import { z as z33 } from "zod/mini";
|
|
4220
4241
|
|
|
4221
4242
|
// src/features/skills/codexcli-skill.ts
|
|
4222
|
-
import { join as
|
|
4223
|
-
|
|
4224
|
-
// src/features/skills/simulated-skill.ts
|
|
4225
|
-
import { join as join40 } from "path";
|
|
4226
|
-
import { z as z19 } from "zod/mini";
|
|
4243
|
+
import { join as join42 } from "path";
|
|
4244
|
+
import { z as z20 } from "zod/mini";
|
|
4227
4245
|
|
|
4228
4246
|
// src/constants/general.ts
|
|
4229
4247
|
var SKILL_FILE_NAME = "SKILL.md";
|
|
4230
4248
|
|
|
4249
|
+
// src/features/skills/rulesync-skill.ts
|
|
4250
|
+
import { join as join40 } from "path";
|
|
4251
|
+
import { z as z19 } from "zod/mini";
|
|
4252
|
+
|
|
4231
4253
|
// src/types/ai-dir.ts
|
|
4232
4254
|
import path2, { basename as basename14, join as join39, relative as relative3, resolve as resolve4 } from "path";
|
|
4233
4255
|
var AiDir = class {
|
|
@@ -4340,7 +4362,113 @@ var AiDir = class {
|
|
|
4340
4362
|
}
|
|
4341
4363
|
};
|
|
4342
4364
|
|
|
4365
|
+
// src/features/skills/rulesync-skill.ts
|
|
4366
|
+
var RulesyncSkillFrontmatterSchemaInternal = z19.object({
|
|
4367
|
+
name: z19.string(),
|
|
4368
|
+
description: z19.string(),
|
|
4369
|
+
targets: z19._default(RulesyncTargetsSchema, ["*"]),
|
|
4370
|
+
claudecode: z19.optional(
|
|
4371
|
+
z19.object({
|
|
4372
|
+
"allowed-tools": z19.optional(z19.array(z19.string()))
|
|
4373
|
+
})
|
|
4374
|
+
)
|
|
4375
|
+
});
|
|
4376
|
+
var RulesyncSkillFrontmatterSchema = RulesyncSkillFrontmatterSchemaInternal;
|
|
4377
|
+
var RulesyncSkill = class _RulesyncSkill extends AiDir {
|
|
4378
|
+
constructor({
|
|
4379
|
+
baseDir = process.cwd(),
|
|
4380
|
+
relativeDirPath = RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
4381
|
+
dirName,
|
|
4382
|
+
frontmatter,
|
|
4383
|
+
body,
|
|
4384
|
+
otherFiles = [],
|
|
4385
|
+
validate = true,
|
|
4386
|
+
global = false
|
|
4387
|
+
}) {
|
|
4388
|
+
super({
|
|
4389
|
+
baseDir,
|
|
4390
|
+
relativeDirPath,
|
|
4391
|
+
dirName,
|
|
4392
|
+
mainFile: {
|
|
4393
|
+
name: SKILL_FILE_NAME,
|
|
4394
|
+
body,
|
|
4395
|
+
frontmatter: { ...frontmatter }
|
|
4396
|
+
},
|
|
4397
|
+
otherFiles,
|
|
4398
|
+
global
|
|
4399
|
+
});
|
|
4400
|
+
if (validate) {
|
|
4401
|
+
const result = this.validate();
|
|
4402
|
+
if (!result.success) {
|
|
4403
|
+
throw result.error;
|
|
4404
|
+
}
|
|
4405
|
+
}
|
|
4406
|
+
}
|
|
4407
|
+
static getSettablePaths() {
|
|
4408
|
+
return {
|
|
4409
|
+
relativeDirPath: RULESYNC_SKILLS_RELATIVE_DIR_PATH
|
|
4410
|
+
};
|
|
4411
|
+
}
|
|
4412
|
+
getFrontmatter() {
|
|
4413
|
+
if (!this.mainFile?.frontmatter) {
|
|
4414
|
+
throw new Error("Frontmatter is not defined");
|
|
4415
|
+
}
|
|
4416
|
+
const result = RulesyncSkillFrontmatterSchema.parse(this.mainFile.frontmatter);
|
|
4417
|
+
return result;
|
|
4418
|
+
}
|
|
4419
|
+
getBody() {
|
|
4420
|
+
return this.mainFile?.body ?? "";
|
|
4421
|
+
}
|
|
4422
|
+
validate() {
|
|
4423
|
+
const result = RulesyncSkillFrontmatterSchema.safeParse(this.mainFile?.frontmatter);
|
|
4424
|
+
if (!result.success) {
|
|
4425
|
+
return {
|
|
4426
|
+
success: false,
|
|
4427
|
+
error: new Error(
|
|
4428
|
+
`Invalid frontmatter in ${this.getDirPath()}: ${formatError(result.error)}`
|
|
4429
|
+
)
|
|
4430
|
+
};
|
|
4431
|
+
}
|
|
4432
|
+
return { success: true, error: null };
|
|
4433
|
+
}
|
|
4434
|
+
static async fromDir({
|
|
4435
|
+
baseDir = process.cwd(),
|
|
4436
|
+
relativeDirPath = RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
4437
|
+
dirName,
|
|
4438
|
+
global = false
|
|
4439
|
+
}) {
|
|
4440
|
+
const skillDirPath = join40(baseDir, relativeDirPath, dirName);
|
|
4441
|
+
const skillFilePath = join40(skillDirPath, SKILL_FILE_NAME);
|
|
4442
|
+
if (!await fileExists(skillFilePath)) {
|
|
4443
|
+
throw new Error(`${SKILL_FILE_NAME} not found in ${skillDirPath}`);
|
|
4444
|
+
}
|
|
4445
|
+
const fileContent = await readFileContent(skillFilePath);
|
|
4446
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
4447
|
+
const result = RulesyncSkillFrontmatterSchema.safeParse(frontmatter);
|
|
4448
|
+
if (!result.success) {
|
|
4449
|
+
throw new Error(`Invalid frontmatter in ${skillFilePath}: ${formatError(result.error)}`);
|
|
4450
|
+
}
|
|
4451
|
+
const otherFiles = await this.collectOtherFiles(
|
|
4452
|
+
baseDir,
|
|
4453
|
+
relativeDirPath,
|
|
4454
|
+
dirName,
|
|
4455
|
+
SKILL_FILE_NAME
|
|
4456
|
+
);
|
|
4457
|
+
return new _RulesyncSkill({
|
|
4458
|
+
baseDir,
|
|
4459
|
+
relativeDirPath,
|
|
4460
|
+
dirName,
|
|
4461
|
+
frontmatter: result.data,
|
|
4462
|
+
body: content.trim(),
|
|
4463
|
+
otherFiles,
|
|
4464
|
+
validate: true,
|
|
4465
|
+
global
|
|
4466
|
+
});
|
|
4467
|
+
}
|
|
4468
|
+
};
|
|
4469
|
+
|
|
4343
4470
|
// src/features/skills/tool-skill.ts
|
|
4471
|
+
import { join as join41 } from "path";
|
|
4344
4472
|
var ToolSkill = class extends AiDir {
|
|
4345
4473
|
/**
|
|
4346
4474
|
* Get the settable paths for this tool's skill directories.
|
|
@@ -4394,24 +4522,66 @@ var ToolSkill = class extends AiDir {
|
|
|
4394
4522
|
static isTargetedByRulesyncSkill(_rulesyncSkill) {
|
|
4395
4523
|
throw new Error("Please implement this method in the subclass.");
|
|
4396
4524
|
}
|
|
4525
|
+
/**
|
|
4526
|
+
* Load and parse skill directory content.
|
|
4527
|
+
* This is a helper method that handles the common logic of reading SKILL.md,
|
|
4528
|
+
* parsing frontmatter, and collecting other files.
|
|
4529
|
+
*
|
|
4530
|
+
* Subclasses should call this method and then validate the frontmatter
|
|
4531
|
+
* against their specific schema.
|
|
4532
|
+
*
|
|
4533
|
+
* @param params - Parameters including settablePaths callback to get tool-specific paths
|
|
4534
|
+
* @returns Parsed skill directory content
|
|
4535
|
+
*/
|
|
4536
|
+
static async loadSkillDirContent({
|
|
4537
|
+
baseDir = process.cwd(),
|
|
4538
|
+
relativeDirPath,
|
|
4539
|
+
dirName,
|
|
4540
|
+
global = false,
|
|
4541
|
+
getSettablePaths
|
|
4542
|
+
}) {
|
|
4543
|
+
const settablePaths = getSettablePaths({ global });
|
|
4544
|
+
const actualRelativeDirPath = relativeDirPath ?? settablePaths.relativeDirPath;
|
|
4545
|
+
const skillDirPath = join41(baseDir, actualRelativeDirPath, dirName);
|
|
4546
|
+
const skillFilePath = join41(skillDirPath, SKILL_FILE_NAME);
|
|
4547
|
+
if (!await fileExists(skillFilePath)) {
|
|
4548
|
+
throw new Error(`${SKILL_FILE_NAME} not found in ${skillDirPath}`);
|
|
4549
|
+
}
|
|
4550
|
+
const fileContent = await readFileContent(skillFilePath);
|
|
4551
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
4552
|
+
const otherFiles = await this.collectOtherFiles(
|
|
4553
|
+
baseDir,
|
|
4554
|
+
actualRelativeDirPath,
|
|
4555
|
+
dirName,
|
|
4556
|
+
SKILL_FILE_NAME
|
|
4557
|
+
);
|
|
4558
|
+
return {
|
|
4559
|
+
baseDir,
|
|
4560
|
+
relativeDirPath: actualRelativeDirPath,
|
|
4561
|
+
dirName,
|
|
4562
|
+
frontmatter,
|
|
4563
|
+
body: content.trim(),
|
|
4564
|
+
otherFiles,
|
|
4565
|
+
global
|
|
4566
|
+
};
|
|
4567
|
+
}
|
|
4397
4568
|
};
|
|
4398
4569
|
|
|
4399
|
-
// src/features/skills/
|
|
4400
|
-
var
|
|
4401
|
-
name:
|
|
4402
|
-
description:
|
|
4570
|
+
// src/features/skills/codexcli-skill.ts
|
|
4571
|
+
var CodexCliSkillFrontmatterSchema = z20.object({
|
|
4572
|
+
name: z20.string(),
|
|
4573
|
+
description: z20.string()
|
|
4403
4574
|
});
|
|
4404
|
-
var
|
|
4405
|
-
frontmatter;
|
|
4406
|
-
body;
|
|
4575
|
+
var CodexCliSkill = class _CodexCliSkill extends ToolSkill {
|
|
4407
4576
|
constructor({
|
|
4408
4577
|
baseDir = process.cwd(),
|
|
4409
|
-
relativeDirPath,
|
|
4578
|
+
relativeDirPath = join42(".codex", "skills"),
|
|
4410
4579
|
dirName,
|
|
4411
4580
|
frontmatter,
|
|
4412
4581
|
body,
|
|
4413
4582
|
otherFiles = [],
|
|
4414
|
-
validate = true
|
|
4583
|
+
validate = true,
|
|
4584
|
+
global = false
|
|
4415
4585
|
}) {
|
|
4416
4586
|
super({
|
|
4417
4587
|
baseDir,
|
|
@@ -4423,37 +4593,42 @@ var SimulatedSkill = class extends ToolSkill {
|
|
|
4423
4593
|
frontmatter: { ...frontmatter }
|
|
4424
4594
|
},
|
|
4425
4595
|
otherFiles,
|
|
4426
|
-
global
|
|
4427
|
-
// Simulated skills are project mode only
|
|
4596
|
+
global
|
|
4428
4597
|
});
|
|
4429
4598
|
if (validate) {
|
|
4430
|
-
const result =
|
|
4599
|
+
const result = this.validate();
|
|
4431
4600
|
if (!result.success) {
|
|
4432
|
-
throw
|
|
4433
|
-
`Invalid frontmatter in ${join40(relativeDirPath, dirName)}: ${formatError(result.error)}`
|
|
4434
|
-
);
|
|
4601
|
+
throw result.error;
|
|
4435
4602
|
}
|
|
4436
4603
|
}
|
|
4437
|
-
this.frontmatter = frontmatter;
|
|
4438
|
-
this.body = body;
|
|
4439
4604
|
}
|
|
4440
|
-
|
|
4441
|
-
|
|
4605
|
+
static getSettablePaths({ global = false } = {}) {
|
|
4606
|
+
if (!global) {
|
|
4607
|
+
throw new Error("CodexCliSkill only supports global mode. Please pass { global: true }.");
|
|
4608
|
+
}
|
|
4609
|
+
return {
|
|
4610
|
+
relativeDirPath: join42(".codex", "skills")
|
|
4611
|
+
};
|
|
4442
4612
|
}
|
|
4443
4613
|
getFrontmatter() {
|
|
4444
|
-
|
|
4614
|
+
if (!this.mainFile?.frontmatter) {
|
|
4615
|
+
throw new Error("Frontmatter is not defined");
|
|
4616
|
+
}
|
|
4617
|
+
const result = CodexCliSkillFrontmatterSchema.parse(this.mainFile.frontmatter);
|
|
4618
|
+
return result;
|
|
4445
4619
|
}
|
|
4446
|
-
|
|
4447
|
-
|
|
4620
|
+
getBody() {
|
|
4621
|
+
return this.mainFile?.body ?? "";
|
|
4448
4622
|
}
|
|
4449
4623
|
validate() {
|
|
4450
|
-
if (!this.
|
|
4451
|
-
return {
|
|
4624
|
+
if (!this.mainFile) {
|
|
4625
|
+
return {
|
|
4626
|
+
success: false,
|
|
4627
|
+
error: new Error(`${this.getDirPath()}: ${SKILL_FILE_NAME} file does not exist`)
|
|
4628
|
+
};
|
|
4452
4629
|
}
|
|
4453
|
-
const result =
|
|
4454
|
-
if (result.success) {
|
|
4455
|
-
return { success: true, error: null };
|
|
4456
|
-
} else {
|
|
4630
|
+
const result = CodexCliSkillFrontmatterSchema.safeParse(this.mainFile.frontmatter);
|
|
4631
|
+
if (!result.success) {
|
|
4457
4632
|
return {
|
|
4458
4633
|
success: false,
|
|
4459
4634
|
error: new Error(
|
|
@@ -4461,41 +4636,182 @@ var SimulatedSkill = class extends ToolSkill {
|
|
|
4461
4636
|
)
|
|
4462
4637
|
};
|
|
4463
4638
|
}
|
|
4639
|
+
return { success: true, error: null };
|
|
4464
4640
|
}
|
|
4465
|
-
|
|
4641
|
+
toRulesyncSkill() {
|
|
4642
|
+
const frontmatter = this.getFrontmatter();
|
|
4643
|
+
const rulesyncFrontmatter = {
|
|
4644
|
+
name: frontmatter.name,
|
|
4645
|
+
description: frontmatter.description,
|
|
4646
|
+
targets: ["*"]
|
|
4647
|
+
};
|
|
4648
|
+
return new RulesyncSkill({
|
|
4649
|
+
baseDir: this.baseDir,
|
|
4650
|
+
relativeDirPath: this.relativeDirPath,
|
|
4651
|
+
dirName: this.getDirName(),
|
|
4652
|
+
frontmatter: rulesyncFrontmatter,
|
|
4653
|
+
body: this.getBody(),
|
|
4654
|
+
otherFiles: this.getOtherFiles(),
|
|
4655
|
+
validate: true,
|
|
4656
|
+
global: this.global
|
|
4657
|
+
});
|
|
4658
|
+
}
|
|
4659
|
+
static fromRulesyncSkill({
|
|
4466
4660
|
rulesyncSkill,
|
|
4467
|
-
validate = true
|
|
4661
|
+
validate = true,
|
|
4662
|
+
global = false
|
|
4468
4663
|
}) {
|
|
4664
|
+
const settablePaths = _CodexCliSkill.getSettablePaths({ global });
|
|
4469
4665
|
const rulesyncFrontmatter = rulesyncSkill.getFrontmatter();
|
|
4470
|
-
const
|
|
4666
|
+
const codexFrontmatter = {
|
|
4471
4667
|
name: rulesyncFrontmatter.name,
|
|
4472
4668
|
description: rulesyncFrontmatter.description
|
|
4473
4669
|
};
|
|
4474
|
-
return {
|
|
4670
|
+
return new _CodexCliSkill({
|
|
4475
4671
|
baseDir: rulesyncSkill.getBaseDir(),
|
|
4476
|
-
relativeDirPath:
|
|
4672
|
+
relativeDirPath: settablePaths.relativeDirPath,
|
|
4477
4673
|
dirName: rulesyncSkill.getDirName(),
|
|
4478
|
-
frontmatter:
|
|
4674
|
+
frontmatter: codexFrontmatter,
|
|
4479
4675
|
body: rulesyncSkill.getBody(),
|
|
4480
4676
|
otherFiles: rulesyncSkill.getOtherFiles(),
|
|
4481
|
-
validate
|
|
4482
|
-
|
|
4677
|
+
validate,
|
|
4678
|
+
global
|
|
4679
|
+
});
|
|
4483
4680
|
}
|
|
4484
|
-
static
|
|
4485
|
-
|
|
4486
|
-
|
|
4487
|
-
|
|
4488
|
-
|
|
4489
|
-
const
|
|
4490
|
-
|
|
4491
|
-
|
|
4492
|
-
|
|
4493
|
-
|
|
4494
|
-
|
|
4495
|
-
|
|
4496
|
-
|
|
4497
|
-
|
|
4498
|
-
|
|
4681
|
+
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
4682
|
+
const targets = rulesyncSkill.getFrontmatter().targets;
|
|
4683
|
+
return targets.includes("*") || targets.includes("codexcli");
|
|
4684
|
+
}
|
|
4685
|
+
static async fromDir(params) {
|
|
4686
|
+
const loaded = await this.loadSkillDirContent({
|
|
4687
|
+
...params,
|
|
4688
|
+
getSettablePaths: _CodexCliSkill.getSettablePaths
|
|
4689
|
+
});
|
|
4690
|
+
const result = CodexCliSkillFrontmatterSchema.safeParse(loaded.frontmatter);
|
|
4691
|
+
if (!result.success) {
|
|
4692
|
+
const skillDirPath = join42(loaded.baseDir, loaded.relativeDirPath, loaded.dirName);
|
|
4693
|
+
throw new Error(
|
|
4694
|
+
`Invalid frontmatter in ${join42(skillDirPath, SKILL_FILE_NAME)}: ${formatError(result.error)}`
|
|
4695
|
+
);
|
|
4696
|
+
}
|
|
4697
|
+
return new _CodexCliSkill({
|
|
4698
|
+
baseDir: loaded.baseDir,
|
|
4699
|
+
relativeDirPath: loaded.relativeDirPath,
|
|
4700
|
+
dirName: loaded.dirName,
|
|
4701
|
+
frontmatter: result.data,
|
|
4702
|
+
body: loaded.body,
|
|
4703
|
+
otherFiles: loaded.otherFiles,
|
|
4704
|
+
validate: true,
|
|
4705
|
+
global: loaded.global
|
|
4706
|
+
});
|
|
4707
|
+
}
|
|
4708
|
+
};
|
|
4709
|
+
|
|
4710
|
+
// src/features/skills/copilot-skill.ts
|
|
4711
|
+
import { join as join44 } from "path";
|
|
4712
|
+
|
|
4713
|
+
// src/features/skills/simulated-skill.ts
|
|
4714
|
+
import { join as join43 } from "path";
|
|
4715
|
+
import { z as z21 } from "zod/mini";
|
|
4716
|
+
var SimulatedSkillFrontmatterSchema = z21.object({
|
|
4717
|
+
name: z21.string(),
|
|
4718
|
+
description: z21.string()
|
|
4719
|
+
});
|
|
4720
|
+
var SimulatedSkill = class extends ToolSkill {
|
|
4721
|
+
frontmatter;
|
|
4722
|
+
body;
|
|
4723
|
+
constructor({
|
|
4724
|
+
baseDir = process.cwd(),
|
|
4725
|
+
relativeDirPath,
|
|
4726
|
+
dirName,
|
|
4727
|
+
frontmatter,
|
|
4728
|
+
body,
|
|
4729
|
+
otherFiles = [],
|
|
4730
|
+
validate = true
|
|
4731
|
+
}) {
|
|
4732
|
+
super({
|
|
4733
|
+
baseDir,
|
|
4734
|
+
relativeDirPath,
|
|
4735
|
+
dirName,
|
|
4736
|
+
mainFile: {
|
|
4737
|
+
name: SKILL_FILE_NAME,
|
|
4738
|
+
body,
|
|
4739
|
+
frontmatter: { ...frontmatter }
|
|
4740
|
+
},
|
|
4741
|
+
otherFiles,
|
|
4742
|
+
global: false
|
|
4743
|
+
// Simulated skills are project mode only
|
|
4744
|
+
});
|
|
4745
|
+
if (validate) {
|
|
4746
|
+
const result = SimulatedSkillFrontmatterSchema.safeParse(frontmatter);
|
|
4747
|
+
if (!result.success) {
|
|
4748
|
+
throw new Error(
|
|
4749
|
+
`Invalid frontmatter in ${join43(relativeDirPath, dirName)}: ${formatError(result.error)}`
|
|
4750
|
+
);
|
|
4751
|
+
}
|
|
4752
|
+
}
|
|
4753
|
+
this.frontmatter = frontmatter;
|
|
4754
|
+
this.body = body;
|
|
4755
|
+
}
|
|
4756
|
+
getBody() {
|
|
4757
|
+
return this.body;
|
|
4758
|
+
}
|
|
4759
|
+
getFrontmatter() {
|
|
4760
|
+
return this.frontmatter;
|
|
4761
|
+
}
|
|
4762
|
+
toRulesyncSkill() {
|
|
4763
|
+
throw new Error("Not implemented because it is a SIMULATED skill.");
|
|
4764
|
+
}
|
|
4765
|
+
validate() {
|
|
4766
|
+
if (!this.frontmatter) {
|
|
4767
|
+
return { success: true, error: null };
|
|
4768
|
+
}
|
|
4769
|
+
const result = SimulatedSkillFrontmatterSchema.safeParse(this.frontmatter);
|
|
4770
|
+
if (result.success) {
|
|
4771
|
+
return { success: true, error: null };
|
|
4772
|
+
} else {
|
|
4773
|
+
return {
|
|
4774
|
+
success: false,
|
|
4775
|
+
error: new Error(
|
|
4776
|
+
`Invalid frontmatter in ${this.getDirPath()}: ${formatError(result.error)}`
|
|
4777
|
+
)
|
|
4778
|
+
};
|
|
4779
|
+
}
|
|
4780
|
+
}
|
|
4781
|
+
static fromRulesyncSkillDefault({
|
|
4782
|
+
rulesyncSkill,
|
|
4783
|
+
validate = true
|
|
4784
|
+
}) {
|
|
4785
|
+
const rulesyncFrontmatter = rulesyncSkill.getFrontmatter();
|
|
4786
|
+
const simulatedFrontmatter = {
|
|
4787
|
+
name: rulesyncFrontmatter.name,
|
|
4788
|
+
description: rulesyncFrontmatter.description
|
|
4789
|
+
};
|
|
4790
|
+
return {
|
|
4791
|
+
baseDir: rulesyncSkill.getBaseDir(),
|
|
4792
|
+
relativeDirPath: this.getSettablePaths().relativeDirPath,
|
|
4793
|
+
dirName: rulesyncSkill.getDirName(),
|
|
4794
|
+
frontmatter: simulatedFrontmatter,
|
|
4795
|
+
body: rulesyncSkill.getBody(),
|
|
4796
|
+
otherFiles: rulesyncSkill.getOtherFiles(),
|
|
4797
|
+
validate
|
|
4798
|
+
};
|
|
4799
|
+
}
|
|
4800
|
+
static async fromDirDefault({
|
|
4801
|
+
baseDir = process.cwd(),
|
|
4802
|
+
relativeDirPath,
|
|
4803
|
+
dirName
|
|
4804
|
+
}) {
|
|
4805
|
+
const settablePaths = this.getSettablePaths();
|
|
4806
|
+
const actualRelativeDirPath = relativeDirPath ?? settablePaths.relativeDirPath;
|
|
4807
|
+
const skillDirPath = join43(baseDir, actualRelativeDirPath, dirName);
|
|
4808
|
+
const skillFilePath = join43(skillDirPath, SKILL_FILE_NAME);
|
|
4809
|
+
if (!await fileExists(skillFilePath)) {
|
|
4810
|
+
throw new Error(`${SKILL_FILE_NAME} not found in ${skillDirPath}`);
|
|
4811
|
+
}
|
|
4812
|
+
const fileContent = await readFileContent(skillFilePath);
|
|
4813
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
4814
|
+
const result = SimulatedSkillFrontmatterSchema.safeParse(frontmatter);
|
|
4499
4815
|
if (!result.success) {
|
|
4500
4816
|
throw new Error(`Invalid frontmatter in ${skillFilePath}: ${formatError(result.error)}`);
|
|
4501
4817
|
}
|
|
@@ -4539,44 +4855,14 @@ var SimulatedSkill = class extends ToolSkill {
|
|
|
4539
4855
|
}
|
|
4540
4856
|
};
|
|
4541
4857
|
|
|
4542
|
-
// src/features/skills/codexcli-skill.ts
|
|
4543
|
-
var CodexCliSkill = class _CodexCliSkill extends SimulatedSkill {
|
|
4544
|
-
static getSettablePaths(options) {
|
|
4545
|
-
if (options?.global) {
|
|
4546
|
-
throw new Error("CodexCliSkill does not support global mode.");
|
|
4547
|
-
}
|
|
4548
|
-
return {
|
|
4549
|
-
relativeDirPath: join41(".codex", "skills")
|
|
4550
|
-
};
|
|
4551
|
-
}
|
|
4552
|
-
static async fromDir(params) {
|
|
4553
|
-
const baseParams = await this.fromDirDefault(params);
|
|
4554
|
-
return new _CodexCliSkill(baseParams);
|
|
4555
|
-
}
|
|
4556
|
-
static fromRulesyncSkill(params) {
|
|
4557
|
-
const baseParams = {
|
|
4558
|
-
...this.fromRulesyncSkillDefault(params),
|
|
4559
|
-
relativeDirPath: this.getSettablePaths().relativeDirPath
|
|
4560
|
-
};
|
|
4561
|
-
return new _CodexCliSkill(baseParams);
|
|
4562
|
-
}
|
|
4563
|
-
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
4564
|
-
return this.isTargetedByRulesyncSkillDefault({
|
|
4565
|
-
rulesyncSkill,
|
|
4566
|
-
toolTarget: "codexcli"
|
|
4567
|
-
});
|
|
4568
|
-
}
|
|
4569
|
-
};
|
|
4570
|
-
|
|
4571
4858
|
// src/features/skills/copilot-skill.ts
|
|
4572
|
-
import { join as join42 } from "path";
|
|
4573
4859
|
var CopilotSkill = class _CopilotSkill extends SimulatedSkill {
|
|
4574
4860
|
static getSettablePaths(options) {
|
|
4575
4861
|
if (options?.global) {
|
|
4576
4862
|
throw new Error("CopilotSkill does not support global mode.");
|
|
4577
4863
|
}
|
|
4578
4864
|
return {
|
|
4579
|
-
relativeDirPath:
|
|
4865
|
+
relativeDirPath: join44(".github", "skills")
|
|
4580
4866
|
};
|
|
4581
4867
|
}
|
|
4582
4868
|
static async fromDir(params) {
|
|
@@ -4599,14 +4885,14 @@ var CopilotSkill = class _CopilotSkill extends SimulatedSkill {
|
|
|
4599
4885
|
};
|
|
4600
4886
|
|
|
4601
4887
|
// src/features/skills/cursor-skill.ts
|
|
4602
|
-
import { join as
|
|
4888
|
+
import { join as join45 } from "path";
|
|
4603
4889
|
var CursorSkill = class _CursorSkill extends SimulatedSkill {
|
|
4604
4890
|
static getSettablePaths(options) {
|
|
4605
4891
|
if (options?.global) {
|
|
4606
4892
|
throw new Error("CursorSkill does not support global mode.");
|
|
4607
4893
|
}
|
|
4608
4894
|
return {
|
|
4609
|
-
relativeDirPath:
|
|
4895
|
+
relativeDirPath: join45(".cursor", "skills")
|
|
4610
4896
|
};
|
|
4611
4897
|
}
|
|
4612
4898
|
static async fromDir(params) {
|
|
@@ -4629,11 +4915,11 @@ var CursorSkill = class _CursorSkill extends SimulatedSkill {
|
|
|
4629
4915
|
};
|
|
4630
4916
|
|
|
4631
4917
|
// src/features/skills/skills-processor.ts
|
|
4632
|
-
import { basename as basename15, join as
|
|
4633
|
-
import { z as
|
|
4918
|
+
import { basename as basename15, join as join50 } from "path";
|
|
4919
|
+
import { z as z23 } from "zod/mini";
|
|
4634
4920
|
|
|
4635
4921
|
// src/types/dir-feature-processor.ts
|
|
4636
|
-
import { join as
|
|
4922
|
+
import { join as join46 } from "path";
|
|
4637
4923
|
var DirFeatureProcessor = class {
|
|
4638
4924
|
baseDir;
|
|
4639
4925
|
constructor({ baseDir = process.cwd() }) {
|
|
@@ -4655,14 +4941,14 @@ var DirFeatureProcessor = class {
|
|
|
4655
4941
|
await ensureDir(dirPath);
|
|
4656
4942
|
const mainFile = aiDir.getMainFile();
|
|
4657
4943
|
if (mainFile) {
|
|
4658
|
-
const mainFilePath =
|
|
4944
|
+
const mainFilePath = join46(dirPath, mainFile.name);
|
|
4659
4945
|
const content = stringifyFrontmatter(mainFile.body, mainFile.frontmatter);
|
|
4660
4946
|
const contentWithNewline = addTrailingNewline(content);
|
|
4661
4947
|
await writeFileContent(mainFilePath, contentWithNewline);
|
|
4662
4948
|
}
|
|
4663
4949
|
const otherFiles = aiDir.getOtherFiles();
|
|
4664
4950
|
for (const file of otherFiles) {
|
|
4665
|
-
const filePath =
|
|
4951
|
+
const filePath = join46(dirPath, file.relativeFilePathToDirPath);
|
|
4666
4952
|
const contentWithNewline = addTrailingNewline(file.fileBuffer.toString("utf-8"));
|
|
4667
4953
|
await writeFileContent(filePath, contentWithNewline);
|
|
4668
4954
|
}
|
|
@@ -4677,14 +4963,14 @@ var DirFeatureProcessor = class {
|
|
|
4677
4963
|
};
|
|
4678
4964
|
|
|
4679
4965
|
// src/features/skills/agentsmd-skill.ts
|
|
4680
|
-
import { join as
|
|
4966
|
+
import { join as join47 } from "path";
|
|
4681
4967
|
var AgentsmdSkill = class _AgentsmdSkill extends SimulatedSkill {
|
|
4682
4968
|
static getSettablePaths(options) {
|
|
4683
4969
|
if (options?.global) {
|
|
4684
4970
|
throw new Error("AgentsmdSkill does not support global mode.");
|
|
4685
4971
|
}
|
|
4686
4972
|
return {
|
|
4687
|
-
relativeDirPath:
|
|
4973
|
+
relativeDirPath: join47(".agents", "skills")
|
|
4688
4974
|
};
|
|
4689
4975
|
}
|
|
4690
4976
|
static async fromDir(params) {
|
|
@@ -4707,126 +4993,17 @@ var AgentsmdSkill = class _AgentsmdSkill extends SimulatedSkill {
|
|
|
4707
4993
|
};
|
|
4708
4994
|
|
|
4709
4995
|
// src/features/skills/claudecode-skill.ts
|
|
4710
|
-
import { join as
|
|
4711
|
-
import { z as
|
|
4712
|
-
|
|
4713
|
-
|
|
4714
|
-
|
|
4715
|
-
|
|
4716
|
-
var RulesyncSkillFrontmatterSchemaInternal = z20.object({
|
|
4717
|
-
name: z20.string(),
|
|
4718
|
-
description: z20.string(),
|
|
4719
|
-
targets: z20._default(RulesyncTargetsSchema, ["*"]),
|
|
4720
|
-
claudecode: z20.optional(
|
|
4721
|
-
z20.object({
|
|
4722
|
-
"allowed-tools": z20.optional(z20.array(z20.string()))
|
|
4723
|
-
})
|
|
4724
|
-
)
|
|
4725
|
-
});
|
|
4726
|
-
var RulesyncSkillFrontmatterSchema = RulesyncSkillFrontmatterSchemaInternal;
|
|
4727
|
-
var RulesyncSkill = class _RulesyncSkill extends AiDir {
|
|
4728
|
-
constructor({
|
|
4729
|
-
baseDir = process.cwd(),
|
|
4730
|
-
relativeDirPath = RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
4731
|
-
dirName,
|
|
4732
|
-
frontmatter,
|
|
4733
|
-
body,
|
|
4734
|
-
otherFiles = [],
|
|
4735
|
-
validate = true,
|
|
4736
|
-
global = false
|
|
4737
|
-
}) {
|
|
4738
|
-
super({
|
|
4739
|
-
baseDir,
|
|
4740
|
-
relativeDirPath,
|
|
4741
|
-
dirName,
|
|
4742
|
-
mainFile: {
|
|
4743
|
-
name: SKILL_FILE_NAME,
|
|
4744
|
-
body,
|
|
4745
|
-
frontmatter: { ...frontmatter }
|
|
4746
|
-
},
|
|
4747
|
-
otherFiles,
|
|
4748
|
-
global
|
|
4749
|
-
});
|
|
4750
|
-
if (validate) {
|
|
4751
|
-
const result = this.validate();
|
|
4752
|
-
if (!result.success) {
|
|
4753
|
-
throw result.error;
|
|
4754
|
-
}
|
|
4755
|
-
}
|
|
4756
|
-
}
|
|
4757
|
-
static getSettablePaths() {
|
|
4758
|
-
return {
|
|
4759
|
-
relativeDirPath: RULESYNC_SKILLS_RELATIVE_DIR_PATH
|
|
4760
|
-
};
|
|
4761
|
-
}
|
|
4762
|
-
getFrontmatter() {
|
|
4763
|
-
if (!this.mainFile?.frontmatter) {
|
|
4764
|
-
throw new Error("Frontmatter is not defined");
|
|
4765
|
-
}
|
|
4766
|
-
const result = RulesyncSkillFrontmatterSchema.parse(this.mainFile.frontmatter);
|
|
4767
|
-
return result;
|
|
4768
|
-
}
|
|
4769
|
-
getBody() {
|
|
4770
|
-
return this.mainFile?.body ?? "";
|
|
4771
|
-
}
|
|
4772
|
-
validate() {
|
|
4773
|
-
const result = RulesyncSkillFrontmatterSchema.safeParse(this.mainFile?.frontmatter);
|
|
4774
|
-
if (!result.success) {
|
|
4775
|
-
return {
|
|
4776
|
-
success: false,
|
|
4777
|
-
error: new Error(
|
|
4778
|
-
`Invalid frontmatter in ${this.getDirPath()}: ${formatError(result.error)}`
|
|
4779
|
-
)
|
|
4780
|
-
};
|
|
4781
|
-
}
|
|
4782
|
-
return { success: true, error: null };
|
|
4783
|
-
}
|
|
4784
|
-
static async fromDir({
|
|
4785
|
-
baseDir = process.cwd(),
|
|
4786
|
-
relativeDirPath = RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
4787
|
-
dirName,
|
|
4788
|
-
global = false
|
|
4789
|
-
}) {
|
|
4790
|
-
const skillDirPath = join46(baseDir, relativeDirPath, dirName);
|
|
4791
|
-
const skillFilePath = join46(skillDirPath, SKILL_FILE_NAME);
|
|
4792
|
-
if (!await fileExists(skillFilePath)) {
|
|
4793
|
-
throw new Error(`${SKILL_FILE_NAME} not found in ${skillDirPath}`);
|
|
4794
|
-
}
|
|
4795
|
-
const fileContent = await readFileContent(skillFilePath);
|
|
4796
|
-
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
4797
|
-
const result = RulesyncSkillFrontmatterSchema.safeParse(frontmatter);
|
|
4798
|
-
if (!result.success) {
|
|
4799
|
-
throw new Error(`Invalid frontmatter in ${skillFilePath}: ${formatError(result.error)}`);
|
|
4800
|
-
}
|
|
4801
|
-
const otherFiles = await this.collectOtherFiles(
|
|
4802
|
-
baseDir,
|
|
4803
|
-
relativeDirPath,
|
|
4804
|
-
dirName,
|
|
4805
|
-
SKILL_FILE_NAME
|
|
4806
|
-
);
|
|
4807
|
-
return new _RulesyncSkill({
|
|
4808
|
-
baseDir,
|
|
4809
|
-
relativeDirPath,
|
|
4810
|
-
dirName,
|
|
4811
|
-
frontmatter: result.data,
|
|
4812
|
-
body: content.trim(),
|
|
4813
|
-
otherFiles,
|
|
4814
|
-
validate: true,
|
|
4815
|
-
global
|
|
4816
|
-
});
|
|
4817
|
-
}
|
|
4818
|
-
};
|
|
4819
|
-
|
|
4820
|
-
// src/features/skills/claudecode-skill.ts
|
|
4821
|
-
var ClaudecodeSkillFrontmatterSchema = z21.object({
|
|
4822
|
-
name: z21.string(),
|
|
4823
|
-
description: z21.string(),
|
|
4824
|
-
"allowed-tools": z21.optional(z21.array(z21.string()))
|
|
4996
|
+
import { join as join48 } from "path";
|
|
4997
|
+
import { z as z22 } from "zod/mini";
|
|
4998
|
+
var ClaudecodeSkillFrontmatterSchema = z22.object({
|
|
4999
|
+
name: z22.string(),
|
|
5000
|
+
description: z22.string(),
|
|
5001
|
+
"allowed-tools": z22.optional(z22.array(z22.string()))
|
|
4825
5002
|
});
|
|
4826
5003
|
var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
|
|
4827
5004
|
constructor({
|
|
4828
5005
|
baseDir = process.cwd(),
|
|
4829
|
-
relativeDirPath =
|
|
5006
|
+
relativeDirPath = join48(".claude", "skills"),
|
|
4830
5007
|
dirName,
|
|
4831
5008
|
frontmatter,
|
|
4832
5009
|
body,
|
|
@@ -4857,7 +5034,7 @@ var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
|
|
|
4857
5034
|
global: _global = false
|
|
4858
5035
|
} = {}) {
|
|
4859
5036
|
return {
|
|
4860
|
-
relativeDirPath:
|
|
5037
|
+
relativeDirPath: join48(".claude", "skills")
|
|
4861
5038
|
};
|
|
4862
5039
|
}
|
|
4863
5040
|
getFrontmatter() {
|
|
@@ -4937,53 +5114,40 @@ var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
|
|
|
4937
5114
|
static isTargetedByRulesyncSkill(_rulesyncSkill) {
|
|
4938
5115
|
return true;
|
|
4939
5116
|
}
|
|
4940
|
-
static async fromDir({
|
|
4941
|
-
|
|
4942
|
-
|
|
4943
|
-
|
|
4944
|
-
|
|
4945
|
-
|
|
4946
|
-
const settablePaths = this.getSettablePaths({ global });
|
|
4947
|
-
const actualRelativeDirPath = relativeDirPath ?? settablePaths.relativeDirPath;
|
|
4948
|
-
const skillDirPath = join47(baseDir, actualRelativeDirPath, dirName);
|
|
4949
|
-
const skillFilePath = join47(skillDirPath, SKILL_FILE_NAME);
|
|
4950
|
-
if (!await fileExists(skillFilePath)) {
|
|
4951
|
-
throw new Error(`${SKILL_FILE_NAME} not found in ${skillDirPath}`);
|
|
4952
|
-
}
|
|
4953
|
-
const fileContent = await readFileContent(skillFilePath);
|
|
4954
|
-
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
4955
|
-
const result = ClaudecodeSkillFrontmatterSchema.safeParse(frontmatter);
|
|
5117
|
+
static async fromDir(params) {
|
|
5118
|
+
const loaded = await this.loadSkillDirContent({
|
|
5119
|
+
...params,
|
|
5120
|
+
getSettablePaths: _ClaudecodeSkill.getSettablePaths
|
|
5121
|
+
});
|
|
5122
|
+
const result = ClaudecodeSkillFrontmatterSchema.safeParse(loaded.frontmatter);
|
|
4956
5123
|
if (!result.success) {
|
|
4957
|
-
|
|
5124
|
+
const skillDirPath = join48(loaded.baseDir, loaded.relativeDirPath, loaded.dirName);
|
|
5125
|
+
throw new Error(
|
|
5126
|
+
`Invalid frontmatter in ${join48(skillDirPath, SKILL_FILE_NAME)}: ${formatError(result.error)}`
|
|
5127
|
+
);
|
|
4958
5128
|
}
|
|
4959
|
-
const otherFiles = await this.collectOtherFiles(
|
|
4960
|
-
baseDir,
|
|
4961
|
-
actualRelativeDirPath,
|
|
4962
|
-
dirName,
|
|
4963
|
-
SKILL_FILE_NAME
|
|
4964
|
-
);
|
|
4965
5129
|
return new _ClaudecodeSkill({
|
|
4966
|
-
baseDir,
|
|
4967
|
-
relativeDirPath:
|
|
4968
|
-
dirName,
|
|
5130
|
+
baseDir: loaded.baseDir,
|
|
5131
|
+
relativeDirPath: loaded.relativeDirPath,
|
|
5132
|
+
dirName: loaded.dirName,
|
|
4969
5133
|
frontmatter: result.data,
|
|
4970
|
-
body:
|
|
4971
|
-
otherFiles,
|
|
5134
|
+
body: loaded.body,
|
|
5135
|
+
otherFiles: loaded.otherFiles,
|
|
4972
5136
|
validate: true,
|
|
4973
|
-
global
|
|
5137
|
+
global: loaded.global
|
|
4974
5138
|
});
|
|
4975
5139
|
}
|
|
4976
5140
|
};
|
|
4977
5141
|
|
|
4978
5142
|
// src/features/skills/geminicli-skill.ts
|
|
4979
|
-
import { join as
|
|
5143
|
+
import { join as join49 } from "path";
|
|
4980
5144
|
var GeminiCliSkill = class _GeminiCliSkill extends SimulatedSkill {
|
|
4981
5145
|
static getSettablePaths(options) {
|
|
4982
5146
|
if (options?.global) {
|
|
4983
5147
|
throw new Error("GeminiCliSkill does not support global mode.");
|
|
4984
5148
|
}
|
|
4985
5149
|
return {
|
|
4986
|
-
relativeDirPath:
|
|
5150
|
+
relativeDirPath: join49(".gemini", "skills")
|
|
4987
5151
|
};
|
|
4988
5152
|
}
|
|
4989
5153
|
static async fromDir(params) {
|
|
@@ -5014,19 +5178,49 @@ var skillsProcessorToolTargetTuple = [
|
|
|
5014
5178
|
"cursor",
|
|
5015
5179
|
"geminicli"
|
|
5016
5180
|
];
|
|
5017
|
-
var SkillsProcessorToolTargetSchema =
|
|
5181
|
+
var SkillsProcessorToolTargetSchema = z23.enum(skillsProcessorToolTargetTuple);
|
|
5018
5182
|
var toolSkillFactories = /* @__PURE__ */ new Map([
|
|
5019
|
-
[
|
|
5183
|
+
[
|
|
5184
|
+
"agentsmd",
|
|
5185
|
+
{
|
|
5186
|
+
class: AgentsmdSkill,
|
|
5187
|
+
meta: { supportsProject: true, supportsSimulated: true, supportsGlobal: false }
|
|
5188
|
+
}
|
|
5189
|
+
],
|
|
5020
5190
|
[
|
|
5021
5191
|
"claudecode",
|
|
5022
|
-
{
|
|
5192
|
+
{
|
|
5193
|
+
class: ClaudecodeSkill,
|
|
5194
|
+
meta: { supportsProject: true, supportsSimulated: false, supportsGlobal: true }
|
|
5195
|
+
}
|
|
5196
|
+
],
|
|
5197
|
+
[
|
|
5198
|
+
"codexcli",
|
|
5199
|
+
{
|
|
5200
|
+
class: CodexCliSkill,
|
|
5201
|
+
meta: { supportsProject: false, supportsSimulated: false, supportsGlobal: true }
|
|
5202
|
+
}
|
|
5203
|
+
],
|
|
5204
|
+
[
|
|
5205
|
+
"copilot",
|
|
5206
|
+
{
|
|
5207
|
+
class: CopilotSkill,
|
|
5208
|
+
meta: { supportsProject: true, supportsSimulated: true, supportsGlobal: false }
|
|
5209
|
+
}
|
|
5210
|
+
],
|
|
5211
|
+
[
|
|
5212
|
+
"cursor",
|
|
5213
|
+
{
|
|
5214
|
+
class: CursorSkill,
|
|
5215
|
+
meta: { supportsProject: true, supportsSimulated: true, supportsGlobal: false }
|
|
5216
|
+
}
|
|
5023
5217
|
],
|
|
5024
|
-
["codexcli", { class: CodexCliSkill, meta: { supportsSimulated: true, supportsGlobal: false } }],
|
|
5025
|
-
["copilot", { class: CopilotSkill, meta: { supportsSimulated: true, supportsGlobal: false } }],
|
|
5026
|
-
["cursor", { class: CursorSkill, meta: { supportsSimulated: true, supportsGlobal: false } }],
|
|
5027
5218
|
[
|
|
5028
5219
|
"geminicli",
|
|
5029
|
-
{
|
|
5220
|
+
{
|
|
5221
|
+
class: GeminiCliSkill,
|
|
5222
|
+
meta: { supportsProject: true, supportsSimulated: true, supportsGlobal: false }
|
|
5223
|
+
}
|
|
5030
5224
|
]
|
|
5031
5225
|
]);
|
|
5032
5226
|
var defaultGetFactory4 = (target) => {
|
|
@@ -5037,7 +5231,10 @@ var defaultGetFactory4 = (target) => {
|
|
|
5037
5231
|
return factory;
|
|
5038
5232
|
};
|
|
5039
5233
|
var allToolTargetKeys3 = [...toolSkillFactories.keys()];
|
|
5040
|
-
var
|
|
5234
|
+
var skillsProcessorToolTargetsProject = allToolTargetKeys3.filter((target) => {
|
|
5235
|
+
const factory = toolSkillFactories.get(target);
|
|
5236
|
+
return factory?.meta.supportsProject ?? true;
|
|
5237
|
+
});
|
|
5041
5238
|
var skillsProcessorToolTargetsSimulated = allToolTargetKeys3.filter(
|
|
5042
5239
|
(target) => {
|
|
5043
5240
|
const factory = toolSkillFactories.get(target);
|
|
@@ -5103,8 +5300,8 @@ var SkillsProcessor = class extends DirFeatureProcessor {
|
|
|
5103
5300
|
*/
|
|
5104
5301
|
async loadRulesyncDirs() {
|
|
5105
5302
|
const paths = RulesyncSkill.getSettablePaths();
|
|
5106
|
-
const rulesyncSkillsDirPath =
|
|
5107
|
-
const dirPaths = await findFilesByGlobs(
|
|
5303
|
+
const rulesyncSkillsDirPath = join50(this.baseDir, paths.relativeDirPath);
|
|
5304
|
+
const dirPaths = await findFilesByGlobs(join50(rulesyncSkillsDirPath, "*"), { type: "dir" });
|
|
5108
5305
|
const dirNames = dirPaths.map((path3) => basename15(path3));
|
|
5109
5306
|
const rulesyncSkills = await Promise.all(
|
|
5110
5307
|
dirNames.map(
|
|
@@ -5121,8 +5318,8 @@ var SkillsProcessor = class extends DirFeatureProcessor {
|
|
|
5121
5318
|
async loadToolDirs() {
|
|
5122
5319
|
const factory = this.getFactory(this.toolTarget);
|
|
5123
5320
|
const paths = factory.class.getSettablePaths({ global: this.global });
|
|
5124
|
-
const skillsDirPath =
|
|
5125
|
-
const dirPaths = await findFilesByGlobs(
|
|
5321
|
+
const skillsDirPath = join50(this.baseDir, paths.relativeDirPath);
|
|
5322
|
+
const dirPaths = await findFilesByGlobs(join50(skillsDirPath, "*"), { type: "dir" });
|
|
5126
5323
|
const dirNames = dirPaths.map((path3) => basename15(path3));
|
|
5127
5324
|
const toolSkills = await Promise.all(
|
|
5128
5325
|
dirNames.map(
|
|
@@ -5150,12 +5347,13 @@ var SkillsProcessor = class extends DirFeatureProcessor {
|
|
|
5150
5347
|
if (global) {
|
|
5151
5348
|
return skillsProcessorToolTargetsGlobal;
|
|
5152
5349
|
}
|
|
5350
|
+
const projectTargets = skillsProcessorToolTargetsProject;
|
|
5153
5351
|
if (!includeSimulated) {
|
|
5154
|
-
return
|
|
5352
|
+
return projectTargets.filter(
|
|
5155
5353
|
(target) => !skillsProcessorToolTargetsSimulated.includes(target)
|
|
5156
5354
|
);
|
|
5157
5355
|
}
|
|
5158
|
-
return
|
|
5356
|
+
return projectTargets;
|
|
5159
5357
|
}
|
|
5160
5358
|
/**
|
|
5161
5359
|
* Return the simulated tool targets
|
|
@@ -5172,11 +5370,11 @@ var SkillsProcessor = class extends DirFeatureProcessor {
|
|
|
5172
5370
|
};
|
|
5173
5371
|
|
|
5174
5372
|
// src/features/subagents/agentsmd-subagent.ts
|
|
5175
|
-
import { join as
|
|
5373
|
+
import { join as join52 } from "path";
|
|
5176
5374
|
|
|
5177
5375
|
// src/features/subagents/simulated-subagent.ts
|
|
5178
|
-
import { basename as basename16, join as
|
|
5179
|
-
import { z as
|
|
5376
|
+
import { basename as basename16, join as join51 } from "path";
|
|
5377
|
+
import { z as z24 } from "zod/mini";
|
|
5180
5378
|
|
|
5181
5379
|
// src/features/subagents/tool-subagent.ts
|
|
5182
5380
|
var ToolSubagent = class extends ToolFile {
|
|
@@ -5211,9 +5409,9 @@ var ToolSubagent = class extends ToolFile {
|
|
|
5211
5409
|
};
|
|
5212
5410
|
|
|
5213
5411
|
// src/features/subagents/simulated-subagent.ts
|
|
5214
|
-
var SimulatedSubagentFrontmatterSchema =
|
|
5215
|
-
name:
|
|
5216
|
-
description:
|
|
5412
|
+
var SimulatedSubagentFrontmatterSchema = z24.object({
|
|
5413
|
+
name: z24.string(),
|
|
5414
|
+
description: z24.string()
|
|
5217
5415
|
});
|
|
5218
5416
|
var SimulatedSubagent = class extends ToolSubagent {
|
|
5219
5417
|
frontmatter;
|
|
@@ -5223,7 +5421,7 @@ var SimulatedSubagent = class extends ToolSubagent {
|
|
|
5223
5421
|
const result = SimulatedSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
5224
5422
|
if (!result.success) {
|
|
5225
5423
|
throw new Error(
|
|
5226
|
-
`Invalid frontmatter in ${
|
|
5424
|
+
`Invalid frontmatter in ${join51(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
5227
5425
|
);
|
|
5228
5426
|
}
|
|
5229
5427
|
}
|
|
@@ -5274,7 +5472,7 @@ var SimulatedSubagent = class extends ToolSubagent {
|
|
|
5274
5472
|
return {
|
|
5275
5473
|
success: false,
|
|
5276
5474
|
error: new Error(
|
|
5277
|
-
`Invalid frontmatter in ${
|
|
5475
|
+
`Invalid frontmatter in ${join51(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
5278
5476
|
)
|
|
5279
5477
|
};
|
|
5280
5478
|
}
|
|
@@ -5284,7 +5482,7 @@ var SimulatedSubagent = class extends ToolSubagent {
|
|
|
5284
5482
|
relativeFilePath,
|
|
5285
5483
|
validate = true
|
|
5286
5484
|
}) {
|
|
5287
|
-
const filePath =
|
|
5485
|
+
const filePath = join51(baseDir, this.getSettablePaths().relativeDirPath, relativeFilePath);
|
|
5288
5486
|
const fileContent = await readFileContent(filePath);
|
|
5289
5487
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
5290
5488
|
const result = SimulatedSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -5306,7 +5504,7 @@ var SimulatedSubagent = class extends ToolSubagent {
|
|
|
5306
5504
|
var AgentsmdSubagent = class _AgentsmdSubagent extends SimulatedSubagent {
|
|
5307
5505
|
static getSettablePaths() {
|
|
5308
5506
|
return {
|
|
5309
|
-
relativeDirPath:
|
|
5507
|
+
relativeDirPath: join52(".agents", "subagents")
|
|
5310
5508
|
};
|
|
5311
5509
|
}
|
|
5312
5510
|
static async fromFile(params) {
|
|
@@ -5326,11 +5524,11 @@ var AgentsmdSubagent = class _AgentsmdSubagent extends SimulatedSubagent {
|
|
|
5326
5524
|
};
|
|
5327
5525
|
|
|
5328
5526
|
// src/features/subagents/codexcli-subagent.ts
|
|
5329
|
-
import { join as
|
|
5527
|
+
import { join as join53 } from "path";
|
|
5330
5528
|
var CodexCliSubagent = class _CodexCliSubagent extends SimulatedSubagent {
|
|
5331
5529
|
static getSettablePaths() {
|
|
5332
5530
|
return {
|
|
5333
|
-
relativeDirPath:
|
|
5531
|
+
relativeDirPath: join53(".codex", "subagents")
|
|
5334
5532
|
};
|
|
5335
5533
|
}
|
|
5336
5534
|
static async fromFile(params) {
|
|
@@ -5350,11 +5548,11 @@ var CodexCliSubagent = class _CodexCliSubagent extends SimulatedSubagent {
|
|
|
5350
5548
|
};
|
|
5351
5549
|
|
|
5352
5550
|
// src/features/subagents/copilot-subagent.ts
|
|
5353
|
-
import { join as
|
|
5551
|
+
import { join as join54 } from "path";
|
|
5354
5552
|
var CopilotSubagent = class _CopilotSubagent extends SimulatedSubagent {
|
|
5355
5553
|
static getSettablePaths() {
|
|
5356
5554
|
return {
|
|
5357
|
-
relativeDirPath:
|
|
5555
|
+
relativeDirPath: join54(".github", "subagents")
|
|
5358
5556
|
};
|
|
5359
5557
|
}
|
|
5360
5558
|
static async fromFile(params) {
|
|
@@ -5374,11 +5572,11 @@ var CopilotSubagent = class _CopilotSubagent extends SimulatedSubagent {
|
|
|
5374
5572
|
};
|
|
5375
5573
|
|
|
5376
5574
|
// src/features/subagents/cursor-subagent.ts
|
|
5377
|
-
import { join as
|
|
5575
|
+
import { join as join55 } from "path";
|
|
5378
5576
|
var CursorSubagent = class _CursorSubagent extends SimulatedSubagent {
|
|
5379
5577
|
static getSettablePaths() {
|
|
5380
5578
|
return {
|
|
5381
|
-
relativeDirPath:
|
|
5579
|
+
relativeDirPath: join55(".cursor", "subagents")
|
|
5382
5580
|
};
|
|
5383
5581
|
}
|
|
5384
5582
|
static async fromFile(params) {
|
|
@@ -5398,11 +5596,11 @@ var CursorSubagent = class _CursorSubagent extends SimulatedSubagent {
|
|
|
5398
5596
|
};
|
|
5399
5597
|
|
|
5400
5598
|
// src/features/subagents/geminicli-subagent.ts
|
|
5401
|
-
import { join as
|
|
5599
|
+
import { join as join56 } from "path";
|
|
5402
5600
|
var GeminiCliSubagent = class _GeminiCliSubagent extends SimulatedSubagent {
|
|
5403
5601
|
static getSettablePaths() {
|
|
5404
5602
|
return {
|
|
5405
|
-
relativeDirPath:
|
|
5603
|
+
relativeDirPath: join56(".gemini", "subagents")
|
|
5406
5604
|
};
|
|
5407
5605
|
}
|
|
5408
5606
|
static async fromFile(params) {
|
|
@@ -5422,11 +5620,11 @@ var GeminiCliSubagent = class _GeminiCliSubagent extends SimulatedSubagent {
|
|
|
5422
5620
|
};
|
|
5423
5621
|
|
|
5424
5622
|
// src/features/subagents/roo-subagent.ts
|
|
5425
|
-
import { join as
|
|
5623
|
+
import { join as join57 } from "path";
|
|
5426
5624
|
var RooSubagent = class _RooSubagent extends SimulatedSubagent {
|
|
5427
5625
|
static getSettablePaths() {
|
|
5428
5626
|
return {
|
|
5429
|
-
relativeDirPath:
|
|
5627
|
+
relativeDirPath: join57(".roo", "subagents")
|
|
5430
5628
|
};
|
|
5431
5629
|
}
|
|
5432
5630
|
static async fromFile(params) {
|
|
@@ -5446,20 +5644,20 @@ var RooSubagent = class _RooSubagent extends SimulatedSubagent {
|
|
|
5446
5644
|
};
|
|
5447
5645
|
|
|
5448
5646
|
// src/features/subagents/subagents-processor.ts
|
|
5449
|
-
import { basename as basename18, join as
|
|
5450
|
-
import { z as
|
|
5647
|
+
import { basename as basename18, join as join60 } from "path";
|
|
5648
|
+
import { z as z27 } from "zod/mini";
|
|
5451
5649
|
|
|
5452
5650
|
// src/features/subagents/claudecode-subagent.ts
|
|
5453
|
-
import { join as
|
|
5454
|
-
import { z as
|
|
5651
|
+
import { join as join59 } from "path";
|
|
5652
|
+
import { z as z26 } from "zod/mini";
|
|
5455
5653
|
|
|
5456
5654
|
// src/features/subagents/rulesync-subagent.ts
|
|
5457
|
-
import { basename as basename17, join as
|
|
5458
|
-
import { z as
|
|
5459
|
-
var RulesyncSubagentFrontmatterSchema =
|
|
5655
|
+
import { basename as basename17, join as join58 } from "path";
|
|
5656
|
+
import { z as z25 } from "zod/mini";
|
|
5657
|
+
var RulesyncSubagentFrontmatterSchema = z25.looseObject({
|
|
5460
5658
|
targets: RulesyncTargetsSchema,
|
|
5461
|
-
name:
|
|
5462
|
-
description:
|
|
5659
|
+
name: z25.string(),
|
|
5660
|
+
description: z25.string()
|
|
5463
5661
|
});
|
|
5464
5662
|
var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
5465
5663
|
frontmatter;
|
|
@@ -5469,7 +5667,7 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
5469
5667
|
const result = RulesyncSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
5470
5668
|
if (!result.success) {
|
|
5471
5669
|
throw new Error(
|
|
5472
|
-
`Invalid frontmatter in ${
|
|
5670
|
+
`Invalid frontmatter in ${join58(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
5473
5671
|
);
|
|
5474
5672
|
}
|
|
5475
5673
|
}
|
|
@@ -5502,7 +5700,7 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
5502
5700
|
return {
|
|
5503
5701
|
success: false,
|
|
5504
5702
|
error: new Error(
|
|
5505
|
-
`Invalid frontmatter in ${
|
|
5703
|
+
`Invalid frontmatter in ${join58(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
5506
5704
|
)
|
|
5507
5705
|
};
|
|
5508
5706
|
}
|
|
@@ -5511,7 +5709,7 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
5511
5709
|
relativeFilePath
|
|
5512
5710
|
}) {
|
|
5513
5711
|
const fileContent = await readFileContent(
|
|
5514
|
-
|
|
5712
|
+
join58(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, relativeFilePath)
|
|
5515
5713
|
);
|
|
5516
5714
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
5517
5715
|
const result = RulesyncSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -5530,13 +5728,13 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
5530
5728
|
};
|
|
5531
5729
|
|
|
5532
5730
|
// src/features/subagents/claudecode-subagent.ts
|
|
5533
|
-
var ClaudecodeSubagentFrontmatterSchema =
|
|
5534
|
-
name:
|
|
5535
|
-
description:
|
|
5536
|
-
model:
|
|
5537
|
-
tools:
|
|
5538
|
-
permissionMode:
|
|
5539
|
-
skills:
|
|
5731
|
+
var ClaudecodeSubagentFrontmatterSchema = z26.looseObject({
|
|
5732
|
+
name: z26.string(),
|
|
5733
|
+
description: z26.string(),
|
|
5734
|
+
model: z26.optional(z26.string()),
|
|
5735
|
+
tools: z26.optional(z26.union([z26.string(), z26.array(z26.string())])),
|
|
5736
|
+
permissionMode: z26.optional(z26.string()),
|
|
5737
|
+
skills: z26.optional(z26.union([z26.string(), z26.array(z26.string())]))
|
|
5540
5738
|
});
|
|
5541
5739
|
var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
5542
5740
|
frontmatter;
|
|
@@ -5546,7 +5744,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
5546
5744
|
const result = ClaudecodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
5547
5745
|
if (!result.success) {
|
|
5548
5746
|
throw new Error(
|
|
5549
|
-
`Invalid frontmatter in ${
|
|
5747
|
+
`Invalid frontmatter in ${join59(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
5550
5748
|
);
|
|
5551
5749
|
}
|
|
5552
5750
|
}
|
|
@@ -5558,7 +5756,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
5558
5756
|
}
|
|
5559
5757
|
static getSettablePaths(_options = {}) {
|
|
5560
5758
|
return {
|
|
5561
|
-
relativeDirPath:
|
|
5759
|
+
relativeDirPath: join59(".claude", "agents")
|
|
5562
5760
|
};
|
|
5563
5761
|
}
|
|
5564
5762
|
getFrontmatter() {
|
|
@@ -5632,7 +5830,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
5632
5830
|
return {
|
|
5633
5831
|
success: false,
|
|
5634
5832
|
error: new Error(
|
|
5635
|
-
`Invalid frontmatter in ${
|
|
5833
|
+
`Invalid frontmatter in ${join59(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
5636
5834
|
)
|
|
5637
5835
|
};
|
|
5638
5836
|
}
|
|
@@ -5650,7 +5848,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
5650
5848
|
global = false
|
|
5651
5849
|
}) {
|
|
5652
5850
|
const paths = this.getSettablePaths({ global });
|
|
5653
|
-
const filePath =
|
|
5851
|
+
const filePath = join59(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
5654
5852
|
const fileContent = await readFileContent(filePath);
|
|
5655
5853
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
5656
5854
|
const result = ClaudecodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -5679,7 +5877,7 @@ var subagentsProcessorToolTargetTuple = [
|
|
|
5679
5877
|
"geminicli",
|
|
5680
5878
|
"roo"
|
|
5681
5879
|
];
|
|
5682
|
-
var SubagentsProcessorToolTargetSchema =
|
|
5880
|
+
var SubagentsProcessorToolTargetSchema = z27.enum(subagentsProcessorToolTargetTuple);
|
|
5683
5881
|
var toolSubagentFactories = /* @__PURE__ */ new Map([
|
|
5684
5882
|
[
|
|
5685
5883
|
"agentsmd",
|
|
@@ -5782,7 +5980,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
5782
5980
|
* Load and parse rulesync subagent files from .rulesync/subagents/ directory
|
|
5783
5981
|
*/
|
|
5784
5982
|
async loadRulesyncFiles() {
|
|
5785
|
-
const subagentsDir =
|
|
5983
|
+
const subagentsDir = join60(this.baseDir, RulesyncSubagent.getSettablePaths().relativeDirPath);
|
|
5786
5984
|
const dirExists = await directoryExists(subagentsDir);
|
|
5787
5985
|
if (!dirExists) {
|
|
5788
5986
|
logger.debug(`Rulesync subagents directory not found: ${subagentsDir}`);
|
|
@@ -5797,7 +5995,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
5797
5995
|
logger.info(`Found ${mdFiles.length} subagent files in ${subagentsDir}`);
|
|
5798
5996
|
const rulesyncSubagents = [];
|
|
5799
5997
|
for (const mdFile of mdFiles) {
|
|
5800
|
-
const filepath =
|
|
5998
|
+
const filepath = join60(subagentsDir, mdFile);
|
|
5801
5999
|
try {
|
|
5802
6000
|
const rulesyncSubagent = await RulesyncSubagent.fromFile({
|
|
5803
6001
|
relativeFilePath: mdFile,
|
|
@@ -5827,7 +6025,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
5827
6025
|
const factory = this.getFactory(this.toolTarget);
|
|
5828
6026
|
const paths = factory.class.getSettablePaths({ global: this.global });
|
|
5829
6027
|
const subagentFilePaths = await findFilesByGlobs(
|
|
5830
|
-
|
|
6028
|
+
join60(this.baseDir, paths.relativeDirPath, "*.md")
|
|
5831
6029
|
);
|
|
5832
6030
|
const toolSubagents = await Promise.all(
|
|
5833
6031
|
subagentFilePaths.map(
|
|
@@ -5866,35 +6064,42 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
5866
6064
|
};
|
|
5867
6065
|
|
|
5868
6066
|
// src/features/rules/agentsmd-rule.ts
|
|
5869
|
-
import { join as
|
|
6067
|
+
import { join as join63 } from "path";
|
|
5870
6068
|
|
|
5871
6069
|
// src/features/rules/tool-rule.ts
|
|
5872
|
-
import { join as
|
|
6070
|
+
import { join as join62 } from "path";
|
|
5873
6071
|
|
|
5874
6072
|
// src/features/rules/rulesync-rule.ts
|
|
5875
|
-
import { basename as basename19, join as
|
|
5876
|
-
import { z as
|
|
5877
|
-
var RulesyncRuleFrontmatterSchema =
|
|
5878
|
-
root:
|
|
5879
|
-
targets:
|
|
5880
|
-
description:
|
|
5881
|
-
globs:
|
|
5882
|
-
agentsmd:
|
|
5883
|
-
|
|
6073
|
+
import { basename as basename19, join as join61 } from "path";
|
|
6074
|
+
import { z as z28 } from "zod/mini";
|
|
6075
|
+
var RulesyncRuleFrontmatterSchema = z28.object({
|
|
6076
|
+
root: z28.optional(z28.optional(z28.boolean())),
|
|
6077
|
+
targets: z28.optional(RulesyncTargetsSchema),
|
|
6078
|
+
description: z28.optional(z28.string()),
|
|
6079
|
+
globs: z28.optional(z28.array(z28.string())),
|
|
6080
|
+
agentsmd: z28.optional(
|
|
6081
|
+
z28.object({
|
|
5884
6082
|
// @example "path/to/subproject"
|
|
5885
|
-
subprojectPath:
|
|
6083
|
+
subprojectPath: z28.optional(z28.string())
|
|
6084
|
+
})
|
|
6085
|
+
),
|
|
6086
|
+
claudecode: z28.optional(
|
|
6087
|
+
z28.object({
|
|
6088
|
+
// Glob patterns for conditional rules (takes precedence over globs)
|
|
6089
|
+
// @example "src/**/*.ts, tests/**/*.test.ts"
|
|
6090
|
+
paths: z28.optional(z28.string())
|
|
5886
6091
|
})
|
|
5887
6092
|
),
|
|
5888
|
-
cursor:
|
|
5889
|
-
|
|
5890
|
-
alwaysApply:
|
|
5891
|
-
description:
|
|
5892
|
-
globs:
|
|
6093
|
+
cursor: z28.optional(
|
|
6094
|
+
z28.object({
|
|
6095
|
+
alwaysApply: z28.optional(z28.boolean()),
|
|
6096
|
+
description: z28.optional(z28.string()),
|
|
6097
|
+
globs: z28.optional(z28.array(z28.string()))
|
|
5893
6098
|
})
|
|
5894
6099
|
),
|
|
5895
|
-
copilot:
|
|
5896
|
-
|
|
5897
|
-
excludeAgent:
|
|
6100
|
+
copilot: z28.optional(
|
|
6101
|
+
z28.object({
|
|
6102
|
+
excludeAgent: z28.optional(z28.union([z28.literal("code-review"), z28.literal("coding-agent")]))
|
|
5898
6103
|
})
|
|
5899
6104
|
)
|
|
5900
6105
|
});
|
|
@@ -5906,7 +6111,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
5906
6111
|
const result = RulesyncRuleFrontmatterSchema.safeParse(frontmatter);
|
|
5907
6112
|
if (!result.success) {
|
|
5908
6113
|
throw new Error(
|
|
5909
|
-
`Invalid frontmatter in ${
|
|
6114
|
+
`Invalid frontmatter in ${join61(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
5910
6115
|
);
|
|
5911
6116
|
}
|
|
5912
6117
|
}
|
|
@@ -5941,7 +6146,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
5941
6146
|
return {
|
|
5942
6147
|
success: false,
|
|
5943
6148
|
error: new Error(
|
|
5944
|
-
`Invalid frontmatter in ${
|
|
6149
|
+
`Invalid frontmatter in ${join61(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
5945
6150
|
)
|
|
5946
6151
|
};
|
|
5947
6152
|
}
|
|
@@ -5950,12 +6155,12 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
5950
6155
|
relativeFilePath,
|
|
5951
6156
|
validate = true
|
|
5952
6157
|
}) {
|
|
5953
|
-
const legacyPath =
|
|
6158
|
+
const legacyPath = join61(
|
|
5954
6159
|
process.cwd(),
|
|
5955
6160
|
this.getSettablePaths().legacy.relativeDirPath,
|
|
5956
6161
|
relativeFilePath
|
|
5957
6162
|
);
|
|
5958
|
-
const recommendedPath =
|
|
6163
|
+
const recommendedPath = join61(
|
|
5959
6164
|
this.getSettablePaths().recommended.relativeDirPath,
|
|
5960
6165
|
relativeFilePath
|
|
5961
6166
|
);
|
|
@@ -5988,7 +6193,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
5988
6193
|
relativeFilePath,
|
|
5989
6194
|
validate = true
|
|
5990
6195
|
}) {
|
|
5991
|
-
const filePath =
|
|
6196
|
+
const filePath = join61(
|
|
5992
6197
|
process.cwd(),
|
|
5993
6198
|
this.getSettablePaths().recommended.relativeDirPath,
|
|
5994
6199
|
relativeFilePath
|
|
@@ -6082,7 +6287,7 @@ var ToolRule = class extends ToolFile {
|
|
|
6082
6287
|
rulesyncRule,
|
|
6083
6288
|
validate = true,
|
|
6084
6289
|
rootPath = { relativeDirPath: ".", relativeFilePath: "AGENTS.md" },
|
|
6085
|
-
nonRootPath = { relativeDirPath:
|
|
6290
|
+
nonRootPath = { relativeDirPath: join62(".agents", "memories") }
|
|
6086
6291
|
}) {
|
|
6087
6292
|
const params = this.buildToolRuleParamsDefault({
|
|
6088
6293
|
baseDir,
|
|
@@ -6093,7 +6298,7 @@ var ToolRule = class extends ToolFile {
|
|
|
6093
6298
|
});
|
|
6094
6299
|
const rulesyncFrontmatter = rulesyncRule.getFrontmatter();
|
|
6095
6300
|
if (!rulesyncFrontmatter.root && rulesyncFrontmatter.agentsmd?.subprojectPath) {
|
|
6096
|
-
params.relativeDirPath =
|
|
6301
|
+
params.relativeDirPath = join62(rulesyncFrontmatter.agentsmd.subprojectPath);
|
|
6097
6302
|
params.relativeFilePath = "AGENTS.md";
|
|
6098
6303
|
}
|
|
6099
6304
|
return params;
|
|
@@ -6158,7 +6363,7 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
6158
6363
|
relativeFilePath: "AGENTS.md"
|
|
6159
6364
|
},
|
|
6160
6365
|
nonRoot: {
|
|
6161
|
-
relativeDirPath:
|
|
6366
|
+
relativeDirPath: join63(".agents", "memories")
|
|
6162
6367
|
}
|
|
6163
6368
|
};
|
|
6164
6369
|
}
|
|
@@ -6168,8 +6373,8 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
6168
6373
|
validate = true
|
|
6169
6374
|
}) {
|
|
6170
6375
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
6171
|
-
const relativePath = isRoot ? "AGENTS.md" :
|
|
6172
|
-
const fileContent = await readFileContent(
|
|
6376
|
+
const relativePath = isRoot ? "AGENTS.md" : join63(".agents", "memories", relativeFilePath);
|
|
6377
|
+
const fileContent = await readFileContent(join63(baseDir, relativePath));
|
|
6173
6378
|
return new _AgentsMdRule({
|
|
6174
6379
|
baseDir,
|
|
6175
6380
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -6209,12 +6414,12 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
6209
6414
|
};
|
|
6210
6415
|
|
|
6211
6416
|
// src/features/rules/amazonqcli-rule.ts
|
|
6212
|
-
import { join as
|
|
6417
|
+
import { join as join64 } from "path";
|
|
6213
6418
|
var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
6214
6419
|
static getSettablePaths() {
|
|
6215
6420
|
return {
|
|
6216
6421
|
nonRoot: {
|
|
6217
|
-
relativeDirPath:
|
|
6422
|
+
relativeDirPath: join64(".amazonq", "rules")
|
|
6218
6423
|
}
|
|
6219
6424
|
};
|
|
6220
6425
|
}
|
|
@@ -6224,7 +6429,7 @@ var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
|
6224
6429
|
validate = true
|
|
6225
6430
|
}) {
|
|
6226
6431
|
const fileContent = await readFileContent(
|
|
6227
|
-
|
|
6432
|
+
join64(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
6228
6433
|
);
|
|
6229
6434
|
return new _AmazonQCliRule({
|
|
6230
6435
|
baseDir,
|
|
@@ -6264,12 +6469,12 @@ var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
|
6264
6469
|
};
|
|
6265
6470
|
|
|
6266
6471
|
// src/features/rules/antigravity-rule.ts
|
|
6267
|
-
import { join as
|
|
6472
|
+
import { join as join65 } from "path";
|
|
6268
6473
|
var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
6269
6474
|
static getSettablePaths() {
|
|
6270
6475
|
return {
|
|
6271
6476
|
nonRoot: {
|
|
6272
|
-
relativeDirPath:
|
|
6477
|
+
relativeDirPath: join65(".agent", "rules")
|
|
6273
6478
|
}
|
|
6274
6479
|
};
|
|
6275
6480
|
}
|
|
@@ -6279,7 +6484,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
6279
6484
|
validate = true
|
|
6280
6485
|
}) {
|
|
6281
6486
|
const fileContent = await readFileContent(
|
|
6282
|
-
|
|
6487
|
+
join65(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
6283
6488
|
);
|
|
6284
6489
|
return new _AntigravityRule({
|
|
6285
6490
|
baseDir,
|
|
@@ -6319,7 +6524,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
6319
6524
|
};
|
|
6320
6525
|
|
|
6321
6526
|
// src/features/rules/augmentcode-legacy-rule.ts
|
|
6322
|
-
import { join as
|
|
6527
|
+
import { join as join66 } from "path";
|
|
6323
6528
|
var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
6324
6529
|
toRulesyncRule() {
|
|
6325
6530
|
const rulesyncFrontmatter = {
|
|
@@ -6345,7 +6550,7 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
6345
6550
|
relativeFilePath: ".augment-guidelines"
|
|
6346
6551
|
},
|
|
6347
6552
|
nonRoot: {
|
|
6348
|
-
relativeDirPath:
|
|
6553
|
+
relativeDirPath: join66(".augment", "rules")
|
|
6349
6554
|
}
|
|
6350
6555
|
};
|
|
6351
6556
|
}
|
|
@@ -6380,62 +6585,153 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
6380
6585
|
}) {
|
|
6381
6586
|
const settablePaths = this.getSettablePaths();
|
|
6382
6587
|
const isRoot = relativeFilePath === settablePaths.root.relativeFilePath;
|
|
6383
|
-
const relativePath = isRoot ? settablePaths.root.relativeFilePath :
|
|
6384
|
-
const fileContent = await readFileContent(
|
|
6588
|
+
const relativePath = isRoot ? settablePaths.root.relativeFilePath : join66(settablePaths.nonRoot.relativeDirPath, relativeFilePath);
|
|
6589
|
+
const fileContent = await readFileContent(join66(baseDir, relativePath));
|
|
6385
6590
|
return new _AugmentcodeLegacyRule({
|
|
6386
6591
|
baseDir,
|
|
6387
|
-
relativeDirPath: isRoot ? settablePaths.root.relativeDirPath : settablePaths.nonRoot.relativeDirPath,
|
|
6388
|
-
relativeFilePath: isRoot ? settablePaths.root.relativeFilePath : relativeFilePath,
|
|
6592
|
+
relativeDirPath: isRoot ? settablePaths.root.relativeDirPath : settablePaths.nonRoot.relativeDirPath,
|
|
6593
|
+
relativeFilePath: isRoot ? settablePaths.root.relativeFilePath : relativeFilePath,
|
|
6594
|
+
fileContent,
|
|
6595
|
+
validate,
|
|
6596
|
+
root: isRoot
|
|
6597
|
+
});
|
|
6598
|
+
}
|
|
6599
|
+
};
|
|
6600
|
+
|
|
6601
|
+
// src/features/rules/augmentcode-rule.ts
|
|
6602
|
+
import { join as join67 } from "path";
|
|
6603
|
+
var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
6604
|
+
toRulesyncRule() {
|
|
6605
|
+
return this.toRulesyncRuleDefault();
|
|
6606
|
+
}
|
|
6607
|
+
static getSettablePaths() {
|
|
6608
|
+
return {
|
|
6609
|
+
nonRoot: {
|
|
6610
|
+
relativeDirPath: join67(".augment", "rules")
|
|
6611
|
+
}
|
|
6612
|
+
};
|
|
6613
|
+
}
|
|
6614
|
+
static fromRulesyncRule({
|
|
6615
|
+
baseDir = process.cwd(),
|
|
6616
|
+
rulesyncRule,
|
|
6617
|
+
validate = true
|
|
6618
|
+
}) {
|
|
6619
|
+
return new _AugmentcodeRule(
|
|
6620
|
+
this.buildToolRuleParamsDefault({
|
|
6621
|
+
baseDir,
|
|
6622
|
+
rulesyncRule,
|
|
6623
|
+
validate,
|
|
6624
|
+
nonRootPath: this.getSettablePaths().nonRoot
|
|
6625
|
+
})
|
|
6626
|
+
);
|
|
6627
|
+
}
|
|
6628
|
+
static async fromFile({
|
|
6629
|
+
baseDir = process.cwd(),
|
|
6630
|
+
relativeFilePath,
|
|
6631
|
+
validate = true
|
|
6632
|
+
}) {
|
|
6633
|
+
const fileContent = await readFileContent(
|
|
6634
|
+
join67(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
6635
|
+
);
|
|
6636
|
+
const { body: content } = parseFrontmatter(fileContent);
|
|
6637
|
+
return new _AugmentcodeRule({
|
|
6638
|
+
baseDir,
|
|
6639
|
+
relativeDirPath: this.getSettablePaths().nonRoot.relativeDirPath,
|
|
6640
|
+
relativeFilePath,
|
|
6641
|
+
fileContent: content.trim(),
|
|
6642
|
+
validate
|
|
6643
|
+
});
|
|
6644
|
+
}
|
|
6645
|
+
validate() {
|
|
6646
|
+
return { success: true, error: null };
|
|
6647
|
+
}
|
|
6648
|
+
static isTargetedByRulesyncRule(rulesyncRule) {
|
|
6649
|
+
return this.isTargetedByRulesyncRuleDefault({
|
|
6650
|
+
rulesyncRule,
|
|
6651
|
+
toolTarget: "augmentcode"
|
|
6652
|
+
});
|
|
6653
|
+
}
|
|
6654
|
+
};
|
|
6655
|
+
|
|
6656
|
+
// src/features/rules/claudecode-legacy-rule.ts
|
|
6657
|
+
import { join as join68 } from "path";
|
|
6658
|
+
var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
6659
|
+
static getSettablePaths({
|
|
6660
|
+
global
|
|
6661
|
+
} = {}) {
|
|
6662
|
+
if (global) {
|
|
6663
|
+
return {
|
|
6664
|
+
root: {
|
|
6665
|
+
relativeDirPath: ".claude",
|
|
6666
|
+
relativeFilePath: "CLAUDE.md"
|
|
6667
|
+
}
|
|
6668
|
+
};
|
|
6669
|
+
}
|
|
6670
|
+
return {
|
|
6671
|
+
root: {
|
|
6672
|
+
relativeDirPath: ".",
|
|
6673
|
+
relativeFilePath: "CLAUDE.md"
|
|
6674
|
+
},
|
|
6675
|
+
nonRoot: {
|
|
6676
|
+
relativeDirPath: join68(".claude", "memories")
|
|
6677
|
+
}
|
|
6678
|
+
};
|
|
6679
|
+
}
|
|
6680
|
+
static async fromFile({
|
|
6681
|
+
baseDir = process.cwd(),
|
|
6682
|
+
relativeFilePath,
|
|
6683
|
+
validate = true,
|
|
6684
|
+
global = false
|
|
6685
|
+
}) {
|
|
6686
|
+
const paths = this.getSettablePaths({ global });
|
|
6687
|
+
const isRoot = relativeFilePath === paths.root.relativeFilePath;
|
|
6688
|
+
if (isRoot) {
|
|
6689
|
+
const relativePath2 = paths.root.relativeFilePath;
|
|
6690
|
+
const fileContent2 = await readFileContent(
|
|
6691
|
+
join68(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
6692
|
+
);
|
|
6693
|
+
return new _ClaudecodeLegacyRule({
|
|
6694
|
+
baseDir,
|
|
6695
|
+
relativeDirPath: paths.root.relativeDirPath,
|
|
6696
|
+
relativeFilePath: paths.root.relativeFilePath,
|
|
6697
|
+
fileContent: fileContent2,
|
|
6698
|
+
validate,
|
|
6699
|
+
root: true
|
|
6700
|
+
});
|
|
6701
|
+
}
|
|
6702
|
+
if (!paths.nonRoot) {
|
|
6703
|
+
throw new Error("nonRoot path is not set");
|
|
6704
|
+
}
|
|
6705
|
+
const relativePath = join68(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
6706
|
+
const fileContent = await readFileContent(join68(baseDir, relativePath));
|
|
6707
|
+
return new _ClaudecodeLegacyRule({
|
|
6708
|
+
baseDir,
|
|
6709
|
+
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
6710
|
+
relativeFilePath,
|
|
6389
6711
|
fileContent,
|
|
6390
6712
|
validate,
|
|
6391
|
-
root:
|
|
6713
|
+
root: false
|
|
6392
6714
|
});
|
|
6393
6715
|
}
|
|
6394
|
-
};
|
|
6395
|
-
|
|
6396
|
-
// src/features/rules/augmentcode-rule.ts
|
|
6397
|
-
import { join as join66 } from "path";
|
|
6398
|
-
var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
6399
|
-
toRulesyncRule() {
|
|
6400
|
-
return this.toRulesyncRuleDefault();
|
|
6401
|
-
}
|
|
6402
|
-
static getSettablePaths() {
|
|
6403
|
-
return {
|
|
6404
|
-
nonRoot: {
|
|
6405
|
-
relativeDirPath: join66(".augment", "rules")
|
|
6406
|
-
}
|
|
6407
|
-
};
|
|
6408
|
-
}
|
|
6409
6716
|
static fromRulesyncRule({
|
|
6410
6717
|
baseDir = process.cwd(),
|
|
6411
6718
|
rulesyncRule,
|
|
6412
|
-
validate = true
|
|
6719
|
+
validate = true,
|
|
6720
|
+
global = false
|
|
6413
6721
|
}) {
|
|
6414
|
-
|
|
6722
|
+
const paths = this.getSettablePaths({ global });
|
|
6723
|
+
return new _ClaudecodeLegacyRule(
|
|
6415
6724
|
this.buildToolRuleParamsDefault({
|
|
6416
6725
|
baseDir,
|
|
6417
6726
|
rulesyncRule,
|
|
6418
6727
|
validate,
|
|
6419
|
-
|
|
6728
|
+
rootPath: paths.root,
|
|
6729
|
+
nonRootPath: paths.nonRoot
|
|
6420
6730
|
})
|
|
6421
6731
|
);
|
|
6422
6732
|
}
|
|
6423
|
-
|
|
6424
|
-
|
|
6425
|
-
relativeFilePath,
|
|
6426
|
-
validate = true
|
|
6427
|
-
}) {
|
|
6428
|
-
const fileContent = await readFileContent(
|
|
6429
|
-
join66(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
6430
|
-
);
|
|
6431
|
-
const { body: content } = parseFrontmatter(fileContent);
|
|
6432
|
-
return new _AugmentcodeRule({
|
|
6433
|
-
baseDir,
|
|
6434
|
-
relativeDirPath: this.getSettablePaths().nonRoot.relativeDirPath,
|
|
6435
|
-
relativeFilePath,
|
|
6436
|
-
fileContent: content.trim(),
|
|
6437
|
-
validate
|
|
6438
|
-
});
|
|
6733
|
+
toRulesyncRule() {
|
|
6734
|
+
return this.toRulesyncRuleDefault();
|
|
6439
6735
|
}
|
|
6440
6736
|
validate() {
|
|
6441
6737
|
return { success: true, error: null };
|
|
@@ -6443,14 +6739,20 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
6443
6739
|
static isTargetedByRulesyncRule(rulesyncRule) {
|
|
6444
6740
|
return this.isTargetedByRulesyncRuleDefault({
|
|
6445
6741
|
rulesyncRule,
|
|
6446
|
-
toolTarget: "
|
|
6742
|
+
toolTarget: "claudecode-legacy"
|
|
6447
6743
|
});
|
|
6448
6744
|
}
|
|
6449
6745
|
};
|
|
6450
6746
|
|
|
6451
6747
|
// src/features/rules/claudecode-rule.ts
|
|
6452
|
-
import { join as
|
|
6748
|
+
import { join as join69 } from "path";
|
|
6749
|
+
import { z as z29 } from "zod/mini";
|
|
6750
|
+
var ClaudecodeRuleFrontmatterSchema = z29.object({
|
|
6751
|
+
paths: z29.optional(z29.string())
|
|
6752
|
+
});
|
|
6453
6753
|
var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
6754
|
+
frontmatter;
|
|
6755
|
+
body;
|
|
6454
6756
|
static getSettablePaths({
|
|
6455
6757
|
global
|
|
6456
6758
|
} = {}) {
|
|
@@ -6464,14 +6766,37 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
6464
6766
|
}
|
|
6465
6767
|
return {
|
|
6466
6768
|
root: {
|
|
6467
|
-
relativeDirPath: ".",
|
|
6769
|
+
relativeDirPath: ".claude",
|
|
6468
6770
|
relativeFilePath: "CLAUDE.md"
|
|
6469
6771
|
},
|
|
6470
6772
|
nonRoot: {
|
|
6471
|
-
relativeDirPath:
|
|
6773
|
+
relativeDirPath: join69(".claude", "rules")
|
|
6472
6774
|
}
|
|
6473
6775
|
};
|
|
6474
6776
|
}
|
|
6777
|
+
constructor({ frontmatter, body, ...rest }) {
|
|
6778
|
+
if (rest.validate) {
|
|
6779
|
+
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
6780
|
+
if (!result.success) {
|
|
6781
|
+
throw new Error(
|
|
6782
|
+
`Invalid frontmatter in ${join69(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6783
|
+
);
|
|
6784
|
+
}
|
|
6785
|
+
}
|
|
6786
|
+
super({
|
|
6787
|
+
...rest,
|
|
6788
|
+
// Root file: no frontmatter; Non-root file: with optional paths frontmatter
|
|
6789
|
+
fileContent: rest.root ? body : _ClaudecodeRule.generateFileContent(body, frontmatter)
|
|
6790
|
+
});
|
|
6791
|
+
this.frontmatter = frontmatter;
|
|
6792
|
+
this.body = body;
|
|
6793
|
+
}
|
|
6794
|
+
static generateFileContent(body, frontmatter) {
|
|
6795
|
+
if (frontmatter.paths) {
|
|
6796
|
+
return stringifyFrontmatter(body, { paths: frontmatter.paths });
|
|
6797
|
+
}
|
|
6798
|
+
return body;
|
|
6799
|
+
}
|
|
6475
6800
|
static async fromFile({
|
|
6476
6801
|
baseDir = process.cwd(),
|
|
6477
6802
|
relativeFilePath,
|
|
@@ -6481,15 +6806,15 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
6481
6806
|
const paths = this.getSettablePaths({ global });
|
|
6482
6807
|
const isRoot = relativeFilePath === paths.root.relativeFilePath;
|
|
6483
6808
|
if (isRoot) {
|
|
6484
|
-
const relativePath2 = paths.root.relativeFilePath;
|
|
6485
6809
|
const fileContent2 = await readFileContent(
|
|
6486
|
-
|
|
6810
|
+
join69(baseDir, paths.root.relativeDirPath, paths.root.relativeFilePath)
|
|
6487
6811
|
);
|
|
6488
6812
|
return new _ClaudecodeRule({
|
|
6489
6813
|
baseDir,
|
|
6490
6814
|
relativeDirPath: paths.root.relativeDirPath,
|
|
6491
6815
|
relativeFilePath: paths.root.relativeFilePath,
|
|
6492
|
-
|
|
6816
|
+
frontmatter: {},
|
|
6817
|
+
body: fileContent2.trim(),
|
|
6493
6818
|
validate,
|
|
6494
6819
|
root: true
|
|
6495
6820
|
});
|
|
@@ -6497,13 +6822,21 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
6497
6822
|
if (!paths.nonRoot) {
|
|
6498
6823
|
throw new Error("nonRoot path is not set");
|
|
6499
6824
|
}
|
|
6500
|
-
const relativePath =
|
|
6501
|
-
const fileContent = await readFileContent(
|
|
6825
|
+
const relativePath = join69(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
6826
|
+
const fileContent = await readFileContent(join69(baseDir, relativePath));
|
|
6827
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
6828
|
+
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
6829
|
+
if (!result.success) {
|
|
6830
|
+
throw new Error(
|
|
6831
|
+
`Invalid frontmatter in ${join69(baseDir, relativePath)}: ${formatError(result.error)}`
|
|
6832
|
+
);
|
|
6833
|
+
}
|
|
6502
6834
|
return new _ClaudecodeRule({
|
|
6503
6835
|
baseDir,
|
|
6504
6836
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
6505
6837
|
relativeFilePath,
|
|
6506
|
-
|
|
6838
|
+
frontmatter: result.data,
|
|
6839
|
+
body: content.trim(),
|
|
6507
6840
|
validate,
|
|
6508
6841
|
root: false
|
|
6509
6842
|
});
|
|
@@ -6514,22 +6847,86 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
6514
6847
|
validate = true,
|
|
6515
6848
|
global = false
|
|
6516
6849
|
}) {
|
|
6850
|
+
const rulesyncFrontmatter = rulesyncRule.getFrontmatter();
|
|
6851
|
+
const root = rulesyncFrontmatter.root ?? false;
|
|
6517
6852
|
const paths = this.getSettablePaths({ global });
|
|
6518
|
-
|
|
6519
|
-
|
|
6853
|
+
const claudecodePaths = rulesyncFrontmatter.claudecode?.paths;
|
|
6854
|
+
const globs = rulesyncFrontmatter.globs;
|
|
6855
|
+
const pathsValue = claudecodePaths ?? (globs?.length ? globs.join(", ") : void 0);
|
|
6856
|
+
const claudecodeFrontmatter = {
|
|
6857
|
+
paths: root ? void 0 : pathsValue
|
|
6858
|
+
};
|
|
6859
|
+
const body = rulesyncRule.getBody();
|
|
6860
|
+
if (root) {
|
|
6861
|
+
return new _ClaudecodeRule({
|
|
6520
6862
|
baseDir,
|
|
6521
|
-
|
|
6863
|
+
frontmatter: claudecodeFrontmatter,
|
|
6864
|
+
body,
|
|
6865
|
+
relativeDirPath: paths.root.relativeDirPath,
|
|
6866
|
+
relativeFilePath: paths.root.relativeFilePath,
|
|
6522
6867
|
validate,
|
|
6523
|
-
|
|
6524
|
-
|
|
6525
|
-
|
|
6526
|
-
)
|
|
6868
|
+
root
|
|
6869
|
+
});
|
|
6870
|
+
}
|
|
6871
|
+
if (!paths.nonRoot) {
|
|
6872
|
+
throw new Error("nonRoot path is not set");
|
|
6873
|
+
}
|
|
6874
|
+
return new _ClaudecodeRule({
|
|
6875
|
+
baseDir,
|
|
6876
|
+
frontmatter: claudecodeFrontmatter,
|
|
6877
|
+
body,
|
|
6878
|
+
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
6879
|
+
relativeFilePath: rulesyncRule.getRelativeFilePath(),
|
|
6880
|
+
validate,
|
|
6881
|
+
root
|
|
6882
|
+
});
|
|
6527
6883
|
}
|
|
6528
6884
|
toRulesyncRule() {
|
|
6529
|
-
|
|
6885
|
+
let globs;
|
|
6886
|
+
if (this.isRoot()) {
|
|
6887
|
+
globs = ["**/*"];
|
|
6888
|
+
} else if (this.frontmatter.paths) {
|
|
6889
|
+
globs = this.frontmatter.paths.split(",").map((g) => g.trim());
|
|
6890
|
+
}
|
|
6891
|
+
const rulesyncFrontmatter = {
|
|
6892
|
+
targets: ["*"],
|
|
6893
|
+
root: this.isRoot(),
|
|
6894
|
+
description: this.description,
|
|
6895
|
+
globs,
|
|
6896
|
+
...this.frontmatter.paths && {
|
|
6897
|
+
claudecode: { paths: this.frontmatter.paths }
|
|
6898
|
+
}
|
|
6899
|
+
};
|
|
6900
|
+
return new RulesyncRule({
|
|
6901
|
+
baseDir: this.getBaseDir(),
|
|
6902
|
+
frontmatter: rulesyncFrontmatter,
|
|
6903
|
+
body: this.body,
|
|
6904
|
+
relativeDirPath: RULESYNC_RULES_RELATIVE_DIR_PATH,
|
|
6905
|
+
relativeFilePath: this.getRelativeFilePath(),
|
|
6906
|
+
validate: true
|
|
6907
|
+
});
|
|
6530
6908
|
}
|
|
6531
6909
|
validate() {
|
|
6532
|
-
|
|
6910
|
+
if (!this.frontmatter) {
|
|
6911
|
+
return { success: true, error: null };
|
|
6912
|
+
}
|
|
6913
|
+
const result = ClaudecodeRuleFrontmatterSchema.safeParse(this.frontmatter);
|
|
6914
|
+
if (result.success) {
|
|
6915
|
+
return { success: true, error: null };
|
|
6916
|
+
} else {
|
|
6917
|
+
return {
|
|
6918
|
+
success: false,
|
|
6919
|
+
error: new Error(
|
|
6920
|
+
`Invalid frontmatter in ${join69(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6921
|
+
)
|
|
6922
|
+
};
|
|
6923
|
+
}
|
|
6924
|
+
}
|
|
6925
|
+
getFrontmatter() {
|
|
6926
|
+
return this.frontmatter;
|
|
6927
|
+
}
|
|
6928
|
+
getBody() {
|
|
6929
|
+
return this.body;
|
|
6533
6930
|
}
|
|
6534
6931
|
static isTargetedByRulesyncRule(rulesyncRule) {
|
|
6535
6932
|
return this.isTargetedByRulesyncRuleDefault({
|
|
@@ -6540,10 +6937,10 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
6540
6937
|
};
|
|
6541
6938
|
|
|
6542
6939
|
// src/features/rules/cline-rule.ts
|
|
6543
|
-
import { join as
|
|
6544
|
-
import { z as
|
|
6545
|
-
var ClineRuleFrontmatterSchema =
|
|
6546
|
-
description:
|
|
6940
|
+
import { join as join70 } from "path";
|
|
6941
|
+
import { z as z30 } from "zod/mini";
|
|
6942
|
+
var ClineRuleFrontmatterSchema = z30.object({
|
|
6943
|
+
description: z30.string()
|
|
6547
6944
|
});
|
|
6548
6945
|
var ClineRule = class _ClineRule extends ToolRule {
|
|
6549
6946
|
static getSettablePaths() {
|
|
@@ -6585,7 +6982,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
6585
6982
|
validate = true
|
|
6586
6983
|
}) {
|
|
6587
6984
|
const fileContent = await readFileContent(
|
|
6588
|
-
|
|
6985
|
+
join70(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
6589
6986
|
);
|
|
6590
6987
|
return new _ClineRule({
|
|
6591
6988
|
baseDir,
|
|
@@ -6598,7 +6995,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
6598
6995
|
};
|
|
6599
6996
|
|
|
6600
6997
|
// src/features/rules/codexcli-rule.ts
|
|
6601
|
-
import { join as
|
|
6998
|
+
import { join as join71 } from "path";
|
|
6602
6999
|
var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
6603
7000
|
static getSettablePaths({
|
|
6604
7001
|
global
|
|
@@ -6617,7 +7014,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
6617
7014
|
relativeFilePath: "AGENTS.md"
|
|
6618
7015
|
},
|
|
6619
7016
|
nonRoot: {
|
|
6620
|
-
relativeDirPath:
|
|
7017
|
+
relativeDirPath: join71(".codex", "memories")
|
|
6621
7018
|
}
|
|
6622
7019
|
};
|
|
6623
7020
|
}
|
|
@@ -6632,7 +7029,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
6632
7029
|
if (isRoot) {
|
|
6633
7030
|
const relativePath2 = paths.root.relativeFilePath;
|
|
6634
7031
|
const fileContent2 = await readFileContent(
|
|
6635
|
-
|
|
7032
|
+
join71(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
6636
7033
|
);
|
|
6637
7034
|
return new _CodexcliRule({
|
|
6638
7035
|
baseDir,
|
|
@@ -6646,8 +7043,8 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
6646
7043
|
if (!paths.nonRoot) {
|
|
6647
7044
|
throw new Error("nonRoot path is not set");
|
|
6648
7045
|
}
|
|
6649
|
-
const relativePath =
|
|
6650
|
-
const fileContent = await readFileContent(
|
|
7046
|
+
const relativePath = join71(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
7047
|
+
const fileContent = await readFileContent(join71(baseDir, relativePath));
|
|
6651
7048
|
return new _CodexcliRule({
|
|
6652
7049
|
baseDir,
|
|
6653
7050
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -6689,12 +7086,12 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
6689
7086
|
};
|
|
6690
7087
|
|
|
6691
7088
|
// src/features/rules/copilot-rule.ts
|
|
6692
|
-
import { join as
|
|
6693
|
-
import { z as
|
|
6694
|
-
var CopilotRuleFrontmatterSchema =
|
|
6695
|
-
description:
|
|
6696
|
-
applyTo:
|
|
6697
|
-
excludeAgent:
|
|
7089
|
+
import { join as join72 } from "path";
|
|
7090
|
+
import { z as z31 } from "zod/mini";
|
|
7091
|
+
var CopilotRuleFrontmatterSchema = z31.object({
|
|
7092
|
+
description: z31.optional(z31.string()),
|
|
7093
|
+
applyTo: z31.optional(z31.string()),
|
|
7094
|
+
excludeAgent: z31.optional(z31.union([z31.literal("code-review"), z31.literal("coding-agent")]))
|
|
6698
7095
|
});
|
|
6699
7096
|
var CopilotRule = class _CopilotRule extends ToolRule {
|
|
6700
7097
|
frontmatter;
|
|
@@ -6706,7 +7103,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
6706
7103
|
relativeFilePath: "copilot-instructions.md"
|
|
6707
7104
|
},
|
|
6708
7105
|
nonRoot: {
|
|
6709
|
-
relativeDirPath:
|
|
7106
|
+
relativeDirPath: join72(".github", "instructions")
|
|
6710
7107
|
}
|
|
6711
7108
|
};
|
|
6712
7109
|
}
|
|
@@ -6715,7 +7112,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
6715
7112
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
6716
7113
|
if (!result.success) {
|
|
6717
7114
|
throw new Error(
|
|
6718
|
-
`Invalid frontmatter in ${
|
|
7115
|
+
`Invalid frontmatter in ${join72(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6719
7116
|
);
|
|
6720
7117
|
}
|
|
6721
7118
|
}
|
|
@@ -6797,11 +7194,11 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
6797
7194
|
validate = true
|
|
6798
7195
|
}) {
|
|
6799
7196
|
const isRoot = relativeFilePath === "copilot-instructions.md";
|
|
6800
|
-
const relativePath = isRoot ?
|
|
7197
|
+
const relativePath = isRoot ? join72(
|
|
6801
7198
|
this.getSettablePaths().root.relativeDirPath,
|
|
6802
7199
|
this.getSettablePaths().root.relativeFilePath
|
|
6803
|
-
) :
|
|
6804
|
-
const fileContent = await readFileContent(
|
|
7200
|
+
) : join72(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
7201
|
+
const fileContent = await readFileContent(join72(baseDir, relativePath));
|
|
6805
7202
|
if (isRoot) {
|
|
6806
7203
|
return new _CopilotRule({
|
|
6807
7204
|
baseDir,
|
|
@@ -6817,7 +7214,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
6817
7214
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
6818
7215
|
if (!result.success) {
|
|
6819
7216
|
throw new Error(
|
|
6820
|
-
`Invalid frontmatter in ${
|
|
7217
|
+
`Invalid frontmatter in ${join72(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
6821
7218
|
);
|
|
6822
7219
|
}
|
|
6823
7220
|
return new _CopilotRule({
|
|
@@ -6841,7 +7238,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
6841
7238
|
return {
|
|
6842
7239
|
success: false,
|
|
6843
7240
|
error: new Error(
|
|
6844
|
-
`Invalid frontmatter in ${
|
|
7241
|
+
`Invalid frontmatter in ${join72(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6845
7242
|
)
|
|
6846
7243
|
};
|
|
6847
7244
|
}
|
|
@@ -6861,12 +7258,12 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
6861
7258
|
};
|
|
6862
7259
|
|
|
6863
7260
|
// src/features/rules/cursor-rule.ts
|
|
6864
|
-
import { basename as basename20, join as
|
|
6865
|
-
import { z as
|
|
6866
|
-
var CursorRuleFrontmatterSchema =
|
|
6867
|
-
description:
|
|
6868
|
-
globs:
|
|
6869
|
-
alwaysApply:
|
|
7261
|
+
import { basename as basename20, join as join73 } from "path";
|
|
7262
|
+
import { z as z32 } from "zod/mini";
|
|
7263
|
+
var CursorRuleFrontmatterSchema = z32.object({
|
|
7264
|
+
description: z32.optional(z32.string()),
|
|
7265
|
+
globs: z32.optional(z32.string()),
|
|
7266
|
+
alwaysApply: z32.optional(z32.boolean())
|
|
6870
7267
|
});
|
|
6871
7268
|
var CursorRule = class _CursorRule extends ToolRule {
|
|
6872
7269
|
frontmatter;
|
|
@@ -6874,7 +7271,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
6874
7271
|
static getSettablePaths() {
|
|
6875
7272
|
return {
|
|
6876
7273
|
nonRoot: {
|
|
6877
|
-
relativeDirPath:
|
|
7274
|
+
relativeDirPath: join73(".cursor", "rules")
|
|
6878
7275
|
}
|
|
6879
7276
|
};
|
|
6880
7277
|
}
|
|
@@ -6883,7 +7280,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
6883
7280
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
6884
7281
|
if (!result.success) {
|
|
6885
7282
|
throw new Error(
|
|
6886
|
-
`Invalid frontmatter in ${
|
|
7283
|
+
`Invalid frontmatter in ${join73(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6887
7284
|
);
|
|
6888
7285
|
}
|
|
6889
7286
|
}
|
|
@@ -7000,13 +7397,13 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
7000
7397
|
validate = true
|
|
7001
7398
|
}) {
|
|
7002
7399
|
const fileContent = await readFileContent(
|
|
7003
|
-
|
|
7400
|
+
join73(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7004
7401
|
);
|
|
7005
7402
|
const { frontmatter, body: content } = _CursorRule.parseCursorFrontmatter(fileContent);
|
|
7006
7403
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7007
7404
|
if (!result.success) {
|
|
7008
7405
|
throw new Error(
|
|
7009
|
-
`Invalid frontmatter in ${
|
|
7406
|
+
`Invalid frontmatter in ${join73(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
7010
7407
|
);
|
|
7011
7408
|
}
|
|
7012
7409
|
return new _CursorRule({
|
|
@@ -7029,7 +7426,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
7029
7426
|
return {
|
|
7030
7427
|
success: false,
|
|
7031
7428
|
error: new Error(
|
|
7032
|
-
`Invalid frontmatter in ${
|
|
7429
|
+
`Invalid frontmatter in ${join73(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
7033
7430
|
)
|
|
7034
7431
|
};
|
|
7035
7432
|
}
|
|
@@ -7049,7 +7446,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
7049
7446
|
};
|
|
7050
7447
|
|
|
7051
7448
|
// src/features/rules/geminicli-rule.ts
|
|
7052
|
-
import { join as
|
|
7449
|
+
import { join as join74 } from "path";
|
|
7053
7450
|
var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
7054
7451
|
static getSettablePaths({
|
|
7055
7452
|
global
|
|
@@ -7068,7 +7465,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
7068
7465
|
relativeFilePath: "GEMINI.md"
|
|
7069
7466
|
},
|
|
7070
7467
|
nonRoot: {
|
|
7071
|
-
relativeDirPath:
|
|
7468
|
+
relativeDirPath: join74(".gemini", "memories")
|
|
7072
7469
|
}
|
|
7073
7470
|
};
|
|
7074
7471
|
}
|
|
@@ -7083,7 +7480,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
7083
7480
|
if (isRoot) {
|
|
7084
7481
|
const relativePath2 = paths.root.relativeFilePath;
|
|
7085
7482
|
const fileContent2 = await readFileContent(
|
|
7086
|
-
|
|
7483
|
+
join74(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
7087
7484
|
);
|
|
7088
7485
|
return new _GeminiCliRule({
|
|
7089
7486
|
baseDir,
|
|
@@ -7097,8 +7494,8 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
7097
7494
|
if (!paths.nonRoot) {
|
|
7098
7495
|
throw new Error("nonRoot path is not set");
|
|
7099
7496
|
}
|
|
7100
|
-
const relativePath =
|
|
7101
|
-
const fileContent = await readFileContent(
|
|
7497
|
+
const relativePath = join74(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
7498
|
+
const fileContent = await readFileContent(join74(baseDir, relativePath));
|
|
7102
7499
|
return new _GeminiCliRule({
|
|
7103
7500
|
baseDir,
|
|
7104
7501
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -7140,7 +7537,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
7140
7537
|
};
|
|
7141
7538
|
|
|
7142
7539
|
// src/features/rules/junie-rule.ts
|
|
7143
|
-
import { join as
|
|
7540
|
+
import { join as join75 } from "path";
|
|
7144
7541
|
var JunieRule = class _JunieRule extends ToolRule {
|
|
7145
7542
|
static getSettablePaths() {
|
|
7146
7543
|
return {
|
|
@@ -7149,7 +7546,7 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
7149
7546
|
relativeFilePath: "guidelines.md"
|
|
7150
7547
|
},
|
|
7151
7548
|
nonRoot: {
|
|
7152
|
-
relativeDirPath:
|
|
7549
|
+
relativeDirPath: join75(".junie", "memories")
|
|
7153
7550
|
}
|
|
7154
7551
|
};
|
|
7155
7552
|
}
|
|
@@ -7159,8 +7556,8 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
7159
7556
|
validate = true
|
|
7160
7557
|
}) {
|
|
7161
7558
|
const isRoot = relativeFilePath === "guidelines.md";
|
|
7162
|
-
const relativePath = isRoot ? "guidelines.md" :
|
|
7163
|
-
const fileContent = await readFileContent(
|
|
7559
|
+
const relativePath = isRoot ? "guidelines.md" : join75(".junie", "memories", relativeFilePath);
|
|
7560
|
+
const fileContent = await readFileContent(join75(baseDir, relativePath));
|
|
7164
7561
|
return new _JunieRule({
|
|
7165
7562
|
baseDir,
|
|
7166
7563
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -7200,12 +7597,12 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
7200
7597
|
};
|
|
7201
7598
|
|
|
7202
7599
|
// src/features/rules/kiro-rule.ts
|
|
7203
|
-
import { join as
|
|
7600
|
+
import { join as join76 } from "path";
|
|
7204
7601
|
var KiroRule = class _KiroRule extends ToolRule {
|
|
7205
7602
|
static getSettablePaths() {
|
|
7206
7603
|
return {
|
|
7207
7604
|
nonRoot: {
|
|
7208
|
-
relativeDirPath:
|
|
7605
|
+
relativeDirPath: join76(".kiro", "steering")
|
|
7209
7606
|
}
|
|
7210
7607
|
};
|
|
7211
7608
|
}
|
|
@@ -7215,7 +7612,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
7215
7612
|
validate = true
|
|
7216
7613
|
}) {
|
|
7217
7614
|
const fileContent = await readFileContent(
|
|
7218
|
-
|
|
7615
|
+
join76(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7219
7616
|
);
|
|
7220
7617
|
return new _KiroRule({
|
|
7221
7618
|
baseDir,
|
|
@@ -7255,7 +7652,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
7255
7652
|
};
|
|
7256
7653
|
|
|
7257
7654
|
// src/features/rules/opencode-rule.ts
|
|
7258
|
-
import { join as
|
|
7655
|
+
import { join as join77 } from "path";
|
|
7259
7656
|
var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
7260
7657
|
static getSettablePaths() {
|
|
7261
7658
|
return {
|
|
@@ -7264,7 +7661,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
7264
7661
|
relativeFilePath: "AGENTS.md"
|
|
7265
7662
|
},
|
|
7266
7663
|
nonRoot: {
|
|
7267
|
-
relativeDirPath:
|
|
7664
|
+
relativeDirPath: join77(".opencode", "memories")
|
|
7268
7665
|
}
|
|
7269
7666
|
};
|
|
7270
7667
|
}
|
|
@@ -7274,8 +7671,8 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
7274
7671
|
validate = true
|
|
7275
7672
|
}) {
|
|
7276
7673
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
7277
|
-
const relativePath = isRoot ? "AGENTS.md" :
|
|
7278
|
-
const fileContent = await readFileContent(
|
|
7674
|
+
const relativePath = isRoot ? "AGENTS.md" : join77(".opencode", "memories", relativeFilePath);
|
|
7675
|
+
const fileContent = await readFileContent(join77(baseDir, relativePath));
|
|
7279
7676
|
return new _OpenCodeRule({
|
|
7280
7677
|
baseDir,
|
|
7281
7678
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -7315,7 +7712,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
7315
7712
|
};
|
|
7316
7713
|
|
|
7317
7714
|
// src/features/rules/qwencode-rule.ts
|
|
7318
|
-
import { join as
|
|
7715
|
+
import { join as join78 } from "path";
|
|
7319
7716
|
var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
7320
7717
|
static getSettablePaths() {
|
|
7321
7718
|
return {
|
|
@@ -7324,7 +7721,7 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
7324
7721
|
relativeFilePath: "QWEN.md"
|
|
7325
7722
|
},
|
|
7326
7723
|
nonRoot: {
|
|
7327
|
-
relativeDirPath:
|
|
7724
|
+
relativeDirPath: join78(".qwen", "memories")
|
|
7328
7725
|
}
|
|
7329
7726
|
};
|
|
7330
7727
|
}
|
|
@@ -7334,8 +7731,8 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
7334
7731
|
validate = true
|
|
7335
7732
|
}) {
|
|
7336
7733
|
const isRoot = relativeFilePath === "QWEN.md";
|
|
7337
|
-
const relativePath = isRoot ? "QWEN.md" :
|
|
7338
|
-
const fileContent = await readFileContent(
|
|
7734
|
+
const relativePath = isRoot ? "QWEN.md" : join78(".qwen", "memories", relativeFilePath);
|
|
7735
|
+
const fileContent = await readFileContent(join78(baseDir, relativePath));
|
|
7339
7736
|
return new _QwencodeRule({
|
|
7340
7737
|
baseDir,
|
|
7341
7738
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -7372,12 +7769,12 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
7372
7769
|
};
|
|
7373
7770
|
|
|
7374
7771
|
// src/features/rules/roo-rule.ts
|
|
7375
|
-
import { join as
|
|
7772
|
+
import { join as join79 } from "path";
|
|
7376
7773
|
var RooRule = class _RooRule extends ToolRule {
|
|
7377
7774
|
static getSettablePaths() {
|
|
7378
7775
|
return {
|
|
7379
7776
|
nonRoot: {
|
|
7380
|
-
relativeDirPath:
|
|
7777
|
+
relativeDirPath: join79(".roo", "rules")
|
|
7381
7778
|
}
|
|
7382
7779
|
};
|
|
7383
7780
|
}
|
|
@@ -7387,7 +7784,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
7387
7784
|
validate = true
|
|
7388
7785
|
}) {
|
|
7389
7786
|
const fileContent = await readFileContent(
|
|
7390
|
-
|
|
7787
|
+
join79(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7391
7788
|
);
|
|
7392
7789
|
return new _RooRule({
|
|
7393
7790
|
baseDir,
|
|
@@ -7442,7 +7839,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
7442
7839
|
};
|
|
7443
7840
|
|
|
7444
7841
|
// src/features/rules/warp-rule.ts
|
|
7445
|
-
import { join as
|
|
7842
|
+
import { join as join80 } from "path";
|
|
7446
7843
|
var WarpRule = class _WarpRule extends ToolRule {
|
|
7447
7844
|
constructor({ fileContent, root, ...rest }) {
|
|
7448
7845
|
super({
|
|
@@ -7458,7 +7855,7 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
7458
7855
|
relativeFilePath: "WARP.md"
|
|
7459
7856
|
},
|
|
7460
7857
|
nonRoot: {
|
|
7461
|
-
relativeDirPath:
|
|
7858
|
+
relativeDirPath: join80(".warp", "memories")
|
|
7462
7859
|
}
|
|
7463
7860
|
};
|
|
7464
7861
|
}
|
|
@@ -7468,8 +7865,8 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
7468
7865
|
validate = true
|
|
7469
7866
|
}) {
|
|
7470
7867
|
const isRoot = relativeFilePath === this.getSettablePaths().root.relativeFilePath;
|
|
7471
|
-
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath :
|
|
7472
|
-
const fileContent = await readFileContent(
|
|
7868
|
+
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath : join80(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
7869
|
+
const fileContent = await readFileContent(join80(baseDir, relativePath));
|
|
7473
7870
|
return new _WarpRule({
|
|
7474
7871
|
baseDir,
|
|
7475
7872
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : ".warp",
|
|
@@ -7509,12 +7906,12 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
7509
7906
|
};
|
|
7510
7907
|
|
|
7511
7908
|
// src/features/rules/windsurf-rule.ts
|
|
7512
|
-
import { join as
|
|
7909
|
+
import { join as join81 } from "path";
|
|
7513
7910
|
var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
7514
7911
|
static getSettablePaths() {
|
|
7515
7912
|
return {
|
|
7516
7913
|
nonRoot: {
|
|
7517
|
-
relativeDirPath:
|
|
7914
|
+
relativeDirPath: join81(".windsurf", "rules")
|
|
7518
7915
|
}
|
|
7519
7916
|
};
|
|
7520
7917
|
}
|
|
@@ -7524,7 +7921,7 @@ var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
|
7524
7921
|
validate = true
|
|
7525
7922
|
}) {
|
|
7526
7923
|
const fileContent = await readFileContent(
|
|
7527
|
-
|
|
7924
|
+
join81(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7528
7925
|
);
|
|
7529
7926
|
return new _WindsurfRule({
|
|
7530
7927
|
baseDir,
|
|
@@ -7570,6 +7967,7 @@ var rulesProcessorToolTargets = [
|
|
|
7570
7967
|
"augmentcode",
|
|
7571
7968
|
"augmentcode-legacy",
|
|
7572
7969
|
"claudecode",
|
|
7970
|
+
"claudecode-legacy",
|
|
7573
7971
|
"cline",
|
|
7574
7972
|
"codexcli",
|
|
7575
7973
|
"copilot",
|
|
@@ -7583,9 +7981,10 @@ var rulesProcessorToolTargets = [
|
|
|
7583
7981
|
"warp",
|
|
7584
7982
|
"windsurf"
|
|
7585
7983
|
];
|
|
7586
|
-
var RulesProcessorToolTargetSchema =
|
|
7984
|
+
var RulesProcessorToolTargetSchema = z33.enum(rulesProcessorToolTargets);
|
|
7587
7985
|
var rulesProcessorToolTargetsGlobal = [
|
|
7588
7986
|
"claudecode",
|
|
7987
|
+
"claudecode-legacy",
|
|
7589
7988
|
"codexcli",
|
|
7590
7989
|
"geminicli"
|
|
7591
7990
|
];
|
|
@@ -7596,6 +7995,7 @@ var toolRuleFactories = /* @__PURE__ */ new Map([
|
|
|
7596
7995
|
["augmentcode", { class: AugmentcodeRule, meta: { extension: "md" } }],
|
|
7597
7996
|
["augmentcode-legacy", { class: AugmentcodeLegacyRule, meta: { extension: "md" } }],
|
|
7598
7997
|
["claudecode", { class: ClaudecodeRule, meta: { extension: "md" } }],
|
|
7998
|
+
["claudecode-legacy", { class: ClaudecodeLegacyRule, meta: { extension: "md" } }],
|
|
7599
7999
|
["cline", { class: ClineRule, meta: { extension: "md" } }],
|
|
7600
8000
|
["codexcli", { class: CodexcliRule, meta: { extension: "md" } }],
|
|
7601
8001
|
["copilot", { class: CopilotRule, meta: { extension: "md" } }],
|
|
@@ -7709,7 +8109,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7709
8109
|
case "agentsmd": {
|
|
7710
8110
|
const rootRule = toolRules[rootRuleIndex];
|
|
7711
8111
|
rootRule?.setFileContent(
|
|
7712
|
-
this.
|
|
8112
|
+
this.generateToonReferencesSection(toolRules) + this.generateAdditionalConventionsSection({
|
|
7713
8113
|
commands: { relativeDirPath: AgentsmdCommand.getSettablePaths().relativeDirPath },
|
|
7714
8114
|
subagents: {
|
|
7715
8115
|
relativeDirPath: AgentsmdSubagent.getSettablePaths().relativeDirPath
|
|
@@ -7721,11 +8121,14 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7721
8121
|
case "augmentcode-legacy": {
|
|
7722
8122
|
const rootRule = toolRules[rootRuleIndex];
|
|
7723
8123
|
rootRule?.setFileContent(
|
|
7724
|
-
this.
|
|
8124
|
+
this.generateToonReferencesSection(toolRules) + rootRule.getFileContent()
|
|
7725
8125
|
);
|
|
7726
8126
|
return toolRules;
|
|
7727
8127
|
}
|
|
7728
8128
|
case "claudecode": {
|
|
8129
|
+
return toolRules;
|
|
8130
|
+
}
|
|
8131
|
+
case "claudecode-legacy": {
|
|
7729
8132
|
const rootRule = toolRules[rootRuleIndex];
|
|
7730
8133
|
rootRule?.setFileContent(
|
|
7731
8134
|
this.generateReferencesSection(toolRules) + rootRule.getFileContent()
|
|
@@ -7735,12 +8138,15 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7735
8138
|
case "codexcli": {
|
|
7736
8139
|
const rootRule = toolRules[rootRuleIndex];
|
|
7737
8140
|
rootRule?.setFileContent(
|
|
7738
|
-
this.
|
|
8141
|
+
this.generateToonReferencesSection(toolRules) + this.generateAdditionalConventionsSection({
|
|
7739
8142
|
subagents: {
|
|
7740
8143
|
relativeDirPath: CodexCliSubagent.getSettablePaths().relativeDirPath
|
|
7741
8144
|
},
|
|
7742
|
-
skills
|
|
7743
|
-
|
|
8145
|
+
// Codex CLI skills are only supported in global mode
|
|
8146
|
+
...this.global && {
|
|
8147
|
+
skills: {
|
|
8148
|
+
relativeDirPath: CodexCliSkill.getSettablePaths({ global: this.global }).relativeDirPath
|
|
8149
|
+
}
|
|
7744
8150
|
}
|
|
7745
8151
|
}) + rootRule.getFileContent()
|
|
7746
8152
|
);
|
|
@@ -7764,7 +8170,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7764
8170
|
case "geminicli": {
|
|
7765
8171
|
const rootRule = toolRules[rootRuleIndex];
|
|
7766
8172
|
rootRule?.setFileContent(
|
|
7767
|
-
this.
|
|
8173
|
+
this.generateToonReferencesSection(toolRules) + this.generateAdditionalConventionsSection({
|
|
7768
8174
|
commands: { relativeDirPath: GeminiCliCommand.getSettablePaths().relativeDirPath },
|
|
7769
8175
|
subagents: {
|
|
7770
8176
|
relativeDirPath: GeminiCliSubagent.getSettablePaths().relativeDirPath
|
|
@@ -7776,28 +8182,28 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7776
8182
|
case "kiro": {
|
|
7777
8183
|
const rootRule = toolRules[rootRuleIndex];
|
|
7778
8184
|
rootRule?.setFileContent(
|
|
7779
|
-
this.
|
|
8185
|
+
this.generateToonReferencesSection(toolRules) + rootRule.getFileContent()
|
|
7780
8186
|
);
|
|
7781
8187
|
return toolRules;
|
|
7782
8188
|
}
|
|
7783
8189
|
case "opencode": {
|
|
7784
8190
|
const rootRule = toolRules[rootRuleIndex];
|
|
7785
8191
|
rootRule?.setFileContent(
|
|
7786
|
-
this.
|
|
8192
|
+
this.generateToonReferencesSection(toolRules) + rootRule.getFileContent()
|
|
7787
8193
|
);
|
|
7788
8194
|
return toolRules;
|
|
7789
8195
|
}
|
|
7790
8196
|
case "qwencode": {
|
|
7791
8197
|
const rootRule = toolRules[rootRuleIndex];
|
|
7792
8198
|
rootRule?.setFileContent(
|
|
7793
|
-
this.
|
|
8199
|
+
this.generateToonReferencesSection(toolRules) + rootRule.getFileContent()
|
|
7794
8200
|
);
|
|
7795
8201
|
return toolRules;
|
|
7796
8202
|
}
|
|
7797
8203
|
case "warp": {
|
|
7798
8204
|
const rootRule = toolRules[rootRuleIndex];
|
|
7799
8205
|
rootRule?.setFileContent(
|
|
7800
|
-
this.
|
|
8206
|
+
this.generateToonReferencesSection(toolRules) + rootRule.getFileContent()
|
|
7801
8207
|
);
|
|
7802
8208
|
return toolRules;
|
|
7803
8209
|
}
|
|
@@ -7817,7 +8223,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7817
8223
|
* Load and parse rulesync rule files from .rulesync/rules/ directory
|
|
7818
8224
|
*/
|
|
7819
8225
|
async loadRulesyncFiles() {
|
|
7820
|
-
const files = await findFilesByGlobs(
|
|
8226
|
+
const files = await findFilesByGlobs(join82(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md"));
|
|
7821
8227
|
logger.debug(`Found ${files.length} rulesync files`);
|
|
7822
8228
|
const rulesyncRules = await Promise.all(
|
|
7823
8229
|
files.map((file) => RulesyncRule.fromFile({ relativeFilePath: basename21(file) }))
|
|
@@ -7838,7 +8244,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7838
8244
|
return rulesyncRules;
|
|
7839
8245
|
}
|
|
7840
8246
|
async loadRulesyncFilesLegacy() {
|
|
7841
|
-
const legacyFiles = await findFilesByGlobs(
|
|
8247
|
+
const legacyFiles = await findFilesByGlobs(join82(RULESYNC_RELATIVE_DIR_PATH, "*.md"));
|
|
7842
8248
|
logger.debug(`Found ${legacyFiles.length} legacy rulesync files`);
|
|
7843
8249
|
return Promise.all(
|
|
7844
8250
|
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath: basename21(file) }))
|
|
@@ -7859,7 +8265,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7859
8265
|
return [];
|
|
7860
8266
|
}
|
|
7861
8267
|
const rootFilePaths = await findFilesByGlobs(
|
|
7862
|
-
|
|
8268
|
+
join82(
|
|
7863
8269
|
this.baseDir,
|
|
7864
8270
|
settablePaths.root.relativeDirPath ?? ".",
|
|
7865
8271
|
settablePaths.root.relativeFilePath
|
|
@@ -7881,7 +8287,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7881
8287
|
return [];
|
|
7882
8288
|
}
|
|
7883
8289
|
const nonRootFilePaths = await findFilesByGlobs(
|
|
7884
|
-
|
|
8290
|
+
join82(this.baseDir, settablePaths.nonRoot.relativeDirPath, `*.${factory.meta.extension}`)
|
|
7885
8291
|
);
|
|
7886
8292
|
return await Promise.all(
|
|
7887
8293
|
nonRootFilePaths.map(
|
|
@@ -7910,43 +8316,35 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7910
8316
|
}
|
|
7911
8317
|
return rulesProcessorToolTargets;
|
|
7912
8318
|
}
|
|
7913
|
-
|
|
8319
|
+
generateToonReferencesSection(toolRules) {
|
|
7914
8320
|
const toolRulesWithoutRoot = toolRules.filter((rule) => !rule.isRoot());
|
|
7915
8321
|
if (toolRulesWithoutRoot.length === 0) {
|
|
7916
8322
|
return "";
|
|
7917
8323
|
}
|
|
7918
8324
|
const lines = [];
|
|
7919
8325
|
lines.push(
|
|
7920
|
-
"Please also reference the following
|
|
8326
|
+
"Please also reference the following rules as needed. The list below is provided in TOON format, and `@` stands for the project root directory."
|
|
7921
8327
|
);
|
|
7922
8328
|
lines.push("");
|
|
7923
|
-
const
|
|
7924
|
-
|
|
7925
|
-
|
|
7926
|
-
|
|
7927
|
-
|
|
7928
|
-
|
|
7929
|
-
|
|
7930
|
-
|
|
7931
|
-
};
|
|
7932
|
-
if (frontmatter.description) {
|
|
7933
|
-
document.Description = frontmatter.description;
|
|
7934
|
-
}
|
|
7935
|
-
if (frontmatter.globs && frontmatter.globs.length > 0) {
|
|
7936
|
-
document.FilePatterns = frontmatter.globs.join(", ");
|
|
7937
|
-
}
|
|
7938
|
-
return document;
|
|
7939
|
-
})
|
|
8329
|
+
const rules = toolRulesWithoutRoot.map((toolRule) => {
|
|
8330
|
+
const rulesyncRule = toolRule.toRulesyncRule();
|
|
8331
|
+
const frontmatter = rulesyncRule.getFrontmatter();
|
|
8332
|
+
const rule = {
|
|
8333
|
+
path: `@${toolRule.getRelativePathFromCwd()}`
|
|
8334
|
+
};
|
|
8335
|
+
if (frontmatter.description) {
|
|
8336
|
+
rule.description = frontmatter.description;
|
|
7940
8337
|
}
|
|
7941
|
-
|
|
7942
|
-
|
|
7943
|
-
|
|
7944
|
-
|
|
7945
|
-
suppressEmptyNode: false
|
|
8338
|
+
if (frontmatter.globs && frontmatter.globs.length > 0) {
|
|
8339
|
+
rule.applyTo = frontmatter.globs;
|
|
8340
|
+
}
|
|
8341
|
+
return rule;
|
|
7946
8342
|
});
|
|
7947
|
-
const
|
|
7948
|
-
|
|
7949
|
-
|
|
8343
|
+
const toonContent = encode({
|
|
8344
|
+
rules
|
|
8345
|
+
});
|
|
8346
|
+
lines.push(toonContent);
|
|
8347
|
+
return lines.join("\n") + "\n\n";
|
|
7950
8348
|
}
|
|
7951
8349
|
generateReferencesSection(toolRules) {
|
|
7952
8350
|
const toolRulesWithoutRoot = toolRules.filter((rule) => !rule.isRoot());
|
|
@@ -7954,13 +8352,13 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7954
8352
|
return "";
|
|
7955
8353
|
}
|
|
7956
8354
|
const lines = [];
|
|
7957
|
-
lines.push("Please also reference the following
|
|
8355
|
+
lines.push("Please also reference the following rules as needed:");
|
|
7958
8356
|
lines.push("");
|
|
7959
|
-
for (const
|
|
7960
|
-
const escapedDescription =
|
|
7961
|
-
const globsText =
|
|
8357
|
+
for (const toolRule of toolRulesWithoutRoot) {
|
|
8358
|
+
const escapedDescription = toolRule.getDescription()?.replace(/"/g, '\\"');
|
|
8359
|
+
const globsText = toolRule.getGlobs()?.join(",");
|
|
7962
8360
|
lines.push(
|
|
7963
|
-
`@${
|
|
8361
|
+
`@${toolRule.getRelativePathFromCwd()} description: "${escapedDescription}" applyTo: "${globsText}"`
|
|
7964
8362
|
);
|
|
7965
8363
|
}
|
|
7966
8364
|
return lines.join("\n") + "\n\n";
|
|
@@ -7988,21 +8386,21 @@ s/<command> [arguments]
|
|
|
7988
8386
|
This syntax employs a double slash (\`s/\`) to prevent conflicts with built-in slash commands.
|
|
7989
8387
|
The \`s\` in \`s/\` stands for *simulate*. Because custom slash commands are not built-in, this syntax provides a pseudo way to invoke them.
|
|
7990
8388
|
|
|
7991
|
-
When users call a custom slash command, you have to look for the markdown file, \`${
|
|
8389
|
+
When users call a custom slash command, you have to look for the markdown file, \`${join82(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "{command}.md")}\`, then execute the contents of that file as the block of operations.` : "";
|
|
7992
8390
|
const subagentsSection = subagents ? `## Simulated Subagents
|
|
7993
8391
|
|
|
7994
8392
|
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.
|
|
7995
8393
|
|
|
7996
|
-
When users call a simulated subagent, it will look for the corresponding markdown file, \`${
|
|
8394
|
+
When users call a simulated subagent, it will look for the corresponding markdown file, \`${join82(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "{subagent}.md")}\`, and execute its contents as the block of operations.
|
|
7997
8395
|
|
|
7998
|
-
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${
|
|
8396
|
+
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${join82(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "planner.md")}\`, and execute its contents as the block of operations.` : "";
|
|
7999
8397
|
const skillsSection = skills ? `## Simulated Skills
|
|
8000
8398
|
|
|
8001
8399
|
Simulated skills are specialized capabilities that can be invoked to handle specific types of tasks.
|
|
8002
8400
|
|
|
8003
|
-
When users invoke a simulated skill, look for the corresponding SKILL.md file in \`${
|
|
8401
|
+
When users invoke a simulated skill, look for the corresponding SKILL.md file in \`${join82(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "{skill}/SKILL.md")}\` and execute its contents as the block of operations.
|
|
8004
8402
|
|
|
8005
|
-
For example, if the user instructs \`Use the skill example-skill to achieve something\`, look for \`${
|
|
8403
|
+
For example, if the user instructs \`Use the skill example-skill to achieve something\`, look for \`${join82(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "example-skill/SKILL.md")}\` and execute its contents.
|
|
8006
8404
|
|
|
8007
8405
|
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.` : "";
|
|
8008
8406
|
const result = [
|
|
@@ -8264,102 +8662,149 @@ async function generateSkills(config) {
|
|
|
8264
8662
|
}
|
|
8265
8663
|
|
|
8266
8664
|
// src/cli/commands/gitignore.ts
|
|
8267
|
-
import { join as
|
|
8665
|
+
import { join as join83 } from "path";
|
|
8666
|
+
var RULESYNC_HEADER = "# Generated by Rulesync";
|
|
8667
|
+
var LEGACY_RULESYNC_HEADER = "# Generated by rulesync - AI tool configuration files";
|
|
8668
|
+
var RULESYNC_IGNORE_ENTRIES = [
|
|
8669
|
+
// AGENTS.md
|
|
8670
|
+
"**/AGENTS.md",
|
|
8671
|
+
"**/.agents/",
|
|
8672
|
+
// Amazon Q
|
|
8673
|
+
"**/.amazonq/",
|
|
8674
|
+
// Augment
|
|
8675
|
+
"**/.augmentignore",
|
|
8676
|
+
"**/.augment/rules/",
|
|
8677
|
+
"**/.augment-guidelines",
|
|
8678
|
+
// Claude Code
|
|
8679
|
+
"**/CLAUDE.md",
|
|
8680
|
+
"**/.claude/CLAUDE.md",
|
|
8681
|
+
"**/.claude/memories/",
|
|
8682
|
+
"**/.claude/rules/",
|
|
8683
|
+
"**/.claude/commands/",
|
|
8684
|
+
"**/.claude/agents/",
|
|
8685
|
+
"**/.claude/skills/",
|
|
8686
|
+
"**/.claude/settings.local.json",
|
|
8687
|
+
"**/.mcp.json",
|
|
8688
|
+
// Cline
|
|
8689
|
+
"**/.clinerules/",
|
|
8690
|
+
"**/.clineignore",
|
|
8691
|
+
"**/.cline/mcp.json",
|
|
8692
|
+
// Codex
|
|
8693
|
+
"**/.codexignore",
|
|
8694
|
+
"**/.codex/",
|
|
8695
|
+
"**/.codex/skills/",
|
|
8696
|
+
// Cursor
|
|
8697
|
+
"**/.cursor/",
|
|
8698
|
+
"**/.cursorignore",
|
|
8699
|
+
// Gemini
|
|
8700
|
+
"**/GEMINI.md",
|
|
8701
|
+
"**/.gemini/memories/",
|
|
8702
|
+
"**/.gemini/commands/",
|
|
8703
|
+
"**/.gemini/subagents/",
|
|
8704
|
+
"**/.gemini/skills/",
|
|
8705
|
+
"**/.geminiignore",
|
|
8706
|
+
// GitHub Copilot
|
|
8707
|
+
"**/.github/copilot-instructions.md",
|
|
8708
|
+
"**/.github/instructions/",
|
|
8709
|
+
"**/.github/prompts/",
|
|
8710
|
+
"**/.github/subagents/",
|
|
8711
|
+
"**/.github/skills/",
|
|
8712
|
+
"**/.vscode/mcp.json",
|
|
8713
|
+
// Junie
|
|
8714
|
+
"**/.junie/guidelines.md",
|
|
8715
|
+
"**/.junie/mcp.json",
|
|
8716
|
+
// Kiro
|
|
8717
|
+
"**/.kiro/steering/",
|
|
8718
|
+
"**/.aiignore",
|
|
8719
|
+
// OpenCode
|
|
8720
|
+
"**/.opencode/memories/",
|
|
8721
|
+
"**/.opencode/command/",
|
|
8722
|
+
"**/opencode.json",
|
|
8723
|
+
// Qwen
|
|
8724
|
+
"**/QWEN.md",
|
|
8725
|
+
"**/.qwen/memories/",
|
|
8726
|
+
// Roo
|
|
8727
|
+
"**/.roo/rules/",
|
|
8728
|
+
"**/.rooignore",
|
|
8729
|
+
"**/.roo/mcp.json",
|
|
8730
|
+
"**/.roo/subagents/",
|
|
8731
|
+
// Warp
|
|
8732
|
+
"**/.warp/",
|
|
8733
|
+
"**/WARP.md",
|
|
8734
|
+
// Others
|
|
8735
|
+
"**/modular-mcp.json",
|
|
8736
|
+
"!.rulesync/.aiignore"
|
|
8737
|
+
];
|
|
8738
|
+
var isRulesyncHeader = (line) => {
|
|
8739
|
+
const trimmed = line.trim();
|
|
8740
|
+
return trimmed === RULESYNC_HEADER || trimmed === LEGACY_RULESYNC_HEADER;
|
|
8741
|
+
};
|
|
8742
|
+
var isRulesyncEntry = (line) => {
|
|
8743
|
+
const trimmed = line.trim();
|
|
8744
|
+
if (trimmed === "" || isRulesyncHeader(line)) {
|
|
8745
|
+
return false;
|
|
8746
|
+
}
|
|
8747
|
+
return RULESYNC_IGNORE_ENTRIES.includes(trimmed);
|
|
8748
|
+
};
|
|
8749
|
+
var removeExistingRulesyncEntries = (content) => {
|
|
8750
|
+
const lines = content.split("\n");
|
|
8751
|
+
const filteredLines = [];
|
|
8752
|
+
let inRulesyncBlock = false;
|
|
8753
|
+
let consecutiveEmptyLines = 0;
|
|
8754
|
+
for (const line of lines) {
|
|
8755
|
+
const trimmed = line.trim();
|
|
8756
|
+
if (isRulesyncHeader(line)) {
|
|
8757
|
+
inRulesyncBlock = true;
|
|
8758
|
+
continue;
|
|
8759
|
+
}
|
|
8760
|
+
if (inRulesyncBlock) {
|
|
8761
|
+
if (trimmed === "") {
|
|
8762
|
+
consecutiveEmptyLines++;
|
|
8763
|
+
if (consecutiveEmptyLines >= 2) {
|
|
8764
|
+
inRulesyncBlock = false;
|
|
8765
|
+
consecutiveEmptyLines = 0;
|
|
8766
|
+
}
|
|
8767
|
+
continue;
|
|
8768
|
+
}
|
|
8769
|
+
if (isRulesyncEntry(line)) {
|
|
8770
|
+
consecutiveEmptyLines = 0;
|
|
8771
|
+
continue;
|
|
8772
|
+
}
|
|
8773
|
+
inRulesyncBlock = false;
|
|
8774
|
+
consecutiveEmptyLines = 0;
|
|
8775
|
+
}
|
|
8776
|
+
if (isRulesyncEntry(line)) {
|
|
8777
|
+
continue;
|
|
8778
|
+
}
|
|
8779
|
+
filteredLines.push(line);
|
|
8780
|
+
}
|
|
8781
|
+
let result = filteredLines.join("\n");
|
|
8782
|
+
while (result.endsWith("\n\n")) {
|
|
8783
|
+
result = result.slice(0, -1);
|
|
8784
|
+
}
|
|
8785
|
+
return result;
|
|
8786
|
+
};
|
|
8268
8787
|
var gitignoreCommand = async () => {
|
|
8269
|
-
const gitignorePath =
|
|
8270
|
-
const rulesFilesToIgnore = [
|
|
8271
|
-
"# Generated by rulesync - AI tool configuration files",
|
|
8272
|
-
// AGENTS.md
|
|
8273
|
-
"**/AGENTS.md",
|
|
8274
|
-
"**/.agents/",
|
|
8275
|
-
// Amazon Q
|
|
8276
|
-
"**/.amazonq/",
|
|
8277
|
-
// Augment
|
|
8278
|
-
"**/.augmentignore",
|
|
8279
|
-
"**/.augment/rules/",
|
|
8280
|
-
"**/.augment-guidelines",
|
|
8281
|
-
// Claude Code
|
|
8282
|
-
"**/CLAUDE.md",
|
|
8283
|
-
"**/.claude/memories/",
|
|
8284
|
-
"**/.claude/commands/",
|
|
8285
|
-
"**/.claude/agents/",
|
|
8286
|
-
"**/.claude/skills/",
|
|
8287
|
-
"**/.claude/settings.local.json",
|
|
8288
|
-
"**/.mcp.json",
|
|
8289
|
-
// Cline
|
|
8290
|
-
"**/.clinerules/",
|
|
8291
|
-
"**/.clineignore",
|
|
8292
|
-
"**/.cline/mcp.json",
|
|
8293
|
-
// Codex
|
|
8294
|
-
"**/.codexignore",
|
|
8295
|
-
"**/.codex/",
|
|
8296
|
-
"**/.codex/skills/",
|
|
8297
|
-
// Cursor
|
|
8298
|
-
"**/.cursor/",
|
|
8299
|
-
"**/.cursorignore",
|
|
8300
|
-
// Gemini
|
|
8301
|
-
"**/GEMINI.md",
|
|
8302
|
-
"**/.gemini/memories/",
|
|
8303
|
-
"**/.gemini/commands/",
|
|
8304
|
-
"**/.gemini/subagents/",
|
|
8305
|
-
"**/.gemini/skills/",
|
|
8306
|
-
// GitHub Copilot
|
|
8307
|
-
"**/.github/copilot-instructions.md",
|
|
8308
|
-
"**/.github/instructions/",
|
|
8309
|
-
"**/.github/prompts/",
|
|
8310
|
-
"**/.github/subagents/",
|
|
8311
|
-
"**/.github/skills/",
|
|
8312
|
-
"**/.vscode/mcp.json",
|
|
8313
|
-
// Junie
|
|
8314
|
-
"**/.junie/guidelines.md",
|
|
8315
|
-
"**/.junie/mcp.json",
|
|
8316
|
-
// Kiro
|
|
8317
|
-
"**/.kiro/steering/",
|
|
8318
|
-
"**/.aiignore",
|
|
8319
|
-
// OpenCode
|
|
8320
|
-
"**/.opencode/memories/",
|
|
8321
|
-
"**/.opencode/command/",
|
|
8322
|
-
"**/opencode.json",
|
|
8323
|
-
// Qwen
|
|
8324
|
-
"**/QWEN.md",
|
|
8325
|
-
"**/.qwen/memories/",
|
|
8326
|
-
// Roo
|
|
8327
|
-
"**/.roo/rules/",
|
|
8328
|
-
"**/.rooignore",
|
|
8329
|
-
"**/.roo/mcp.json",
|
|
8330
|
-
"**/.roo/subagents/",
|
|
8331
|
-
// Warp
|
|
8332
|
-
"**/.warp/",
|
|
8333
|
-
"**/WARP.md",
|
|
8334
|
-
// Others
|
|
8335
|
-
"**/modular-mcp.json",
|
|
8336
|
-
"!.rulesync/.aiignore"
|
|
8337
|
-
];
|
|
8788
|
+
const gitignorePath = join83(process.cwd(), ".gitignore");
|
|
8338
8789
|
let gitignoreContent = "";
|
|
8339
8790
|
if (await fileExists(gitignorePath)) {
|
|
8340
8791
|
gitignoreContent = await readFileContent(gitignorePath);
|
|
8341
8792
|
}
|
|
8342
|
-
const
|
|
8343
|
-
|
|
8344
|
-
|
|
8345
|
-
|
|
8346
|
-
|
|
8347
|
-
|
|
8348
|
-
|
|
8793
|
+
const cleanedContent = removeExistingRulesyncEntries(gitignoreContent);
|
|
8794
|
+
const rulesyncBlock = [RULESYNC_HEADER, ...RULESYNC_IGNORE_ENTRIES].join("\n");
|
|
8795
|
+
const newContent = cleanedContent.trim() ? `${cleanedContent.trimEnd()}
|
|
8796
|
+
|
|
8797
|
+
${rulesyncBlock}
|
|
8798
|
+
` : `${rulesyncBlock}
|
|
8799
|
+
`;
|
|
8800
|
+
if (gitignoreContent === newContent) {
|
|
8349
8801
|
logger.success(".gitignore is already up to date");
|
|
8350
8802
|
return;
|
|
8351
8803
|
}
|
|
8352
|
-
const newContent = gitignoreContent ? `${gitignoreContent.trimEnd()}
|
|
8353
|
-
|
|
8354
|
-
${linesToAdd.join("\n")}
|
|
8355
|
-
` : `${linesToAdd.join("\n")}
|
|
8356
|
-
`;
|
|
8357
8804
|
await writeFileContent(gitignorePath, newContent);
|
|
8358
|
-
logger.success(
|
|
8359
|
-
for (const
|
|
8360
|
-
|
|
8361
|
-
logger.info(` ${line}`);
|
|
8362
|
-
}
|
|
8805
|
+
logger.success("Updated .gitignore with rulesync entries:");
|
|
8806
|
+
for (const entry of RULESYNC_IGNORE_ENTRIES) {
|
|
8807
|
+
logger.info(` ${entry}`);
|
|
8363
8808
|
}
|
|
8364
8809
|
};
|
|
8365
8810
|
|
|
@@ -8539,7 +8984,7 @@ async function importSkills(config, tool) {
|
|
|
8539
8984
|
}
|
|
8540
8985
|
|
|
8541
8986
|
// src/cli/commands/init.ts
|
|
8542
|
-
import { join as
|
|
8987
|
+
import { join as join84 } from "path";
|
|
8543
8988
|
async function initCommand() {
|
|
8544
8989
|
logger.info("Initializing rulesync...");
|
|
8545
8990
|
await ensureDir(RULESYNC_RELATIVE_DIR_PATH);
|
|
@@ -8702,14 +9147,14 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
8702
9147
|
await ensureDir(commandPaths.relativeDirPath);
|
|
8703
9148
|
await ensureDir(subagentPaths.relativeDirPath);
|
|
8704
9149
|
await ensureDir(ignorePaths.recommended.relativeDirPath);
|
|
8705
|
-
const ruleFilepath =
|
|
9150
|
+
const ruleFilepath = join84(rulePaths.recommended.relativeDirPath, sampleRuleFile.filename);
|
|
8706
9151
|
if (!await fileExists(ruleFilepath)) {
|
|
8707
9152
|
await writeFileContent(ruleFilepath, sampleRuleFile.content);
|
|
8708
9153
|
logger.success(`Created ${ruleFilepath}`);
|
|
8709
9154
|
} else {
|
|
8710
9155
|
logger.info(`Skipped ${ruleFilepath} (already exists)`);
|
|
8711
9156
|
}
|
|
8712
|
-
const mcpFilepath =
|
|
9157
|
+
const mcpFilepath = join84(
|
|
8713
9158
|
mcpPaths.recommended.relativeDirPath,
|
|
8714
9159
|
mcpPaths.recommended.relativeFilePath
|
|
8715
9160
|
);
|
|
@@ -8719,21 +9164,21 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
8719
9164
|
} else {
|
|
8720
9165
|
logger.info(`Skipped ${mcpFilepath} (already exists)`);
|
|
8721
9166
|
}
|
|
8722
|
-
const commandFilepath =
|
|
9167
|
+
const commandFilepath = join84(commandPaths.relativeDirPath, sampleCommandFile.filename);
|
|
8723
9168
|
if (!await fileExists(commandFilepath)) {
|
|
8724
9169
|
await writeFileContent(commandFilepath, sampleCommandFile.content);
|
|
8725
9170
|
logger.success(`Created ${commandFilepath}`);
|
|
8726
9171
|
} else {
|
|
8727
9172
|
logger.info(`Skipped ${commandFilepath} (already exists)`);
|
|
8728
9173
|
}
|
|
8729
|
-
const subagentFilepath =
|
|
9174
|
+
const subagentFilepath = join84(subagentPaths.relativeDirPath, sampleSubagentFile.filename);
|
|
8730
9175
|
if (!await fileExists(subagentFilepath)) {
|
|
8731
9176
|
await writeFileContent(subagentFilepath, sampleSubagentFile.content);
|
|
8732
9177
|
logger.success(`Created ${subagentFilepath}`);
|
|
8733
9178
|
} else {
|
|
8734
9179
|
logger.info(`Skipped ${subagentFilepath} (already exists)`);
|
|
8735
9180
|
}
|
|
8736
|
-
const ignoreFilepath =
|
|
9181
|
+
const ignoreFilepath = join84(
|
|
8737
9182
|
ignorePaths.recommended.relativeDirPath,
|
|
8738
9183
|
ignorePaths.recommended.relativeFilePath
|
|
8739
9184
|
);
|
|
@@ -8749,12 +9194,12 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
8749
9194
|
import { FastMCP } from "fastmcp";
|
|
8750
9195
|
|
|
8751
9196
|
// src/mcp/commands.ts
|
|
8752
|
-
import { basename as basename22, join as
|
|
8753
|
-
import { z as
|
|
9197
|
+
import { basename as basename22, join as join85 } from "path";
|
|
9198
|
+
import { z as z34 } from "zod/mini";
|
|
8754
9199
|
var maxCommandSizeBytes = 1024 * 1024;
|
|
8755
9200
|
var maxCommandsCount = 1e3;
|
|
8756
9201
|
async function listCommands() {
|
|
8757
|
-
const commandsDir =
|
|
9202
|
+
const commandsDir = join85(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
8758
9203
|
try {
|
|
8759
9204
|
const files = await listDirectoryFiles(commandsDir);
|
|
8760
9205
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -8766,7 +9211,7 @@ async function listCommands() {
|
|
|
8766
9211
|
});
|
|
8767
9212
|
const frontmatter = command.getFrontmatter();
|
|
8768
9213
|
return {
|
|
8769
|
-
relativePathFromCwd:
|
|
9214
|
+
relativePathFromCwd: join85(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, file),
|
|
8770
9215
|
frontmatter
|
|
8771
9216
|
};
|
|
8772
9217
|
} catch (error) {
|
|
@@ -8792,7 +9237,7 @@ async function getCommand({ relativePathFromCwd }) {
|
|
|
8792
9237
|
relativeFilePath: filename
|
|
8793
9238
|
});
|
|
8794
9239
|
return {
|
|
8795
|
-
relativePathFromCwd:
|
|
9240
|
+
relativePathFromCwd: join85(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
8796
9241
|
frontmatter: command.getFrontmatter(),
|
|
8797
9242
|
body: command.getBody()
|
|
8798
9243
|
};
|
|
@@ -8821,7 +9266,7 @@ async function putCommand({
|
|
|
8821
9266
|
try {
|
|
8822
9267
|
const existingCommands = await listCommands();
|
|
8823
9268
|
const isUpdate = existingCommands.some(
|
|
8824
|
-
(command2) => command2.relativePathFromCwd ===
|
|
9269
|
+
(command2) => command2.relativePathFromCwd === join85(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
8825
9270
|
);
|
|
8826
9271
|
if (!isUpdate && existingCommands.length >= maxCommandsCount) {
|
|
8827
9272
|
throw new Error(`Maximum number of commands (${maxCommandsCount}) reached`);
|
|
@@ -8836,11 +9281,11 @@ async function putCommand({
|
|
|
8836
9281
|
fileContent,
|
|
8837
9282
|
validate: true
|
|
8838
9283
|
});
|
|
8839
|
-
const commandsDir =
|
|
9284
|
+
const commandsDir = join85(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
8840
9285
|
await ensureDir(commandsDir);
|
|
8841
9286
|
await writeFileContent(command.getFilePath(), command.getFileContent());
|
|
8842
9287
|
return {
|
|
8843
|
-
relativePathFromCwd:
|
|
9288
|
+
relativePathFromCwd: join85(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
8844
9289
|
frontmatter: command.getFrontmatter(),
|
|
8845
9290
|
body: command.getBody()
|
|
8846
9291
|
};
|
|
@@ -8856,11 +9301,11 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
8856
9301
|
intendedRootDir: process.cwd()
|
|
8857
9302
|
});
|
|
8858
9303
|
const filename = basename22(relativePathFromCwd);
|
|
8859
|
-
const fullPath =
|
|
9304
|
+
const fullPath = join85(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename);
|
|
8860
9305
|
try {
|
|
8861
9306
|
await removeFile(fullPath);
|
|
8862
9307
|
return {
|
|
8863
|
-
relativePathFromCwd:
|
|
9308
|
+
relativePathFromCwd: join85(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
8864
9309
|
};
|
|
8865
9310
|
} catch (error) {
|
|
8866
9311
|
throw new Error(`Failed to delete command file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -8869,23 +9314,23 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
8869
9314
|
}
|
|
8870
9315
|
}
|
|
8871
9316
|
var commandToolSchemas = {
|
|
8872
|
-
listCommands:
|
|
8873
|
-
getCommand:
|
|
8874
|
-
relativePathFromCwd:
|
|
9317
|
+
listCommands: z34.object({}),
|
|
9318
|
+
getCommand: z34.object({
|
|
9319
|
+
relativePathFromCwd: z34.string()
|
|
8875
9320
|
}),
|
|
8876
|
-
putCommand:
|
|
8877
|
-
relativePathFromCwd:
|
|
9321
|
+
putCommand: z34.object({
|
|
9322
|
+
relativePathFromCwd: z34.string(),
|
|
8878
9323
|
frontmatter: RulesyncCommandFrontmatterSchema,
|
|
8879
|
-
body:
|
|
9324
|
+
body: z34.string()
|
|
8880
9325
|
}),
|
|
8881
|
-
deleteCommand:
|
|
8882
|
-
relativePathFromCwd:
|
|
9326
|
+
deleteCommand: z34.object({
|
|
9327
|
+
relativePathFromCwd: z34.string()
|
|
8883
9328
|
})
|
|
8884
9329
|
};
|
|
8885
9330
|
var commandTools = {
|
|
8886
9331
|
listCommands: {
|
|
8887
9332
|
name: "listCommands",
|
|
8888
|
-
description: `List all commands from ${
|
|
9333
|
+
description: `List all commands from ${join85(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
8889
9334
|
parameters: commandToolSchemas.listCommands,
|
|
8890
9335
|
execute: async () => {
|
|
8891
9336
|
const commands = await listCommands();
|
|
@@ -8927,11 +9372,11 @@ var commandTools = {
|
|
|
8927
9372
|
};
|
|
8928
9373
|
|
|
8929
9374
|
// src/mcp/ignore.ts
|
|
8930
|
-
import { join as
|
|
8931
|
-
import { z as
|
|
9375
|
+
import { join as join86 } from "path";
|
|
9376
|
+
import { z as z35 } from "zod/mini";
|
|
8932
9377
|
var maxIgnoreFileSizeBytes = 100 * 1024;
|
|
8933
9378
|
async function getIgnoreFile() {
|
|
8934
|
-
const ignoreFilePath =
|
|
9379
|
+
const ignoreFilePath = join86(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
8935
9380
|
try {
|
|
8936
9381
|
const content = await readFileContent(ignoreFilePath);
|
|
8937
9382
|
return {
|
|
@@ -8945,7 +9390,7 @@ async function getIgnoreFile() {
|
|
|
8945
9390
|
}
|
|
8946
9391
|
}
|
|
8947
9392
|
async function putIgnoreFile({ content }) {
|
|
8948
|
-
const ignoreFilePath =
|
|
9393
|
+
const ignoreFilePath = join86(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
8949
9394
|
const contentSizeBytes = Buffer.byteLength(content, "utf8");
|
|
8950
9395
|
if (contentSizeBytes > maxIgnoreFileSizeBytes) {
|
|
8951
9396
|
throw new Error(
|
|
@@ -8966,8 +9411,8 @@ async function putIgnoreFile({ content }) {
|
|
|
8966
9411
|
}
|
|
8967
9412
|
}
|
|
8968
9413
|
async function deleteIgnoreFile() {
|
|
8969
|
-
const aiignorePath =
|
|
8970
|
-
const legacyIgnorePath =
|
|
9414
|
+
const aiignorePath = join86(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
9415
|
+
const legacyIgnorePath = join86(process.cwd(), RULESYNC_IGNORE_RELATIVE_FILE_PATH);
|
|
8971
9416
|
try {
|
|
8972
9417
|
await Promise.all([removeFile(aiignorePath), removeFile(legacyIgnorePath)]);
|
|
8973
9418
|
return {
|
|
@@ -8985,11 +9430,11 @@ async function deleteIgnoreFile() {
|
|
|
8985
9430
|
}
|
|
8986
9431
|
}
|
|
8987
9432
|
var ignoreToolSchemas = {
|
|
8988
|
-
getIgnoreFile:
|
|
8989
|
-
putIgnoreFile:
|
|
8990
|
-
content:
|
|
9433
|
+
getIgnoreFile: z35.object({}),
|
|
9434
|
+
putIgnoreFile: z35.object({
|
|
9435
|
+
content: z35.string()
|
|
8991
9436
|
}),
|
|
8992
|
-
deleteIgnoreFile:
|
|
9437
|
+
deleteIgnoreFile: z35.object({})
|
|
8993
9438
|
};
|
|
8994
9439
|
var ignoreTools = {
|
|
8995
9440
|
getIgnoreFile: {
|
|
@@ -9022,8 +9467,8 @@ var ignoreTools = {
|
|
|
9022
9467
|
};
|
|
9023
9468
|
|
|
9024
9469
|
// src/mcp/mcp.ts
|
|
9025
|
-
import { join as
|
|
9026
|
-
import { z as
|
|
9470
|
+
import { join as join87 } from "path";
|
|
9471
|
+
import { z as z36 } from "zod/mini";
|
|
9027
9472
|
var maxMcpSizeBytes = 1024 * 1024;
|
|
9028
9473
|
async function getMcpFile() {
|
|
9029
9474
|
const config = await ConfigResolver.resolve({});
|
|
@@ -9032,7 +9477,7 @@ async function getMcpFile() {
|
|
|
9032
9477
|
validate: true,
|
|
9033
9478
|
modularMcp: config.getModularMcp()
|
|
9034
9479
|
});
|
|
9035
|
-
const relativePathFromCwd =
|
|
9480
|
+
const relativePathFromCwd = join87(
|
|
9036
9481
|
rulesyncMcp.getRelativeDirPath(),
|
|
9037
9482
|
rulesyncMcp.getRelativeFilePath()
|
|
9038
9483
|
);
|
|
@@ -9065,7 +9510,7 @@ async function putMcpFile({ content }) {
|
|
|
9065
9510
|
const paths = RulesyncMcp.getSettablePaths();
|
|
9066
9511
|
const relativeDirPath = paths.recommended.relativeDirPath;
|
|
9067
9512
|
const relativeFilePath = paths.recommended.relativeFilePath;
|
|
9068
|
-
const fullPath =
|
|
9513
|
+
const fullPath = join87(baseDir, relativeDirPath, relativeFilePath);
|
|
9069
9514
|
const rulesyncMcp = new RulesyncMcp({
|
|
9070
9515
|
baseDir,
|
|
9071
9516
|
relativeDirPath,
|
|
@@ -9074,9 +9519,9 @@ async function putMcpFile({ content }) {
|
|
|
9074
9519
|
validate: true,
|
|
9075
9520
|
modularMcp: config.getModularMcp()
|
|
9076
9521
|
});
|
|
9077
|
-
await ensureDir(
|
|
9522
|
+
await ensureDir(join87(baseDir, relativeDirPath));
|
|
9078
9523
|
await writeFileContent(fullPath, content);
|
|
9079
|
-
const relativePathFromCwd =
|
|
9524
|
+
const relativePathFromCwd = join87(relativeDirPath, relativeFilePath);
|
|
9080
9525
|
return {
|
|
9081
9526
|
relativePathFromCwd,
|
|
9082
9527
|
content: rulesyncMcp.getFileContent()
|
|
@@ -9091,15 +9536,15 @@ async function deleteMcpFile() {
|
|
|
9091
9536
|
try {
|
|
9092
9537
|
const baseDir = process.cwd();
|
|
9093
9538
|
const paths = RulesyncMcp.getSettablePaths();
|
|
9094
|
-
const recommendedPath =
|
|
9539
|
+
const recommendedPath = join87(
|
|
9095
9540
|
baseDir,
|
|
9096
9541
|
paths.recommended.relativeDirPath,
|
|
9097
9542
|
paths.recommended.relativeFilePath
|
|
9098
9543
|
);
|
|
9099
|
-
const legacyPath =
|
|
9544
|
+
const legacyPath = join87(baseDir, paths.legacy.relativeDirPath, paths.legacy.relativeFilePath);
|
|
9100
9545
|
await removeFile(recommendedPath);
|
|
9101
9546
|
await removeFile(legacyPath);
|
|
9102
|
-
const relativePathFromCwd =
|
|
9547
|
+
const relativePathFromCwd = join87(
|
|
9103
9548
|
paths.recommended.relativeDirPath,
|
|
9104
9549
|
paths.recommended.relativeFilePath
|
|
9105
9550
|
);
|
|
@@ -9113,11 +9558,11 @@ async function deleteMcpFile() {
|
|
|
9113
9558
|
}
|
|
9114
9559
|
}
|
|
9115
9560
|
var mcpToolSchemas = {
|
|
9116
|
-
getMcpFile:
|
|
9117
|
-
putMcpFile:
|
|
9118
|
-
content:
|
|
9561
|
+
getMcpFile: z36.object({}),
|
|
9562
|
+
putMcpFile: z36.object({
|
|
9563
|
+
content: z36.string()
|
|
9119
9564
|
}),
|
|
9120
|
-
deleteMcpFile:
|
|
9565
|
+
deleteMcpFile: z36.object({})
|
|
9121
9566
|
};
|
|
9122
9567
|
var mcpTools = {
|
|
9123
9568
|
getMcpFile: {
|
|
@@ -9150,12 +9595,12 @@ var mcpTools = {
|
|
|
9150
9595
|
};
|
|
9151
9596
|
|
|
9152
9597
|
// src/mcp/rules.ts
|
|
9153
|
-
import { basename as basename23, join as
|
|
9154
|
-
import { z as
|
|
9598
|
+
import { basename as basename23, join as join88 } from "path";
|
|
9599
|
+
import { z as z37 } from "zod/mini";
|
|
9155
9600
|
var maxRuleSizeBytes = 1024 * 1024;
|
|
9156
9601
|
var maxRulesCount = 1e3;
|
|
9157
9602
|
async function listRules() {
|
|
9158
|
-
const rulesDir =
|
|
9603
|
+
const rulesDir = join88(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
9159
9604
|
try {
|
|
9160
9605
|
const files = await listDirectoryFiles(rulesDir);
|
|
9161
9606
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -9168,7 +9613,7 @@ async function listRules() {
|
|
|
9168
9613
|
});
|
|
9169
9614
|
const frontmatter = rule.getFrontmatter();
|
|
9170
9615
|
return {
|
|
9171
|
-
relativePathFromCwd:
|
|
9616
|
+
relativePathFromCwd: join88(RULESYNC_RULES_RELATIVE_DIR_PATH, file),
|
|
9172
9617
|
frontmatter
|
|
9173
9618
|
};
|
|
9174
9619
|
} catch (error) {
|
|
@@ -9195,7 +9640,7 @@ async function getRule({ relativePathFromCwd }) {
|
|
|
9195
9640
|
validate: true
|
|
9196
9641
|
});
|
|
9197
9642
|
return {
|
|
9198
|
-
relativePathFromCwd:
|
|
9643
|
+
relativePathFromCwd: join88(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
9199
9644
|
frontmatter: rule.getFrontmatter(),
|
|
9200
9645
|
body: rule.getBody()
|
|
9201
9646
|
};
|
|
@@ -9224,7 +9669,7 @@ async function putRule({
|
|
|
9224
9669
|
try {
|
|
9225
9670
|
const existingRules = await listRules();
|
|
9226
9671
|
const isUpdate = existingRules.some(
|
|
9227
|
-
(rule2) => rule2.relativePathFromCwd ===
|
|
9672
|
+
(rule2) => rule2.relativePathFromCwd === join88(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
9228
9673
|
);
|
|
9229
9674
|
if (!isUpdate && existingRules.length >= maxRulesCount) {
|
|
9230
9675
|
throw new Error(`Maximum number of rules (${maxRulesCount}) reached`);
|
|
@@ -9237,11 +9682,11 @@ async function putRule({
|
|
|
9237
9682
|
body,
|
|
9238
9683
|
validate: true
|
|
9239
9684
|
});
|
|
9240
|
-
const rulesDir =
|
|
9685
|
+
const rulesDir = join88(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
9241
9686
|
await ensureDir(rulesDir);
|
|
9242
9687
|
await writeFileContent(rule.getFilePath(), rule.getFileContent());
|
|
9243
9688
|
return {
|
|
9244
|
-
relativePathFromCwd:
|
|
9689
|
+
relativePathFromCwd: join88(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
9245
9690
|
frontmatter: rule.getFrontmatter(),
|
|
9246
9691
|
body: rule.getBody()
|
|
9247
9692
|
};
|
|
@@ -9257,11 +9702,11 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
9257
9702
|
intendedRootDir: process.cwd()
|
|
9258
9703
|
});
|
|
9259
9704
|
const filename = basename23(relativePathFromCwd);
|
|
9260
|
-
const fullPath =
|
|
9705
|
+
const fullPath = join88(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH, filename);
|
|
9261
9706
|
try {
|
|
9262
9707
|
await removeFile(fullPath);
|
|
9263
9708
|
return {
|
|
9264
|
-
relativePathFromCwd:
|
|
9709
|
+
relativePathFromCwd: join88(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
9265
9710
|
};
|
|
9266
9711
|
} catch (error) {
|
|
9267
9712
|
throw new Error(`Failed to delete rule file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -9270,23 +9715,23 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
9270
9715
|
}
|
|
9271
9716
|
}
|
|
9272
9717
|
var ruleToolSchemas = {
|
|
9273
|
-
listRules:
|
|
9274
|
-
getRule:
|
|
9275
|
-
relativePathFromCwd:
|
|
9718
|
+
listRules: z37.object({}),
|
|
9719
|
+
getRule: z37.object({
|
|
9720
|
+
relativePathFromCwd: z37.string()
|
|
9276
9721
|
}),
|
|
9277
|
-
putRule:
|
|
9278
|
-
relativePathFromCwd:
|
|
9722
|
+
putRule: z37.object({
|
|
9723
|
+
relativePathFromCwd: z37.string(),
|
|
9279
9724
|
frontmatter: RulesyncRuleFrontmatterSchema,
|
|
9280
|
-
body:
|
|
9725
|
+
body: z37.string()
|
|
9281
9726
|
}),
|
|
9282
|
-
deleteRule:
|
|
9283
|
-
relativePathFromCwd:
|
|
9727
|
+
deleteRule: z37.object({
|
|
9728
|
+
relativePathFromCwd: z37.string()
|
|
9284
9729
|
})
|
|
9285
9730
|
};
|
|
9286
9731
|
var ruleTools = {
|
|
9287
9732
|
listRules: {
|
|
9288
9733
|
name: "listRules",
|
|
9289
|
-
description: `List all rules from ${
|
|
9734
|
+
description: `List all rules from ${join88(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
9290
9735
|
parameters: ruleToolSchemas.listRules,
|
|
9291
9736
|
execute: async () => {
|
|
9292
9737
|
const rules = await listRules();
|
|
@@ -9328,8 +9773,8 @@ var ruleTools = {
|
|
|
9328
9773
|
};
|
|
9329
9774
|
|
|
9330
9775
|
// src/mcp/skills.ts
|
|
9331
|
-
import { basename as basename24, dirname as dirname2, join as
|
|
9332
|
-
import { z as
|
|
9776
|
+
import { basename as basename24, dirname as dirname2, join as join89 } from "path";
|
|
9777
|
+
import { z as z38 } from "zod/mini";
|
|
9333
9778
|
var maxSkillSizeBytes = 1024 * 1024;
|
|
9334
9779
|
var maxSkillsCount = 1e3;
|
|
9335
9780
|
function aiDirFileToMcpSkillFile(file) {
|
|
@@ -9352,9 +9797,9 @@ function extractDirName(relativeDirPathFromCwd) {
|
|
|
9352
9797
|
return dirName;
|
|
9353
9798
|
}
|
|
9354
9799
|
async function listSkills() {
|
|
9355
|
-
const skillsDir =
|
|
9800
|
+
const skillsDir = join89(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH);
|
|
9356
9801
|
try {
|
|
9357
|
-
const skillDirPaths = await findFilesByGlobs(
|
|
9802
|
+
const skillDirPaths = await findFilesByGlobs(join89(skillsDir, "*"), { type: "dir" });
|
|
9358
9803
|
const skills = await Promise.all(
|
|
9359
9804
|
skillDirPaths.map(async (dirPath) => {
|
|
9360
9805
|
const dirName = basename24(dirPath);
|
|
@@ -9365,7 +9810,7 @@ async function listSkills() {
|
|
|
9365
9810
|
});
|
|
9366
9811
|
const frontmatter = skill.getFrontmatter();
|
|
9367
9812
|
return {
|
|
9368
|
-
relativeDirPathFromCwd:
|
|
9813
|
+
relativeDirPathFromCwd: join89(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
9369
9814
|
frontmatter
|
|
9370
9815
|
};
|
|
9371
9816
|
} catch (error) {
|
|
@@ -9391,7 +9836,7 @@ async function getSkill({ relativeDirPathFromCwd }) {
|
|
|
9391
9836
|
dirName
|
|
9392
9837
|
});
|
|
9393
9838
|
return {
|
|
9394
|
-
relativeDirPathFromCwd:
|
|
9839
|
+
relativeDirPathFromCwd: join89(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
9395
9840
|
frontmatter: skill.getFrontmatter(),
|
|
9396
9841
|
body: skill.getBody(),
|
|
9397
9842
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -9425,7 +9870,7 @@ async function putSkill({
|
|
|
9425
9870
|
try {
|
|
9426
9871
|
const existingSkills = await listSkills();
|
|
9427
9872
|
const isUpdate = existingSkills.some(
|
|
9428
|
-
(skill2) => skill2.relativeDirPathFromCwd ===
|
|
9873
|
+
(skill2) => skill2.relativeDirPathFromCwd === join89(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
9429
9874
|
);
|
|
9430
9875
|
if (!isUpdate && existingSkills.length >= maxSkillsCount) {
|
|
9431
9876
|
throw new Error(`Maximum number of skills (${maxSkillsCount}) reached`);
|
|
@@ -9440,9 +9885,9 @@ async function putSkill({
|
|
|
9440
9885
|
otherFiles: aiDirFiles,
|
|
9441
9886
|
validate: true
|
|
9442
9887
|
});
|
|
9443
|
-
const skillDirPath =
|
|
9888
|
+
const skillDirPath = join89(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
9444
9889
|
await ensureDir(skillDirPath);
|
|
9445
|
-
const skillFilePath =
|
|
9890
|
+
const skillFilePath = join89(skillDirPath, SKILL_FILE_NAME);
|
|
9446
9891
|
const skillFileContent = stringifyFrontmatter(body, frontmatter);
|
|
9447
9892
|
await writeFileContent(skillFilePath, skillFileContent);
|
|
9448
9893
|
for (const file of otherFiles) {
|
|
@@ -9450,15 +9895,15 @@ async function putSkill({
|
|
|
9450
9895
|
relativePath: file.name,
|
|
9451
9896
|
intendedRootDir: skillDirPath
|
|
9452
9897
|
});
|
|
9453
|
-
const filePath =
|
|
9454
|
-
const fileDir =
|
|
9898
|
+
const filePath = join89(skillDirPath, file.name);
|
|
9899
|
+
const fileDir = join89(skillDirPath, dirname2(file.name));
|
|
9455
9900
|
if (fileDir !== skillDirPath) {
|
|
9456
9901
|
await ensureDir(fileDir);
|
|
9457
9902
|
}
|
|
9458
9903
|
await writeFileContent(filePath, file.body);
|
|
9459
9904
|
}
|
|
9460
9905
|
return {
|
|
9461
|
-
relativeDirPathFromCwd:
|
|
9906
|
+
relativeDirPathFromCwd: join89(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
9462
9907
|
frontmatter: skill.getFrontmatter(),
|
|
9463
9908
|
body: skill.getBody(),
|
|
9464
9909
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -9480,13 +9925,13 @@ async function deleteSkill({
|
|
|
9480
9925
|
intendedRootDir: process.cwd()
|
|
9481
9926
|
});
|
|
9482
9927
|
const dirName = extractDirName(relativeDirPathFromCwd);
|
|
9483
|
-
const skillDirPath =
|
|
9928
|
+
const skillDirPath = join89(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
9484
9929
|
try {
|
|
9485
9930
|
if (await directoryExists(skillDirPath)) {
|
|
9486
9931
|
await removeDirectory(skillDirPath);
|
|
9487
9932
|
}
|
|
9488
9933
|
return {
|
|
9489
|
-
relativeDirPathFromCwd:
|
|
9934
|
+
relativeDirPathFromCwd: join89(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
9490
9935
|
};
|
|
9491
9936
|
} catch (error) {
|
|
9492
9937
|
throw new Error(
|
|
@@ -9497,29 +9942,29 @@ async function deleteSkill({
|
|
|
9497
9942
|
);
|
|
9498
9943
|
}
|
|
9499
9944
|
}
|
|
9500
|
-
var McpSkillFileSchema =
|
|
9501
|
-
name:
|
|
9502
|
-
body:
|
|
9945
|
+
var McpSkillFileSchema = z38.object({
|
|
9946
|
+
name: z38.string(),
|
|
9947
|
+
body: z38.string()
|
|
9503
9948
|
});
|
|
9504
9949
|
var skillToolSchemas = {
|
|
9505
|
-
listSkills:
|
|
9506
|
-
getSkill:
|
|
9507
|
-
relativeDirPathFromCwd:
|
|
9950
|
+
listSkills: z38.object({}),
|
|
9951
|
+
getSkill: z38.object({
|
|
9952
|
+
relativeDirPathFromCwd: z38.string()
|
|
9508
9953
|
}),
|
|
9509
|
-
putSkill:
|
|
9510
|
-
relativeDirPathFromCwd:
|
|
9954
|
+
putSkill: z38.object({
|
|
9955
|
+
relativeDirPathFromCwd: z38.string(),
|
|
9511
9956
|
frontmatter: RulesyncSkillFrontmatterSchema,
|
|
9512
|
-
body:
|
|
9513
|
-
otherFiles:
|
|
9957
|
+
body: z38.string(),
|
|
9958
|
+
otherFiles: z38.optional(z38.array(McpSkillFileSchema))
|
|
9514
9959
|
}),
|
|
9515
|
-
deleteSkill:
|
|
9516
|
-
relativeDirPathFromCwd:
|
|
9960
|
+
deleteSkill: z38.object({
|
|
9961
|
+
relativeDirPathFromCwd: z38.string()
|
|
9517
9962
|
})
|
|
9518
9963
|
};
|
|
9519
9964
|
var skillTools = {
|
|
9520
9965
|
listSkills: {
|
|
9521
9966
|
name: "listSkills",
|
|
9522
|
-
description: `List all skills from ${
|
|
9967
|
+
description: `List all skills from ${join89(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "*", SKILL_FILE_NAME)} with their frontmatter.`,
|
|
9523
9968
|
parameters: skillToolSchemas.listSkills,
|
|
9524
9969
|
execute: async () => {
|
|
9525
9970
|
const skills = await listSkills();
|
|
@@ -9562,12 +10007,12 @@ var skillTools = {
|
|
|
9562
10007
|
};
|
|
9563
10008
|
|
|
9564
10009
|
// src/mcp/subagents.ts
|
|
9565
|
-
import { basename as basename25, join as
|
|
9566
|
-
import { z as
|
|
10010
|
+
import { basename as basename25, join as join90 } from "path";
|
|
10011
|
+
import { z as z39 } from "zod/mini";
|
|
9567
10012
|
var maxSubagentSizeBytes = 1024 * 1024;
|
|
9568
10013
|
var maxSubagentsCount = 1e3;
|
|
9569
10014
|
async function listSubagents() {
|
|
9570
|
-
const subagentsDir =
|
|
10015
|
+
const subagentsDir = join90(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
9571
10016
|
try {
|
|
9572
10017
|
const files = await listDirectoryFiles(subagentsDir);
|
|
9573
10018
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -9580,7 +10025,7 @@ async function listSubagents() {
|
|
|
9580
10025
|
});
|
|
9581
10026
|
const frontmatter = subagent.getFrontmatter();
|
|
9582
10027
|
return {
|
|
9583
|
-
relativePathFromCwd:
|
|
10028
|
+
relativePathFromCwd: join90(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, file),
|
|
9584
10029
|
frontmatter
|
|
9585
10030
|
};
|
|
9586
10031
|
} catch (error) {
|
|
@@ -9609,7 +10054,7 @@ async function getSubagent({ relativePathFromCwd }) {
|
|
|
9609
10054
|
validate: true
|
|
9610
10055
|
});
|
|
9611
10056
|
return {
|
|
9612
|
-
relativePathFromCwd:
|
|
10057
|
+
relativePathFromCwd: join90(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
9613
10058
|
frontmatter: subagent.getFrontmatter(),
|
|
9614
10059
|
body: subagent.getBody()
|
|
9615
10060
|
};
|
|
@@ -9638,7 +10083,7 @@ async function putSubagent({
|
|
|
9638
10083
|
try {
|
|
9639
10084
|
const existingSubagents = await listSubagents();
|
|
9640
10085
|
const isUpdate = existingSubagents.some(
|
|
9641
|
-
(subagent2) => subagent2.relativePathFromCwd ===
|
|
10086
|
+
(subagent2) => subagent2.relativePathFromCwd === join90(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
9642
10087
|
);
|
|
9643
10088
|
if (!isUpdate && existingSubagents.length >= maxSubagentsCount) {
|
|
9644
10089
|
throw new Error(`Maximum number of subagents (${maxSubagentsCount}) reached`);
|
|
@@ -9651,11 +10096,11 @@ async function putSubagent({
|
|
|
9651
10096
|
body,
|
|
9652
10097
|
validate: true
|
|
9653
10098
|
});
|
|
9654
|
-
const subagentsDir =
|
|
10099
|
+
const subagentsDir = join90(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
9655
10100
|
await ensureDir(subagentsDir);
|
|
9656
10101
|
await writeFileContent(subagent.getFilePath(), subagent.getFileContent());
|
|
9657
10102
|
return {
|
|
9658
|
-
relativePathFromCwd:
|
|
10103
|
+
relativePathFromCwd: join90(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
9659
10104
|
frontmatter: subagent.getFrontmatter(),
|
|
9660
10105
|
body: subagent.getBody()
|
|
9661
10106
|
};
|
|
@@ -9671,11 +10116,11 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
9671
10116
|
intendedRootDir: process.cwd()
|
|
9672
10117
|
});
|
|
9673
10118
|
const filename = basename25(relativePathFromCwd);
|
|
9674
|
-
const fullPath =
|
|
10119
|
+
const fullPath = join90(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename);
|
|
9675
10120
|
try {
|
|
9676
10121
|
await removeFile(fullPath);
|
|
9677
10122
|
return {
|
|
9678
|
-
relativePathFromCwd:
|
|
10123
|
+
relativePathFromCwd: join90(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
9679
10124
|
};
|
|
9680
10125
|
} catch (error) {
|
|
9681
10126
|
throw new Error(
|
|
@@ -9687,23 +10132,23 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
9687
10132
|
}
|
|
9688
10133
|
}
|
|
9689
10134
|
var subagentToolSchemas = {
|
|
9690
|
-
listSubagents:
|
|
9691
|
-
getSubagent:
|
|
9692
|
-
relativePathFromCwd:
|
|
10135
|
+
listSubagents: z39.object({}),
|
|
10136
|
+
getSubagent: z39.object({
|
|
10137
|
+
relativePathFromCwd: z39.string()
|
|
9693
10138
|
}),
|
|
9694
|
-
putSubagent:
|
|
9695
|
-
relativePathFromCwd:
|
|
10139
|
+
putSubagent: z39.object({
|
|
10140
|
+
relativePathFromCwd: z39.string(),
|
|
9696
10141
|
frontmatter: RulesyncSubagentFrontmatterSchema,
|
|
9697
|
-
body:
|
|
10142
|
+
body: z39.string()
|
|
9698
10143
|
}),
|
|
9699
|
-
deleteSubagent:
|
|
9700
|
-
relativePathFromCwd:
|
|
10144
|
+
deleteSubagent: z39.object({
|
|
10145
|
+
relativePathFromCwd: z39.string()
|
|
9701
10146
|
})
|
|
9702
10147
|
};
|
|
9703
10148
|
var subagentTools = {
|
|
9704
10149
|
listSubagents: {
|
|
9705
10150
|
name: "listSubagents",
|
|
9706
|
-
description: `List all subagents from ${
|
|
10151
|
+
description: `List all subagents from ${join90(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
9707
10152
|
parameters: subagentToolSchemas.listSubagents,
|
|
9708
10153
|
execute: async () => {
|
|
9709
10154
|
const subagents = await listSubagents();
|
|
@@ -9781,7 +10226,7 @@ async function mcpCommand({ version }) {
|
|
|
9781
10226
|
}
|
|
9782
10227
|
|
|
9783
10228
|
// src/cli/index.ts
|
|
9784
|
-
var getVersion = () => "3.
|
|
10229
|
+
var getVersion = () => "3.32.0";
|
|
9785
10230
|
var main = async () => {
|
|
9786
10231
|
const program = new Command();
|
|
9787
10232
|
const version = getVersion();
|