rulesync 4.1.1 → 4.3.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 +33 -19
- package/dist/index.cjs +1024 -568
- package/dist/index.js +1028 -572
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -4727,9 +4727,9 @@ var McpProcessor = class extends FeatureProcessor {
|
|
|
4727
4727
|
};
|
|
4728
4728
|
|
|
4729
4729
|
// src/features/rules/rules-processor.ts
|
|
4730
|
-
var
|
|
4730
|
+
var import_node_path86 = require("path");
|
|
4731
4731
|
var import_toon = require("@toon-format/toon");
|
|
4732
|
-
var
|
|
4732
|
+
var import_mini39 = require("zod/mini");
|
|
4733
4733
|
|
|
4734
4734
|
// src/constants/general.ts
|
|
4735
4735
|
var SKILL_FILE_NAME = "SKILL.md";
|
|
@@ -5160,127 +5160,11 @@ var AgentsmdSkill = class _AgentsmdSkill extends SimulatedSkill {
|
|
|
5160
5160
|
};
|
|
5161
5161
|
|
|
5162
5162
|
// src/features/skills/cursor-skill.ts
|
|
5163
|
-
var import_node_path45 = require("path");
|
|
5164
|
-
var CursorSkill = class _CursorSkill extends SimulatedSkill {
|
|
5165
|
-
static getSettablePaths(options) {
|
|
5166
|
-
if (options?.global) {
|
|
5167
|
-
throw new Error("CursorSkill does not support global mode.");
|
|
5168
|
-
}
|
|
5169
|
-
return {
|
|
5170
|
-
relativeDirPath: (0, import_node_path45.join)(".cursor", "skills")
|
|
5171
|
-
};
|
|
5172
|
-
}
|
|
5173
|
-
static async fromDir(params) {
|
|
5174
|
-
const baseParams = await this.fromDirDefault(params);
|
|
5175
|
-
return new _CursorSkill(baseParams);
|
|
5176
|
-
}
|
|
5177
|
-
static fromRulesyncSkill(params) {
|
|
5178
|
-
const baseParams = {
|
|
5179
|
-
...this.fromRulesyncSkillDefault(params),
|
|
5180
|
-
relativeDirPath: this.getSettablePaths().relativeDirPath
|
|
5181
|
-
};
|
|
5182
|
-
return new _CursorSkill(baseParams);
|
|
5183
|
-
}
|
|
5184
|
-
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
5185
|
-
return this.isTargetedByRulesyncSkillDefault({
|
|
5186
|
-
rulesyncSkill,
|
|
5187
|
-
toolTarget: "cursor"
|
|
5188
|
-
});
|
|
5189
|
-
}
|
|
5190
|
-
static forDeletion(params) {
|
|
5191
|
-
const baseParams = this.forDeletionDefault(params);
|
|
5192
|
-
return new _CursorSkill(baseParams);
|
|
5193
|
-
}
|
|
5194
|
-
};
|
|
5195
|
-
|
|
5196
|
-
// src/features/skills/geminicli-skill.ts
|
|
5197
5163
|
var import_node_path46 = require("path");
|
|
5198
|
-
var GeminiCliSkill = class _GeminiCliSkill extends SimulatedSkill {
|
|
5199
|
-
static getSettablePaths(options) {
|
|
5200
|
-
if (options?.global) {
|
|
5201
|
-
throw new Error("GeminiCliSkill does not support global mode.");
|
|
5202
|
-
}
|
|
5203
|
-
return {
|
|
5204
|
-
relativeDirPath: (0, import_node_path46.join)(".gemini", "skills")
|
|
5205
|
-
};
|
|
5206
|
-
}
|
|
5207
|
-
static async fromDir(params) {
|
|
5208
|
-
const baseParams = await this.fromDirDefault(params);
|
|
5209
|
-
return new _GeminiCliSkill(baseParams);
|
|
5210
|
-
}
|
|
5211
|
-
static fromRulesyncSkill(params) {
|
|
5212
|
-
const baseParams = {
|
|
5213
|
-
...this.fromRulesyncSkillDefault(params),
|
|
5214
|
-
relativeDirPath: this.getSettablePaths().relativeDirPath
|
|
5215
|
-
};
|
|
5216
|
-
return new _GeminiCliSkill(baseParams);
|
|
5217
|
-
}
|
|
5218
|
-
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
5219
|
-
return this.isTargetedByRulesyncSkillDefault({
|
|
5220
|
-
rulesyncSkill,
|
|
5221
|
-
toolTarget: "geminicli"
|
|
5222
|
-
});
|
|
5223
|
-
}
|
|
5224
|
-
static forDeletion(params) {
|
|
5225
|
-
const baseParams = this.forDeletionDefault(params);
|
|
5226
|
-
return new _GeminiCliSkill(baseParams);
|
|
5227
|
-
}
|
|
5228
|
-
};
|
|
5229
|
-
|
|
5230
|
-
// src/features/skills/skills-processor.ts
|
|
5231
|
-
var import_node_path53 = require("path");
|
|
5232
|
-
var import_mini25 = require("zod/mini");
|
|
5233
|
-
|
|
5234
|
-
// src/types/dir-feature-processor.ts
|
|
5235
|
-
var import_node_path47 = require("path");
|
|
5236
|
-
var DirFeatureProcessor = class {
|
|
5237
|
-
baseDir;
|
|
5238
|
-
constructor({ baseDir = process.cwd() }) {
|
|
5239
|
-
this.baseDir = baseDir;
|
|
5240
|
-
}
|
|
5241
|
-
/**
|
|
5242
|
-
* Return tool targets that this feature supports.
|
|
5243
|
-
*/
|
|
5244
|
-
static getToolTargets(_params = {}) {
|
|
5245
|
-
throw new Error("Not implemented");
|
|
5246
|
-
}
|
|
5247
|
-
/**
|
|
5248
|
-
* Once converted to rulesync/tool dirs, write them to the filesystem.
|
|
5249
|
-
* Returns the number of directories written.
|
|
5250
|
-
*/
|
|
5251
|
-
async writeAiDirs(aiDirs) {
|
|
5252
|
-
for (const aiDir of aiDirs) {
|
|
5253
|
-
const dirPath = aiDir.getDirPath();
|
|
5254
|
-
await ensureDir(dirPath);
|
|
5255
|
-
const mainFile = aiDir.getMainFile();
|
|
5256
|
-
if (mainFile) {
|
|
5257
|
-
const mainFilePath = (0, import_node_path47.join)(dirPath, mainFile.name);
|
|
5258
|
-
const content = stringifyFrontmatter(mainFile.body, mainFile.frontmatter);
|
|
5259
|
-
const contentWithNewline = addTrailingNewline(content);
|
|
5260
|
-
await writeFileContent(mainFilePath, contentWithNewline);
|
|
5261
|
-
}
|
|
5262
|
-
const otherFiles = aiDir.getOtherFiles();
|
|
5263
|
-
for (const file of otherFiles) {
|
|
5264
|
-
const filePath = (0, import_node_path47.join)(dirPath, file.relativeFilePathToDirPath);
|
|
5265
|
-
const contentWithNewline = addTrailingNewline(file.fileBuffer.toString("utf-8"));
|
|
5266
|
-
await writeFileContent(filePath, contentWithNewline);
|
|
5267
|
-
}
|
|
5268
|
-
}
|
|
5269
|
-
return aiDirs.length;
|
|
5270
|
-
}
|
|
5271
|
-
async removeAiDirs(aiDirs) {
|
|
5272
|
-
for (const aiDir of aiDirs) {
|
|
5273
|
-
await removeDirectory(aiDir.getDirPath());
|
|
5274
|
-
}
|
|
5275
|
-
}
|
|
5276
|
-
};
|
|
5277
|
-
|
|
5278
|
-
// src/features/skills/claudecode-skill.ts
|
|
5279
|
-
var import_node_path49 = require("path");
|
|
5280
5164
|
var import_mini21 = require("zod/mini");
|
|
5281
5165
|
|
|
5282
5166
|
// src/features/skills/rulesync-skill.ts
|
|
5283
|
-
var
|
|
5167
|
+
var import_node_path45 = require("path");
|
|
5284
5168
|
var import_mini20 = require("zod/mini");
|
|
5285
5169
|
var RulesyncSkillFrontmatterSchemaInternal = import_mini20.z.looseObject({
|
|
5286
5170
|
name: import_mini20.z.string(),
|
|
@@ -5360,47 +5244,289 @@ var RulesyncSkill = class _RulesyncSkill extends AiDir {
|
|
|
5360
5244
|
}
|
|
5361
5245
|
return { success: true, error: null };
|
|
5362
5246
|
}
|
|
5363
|
-
static async fromDir({
|
|
5364
|
-
baseDir = process.cwd(),
|
|
5365
|
-
relativeDirPath = RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
5366
|
-
dirName,
|
|
5367
|
-
global = false
|
|
5368
|
-
}) {
|
|
5369
|
-
const skillDirPath = (0,
|
|
5370
|
-
const skillFilePath = (0,
|
|
5371
|
-
if (!await fileExists(skillFilePath)) {
|
|
5372
|
-
throw new Error(`${SKILL_FILE_NAME} not found in ${skillDirPath}`);
|
|
5247
|
+
static async fromDir({
|
|
5248
|
+
baseDir = process.cwd(),
|
|
5249
|
+
relativeDirPath = RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
5250
|
+
dirName,
|
|
5251
|
+
global = false
|
|
5252
|
+
}) {
|
|
5253
|
+
const skillDirPath = (0, import_node_path45.join)(baseDir, relativeDirPath, dirName);
|
|
5254
|
+
const skillFilePath = (0, import_node_path45.join)(skillDirPath, SKILL_FILE_NAME);
|
|
5255
|
+
if (!await fileExists(skillFilePath)) {
|
|
5256
|
+
throw new Error(`${SKILL_FILE_NAME} not found in ${skillDirPath}`);
|
|
5257
|
+
}
|
|
5258
|
+
const fileContent = await readFileContent(skillFilePath);
|
|
5259
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
5260
|
+
const result = RulesyncSkillFrontmatterSchema.safeParse(frontmatter);
|
|
5261
|
+
if (!result.success) {
|
|
5262
|
+
throw new Error(`Invalid frontmatter in ${skillFilePath}: ${formatError(result.error)}`);
|
|
5263
|
+
}
|
|
5264
|
+
const otherFiles = await this.collectOtherFiles(
|
|
5265
|
+
baseDir,
|
|
5266
|
+
relativeDirPath,
|
|
5267
|
+
dirName,
|
|
5268
|
+
SKILL_FILE_NAME
|
|
5269
|
+
);
|
|
5270
|
+
return new _RulesyncSkill({
|
|
5271
|
+
baseDir,
|
|
5272
|
+
relativeDirPath,
|
|
5273
|
+
dirName,
|
|
5274
|
+
frontmatter: result.data,
|
|
5275
|
+
body: content.trim(),
|
|
5276
|
+
otherFiles,
|
|
5277
|
+
validate: true,
|
|
5278
|
+
global
|
|
5279
|
+
});
|
|
5280
|
+
}
|
|
5281
|
+
};
|
|
5282
|
+
|
|
5283
|
+
// src/features/skills/cursor-skill.ts
|
|
5284
|
+
var CursorSkillFrontmatterSchema = import_mini21.z.looseObject({
|
|
5285
|
+
name: import_mini21.z.string(),
|
|
5286
|
+
description: import_mini21.z.string()
|
|
5287
|
+
});
|
|
5288
|
+
var CursorSkill = class _CursorSkill extends ToolSkill {
|
|
5289
|
+
constructor({
|
|
5290
|
+
baseDir = process.cwd(),
|
|
5291
|
+
relativeDirPath = (0, import_node_path46.join)(".cursor", "skills"),
|
|
5292
|
+
dirName,
|
|
5293
|
+
frontmatter,
|
|
5294
|
+
body,
|
|
5295
|
+
otherFiles = [],
|
|
5296
|
+
validate = true,
|
|
5297
|
+
global = false
|
|
5298
|
+
}) {
|
|
5299
|
+
super({
|
|
5300
|
+
baseDir,
|
|
5301
|
+
relativeDirPath,
|
|
5302
|
+
dirName,
|
|
5303
|
+
mainFile: {
|
|
5304
|
+
name: SKILL_FILE_NAME,
|
|
5305
|
+
body,
|
|
5306
|
+
frontmatter: { ...frontmatter }
|
|
5307
|
+
},
|
|
5308
|
+
otherFiles,
|
|
5309
|
+
global
|
|
5310
|
+
});
|
|
5311
|
+
if (validate) {
|
|
5312
|
+
const result = this.validate();
|
|
5313
|
+
if (!result.success) {
|
|
5314
|
+
throw result.error;
|
|
5315
|
+
}
|
|
5316
|
+
}
|
|
5317
|
+
}
|
|
5318
|
+
static getSettablePaths(options) {
|
|
5319
|
+
if (options?.global) {
|
|
5320
|
+
throw new Error("CursorSkill does not support global mode.");
|
|
5321
|
+
}
|
|
5322
|
+
return {
|
|
5323
|
+
relativeDirPath: (0, import_node_path46.join)(".cursor", "skills")
|
|
5324
|
+
};
|
|
5325
|
+
}
|
|
5326
|
+
getFrontmatter() {
|
|
5327
|
+
if (!this.mainFile?.frontmatter) {
|
|
5328
|
+
throw new Error("Frontmatter is not defined");
|
|
5329
|
+
}
|
|
5330
|
+
const result = CursorSkillFrontmatterSchema.parse(this.mainFile.frontmatter);
|
|
5331
|
+
return result;
|
|
5332
|
+
}
|
|
5333
|
+
getBody() {
|
|
5334
|
+
return this.mainFile?.body ?? "";
|
|
5335
|
+
}
|
|
5336
|
+
validate() {
|
|
5337
|
+
if (!this.mainFile) {
|
|
5338
|
+
return {
|
|
5339
|
+
success: false,
|
|
5340
|
+
error: new Error(`${this.getDirPath()}: ${SKILL_FILE_NAME} file does not exist`)
|
|
5341
|
+
};
|
|
5342
|
+
}
|
|
5343
|
+
const result = CursorSkillFrontmatterSchema.safeParse(this.mainFile.frontmatter);
|
|
5344
|
+
if (!result.success) {
|
|
5345
|
+
return {
|
|
5346
|
+
success: false,
|
|
5347
|
+
error: new Error(
|
|
5348
|
+
`Invalid frontmatter in ${this.getDirPath()}: ${formatError(result.error)}`
|
|
5349
|
+
)
|
|
5350
|
+
};
|
|
5351
|
+
}
|
|
5352
|
+
return { success: true, error: null };
|
|
5353
|
+
}
|
|
5354
|
+
toRulesyncSkill() {
|
|
5355
|
+
const frontmatter = this.getFrontmatter();
|
|
5356
|
+
const rulesyncFrontmatter = {
|
|
5357
|
+
name: frontmatter.name,
|
|
5358
|
+
description: frontmatter.description,
|
|
5359
|
+
targets: ["*"]
|
|
5360
|
+
};
|
|
5361
|
+
return new RulesyncSkill({
|
|
5362
|
+
baseDir: this.baseDir,
|
|
5363
|
+
relativeDirPath: this.relativeDirPath,
|
|
5364
|
+
dirName: this.getDirName(),
|
|
5365
|
+
frontmatter: rulesyncFrontmatter,
|
|
5366
|
+
body: this.getBody(),
|
|
5367
|
+
otherFiles: this.getOtherFiles(),
|
|
5368
|
+
validate: true,
|
|
5369
|
+
global: this.global
|
|
5370
|
+
});
|
|
5371
|
+
}
|
|
5372
|
+
static fromRulesyncSkill({
|
|
5373
|
+
rulesyncSkill,
|
|
5374
|
+
validate = true,
|
|
5375
|
+
global = false
|
|
5376
|
+
}) {
|
|
5377
|
+
const settablePaths = _CursorSkill.getSettablePaths({ global });
|
|
5378
|
+
const rulesyncFrontmatter = rulesyncSkill.getFrontmatter();
|
|
5379
|
+
const cursorFrontmatter = {
|
|
5380
|
+
name: rulesyncFrontmatter.name,
|
|
5381
|
+
description: rulesyncFrontmatter.description
|
|
5382
|
+
};
|
|
5383
|
+
return new _CursorSkill({
|
|
5384
|
+
baseDir: rulesyncSkill.getBaseDir(),
|
|
5385
|
+
relativeDirPath: settablePaths.relativeDirPath,
|
|
5386
|
+
dirName: rulesyncSkill.getDirName(),
|
|
5387
|
+
frontmatter: cursorFrontmatter,
|
|
5388
|
+
body: rulesyncSkill.getBody(),
|
|
5389
|
+
otherFiles: rulesyncSkill.getOtherFiles(),
|
|
5390
|
+
validate,
|
|
5391
|
+
global
|
|
5392
|
+
});
|
|
5393
|
+
}
|
|
5394
|
+
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
5395
|
+
const targets = rulesyncSkill.getFrontmatter().targets;
|
|
5396
|
+
return targets.includes("*") || targets.includes("cursor");
|
|
5397
|
+
}
|
|
5398
|
+
static async fromDir(params) {
|
|
5399
|
+
const loaded = await this.loadSkillDirContent({
|
|
5400
|
+
...params,
|
|
5401
|
+
getSettablePaths: _CursorSkill.getSettablePaths
|
|
5402
|
+
});
|
|
5403
|
+
const result = CursorSkillFrontmatterSchema.safeParse(loaded.frontmatter);
|
|
5404
|
+
if (!result.success) {
|
|
5405
|
+
const skillDirPath = (0, import_node_path46.join)(loaded.baseDir, loaded.relativeDirPath, loaded.dirName);
|
|
5406
|
+
throw new Error(
|
|
5407
|
+
`Invalid frontmatter in ${(0, import_node_path46.join)(skillDirPath, SKILL_FILE_NAME)}: ${formatError(result.error)}`
|
|
5408
|
+
);
|
|
5409
|
+
}
|
|
5410
|
+
return new _CursorSkill({
|
|
5411
|
+
baseDir: loaded.baseDir,
|
|
5412
|
+
relativeDirPath: loaded.relativeDirPath,
|
|
5413
|
+
dirName: loaded.dirName,
|
|
5414
|
+
frontmatter: result.data,
|
|
5415
|
+
body: loaded.body,
|
|
5416
|
+
otherFiles: loaded.otherFiles,
|
|
5417
|
+
validate: true,
|
|
5418
|
+
global: loaded.global
|
|
5419
|
+
});
|
|
5420
|
+
}
|
|
5421
|
+
static forDeletion({
|
|
5422
|
+
baseDir = process.cwd(),
|
|
5423
|
+
relativeDirPath,
|
|
5424
|
+
dirName,
|
|
5425
|
+
global = false
|
|
5426
|
+
}) {
|
|
5427
|
+
const settablePaths = _CursorSkill.getSettablePaths({ global });
|
|
5428
|
+
return new _CursorSkill({
|
|
5429
|
+
baseDir,
|
|
5430
|
+
relativeDirPath: relativeDirPath ?? settablePaths.relativeDirPath,
|
|
5431
|
+
dirName,
|
|
5432
|
+
frontmatter: { name: "", description: "" },
|
|
5433
|
+
body: "",
|
|
5434
|
+
otherFiles: [],
|
|
5435
|
+
validate: false,
|
|
5436
|
+
global
|
|
5437
|
+
});
|
|
5438
|
+
}
|
|
5439
|
+
};
|
|
5440
|
+
|
|
5441
|
+
// src/features/skills/geminicli-skill.ts
|
|
5442
|
+
var import_node_path47 = require("path");
|
|
5443
|
+
var GeminiCliSkill = class _GeminiCliSkill extends SimulatedSkill {
|
|
5444
|
+
static getSettablePaths(options) {
|
|
5445
|
+
if (options?.global) {
|
|
5446
|
+
throw new Error("GeminiCliSkill does not support global mode.");
|
|
5447
|
+
}
|
|
5448
|
+
return {
|
|
5449
|
+
relativeDirPath: (0, import_node_path47.join)(".gemini", "skills")
|
|
5450
|
+
};
|
|
5451
|
+
}
|
|
5452
|
+
static async fromDir(params) {
|
|
5453
|
+
const baseParams = await this.fromDirDefault(params);
|
|
5454
|
+
return new _GeminiCliSkill(baseParams);
|
|
5455
|
+
}
|
|
5456
|
+
static fromRulesyncSkill(params) {
|
|
5457
|
+
const baseParams = {
|
|
5458
|
+
...this.fromRulesyncSkillDefault(params),
|
|
5459
|
+
relativeDirPath: this.getSettablePaths().relativeDirPath
|
|
5460
|
+
};
|
|
5461
|
+
return new _GeminiCliSkill(baseParams);
|
|
5462
|
+
}
|
|
5463
|
+
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
5464
|
+
return this.isTargetedByRulesyncSkillDefault({
|
|
5465
|
+
rulesyncSkill,
|
|
5466
|
+
toolTarget: "geminicli"
|
|
5467
|
+
});
|
|
5468
|
+
}
|
|
5469
|
+
static forDeletion(params) {
|
|
5470
|
+
const baseParams = this.forDeletionDefault(params);
|
|
5471
|
+
return new _GeminiCliSkill(baseParams);
|
|
5472
|
+
}
|
|
5473
|
+
};
|
|
5474
|
+
|
|
5475
|
+
// src/features/skills/skills-processor.ts
|
|
5476
|
+
var import_node_path53 = require("path");
|
|
5477
|
+
var import_mini26 = require("zod/mini");
|
|
5478
|
+
|
|
5479
|
+
// src/types/dir-feature-processor.ts
|
|
5480
|
+
var import_node_path48 = require("path");
|
|
5481
|
+
var DirFeatureProcessor = class {
|
|
5482
|
+
baseDir;
|
|
5483
|
+
constructor({ baseDir = process.cwd() }) {
|
|
5484
|
+
this.baseDir = baseDir;
|
|
5485
|
+
}
|
|
5486
|
+
/**
|
|
5487
|
+
* Return tool targets that this feature supports.
|
|
5488
|
+
*/
|
|
5489
|
+
static getToolTargets(_params = {}) {
|
|
5490
|
+
throw new Error("Not implemented");
|
|
5491
|
+
}
|
|
5492
|
+
/**
|
|
5493
|
+
* Once converted to rulesync/tool dirs, write them to the filesystem.
|
|
5494
|
+
* Returns the number of directories written.
|
|
5495
|
+
*/
|
|
5496
|
+
async writeAiDirs(aiDirs) {
|
|
5497
|
+
for (const aiDir of aiDirs) {
|
|
5498
|
+
const dirPath = aiDir.getDirPath();
|
|
5499
|
+
await ensureDir(dirPath);
|
|
5500
|
+
const mainFile = aiDir.getMainFile();
|
|
5501
|
+
if (mainFile) {
|
|
5502
|
+
const mainFilePath = (0, import_node_path48.join)(dirPath, mainFile.name);
|
|
5503
|
+
const content = stringifyFrontmatter(mainFile.body, mainFile.frontmatter);
|
|
5504
|
+
const contentWithNewline = addTrailingNewline(content);
|
|
5505
|
+
await writeFileContent(mainFilePath, contentWithNewline);
|
|
5506
|
+
}
|
|
5507
|
+
const otherFiles = aiDir.getOtherFiles();
|
|
5508
|
+
for (const file of otherFiles) {
|
|
5509
|
+
const filePath = (0, import_node_path48.join)(dirPath, file.relativeFilePathToDirPath);
|
|
5510
|
+
const contentWithNewline = addTrailingNewline(file.fileBuffer.toString("utf-8"));
|
|
5511
|
+
await writeFileContent(filePath, contentWithNewline);
|
|
5512
|
+
}
|
|
5373
5513
|
}
|
|
5374
|
-
|
|
5375
|
-
|
|
5376
|
-
|
|
5377
|
-
|
|
5378
|
-
|
|
5514
|
+
return aiDirs.length;
|
|
5515
|
+
}
|
|
5516
|
+
async removeAiDirs(aiDirs) {
|
|
5517
|
+
for (const aiDir of aiDirs) {
|
|
5518
|
+
await removeDirectory(aiDir.getDirPath());
|
|
5379
5519
|
}
|
|
5380
|
-
const otherFiles = await this.collectOtherFiles(
|
|
5381
|
-
baseDir,
|
|
5382
|
-
relativeDirPath,
|
|
5383
|
-
dirName,
|
|
5384
|
-
SKILL_FILE_NAME
|
|
5385
|
-
);
|
|
5386
|
-
return new _RulesyncSkill({
|
|
5387
|
-
baseDir,
|
|
5388
|
-
relativeDirPath,
|
|
5389
|
-
dirName,
|
|
5390
|
-
frontmatter: result.data,
|
|
5391
|
-
body: content.trim(),
|
|
5392
|
-
otherFiles,
|
|
5393
|
-
validate: true,
|
|
5394
|
-
global
|
|
5395
|
-
});
|
|
5396
5520
|
}
|
|
5397
5521
|
};
|
|
5398
5522
|
|
|
5399
5523
|
// src/features/skills/claudecode-skill.ts
|
|
5400
|
-
var
|
|
5401
|
-
|
|
5402
|
-
|
|
5403
|
-
|
|
5524
|
+
var import_node_path49 = require("path");
|
|
5525
|
+
var import_mini22 = require("zod/mini");
|
|
5526
|
+
var ClaudecodeSkillFrontmatterSchema = import_mini22.z.looseObject({
|
|
5527
|
+
name: import_mini22.z.string(),
|
|
5528
|
+
description: import_mini22.z.string(),
|
|
5529
|
+
"allowed-tools": import_mini22.z.optional(import_mini22.z.array(import_mini22.z.string()))
|
|
5404
5530
|
});
|
|
5405
5531
|
var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
|
|
5406
5532
|
constructor({
|
|
@@ -5561,10 +5687,10 @@ var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
|
|
|
5561
5687
|
|
|
5562
5688
|
// src/features/skills/codexcli-skill.ts
|
|
5563
5689
|
var import_node_path50 = require("path");
|
|
5564
|
-
var
|
|
5565
|
-
var CodexCliSkillFrontmatterSchema =
|
|
5566
|
-
name:
|
|
5567
|
-
description:
|
|
5690
|
+
var import_mini23 = require("zod/mini");
|
|
5691
|
+
var CodexCliSkillFrontmatterSchema = import_mini23.z.looseObject({
|
|
5692
|
+
name: import_mini23.z.string(),
|
|
5693
|
+
description: import_mini23.z.string()
|
|
5568
5694
|
});
|
|
5569
5695
|
var CodexCliSkill = class _CodexCliSkill extends ToolSkill {
|
|
5570
5696
|
constructor({
|
|
@@ -5720,11 +5846,11 @@ var CodexCliSkill = class _CodexCliSkill extends ToolSkill {
|
|
|
5720
5846
|
|
|
5721
5847
|
// src/features/skills/copilot-skill.ts
|
|
5722
5848
|
var import_node_path51 = require("path");
|
|
5723
|
-
var
|
|
5724
|
-
var CopilotSkillFrontmatterSchema =
|
|
5725
|
-
name:
|
|
5726
|
-
description:
|
|
5727
|
-
license:
|
|
5849
|
+
var import_mini24 = require("zod/mini");
|
|
5850
|
+
var CopilotSkillFrontmatterSchema = import_mini24.z.looseObject({
|
|
5851
|
+
name: import_mini24.z.string(),
|
|
5852
|
+
description: import_mini24.z.string(),
|
|
5853
|
+
license: import_mini24.z.optional(import_mini24.z.string())
|
|
5728
5854
|
});
|
|
5729
5855
|
var CopilotSkill = class _CopilotSkill extends ToolSkill {
|
|
5730
5856
|
constructor({
|
|
@@ -5887,11 +6013,11 @@ var CopilotSkill = class _CopilotSkill extends ToolSkill {
|
|
|
5887
6013
|
|
|
5888
6014
|
// src/features/skills/opencode-skill.ts
|
|
5889
6015
|
var import_node_path52 = require("path");
|
|
5890
|
-
var
|
|
5891
|
-
var OpenCodeSkillFrontmatterSchema =
|
|
5892
|
-
name:
|
|
5893
|
-
description:
|
|
5894
|
-
"allowed-tools":
|
|
6016
|
+
var import_mini25 = require("zod/mini");
|
|
6017
|
+
var OpenCodeSkillFrontmatterSchema = import_mini25.z.looseObject({
|
|
6018
|
+
name: import_mini25.z.string(),
|
|
6019
|
+
description: import_mini25.z.string(),
|
|
6020
|
+
"allowed-tools": import_mini25.z.optional(import_mini25.z.array(import_mini25.z.string()))
|
|
5895
6021
|
});
|
|
5896
6022
|
var OpenCodeSkill = class _OpenCodeSkill extends ToolSkill {
|
|
5897
6023
|
constructor({
|
|
@@ -6058,7 +6184,7 @@ var skillsProcessorToolTargetTuple = [
|
|
|
6058
6184
|
"geminicli",
|
|
6059
6185
|
"opencode"
|
|
6060
6186
|
];
|
|
6061
|
-
var SkillsProcessorToolTargetSchema =
|
|
6187
|
+
var SkillsProcessorToolTargetSchema = import_mini26.z.enum(skillsProcessorToolTargetTuple);
|
|
6062
6188
|
var toolSkillFactories = /* @__PURE__ */ new Map([
|
|
6063
6189
|
[
|
|
6064
6190
|
"agentsmd",
|
|
@@ -6092,7 +6218,7 @@ var toolSkillFactories = /* @__PURE__ */ new Map([
|
|
|
6092
6218
|
"cursor",
|
|
6093
6219
|
{
|
|
6094
6220
|
class: CursorSkill,
|
|
6095
|
-
meta: { supportsProject: true, supportsSimulated:
|
|
6221
|
+
meta: { supportsProject: true, supportsSimulated: false, supportsGlobal: false }
|
|
6096
6222
|
}
|
|
6097
6223
|
],
|
|
6098
6224
|
[
|
|
@@ -6277,7 +6403,7 @@ var import_node_path55 = require("path");
|
|
|
6277
6403
|
|
|
6278
6404
|
// src/features/subagents/simulated-subagent.ts
|
|
6279
6405
|
var import_node_path54 = require("path");
|
|
6280
|
-
var
|
|
6406
|
+
var import_mini27 = require("zod/mini");
|
|
6281
6407
|
|
|
6282
6408
|
// src/features/subagents/tool-subagent.ts
|
|
6283
6409
|
var ToolSubagent = class extends ToolFile {
|
|
@@ -6320,9 +6446,9 @@ var ToolSubagent = class extends ToolFile {
|
|
|
6320
6446
|
};
|
|
6321
6447
|
|
|
6322
6448
|
// src/features/subagents/simulated-subagent.ts
|
|
6323
|
-
var SimulatedSubagentFrontmatterSchema =
|
|
6324
|
-
name:
|
|
6325
|
-
description:
|
|
6449
|
+
var SimulatedSubagentFrontmatterSchema = import_mini27.z.object({
|
|
6450
|
+
name: import_mini27.z.string(),
|
|
6451
|
+
description: import_mini27.z.string()
|
|
6326
6452
|
});
|
|
6327
6453
|
var SimulatedSubagent = class extends ToolSubagent {
|
|
6328
6454
|
frontmatter;
|
|
@@ -6560,20 +6686,20 @@ var RooSubagent = class _RooSubagent extends SimulatedSubagent {
|
|
|
6560
6686
|
};
|
|
6561
6687
|
|
|
6562
6688
|
// src/features/subagents/subagents-processor.ts
|
|
6563
|
-
var
|
|
6564
|
-
var
|
|
6689
|
+
var import_node_path64 = require("path");
|
|
6690
|
+
var import_mini32 = require("zod/mini");
|
|
6565
6691
|
|
|
6566
6692
|
// src/features/subagents/claudecode-subagent.ts
|
|
6567
6693
|
var import_node_path61 = require("path");
|
|
6568
|
-
var
|
|
6694
|
+
var import_mini29 = require("zod/mini");
|
|
6569
6695
|
|
|
6570
6696
|
// src/features/subagents/rulesync-subagent.ts
|
|
6571
6697
|
var import_node_path60 = require("path");
|
|
6572
|
-
var
|
|
6573
|
-
var RulesyncSubagentFrontmatterSchema =
|
|
6698
|
+
var import_mini28 = require("zod/mini");
|
|
6699
|
+
var RulesyncSubagentFrontmatterSchema = import_mini28.z.looseObject({
|
|
6574
6700
|
targets: RulesyncTargetsSchema,
|
|
6575
|
-
name:
|
|
6576
|
-
description:
|
|
6701
|
+
name: import_mini28.z.string(),
|
|
6702
|
+
description: import_mini28.z.string()
|
|
6577
6703
|
});
|
|
6578
6704
|
var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
6579
6705
|
frontmatter;
|
|
@@ -6644,13 +6770,13 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
6644
6770
|
};
|
|
6645
6771
|
|
|
6646
6772
|
// src/features/subagents/claudecode-subagent.ts
|
|
6647
|
-
var ClaudecodeSubagentFrontmatterSchema =
|
|
6648
|
-
name:
|
|
6649
|
-
description:
|
|
6650
|
-
model:
|
|
6651
|
-
tools:
|
|
6652
|
-
permissionMode:
|
|
6653
|
-
skills:
|
|
6773
|
+
var ClaudecodeSubagentFrontmatterSchema = import_mini29.z.looseObject({
|
|
6774
|
+
name: import_mini29.z.string(),
|
|
6775
|
+
description: import_mini29.z.string(),
|
|
6776
|
+
model: import_mini29.z.optional(import_mini29.z.string()),
|
|
6777
|
+
tools: import_mini29.z.optional(import_mini29.z.union([import_mini29.z.string(), import_mini29.z.array(import_mini29.z.string())])),
|
|
6778
|
+
permissionMode: import_mini29.z.optional(import_mini29.z.string()),
|
|
6779
|
+
skills: import_mini29.z.optional(import_mini29.z.union([import_mini29.z.string(), import_mini29.z.array(import_mini29.z.string())]))
|
|
6654
6780
|
});
|
|
6655
6781
|
var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
6656
6782
|
frontmatter;
|
|
@@ -6746,7 +6872,172 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6746
6872
|
return {
|
|
6747
6873
|
success: false,
|
|
6748
6874
|
error: new Error(
|
|
6749
|
-
`Invalid frontmatter in ${(0, import_node_path61.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6875
|
+
`Invalid frontmatter in ${(0, import_node_path61.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6876
|
+
)
|
|
6877
|
+
};
|
|
6878
|
+
}
|
|
6879
|
+
}
|
|
6880
|
+
static isTargetedByRulesyncSubagent(rulesyncSubagent) {
|
|
6881
|
+
return this.isTargetedByRulesyncSubagentDefault({
|
|
6882
|
+
rulesyncSubagent,
|
|
6883
|
+
toolTarget: "claudecode"
|
|
6884
|
+
});
|
|
6885
|
+
}
|
|
6886
|
+
static async fromFile({
|
|
6887
|
+
baseDir = process.cwd(),
|
|
6888
|
+
relativeFilePath,
|
|
6889
|
+
validate = true,
|
|
6890
|
+
global = false
|
|
6891
|
+
}) {
|
|
6892
|
+
const paths = this.getSettablePaths({ global });
|
|
6893
|
+
const filePath = (0, import_node_path61.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
6894
|
+
const fileContent = await readFileContent(filePath);
|
|
6895
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
6896
|
+
const result = ClaudecodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6897
|
+
if (!result.success) {
|
|
6898
|
+
throw new Error(`Invalid frontmatter in ${filePath}: ${formatError(result.error)}`);
|
|
6899
|
+
}
|
|
6900
|
+
return new _ClaudecodeSubagent({
|
|
6901
|
+
baseDir,
|
|
6902
|
+
relativeDirPath: paths.relativeDirPath,
|
|
6903
|
+
relativeFilePath,
|
|
6904
|
+
frontmatter: result.data,
|
|
6905
|
+
body: content.trim(),
|
|
6906
|
+
fileContent,
|
|
6907
|
+
validate
|
|
6908
|
+
});
|
|
6909
|
+
}
|
|
6910
|
+
static forDeletion({
|
|
6911
|
+
baseDir = process.cwd(),
|
|
6912
|
+
relativeDirPath,
|
|
6913
|
+
relativeFilePath
|
|
6914
|
+
}) {
|
|
6915
|
+
return new _ClaudecodeSubagent({
|
|
6916
|
+
baseDir,
|
|
6917
|
+
relativeDirPath,
|
|
6918
|
+
relativeFilePath,
|
|
6919
|
+
frontmatter: { name: "", description: "" },
|
|
6920
|
+
body: "",
|
|
6921
|
+
fileContent: "",
|
|
6922
|
+
validate: false
|
|
6923
|
+
});
|
|
6924
|
+
}
|
|
6925
|
+
};
|
|
6926
|
+
|
|
6927
|
+
// src/features/subagents/copilot-subagent.ts
|
|
6928
|
+
var import_node_path62 = require("path");
|
|
6929
|
+
var import_mini30 = require("zod/mini");
|
|
6930
|
+
var REQUIRED_TOOL = "agent/runSubagent";
|
|
6931
|
+
var CopilotSubagentFrontmatterSchema = import_mini30.z.looseObject({
|
|
6932
|
+
name: import_mini30.z.string(),
|
|
6933
|
+
description: import_mini30.z.string(),
|
|
6934
|
+
tools: import_mini30.z.optional(import_mini30.z.union([import_mini30.z.string(), import_mini30.z.array(import_mini30.z.string())]))
|
|
6935
|
+
});
|
|
6936
|
+
var normalizeTools = (tools) => {
|
|
6937
|
+
if (!tools) {
|
|
6938
|
+
return [];
|
|
6939
|
+
}
|
|
6940
|
+
return Array.isArray(tools) ? tools : [tools];
|
|
6941
|
+
};
|
|
6942
|
+
var ensureRequiredTool = (tools) => {
|
|
6943
|
+
const mergedTools = /* @__PURE__ */ new Set([REQUIRED_TOOL, ...tools]);
|
|
6944
|
+
return Array.from(mergedTools);
|
|
6945
|
+
};
|
|
6946
|
+
var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
6947
|
+
frontmatter;
|
|
6948
|
+
body;
|
|
6949
|
+
constructor({ frontmatter, body, ...rest }) {
|
|
6950
|
+
if (rest.validate !== false) {
|
|
6951
|
+
const result = CopilotSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6952
|
+
if (!result.success) {
|
|
6953
|
+
throw new Error(
|
|
6954
|
+
`Invalid frontmatter in ${(0, import_node_path62.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6955
|
+
);
|
|
6956
|
+
}
|
|
6957
|
+
}
|
|
6958
|
+
super({
|
|
6959
|
+
...rest
|
|
6960
|
+
});
|
|
6961
|
+
this.frontmatter = frontmatter;
|
|
6962
|
+
this.body = body;
|
|
6963
|
+
}
|
|
6964
|
+
static getSettablePaths(_options = {}) {
|
|
6965
|
+
return {
|
|
6966
|
+
relativeDirPath: (0, import_node_path62.join)(".github", "agents")
|
|
6967
|
+
};
|
|
6968
|
+
}
|
|
6969
|
+
getFrontmatter() {
|
|
6970
|
+
return this.frontmatter;
|
|
6971
|
+
}
|
|
6972
|
+
getBody() {
|
|
6973
|
+
return this.body;
|
|
6974
|
+
}
|
|
6975
|
+
toRulesyncSubagent() {
|
|
6976
|
+
const { name, description, tools, ...rest } = this.frontmatter;
|
|
6977
|
+
const rulesyncFrontmatter = {
|
|
6978
|
+
targets: ["copilot"],
|
|
6979
|
+
name,
|
|
6980
|
+
description,
|
|
6981
|
+
copilot: {
|
|
6982
|
+
...tools && { tools },
|
|
6983
|
+
...rest
|
|
6984
|
+
}
|
|
6985
|
+
};
|
|
6986
|
+
return new RulesyncSubagent({
|
|
6987
|
+
baseDir: ".",
|
|
6988
|
+
// RulesyncCommand baseDir is always the project root directory
|
|
6989
|
+
frontmatter: rulesyncFrontmatter,
|
|
6990
|
+
body: this.body,
|
|
6991
|
+
relativeDirPath: RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH,
|
|
6992
|
+
relativeFilePath: this.getRelativeFilePath(),
|
|
6993
|
+
validate: true
|
|
6994
|
+
});
|
|
6995
|
+
}
|
|
6996
|
+
static fromRulesyncSubagent({
|
|
6997
|
+
baseDir = process.cwd(),
|
|
6998
|
+
rulesyncSubagent,
|
|
6999
|
+
validate = true,
|
|
7000
|
+
global = false
|
|
7001
|
+
}) {
|
|
7002
|
+
const rulesyncFrontmatter = rulesyncSubagent.getFrontmatter();
|
|
7003
|
+
const copilotSection = rulesyncFrontmatter.copilot ?? {};
|
|
7004
|
+
const toolsField = copilotSection.tools;
|
|
7005
|
+
const userTools = normalizeTools(
|
|
7006
|
+
Array.isArray(toolsField) || typeof toolsField === "string" ? toolsField : void 0
|
|
7007
|
+
);
|
|
7008
|
+
const mergedTools = ensureRequiredTool(userTools);
|
|
7009
|
+
const copilotFrontmatter = {
|
|
7010
|
+
name: rulesyncFrontmatter.name,
|
|
7011
|
+
description: rulesyncFrontmatter.description,
|
|
7012
|
+
...copilotSection,
|
|
7013
|
+
...mergedTools.length > 0 && { tools: mergedTools }
|
|
7014
|
+
};
|
|
7015
|
+
const body = rulesyncSubagent.getBody();
|
|
7016
|
+
const fileContent = stringifyFrontmatter(body, copilotFrontmatter);
|
|
7017
|
+
const paths = this.getSettablePaths({ global });
|
|
7018
|
+
return new _CopilotSubagent({
|
|
7019
|
+
baseDir,
|
|
7020
|
+
frontmatter: copilotFrontmatter,
|
|
7021
|
+
body,
|
|
7022
|
+
relativeDirPath: paths.relativeDirPath,
|
|
7023
|
+
relativeFilePath: rulesyncSubagent.getRelativeFilePath(),
|
|
7024
|
+
fileContent,
|
|
7025
|
+
validate,
|
|
7026
|
+
global
|
|
7027
|
+
});
|
|
7028
|
+
}
|
|
7029
|
+
validate() {
|
|
7030
|
+
if (!this.frontmatter) {
|
|
7031
|
+
return { success: true, error: null };
|
|
7032
|
+
}
|
|
7033
|
+
const result = CopilotSubagentFrontmatterSchema.safeParse(this.frontmatter);
|
|
7034
|
+
if (result.success) {
|
|
7035
|
+
return { success: true, error: null };
|
|
7036
|
+
} else {
|
|
7037
|
+
return {
|
|
7038
|
+
success: false,
|
|
7039
|
+
error: new Error(
|
|
7040
|
+
`Invalid frontmatter in ${(0, import_node_path62.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6750
7041
|
)
|
|
6751
7042
|
};
|
|
6752
7043
|
}
|
|
@@ -6754,7 +7045,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6754
7045
|
static isTargetedByRulesyncSubagent(rulesyncSubagent) {
|
|
6755
7046
|
return this.isTargetedByRulesyncSubagentDefault({
|
|
6756
7047
|
rulesyncSubagent,
|
|
6757
|
-
toolTarget: "
|
|
7048
|
+
toolTarget: "copilot"
|
|
6758
7049
|
});
|
|
6759
7050
|
}
|
|
6760
7051
|
static async fromFile({
|
|
@@ -6764,21 +7055,22 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6764
7055
|
global = false
|
|
6765
7056
|
}) {
|
|
6766
7057
|
const paths = this.getSettablePaths({ global });
|
|
6767
|
-
const filePath = (0,
|
|
7058
|
+
const filePath = (0, import_node_path62.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
6768
7059
|
const fileContent = await readFileContent(filePath);
|
|
6769
7060
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
6770
|
-
const result =
|
|
7061
|
+
const result = CopilotSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6771
7062
|
if (!result.success) {
|
|
6772
7063
|
throw new Error(`Invalid frontmatter in ${filePath}: ${formatError(result.error)}`);
|
|
6773
7064
|
}
|
|
6774
|
-
return new
|
|
7065
|
+
return new _CopilotSubagent({
|
|
6775
7066
|
baseDir,
|
|
6776
7067
|
relativeDirPath: paths.relativeDirPath,
|
|
6777
7068
|
relativeFilePath,
|
|
6778
7069
|
frontmatter: result.data,
|
|
6779
7070
|
body: content.trim(),
|
|
6780
7071
|
fileContent,
|
|
6781
|
-
validate
|
|
7072
|
+
validate,
|
|
7073
|
+
global
|
|
6782
7074
|
});
|
|
6783
7075
|
}
|
|
6784
7076
|
static forDeletion({
|
|
@@ -6786,7 +7078,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6786
7078
|
relativeDirPath,
|
|
6787
7079
|
relativeFilePath
|
|
6788
7080
|
}) {
|
|
6789
|
-
return new
|
|
7081
|
+
return new _CopilotSubagent({
|
|
6790
7082
|
baseDir,
|
|
6791
7083
|
relativeDirPath,
|
|
6792
7084
|
relativeFilePath,
|
|
@@ -6798,34 +7090,23 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6798
7090
|
}
|
|
6799
7091
|
};
|
|
6800
7092
|
|
|
6801
|
-
// src/features/subagents/
|
|
6802
|
-
var
|
|
6803
|
-
var
|
|
6804
|
-
var
|
|
6805
|
-
|
|
6806
|
-
|
|
6807
|
-
|
|
6808
|
-
tools: import_mini29.z.optional(import_mini29.z.union([import_mini29.z.string(), import_mini29.z.array(import_mini29.z.string())]))
|
|
7093
|
+
// src/features/subagents/opencode-subagent.ts
|
|
7094
|
+
var import_node_path63 = require("path");
|
|
7095
|
+
var import_mini31 = require("zod/mini");
|
|
7096
|
+
var OpenCodeSubagentFrontmatterSchema = import_mini31.z.looseObject({
|
|
7097
|
+
description: import_mini31.z.string(),
|
|
7098
|
+
mode: import_mini31.z.literal("subagent"),
|
|
7099
|
+
name: import_mini31.z.optional(import_mini31.z.string())
|
|
6809
7100
|
});
|
|
6810
|
-
var
|
|
6811
|
-
if (!tools) {
|
|
6812
|
-
return [];
|
|
6813
|
-
}
|
|
6814
|
-
return Array.isArray(tools) ? tools : [tools];
|
|
6815
|
-
};
|
|
6816
|
-
var ensureRequiredTool = (tools) => {
|
|
6817
|
-
const mergedTools = /* @__PURE__ */ new Set([REQUIRED_TOOL, ...tools]);
|
|
6818
|
-
return Array.from(mergedTools);
|
|
6819
|
-
};
|
|
6820
|
-
var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
7101
|
+
var OpenCodeSubagent = class _OpenCodeSubagent extends ToolSubagent {
|
|
6821
7102
|
frontmatter;
|
|
6822
7103
|
body;
|
|
6823
7104
|
constructor({ frontmatter, body, ...rest }) {
|
|
6824
7105
|
if (rest.validate !== false) {
|
|
6825
|
-
const result =
|
|
7106
|
+
const result = OpenCodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6826
7107
|
if (!result.success) {
|
|
6827
7108
|
throw new Error(
|
|
6828
|
-
`Invalid frontmatter in ${(0,
|
|
7109
|
+
`Invalid frontmatter in ${(0, import_node_path63.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6829
7110
|
);
|
|
6830
7111
|
}
|
|
6831
7112
|
}
|
|
@@ -6835,9 +7116,11 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
6835
7116
|
this.frontmatter = frontmatter;
|
|
6836
7117
|
this.body = body;
|
|
6837
7118
|
}
|
|
6838
|
-
static getSettablePaths(
|
|
7119
|
+
static getSettablePaths({
|
|
7120
|
+
global = false
|
|
7121
|
+
} = {}) {
|
|
6839
7122
|
return {
|
|
6840
|
-
relativeDirPath: (0,
|
|
7123
|
+
relativeDirPath: global ? (0, import_node_path63.join)(".config", "opencode", "agent") : (0, import_node_path63.join)(".opencode", "agent")
|
|
6841
7124
|
};
|
|
6842
7125
|
}
|
|
6843
7126
|
getFrontmatter() {
|
|
@@ -6847,19 +7130,16 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
6847
7130
|
return this.body;
|
|
6848
7131
|
}
|
|
6849
7132
|
toRulesyncSubagent() {
|
|
6850
|
-
const {
|
|
7133
|
+
const { description, mode, name, ...opencodeSection } = this.frontmatter;
|
|
6851
7134
|
const rulesyncFrontmatter = {
|
|
6852
|
-
targets: ["
|
|
6853
|
-
name,
|
|
7135
|
+
targets: ["opencode"],
|
|
7136
|
+
name: name ?? (0, import_node_path63.basename)(this.getRelativeFilePath(), ".md"),
|
|
6854
7137
|
description,
|
|
6855
|
-
|
|
6856
|
-
...tools && { tools },
|
|
6857
|
-
...rest
|
|
6858
|
-
}
|
|
7138
|
+
opencode: { mode, ...opencodeSection }
|
|
6859
7139
|
};
|
|
6860
7140
|
return new RulesyncSubagent({
|
|
6861
7141
|
baseDir: ".",
|
|
6862
|
-
//
|
|
7142
|
+
// RulesyncSubagent baseDir is always the project root directory
|
|
6863
7143
|
frontmatter: rulesyncFrontmatter,
|
|
6864
7144
|
body: this.body,
|
|
6865
7145
|
relativeDirPath: RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH,
|
|
@@ -6874,24 +7154,19 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
6874
7154
|
global = false
|
|
6875
7155
|
}) {
|
|
6876
7156
|
const rulesyncFrontmatter = rulesyncSubagent.getFrontmatter();
|
|
6877
|
-
const
|
|
6878
|
-
const
|
|
6879
|
-
|
|
6880
|
-
Array.isArray(toolsField) || typeof toolsField === "string" ? toolsField : void 0
|
|
6881
|
-
);
|
|
6882
|
-
const mergedTools = ensureRequiredTool(userTools);
|
|
6883
|
-
const copilotFrontmatter = {
|
|
6884
|
-
name: rulesyncFrontmatter.name,
|
|
7157
|
+
const opencodeSection = rulesyncFrontmatter.opencode ?? {};
|
|
7158
|
+
const opencodeFrontmatter = {
|
|
7159
|
+
...opencodeSection,
|
|
6885
7160
|
description: rulesyncFrontmatter.description,
|
|
6886
|
-
|
|
6887
|
-
...
|
|
7161
|
+
mode: "subagent",
|
|
7162
|
+
...rulesyncFrontmatter.name && { name: rulesyncFrontmatter.name }
|
|
6888
7163
|
};
|
|
6889
7164
|
const body = rulesyncSubagent.getBody();
|
|
6890
|
-
const fileContent = stringifyFrontmatter(body,
|
|
7165
|
+
const fileContent = stringifyFrontmatter(body, opencodeFrontmatter);
|
|
6891
7166
|
const paths = this.getSettablePaths({ global });
|
|
6892
|
-
return new
|
|
7167
|
+
return new _OpenCodeSubagent({
|
|
6893
7168
|
baseDir,
|
|
6894
|
-
frontmatter:
|
|
7169
|
+
frontmatter: opencodeFrontmatter,
|
|
6895
7170
|
body,
|
|
6896
7171
|
relativeDirPath: paths.relativeDirPath,
|
|
6897
7172
|
relativeFilePath: rulesyncSubagent.getRelativeFilePath(),
|
|
@@ -6904,22 +7179,21 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
6904
7179
|
if (!this.frontmatter) {
|
|
6905
7180
|
return { success: true, error: null };
|
|
6906
7181
|
}
|
|
6907
|
-
const result =
|
|
7182
|
+
const result = OpenCodeSubagentFrontmatterSchema.safeParse(this.frontmatter);
|
|
6908
7183
|
if (result.success) {
|
|
6909
7184
|
return { success: true, error: null };
|
|
6910
|
-
} else {
|
|
6911
|
-
return {
|
|
6912
|
-
success: false,
|
|
6913
|
-
error: new Error(
|
|
6914
|
-
`Invalid frontmatter in ${(0, import_node_path62.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6915
|
-
)
|
|
6916
|
-
};
|
|
6917
7185
|
}
|
|
7186
|
+
return {
|
|
7187
|
+
success: false,
|
|
7188
|
+
error: new Error(
|
|
7189
|
+
`Invalid frontmatter in ${(0, import_node_path63.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
7190
|
+
)
|
|
7191
|
+
};
|
|
6918
7192
|
}
|
|
6919
7193
|
static isTargetedByRulesyncSubagent(rulesyncSubagent) {
|
|
6920
7194
|
return this.isTargetedByRulesyncSubagentDefault({
|
|
6921
7195
|
rulesyncSubagent,
|
|
6922
|
-
toolTarget: "
|
|
7196
|
+
toolTarget: "opencode"
|
|
6923
7197
|
});
|
|
6924
7198
|
}
|
|
6925
7199
|
static async fromFile({
|
|
@@ -6929,14 +7203,14 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
6929
7203
|
global = false
|
|
6930
7204
|
}) {
|
|
6931
7205
|
const paths = this.getSettablePaths({ global });
|
|
6932
|
-
const filePath = (0,
|
|
7206
|
+
const filePath = (0, import_node_path63.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
6933
7207
|
const fileContent = await readFileContent(filePath);
|
|
6934
7208
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
6935
|
-
const result =
|
|
7209
|
+
const result = OpenCodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6936
7210
|
if (!result.success) {
|
|
6937
7211
|
throw new Error(`Invalid frontmatter in ${filePath}: ${formatError(result.error)}`);
|
|
6938
7212
|
}
|
|
6939
|
-
return new
|
|
7213
|
+
return new _OpenCodeSubagent({
|
|
6940
7214
|
baseDir,
|
|
6941
7215
|
relativeDirPath: paths.relativeDirPath,
|
|
6942
7216
|
relativeFilePath,
|
|
@@ -6952,11 +7226,11 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
6952
7226
|
relativeDirPath,
|
|
6953
7227
|
relativeFilePath
|
|
6954
7228
|
}) {
|
|
6955
|
-
return new
|
|
7229
|
+
return new _OpenCodeSubagent({
|
|
6956
7230
|
baseDir,
|
|
6957
7231
|
relativeDirPath,
|
|
6958
7232
|
relativeFilePath,
|
|
6959
|
-
frontmatter: {
|
|
7233
|
+
frontmatter: { description: "", mode: "subagent" },
|
|
6960
7234
|
body: "",
|
|
6961
7235
|
fileContent: "",
|
|
6962
7236
|
validate: false
|
|
@@ -6972,9 +7246,10 @@ var subagentsProcessorToolTargetTuple = [
|
|
|
6972
7246
|
"copilot",
|
|
6973
7247
|
"cursor",
|
|
6974
7248
|
"geminicli",
|
|
7249
|
+
"opencode",
|
|
6975
7250
|
"roo"
|
|
6976
7251
|
];
|
|
6977
|
-
var SubagentsProcessorToolTargetSchema =
|
|
7252
|
+
var SubagentsProcessorToolTargetSchema = import_mini32.z.enum(subagentsProcessorToolTargetTuple);
|
|
6978
7253
|
var toolSubagentFactories = /* @__PURE__ */ new Map([
|
|
6979
7254
|
[
|
|
6980
7255
|
"agentsmd",
|
|
@@ -6997,6 +7272,10 @@ var toolSubagentFactories = /* @__PURE__ */ new Map([
|
|
|
6997
7272
|
"geminicli",
|
|
6998
7273
|
{ class: GeminiCliSubagent, meta: { supportsSimulated: true, supportsGlobal: false } }
|
|
6999
7274
|
],
|
|
7275
|
+
[
|
|
7276
|
+
"opencode",
|
|
7277
|
+
{ class: OpenCodeSubagent, meta: { supportsSimulated: false, supportsGlobal: true } }
|
|
7278
|
+
],
|
|
7000
7279
|
["roo", { class: RooSubagent, meta: { supportsSimulated: true, supportsGlobal: false } }]
|
|
7001
7280
|
]);
|
|
7002
7281
|
var defaultGetFactory5 = (target) => {
|
|
@@ -7080,7 +7359,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7080
7359
|
* Load and parse rulesync subagent files from .rulesync/subagents/ directory
|
|
7081
7360
|
*/
|
|
7082
7361
|
async loadRulesyncFiles() {
|
|
7083
|
-
const subagentsDir = (0,
|
|
7362
|
+
const subagentsDir = (0, import_node_path64.join)(this.baseDir, RulesyncSubagent.getSettablePaths().relativeDirPath);
|
|
7084
7363
|
const dirExists = await directoryExists(subagentsDir);
|
|
7085
7364
|
if (!dirExists) {
|
|
7086
7365
|
logger.debug(`Rulesync subagents directory not found: ${subagentsDir}`);
|
|
@@ -7095,7 +7374,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7095
7374
|
logger.info(`Found ${mdFiles.length} subagent files in ${subagentsDir}`);
|
|
7096
7375
|
const rulesyncSubagents = [];
|
|
7097
7376
|
for (const mdFile of mdFiles) {
|
|
7098
|
-
const filepath = (0,
|
|
7377
|
+
const filepath = (0, import_node_path64.join)(subagentsDir, mdFile);
|
|
7099
7378
|
try {
|
|
7100
7379
|
const rulesyncSubagent = await RulesyncSubagent.fromFile({
|
|
7101
7380
|
relativeFilePath: mdFile,
|
|
@@ -7125,14 +7404,14 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7125
7404
|
const factory = this.getFactory(this.toolTarget);
|
|
7126
7405
|
const paths = factory.class.getSettablePaths({ global: this.global });
|
|
7127
7406
|
const subagentFilePaths = await findFilesByGlobs(
|
|
7128
|
-
(0,
|
|
7407
|
+
(0, import_node_path64.join)(this.baseDir, paths.relativeDirPath, "*.md")
|
|
7129
7408
|
);
|
|
7130
7409
|
if (forDeletion) {
|
|
7131
7410
|
const toolSubagents2 = subagentFilePaths.map(
|
|
7132
7411
|
(path3) => factory.class.forDeletion({
|
|
7133
7412
|
baseDir: this.baseDir,
|
|
7134
7413
|
relativeDirPath: paths.relativeDirPath,
|
|
7135
|
-
relativeFilePath: (0,
|
|
7414
|
+
relativeFilePath: (0, import_node_path64.basename)(path3),
|
|
7136
7415
|
global: this.global
|
|
7137
7416
|
})
|
|
7138
7417
|
).filter((subagent) => subagent.isDeletable());
|
|
@@ -7143,7 +7422,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7143
7422
|
subagentFilePaths.map(
|
|
7144
7423
|
(path3) => factory.class.fromFile({
|
|
7145
7424
|
baseDir: this.baseDir,
|
|
7146
|
-
relativeFilePath: (0,
|
|
7425
|
+
relativeFilePath: (0, import_node_path64.basename)(path3),
|
|
7147
7426
|
global: this.global
|
|
7148
7427
|
})
|
|
7149
7428
|
)
|
|
@@ -7175,48 +7454,48 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7175
7454
|
};
|
|
7176
7455
|
|
|
7177
7456
|
// src/features/rules/agentsmd-rule.ts
|
|
7178
|
-
var
|
|
7457
|
+
var import_node_path67 = require("path");
|
|
7179
7458
|
|
|
7180
7459
|
// src/features/rules/tool-rule.ts
|
|
7181
|
-
var
|
|
7460
|
+
var import_node_path66 = require("path");
|
|
7182
7461
|
|
|
7183
7462
|
// src/features/rules/rulesync-rule.ts
|
|
7184
|
-
var
|
|
7185
|
-
var
|
|
7186
|
-
var RulesyncRuleFrontmatterSchema =
|
|
7187
|
-
root:
|
|
7188
|
-
targets:
|
|
7189
|
-
description:
|
|
7190
|
-
globs:
|
|
7191
|
-
agentsmd:
|
|
7192
|
-
|
|
7463
|
+
var import_node_path65 = require("path");
|
|
7464
|
+
var import_mini33 = require("zod/mini");
|
|
7465
|
+
var RulesyncRuleFrontmatterSchema = import_mini33.z.object({
|
|
7466
|
+
root: import_mini33.z.optional(import_mini33.z.optional(import_mini33.z.boolean())),
|
|
7467
|
+
targets: import_mini33.z.optional(RulesyncTargetsSchema),
|
|
7468
|
+
description: import_mini33.z.optional(import_mini33.z.string()),
|
|
7469
|
+
globs: import_mini33.z.optional(import_mini33.z.array(import_mini33.z.string())),
|
|
7470
|
+
agentsmd: import_mini33.z.optional(
|
|
7471
|
+
import_mini33.z.object({
|
|
7193
7472
|
// @example "path/to/subproject"
|
|
7194
|
-
subprojectPath:
|
|
7473
|
+
subprojectPath: import_mini33.z.optional(import_mini33.z.string())
|
|
7195
7474
|
})
|
|
7196
7475
|
),
|
|
7197
|
-
claudecode:
|
|
7198
|
-
|
|
7476
|
+
claudecode: import_mini33.z.optional(
|
|
7477
|
+
import_mini33.z.object({
|
|
7199
7478
|
// Glob patterns for conditional rules (takes precedence over globs)
|
|
7200
7479
|
// @example "src/**/*.ts, tests/**/*.test.ts"
|
|
7201
|
-
paths:
|
|
7480
|
+
paths: import_mini33.z.optional(import_mini33.z.string())
|
|
7202
7481
|
})
|
|
7203
7482
|
),
|
|
7204
|
-
cursor:
|
|
7205
|
-
|
|
7206
|
-
alwaysApply:
|
|
7207
|
-
description:
|
|
7208
|
-
globs:
|
|
7483
|
+
cursor: import_mini33.z.optional(
|
|
7484
|
+
import_mini33.z.object({
|
|
7485
|
+
alwaysApply: import_mini33.z.optional(import_mini33.z.boolean()),
|
|
7486
|
+
description: import_mini33.z.optional(import_mini33.z.string()),
|
|
7487
|
+
globs: import_mini33.z.optional(import_mini33.z.array(import_mini33.z.string()))
|
|
7209
7488
|
})
|
|
7210
7489
|
),
|
|
7211
|
-
copilot:
|
|
7212
|
-
|
|
7213
|
-
excludeAgent:
|
|
7490
|
+
copilot: import_mini33.z.optional(
|
|
7491
|
+
import_mini33.z.object({
|
|
7492
|
+
excludeAgent: import_mini33.z.optional(import_mini33.z.union([import_mini33.z.literal("code-review"), import_mini33.z.literal("coding-agent")]))
|
|
7214
7493
|
})
|
|
7215
7494
|
),
|
|
7216
|
-
antigravity:
|
|
7217
|
-
|
|
7218
|
-
trigger:
|
|
7219
|
-
globs:
|
|
7495
|
+
antigravity: import_mini33.z.optional(
|
|
7496
|
+
import_mini33.z.looseObject({
|
|
7497
|
+
trigger: import_mini33.z.optional(import_mini33.z.string()),
|
|
7498
|
+
globs: import_mini33.z.optional(import_mini33.z.array(import_mini33.z.string()))
|
|
7220
7499
|
})
|
|
7221
7500
|
)
|
|
7222
7501
|
});
|
|
@@ -7228,7 +7507,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7228
7507
|
const result = RulesyncRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7229
7508
|
if (!result.success) {
|
|
7230
7509
|
throw new Error(
|
|
7231
|
-
`Invalid frontmatter in ${(0,
|
|
7510
|
+
`Invalid frontmatter in ${(0, import_node_path65.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
7232
7511
|
);
|
|
7233
7512
|
}
|
|
7234
7513
|
}
|
|
@@ -7263,7 +7542,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7263
7542
|
return {
|
|
7264
7543
|
success: false,
|
|
7265
7544
|
error: new Error(
|
|
7266
|
-
`Invalid frontmatter in ${(0,
|
|
7545
|
+
`Invalid frontmatter in ${(0, import_node_path65.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
7267
7546
|
)
|
|
7268
7547
|
};
|
|
7269
7548
|
}
|
|
@@ -7272,12 +7551,12 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7272
7551
|
relativeFilePath,
|
|
7273
7552
|
validate = true
|
|
7274
7553
|
}) {
|
|
7275
|
-
const legacyPath = (0,
|
|
7554
|
+
const legacyPath = (0, import_node_path65.join)(
|
|
7276
7555
|
process.cwd(),
|
|
7277
7556
|
this.getSettablePaths().legacy.relativeDirPath,
|
|
7278
7557
|
relativeFilePath
|
|
7279
7558
|
);
|
|
7280
|
-
const recommendedPath = (0,
|
|
7559
|
+
const recommendedPath = (0, import_node_path65.join)(
|
|
7281
7560
|
this.getSettablePaths().recommended.relativeDirPath,
|
|
7282
7561
|
relativeFilePath
|
|
7283
7562
|
);
|
|
@@ -7296,7 +7575,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7296
7575
|
agentsmd: result.data.agentsmd,
|
|
7297
7576
|
cursor: result.data.cursor
|
|
7298
7577
|
};
|
|
7299
|
-
const filename = (0,
|
|
7578
|
+
const filename = (0, import_node_path65.basename)(legacyPath);
|
|
7300
7579
|
return new _RulesyncRule({
|
|
7301
7580
|
baseDir: process.cwd(),
|
|
7302
7581
|
relativeDirPath: this.getSettablePaths().recommended.relativeDirPath,
|
|
@@ -7310,7 +7589,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7310
7589
|
relativeFilePath,
|
|
7311
7590
|
validate = true
|
|
7312
7591
|
}) {
|
|
7313
|
-
const filePath = (0,
|
|
7592
|
+
const filePath = (0, import_node_path65.join)(
|
|
7314
7593
|
process.cwd(),
|
|
7315
7594
|
this.getSettablePaths().recommended.relativeDirPath,
|
|
7316
7595
|
relativeFilePath
|
|
@@ -7329,7 +7608,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7329
7608
|
agentsmd: result.data.agentsmd,
|
|
7330
7609
|
cursor: result.data.cursor
|
|
7331
7610
|
};
|
|
7332
|
-
const filename = (0,
|
|
7611
|
+
const filename = (0, import_node_path65.basename)(filePath);
|
|
7333
7612
|
return new _RulesyncRule({
|
|
7334
7613
|
baseDir: process.cwd(),
|
|
7335
7614
|
relativeDirPath: this.getSettablePaths().recommended.relativeDirPath,
|
|
@@ -7412,7 +7691,7 @@ var ToolRule = class extends ToolFile {
|
|
|
7412
7691
|
rulesyncRule,
|
|
7413
7692
|
validate = true,
|
|
7414
7693
|
rootPath = { relativeDirPath: ".", relativeFilePath: "AGENTS.md" },
|
|
7415
|
-
nonRootPath = { relativeDirPath: (0,
|
|
7694
|
+
nonRootPath = { relativeDirPath: (0, import_node_path66.join)(".agents", "memories") }
|
|
7416
7695
|
}) {
|
|
7417
7696
|
const params = this.buildToolRuleParamsDefault({
|
|
7418
7697
|
baseDir,
|
|
@@ -7423,7 +7702,7 @@ var ToolRule = class extends ToolFile {
|
|
|
7423
7702
|
});
|
|
7424
7703
|
const rulesyncFrontmatter = rulesyncRule.getFrontmatter();
|
|
7425
7704
|
if (!rulesyncFrontmatter.root && rulesyncFrontmatter.agentsmd?.subprojectPath) {
|
|
7426
|
-
params.relativeDirPath = (0,
|
|
7705
|
+
params.relativeDirPath = (0, import_node_path66.join)(rulesyncFrontmatter.agentsmd.subprojectPath);
|
|
7427
7706
|
params.relativeFilePath = "AGENTS.md";
|
|
7428
7707
|
}
|
|
7429
7708
|
return params;
|
|
@@ -7488,7 +7767,7 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
7488
7767
|
relativeFilePath: "AGENTS.md"
|
|
7489
7768
|
},
|
|
7490
7769
|
nonRoot: {
|
|
7491
|
-
relativeDirPath: (0,
|
|
7770
|
+
relativeDirPath: (0, import_node_path67.join)(".agents", "memories")
|
|
7492
7771
|
}
|
|
7493
7772
|
};
|
|
7494
7773
|
}
|
|
@@ -7498,8 +7777,8 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
7498
7777
|
validate = true
|
|
7499
7778
|
}) {
|
|
7500
7779
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
7501
|
-
const relativePath = isRoot ? "AGENTS.md" : (0,
|
|
7502
|
-
const fileContent = await readFileContent((0,
|
|
7780
|
+
const relativePath = isRoot ? "AGENTS.md" : (0, import_node_path67.join)(".agents", "memories", relativeFilePath);
|
|
7781
|
+
const fileContent = await readFileContent((0, import_node_path67.join)(baseDir, relativePath));
|
|
7503
7782
|
return new _AgentsMdRule({
|
|
7504
7783
|
baseDir,
|
|
7505
7784
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -7554,12 +7833,12 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
7554
7833
|
};
|
|
7555
7834
|
|
|
7556
7835
|
// src/features/rules/amazonqcli-rule.ts
|
|
7557
|
-
var
|
|
7836
|
+
var import_node_path68 = require("path");
|
|
7558
7837
|
var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
7559
7838
|
static getSettablePaths() {
|
|
7560
7839
|
return {
|
|
7561
7840
|
nonRoot: {
|
|
7562
|
-
relativeDirPath: (0,
|
|
7841
|
+
relativeDirPath: (0, import_node_path68.join)(".amazonq", "rules")
|
|
7563
7842
|
}
|
|
7564
7843
|
};
|
|
7565
7844
|
}
|
|
@@ -7569,7 +7848,7 @@ var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
|
7569
7848
|
validate = true
|
|
7570
7849
|
}) {
|
|
7571
7850
|
const fileContent = await readFileContent(
|
|
7572
|
-
(0,
|
|
7851
|
+
(0, import_node_path68.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7573
7852
|
);
|
|
7574
7853
|
return new _AmazonQCliRule({
|
|
7575
7854
|
baseDir,
|
|
@@ -7623,21 +7902,21 @@ var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
|
7623
7902
|
};
|
|
7624
7903
|
|
|
7625
7904
|
// src/features/rules/antigravity-rule.ts
|
|
7626
|
-
var
|
|
7627
|
-
var
|
|
7628
|
-
var AntigravityRuleFrontmatterSchema =
|
|
7629
|
-
trigger:
|
|
7630
|
-
|
|
7631
|
-
|
|
7632
|
-
|
|
7633
|
-
|
|
7634
|
-
|
|
7635
|
-
|
|
7905
|
+
var import_node_path69 = require("path");
|
|
7906
|
+
var import_mini34 = require("zod/mini");
|
|
7907
|
+
var AntigravityRuleFrontmatterSchema = import_mini34.z.looseObject({
|
|
7908
|
+
trigger: import_mini34.z.optional(
|
|
7909
|
+
import_mini34.z.union([
|
|
7910
|
+
import_mini34.z.literal("always_on"),
|
|
7911
|
+
import_mini34.z.literal("glob"),
|
|
7912
|
+
import_mini34.z.literal("manual"),
|
|
7913
|
+
import_mini34.z.literal("model_decision"),
|
|
7914
|
+
import_mini34.z.string()
|
|
7636
7915
|
// accepts any string for forward compatibility
|
|
7637
7916
|
])
|
|
7638
7917
|
),
|
|
7639
|
-
globs:
|
|
7640
|
-
description:
|
|
7918
|
+
globs: import_mini34.z.optional(import_mini34.z.string()),
|
|
7919
|
+
description: import_mini34.z.optional(import_mini34.z.string())
|
|
7641
7920
|
});
|
|
7642
7921
|
function parseGlobsString(globs) {
|
|
7643
7922
|
if (!globs) {
|
|
@@ -7782,7 +8061,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7782
8061
|
const result = AntigravityRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7783
8062
|
if (!result.success) {
|
|
7784
8063
|
throw new Error(
|
|
7785
|
-
`Invalid frontmatter in ${(0,
|
|
8064
|
+
`Invalid frontmatter in ${(0, import_node_path69.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
7786
8065
|
);
|
|
7787
8066
|
}
|
|
7788
8067
|
}
|
|
@@ -7797,7 +8076,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7797
8076
|
static getSettablePaths() {
|
|
7798
8077
|
return {
|
|
7799
8078
|
nonRoot: {
|
|
7800
|
-
relativeDirPath: (0,
|
|
8079
|
+
relativeDirPath: (0, import_node_path69.join)(".agent", "rules")
|
|
7801
8080
|
}
|
|
7802
8081
|
};
|
|
7803
8082
|
}
|
|
@@ -7806,7 +8085,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7806
8085
|
relativeFilePath,
|
|
7807
8086
|
validate = true
|
|
7808
8087
|
}) {
|
|
7809
|
-
const filePath = (0,
|
|
8088
|
+
const filePath = (0, import_node_path69.join)(
|
|
7810
8089
|
baseDir,
|
|
7811
8090
|
this.getSettablePaths().nonRoot.relativeDirPath,
|
|
7812
8091
|
relativeFilePath
|
|
@@ -7947,7 +8226,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7947
8226
|
};
|
|
7948
8227
|
|
|
7949
8228
|
// src/features/rules/augmentcode-legacy-rule.ts
|
|
7950
|
-
var
|
|
8229
|
+
var import_node_path70 = require("path");
|
|
7951
8230
|
var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
7952
8231
|
toRulesyncRule() {
|
|
7953
8232
|
const rulesyncFrontmatter = {
|
|
@@ -7973,7 +8252,7 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
7973
8252
|
relativeFilePath: ".augment-guidelines"
|
|
7974
8253
|
},
|
|
7975
8254
|
nonRoot: {
|
|
7976
|
-
relativeDirPath: (0,
|
|
8255
|
+
relativeDirPath: (0, import_node_path70.join)(".augment", "rules")
|
|
7977
8256
|
}
|
|
7978
8257
|
};
|
|
7979
8258
|
}
|
|
@@ -8008,8 +8287,8 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
8008
8287
|
}) {
|
|
8009
8288
|
const settablePaths = this.getSettablePaths();
|
|
8010
8289
|
const isRoot = relativeFilePath === settablePaths.root.relativeFilePath;
|
|
8011
|
-
const relativePath = isRoot ? settablePaths.root.relativeFilePath : (0,
|
|
8012
|
-
const fileContent = await readFileContent((0,
|
|
8290
|
+
const relativePath = isRoot ? settablePaths.root.relativeFilePath : (0, import_node_path70.join)(settablePaths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8291
|
+
const fileContent = await readFileContent((0, import_node_path70.join)(baseDir, relativePath));
|
|
8013
8292
|
return new _AugmentcodeLegacyRule({
|
|
8014
8293
|
baseDir,
|
|
8015
8294
|
relativeDirPath: isRoot ? settablePaths.root.relativeDirPath : settablePaths.nonRoot.relativeDirPath,
|
|
@@ -8038,7 +8317,7 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
8038
8317
|
};
|
|
8039
8318
|
|
|
8040
8319
|
// src/features/rules/augmentcode-rule.ts
|
|
8041
|
-
var
|
|
8320
|
+
var import_node_path71 = require("path");
|
|
8042
8321
|
var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
8043
8322
|
toRulesyncRule() {
|
|
8044
8323
|
return this.toRulesyncRuleDefault();
|
|
@@ -8046,7 +8325,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
8046
8325
|
static getSettablePaths() {
|
|
8047
8326
|
return {
|
|
8048
8327
|
nonRoot: {
|
|
8049
|
-
relativeDirPath: (0,
|
|
8328
|
+
relativeDirPath: (0, import_node_path71.join)(".augment", "rules")
|
|
8050
8329
|
}
|
|
8051
8330
|
};
|
|
8052
8331
|
}
|
|
@@ -8070,7 +8349,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
8070
8349
|
validate = true
|
|
8071
8350
|
}) {
|
|
8072
8351
|
const fileContent = await readFileContent(
|
|
8073
|
-
(0,
|
|
8352
|
+
(0, import_node_path71.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
8074
8353
|
);
|
|
8075
8354
|
const { body: content } = parseFrontmatter(fileContent);
|
|
8076
8355
|
return new _AugmentcodeRule({
|
|
@@ -8106,7 +8385,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
8106
8385
|
};
|
|
8107
8386
|
|
|
8108
8387
|
// src/features/rules/claudecode-legacy-rule.ts
|
|
8109
|
-
var
|
|
8388
|
+
var import_node_path72 = require("path");
|
|
8110
8389
|
var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
8111
8390
|
static getSettablePaths({
|
|
8112
8391
|
global
|
|
@@ -8125,7 +8404,7 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
8125
8404
|
relativeFilePath: "CLAUDE.md"
|
|
8126
8405
|
},
|
|
8127
8406
|
nonRoot: {
|
|
8128
|
-
relativeDirPath: (0,
|
|
8407
|
+
relativeDirPath: (0, import_node_path72.join)(".claude", "memories")
|
|
8129
8408
|
}
|
|
8130
8409
|
};
|
|
8131
8410
|
}
|
|
@@ -8140,7 +8419,7 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
8140
8419
|
if (isRoot) {
|
|
8141
8420
|
const relativePath2 = paths.root.relativeFilePath;
|
|
8142
8421
|
const fileContent2 = await readFileContent(
|
|
8143
|
-
(0,
|
|
8422
|
+
(0, import_node_path72.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
8144
8423
|
);
|
|
8145
8424
|
return new _ClaudecodeLegacyRule({
|
|
8146
8425
|
baseDir,
|
|
@@ -8154,8 +8433,8 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
8154
8433
|
if (!paths.nonRoot) {
|
|
8155
8434
|
throw new Error("nonRoot path is not set");
|
|
8156
8435
|
}
|
|
8157
|
-
const relativePath = (0,
|
|
8158
|
-
const fileContent = await readFileContent((0,
|
|
8436
|
+
const relativePath = (0, import_node_path72.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8437
|
+
const fileContent = await readFileContent((0, import_node_path72.join)(baseDir, relativePath));
|
|
8159
8438
|
return new _ClaudecodeLegacyRule({
|
|
8160
8439
|
baseDir,
|
|
8161
8440
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -8214,10 +8493,10 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
8214
8493
|
};
|
|
8215
8494
|
|
|
8216
8495
|
// src/features/rules/claudecode-rule.ts
|
|
8217
|
-
var
|
|
8218
|
-
var
|
|
8219
|
-
var ClaudecodeRuleFrontmatterSchema =
|
|
8220
|
-
paths:
|
|
8496
|
+
var import_node_path73 = require("path");
|
|
8497
|
+
var import_mini35 = require("zod/mini");
|
|
8498
|
+
var ClaudecodeRuleFrontmatterSchema = import_mini35.z.object({
|
|
8499
|
+
paths: import_mini35.z.optional(import_mini35.z.string())
|
|
8221
8500
|
});
|
|
8222
8501
|
var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
8223
8502
|
frontmatter;
|
|
@@ -8239,7 +8518,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8239
8518
|
relativeFilePath: "CLAUDE.md"
|
|
8240
8519
|
},
|
|
8241
8520
|
nonRoot: {
|
|
8242
|
-
relativeDirPath: (0,
|
|
8521
|
+
relativeDirPath: (0, import_node_path73.join)(".claude", "rules")
|
|
8243
8522
|
}
|
|
8244
8523
|
};
|
|
8245
8524
|
}
|
|
@@ -8248,7 +8527,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8248
8527
|
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8249
8528
|
if (!result.success) {
|
|
8250
8529
|
throw new Error(
|
|
8251
|
-
`Invalid frontmatter in ${(0,
|
|
8530
|
+
`Invalid frontmatter in ${(0, import_node_path73.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
8252
8531
|
);
|
|
8253
8532
|
}
|
|
8254
8533
|
}
|
|
@@ -8276,7 +8555,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8276
8555
|
const isRoot = relativeFilePath === paths.root.relativeFilePath;
|
|
8277
8556
|
if (isRoot) {
|
|
8278
8557
|
const fileContent2 = await readFileContent(
|
|
8279
|
-
(0,
|
|
8558
|
+
(0, import_node_path73.join)(baseDir, paths.root.relativeDirPath, paths.root.relativeFilePath)
|
|
8280
8559
|
);
|
|
8281
8560
|
return new _ClaudecodeRule({
|
|
8282
8561
|
baseDir,
|
|
@@ -8291,13 +8570,13 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8291
8570
|
if (!paths.nonRoot) {
|
|
8292
8571
|
throw new Error("nonRoot path is not set");
|
|
8293
8572
|
}
|
|
8294
|
-
const relativePath = (0,
|
|
8295
|
-
const fileContent = await readFileContent((0,
|
|
8573
|
+
const relativePath = (0, import_node_path73.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8574
|
+
const fileContent = await readFileContent((0, import_node_path73.join)(baseDir, relativePath));
|
|
8296
8575
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
8297
8576
|
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8298
8577
|
if (!result.success) {
|
|
8299
8578
|
throw new Error(
|
|
8300
|
-
`Invalid frontmatter in ${(0,
|
|
8579
|
+
`Invalid frontmatter in ${(0, import_node_path73.join)(baseDir, relativePath)}: ${formatError(result.error)}`
|
|
8301
8580
|
);
|
|
8302
8581
|
}
|
|
8303
8582
|
return new _ClaudecodeRule({
|
|
@@ -8404,7 +8683,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8404
8683
|
return {
|
|
8405
8684
|
success: false,
|
|
8406
8685
|
error: new Error(
|
|
8407
|
-
`Invalid frontmatter in ${(0,
|
|
8686
|
+
`Invalid frontmatter in ${(0, import_node_path73.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
8408
8687
|
)
|
|
8409
8688
|
};
|
|
8410
8689
|
}
|
|
@@ -8424,10 +8703,10 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8424
8703
|
};
|
|
8425
8704
|
|
|
8426
8705
|
// src/features/rules/cline-rule.ts
|
|
8427
|
-
var
|
|
8428
|
-
var
|
|
8429
|
-
var ClineRuleFrontmatterSchema =
|
|
8430
|
-
description:
|
|
8706
|
+
var import_node_path74 = require("path");
|
|
8707
|
+
var import_mini36 = require("zod/mini");
|
|
8708
|
+
var ClineRuleFrontmatterSchema = import_mini36.z.object({
|
|
8709
|
+
description: import_mini36.z.string()
|
|
8431
8710
|
});
|
|
8432
8711
|
var ClineRule = class _ClineRule extends ToolRule {
|
|
8433
8712
|
static getSettablePaths() {
|
|
@@ -8469,7 +8748,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
8469
8748
|
validate = true
|
|
8470
8749
|
}) {
|
|
8471
8750
|
const fileContent = await readFileContent(
|
|
8472
|
-
(0,
|
|
8751
|
+
(0, import_node_path74.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
8473
8752
|
);
|
|
8474
8753
|
return new _ClineRule({
|
|
8475
8754
|
baseDir,
|
|
@@ -8495,7 +8774,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
8495
8774
|
};
|
|
8496
8775
|
|
|
8497
8776
|
// src/features/rules/codexcli-rule.ts
|
|
8498
|
-
var
|
|
8777
|
+
var import_node_path75 = require("path");
|
|
8499
8778
|
var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
8500
8779
|
static getSettablePaths({
|
|
8501
8780
|
global
|
|
@@ -8514,7 +8793,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8514
8793
|
relativeFilePath: "AGENTS.md"
|
|
8515
8794
|
},
|
|
8516
8795
|
nonRoot: {
|
|
8517
|
-
relativeDirPath: (0,
|
|
8796
|
+
relativeDirPath: (0, import_node_path75.join)(".codex", "memories")
|
|
8518
8797
|
}
|
|
8519
8798
|
};
|
|
8520
8799
|
}
|
|
@@ -8529,7 +8808,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8529
8808
|
if (isRoot) {
|
|
8530
8809
|
const relativePath2 = paths.root.relativeFilePath;
|
|
8531
8810
|
const fileContent2 = await readFileContent(
|
|
8532
|
-
(0,
|
|
8811
|
+
(0, import_node_path75.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
8533
8812
|
);
|
|
8534
8813
|
return new _CodexcliRule({
|
|
8535
8814
|
baseDir,
|
|
@@ -8543,8 +8822,8 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8543
8822
|
if (!paths.nonRoot) {
|
|
8544
8823
|
throw new Error("nonRoot path is not set");
|
|
8545
8824
|
}
|
|
8546
|
-
const relativePath = (0,
|
|
8547
|
-
const fileContent = await readFileContent((0,
|
|
8825
|
+
const relativePath = (0, import_node_path75.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8826
|
+
const fileContent = await readFileContent((0, import_node_path75.join)(baseDir, relativePath));
|
|
8548
8827
|
return new _CodexcliRule({
|
|
8549
8828
|
baseDir,
|
|
8550
8829
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -8603,12 +8882,12 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8603
8882
|
};
|
|
8604
8883
|
|
|
8605
8884
|
// src/features/rules/copilot-rule.ts
|
|
8606
|
-
var
|
|
8607
|
-
var
|
|
8608
|
-
var CopilotRuleFrontmatterSchema =
|
|
8609
|
-
description:
|
|
8610
|
-
applyTo:
|
|
8611
|
-
excludeAgent:
|
|
8885
|
+
var import_node_path76 = require("path");
|
|
8886
|
+
var import_mini37 = require("zod/mini");
|
|
8887
|
+
var CopilotRuleFrontmatterSchema = import_mini37.z.object({
|
|
8888
|
+
description: import_mini37.z.optional(import_mini37.z.string()),
|
|
8889
|
+
applyTo: import_mini37.z.optional(import_mini37.z.string()),
|
|
8890
|
+
excludeAgent: import_mini37.z.optional(import_mini37.z.union([import_mini37.z.literal("code-review"), import_mini37.z.literal("coding-agent")]))
|
|
8612
8891
|
});
|
|
8613
8892
|
var CopilotRule = class _CopilotRule extends ToolRule {
|
|
8614
8893
|
frontmatter;
|
|
@@ -8620,7 +8899,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8620
8899
|
relativeFilePath: "copilot-instructions.md"
|
|
8621
8900
|
},
|
|
8622
8901
|
nonRoot: {
|
|
8623
|
-
relativeDirPath: (0,
|
|
8902
|
+
relativeDirPath: (0, import_node_path76.join)(".github", "instructions")
|
|
8624
8903
|
}
|
|
8625
8904
|
};
|
|
8626
8905
|
}
|
|
@@ -8629,7 +8908,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8629
8908
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8630
8909
|
if (!result.success) {
|
|
8631
8910
|
throw new Error(
|
|
8632
|
-
`Invalid frontmatter in ${(0,
|
|
8911
|
+
`Invalid frontmatter in ${(0, import_node_path76.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
8633
8912
|
);
|
|
8634
8913
|
}
|
|
8635
8914
|
}
|
|
@@ -8711,11 +8990,11 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8711
8990
|
validate = true
|
|
8712
8991
|
}) {
|
|
8713
8992
|
const isRoot = relativeFilePath === "copilot-instructions.md";
|
|
8714
|
-
const relativePath = isRoot ? (0,
|
|
8993
|
+
const relativePath = isRoot ? (0, import_node_path76.join)(
|
|
8715
8994
|
this.getSettablePaths().root.relativeDirPath,
|
|
8716
8995
|
this.getSettablePaths().root.relativeFilePath
|
|
8717
|
-
) : (0,
|
|
8718
|
-
const fileContent = await readFileContent((0,
|
|
8996
|
+
) : (0, import_node_path76.join)(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
8997
|
+
const fileContent = await readFileContent((0, import_node_path76.join)(baseDir, relativePath));
|
|
8719
8998
|
if (isRoot) {
|
|
8720
8999
|
return new _CopilotRule({
|
|
8721
9000
|
baseDir,
|
|
@@ -8731,7 +9010,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8731
9010
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8732
9011
|
if (!result.success) {
|
|
8733
9012
|
throw new Error(
|
|
8734
|
-
`Invalid frontmatter in ${(0,
|
|
9013
|
+
`Invalid frontmatter in ${(0, import_node_path76.join)(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
8735
9014
|
);
|
|
8736
9015
|
}
|
|
8737
9016
|
return new _CopilotRule({
|
|
@@ -8771,7 +9050,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8771
9050
|
return {
|
|
8772
9051
|
success: false,
|
|
8773
9052
|
error: new Error(
|
|
8774
|
-
`Invalid frontmatter in ${(0,
|
|
9053
|
+
`Invalid frontmatter in ${(0, import_node_path76.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
8775
9054
|
)
|
|
8776
9055
|
};
|
|
8777
9056
|
}
|
|
@@ -8791,12 +9070,12 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8791
9070
|
};
|
|
8792
9071
|
|
|
8793
9072
|
// src/features/rules/cursor-rule.ts
|
|
8794
|
-
var
|
|
8795
|
-
var
|
|
8796
|
-
var CursorRuleFrontmatterSchema =
|
|
8797
|
-
description:
|
|
8798
|
-
globs:
|
|
8799
|
-
alwaysApply:
|
|
9073
|
+
var import_node_path77 = require("path");
|
|
9074
|
+
var import_mini38 = require("zod/mini");
|
|
9075
|
+
var CursorRuleFrontmatterSchema = import_mini38.z.object({
|
|
9076
|
+
description: import_mini38.z.optional(import_mini38.z.string()),
|
|
9077
|
+
globs: import_mini38.z.optional(import_mini38.z.string()),
|
|
9078
|
+
alwaysApply: import_mini38.z.optional(import_mini38.z.boolean())
|
|
8800
9079
|
});
|
|
8801
9080
|
var CursorRule = class _CursorRule extends ToolRule {
|
|
8802
9081
|
frontmatter;
|
|
@@ -8804,7 +9083,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8804
9083
|
static getSettablePaths() {
|
|
8805
9084
|
return {
|
|
8806
9085
|
nonRoot: {
|
|
8807
|
-
relativeDirPath: (0,
|
|
9086
|
+
relativeDirPath: (0, import_node_path77.join)(".cursor", "rules")
|
|
8808
9087
|
}
|
|
8809
9088
|
};
|
|
8810
9089
|
}
|
|
@@ -8813,7 +9092,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8813
9092
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8814
9093
|
if (!result.success) {
|
|
8815
9094
|
throw new Error(
|
|
8816
|
-
`Invalid frontmatter in ${(0,
|
|
9095
|
+
`Invalid frontmatter in ${(0, import_node_path77.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
8817
9096
|
);
|
|
8818
9097
|
}
|
|
8819
9098
|
}
|
|
@@ -8930,19 +9209,19 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8930
9209
|
validate = true
|
|
8931
9210
|
}) {
|
|
8932
9211
|
const fileContent = await readFileContent(
|
|
8933
|
-
(0,
|
|
9212
|
+
(0, import_node_path77.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
8934
9213
|
);
|
|
8935
9214
|
const { frontmatter, body: content } = _CursorRule.parseCursorFrontmatter(fileContent);
|
|
8936
9215
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8937
9216
|
if (!result.success) {
|
|
8938
9217
|
throw new Error(
|
|
8939
|
-
`Invalid frontmatter in ${(0,
|
|
9218
|
+
`Invalid frontmatter in ${(0, import_node_path77.join)(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
8940
9219
|
);
|
|
8941
9220
|
}
|
|
8942
9221
|
return new _CursorRule({
|
|
8943
9222
|
baseDir,
|
|
8944
9223
|
relativeDirPath: this.getSettablePaths().nonRoot.relativeDirPath,
|
|
8945
|
-
relativeFilePath: (0,
|
|
9224
|
+
relativeFilePath: (0, import_node_path77.basename)(relativeFilePath),
|
|
8946
9225
|
frontmatter: result.data,
|
|
8947
9226
|
body: content.trim(),
|
|
8948
9227
|
validate
|
|
@@ -8973,7 +9252,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8973
9252
|
return {
|
|
8974
9253
|
success: false,
|
|
8975
9254
|
error: new Error(
|
|
8976
|
-
`Invalid frontmatter in ${(0,
|
|
9255
|
+
`Invalid frontmatter in ${(0, import_node_path77.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
8977
9256
|
)
|
|
8978
9257
|
};
|
|
8979
9258
|
}
|
|
@@ -8993,7 +9272,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8993
9272
|
};
|
|
8994
9273
|
|
|
8995
9274
|
// src/features/rules/geminicli-rule.ts
|
|
8996
|
-
var
|
|
9275
|
+
var import_node_path78 = require("path");
|
|
8997
9276
|
var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
8998
9277
|
static getSettablePaths({
|
|
8999
9278
|
global
|
|
@@ -9012,7 +9291,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
9012
9291
|
relativeFilePath: "GEMINI.md"
|
|
9013
9292
|
},
|
|
9014
9293
|
nonRoot: {
|
|
9015
|
-
relativeDirPath: (0,
|
|
9294
|
+
relativeDirPath: (0, import_node_path78.join)(".gemini", "memories")
|
|
9016
9295
|
}
|
|
9017
9296
|
};
|
|
9018
9297
|
}
|
|
@@ -9027,7 +9306,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
9027
9306
|
if (isRoot) {
|
|
9028
9307
|
const relativePath2 = paths.root.relativeFilePath;
|
|
9029
9308
|
const fileContent2 = await readFileContent(
|
|
9030
|
-
(0,
|
|
9309
|
+
(0, import_node_path78.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
9031
9310
|
);
|
|
9032
9311
|
return new _GeminiCliRule({
|
|
9033
9312
|
baseDir,
|
|
@@ -9041,8 +9320,8 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
9041
9320
|
if (!paths.nonRoot) {
|
|
9042
9321
|
throw new Error("nonRoot path is not set");
|
|
9043
9322
|
}
|
|
9044
|
-
const relativePath = (0,
|
|
9045
|
-
const fileContent = await readFileContent((0,
|
|
9323
|
+
const relativePath = (0, import_node_path78.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
9324
|
+
const fileContent = await readFileContent((0, import_node_path78.join)(baseDir, relativePath));
|
|
9046
9325
|
return new _GeminiCliRule({
|
|
9047
9326
|
baseDir,
|
|
9048
9327
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -9101,7 +9380,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
9101
9380
|
};
|
|
9102
9381
|
|
|
9103
9382
|
// src/features/rules/junie-rule.ts
|
|
9104
|
-
var
|
|
9383
|
+
var import_node_path79 = require("path");
|
|
9105
9384
|
var JunieRule = class _JunieRule extends ToolRule {
|
|
9106
9385
|
static getSettablePaths() {
|
|
9107
9386
|
return {
|
|
@@ -9110,7 +9389,7 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
9110
9389
|
relativeFilePath: "guidelines.md"
|
|
9111
9390
|
},
|
|
9112
9391
|
nonRoot: {
|
|
9113
|
-
relativeDirPath: (0,
|
|
9392
|
+
relativeDirPath: (0, import_node_path79.join)(".junie", "memories")
|
|
9114
9393
|
}
|
|
9115
9394
|
};
|
|
9116
9395
|
}
|
|
@@ -9120,8 +9399,8 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
9120
9399
|
validate = true
|
|
9121
9400
|
}) {
|
|
9122
9401
|
const isRoot = relativeFilePath === "guidelines.md";
|
|
9123
|
-
const relativePath = isRoot ? "guidelines.md" : (0,
|
|
9124
|
-
const fileContent = await readFileContent((0,
|
|
9402
|
+
const relativePath = isRoot ? "guidelines.md" : (0, import_node_path79.join)(".junie", "memories", relativeFilePath);
|
|
9403
|
+
const fileContent = await readFileContent((0, import_node_path79.join)(baseDir, relativePath));
|
|
9125
9404
|
return new _JunieRule({
|
|
9126
9405
|
baseDir,
|
|
9127
9406
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -9176,12 +9455,12 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
9176
9455
|
};
|
|
9177
9456
|
|
|
9178
9457
|
// src/features/rules/kiro-rule.ts
|
|
9179
|
-
var
|
|
9458
|
+
var import_node_path80 = require("path");
|
|
9180
9459
|
var KiroRule = class _KiroRule extends ToolRule {
|
|
9181
9460
|
static getSettablePaths() {
|
|
9182
9461
|
return {
|
|
9183
9462
|
nonRoot: {
|
|
9184
|
-
relativeDirPath: (0,
|
|
9463
|
+
relativeDirPath: (0, import_node_path80.join)(".kiro", "steering")
|
|
9185
9464
|
}
|
|
9186
9465
|
};
|
|
9187
9466
|
}
|
|
@@ -9191,7 +9470,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
9191
9470
|
validate = true
|
|
9192
9471
|
}) {
|
|
9193
9472
|
const fileContent = await readFileContent(
|
|
9194
|
-
(0,
|
|
9473
|
+
(0, import_node_path80.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
9195
9474
|
);
|
|
9196
9475
|
return new _KiroRule({
|
|
9197
9476
|
baseDir,
|
|
@@ -9245,7 +9524,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
9245
9524
|
};
|
|
9246
9525
|
|
|
9247
9526
|
// src/features/rules/opencode-rule.ts
|
|
9248
|
-
var
|
|
9527
|
+
var import_node_path81 = require("path");
|
|
9249
9528
|
var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
9250
9529
|
static getSettablePaths() {
|
|
9251
9530
|
return {
|
|
@@ -9254,7 +9533,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
9254
9533
|
relativeFilePath: "AGENTS.md"
|
|
9255
9534
|
},
|
|
9256
9535
|
nonRoot: {
|
|
9257
|
-
relativeDirPath: (0,
|
|
9536
|
+
relativeDirPath: (0, import_node_path81.join)(".opencode", "memories")
|
|
9258
9537
|
}
|
|
9259
9538
|
};
|
|
9260
9539
|
}
|
|
@@ -9264,8 +9543,8 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
9264
9543
|
validate = true
|
|
9265
9544
|
}) {
|
|
9266
9545
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
9267
|
-
const relativePath = isRoot ? "AGENTS.md" : (0,
|
|
9268
|
-
const fileContent = await readFileContent((0,
|
|
9546
|
+
const relativePath = isRoot ? "AGENTS.md" : (0, import_node_path81.join)(".opencode", "memories", relativeFilePath);
|
|
9547
|
+
const fileContent = await readFileContent((0, import_node_path81.join)(baseDir, relativePath));
|
|
9269
9548
|
return new _OpenCodeRule({
|
|
9270
9549
|
baseDir,
|
|
9271
9550
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -9320,7 +9599,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
9320
9599
|
};
|
|
9321
9600
|
|
|
9322
9601
|
// src/features/rules/qwencode-rule.ts
|
|
9323
|
-
var
|
|
9602
|
+
var import_node_path82 = require("path");
|
|
9324
9603
|
var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
9325
9604
|
static getSettablePaths() {
|
|
9326
9605
|
return {
|
|
@@ -9329,7 +9608,7 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
9329
9608
|
relativeFilePath: "QWEN.md"
|
|
9330
9609
|
},
|
|
9331
9610
|
nonRoot: {
|
|
9332
|
-
relativeDirPath: (0,
|
|
9611
|
+
relativeDirPath: (0, import_node_path82.join)(".qwen", "memories")
|
|
9333
9612
|
}
|
|
9334
9613
|
};
|
|
9335
9614
|
}
|
|
@@ -9339,8 +9618,8 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
9339
9618
|
validate = true
|
|
9340
9619
|
}) {
|
|
9341
9620
|
const isRoot = relativeFilePath === "QWEN.md";
|
|
9342
|
-
const relativePath = isRoot ? "QWEN.md" : (0,
|
|
9343
|
-
const fileContent = await readFileContent((0,
|
|
9621
|
+
const relativePath = isRoot ? "QWEN.md" : (0, import_node_path82.join)(".qwen", "memories", relativeFilePath);
|
|
9622
|
+
const fileContent = await readFileContent((0, import_node_path82.join)(baseDir, relativePath));
|
|
9344
9623
|
return new _QwencodeRule({
|
|
9345
9624
|
baseDir,
|
|
9346
9625
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -9392,12 +9671,12 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
9392
9671
|
};
|
|
9393
9672
|
|
|
9394
9673
|
// src/features/rules/roo-rule.ts
|
|
9395
|
-
var
|
|
9674
|
+
var import_node_path83 = require("path");
|
|
9396
9675
|
var RooRule = class _RooRule extends ToolRule {
|
|
9397
9676
|
static getSettablePaths() {
|
|
9398
9677
|
return {
|
|
9399
9678
|
nonRoot: {
|
|
9400
|
-
relativeDirPath: (0,
|
|
9679
|
+
relativeDirPath: (0, import_node_path83.join)(".roo", "rules")
|
|
9401
9680
|
}
|
|
9402
9681
|
};
|
|
9403
9682
|
}
|
|
@@ -9407,7 +9686,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
9407
9686
|
validate = true
|
|
9408
9687
|
}) {
|
|
9409
9688
|
const fileContent = await readFileContent(
|
|
9410
|
-
(0,
|
|
9689
|
+
(0, import_node_path83.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
9411
9690
|
);
|
|
9412
9691
|
return new _RooRule({
|
|
9413
9692
|
baseDir,
|
|
@@ -9476,7 +9755,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
9476
9755
|
};
|
|
9477
9756
|
|
|
9478
9757
|
// src/features/rules/warp-rule.ts
|
|
9479
|
-
var
|
|
9758
|
+
var import_node_path84 = require("path");
|
|
9480
9759
|
var WarpRule = class _WarpRule extends ToolRule {
|
|
9481
9760
|
constructor({ fileContent, root, ...rest }) {
|
|
9482
9761
|
super({
|
|
@@ -9492,7 +9771,7 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
9492
9771
|
relativeFilePath: "WARP.md"
|
|
9493
9772
|
},
|
|
9494
9773
|
nonRoot: {
|
|
9495
|
-
relativeDirPath: (0,
|
|
9774
|
+
relativeDirPath: (0, import_node_path84.join)(".warp", "memories")
|
|
9496
9775
|
}
|
|
9497
9776
|
};
|
|
9498
9777
|
}
|
|
@@ -9502,8 +9781,8 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
9502
9781
|
validate = true
|
|
9503
9782
|
}) {
|
|
9504
9783
|
const isRoot = relativeFilePath === this.getSettablePaths().root.relativeFilePath;
|
|
9505
|
-
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath : (0,
|
|
9506
|
-
const fileContent = await readFileContent((0,
|
|
9784
|
+
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath : (0, import_node_path84.join)(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
9785
|
+
const fileContent = await readFileContent((0, import_node_path84.join)(baseDir, relativePath));
|
|
9507
9786
|
return new _WarpRule({
|
|
9508
9787
|
baseDir,
|
|
9509
9788
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : ".warp",
|
|
@@ -9558,12 +9837,12 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
9558
9837
|
};
|
|
9559
9838
|
|
|
9560
9839
|
// src/features/rules/windsurf-rule.ts
|
|
9561
|
-
var
|
|
9840
|
+
var import_node_path85 = require("path");
|
|
9562
9841
|
var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
9563
9842
|
static getSettablePaths() {
|
|
9564
9843
|
return {
|
|
9565
9844
|
nonRoot: {
|
|
9566
|
-
relativeDirPath: (0,
|
|
9845
|
+
relativeDirPath: (0, import_node_path85.join)(".windsurf", "rules")
|
|
9567
9846
|
}
|
|
9568
9847
|
};
|
|
9569
9848
|
}
|
|
@@ -9573,7 +9852,7 @@ var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
|
9573
9852
|
validate = true
|
|
9574
9853
|
}) {
|
|
9575
9854
|
const fileContent = await readFileContent(
|
|
9576
|
-
(0,
|
|
9855
|
+
(0, import_node_path85.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
9577
9856
|
);
|
|
9578
9857
|
return new _WindsurfRule({
|
|
9579
9858
|
baseDir,
|
|
@@ -9646,7 +9925,7 @@ var rulesProcessorToolTargets = [
|
|
|
9646
9925
|
"warp",
|
|
9647
9926
|
"windsurf"
|
|
9648
9927
|
];
|
|
9649
|
-
var RulesProcessorToolTargetSchema =
|
|
9928
|
+
var RulesProcessorToolTargetSchema = import_mini39.z.enum(rulesProcessorToolTargets);
|
|
9650
9929
|
var toolRuleFactories = /* @__PURE__ */ new Map([
|
|
9651
9930
|
[
|
|
9652
9931
|
"agentsmd",
|
|
@@ -9931,7 +10210,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9931
10210
|
}).relativeDirPath;
|
|
9932
10211
|
return this.skills.filter((skill) => skillClass.isTargetedByRulesyncSkill(skill)).map((skill) => {
|
|
9933
10212
|
const frontmatter = skill.getFrontmatter();
|
|
9934
|
-
const relativePath = (0,
|
|
10213
|
+
const relativePath = (0, import_node_path86.join)(toolRelativeDirPath, skill.getDirName(), SKILL_FILE_NAME);
|
|
9935
10214
|
return {
|
|
9936
10215
|
name: frontmatter.name,
|
|
9937
10216
|
description: frontmatter.description,
|
|
@@ -9998,10 +10277,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9998
10277
|
* Load and parse rulesync rule files from .rulesync/rules/ directory
|
|
9999
10278
|
*/
|
|
10000
10279
|
async loadRulesyncFiles() {
|
|
10001
|
-
const files = await findFilesByGlobs((0,
|
|
10280
|
+
const files = await findFilesByGlobs((0, import_node_path86.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md"));
|
|
10002
10281
|
logger.debug(`Found ${files.length} rulesync files`);
|
|
10003
10282
|
const rulesyncRules = await Promise.all(
|
|
10004
|
-
files.map((file) => RulesyncRule.fromFile({ relativeFilePath: (0,
|
|
10283
|
+
files.map((file) => RulesyncRule.fromFile({ relativeFilePath: (0, import_node_path86.basename)(file) }))
|
|
10005
10284
|
);
|
|
10006
10285
|
const rootRules = rulesyncRules.filter((rule) => rule.getFrontmatter().root);
|
|
10007
10286
|
if (rootRules.length > 1) {
|
|
@@ -10019,10 +10298,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10019
10298
|
return rulesyncRules;
|
|
10020
10299
|
}
|
|
10021
10300
|
async loadRulesyncFilesLegacy() {
|
|
10022
|
-
const legacyFiles = await findFilesByGlobs((0,
|
|
10301
|
+
const legacyFiles = await findFilesByGlobs((0, import_node_path86.join)(RULESYNC_RELATIVE_DIR_PATH, "*.md"));
|
|
10023
10302
|
logger.debug(`Found ${legacyFiles.length} legacy rulesync files`);
|
|
10024
10303
|
return Promise.all(
|
|
10025
|
-
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath: (0,
|
|
10304
|
+
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath: (0, import_node_path86.basename)(file) }))
|
|
10026
10305
|
);
|
|
10027
10306
|
}
|
|
10028
10307
|
/**
|
|
@@ -10040,7 +10319,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10040
10319
|
return [];
|
|
10041
10320
|
}
|
|
10042
10321
|
const rootFilePaths = await findFilesByGlobs(
|
|
10043
|
-
(0,
|
|
10322
|
+
(0, import_node_path86.join)(
|
|
10044
10323
|
this.baseDir,
|
|
10045
10324
|
settablePaths.root.relativeDirPath ?? ".",
|
|
10046
10325
|
settablePaths.root.relativeFilePath
|
|
@@ -10051,7 +10330,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10051
10330
|
(filePath) => factory.class.forDeletion({
|
|
10052
10331
|
baseDir: this.baseDir,
|
|
10053
10332
|
relativeDirPath: settablePaths.root?.relativeDirPath ?? ".",
|
|
10054
|
-
relativeFilePath: (0,
|
|
10333
|
+
relativeFilePath: (0, import_node_path86.basename)(filePath),
|
|
10055
10334
|
global: this.global
|
|
10056
10335
|
})
|
|
10057
10336
|
).filter((rule) => rule.isDeletable());
|
|
@@ -10060,7 +10339,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10060
10339
|
rootFilePaths.map(
|
|
10061
10340
|
(filePath) => factory.class.fromFile({
|
|
10062
10341
|
baseDir: this.baseDir,
|
|
10063
|
-
relativeFilePath: (0,
|
|
10342
|
+
relativeFilePath: (0, import_node_path86.basename)(filePath),
|
|
10064
10343
|
global: this.global
|
|
10065
10344
|
})
|
|
10066
10345
|
)
|
|
@@ -10072,14 +10351,14 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10072
10351
|
return [];
|
|
10073
10352
|
}
|
|
10074
10353
|
const nonRootFilePaths = await findFilesByGlobs(
|
|
10075
|
-
(0,
|
|
10354
|
+
(0, import_node_path86.join)(this.baseDir, settablePaths.nonRoot.relativeDirPath, `*.${factory.meta.extension}`)
|
|
10076
10355
|
);
|
|
10077
10356
|
if (forDeletion) {
|
|
10078
10357
|
return nonRootFilePaths.map(
|
|
10079
10358
|
(filePath) => factory.class.forDeletion({
|
|
10080
10359
|
baseDir: this.baseDir,
|
|
10081
10360
|
relativeDirPath: settablePaths.nonRoot?.relativeDirPath ?? ".",
|
|
10082
|
-
relativeFilePath: (0,
|
|
10361
|
+
relativeFilePath: (0, import_node_path86.basename)(filePath),
|
|
10083
10362
|
global: this.global
|
|
10084
10363
|
})
|
|
10085
10364
|
).filter((rule) => rule.isDeletable());
|
|
@@ -10088,7 +10367,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10088
10367
|
nonRootFilePaths.map(
|
|
10089
10368
|
(filePath) => factory.class.fromFile({
|
|
10090
10369
|
baseDir: this.baseDir,
|
|
10091
|
-
relativeFilePath: (0,
|
|
10370
|
+
relativeFilePath: (0, import_node_path86.basename)(filePath),
|
|
10092
10371
|
global: this.global
|
|
10093
10372
|
})
|
|
10094
10373
|
)
|
|
@@ -10181,14 +10460,14 @@ s/<command> [arguments]
|
|
|
10181
10460
|
This syntax employs a double slash (\`s/\`) to prevent conflicts with built-in slash commands.
|
|
10182
10461
|
The \`s\` in \`s/\` stands for *simulate*. Because custom slash commands are not built-in, this syntax provides a pseudo way to invoke them.
|
|
10183
10462
|
|
|
10184
|
-
When users call a custom slash command, you have to look for the markdown file, \`${(0,
|
|
10463
|
+
When users call a custom slash command, you have to look for the markdown file, \`${(0, import_node_path86.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "{command}.md")}\`, then execute the contents of that file as the block of operations.` : "";
|
|
10185
10464
|
const subagentsSection = subagents ? `## Simulated Subagents
|
|
10186
10465
|
|
|
10187
10466
|
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.
|
|
10188
10467
|
|
|
10189
|
-
When users call a simulated subagent, it will look for the corresponding markdown file, \`${(0,
|
|
10468
|
+
When users call a simulated subagent, it will look for the corresponding markdown file, \`${(0, import_node_path86.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "{subagent}.md")}\`, and execute its contents as the block of operations.
|
|
10190
10469
|
|
|
10191
|
-
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${(0,
|
|
10470
|
+
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${(0, import_node_path86.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "planner.md")}\`, and execute its contents as the block of operations.` : "";
|
|
10192
10471
|
const skillsSection = skills ? this.generateSkillsSection(skills) : "";
|
|
10193
10472
|
const result = [
|
|
10194
10473
|
overview,
|
|
@@ -10470,7 +10749,7 @@ async function generateSkills(config) {
|
|
|
10470
10749
|
}
|
|
10471
10750
|
|
|
10472
10751
|
// src/cli/commands/gitignore.ts
|
|
10473
|
-
var
|
|
10752
|
+
var import_node_path87 = require("path");
|
|
10474
10753
|
var RULESYNC_HEADER = "# Generated by Rulesync";
|
|
10475
10754
|
var LEGACY_RULESYNC_HEADER = "# Generated by rulesync - AI tool configuration files";
|
|
10476
10755
|
var RULESYNC_IGNORE_ENTRIES = [
|
|
@@ -10527,6 +10806,7 @@ var RULESYNC_IGNORE_ENTRIES = [
|
|
|
10527
10806
|
// OpenCode
|
|
10528
10807
|
"**/.opencode/memories/",
|
|
10529
10808
|
"**/.opencode/command/",
|
|
10809
|
+
"**/.opencode/agent/",
|
|
10530
10810
|
"**/.opencode/skills/",
|
|
10531
10811
|
"**/opencode.json",
|
|
10532
10812
|
// Qwen
|
|
@@ -10594,7 +10874,7 @@ var removeExistingRulesyncEntries = (content) => {
|
|
|
10594
10874
|
return result;
|
|
10595
10875
|
};
|
|
10596
10876
|
var gitignoreCommand = async () => {
|
|
10597
|
-
const gitignorePath = (0,
|
|
10877
|
+
const gitignorePath = (0, import_node_path87.join)(process.cwd(), ".gitignore");
|
|
10598
10878
|
let gitignoreContent = "";
|
|
10599
10879
|
if (await fileExists(gitignorePath)) {
|
|
10600
10880
|
gitignoreContent = await readFileContent(gitignorePath);
|
|
@@ -10793,7 +11073,7 @@ async function importSkills(config, tool) {
|
|
|
10793
11073
|
}
|
|
10794
11074
|
|
|
10795
11075
|
// src/cli/commands/init.ts
|
|
10796
|
-
var
|
|
11076
|
+
var import_node_path88 = require("path");
|
|
10797
11077
|
async function initCommand() {
|
|
10798
11078
|
logger.info("Initializing rulesync...");
|
|
10799
11079
|
await ensureDir(RULESYNC_RELATIVE_DIR_PATH);
|
|
@@ -10956,14 +11236,14 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
10956
11236
|
await ensureDir(commandPaths.relativeDirPath);
|
|
10957
11237
|
await ensureDir(subagentPaths.relativeDirPath);
|
|
10958
11238
|
await ensureDir(ignorePaths.recommended.relativeDirPath);
|
|
10959
|
-
const ruleFilepath = (0,
|
|
11239
|
+
const ruleFilepath = (0, import_node_path88.join)(rulePaths.recommended.relativeDirPath, sampleRuleFile.filename);
|
|
10960
11240
|
if (!await fileExists(ruleFilepath)) {
|
|
10961
11241
|
await writeFileContent(ruleFilepath, sampleRuleFile.content);
|
|
10962
11242
|
logger.success(`Created ${ruleFilepath}`);
|
|
10963
11243
|
} else {
|
|
10964
11244
|
logger.info(`Skipped ${ruleFilepath} (already exists)`);
|
|
10965
11245
|
}
|
|
10966
|
-
const mcpFilepath = (0,
|
|
11246
|
+
const mcpFilepath = (0, import_node_path88.join)(
|
|
10967
11247
|
mcpPaths.recommended.relativeDirPath,
|
|
10968
11248
|
mcpPaths.recommended.relativeFilePath
|
|
10969
11249
|
);
|
|
@@ -10973,21 +11253,21 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
10973
11253
|
} else {
|
|
10974
11254
|
logger.info(`Skipped ${mcpFilepath} (already exists)`);
|
|
10975
11255
|
}
|
|
10976
|
-
const commandFilepath = (0,
|
|
11256
|
+
const commandFilepath = (0, import_node_path88.join)(commandPaths.relativeDirPath, sampleCommandFile.filename);
|
|
10977
11257
|
if (!await fileExists(commandFilepath)) {
|
|
10978
11258
|
await writeFileContent(commandFilepath, sampleCommandFile.content);
|
|
10979
11259
|
logger.success(`Created ${commandFilepath}`);
|
|
10980
11260
|
} else {
|
|
10981
11261
|
logger.info(`Skipped ${commandFilepath} (already exists)`);
|
|
10982
11262
|
}
|
|
10983
|
-
const subagentFilepath = (0,
|
|
11263
|
+
const subagentFilepath = (0, import_node_path88.join)(subagentPaths.relativeDirPath, sampleSubagentFile.filename);
|
|
10984
11264
|
if (!await fileExists(subagentFilepath)) {
|
|
10985
11265
|
await writeFileContent(subagentFilepath, sampleSubagentFile.content);
|
|
10986
11266
|
logger.success(`Created ${subagentFilepath}`);
|
|
10987
11267
|
} else {
|
|
10988
11268
|
logger.info(`Skipped ${subagentFilepath} (already exists)`);
|
|
10989
11269
|
}
|
|
10990
|
-
const ignoreFilepath = (0,
|
|
11270
|
+
const ignoreFilepath = (0, import_node_path88.join)(
|
|
10991
11271
|
ignorePaths.recommended.relativeDirPath,
|
|
10992
11272
|
ignorePaths.recommended.relativeFilePath
|
|
10993
11273
|
);
|
|
@@ -11002,13 +11282,16 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
11002
11282
|
// src/cli/commands/mcp.ts
|
|
11003
11283
|
var import_fastmcp = require("fastmcp");
|
|
11004
11284
|
|
|
11285
|
+
// src/mcp/tools.ts
|
|
11286
|
+
var import_mini46 = require("zod/mini");
|
|
11287
|
+
|
|
11005
11288
|
// src/mcp/commands.ts
|
|
11006
|
-
var
|
|
11007
|
-
var
|
|
11289
|
+
var import_node_path89 = require("path");
|
|
11290
|
+
var import_mini40 = require("zod/mini");
|
|
11008
11291
|
var maxCommandSizeBytes = 1024 * 1024;
|
|
11009
11292
|
var maxCommandsCount = 1e3;
|
|
11010
11293
|
async function listCommands() {
|
|
11011
|
-
const commandsDir = (0,
|
|
11294
|
+
const commandsDir = (0, import_node_path89.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
11012
11295
|
try {
|
|
11013
11296
|
const files = await listDirectoryFiles(commandsDir);
|
|
11014
11297
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -11020,7 +11303,7 @@ async function listCommands() {
|
|
|
11020
11303
|
});
|
|
11021
11304
|
const frontmatter = command.getFrontmatter();
|
|
11022
11305
|
return {
|
|
11023
|
-
relativePathFromCwd: (0,
|
|
11306
|
+
relativePathFromCwd: (0, import_node_path89.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, file),
|
|
11024
11307
|
frontmatter
|
|
11025
11308
|
};
|
|
11026
11309
|
} catch (error) {
|
|
@@ -11040,13 +11323,13 @@ async function getCommand({ relativePathFromCwd }) {
|
|
|
11040
11323
|
relativePath: relativePathFromCwd,
|
|
11041
11324
|
intendedRootDir: process.cwd()
|
|
11042
11325
|
});
|
|
11043
|
-
const filename = (0,
|
|
11326
|
+
const filename = (0, import_node_path89.basename)(relativePathFromCwd);
|
|
11044
11327
|
try {
|
|
11045
11328
|
const command = await RulesyncCommand.fromFile({
|
|
11046
11329
|
relativeFilePath: filename
|
|
11047
11330
|
});
|
|
11048
11331
|
return {
|
|
11049
|
-
relativePathFromCwd: (0,
|
|
11332
|
+
relativePathFromCwd: (0, import_node_path89.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
11050
11333
|
frontmatter: command.getFrontmatter(),
|
|
11051
11334
|
body: command.getBody()
|
|
11052
11335
|
};
|
|
@@ -11065,7 +11348,7 @@ async function putCommand({
|
|
|
11065
11348
|
relativePath: relativePathFromCwd,
|
|
11066
11349
|
intendedRootDir: process.cwd()
|
|
11067
11350
|
});
|
|
11068
|
-
const filename = (0,
|
|
11351
|
+
const filename = (0, import_node_path89.basename)(relativePathFromCwd);
|
|
11069
11352
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
11070
11353
|
if (estimatedSize > maxCommandSizeBytes) {
|
|
11071
11354
|
throw new Error(
|
|
@@ -11075,7 +11358,7 @@ async function putCommand({
|
|
|
11075
11358
|
try {
|
|
11076
11359
|
const existingCommands = await listCommands();
|
|
11077
11360
|
const isUpdate = existingCommands.some(
|
|
11078
|
-
(command2) => command2.relativePathFromCwd === (0,
|
|
11361
|
+
(command2) => command2.relativePathFromCwd === (0, import_node_path89.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
11079
11362
|
);
|
|
11080
11363
|
if (!isUpdate && existingCommands.length >= maxCommandsCount) {
|
|
11081
11364
|
throw new Error(`Maximum number of commands (${maxCommandsCount}) reached`);
|
|
@@ -11090,11 +11373,11 @@ async function putCommand({
|
|
|
11090
11373
|
fileContent,
|
|
11091
11374
|
validate: true
|
|
11092
11375
|
});
|
|
11093
|
-
const commandsDir = (0,
|
|
11376
|
+
const commandsDir = (0, import_node_path89.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
11094
11377
|
await ensureDir(commandsDir);
|
|
11095
11378
|
await writeFileContent(command.getFilePath(), command.getFileContent());
|
|
11096
11379
|
return {
|
|
11097
|
-
relativePathFromCwd: (0,
|
|
11380
|
+
relativePathFromCwd: (0, import_node_path89.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
11098
11381
|
frontmatter: command.getFrontmatter(),
|
|
11099
11382
|
body: command.getBody()
|
|
11100
11383
|
};
|
|
@@ -11109,12 +11392,12 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
11109
11392
|
relativePath: relativePathFromCwd,
|
|
11110
11393
|
intendedRootDir: process.cwd()
|
|
11111
11394
|
});
|
|
11112
|
-
const filename = (0,
|
|
11113
|
-
const fullPath = (0,
|
|
11395
|
+
const filename = (0, import_node_path89.basename)(relativePathFromCwd);
|
|
11396
|
+
const fullPath = (0, import_node_path89.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename);
|
|
11114
11397
|
try {
|
|
11115
11398
|
await removeFile(fullPath);
|
|
11116
11399
|
return {
|
|
11117
|
-
relativePathFromCwd: (0,
|
|
11400
|
+
relativePathFromCwd: (0, import_node_path89.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
11118
11401
|
};
|
|
11119
11402
|
} catch (error) {
|
|
11120
11403
|
throw new Error(`Failed to delete command file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -11123,23 +11406,23 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
11123
11406
|
}
|
|
11124
11407
|
}
|
|
11125
11408
|
var commandToolSchemas = {
|
|
11126
|
-
listCommands:
|
|
11127
|
-
getCommand:
|
|
11128
|
-
relativePathFromCwd:
|
|
11409
|
+
listCommands: import_mini40.z.object({}),
|
|
11410
|
+
getCommand: import_mini40.z.object({
|
|
11411
|
+
relativePathFromCwd: import_mini40.z.string()
|
|
11129
11412
|
}),
|
|
11130
|
-
putCommand:
|
|
11131
|
-
relativePathFromCwd:
|
|
11413
|
+
putCommand: import_mini40.z.object({
|
|
11414
|
+
relativePathFromCwd: import_mini40.z.string(),
|
|
11132
11415
|
frontmatter: RulesyncCommandFrontmatterSchema,
|
|
11133
|
-
body:
|
|
11416
|
+
body: import_mini40.z.string()
|
|
11134
11417
|
}),
|
|
11135
|
-
deleteCommand:
|
|
11136
|
-
relativePathFromCwd:
|
|
11418
|
+
deleteCommand: import_mini40.z.object({
|
|
11419
|
+
relativePathFromCwd: import_mini40.z.string()
|
|
11137
11420
|
})
|
|
11138
11421
|
};
|
|
11139
11422
|
var commandTools = {
|
|
11140
11423
|
listCommands: {
|
|
11141
11424
|
name: "listCommands",
|
|
11142
|
-
description: `List all commands from ${(0,
|
|
11425
|
+
description: `List all commands from ${(0, import_node_path89.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
11143
11426
|
parameters: commandToolSchemas.listCommands,
|
|
11144
11427
|
execute: async () => {
|
|
11145
11428
|
const commands = await listCommands();
|
|
@@ -11181,11 +11464,11 @@ var commandTools = {
|
|
|
11181
11464
|
};
|
|
11182
11465
|
|
|
11183
11466
|
// src/mcp/ignore.ts
|
|
11184
|
-
var
|
|
11185
|
-
var
|
|
11467
|
+
var import_node_path90 = require("path");
|
|
11468
|
+
var import_mini41 = require("zod/mini");
|
|
11186
11469
|
var maxIgnoreFileSizeBytes = 100 * 1024;
|
|
11187
11470
|
async function getIgnoreFile() {
|
|
11188
|
-
const ignoreFilePath = (0,
|
|
11471
|
+
const ignoreFilePath = (0, import_node_path90.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
11189
11472
|
try {
|
|
11190
11473
|
const content = await readFileContent(ignoreFilePath);
|
|
11191
11474
|
return {
|
|
@@ -11199,7 +11482,7 @@ async function getIgnoreFile() {
|
|
|
11199
11482
|
}
|
|
11200
11483
|
}
|
|
11201
11484
|
async function putIgnoreFile({ content }) {
|
|
11202
|
-
const ignoreFilePath = (0,
|
|
11485
|
+
const ignoreFilePath = (0, import_node_path90.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
11203
11486
|
const contentSizeBytes = Buffer.byteLength(content, "utf8");
|
|
11204
11487
|
if (contentSizeBytes > maxIgnoreFileSizeBytes) {
|
|
11205
11488
|
throw new Error(
|
|
@@ -11220,8 +11503,8 @@ async function putIgnoreFile({ content }) {
|
|
|
11220
11503
|
}
|
|
11221
11504
|
}
|
|
11222
11505
|
async function deleteIgnoreFile() {
|
|
11223
|
-
const aiignorePath = (0,
|
|
11224
|
-
const legacyIgnorePath = (0,
|
|
11506
|
+
const aiignorePath = (0, import_node_path90.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
11507
|
+
const legacyIgnorePath = (0, import_node_path90.join)(process.cwd(), RULESYNC_IGNORE_RELATIVE_FILE_PATH);
|
|
11225
11508
|
try {
|
|
11226
11509
|
await Promise.all([removeFile(aiignorePath), removeFile(legacyIgnorePath)]);
|
|
11227
11510
|
return {
|
|
@@ -11239,11 +11522,11 @@ async function deleteIgnoreFile() {
|
|
|
11239
11522
|
}
|
|
11240
11523
|
}
|
|
11241
11524
|
var ignoreToolSchemas = {
|
|
11242
|
-
getIgnoreFile:
|
|
11243
|
-
putIgnoreFile:
|
|
11244
|
-
content:
|
|
11525
|
+
getIgnoreFile: import_mini41.z.object({}),
|
|
11526
|
+
putIgnoreFile: import_mini41.z.object({
|
|
11527
|
+
content: import_mini41.z.string()
|
|
11245
11528
|
}),
|
|
11246
|
-
deleteIgnoreFile:
|
|
11529
|
+
deleteIgnoreFile: import_mini41.z.object({})
|
|
11247
11530
|
};
|
|
11248
11531
|
var ignoreTools = {
|
|
11249
11532
|
getIgnoreFile: {
|
|
@@ -11276,8 +11559,8 @@ var ignoreTools = {
|
|
|
11276
11559
|
};
|
|
11277
11560
|
|
|
11278
11561
|
// src/mcp/mcp.ts
|
|
11279
|
-
var
|
|
11280
|
-
var
|
|
11562
|
+
var import_node_path91 = require("path");
|
|
11563
|
+
var import_mini42 = require("zod/mini");
|
|
11281
11564
|
var maxMcpSizeBytes = 1024 * 1024;
|
|
11282
11565
|
async function getMcpFile() {
|
|
11283
11566
|
const config = await ConfigResolver.resolve({});
|
|
@@ -11286,7 +11569,7 @@ async function getMcpFile() {
|
|
|
11286
11569
|
validate: true,
|
|
11287
11570
|
modularMcp: config.getModularMcp()
|
|
11288
11571
|
});
|
|
11289
|
-
const relativePathFromCwd = (0,
|
|
11572
|
+
const relativePathFromCwd = (0, import_node_path91.join)(
|
|
11290
11573
|
rulesyncMcp.getRelativeDirPath(),
|
|
11291
11574
|
rulesyncMcp.getRelativeFilePath()
|
|
11292
11575
|
);
|
|
@@ -11319,7 +11602,7 @@ async function putMcpFile({ content }) {
|
|
|
11319
11602
|
const paths = RulesyncMcp.getSettablePaths();
|
|
11320
11603
|
const relativeDirPath = paths.recommended.relativeDirPath;
|
|
11321
11604
|
const relativeFilePath = paths.recommended.relativeFilePath;
|
|
11322
|
-
const fullPath = (0,
|
|
11605
|
+
const fullPath = (0, import_node_path91.join)(baseDir, relativeDirPath, relativeFilePath);
|
|
11323
11606
|
const rulesyncMcp = new RulesyncMcp({
|
|
11324
11607
|
baseDir,
|
|
11325
11608
|
relativeDirPath,
|
|
@@ -11328,9 +11611,9 @@ async function putMcpFile({ content }) {
|
|
|
11328
11611
|
validate: true,
|
|
11329
11612
|
modularMcp: config.getModularMcp()
|
|
11330
11613
|
});
|
|
11331
|
-
await ensureDir((0,
|
|
11614
|
+
await ensureDir((0, import_node_path91.join)(baseDir, relativeDirPath));
|
|
11332
11615
|
await writeFileContent(fullPath, content);
|
|
11333
|
-
const relativePathFromCwd = (0,
|
|
11616
|
+
const relativePathFromCwd = (0, import_node_path91.join)(relativeDirPath, relativeFilePath);
|
|
11334
11617
|
return {
|
|
11335
11618
|
relativePathFromCwd,
|
|
11336
11619
|
content: rulesyncMcp.getFileContent()
|
|
@@ -11345,15 +11628,15 @@ async function deleteMcpFile() {
|
|
|
11345
11628
|
try {
|
|
11346
11629
|
const baseDir = process.cwd();
|
|
11347
11630
|
const paths = RulesyncMcp.getSettablePaths();
|
|
11348
|
-
const recommendedPath = (0,
|
|
11631
|
+
const recommendedPath = (0, import_node_path91.join)(
|
|
11349
11632
|
baseDir,
|
|
11350
11633
|
paths.recommended.relativeDirPath,
|
|
11351
11634
|
paths.recommended.relativeFilePath
|
|
11352
11635
|
);
|
|
11353
|
-
const legacyPath = (0,
|
|
11636
|
+
const legacyPath = (0, import_node_path91.join)(baseDir, paths.legacy.relativeDirPath, paths.legacy.relativeFilePath);
|
|
11354
11637
|
await removeFile(recommendedPath);
|
|
11355
11638
|
await removeFile(legacyPath);
|
|
11356
|
-
const relativePathFromCwd = (0,
|
|
11639
|
+
const relativePathFromCwd = (0, import_node_path91.join)(
|
|
11357
11640
|
paths.recommended.relativeDirPath,
|
|
11358
11641
|
paths.recommended.relativeFilePath
|
|
11359
11642
|
);
|
|
@@ -11367,11 +11650,11 @@ async function deleteMcpFile() {
|
|
|
11367
11650
|
}
|
|
11368
11651
|
}
|
|
11369
11652
|
var mcpToolSchemas = {
|
|
11370
|
-
getMcpFile:
|
|
11371
|
-
putMcpFile:
|
|
11372
|
-
content:
|
|
11653
|
+
getMcpFile: import_mini42.z.object({}),
|
|
11654
|
+
putMcpFile: import_mini42.z.object({
|
|
11655
|
+
content: import_mini42.z.string()
|
|
11373
11656
|
}),
|
|
11374
|
-
deleteMcpFile:
|
|
11657
|
+
deleteMcpFile: import_mini42.z.object({})
|
|
11375
11658
|
};
|
|
11376
11659
|
var mcpTools = {
|
|
11377
11660
|
getMcpFile: {
|
|
@@ -11404,12 +11687,12 @@ var mcpTools = {
|
|
|
11404
11687
|
};
|
|
11405
11688
|
|
|
11406
11689
|
// src/mcp/rules.ts
|
|
11407
|
-
var
|
|
11408
|
-
var
|
|
11690
|
+
var import_node_path92 = require("path");
|
|
11691
|
+
var import_mini43 = require("zod/mini");
|
|
11409
11692
|
var maxRuleSizeBytes = 1024 * 1024;
|
|
11410
11693
|
var maxRulesCount = 1e3;
|
|
11411
11694
|
async function listRules() {
|
|
11412
|
-
const rulesDir = (0,
|
|
11695
|
+
const rulesDir = (0, import_node_path92.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
11413
11696
|
try {
|
|
11414
11697
|
const files = await listDirectoryFiles(rulesDir);
|
|
11415
11698
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -11422,7 +11705,7 @@ async function listRules() {
|
|
|
11422
11705
|
});
|
|
11423
11706
|
const frontmatter = rule.getFrontmatter();
|
|
11424
11707
|
return {
|
|
11425
|
-
relativePathFromCwd: (0,
|
|
11708
|
+
relativePathFromCwd: (0, import_node_path92.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, file),
|
|
11426
11709
|
frontmatter
|
|
11427
11710
|
};
|
|
11428
11711
|
} catch (error) {
|
|
@@ -11442,14 +11725,14 @@ async function getRule({ relativePathFromCwd }) {
|
|
|
11442
11725
|
relativePath: relativePathFromCwd,
|
|
11443
11726
|
intendedRootDir: process.cwd()
|
|
11444
11727
|
});
|
|
11445
|
-
const filename = (0,
|
|
11728
|
+
const filename = (0, import_node_path92.basename)(relativePathFromCwd);
|
|
11446
11729
|
try {
|
|
11447
11730
|
const rule = await RulesyncRule.fromFile({
|
|
11448
11731
|
relativeFilePath: filename,
|
|
11449
11732
|
validate: true
|
|
11450
11733
|
});
|
|
11451
11734
|
return {
|
|
11452
|
-
relativePathFromCwd: (0,
|
|
11735
|
+
relativePathFromCwd: (0, import_node_path92.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
11453
11736
|
frontmatter: rule.getFrontmatter(),
|
|
11454
11737
|
body: rule.getBody()
|
|
11455
11738
|
};
|
|
@@ -11468,7 +11751,7 @@ async function putRule({
|
|
|
11468
11751
|
relativePath: relativePathFromCwd,
|
|
11469
11752
|
intendedRootDir: process.cwd()
|
|
11470
11753
|
});
|
|
11471
|
-
const filename = (0,
|
|
11754
|
+
const filename = (0, import_node_path92.basename)(relativePathFromCwd);
|
|
11472
11755
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
11473
11756
|
if (estimatedSize > maxRuleSizeBytes) {
|
|
11474
11757
|
throw new Error(
|
|
@@ -11478,7 +11761,7 @@ async function putRule({
|
|
|
11478
11761
|
try {
|
|
11479
11762
|
const existingRules = await listRules();
|
|
11480
11763
|
const isUpdate = existingRules.some(
|
|
11481
|
-
(rule2) => rule2.relativePathFromCwd === (0,
|
|
11764
|
+
(rule2) => rule2.relativePathFromCwd === (0, import_node_path92.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
11482
11765
|
);
|
|
11483
11766
|
if (!isUpdate && existingRules.length >= maxRulesCount) {
|
|
11484
11767
|
throw new Error(`Maximum number of rules (${maxRulesCount}) reached`);
|
|
@@ -11491,11 +11774,11 @@ async function putRule({
|
|
|
11491
11774
|
body,
|
|
11492
11775
|
validate: true
|
|
11493
11776
|
});
|
|
11494
|
-
const rulesDir = (0,
|
|
11777
|
+
const rulesDir = (0, import_node_path92.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
11495
11778
|
await ensureDir(rulesDir);
|
|
11496
11779
|
await writeFileContent(rule.getFilePath(), rule.getFileContent());
|
|
11497
11780
|
return {
|
|
11498
|
-
relativePathFromCwd: (0,
|
|
11781
|
+
relativePathFromCwd: (0, import_node_path92.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
11499
11782
|
frontmatter: rule.getFrontmatter(),
|
|
11500
11783
|
body: rule.getBody()
|
|
11501
11784
|
};
|
|
@@ -11510,12 +11793,12 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
11510
11793
|
relativePath: relativePathFromCwd,
|
|
11511
11794
|
intendedRootDir: process.cwd()
|
|
11512
11795
|
});
|
|
11513
|
-
const filename = (0,
|
|
11514
|
-
const fullPath = (0,
|
|
11796
|
+
const filename = (0, import_node_path92.basename)(relativePathFromCwd);
|
|
11797
|
+
const fullPath = (0, import_node_path92.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH, filename);
|
|
11515
11798
|
try {
|
|
11516
11799
|
await removeFile(fullPath);
|
|
11517
11800
|
return {
|
|
11518
|
-
relativePathFromCwd: (0,
|
|
11801
|
+
relativePathFromCwd: (0, import_node_path92.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
11519
11802
|
};
|
|
11520
11803
|
} catch (error) {
|
|
11521
11804
|
throw new Error(`Failed to delete rule file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -11524,23 +11807,23 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
11524
11807
|
}
|
|
11525
11808
|
}
|
|
11526
11809
|
var ruleToolSchemas = {
|
|
11527
|
-
listRules:
|
|
11528
|
-
getRule:
|
|
11529
|
-
relativePathFromCwd:
|
|
11810
|
+
listRules: import_mini43.z.object({}),
|
|
11811
|
+
getRule: import_mini43.z.object({
|
|
11812
|
+
relativePathFromCwd: import_mini43.z.string()
|
|
11530
11813
|
}),
|
|
11531
|
-
putRule:
|
|
11532
|
-
relativePathFromCwd:
|
|
11814
|
+
putRule: import_mini43.z.object({
|
|
11815
|
+
relativePathFromCwd: import_mini43.z.string(),
|
|
11533
11816
|
frontmatter: RulesyncRuleFrontmatterSchema,
|
|
11534
|
-
body:
|
|
11817
|
+
body: import_mini43.z.string()
|
|
11535
11818
|
}),
|
|
11536
|
-
deleteRule:
|
|
11537
|
-
relativePathFromCwd:
|
|
11819
|
+
deleteRule: import_mini43.z.object({
|
|
11820
|
+
relativePathFromCwd: import_mini43.z.string()
|
|
11538
11821
|
})
|
|
11539
11822
|
};
|
|
11540
11823
|
var ruleTools = {
|
|
11541
11824
|
listRules: {
|
|
11542
11825
|
name: "listRules",
|
|
11543
|
-
description: `List all rules from ${(0,
|
|
11826
|
+
description: `List all rules from ${(0, import_node_path92.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
11544
11827
|
parameters: ruleToolSchemas.listRules,
|
|
11545
11828
|
execute: async () => {
|
|
11546
11829
|
const rules = await listRules();
|
|
@@ -11582,8 +11865,8 @@ var ruleTools = {
|
|
|
11582
11865
|
};
|
|
11583
11866
|
|
|
11584
11867
|
// src/mcp/skills.ts
|
|
11585
|
-
var
|
|
11586
|
-
var
|
|
11868
|
+
var import_node_path93 = require("path");
|
|
11869
|
+
var import_mini44 = require("zod/mini");
|
|
11587
11870
|
var maxSkillSizeBytes = 1024 * 1024;
|
|
11588
11871
|
var maxSkillsCount = 1e3;
|
|
11589
11872
|
function aiDirFileToMcpSkillFile(file) {
|
|
@@ -11599,19 +11882,19 @@ function mcpSkillFileToAiDirFile(file) {
|
|
|
11599
11882
|
};
|
|
11600
11883
|
}
|
|
11601
11884
|
function extractDirName(relativeDirPathFromCwd) {
|
|
11602
|
-
const dirName = (0,
|
|
11885
|
+
const dirName = (0, import_node_path93.basename)(relativeDirPathFromCwd);
|
|
11603
11886
|
if (!dirName) {
|
|
11604
11887
|
throw new Error(`Invalid path: ${relativeDirPathFromCwd}`);
|
|
11605
11888
|
}
|
|
11606
11889
|
return dirName;
|
|
11607
11890
|
}
|
|
11608
11891
|
async function listSkills() {
|
|
11609
|
-
const skillsDir = (0,
|
|
11892
|
+
const skillsDir = (0, import_node_path93.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH);
|
|
11610
11893
|
try {
|
|
11611
|
-
const skillDirPaths = await findFilesByGlobs((0,
|
|
11894
|
+
const skillDirPaths = await findFilesByGlobs((0, import_node_path93.join)(skillsDir, "*"), { type: "dir" });
|
|
11612
11895
|
const skills = await Promise.all(
|
|
11613
11896
|
skillDirPaths.map(async (dirPath) => {
|
|
11614
|
-
const dirName = (0,
|
|
11897
|
+
const dirName = (0, import_node_path93.basename)(dirPath);
|
|
11615
11898
|
if (!dirName) return null;
|
|
11616
11899
|
try {
|
|
11617
11900
|
const skill = await RulesyncSkill.fromDir({
|
|
@@ -11619,7 +11902,7 @@ async function listSkills() {
|
|
|
11619
11902
|
});
|
|
11620
11903
|
const frontmatter = skill.getFrontmatter();
|
|
11621
11904
|
return {
|
|
11622
|
-
relativeDirPathFromCwd: (0,
|
|
11905
|
+
relativeDirPathFromCwd: (0, import_node_path93.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
11623
11906
|
frontmatter
|
|
11624
11907
|
};
|
|
11625
11908
|
} catch (error) {
|
|
@@ -11645,7 +11928,7 @@ async function getSkill({ relativeDirPathFromCwd }) {
|
|
|
11645
11928
|
dirName
|
|
11646
11929
|
});
|
|
11647
11930
|
return {
|
|
11648
|
-
relativeDirPathFromCwd: (0,
|
|
11931
|
+
relativeDirPathFromCwd: (0, import_node_path93.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
11649
11932
|
frontmatter: skill.getFrontmatter(),
|
|
11650
11933
|
body: skill.getBody(),
|
|
11651
11934
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -11679,7 +11962,7 @@ async function putSkill({
|
|
|
11679
11962
|
try {
|
|
11680
11963
|
const existingSkills = await listSkills();
|
|
11681
11964
|
const isUpdate = existingSkills.some(
|
|
11682
|
-
(skill2) => skill2.relativeDirPathFromCwd === (0,
|
|
11965
|
+
(skill2) => skill2.relativeDirPathFromCwd === (0, import_node_path93.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
11683
11966
|
);
|
|
11684
11967
|
if (!isUpdate && existingSkills.length >= maxSkillsCount) {
|
|
11685
11968
|
throw new Error(`Maximum number of skills (${maxSkillsCount}) reached`);
|
|
@@ -11694,9 +11977,9 @@ async function putSkill({
|
|
|
11694
11977
|
otherFiles: aiDirFiles,
|
|
11695
11978
|
validate: true
|
|
11696
11979
|
});
|
|
11697
|
-
const skillDirPath = (0,
|
|
11980
|
+
const skillDirPath = (0, import_node_path93.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
11698
11981
|
await ensureDir(skillDirPath);
|
|
11699
|
-
const skillFilePath = (0,
|
|
11982
|
+
const skillFilePath = (0, import_node_path93.join)(skillDirPath, SKILL_FILE_NAME);
|
|
11700
11983
|
const skillFileContent = stringifyFrontmatter(body, frontmatter);
|
|
11701
11984
|
await writeFileContent(skillFilePath, skillFileContent);
|
|
11702
11985
|
for (const file of otherFiles) {
|
|
@@ -11704,15 +11987,15 @@ async function putSkill({
|
|
|
11704
11987
|
relativePath: file.name,
|
|
11705
11988
|
intendedRootDir: skillDirPath
|
|
11706
11989
|
});
|
|
11707
|
-
const filePath = (0,
|
|
11708
|
-
const fileDir = (0,
|
|
11990
|
+
const filePath = (0, import_node_path93.join)(skillDirPath, file.name);
|
|
11991
|
+
const fileDir = (0, import_node_path93.join)(skillDirPath, (0, import_node_path93.dirname)(file.name));
|
|
11709
11992
|
if (fileDir !== skillDirPath) {
|
|
11710
11993
|
await ensureDir(fileDir);
|
|
11711
11994
|
}
|
|
11712
11995
|
await writeFileContent(filePath, file.body);
|
|
11713
11996
|
}
|
|
11714
11997
|
return {
|
|
11715
|
-
relativeDirPathFromCwd: (0,
|
|
11998
|
+
relativeDirPathFromCwd: (0, import_node_path93.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
11716
11999
|
frontmatter: skill.getFrontmatter(),
|
|
11717
12000
|
body: skill.getBody(),
|
|
11718
12001
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -11734,13 +12017,13 @@ async function deleteSkill({
|
|
|
11734
12017
|
intendedRootDir: process.cwd()
|
|
11735
12018
|
});
|
|
11736
12019
|
const dirName = extractDirName(relativeDirPathFromCwd);
|
|
11737
|
-
const skillDirPath = (0,
|
|
12020
|
+
const skillDirPath = (0, import_node_path93.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
11738
12021
|
try {
|
|
11739
12022
|
if (await directoryExists(skillDirPath)) {
|
|
11740
12023
|
await removeDirectory(skillDirPath);
|
|
11741
12024
|
}
|
|
11742
12025
|
return {
|
|
11743
|
-
relativeDirPathFromCwd: (0,
|
|
12026
|
+
relativeDirPathFromCwd: (0, import_node_path93.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
11744
12027
|
};
|
|
11745
12028
|
} catch (error) {
|
|
11746
12029
|
throw new Error(
|
|
@@ -11751,29 +12034,29 @@ async function deleteSkill({
|
|
|
11751
12034
|
);
|
|
11752
12035
|
}
|
|
11753
12036
|
}
|
|
11754
|
-
var McpSkillFileSchema =
|
|
11755
|
-
name:
|
|
11756
|
-
body:
|
|
12037
|
+
var McpSkillFileSchema = import_mini44.z.object({
|
|
12038
|
+
name: import_mini44.z.string(),
|
|
12039
|
+
body: import_mini44.z.string()
|
|
11757
12040
|
});
|
|
11758
12041
|
var skillToolSchemas = {
|
|
11759
|
-
listSkills:
|
|
11760
|
-
getSkill:
|
|
11761
|
-
relativeDirPathFromCwd:
|
|
12042
|
+
listSkills: import_mini44.z.object({}),
|
|
12043
|
+
getSkill: import_mini44.z.object({
|
|
12044
|
+
relativeDirPathFromCwd: import_mini44.z.string()
|
|
11762
12045
|
}),
|
|
11763
|
-
putSkill:
|
|
11764
|
-
relativeDirPathFromCwd:
|
|
12046
|
+
putSkill: import_mini44.z.object({
|
|
12047
|
+
relativeDirPathFromCwd: import_mini44.z.string(),
|
|
11765
12048
|
frontmatter: RulesyncSkillFrontmatterSchema,
|
|
11766
|
-
body:
|
|
11767
|
-
otherFiles:
|
|
12049
|
+
body: import_mini44.z.string(),
|
|
12050
|
+
otherFiles: import_mini44.z.optional(import_mini44.z.array(McpSkillFileSchema))
|
|
11768
12051
|
}),
|
|
11769
|
-
deleteSkill:
|
|
11770
|
-
relativeDirPathFromCwd:
|
|
12052
|
+
deleteSkill: import_mini44.z.object({
|
|
12053
|
+
relativeDirPathFromCwd: import_mini44.z.string()
|
|
11771
12054
|
})
|
|
11772
12055
|
};
|
|
11773
12056
|
var skillTools = {
|
|
11774
12057
|
listSkills: {
|
|
11775
12058
|
name: "listSkills",
|
|
11776
|
-
description: `List all skills from ${(0,
|
|
12059
|
+
description: `List all skills from ${(0, import_node_path93.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "*", SKILL_FILE_NAME)} with their frontmatter.`,
|
|
11777
12060
|
parameters: skillToolSchemas.listSkills,
|
|
11778
12061
|
execute: async () => {
|
|
11779
12062
|
const skills = await listSkills();
|
|
@@ -11816,12 +12099,12 @@ var skillTools = {
|
|
|
11816
12099
|
};
|
|
11817
12100
|
|
|
11818
12101
|
// src/mcp/subagents.ts
|
|
11819
|
-
var
|
|
11820
|
-
var
|
|
12102
|
+
var import_node_path94 = require("path");
|
|
12103
|
+
var import_mini45 = require("zod/mini");
|
|
11821
12104
|
var maxSubagentSizeBytes = 1024 * 1024;
|
|
11822
12105
|
var maxSubagentsCount = 1e3;
|
|
11823
12106
|
async function listSubagents() {
|
|
11824
|
-
const subagentsDir = (0,
|
|
12107
|
+
const subagentsDir = (0, import_node_path94.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
11825
12108
|
try {
|
|
11826
12109
|
const files = await listDirectoryFiles(subagentsDir);
|
|
11827
12110
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -11834,7 +12117,7 @@ async function listSubagents() {
|
|
|
11834
12117
|
});
|
|
11835
12118
|
const frontmatter = subagent.getFrontmatter();
|
|
11836
12119
|
return {
|
|
11837
|
-
relativePathFromCwd: (0,
|
|
12120
|
+
relativePathFromCwd: (0, import_node_path94.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, file),
|
|
11838
12121
|
frontmatter
|
|
11839
12122
|
};
|
|
11840
12123
|
} catch (error) {
|
|
@@ -11856,14 +12139,14 @@ async function getSubagent({ relativePathFromCwd }) {
|
|
|
11856
12139
|
relativePath: relativePathFromCwd,
|
|
11857
12140
|
intendedRootDir: process.cwd()
|
|
11858
12141
|
});
|
|
11859
|
-
const filename = (0,
|
|
12142
|
+
const filename = (0, import_node_path94.basename)(relativePathFromCwd);
|
|
11860
12143
|
try {
|
|
11861
12144
|
const subagent = await RulesyncSubagent.fromFile({
|
|
11862
12145
|
relativeFilePath: filename,
|
|
11863
12146
|
validate: true
|
|
11864
12147
|
});
|
|
11865
12148
|
return {
|
|
11866
|
-
relativePathFromCwd: (0,
|
|
12149
|
+
relativePathFromCwd: (0, import_node_path94.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
11867
12150
|
frontmatter: subagent.getFrontmatter(),
|
|
11868
12151
|
body: subagent.getBody()
|
|
11869
12152
|
};
|
|
@@ -11882,7 +12165,7 @@ async function putSubagent({
|
|
|
11882
12165
|
relativePath: relativePathFromCwd,
|
|
11883
12166
|
intendedRootDir: process.cwd()
|
|
11884
12167
|
});
|
|
11885
|
-
const filename = (0,
|
|
12168
|
+
const filename = (0, import_node_path94.basename)(relativePathFromCwd);
|
|
11886
12169
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
11887
12170
|
if (estimatedSize > maxSubagentSizeBytes) {
|
|
11888
12171
|
throw new Error(
|
|
@@ -11892,7 +12175,7 @@ async function putSubagent({
|
|
|
11892
12175
|
try {
|
|
11893
12176
|
const existingSubagents = await listSubagents();
|
|
11894
12177
|
const isUpdate = existingSubagents.some(
|
|
11895
|
-
(subagent2) => subagent2.relativePathFromCwd === (0,
|
|
12178
|
+
(subagent2) => subagent2.relativePathFromCwd === (0, import_node_path94.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
11896
12179
|
);
|
|
11897
12180
|
if (!isUpdate && existingSubagents.length >= maxSubagentsCount) {
|
|
11898
12181
|
throw new Error(`Maximum number of subagents (${maxSubagentsCount}) reached`);
|
|
@@ -11905,11 +12188,11 @@ async function putSubagent({
|
|
|
11905
12188
|
body,
|
|
11906
12189
|
validate: true
|
|
11907
12190
|
});
|
|
11908
|
-
const subagentsDir = (0,
|
|
12191
|
+
const subagentsDir = (0, import_node_path94.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
11909
12192
|
await ensureDir(subagentsDir);
|
|
11910
12193
|
await writeFileContent(subagent.getFilePath(), subagent.getFileContent());
|
|
11911
12194
|
return {
|
|
11912
|
-
relativePathFromCwd: (0,
|
|
12195
|
+
relativePathFromCwd: (0, import_node_path94.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
11913
12196
|
frontmatter: subagent.getFrontmatter(),
|
|
11914
12197
|
body: subagent.getBody()
|
|
11915
12198
|
};
|
|
@@ -11924,12 +12207,12 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
11924
12207
|
relativePath: relativePathFromCwd,
|
|
11925
12208
|
intendedRootDir: process.cwd()
|
|
11926
12209
|
});
|
|
11927
|
-
const filename = (0,
|
|
11928
|
-
const fullPath = (0,
|
|
12210
|
+
const filename = (0, import_node_path94.basename)(relativePathFromCwd);
|
|
12211
|
+
const fullPath = (0, import_node_path94.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename);
|
|
11929
12212
|
try {
|
|
11930
12213
|
await removeFile(fullPath);
|
|
11931
12214
|
return {
|
|
11932
|
-
relativePathFromCwd: (0,
|
|
12215
|
+
relativePathFromCwd: (0, import_node_path94.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
11933
12216
|
};
|
|
11934
12217
|
} catch (error) {
|
|
11935
12218
|
throw new Error(
|
|
@@ -11941,23 +12224,23 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
11941
12224
|
}
|
|
11942
12225
|
}
|
|
11943
12226
|
var subagentToolSchemas = {
|
|
11944
|
-
listSubagents:
|
|
11945
|
-
getSubagent:
|
|
11946
|
-
relativePathFromCwd:
|
|
12227
|
+
listSubagents: import_mini45.z.object({}),
|
|
12228
|
+
getSubagent: import_mini45.z.object({
|
|
12229
|
+
relativePathFromCwd: import_mini45.z.string()
|
|
11947
12230
|
}),
|
|
11948
|
-
putSubagent:
|
|
11949
|
-
relativePathFromCwd:
|
|
12231
|
+
putSubagent: import_mini45.z.object({
|
|
12232
|
+
relativePathFromCwd: import_mini45.z.string(),
|
|
11950
12233
|
frontmatter: RulesyncSubagentFrontmatterSchema,
|
|
11951
|
-
body:
|
|
12234
|
+
body: import_mini45.z.string()
|
|
11952
12235
|
}),
|
|
11953
|
-
deleteSubagent:
|
|
11954
|
-
relativePathFromCwd:
|
|
12236
|
+
deleteSubagent: import_mini45.z.object({
|
|
12237
|
+
relativePathFromCwd: import_mini45.z.string()
|
|
11955
12238
|
})
|
|
11956
12239
|
};
|
|
11957
12240
|
var subagentTools = {
|
|
11958
12241
|
listSubagents: {
|
|
11959
12242
|
name: "listSubagents",
|
|
11960
|
-
description: `List all subagents from ${(0,
|
|
12243
|
+
description: `List all subagents from ${(0, import_node_path94.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
11961
12244
|
parameters: subagentToolSchemas.listSubagents,
|
|
11962
12245
|
execute: async () => {
|
|
11963
12246
|
const subagents = await listSubagents();
|
|
@@ -11998,6 +12281,200 @@ var subagentTools = {
|
|
|
11998
12281
|
}
|
|
11999
12282
|
};
|
|
12000
12283
|
|
|
12284
|
+
// src/mcp/tools.ts
|
|
12285
|
+
var rulesyncFeatureSchema = import_mini46.z.enum(["rule", "command", "subagent", "skill", "ignore", "mcp"]);
|
|
12286
|
+
var rulesyncOperationSchema = import_mini46.z.enum(["list", "get", "put", "delete"]);
|
|
12287
|
+
var skillFileSchema = import_mini46.z.object({
|
|
12288
|
+
name: import_mini46.z.string(),
|
|
12289
|
+
body: import_mini46.z.string()
|
|
12290
|
+
});
|
|
12291
|
+
var rulesyncToolSchema = import_mini46.z.object({
|
|
12292
|
+
feature: rulesyncFeatureSchema,
|
|
12293
|
+
operation: rulesyncOperationSchema,
|
|
12294
|
+
targetPathFromCwd: import_mini46.z.optional(import_mini46.z.string()),
|
|
12295
|
+
frontmatter: import_mini46.z.optional(import_mini46.z.unknown()),
|
|
12296
|
+
body: import_mini46.z.optional(import_mini46.z.string()),
|
|
12297
|
+
otherFiles: import_mini46.z.optional(import_mini46.z.array(skillFileSchema)),
|
|
12298
|
+
content: import_mini46.z.optional(import_mini46.z.string())
|
|
12299
|
+
});
|
|
12300
|
+
var supportedOperationsByFeature = {
|
|
12301
|
+
rule: ["list", "get", "put", "delete"],
|
|
12302
|
+
command: ["list", "get", "put", "delete"],
|
|
12303
|
+
subagent: ["list", "get", "put", "delete"],
|
|
12304
|
+
skill: ["list", "get", "put", "delete"],
|
|
12305
|
+
ignore: ["get", "put", "delete"],
|
|
12306
|
+
mcp: ["get", "put", "delete"]
|
|
12307
|
+
};
|
|
12308
|
+
function assertSupported({
|
|
12309
|
+
feature,
|
|
12310
|
+
operation
|
|
12311
|
+
}) {
|
|
12312
|
+
const supportedOperations = supportedOperationsByFeature[feature];
|
|
12313
|
+
if (!supportedOperations.includes(operation)) {
|
|
12314
|
+
throw new Error(
|
|
12315
|
+
`Operation ${operation} is not supported for feature ${feature}. Supported operations: ${supportedOperations.join(
|
|
12316
|
+
", "
|
|
12317
|
+
)}`
|
|
12318
|
+
);
|
|
12319
|
+
}
|
|
12320
|
+
}
|
|
12321
|
+
function requireTargetPath({ targetPathFromCwd, feature, operation }) {
|
|
12322
|
+
if (!targetPathFromCwd) {
|
|
12323
|
+
throw new Error(`targetPathFromCwd is required for ${feature} ${operation} operation`);
|
|
12324
|
+
}
|
|
12325
|
+
return targetPathFromCwd;
|
|
12326
|
+
}
|
|
12327
|
+
function parseFrontmatter2({
|
|
12328
|
+
feature,
|
|
12329
|
+
frontmatter
|
|
12330
|
+
}) {
|
|
12331
|
+
switch (feature) {
|
|
12332
|
+
case "rule": {
|
|
12333
|
+
return RulesyncRuleFrontmatterSchema.parse(frontmatter);
|
|
12334
|
+
}
|
|
12335
|
+
case "command": {
|
|
12336
|
+
return RulesyncCommandFrontmatterSchema.parse(frontmatter);
|
|
12337
|
+
}
|
|
12338
|
+
case "subagent": {
|
|
12339
|
+
return RulesyncSubagentFrontmatterSchema.parse(frontmatter);
|
|
12340
|
+
}
|
|
12341
|
+
case "skill": {
|
|
12342
|
+
return RulesyncSkillFrontmatterSchema.parse(frontmatter);
|
|
12343
|
+
}
|
|
12344
|
+
}
|
|
12345
|
+
}
|
|
12346
|
+
function ensureBody({ body, feature, operation }) {
|
|
12347
|
+
if (!body) {
|
|
12348
|
+
throw new Error(`body is required for ${feature} ${operation} operation`);
|
|
12349
|
+
}
|
|
12350
|
+
return body;
|
|
12351
|
+
}
|
|
12352
|
+
var rulesyncTool = {
|
|
12353
|
+
name: "rulesyncTool",
|
|
12354
|
+
description: "Manage Rulesync files through a single MCP tool. Features: rule/command/subagent/skill support list/get/put/delete; ignore/mcp support get/put/delete only. Parameters: list requires no targetPathFromCwd (lists all items); get/delete require targetPathFromCwd; put requires targetPathFromCwd, frontmatter, and body (or content for ignore/mcp).",
|
|
12355
|
+
parameters: rulesyncToolSchema,
|
|
12356
|
+
execute: async (args) => {
|
|
12357
|
+
const parsed = rulesyncToolSchema.parse(args);
|
|
12358
|
+
assertSupported({ feature: parsed.feature, operation: parsed.operation });
|
|
12359
|
+
switch (parsed.feature) {
|
|
12360
|
+
case "rule": {
|
|
12361
|
+
if (parsed.operation === "list") {
|
|
12362
|
+
return ruleTools.listRules.execute();
|
|
12363
|
+
}
|
|
12364
|
+
if (parsed.operation === "get") {
|
|
12365
|
+
return ruleTools.getRule.execute({ relativePathFromCwd: requireTargetPath(parsed) });
|
|
12366
|
+
}
|
|
12367
|
+
if (parsed.operation === "put") {
|
|
12368
|
+
return ruleTools.putRule.execute({
|
|
12369
|
+
relativePathFromCwd: requireTargetPath(parsed),
|
|
12370
|
+
frontmatter: parseFrontmatter2({
|
|
12371
|
+
feature: "rule",
|
|
12372
|
+
frontmatter: parsed.frontmatter ?? {}
|
|
12373
|
+
}),
|
|
12374
|
+
body: ensureBody(parsed)
|
|
12375
|
+
});
|
|
12376
|
+
}
|
|
12377
|
+
return ruleTools.deleteRule.execute({ relativePathFromCwd: requireTargetPath(parsed) });
|
|
12378
|
+
}
|
|
12379
|
+
case "command": {
|
|
12380
|
+
if (parsed.operation === "list") {
|
|
12381
|
+
return commandTools.listCommands.execute();
|
|
12382
|
+
}
|
|
12383
|
+
if (parsed.operation === "get") {
|
|
12384
|
+
return commandTools.getCommand.execute({
|
|
12385
|
+
relativePathFromCwd: requireTargetPath(parsed)
|
|
12386
|
+
});
|
|
12387
|
+
}
|
|
12388
|
+
if (parsed.operation === "put") {
|
|
12389
|
+
return commandTools.putCommand.execute({
|
|
12390
|
+
relativePathFromCwd: requireTargetPath(parsed),
|
|
12391
|
+
frontmatter: parseFrontmatter2({
|
|
12392
|
+
feature: "command",
|
|
12393
|
+
frontmatter: parsed.frontmatter ?? {}
|
|
12394
|
+
}),
|
|
12395
|
+
body: ensureBody(parsed)
|
|
12396
|
+
});
|
|
12397
|
+
}
|
|
12398
|
+
return commandTools.deleteCommand.execute({
|
|
12399
|
+
relativePathFromCwd: requireTargetPath(parsed)
|
|
12400
|
+
});
|
|
12401
|
+
}
|
|
12402
|
+
case "subagent": {
|
|
12403
|
+
if (parsed.operation === "list") {
|
|
12404
|
+
return subagentTools.listSubagents.execute();
|
|
12405
|
+
}
|
|
12406
|
+
if (parsed.operation === "get") {
|
|
12407
|
+
return subagentTools.getSubagent.execute({
|
|
12408
|
+
relativePathFromCwd: requireTargetPath(parsed)
|
|
12409
|
+
});
|
|
12410
|
+
}
|
|
12411
|
+
if (parsed.operation === "put") {
|
|
12412
|
+
return subagentTools.putSubagent.execute({
|
|
12413
|
+
relativePathFromCwd: requireTargetPath(parsed),
|
|
12414
|
+
frontmatter: parseFrontmatter2({
|
|
12415
|
+
feature: "subagent",
|
|
12416
|
+
frontmatter: parsed.frontmatter ?? {}
|
|
12417
|
+
}),
|
|
12418
|
+
body: ensureBody(parsed)
|
|
12419
|
+
});
|
|
12420
|
+
}
|
|
12421
|
+
return subagentTools.deleteSubagent.execute({
|
|
12422
|
+
relativePathFromCwd: requireTargetPath(parsed)
|
|
12423
|
+
});
|
|
12424
|
+
}
|
|
12425
|
+
case "skill": {
|
|
12426
|
+
if (parsed.operation === "list") {
|
|
12427
|
+
return skillTools.listSkills.execute();
|
|
12428
|
+
}
|
|
12429
|
+
if (parsed.operation === "get") {
|
|
12430
|
+
return skillTools.getSkill.execute({ relativeDirPathFromCwd: requireTargetPath(parsed) });
|
|
12431
|
+
}
|
|
12432
|
+
if (parsed.operation === "put") {
|
|
12433
|
+
return skillTools.putSkill.execute({
|
|
12434
|
+
relativeDirPathFromCwd: requireTargetPath(parsed),
|
|
12435
|
+
frontmatter: parseFrontmatter2({
|
|
12436
|
+
feature: "skill",
|
|
12437
|
+
frontmatter: parsed.frontmatter ?? {}
|
|
12438
|
+
}),
|
|
12439
|
+
body: ensureBody(parsed),
|
|
12440
|
+
otherFiles: parsed.otherFiles ?? []
|
|
12441
|
+
});
|
|
12442
|
+
}
|
|
12443
|
+
return skillTools.deleteSkill.execute({
|
|
12444
|
+
relativeDirPathFromCwd: requireTargetPath(parsed)
|
|
12445
|
+
});
|
|
12446
|
+
}
|
|
12447
|
+
case "ignore": {
|
|
12448
|
+
if (parsed.operation === "get") {
|
|
12449
|
+
return ignoreTools.getIgnoreFile.execute();
|
|
12450
|
+
}
|
|
12451
|
+
if (parsed.operation === "put") {
|
|
12452
|
+
if (!parsed.content) {
|
|
12453
|
+
throw new Error("content is required for ignore put operation");
|
|
12454
|
+
}
|
|
12455
|
+
return ignoreTools.putIgnoreFile.execute({ content: parsed.content });
|
|
12456
|
+
}
|
|
12457
|
+
return ignoreTools.deleteIgnoreFile.execute();
|
|
12458
|
+
}
|
|
12459
|
+
case "mcp": {
|
|
12460
|
+
if (parsed.operation === "get") {
|
|
12461
|
+
return mcpTools.getMcpFile.execute();
|
|
12462
|
+
}
|
|
12463
|
+
if (parsed.operation === "put") {
|
|
12464
|
+
if (!parsed.content) {
|
|
12465
|
+
throw new Error("content is required for mcp put operation");
|
|
12466
|
+
}
|
|
12467
|
+
return mcpTools.putMcpFile.execute({ content: parsed.content });
|
|
12468
|
+
}
|
|
12469
|
+
return mcpTools.deleteMcpFile.execute();
|
|
12470
|
+
}
|
|
12471
|
+
default: {
|
|
12472
|
+
throw new Error(`Unknown feature: ${parsed.feature}`);
|
|
12473
|
+
}
|
|
12474
|
+
}
|
|
12475
|
+
}
|
|
12476
|
+
};
|
|
12477
|
+
|
|
12001
12478
|
// src/cli/commands/mcp.ts
|
|
12002
12479
|
async function mcpCommand({ version }) {
|
|
12003
12480
|
const server = new import_fastmcp.FastMCP({
|
|
@@ -12006,28 +12483,7 @@ async function mcpCommand({ version }) {
|
|
|
12006
12483
|
version,
|
|
12007
12484
|
instructions: "This server handles Rulesync files including rules, commands, MCP, ignore files, subagents and skills for any AI agents. It should be used when you need those files."
|
|
12008
12485
|
});
|
|
12009
|
-
server.addTool(
|
|
12010
|
-
server.addTool(ruleTools.getRule);
|
|
12011
|
-
server.addTool(ruleTools.putRule);
|
|
12012
|
-
server.addTool(ruleTools.deleteRule);
|
|
12013
|
-
server.addTool(commandTools.listCommands);
|
|
12014
|
-
server.addTool(commandTools.getCommand);
|
|
12015
|
-
server.addTool(commandTools.putCommand);
|
|
12016
|
-
server.addTool(commandTools.deleteCommand);
|
|
12017
|
-
server.addTool(subagentTools.listSubagents);
|
|
12018
|
-
server.addTool(subagentTools.getSubagent);
|
|
12019
|
-
server.addTool(subagentTools.putSubagent);
|
|
12020
|
-
server.addTool(subagentTools.deleteSubagent);
|
|
12021
|
-
server.addTool(skillTools.listSkills);
|
|
12022
|
-
server.addTool(skillTools.getSkill);
|
|
12023
|
-
server.addTool(skillTools.putSkill);
|
|
12024
|
-
server.addTool(skillTools.deleteSkill);
|
|
12025
|
-
server.addTool(ignoreTools.getIgnoreFile);
|
|
12026
|
-
server.addTool(ignoreTools.putIgnoreFile);
|
|
12027
|
-
server.addTool(ignoreTools.deleteIgnoreFile);
|
|
12028
|
-
server.addTool(mcpTools.getMcpFile);
|
|
12029
|
-
server.addTool(mcpTools.putMcpFile);
|
|
12030
|
-
server.addTool(mcpTools.deleteMcpFile);
|
|
12486
|
+
server.addTool(rulesyncTool);
|
|
12031
12487
|
logger.info("Rulesync MCP server started via stdio");
|
|
12032
12488
|
void server.start({
|
|
12033
12489
|
transportType: "stdio"
|
|
@@ -12035,7 +12491,7 @@ async function mcpCommand({ version }) {
|
|
|
12035
12491
|
}
|
|
12036
12492
|
|
|
12037
12493
|
// src/cli/index.ts
|
|
12038
|
-
var getVersion = () => "4.
|
|
12494
|
+
var getVersion = () => "4.3.0";
|
|
12039
12495
|
var main = async () => {
|
|
12040
12496
|
const program = new import_commander.Command();
|
|
12041
12497
|
const version = getVersion();
|