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.js
CHANGED
|
@@ -4704,9 +4704,9 @@ var McpProcessor = class extends FeatureProcessor {
|
|
|
4704
4704
|
};
|
|
4705
4705
|
|
|
4706
4706
|
// src/features/rules/rules-processor.ts
|
|
4707
|
-
import { basename as
|
|
4707
|
+
import { basename as basename21, join as join84 } from "path";
|
|
4708
4708
|
import { encode } from "@toon-format/toon";
|
|
4709
|
-
import { z as
|
|
4709
|
+
import { z as z39 } from "zod/mini";
|
|
4710
4710
|
|
|
4711
4711
|
// src/constants/general.ts
|
|
4712
4712
|
var SKILL_FILE_NAME = "SKILL.md";
|
|
@@ -5137,48 +5137,293 @@ var AgentsmdSkill = class _AgentsmdSkill extends SimulatedSkill {
|
|
|
5137
5137
|
};
|
|
5138
5138
|
|
|
5139
5139
|
// src/features/skills/cursor-skill.ts
|
|
5140
|
+
import { join as join44 } from "path";
|
|
5141
|
+
import { z as z21 } from "zod/mini";
|
|
5142
|
+
|
|
5143
|
+
// src/features/skills/rulesync-skill.ts
|
|
5140
5144
|
import { join as join43 } from "path";
|
|
5141
|
-
|
|
5145
|
+
import { z as z20 } from "zod/mini";
|
|
5146
|
+
var RulesyncSkillFrontmatterSchemaInternal = z20.looseObject({
|
|
5147
|
+
name: z20.string(),
|
|
5148
|
+
description: z20.string(),
|
|
5149
|
+
targets: z20._default(RulesyncTargetsSchema, ["*"]),
|
|
5150
|
+
claudecode: z20.optional(
|
|
5151
|
+
z20.looseObject({
|
|
5152
|
+
"allowed-tools": z20.optional(z20.array(z20.string()))
|
|
5153
|
+
})
|
|
5154
|
+
),
|
|
5155
|
+
opencode: z20.optional(
|
|
5156
|
+
z20.looseObject({
|
|
5157
|
+
"allowed-tools": z20.optional(z20.array(z20.string()))
|
|
5158
|
+
})
|
|
5159
|
+
),
|
|
5160
|
+
copilot: z20.optional(
|
|
5161
|
+
z20.looseObject({
|
|
5162
|
+
license: z20.optional(z20.string())
|
|
5163
|
+
})
|
|
5164
|
+
)
|
|
5165
|
+
});
|
|
5166
|
+
var RulesyncSkillFrontmatterSchema = RulesyncSkillFrontmatterSchemaInternal;
|
|
5167
|
+
var RulesyncSkill = class _RulesyncSkill extends AiDir {
|
|
5168
|
+
constructor({
|
|
5169
|
+
baseDir = process.cwd(),
|
|
5170
|
+
relativeDirPath = RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
5171
|
+
dirName,
|
|
5172
|
+
frontmatter,
|
|
5173
|
+
body,
|
|
5174
|
+
otherFiles = [],
|
|
5175
|
+
validate = true,
|
|
5176
|
+
global = false
|
|
5177
|
+
}) {
|
|
5178
|
+
super({
|
|
5179
|
+
baseDir,
|
|
5180
|
+
relativeDirPath,
|
|
5181
|
+
dirName,
|
|
5182
|
+
mainFile: {
|
|
5183
|
+
name: SKILL_FILE_NAME,
|
|
5184
|
+
body,
|
|
5185
|
+
frontmatter: { ...frontmatter }
|
|
5186
|
+
},
|
|
5187
|
+
otherFiles,
|
|
5188
|
+
global
|
|
5189
|
+
});
|
|
5190
|
+
if (validate) {
|
|
5191
|
+
const result = this.validate();
|
|
5192
|
+
if (!result.success) {
|
|
5193
|
+
throw result.error;
|
|
5194
|
+
}
|
|
5195
|
+
}
|
|
5196
|
+
}
|
|
5197
|
+
static getSettablePaths() {
|
|
5198
|
+
return {
|
|
5199
|
+
relativeDirPath: RULESYNC_SKILLS_RELATIVE_DIR_PATH
|
|
5200
|
+
};
|
|
5201
|
+
}
|
|
5202
|
+
getFrontmatter() {
|
|
5203
|
+
if (!this.mainFile?.frontmatter) {
|
|
5204
|
+
throw new Error("Frontmatter is not defined");
|
|
5205
|
+
}
|
|
5206
|
+
const result = RulesyncSkillFrontmatterSchema.parse(this.mainFile.frontmatter);
|
|
5207
|
+
return result;
|
|
5208
|
+
}
|
|
5209
|
+
getBody() {
|
|
5210
|
+
return this.mainFile?.body ?? "";
|
|
5211
|
+
}
|
|
5212
|
+
validate() {
|
|
5213
|
+
const result = RulesyncSkillFrontmatterSchema.safeParse(this.mainFile?.frontmatter);
|
|
5214
|
+
if (!result.success) {
|
|
5215
|
+
return {
|
|
5216
|
+
success: false,
|
|
5217
|
+
error: new Error(
|
|
5218
|
+
`Invalid frontmatter in ${this.getDirPath()}: ${formatError(result.error)}`
|
|
5219
|
+
)
|
|
5220
|
+
};
|
|
5221
|
+
}
|
|
5222
|
+
return { success: true, error: null };
|
|
5223
|
+
}
|
|
5224
|
+
static async fromDir({
|
|
5225
|
+
baseDir = process.cwd(),
|
|
5226
|
+
relativeDirPath = RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
5227
|
+
dirName,
|
|
5228
|
+
global = false
|
|
5229
|
+
}) {
|
|
5230
|
+
const skillDirPath = join43(baseDir, relativeDirPath, dirName);
|
|
5231
|
+
const skillFilePath = join43(skillDirPath, SKILL_FILE_NAME);
|
|
5232
|
+
if (!await fileExists(skillFilePath)) {
|
|
5233
|
+
throw new Error(`${SKILL_FILE_NAME} not found in ${skillDirPath}`);
|
|
5234
|
+
}
|
|
5235
|
+
const fileContent = await readFileContent(skillFilePath);
|
|
5236
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
5237
|
+
const result = RulesyncSkillFrontmatterSchema.safeParse(frontmatter);
|
|
5238
|
+
if (!result.success) {
|
|
5239
|
+
throw new Error(`Invalid frontmatter in ${skillFilePath}: ${formatError(result.error)}`);
|
|
5240
|
+
}
|
|
5241
|
+
const otherFiles = await this.collectOtherFiles(
|
|
5242
|
+
baseDir,
|
|
5243
|
+
relativeDirPath,
|
|
5244
|
+
dirName,
|
|
5245
|
+
SKILL_FILE_NAME
|
|
5246
|
+
);
|
|
5247
|
+
return new _RulesyncSkill({
|
|
5248
|
+
baseDir,
|
|
5249
|
+
relativeDirPath,
|
|
5250
|
+
dirName,
|
|
5251
|
+
frontmatter: result.data,
|
|
5252
|
+
body: content.trim(),
|
|
5253
|
+
otherFiles,
|
|
5254
|
+
validate: true,
|
|
5255
|
+
global
|
|
5256
|
+
});
|
|
5257
|
+
}
|
|
5258
|
+
};
|
|
5259
|
+
|
|
5260
|
+
// src/features/skills/cursor-skill.ts
|
|
5261
|
+
var CursorSkillFrontmatterSchema = z21.looseObject({
|
|
5262
|
+
name: z21.string(),
|
|
5263
|
+
description: z21.string()
|
|
5264
|
+
});
|
|
5265
|
+
var CursorSkill = class _CursorSkill extends ToolSkill {
|
|
5266
|
+
constructor({
|
|
5267
|
+
baseDir = process.cwd(),
|
|
5268
|
+
relativeDirPath = join44(".cursor", "skills"),
|
|
5269
|
+
dirName,
|
|
5270
|
+
frontmatter,
|
|
5271
|
+
body,
|
|
5272
|
+
otherFiles = [],
|
|
5273
|
+
validate = true,
|
|
5274
|
+
global = false
|
|
5275
|
+
}) {
|
|
5276
|
+
super({
|
|
5277
|
+
baseDir,
|
|
5278
|
+
relativeDirPath,
|
|
5279
|
+
dirName,
|
|
5280
|
+
mainFile: {
|
|
5281
|
+
name: SKILL_FILE_NAME,
|
|
5282
|
+
body,
|
|
5283
|
+
frontmatter: { ...frontmatter }
|
|
5284
|
+
},
|
|
5285
|
+
otherFiles,
|
|
5286
|
+
global
|
|
5287
|
+
});
|
|
5288
|
+
if (validate) {
|
|
5289
|
+
const result = this.validate();
|
|
5290
|
+
if (!result.success) {
|
|
5291
|
+
throw result.error;
|
|
5292
|
+
}
|
|
5293
|
+
}
|
|
5294
|
+
}
|
|
5142
5295
|
static getSettablePaths(options) {
|
|
5143
5296
|
if (options?.global) {
|
|
5144
5297
|
throw new Error("CursorSkill does not support global mode.");
|
|
5145
5298
|
}
|
|
5146
5299
|
return {
|
|
5147
|
-
relativeDirPath:
|
|
5300
|
+
relativeDirPath: join44(".cursor", "skills")
|
|
5148
5301
|
};
|
|
5149
5302
|
}
|
|
5150
|
-
|
|
5151
|
-
|
|
5152
|
-
|
|
5303
|
+
getFrontmatter() {
|
|
5304
|
+
if (!this.mainFile?.frontmatter) {
|
|
5305
|
+
throw new Error("Frontmatter is not defined");
|
|
5306
|
+
}
|
|
5307
|
+
const result = CursorSkillFrontmatterSchema.parse(this.mainFile.frontmatter);
|
|
5308
|
+
return result;
|
|
5153
5309
|
}
|
|
5154
|
-
|
|
5155
|
-
|
|
5156
|
-
|
|
5157
|
-
|
|
5310
|
+
getBody() {
|
|
5311
|
+
return this.mainFile?.body ?? "";
|
|
5312
|
+
}
|
|
5313
|
+
validate() {
|
|
5314
|
+
if (!this.mainFile) {
|
|
5315
|
+
return {
|
|
5316
|
+
success: false,
|
|
5317
|
+
error: new Error(`${this.getDirPath()}: ${SKILL_FILE_NAME} file does not exist`)
|
|
5318
|
+
};
|
|
5319
|
+
}
|
|
5320
|
+
const result = CursorSkillFrontmatterSchema.safeParse(this.mainFile.frontmatter);
|
|
5321
|
+
if (!result.success) {
|
|
5322
|
+
return {
|
|
5323
|
+
success: false,
|
|
5324
|
+
error: new Error(
|
|
5325
|
+
`Invalid frontmatter in ${this.getDirPath()}: ${formatError(result.error)}`
|
|
5326
|
+
)
|
|
5327
|
+
};
|
|
5328
|
+
}
|
|
5329
|
+
return { success: true, error: null };
|
|
5330
|
+
}
|
|
5331
|
+
toRulesyncSkill() {
|
|
5332
|
+
const frontmatter = this.getFrontmatter();
|
|
5333
|
+
const rulesyncFrontmatter = {
|
|
5334
|
+
name: frontmatter.name,
|
|
5335
|
+
description: frontmatter.description,
|
|
5336
|
+
targets: ["*"]
|
|
5337
|
+
};
|
|
5338
|
+
return new RulesyncSkill({
|
|
5339
|
+
baseDir: this.baseDir,
|
|
5340
|
+
relativeDirPath: this.relativeDirPath,
|
|
5341
|
+
dirName: this.getDirName(),
|
|
5342
|
+
frontmatter: rulesyncFrontmatter,
|
|
5343
|
+
body: this.getBody(),
|
|
5344
|
+
otherFiles: this.getOtherFiles(),
|
|
5345
|
+
validate: true,
|
|
5346
|
+
global: this.global
|
|
5347
|
+
});
|
|
5348
|
+
}
|
|
5349
|
+
static fromRulesyncSkill({
|
|
5350
|
+
rulesyncSkill,
|
|
5351
|
+
validate = true,
|
|
5352
|
+
global = false
|
|
5353
|
+
}) {
|
|
5354
|
+
const settablePaths = _CursorSkill.getSettablePaths({ global });
|
|
5355
|
+
const rulesyncFrontmatter = rulesyncSkill.getFrontmatter();
|
|
5356
|
+
const cursorFrontmatter = {
|
|
5357
|
+
name: rulesyncFrontmatter.name,
|
|
5358
|
+
description: rulesyncFrontmatter.description
|
|
5158
5359
|
};
|
|
5159
|
-
return new _CursorSkill(
|
|
5360
|
+
return new _CursorSkill({
|
|
5361
|
+
baseDir: rulesyncSkill.getBaseDir(),
|
|
5362
|
+
relativeDirPath: settablePaths.relativeDirPath,
|
|
5363
|
+
dirName: rulesyncSkill.getDirName(),
|
|
5364
|
+
frontmatter: cursorFrontmatter,
|
|
5365
|
+
body: rulesyncSkill.getBody(),
|
|
5366
|
+
otherFiles: rulesyncSkill.getOtherFiles(),
|
|
5367
|
+
validate,
|
|
5368
|
+
global
|
|
5369
|
+
});
|
|
5160
5370
|
}
|
|
5161
5371
|
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
5162
|
-
|
|
5163
|
-
|
|
5164
|
-
|
|
5372
|
+
const targets = rulesyncSkill.getFrontmatter().targets;
|
|
5373
|
+
return targets.includes("*") || targets.includes("cursor");
|
|
5374
|
+
}
|
|
5375
|
+
static async fromDir(params) {
|
|
5376
|
+
const loaded = await this.loadSkillDirContent({
|
|
5377
|
+
...params,
|
|
5378
|
+
getSettablePaths: _CursorSkill.getSettablePaths
|
|
5379
|
+
});
|
|
5380
|
+
const result = CursorSkillFrontmatterSchema.safeParse(loaded.frontmatter);
|
|
5381
|
+
if (!result.success) {
|
|
5382
|
+
const skillDirPath = join44(loaded.baseDir, loaded.relativeDirPath, loaded.dirName);
|
|
5383
|
+
throw new Error(
|
|
5384
|
+
`Invalid frontmatter in ${join44(skillDirPath, SKILL_FILE_NAME)}: ${formatError(result.error)}`
|
|
5385
|
+
);
|
|
5386
|
+
}
|
|
5387
|
+
return new _CursorSkill({
|
|
5388
|
+
baseDir: loaded.baseDir,
|
|
5389
|
+
relativeDirPath: loaded.relativeDirPath,
|
|
5390
|
+
dirName: loaded.dirName,
|
|
5391
|
+
frontmatter: result.data,
|
|
5392
|
+
body: loaded.body,
|
|
5393
|
+
otherFiles: loaded.otherFiles,
|
|
5394
|
+
validate: true,
|
|
5395
|
+
global: loaded.global
|
|
5165
5396
|
});
|
|
5166
5397
|
}
|
|
5167
|
-
static forDeletion(
|
|
5168
|
-
|
|
5169
|
-
|
|
5398
|
+
static forDeletion({
|
|
5399
|
+
baseDir = process.cwd(),
|
|
5400
|
+
relativeDirPath,
|
|
5401
|
+
dirName,
|
|
5402
|
+
global = false
|
|
5403
|
+
}) {
|
|
5404
|
+
const settablePaths = _CursorSkill.getSettablePaths({ global });
|
|
5405
|
+
return new _CursorSkill({
|
|
5406
|
+
baseDir,
|
|
5407
|
+
relativeDirPath: relativeDirPath ?? settablePaths.relativeDirPath,
|
|
5408
|
+
dirName,
|
|
5409
|
+
frontmatter: { name: "", description: "" },
|
|
5410
|
+
body: "",
|
|
5411
|
+
otherFiles: [],
|
|
5412
|
+
validate: false,
|
|
5413
|
+
global
|
|
5414
|
+
});
|
|
5170
5415
|
}
|
|
5171
5416
|
};
|
|
5172
5417
|
|
|
5173
5418
|
// src/features/skills/geminicli-skill.ts
|
|
5174
|
-
import { join as
|
|
5419
|
+
import { join as join45 } from "path";
|
|
5175
5420
|
var GeminiCliSkill = class _GeminiCliSkill extends SimulatedSkill {
|
|
5176
5421
|
static getSettablePaths(options) {
|
|
5177
5422
|
if (options?.global) {
|
|
5178
5423
|
throw new Error("GeminiCliSkill does not support global mode.");
|
|
5179
5424
|
}
|
|
5180
5425
|
return {
|
|
5181
|
-
relativeDirPath:
|
|
5426
|
+
relativeDirPath: join45(".gemini", "skills")
|
|
5182
5427
|
};
|
|
5183
5428
|
}
|
|
5184
5429
|
static async fromDir(params) {
|
|
@@ -5206,10 +5451,10 @@ var GeminiCliSkill = class _GeminiCliSkill extends SimulatedSkill {
|
|
|
5206
5451
|
|
|
5207
5452
|
// src/features/skills/skills-processor.ts
|
|
5208
5453
|
import { basename as basename14, join as join51 } from "path";
|
|
5209
|
-
import { z as
|
|
5454
|
+
import { z as z26 } from "zod/mini";
|
|
5210
5455
|
|
|
5211
5456
|
// src/types/dir-feature-processor.ts
|
|
5212
|
-
import { join as
|
|
5457
|
+
import { join as join46 } from "path";
|
|
5213
5458
|
var DirFeatureProcessor = class {
|
|
5214
5459
|
baseDir;
|
|
5215
5460
|
constructor({ baseDir = process.cwd() }) {
|
|
@@ -5231,153 +5476,34 @@ var DirFeatureProcessor = class {
|
|
|
5231
5476
|
await ensureDir(dirPath);
|
|
5232
5477
|
const mainFile = aiDir.getMainFile();
|
|
5233
5478
|
if (mainFile) {
|
|
5234
|
-
const mainFilePath =
|
|
5479
|
+
const mainFilePath = join46(dirPath, mainFile.name);
|
|
5235
5480
|
const content = stringifyFrontmatter(mainFile.body, mainFile.frontmatter);
|
|
5236
5481
|
const contentWithNewline = addTrailingNewline(content);
|
|
5237
5482
|
await writeFileContent(mainFilePath, contentWithNewline);
|
|
5238
5483
|
}
|
|
5239
5484
|
const otherFiles = aiDir.getOtherFiles();
|
|
5240
5485
|
for (const file of otherFiles) {
|
|
5241
|
-
const filePath =
|
|
5486
|
+
const filePath = join46(dirPath, file.relativeFilePathToDirPath);
|
|
5242
5487
|
const contentWithNewline = addTrailingNewline(file.fileBuffer.toString("utf-8"));
|
|
5243
5488
|
await writeFileContent(filePath, contentWithNewline);
|
|
5244
5489
|
}
|
|
5245
5490
|
}
|
|
5246
|
-
return aiDirs.length;
|
|
5247
|
-
}
|
|
5248
|
-
async removeAiDirs(aiDirs) {
|
|
5249
|
-
for (const aiDir of aiDirs) {
|
|
5250
|
-
await removeDirectory(aiDir.getDirPath());
|
|
5251
|
-
}
|
|
5252
|
-
}
|
|
5253
|
-
};
|
|
5254
|
-
|
|
5255
|
-
// src/features/skills/claudecode-skill.ts
|
|
5256
|
-
import { join as join47 } from "path";
|
|
5257
|
-
import { z as z21 } from "zod/mini";
|
|
5258
|
-
|
|
5259
|
-
// src/features/skills/rulesync-skill.ts
|
|
5260
|
-
import { join as join46 } from "path";
|
|
5261
|
-
import { z as z20 } from "zod/mini";
|
|
5262
|
-
var RulesyncSkillFrontmatterSchemaInternal = z20.looseObject({
|
|
5263
|
-
name: z20.string(),
|
|
5264
|
-
description: z20.string(),
|
|
5265
|
-
targets: z20._default(RulesyncTargetsSchema, ["*"]),
|
|
5266
|
-
claudecode: z20.optional(
|
|
5267
|
-
z20.looseObject({
|
|
5268
|
-
"allowed-tools": z20.optional(z20.array(z20.string()))
|
|
5269
|
-
})
|
|
5270
|
-
),
|
|
5271
|
-
opencode: z20.optional(
|
|
5272
|
-
z20.looseObject({
|
|
5273
|
-
"allowed-tools": z20.optional(z20.array(z20.string()))
|
|
5274
|
-
})
|
|
5275
|
-
),
|
|
5276
|
-
copilot: z20.optional(
|
|
5277
|
-
z20.looseObject({
|
|
5278
|
-
license: z20.optional(z20.string())
|
|
5279
|
-
})
|
|
5280
|
-
)
|
|
5281
|
-
});
|
|
5282
|
-
var RulesyncSkillFrontmatterSchema = RulesyncSkillFrontmatterSchemaInternal;
|
|
5283
|
-
var RulesyncSkill = class _RulesyncSkill extends AiDir {
|
|
5284
|
-
constructor({
|
|
5285
|
-
baseDir = process.cwd(),
|
|
5286
|
-
relativeDirPath = RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
5287
|
-
dirName,
|
|
5288
|
-
frontmatter,
|
|
5289
|
-
body,
|
|
5290
|
-
otherFiles = [],
|
|
5291
|
-
validate = true,
|
|
5292
|
-
global = false
|
|
5293
|
-
}) {
|
|
5294
|
-
super({
|
|
5295
|
-
baseDir,
|
|
5296
|
-
relativeDirPath,
|
|
5297
|
-
dirName,
|
|
5298
|
-
mainFile: {
|
|
5299
|
-
name: SKILL_FILE_NAME,
|
|
5300
|
-
body,
|
|
5301
|
-
frontmatter: { ...frontmatter }
|
|
5302
|
-
},
|
|
5303
|
-
otherFiles,
|
|
5304
|
-
global
|
|
5305
|
-
});
|
|
5306
|
-
if (validate) {
|
|
5307
|
-
const result = this.validate();
|
|
5308
|
-
if (!result.success) {
|
|
5309
|
-
throw result.error;
|
|
5310
|
-
}
|
|
5311
|
-
}
|
|
5312
|
-
}
|
|
5313
|
-
static getSettablePaths() {
|
|
5314
|
-
return {
|
|
5315
|
-
relativeDirPath: RULESYNC_SKILLS_RELATIVE_DIR_PATH
|
|
5316
|
-
};
|
|
5317
|
-
}
|
|
5318
|
-
getFrontmatter() {
|
|
5319
|
-
if (!this.mainFile?.frontmatter) {
|
|
5320
|
-
throw new Error("Frontmatter is not defined");
|
|
5321
|
-
}
|
|
5322
|
-
const result = RulesyncSkillFrontmatterSchema.parse(this.mainFile.frontmatter);
|
|
5323
|
-
return result;
|
|
5324
|
-
}
|
|
5325
|
-
getBody() {
|
|
5326
|
-
return this.mainFile?.body ?? "";
|
|
5327
|
-
}
|
|
5328
|
-
validate() {
|
|
5329
|
-
const result = RulesyncSkillFrontmatterSchema.safeParse(this.mainFile?.frontmatter);
|
|
5330
|
-
if (!result.success) {
|
|
5331
|
-
return {
|
|
5332
|
-
success: false,
|
|
5333
|
-
error: new Error(
|
|
5334
|
-
`Invalid frontmatter in ${this.getDirPath()}: ${formatError(result.error)}`
|
|
5335
|
-
)
|
|
5336
|
-
};
|
|
5337
|
-
}
|
|
5338
|
-
return { success: true, error: null };
|
|
5491
|
+
return aiDirs.length;
|
|
5339
5492
|
}
|
|
5340
|
-
|
|
5341
|
-
|
|
5342
|
-
|
|
5343
|
-
dirName,
|
|
5344
|
-
global = false
|
|
5345
|
-
}) {
|
|
5346
|
-
const skillDirPath = join46(baseDir, relativeDirPath, dirName);
|
|
5347
|
-
const skillFilePath = join46(skillDirPath, SKILL_FILE_NAME);
|
|
5348
|
-
if (!await fileExists(skillFilePath)) {
|
|
5349
|
-
throw new Error(`${SKILL_FILE_NAME} not found in ${skillDirPath}`);
|
|
5350
|
-
}
|
|
5351
|
-
const fileContent = await readFileContent(skillFilePath);
|
|
5352
|
-
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
5353
|
-
const result = RulesyncSkillFrontmatterSchema.safeParse(frontmatter);
|
|
5354
|
-
if (!result.success) {
|
|
5355
|
-
throw new Error(`Invalid frontmatter in ${skillFilePath}: ${formatError(result.error)}`);
|
|
5493
|
+
async removeAiDirs(aiDirs) {
|
|
5494
|
+
for (const aiDir of aiDirs) {
|
|
5495
|
+
await removeDirectory(aiDir.getDirPath());
|
|
5356
5496
|
}
|
|
5357
|
-
const otherFiles = await this.collectOtherFiles(
|
|
5358
|
-
baseDir,
|
|
5359
|
-
relativeDirPath,
|
|
5360
|
-
dirName,
|
|
5361
|
-
SKILL_FILE_NAME
|
|
5362
|
-
);
|
|
5363
|
-
return new _RulesyncSkill({
|
|
5364
|
-
baseDir,
|
|
5365
|
-
relativeDirPath,
|
|
5366
|
-
dirName,
|
|
5367
|
-
frontmatter: result.data,
|
|
5368
|
-
body: content.trim(),
|
|
5369
|
-
otherFiles,
|
|
5370
|
-
validate: true,
|
|
5371
|
-
global
|
|
5372
|
-
});
|
|
5373
5497
|
}
|
|
5374
5498
|
};
|
|
5375
5499
|
|
|
5376
5500
|
// src/features/skills/claudecode-skill.ts
|
|
5377
|
-
|
|
5378
|
-
|
|
5379
|
-
|
|
5380
|
-
|
|
5501
|
+
import { join as join47 } from "path";
|
|
5502
|
+
import { z as z22 } from "zod/mini";
|
|
5503
|
+
var ClaudecodeSkillFrontmatterSchema = z22.looseObject({
|
|
5504
|
+
name: z22.string(),
|
|
5505
|
+
description: z22.string(),
|
|
5506
|
+
"allowed-tools": z22.optional(z22.array(z22.string()))
|
|
5381
5507
|
});
|
|
5382
5508
|
var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
|
|
5383
5509
|
constructor({
|
|
@@ -5538,10 +5664,10 @@ var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
|
|
|
5538
5664
|
|
|
5539
5665
|
// src/features/skills/codexcli-skill.ts
|
|
5540
5666
|
import { join as join48 } from "path";
|
|
5541
|
-
import { z as
|
|
5542
|
-
var CodexCliSkillFrontmatterSchema =
|
|
5543
|
-
name:
|
|
5544
|
-
description:
|
|
5667
|
+
import { z as z23 } from "zod/mini";
|
|
5668
|
+
var CodexCliSkillFrontmatterSchema = z23.looseObject({
|
|
5669
|
+
name: z23.string(),
|
|
5670
|
+
description: z23.string()
|
|
5545
5671
|
});
|
|
5546
5672
|
var CodexCliSkill = class _CodexCliSkill extends ToolSkill {
|
|
5547
5673
|
constructor({
|
|
@@ -5697,11 +5823,11 @@ var CodexCliSkill = class _CodexCliSkill extends ToolSkill {
|
|
|
5697
5823
|
|
|
5698
5824
|
// src/features/skills/copilot-skill.ts
|
|
5699
5825
|
import { join as join49 } from "path";
|
|
5700
|
-
import { z as
|
|
5701
|
-
var CopilotSkillFrontmatterSchema =
|
|
5702
|
-
name:
|
|
5703
|
-
description:
|
|
5704
|
-
license:
|
|
5826
|
+
import { z as z24 } from "zod/mini";
|
|
5827
|
+
var CopilotSkillFrontmatterSchema = z24.looseObject({
|
|
5828
|
+
name: z24.string(),
|
|
5829
|
+
description: z24.string(),
|
|
5830
|
+
license: z24.optional(z24.string())
|
|
5705
5831
|
});
|
|
5706
5832
|
var CopilotSkill = class _CopilotSkill extends ToolSkill {
|
|
5707
5833
|
constructor({
|
|
@@ -5864,11 +5990,11 @@ var CopilotSkill = class _CopilotSkill extends ToolSkill {
|
|
|
5864
5990
|
|
|
5865
5991
|
// src/features/skills/opencode-skill.ts
|
|
5866
5992
|
import { join as join50 } from "path";
|
|
5867
|
-
import { z as
|
|
5868
|
-
var OpenCodeSkillFrontmatterSchema =
|
|
5869
|
-
name:
|
|
5870
|
-
description:
|
|
5871
|
-
"allowed-tools":
|
|
5993
|
+
import { z as z25 } from "zod/mini";
|
|
5994
|
+
var OpenCodeSkillFrontmatterSchema = z25.looseObject({
|
|
5995
|
+
name: z25.string(),
|
|
5996
|
+
description: z25.string(),
|
|
5997
|
+
"allowed-tools": z25.optional(z25.array(z25.string()))
|
|
5872
5998
|
});
|
|
5873
5999
|
var OpenCodeSkill = class _OpenCodeSkill extends ToolSkill {
|
|
5874
6000
|
constructor({
|
|
@@ -6035,7 +6161,7 @@ var skillsProcessorToolTargetTuple = [
|
|
|
6035
6161
|
"geminicli",
|
|
6036
6162
|
"opencode"
|
|
6037
6163
|
];
|
|
6038
|
-
var SkillsProcessorToolTargetSchema =
|
|
6164
|
+
var SkillsProcessorToolTargetSchema = z26.enum(skillsProcessorToolTargetTuple);
|
|
6039
6165
|
var toolSkillFactories = /* @__PURE__ */ new Map([
|
|
6040
6166
|
[
|
|
6041
6167
|
"agentsmd",
|
|
@@ -6069,7 +6195,7 @@ var toolSkillFactories = /* @__PURE__ */ new Map([
|
|
|
6069
6195
|
"cursor",
|
|
6070
6196
|
{
|
|
6071
6197
|
class: CursorSkill,
|
|
6072
|
-
meta: { supportsProject: true, supportsSimulated:
|
|
6198
|
+
meta: { supportsProject: true, supportsSimulated: false, supportsGlobal: false }
|
|
6073
6199
|
}
|
|
6074
6200
|
],
|
|
6075
6201
|
[
|
|
@@ -6254,7 +6380,7 @@ import { join as join53 } from "path";
|
|
|
6254
6380
|
|
|
6255
6381
|
// src/features/subagents/simulated-subagent.ts
|
|
6256
6382
|
import { basename as basename15, join as join52 } from "path";
|
|
6257
|
-
import { z as
|
|
6383
|
+
import { z as z27 } from "zod/mini";
|
|
6258
6384
|
|
|
6259
6385
|
// src/features/subagents/tool-subagent.ts
|
|
6260
6386
|
var ToolSubagent = class extends ToolFile {
|
|
@@ -6297,9 +6423,9 @@ var ToolSubagent = class extends ToolFile {
|
|
|
6297
6423
|
};
|
|
6298
6424
|
|
|
6299
6425
|
// src/features/subagents/simulated-subagent.ts
|
|
6300
|
-
var SimulatedSubagentFrontmatterSchema =
|
|
6301
|
-
name:
|
|
6302
|
-
description:
|
|
6426
|
+
var SimulatedSubagentFrontmatterSchema = z27.object({
|
|
6427
|
+
name: z27.string(),
|
|
6428
|
+
description: z27.string()
|
|
6303
6429
|
});
|
|
6304
6430
|
var SimulatedSubagent = class extends ToolSubagent {
|
|
6305
6431
|
frontmatter;
|
|
@@ -6537,20 +6663,20 @@ var RooSubagent = class _RooSubagent extends SimulatedSubagent {
|
|
|
6537
6663
|
};
|
|
6538
6664
|
|
|
6539
6665
|
// src/features/subagents/subagents-processor.ts
|
|
6540
|
-
import { basename as
|
|
6541
|
-
import { z as
|
|
6666
|
+
import { basename as basename18, join as join62 } from "path";
|
|
6667
|
+
import { z as z32 } from "zod/mini";
|
|
6542
6668
|
|
|
6543
6669
|
// src/features/subagents/claudecode-subagent.ts
|
|
6544
6670
|
import { join as join59 } from "path";
|
|
6545
|
-
import { z as
|
|
6671
|
+
import { z as z29 } from "zod/mini";
|
|
6546
6672
|
|
|
6547
6673
|
// src/features/subagents/rulesync-subagent.ts
|
|
6548
6674
|
import { basename as basename16, join as join58 } from "path";
|
|
6549
|
-
import { z as
|
|
6550
|
-
var RulesyncSubagentFrontmatterSchema =
|
|
6675
|
+
import { z as z28 } from "zod/mini";
|
|
6676
|
+
var RulesyncSubagentFrontmatterSchema = z28.looseObject({
|
|
6551
6677
|
targets: RulesyncTargetsSchema,
|
|
6552
|
-
name:
|
|
6553
|
-
description:
|
|
6678
|
+
name: z28.string(),
|
|
6679
|
+
description: z28.string()
|
|
6554
6680
|
});
|
|
6555
6681
|
var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
6556
6682
|
frontmatter;
|
|
@@ -6621,13 +6747,13 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
6621
6747
|
};
|
|
6622
6748
|
|
|
6623
6749
|
// src/features/subagents/claudecode-subagent.ts
|
|
6624
|
-
var ClaudecodeSubagentFrontmatterSchema =
|
|
6625
|
-
name:
|
|
6626
|
-
description:
|
|
6627
|
-
model:
|
|
6628
|
-
tools:
|
|
6629
|
-
permissionMode:
|
|
6630
|
-
skills:
|
|
6750
|
+
var ClaudecodeSubagentFrontmatterSchema = z29.looseObject({
|
|
6751
|
+
name: z29.string(),
|
|
6752
|
+
description: z29.string(),
|
|
6753
|
+
model: z29.optional(z29.string()),
|
|
6754
|
+
tools: z29.optional(z29.union([z29.string(), z29.array(z29.string())])),
|
|
6755
|
+
permissionMode: z29.optional(z29.string()),
|
|
6756
|
+
skills: z29.optional(z29.union([z29.string(), z29.array(z29.string())]))
|
|
6631
6757
|
});
|
|
6632
6758
|
var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
6633
6759
|
frontmatter;
|
|
@@ -6700,30 +6826,195 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6700
6826
|
}
|
|
6701
6827
|
const claudecodeFrontmatter = result.data;
|
|
6702
6828
|
const body = rulesyncSubagent.getBody();
|
|
6703
|
-
const fileContent = stringifyFrontmatter(body, claudecodeFrontmatter);
|
|
6829
|
+
const fileContent = stringifyFrontmatter(body, claudecodeFrontmatter);
|
|
6830
|
+
const paths = this.getSettablePaths({ global });
|
|
6831
|
+
return new _ClaudecodeSubagent({
|
|
6832
|
+
baseDir,
|
|
6833
|
+
frontmatter: claudecodeFrontmatter,
|
|
6834
|
+
body,
|
|
6835
|
+
relativeDirPath: paths.relativeDirPath,
|
|
6836
|
+
relativeFilePath: rulesyncSubagent.getRelativeFilePath(),
|
|
6837
|
+
fileContent,
|
|
6838
|
+
validate
|
|
6839
|
+
});
|
|
6840
|
+
}
|
|
6841
|
+
validate() {
|
|
6842
|
+
if (!this.frontmatter) {
|
|
6843
|
+
return { success: true, error: null };
|
|
6844
|
+
}
|
|
6845
|
+
const result = ClaudecodeSubagentFrontmatterSchema.safeParse(this.frontmatter);
|
|
6846
|
+
if (result.success) {
|
|
6847
|
+
return { success: true, error: null };
|
|
6848
|
+
} else {
|
|
6849
|
+
return {
|
|
6850
|
+
success: false,
|
|
6851
|
+
error: new Error(
|
|
6852
|
+
`Invalid frontmatter in ${join59(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6853
|
+
)
|
|
6854
|
+
};
|
|
6855
|
+
}
|
|
6856
|
+
}
|
|
6857
|
+
static isTargetedByRulesyncSubagent(rulesyncSubagent) {
|
|
6858
|
+
return this.isTargetedByRulesyncSubagentDefault({
|
|
6859
|
+
rulesyncSubagent,
|
|
6860
|
+
toolTarget: "claudecode"
|
|
6861
|
+
});
|
|
6862
|
+
}
|
|
6863
|
+
static async fromFile({
|
|
6864
|
+
baseDir = process.cwd(),
|
|
6865
|
+
relativeFilePath,
|
|
6866
|
+
validate = true,
|
|
6867
|
+
global = false
|
|
6868
|
+
}) {
|
|
6869
|
+
const paths = this.getSettablePaths({ global });
|
|
6870
|
+
const filePath = join59(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
6871
|
+
const fileContent = await readFileContent(filePath);
|
|
6872
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
6873
|
+
const result = ClaudecodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6874
|
+
if (!result.success) {
|
|
6875
|
+
throw new Error(`Invalid frontmatter in ${filePath}: ${formatError(result.error)}`);
|
|
6876
|
+
}
|
|
6877
|
+
return new _ClaudecodeSubagent({
|
|
6878
|
+
baseDir,
|
|
6879
|
+
relativeDirPath: paths.relativeDirPath,
|
|
6880
|
+
relativeFilePath,
|
|
6881
|
+
frontmatter: result.data,
|
|
6882
|
+
body: content.trim(),
|
|
6883
|
+
fileContent,
|
|
6884
|
+
validate
|
|
6885
|
+
});
|
|
6886
|
+
}
|
|
6887
|
+
static forDeletion({
|
|
6888
|
+
baseDir = process.cwd(),
|
|
6889
|
+
relativeDirPath,
|
|
6890
|
+
relativeFilePath
|
|
6891
|
+
}) {
|
|
6892
|
+
return new _ClaudecodeSubagent({
|
|
6893
|
+
baseDir,
|
|
6894
|
+
relativeDirPath,
|
|
6895
|
+
relativeFilePath,
|
|
6896
|
+
frontmatter: { name: "", description: "" },
|
|
6897
|
+
body: "",
|
|
6898
|
+
fileContent: "",
|
|
6899
|
+
validate: false
|
|
6900
|
+
});
|
|
6901
|
+
}
|
|
6902
|
+
};
|
|
6903
|
+
|
|
6904
|
+
// src/features/subagents/copilot-subagent.ts
|
|
6905
|
+
import { join as join60 } from "path";
|
|
6906
|
+
import { z as z30 } from "zod/mini";
|
|
6907
|
+
var REQUIRED_TOOL = "agent/runSubagent";
|
|
6908
|
+
var CopilotSubagentFrontmatterSchema = z30.looseObject({
|
|
6909
|
+
name: z30.string(),
|
|
6910
|
+
description: z30.string(),
|
|
6911
|
+
tools: z30.optional(z30.union([z30.string(), z30.array(z30.string())]))
|
|
6912
|
+
});
|
|
6913
|
+
var normalizeTools = (tools) => {
|
|
6914
|
+
if (!tools) {
|
|
6915
|
+
return [];
|
|
6916
|
+
}
|
|
6917
|
+
return Array.isArray(tools) ? tools : [tools];
|
|
6918
|
+
};
|
|
6919
|
+
var ensureRequiredTool = (tools) => {
|
|
6920
|
+
const mergedTools = /* @__PURE__ */ new Set([REQUIRED_TOOL, ...tools]);
|
|
6921
|
+
return Array.from(mergedTools);
|
|
6922
|
+
};
|
|
6923
|
+
var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
6924
|
+
frontmatter;
|
|
6925
|
+
body;
|
|
6926
|
+
constructor({ frontmatter, body, ...rest }) {
|
|
6927
|
+
if (rest.validate !== false) {
|
|
6928
|
+
const result = CopilotSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6929
|
+
if (!result.success) {
|
|
6930
|
+
throw new Error(
|
|
6931
|
+
`Invalid frontmatter in ${join60(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6932
|
+
);
|
|
6933
|
+
}
|
|
6934
|
+
}
|
|
6935
|
+
super({
|
|
6936
|
+
...rest
|
|
6937
|
+
});
|
|
6938
|
+
this.frontmatter = frontmatter;
|
|
6939
|
+
this.body = body;
|
|
6940
|
+
}
|
|
6941
|
+
static getSettablePaths(_options = {}) {
|
|
6942
|
+
return {
|
|
6943
|
+
relativeDirPath: join60(".github", "agents")
|
|
6944
|
+
};
|
|
6945
|
+
}
|
|
6946
|
+
getFrontmatter() {
|
|
6947
|
+
return this.frontmatter;
|
|
6948
|
+
}
|
|
6949
|
+
getBody() {
|
|
6950
|
+
return this.body;
|
|
6951
|
+
}
|
|
6952
|
+
toRulesyncSubagent() {
|
|
6953
|
+
const { name, description, tools, ...rest } = this.frontmatter;
|
|
6954
|
+
const rulesyncFrontmatter = {
|
|
6955
|
+
targets: ["copilot"],
|
|
6956
|
+
name,
|
|
6957
|
+
description,
|
|
6958
|
+
copilot: {
|
|
6959
|
+
...tools && { tools },
|
|
6960
|
+
...rest
|
|
6961
|
+
}
|
|
6962
|
+
};
|
|
6963
|
+
return new RulesyncSubagent({
|
|
6964
|
+
baseDir: ".",
|
|
6965
|
+
// RulesyncCommand baseDir is always the project root directory
|
|
6966
|
+
frontmatter: rulesyncFrontmatter,
|
|
6967
|
+
body: this.body,
|
|
6968
|
+
relativeDirPath: RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH,
|
|
6969
|
+
relativeFilePath: this.getRelativeFilePath(),
|
|
6970
|
+
validate: true
|
|
6971
|
+
});
|
|
6972
|
+
}
|
|
6973
|
+
static fromRulesyncSubagent({
|
|
6974
|
+
baseDir = process.cwd(),
|
|
6975
|
+
rulesyncSubagent,
|
|
6976
|
+
validate = true,
|
|
6977
|
+
global = false
|
|
6978
|
+
}) {
|
|
6979
|
+
const rulesyncFrontmatter = rulesyncSubagent.getFrontmatter();
|
|
6980
|
+
const copilotSection = rulesyncFrontmatter.copilot ?? {};
|
|
6981
|
+
const toolsField = copilotSection.tools;
|
|
6982
|
+
const userTools = normalizeTools(
|
|
6983
|
+
Array.isArray(toolsField) || typeof toolsField === "string" ? toolsField : void 0
|
|
6984
|
+
);
|
|
6985
|
+
const mergedTools = ensureRequiredTool(userTools);
|
|
6986
|
+
const copilotFrontmatter = {
|
|
6987
|
+
name: rulesyncFrontmatter.name,
|
|
6988
|
+
description: rulesyncFrontmatter.description,
|
|
6989
|
+
...copilotSection,
|
|
6990
|
+
...mergedTools.length > 0 && { tools: mergedTools }
|
|
6991
|
+
};
|
|
6992
|
+
const body = rulesyncSubagent.getBody();
|
|
6993
|
+
const fileContent = stringifyFrontmatter(body, copilotFrontmatter);
|
|
6704
6994
|
const paths = this.getSettablePaths({ global });
|
|
6705
|
-
return new
|
|
6995
|
+
return new _CopilotSubagent({
|
|
6706
6996
|
baseDir,
|
|
6707
|
-
frontmatter:
|
|
6997
|
+
frontmatter: copilotFrontmatter,
|
|
6708
6998
|
body,
|
|
6709
6999
|
relativeDirPath: paths.relativeDirPath,
|
|
6710
7000
|
relativeFilePath: rulesyncSubagent.getRelativeFilePath(),
|
|
6711
7001
|
fileContent,
|
|
6712
|
-
validate
|
|
7002
|
+
validate,
|
|
7003
|
+
global
|
|
6713
7004
|
});
|
|
6714
7005
|
}
|
|
6715
7006
|
validate() {
|
|
6716
7007
|
if (!this.frontmatter) {
|
|
6717
7008
|
return { success: true, error: null };
|
|
6718
7009
|
}
|
|
6719
|
-
const result =
|
|
7010
|
+
const result = CopilotSubagentFrontmatterSchema.safeParse(this.frontmatter);
|
|
6720
7011
|
if (result.success) {
|
|
6721
7012
|
return { success: true, error: null };
|
|
6722
7013
|
} else {
|
|
6723
7014
|
return {
|
|
6724
7015
|
success: false,
|
|
6725
7016
|
error: new Error(
|
|
6726
|
-
`Invalid frontmatter in ${
|
|
7017
|
+
`Invalid frontmatter in ${join60(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6727
7018
|
)
|
|
6728
7019
|
};
|
|
6729
7020
|
}
|
|
@@ -6731,7 +7022,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6731
7022
|
static isTargetedByRulesyncSubagent(rulesyncSubagent) {
|
|
6732
7023
|
return this.isTargetedByRulesyncSubagentDefault({
|
|
6733
7024
|
rulesyncSubagent,
|
|
6734
|
-
toolTarget: "
|
|
7025
|
+
toolTarget: "copilot"
|
|
6735
7026
|
});
|
|
6736
7027
|
}
|
|
6737
7028
|
static async fromFile({
|
|
@@ -6741,21 +7032,22 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6741
7032
|
global = false
|
|
6742
7033
|
}) {
|
|
6743
7034
|
const paths = this.getSettablePaths({ global });
|
|
6744
|
-
const filePath =
|
|
7035
|
+
const filePath = join60(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
6745
7036
|
const fileContent = await readFileContent(filePath);
|
|
6746
7037
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
6747
|
-
const result =
|
|
7038
|
+
const result = CopilotSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6748
7039
|
if (!result.success) {
|
|
6749
7040
|
throw new Error(`Invalid frontmatter in ${filePath}: ${formatError(result.error)}`);
|
|
6750
7041
|
}
|
|
6751
|
-
return new
|
|
7042
|
+
return new _CopilotSubagent({
|
|
6752
7043
|
baseDir,
|
|
6753
7044
|
relativeDirPath: paths.relativeDirPath,
|
|
6754
7045
|
relativeFilePath,
|
|
6755
7046
|
frontmatter: result.data,
|
|
6756
7047
|
body: content.trim(),
|
|
6757
7048
|
fileContent,
|
|
6758
|
-
validate
|
|
7049
|
+
validate,
|
|
7050
|
+
global
|
|
6759
7051
|
});
|
|
6760
7052
|
}
|
|
6761
7053
|
static forDeletion({
|
|
@@ -6763,7 +7055,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6763
7055
|
relativeDirPath,
|
|
6764
7056
|
relativeFilePath
|
|
6765
7057
|
}) {
|
|
6766
|
-
return new
|
|
7058
|
+
return new _CopilotSubagent({
|
|
6767
7059
|
baseDir,
|
|
6768
7060
|
relativeDirPath,
|
|
6769
7061
|
relativeFilePath,
|
|
@@ -6775,34 +7067,23 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6775
7067
|
}
|
|
6776
7068
|
};
|
|
6777
7069
|
|
|
6778
|
-
// src/features/subagents/
|
|
6779
|
-
import { join as
|
|
6780
|
-
import { z as
|
|
6781
|
-
var
|
|
6782
|
-
|
|
6783
|
-
|
|
6784
|
-
|
|
6785
|
-
tools: z29.optional(z29.union([z29.string(), z29.array(z29.string())]))
|
|
7070
|
+
// src/features/subagents/opencode-subagent.ts
|
|
7071
|
+
import { basename as basename17, join as join61 } from "path";
|
|
7072
|
+
import { z as z31 } from "zod/mini";
|
|
7073
|
+
var OpenCodeSubagentFrontmatterSchema = z31.looseObject({
|
|
7074
|
+
description: z31.string(),
|
|
7075
|
+
mode: z31.literal("subagent"),
|
|
7076
|
+
name: z31.optional(z31.string())
|
|
6786
7077
|
});
|
|
6787
|
-
var
|
|
6788
|
-
if (!tools) {
|
|
6789
|
-
return [];
|
|
6790
|
-
}
|
|
6791
|
-
return Array.isArray(tools) ? tools : [tools];
|
|
6792
|
-
};
|
|
6793
|
-
var ensureRequiredTool = (tools) => {
|
|
6794
|
-
const mergedTools = /* @__PURE__ */ new Set([REQUIRED_TOOL, ...tools]);
|
|
6795
|
-
return Array.from(mergedTools);
|
|
6796
|
-
};
|
|
6797
|
-
var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
7078
|
+
var OpenCodeSubagent = class _OpenCodeSubagent extends ToolSubagent {
|
|
6798
7079
|
frontmatter;
|
|
6799
7080
|
body;
|
|
6800
7081
|
constructor({ frontmatter, body, ...rest }) {
|
|
6801
7082
|
if (rest.validate !== false) {
|
|
6802
|
-
const result =
|
|
7083
|
+
const result = OpenCodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6803
7084
|
if (!result.success) {
|
|
6804
7085
|
throw new Error(
|
|
6805
|
-
`Invalid frontmatter in ${
|
|
7086
|
+
`Invalid frontmatter in ${join61(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6806
7087
|
);
|
|
6807
7088
|
}
|
|
6808
7089
|
}
|
|
@@ -6812,9 +7093,11 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
6812
7093
|
this.frontmatter = frontmatter;
|
|
6813
7094
|
this.body = body;
|
|
6814
7095
|
}
|
|
6815
|
-
static getSettablePaths(
|
|
7096
|
+
static getSettablePaths({
|
|
7097
|
+
global = false
|
|
7098
|
+
} = {}) {
|
|
6816
7099
|
return {
|
|
6817
|
-
relativeDirPath:
|
|
7100
|
+
relativeDirPath: global ? join61(".config", "opencode", "agent") : join61(".opencode", "agent")
|
|
6818
7101
|
};
|
|
6819
7102
|
}
|
|
6820
7103
|
getFrontmatter() {
|
|
@@ -6824,19 +7107,16 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
6824
7107
|
return this.body;
|
|
6825
7108
|
}
|
|
6826
7109
|
toRulesyncSubagent() {
|
|
6827
|
-
const {
|
|
7110
|
+
const { description, mode, name, ...opencodeSection } = this.frontmatter;
|
|
6828
7111
|
const rulesyncFrontmatter = {
|
|
6829
|
-
targets: ["
|
|
6830
|
-
name,
|
|
7112
|
+
targets: ["opencode"],
|
|
7113
|
+
name: name ?? basename17(this.getRelativeFilePath(), ".md"),
|
|
6831
7114
|
description,
|
|
6832
|
-
|
|
6833
|
-
...tools && { tools },
|
|
6834
|
-
...rest
|
|
6835
|
-
}
|
|
7115
|
+
opencode: { mode, ...opencodeSection }
|
|
6836
7116
|
};
|
|
6837
7117
|
return new RulesyncSubagent({
|
|
6838
7118
|
baseDir: ".",
|
|
6839
|
-
//
|
|
7119
|
+
// RulesyncSubagent baseDir is always the project root directory
|
|
6840
7120
|
frontmatter: rulesyncFrontmatter,
|
|
6841
7121
|
body: this.body,
|
|
6842
7122
|
relativeDirPath: RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH,
|
|
@@ -6851,24 +7131,19 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
6851
7131
|
global = false
|
|
6852
7132
|
}) {
|
|
6853
7133
|
const rulesyncFrontmatter = rulesyncSubagent.getFrontmatter();
|
|
6854
|
-
const
|
|
6855
|
-
const
|
|
6856
|
-
|
|
6857
|
-
Array.isArray(toolsField) || typeof toolsField === "string" ? toolsField : void 0
|
|
6858
|
-
);
|
|
6859
|
-
const mergedTools = ensureRequiredTool(userTools);
|
|
6860
|
-
const copilotFrontmatter = {
|
|
6861
|
-
name: rulesyncFrontmatter.name,
|
|
7134
|
+
const opencodeSection = rulesyncFrontmatter.opencode ?? {};
|
|
7135
|
+
const opencodeFrontmatter = {
|
|
7136
|
+
...opencodeSection,
|
|
6862
7137
|
description: rulesyncFrontmatter.description,
|
|
6863
|
-
|
|
6864
|
-
...
|
|
7138
|
+
mode: "subagent",
|
|
7139
|
+
...rulesyncFrontmatter.name && { name: rulesyncFrontmatter.name }
|
|
6865
7140
|
};
|
|
6866
7141
|
const body = rulesyncSubagent.getBody();
|
|
6867
|
-
const fileContent = stringifyFrontmatter(body,
|
|
7142
|
+
const fileContent = stringifyFrontmatter(body, opencodeFrontmatter);
|
|
6868
7143
|
const paths = this.getSettablePaths({ global });
|
|
6869
|
-
return new
|
|
7144
|
+
return new _OpenCodeSubagent({
|
|
6870
7145
|
baseDir,
|
|
6871
|
-
frontmatter:
|
|
7146
|
+
frontmatter: opencodeFrontmatter,
|
|
6872
7147
|
body,
|
|
6873
7148
|
relativeDirPath: paths.relativeDirPath,
|
|
6874
7149
|
relativeFilePath: rulesyncSubagent.getRelativeFilePath(),
|
|
@@ -6881,22 +7156,21 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
6881
7156
|
if (!this.frontmatter) {
|
|
6882
7157
|
return { success: true, error: null };
|
|
6883
7158
|
}
|
|
6884
|
-
const result =
|
|
7159
|
+
const result = OpenCodeSubagentFrontmatterSchema.safeParse(this.frontmatter);
|
|
6885
7160
|
if (result.success) {
|
|
6886
7161
|
return { success: true, error: null };
|
|
6887
|
-
} else {
|
|
6888
|
-
return {
|
|
6889
|
-
success: false,
|
|
6890
|
-
error: new Error(
|
|
6891
|
-
`Invalid frontmatter in ${join60(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6892
|
-
)
|
|
6893
|
-
};
|
|
6894
7162
|
}
|
|
7163
|
+
return {
|
|
7164
|
+
success: false,
|
|
7165
|
+
error: new Error(
|
|
7166
|
+
`Invalid frontmatter in ${join61(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
7167
|
+
)
|
|
7168
|
+
};
|
|
6895
7169
|
}
|
|
6896
7170
|
static isTargetedByRulesyncSubagent(rulesyncSubagent) {
|
|
6897
7171
|
return this.isTargetedByRulesyncSubagentDefault({
|
|
6898
7172
|
rulesyncSubagent,
|
|
6899
|
-
toolTarget: "
|
|
7173
|
+
toolTarget: "opencode"
|
|
6900
7174
|
});
|
|
6901
7175
|
}
|
|
6902
7176
|
static async fromFile({
|
|
@@ -6906,14 +7180,14 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
6906
7180
|
global = false
|
|
6907
7181
|
}) {
|
|
6908
7182
|
const paths = this.getSettablePaths({ global });
|
|
6909
|
-
const filePath =
|
|
7183
|
+
const filePath = join61(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
6910
7184
|
const fileContent = await readFileContent(filePath);
|
|
6911
7185
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
6912
|
-
const result =
|
|
7186
|
+
const result = OpenCodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6913
7187
|
if (!result.success) {
|
|
6914
7188
|
throw new Error(`Invalid frontmatter in ${filePath}: ${formatError(result.error)}`);
|
|
6915
7189
|
}
|
|
6916
|
-
return new
|
|
7190
|
+
return new _OpenCodeSubagent({
|
|
6917
7191
|
baseDir,
|
|
6918
7192
|
relativeDirPath: paths.relativeDirPath,
|
|
6919
7193
|
relativeFilePath,
|
|
@@ -6929,11 +7203,11 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
6929
7203
|
relativeDirPath,
|
|
6930
7204
|
relativeFilePath
|
|
6931
7205
|
}) {
|
|
6932
|
-
return new
|
|
7206
|
+
return new _OpenCodeSubagent({
|
|
6933
7207
|
baseDir,
|
|
6934
7208
|
relativeDirPath,
|
|
6935
7209
|
relativeFilePath,
|
|
6936
|
-
frontmatter: {
|
|
7210
|
+
frontmatter: { description: "", mode: "subagent" },
|
|
6937
7211
|
body: "",
|
|
6938
7212
|
fileContent: "",
|
|
6939
7213
|
validate: false
|
|
@@ -6949,9 +7223,10 @@ var subagentsProcessorToolTargetTuple = [
|
|
|
6949
7223
|
"copilot",
|
|
6950
7224
|
"cursor",
|
|
6951
7225
|
"geminicli",
|
|
7226
|
+
"opencode",
|
|
6952
7227
|
"roo"
|
|
6953
7228
|
];
|
|
6954
|
-
var SubagentsProcessorToolTargetSchema =
|
|
7229
|
+
var SubagentsProcessorToolTargetSchema = z32.enum(subagentsProcessorToolTargetTuple);
|
|
6955
7230
|
var toolSubagentFactories = /* @__PURE__ */ new Map([
|
|
6956
7231
|
[
|
|
6957
7232
|
"agentsmd",
|
|
@@ -6974,6 +7249,10 @@ var toolSubagentFactories = /* @__PURE__ */ new Map([
|
|
|
6974
7249
|
"geminicli",
|
|
6975
7250
|
{ class: GeminiCliSubagent, meta: { supportsSimulated: true, supportsGlobal: false } }
|
|
6976
7251
|
],
|
|
7252
|
+
[
|
|
7253
|
+
"opencode",
|
|
7254
|
+
{ class: OpenCodeSubagent, meta: { supportsSimulated: false, supportsGlobal: true } }
|
|
7255
|
+
],
|
|
6977
7256
|
["roo", { class: RooSubagent, meta: { supportsSimulated: true, supportsGlobal: false } }]
|
|
6978
7257
|
]);
|
|
6979
7258
|
var defaultGetFactory5 = (target) => {
|
|
@@ -7057,7 +7336,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7057
7336
|
* Load and parse rulesync subagent files from .rulesync/subagents/ directory
|
|
7058
7337
|
*/
|
|
7059
7338
|
async loadRulesyncFiles() {
|
|
7060
|
-
const subagentsDir =
|
|
7339
|
+
const subagentsDir = join62(this.baseDir, RulesyncSubagent.getSettablePaths().relativeDirPath);
|
|
7061
7340
|
const dirExists = await directoryExists(subagentsDir);
|
|
7062
7341
|
if (!dirExists) {
|
|
7063
7342
|
logger.debug(`Rulesync subagents directory not found: ${subagentsDir}`);
|
|
@@ -7072,7 +7351,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7072
7351
|
logger.info(`Found ${mdFiles.length} subagent files in ${subagentsDir}`);
|
|
7073
7352
|
const rulesyncSubagents = [];
|
|
7074
7353
|
for (const mdFile of mdFiles) {
|
|
7075
|
-
const filepath =
|
|
7354
|
+
const filepath = join62(subagentsDir, mdFile);
|
|
7076
7355
|
try {
|
|
7077
7356
|
const rulesyncSubagent = await RulesyncSubagent.fromFile({
|
|
7078
7357
|
relativeFilePath: mdFile,
|
|
@@ -7102,14 +7381,14 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7102
7381
|
const factory = this.getFactory(this.toolTarget);
|
|
7103
7382
|
const paths = factory.class.getSettablePaths({ global: this.global });
|
|
7104
7383
|
const subagentFilePaths = await findFilesByGlobs(
|
|
7105
|
-
|
|
7384
|
+
join62(this.baseDir, paths.relativeDirPath, "*.md")
|
|
7106
7385
|
);
|
|
7107
7386
|
if (forDeletion) {
|
|
7108
7387
|
const toolSubagents2 = subagentFilePaths.map(
|
|
7109
7388
|
(path3) => factory.class.forDeletion({
|
|
7110
7389
|
baseDir: this.baseDir,
|
|
7111
7390
|
relativeDirPath: paths.relativeDirPath,
|
|
7112
|
-
relativeFilePath:
|
|
7391
|
+
relativeFilePath: basename18(path3),
|
|
7113
7392
|
global: this.global
|
|
7114
7393
|
})
|
|
7115
7394
|
).filter((subagent) => subagent.isDeletable());
|
|
@@ -7120,7 +7399,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7120
7399
|
subagentFilePaths.map(
|
|
7121
7400
|
(path3) => factory.class.fromFile({
|
|
7122
7401
|
baseDir: this.baseDir,
|
|
7123
|
-
relativeFilePath:
|
|
7402
|
+
relativeFilePath: basename18(path3),
|
|
7124
7403
|
global: this.global
|
|
7125
7404
|
})
|
|
7126
7405
|
)
|
|
@@ -7152,48 +7431,48 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7152
7431
|
};
|
|
7153
7432
|
|
|
7154
7433
|
// src/features/rules/agentsmd-rule.ts
|
|
7155
|
-
import { join as
|
|
7434
|
+
import { join as join65 } from "path";
|
|
7156
7435
|
|
|
7157
7436
|
// src/features/rules/tool-rule.ts
|
|
7158
|
-
import { join as
|
|
7437
|
+
import { join as join64 } from "path";
|
|
7159
7438
|
|
|
7160
7439
|
// src/features/rules/rulesync-rule.ts
|
|
7161
|
-
import { basename as
|
|
7162
|
-
import { z as
|
|
7163
|
-
var RulesyncRuleFrontmatterSchema =
|
|
7164
|
-
root:
|
|
7165
|
-
targets:
|
|
7166
|
-
description:
|
|
7167
|
-
globs:
|
|
7168
|
-
agentsmd:
|
|
7169
|
-
|
|
7440
|
+
import { basename as basename19, join as join63 } from "path";
|
|
7441
|
+
import { z as z33 } from "zod/mini";
|
|
7442
|
+
var RulesyncRuleFrontmatterSchema = z33.object({
|
|
7443
|
+
root: z33.optional(z33.optional(z33.boolean())),
|
|
7444
|
+
targets: z33.optional(RulesyncTargetsSchema),
|
|
7445
|
+
description: z33.optional(z33.string()),
|
|
7446
|
+
globs: z33.optional(z33.array(z33.string())),
|
|
7447
|
+
agentsmd: z33.optional(
|
|
7448
|
+
z33.object({
|
|
7170
7449
|
// @example "path/to/subproject"
|
|
7171
|
-
subprojectPath:
|
|
7450
|
+
subprojectPath: z33.optional(z33.string())
|
|
7172
7451
|
})
|
|
7173
7452
|
),
|
|
7174
|
-
claudecode:
|
|
7175
|
-
|
|
7453
|
+
claudecode: z33.optional(
|
|
7454
|
+
z33.object({
|
|
7176
7455
|
// Glob patterns for conditional rules (takes precedence over globs)
|
|
7177
7456
|
// @example "src/**/*.ts, tests/**/*.test.ts"
|
|
7178
|
-
paths:
|
|
7457
|
+
paths: z33.optional(z33.string())
|
|
7179
7458
|
})
|
|
7180
7459
|
),
|
|
7181
|
-
cursor:
|
|
7182
|
-
|
|
7183
|
-
alwaysApply:
|
|
7184
|
-
description:
|
|
7185
|
-
globs:
|
|
7460
|
+
cursor: z33.optional(
|
|
7461
|
+
z33.object({
|
|
7462
|
+
alwaysApply: z33.optional(z33.boolean()),
|
|
7463
|
+
description: z33.optional(z33.string()),
|
|
7464
|
+
globs: z33.optional(z33.array(z33.string()))
|
|
7186
7465
|
})
|
|
7187
7466
|
),
|
|
7188
|
-
copilot:
|
|
7189
|
-
|
|
7190
|
-
excludeAgent:
|
|
7467
|
+
copilot: z33.optional(
|
|
7468
|
+
z33.object({
|
|
7469
|
+
excludeAgent: z33.optional(z33.union([z33.literal("code-review"), z33.literal("coding-agent")]))
|
|
7191
7470
|
})
|
|
7192
7471
|
),
|
|
7193
|
-
antigravity:
|
|
7194
|
-
|
|
7195
|
-
trigger:
|
|
7196
|
-
globs:
|
|
7472
|
+
antigravity: z33.optional(
|
|
7473
|
+
z33.looseObject({
|
|
7474
|
+
trigger: z33.optional(z33.string()),
|
|
7475
|
+
globs: z33.optional(z33.array(z33.string()))
|
|
7197
7476
|
})
|
|
7198
7477
|
)
|
|
7199
7478
|
});
|
|
@@ -7205,7 +7484,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7205
7484
|
const result = RulesyncRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7206
7485
|
if (!result.success) {
|
|
7207
7486
|
throw new Error(
|
|
7208
|
-
`Invalid frontmatter in ${
|
|
7487
|
+
`Invalid frontmatter in ${join63(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
7209
7488
|
);
|
|
7210
7489
|
}
|
|
7211
7490
|
}
|
|
@@ -7240,7 +7519,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7240
7519
|
return {
|
|
7241
7520
|
success: false,
|
|
7242
7521
|
error: new Error(
|
|
7243
|
-
`Invalid frontmatter in ${
|
|
7522
|
+
`Invalid frontmatter in ${join63(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
7244
7523
|
)
|
|
7245
7524
|
};
|
|
7246
7525
|
}
|
|
@@ -7249,12 +7528,12 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7249
7528
|
relativeFilePath,
|
|
7250
7529
|
validate = true
|
|
7251
7530
|
}) {
|
|
7252
|
-
const legacyPath =
|
|
7531
|
+
const legacyPath = join63(
|
|
7253
7532
|
process.cwd(),
|
|
7254
7533
|
this.getSettablePaths().legacy.relativeDirPath,
|
|
7255
7534
|
relativeFilePath
|
|
7256
7535
|
);
|
|
7257
|
-
const recommendedPath =
|
|
7536
|
+
const recommendedPath = join63(
|
|
7258
7537
|
this.getSettablePaths().recommended.relativeDirPath,
|
|
7259
7538
|
relativeFilePath
|
|
7260
7539
|
);
|
|
@@ -7273,7 +7552,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7273
7552
|
agentsmd: result.data.agentsmd,
|
|
7274
7553
|
cursor: result.data.cursor
|
|
7275
7554
|
};
|
|
7276
|
-
const filename =
|
|
7555
|
+
const filename = basename19(legacyPath);
|
|
7277
7556
|
return new _RulesyncRule({
|
|
7278
7557
|
baseDir: process.cwd(),
|
|
7279
7558
|
relativeDirPath: this.getSettablePaths().recommended.relativeDirPath,
|
|
@@ -7287,7 +7566,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7287
7566
|
relativeFilePath,
|
|
7288
7567
|
validate = true
|
|
7289
7568
|
}) {
|
|
7290
|
-
const filePath =
|
|
7569
|
+
const filePath = join63(
|
|
7291
7570
|
process.cwd(),
|
|
7292
7571
|
this.getSettablePaths().recommended.relativeDirPath,
|
|
7293
7572
|
relativeFilePath
|
|
@@ -7306,7 +7585,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7306
7585
|
agentsmd: result.data.agentsmd,
|
|
7307
7586
|
cursor: result.data.cursor
|
|
7308
7587
|
};
|
|
7309
|
-
const filename =
|
|
7588
|
+
const filename = basename19(filePath);
|
|
7310
7589
|
return new _RulesyncRule({
|
|
7311
7590
|
baseDir: process.cwd(),
|
|
7312
7591
|
relativeDirPath: this.getSettablePaths().recommended.relativeDirPath,
|
|
@@ -7389,7 +7668,7 @@ var ToolRule = class extends ToolFile {
|
|
|
7389
7668
|
rulesyncRule,
|
|
7390
7669
|
validate = true,
|
|
7391
7670
|
rootPath = { relativeDirPath: ".", relativeFilePath: "AGENTS.md" },
|
|
7392
|
-
nonRootPath = { relativeDirPath:
|
|
7671
|
+
nonRootPath = { relativeDirPath: join64(".agents", "memories") }
|
|
7393
7672
|
}) {
|
|
7394
7673
|
const params = this.buildToolRuleParamsDefault({
|
|
7395
7674
|
baseDir,
|
|
@@ -7400,7 +7679,7 @@ var ToolRule = class extends ToolFile {
|
|
|
7400
7679
|
});
|
|
7401
7680
|
const rulesyncFrontmatter = rulesyncRule.getFrontmatter();
|
|
7402
7681
|
if (!rulesyncFrontmatter.root && rulesyncFrontmatter.agentsmd?.subprojectPath) {
|
|
7403
|
-
params.relativeDirPath =
|
|
7682
|
+
params.relativeDirPath = join64(rulesyncFrontmatter.agentsmd.subprojectPath);
|
|
7404
7683
|
params.relativeFilePath = "AGENTS.md";
|
|
7405
7684
|
}
|
|
7406
7685
|
return params;
|
|
@@ -7465,7 +7744,7 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
7465
7744
|
relativeFilePath: "AGENTS.md"
|
|
7466
7745
|
},
|
|
7467
7746
|
nonRoot: {
|
|
7468
|
-
relativeDirPath:
|
|
7747
|
+
relativeDirPath: join65(".agents", "memories")
|
|
7469
7748
|
}
|
|
7470
7749
|
};
|
|
7471
7750
|
}
|
|
@@ -7475,8 +7754,8 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
7475
7754
|
validate = true
|
|
7476
7755
|
}) {
|
|
7477
7756
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
7478
|
-
const relativePath = isRoot ? "AGENTS.md" :
|
|
7479
|
-
const fileContent = await readFileContent(
|
|
7757
|
+
const relativePath = isRoot ? "AGENTS.md" : join65(".agents", "memories", relativeFilePath);
|
|
7758
|
+
const fileContent = await readFileContent(join65(baseDir, relativePath));
|
|
7480
7759
|
return new _AgentsMdRule({
|
|
7481
7760
|
baseDir,
|
|
7482
7761
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -7531,12 +7810,12 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
7531
7810
|
};
|
|
7532
7811
|
|
|
7533
7812
|
// src/features/rules/amazonqcli-rule.ts
|
|
7534
|
-
import { join as
|
|
7813
|
+
import { join as join66 } from "path";
|
|
7535
7814
|
var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
7536
7815
|
static getSettablePaths() {
|
|
7537
7816
|
return {
|
|
7538
7817
|
nonRoot: {
|
|
7539
|
-
relativeDirPath:
|
|
7818
|
+
relativeDirPath: join66(".amazonq", "rules")
|
|
7540
7819
|
}
|
|
7541
7820
|
};
|
|
7542
7821
|
}
|
|
@@ -7546,7 +7825,7 @@ var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
|
7546
7825
|
validate = true
|
|
7547
7826
|
}) {
|
|
7548
7827
|
const fileContent = await readFileContent(
|
|
7549
|
-
|
|
7828
|
+
join66(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7550
7829
|
);
|
|
7551
7830
|
return new _AmazonQCliRule({
|
|
7552
7831
|
baseDir,
|
|
@@ -7600,21 +7879,21 @@ var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
|
7600
7879
|
};
|
|
7601
7880
|
|
|
7602
7881
|
// src/features/rules/antigravity-rule.ts
|
|
7603
|
-
import { join as
|
|
7604
|
-
import { z as
|
|
7605
|
-
var AntigravityRuleFrontmatterSchema =
|
|
7606
|
-
trigger:
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
7882
|
+
import { join as join67 } from "path";
|
|
7883
|
+
import { z as z34 } from "zod/mini";
|
|
7884
|
+
var AntigravityRuleFrontmatterSchema = z34.looseObject({
|
|
7885
|
+
trigger: z34.optional(
|
|
7886
|
+
z34.union([
|
|
7887
|
+
z34.literal("always_on"),
|
|
7888
|
+
z34.literal("glob"),
|
|
7889
|
+
z34.literal("manual"),
|
|
7890
|
+
z34.literal("model_decision"),
|
|
7891
|
+
z34.string()
|
|
7613
7892
|
// accepts any string for forward compatibility
|
|
7614
7893
|
])
|
|
7615
7894
|
),
|
|
7616
|
-
globs:
|
|
7617
|
-
description:
|
|
7895
|
+
globs: z34.optional(z34.string()),
|
|
7896
|
+
description: z34.optional(z34.string())
|
|
7618
7897
|
});
|
|
7619
7898
|
function parseGlobsString(globs) {
|
|
7620
7899
|
if (!globs) {
|
|
@@ -7759,7 +8038,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7759
8038
|
const result = AntigravityRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7760
8039
|
if (!result.success) {
|
|
7761
8040
|
throw new Error(
|
|
7762
|
-
`Invalid frontmatter in ${
|
|
8041
|
+
`Invalid frontmatter in ${join67(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
7763
8042
|
);
|
|
7764
8043
|
}
|
|
7765
8044
|
}
|
|
@@ -7774,7 +8053,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7774
8053
|
static getSettablePaths() {
|
|
7775
8054
|
return {
|
|
7776
8055
|
nonRoot: {
|
|
7777
|
-
relativeDirPath:
|
|
8056
|
+
relativeDirPath: join67(".agent", "rules")
|
|
7778
8057
|
}
|
|
7779
8058
|
};
|
|
7780
8059
|
}
|
|
@@ -7783,7 +8062,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7783
8062
|
relativeFilePath,
|
|
7784
8063
|
validate = true
|
|
7785
8064
|
}) {
|
|
7786
|
-
const filePath =
|
|
8065
|
+
const filePath = join67(
|
|
7787
8066
|
baseDir,
|
|
7788
8067
|
this.getSettablePaths().nonRoot.relativeDirPath,
|
|
7789
8068
|
relativeFilePath
|
|
@@ -7924,7 +8203,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7924
8203
|
};
|
|
7925
8204
|
|
|
7926
8205
|
// src/features/rules/augmentcode-legacy-rule.ts
|
|
7927
|
-
import { join as
|
|
8206
|
+
import { join as join68 } from "path";
|
|
7928
8207
|
var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
7929
8208
|
toRulesyncRule() {
|
|
7930
8209
|
const rulesyncFrontmatter = {
|
|
@@ -7950,7 +8229,7 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
7950
8229
|
relativeFilePath: ".augment-guidelines"
|
|
7951
8230
|
},
|
|
7952
8231
|
nonRoot: {
|
|
7953
|
-
relativeDirPath:
|
|
8232
|
+
relativeDirPath: join68(".augment", "rules")
|
|
7954
8233
|
}
|
|
7955
8234
|
};
|
|
7956
8235
|
}
|
|
@@ -7985,8 +8264,8 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
7985
8264
|
}) {
|
|
7986
8265
|
const settablePaths = this.getSettablePaths();
|
|
7987
8266
|
const isRoot = relativeFilePath === settablePaths.root.relativeFilePath;
|
|
7988
|
-
const relativePath = isRoot ? settablePaths.root.relativeFilePath :
|
|
7989
|
-
const fileContent = await readFileContent(
|
|
8267
|
+
const relativePath = isRoot ? settablePaths.root.relativeFilePath : join68(settablePaths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8268
|
+
const fileContent = await readFileContent(join68(baseDir, relativePath));
|
|
7990
8269
|
return new _AugmentcodeLegacyRule({
|
|
7991
8270
|
baseDir,
|
|
7992
8271
|
relativeDirPath: isRoot ? settablePaths.root.relativeDirPath : settablePaths.nonRoot.relativeDirPath,
|
|
@@ -8015,7 +8294,7 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
8015
8294
|
};
|
|
8016
8295
|
|
|
8017
8296
|
// src/features/rules/augmentcode-rule.ts
|
|
8018
|
-
import { join as
|
|
8297
|
+
import { join as join69 } from "path";
|
|
8019
8298
|
var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
8020
8299
|
toRulesyncRule() {
|
|
8021
8300
|
return this.toRulesyncRuleDefault();
|
|
@@ -8023,7 +8302,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
8023
8302
|
static getSettablePaths() {
|
|
8024
8303
|
return {
|
|
8025
8304
|
nonRoot: {
|
|
8026
|
-
relativeDirPath:
|
|
8305
|
+
relativeDirPath: join69(".augment", "rules")
|
|
8027
8306
|
}
|
|
8028
8307
|
};
|
|
8029
8308
|
}
|
|
@@ -8047,7 +8326,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
8047
8326
|
validate = true
|
|
8048
8327
|
}) {
|
|
8049
8328
|
const fileContent = await readFileContent(
|
|
8050
|
-
|
|
8329
|
+
join69(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
8051
8330
|
);
|
|
8052
8331
|
const { body: content } = parseFrontmatter(fileContent);
|
|
8053
8332
|
return new _AugmentcodeRule({
|
|
@@ -8083,7 +8362,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
8083
8362
|
};
|
|
8084
8363
|
|
|
8085
8364
|
// src/features/rules/claudecode-legacy-rule.ts
|
|
8086
|
-
import { join as
|
|
8365
|
+
import { join as join70 } from "path";
|
|
8087
8366
|
var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
8088
8367
|
static getSettablePaths({
|
|
8089
8368
|
global
|
|
@@ -8102,7 +8381,7 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
8102
8381
|
relativeFilePath: "CLAUDE.md"
|
|
8103
8382
|
},
|
|
8104
8383
|
nonRoot: {
|
|
8105
|
-
relativeDirPath:
|
|
8384
|
+
relativeDirPath: join70(".claude", "memories")
|
|
8106
8385
|
}
|
|
8107
8386
|
};
|
|
8108
8387
|
}
|
|
@@ -8117,7 +8396,7 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
8117
8396
|
if (isRoot) {
|
|
8118
8397
|
const relativePath2 = paths.root.relativeFilePath;
|
|
8119
8398
|
const fileContent2 = await readFileContent(
|
|
8120
|
-
|
|
8399
|
+
join70(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
8121
8400
|
);
|
|
8122
8401
|
return new _ClaudecodeLegacyRule({
|
|
8123
8402
|
baseDir,
|
|
@@ -8131,8 +8410,8 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
8131
8410
|
if (!paths.nonRoot) {
|
|
8132
8411
|
throw new Error("nonRoot path is not set");
|
|
8133
8412
|
}
|
|
8134
|
-
const relativePath =
|
|
8135
|
-
const fileContent = await readFileContent(
|
|
8413
|
+
const relativePath = join70(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8414
|
+
const fileContent = await readFileContent(join70(baseDir, relativePath));
|
|
8136
8415
|
return new _ClaudecodeLegacyRule({
|
|
8137
8416
|
baseDir,
|
|
8138
8417
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -8191,10 +8470,10 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
8191
8470
|
};
|
|
8192
8471
|
|
|
8193
8472
|
// src/features/rules/claudecode-rule.ts
|
|
8194
|
-
import { join as
|
|
8195
|
-
import { z as
|
|
8196
|
-
var ClaudecodeRuleFrontmatterSchema =
|
|
8197
|
-
paths:
|
|
8473
|
+
import { join as join71 } from "path";
|
|
8474
|
+
import { z as z35 } from "zod/mini";
|
|
8475
|
+
var ClaudecodeRuleFrontmatterSchema = z35.object({
|
|
8476
|
+
paths: z35.optional(z35.string())
|
|
8198
8477
|
});
|
|
8199
8478
|
var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
8200
8479
|
frontmatter;
|
|
@@ -8216,7 +8495,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8216
8495
|
relativeFilePath: "CLAUDE.md"
|
|
8217
8496
|
},
|
|
8218
8497
|
nonRoot: {
|
|
8219
|
-
relativeDirPath:
|
|
8498
|
+
relativeDirPath: join71(".claude", "rules")
|
|
8220
8499
|
}
|
|
8221
8500
|
};
|
|
8222
8501
|
}
|
|
@@ -8225,7 +8504,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8225
8504
|
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8226
8505
|
if (!result.success) {
|
|
8227
8506
|
throw new Error(
|
|
8228
|
-
`Invalid frontmatter in ${
|
|
8507
|
+
`Invalid frontmatter in ${join71(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
8229
8508
|
);
|
|
8230
8509
|
}
|
|
8231
8510
|
}
|
|
@@ -8253,7 +8532,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8253
8532
|
const isRoot = relativeFilePath === paths.root.relativeFilePath;
|
|
8254
8533
|
if (isRoot) {
|
|
8255
8534
|
const fileContent2 = await readFileContent(
|
|
8256
|
-
|
|
8535
|
+
join71(baseDir, paths.root.relativeDirPath, paths.root.relativeFilePath)
|
|
8257
8536
|
);
|
|
8258
8537
|
return new _ClaudecodeRule({
|
|
8259
8538
|
baseDir,
|
|
@@ -8268,13 +8547,13 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8268
8547
|
if (!paths.nonRoot) {
|
|
8269
8548
|
throw new Error("nonRoot path is not set");
|
|
8270
8549
|
}
|
|
8271
|
-
const relativePath =
|
|
8272
|
-
const fileContent = await readFileContent(
|
|
8550
|
+
const relativePath = join71(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8551
|
+
const fileContent = await readFileContent(join71(baseDir, relativePath));
|
|
8273
8552
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
8274
8553
|
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8275
8554
|
if (!result.success) {
|
|
8276
8555
|
throw new Error(
|
|
8277
|
-
`Invalid frontmatter in ${
|
|
8556
|
+
`Invalid frontmatter in ${join71(baseDir, relativePath)}: ${formatError(result.error)}`
|
|
8278
8557
|
);
|
|
8279
8558
|
}
|
|
8280
8559
|
return new _ClaudecodeRule({
|
|
@@ -8381,7 +8660,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8381
8660
|
return {
|
|
8382
8661
|
success: false,
|
|
8383
8662
|
error: new Error(
|
|
8384
|
-
`Invalid frontmatter in ${
|
|
8663
|
+
`Invalid frontmatter in ${join71(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
8385
8664
|
)
|
|
8386
8665
|
};
|
|
8387
8666
|
}
|
|
@@ -8401,10 +8680,10 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8401
8680
|
};
|
|
8402
8681
|
|
|
8403
8682
|
// src/features/rules/cline-rule.ts
|
|
8404
|
-
import { join as
|
|
8405
|
-
import { z as
|
|
8406
|
-
var ClineRuleFrontmatterSchema =
|
|
8407
|
-
description:
|
|
8683
|
+
import { join as join72 } from "path";
|
|
8684
|
+
import { z as z36 } from "zod/mini";
|
|
8685
|
+
var ClineRuleFrontmatterSchema = z36.object({
|
|
8686
|
+
description: z36.string()
|
|
8408
8687
|
});
|
|
8409
8688
|
var ClineRule = class _ClineRule extends ToolRule {
|
|
8410
8689
|
static getSettablePaths() {
|
|
@@ -8446,7 +8725,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
8446
8725
|
validate = true
|
|
8447
8726
|
}) {
|
|
8448
8727
|
const fileContent = await readFileContent(
|
|
8449
|
-
|
|
8728
|
+
join72(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
8450
8729
|
);
|
|
8451
8730
|
return new _ClineRule({
|
|
8452
8731
|
baseDir,
|
|
@@ -8472,7 +8751,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
8472
8751
|
};
|
|
8473
8752
|
|
|
8474
8753
|
// src/features/rules/codexcli-rule.ts
|
|
8475
|
-
import { join as
|
|
8754
|
+
import { join as join73 } from "path";
|
|
8476
8755
|
var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
8477
8756
|
static getSettablePaths({
|
|
8478
8757
|
global
|
|
@@ -8491,7 +8770,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8491
8770
|
relativeFilePath: "AGENTS.md"
|
|
8492
8771
|
},
|
|
8493
8772
|
nonRoot: {
|
|
8494
|
-
relativeDirPath:
|
|
8773
|
+
relativeDirPath: join73(".codex", "memories")
|
|
8495
8774
|
}
|
|
8496
8775
|
};
|
|
8497
8776
|
}
|
|
@@ -8506,7 +8785,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8506
8785
|
if (isRoot) {
|
|
8507
8786
|
const relativePath2 = paths.root.relativeFilePath;
|
|
8508
8787
|
const fileContent2 = await readFileContent(
|
|
8509
|
-
|
|
8788
|
+
join73(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
8510
8789
|
);
|
|
8511
8790
|
return new _CodexcliRule({
|
|
8512
8791
|
baseDir,
|
|
@@ -8520,8 +8799,8 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8520
8799
|
if (!paths.nonRoot) {
|
|
8521
8800
|
throw new Error("nonRoot path is not set");
|
|
8522
8801
|
}
|
|
8523
|
-
const relativePath =
|
|
8524
|
-
const fileContent = await readFileContent(
|
|
8802
|
+
const relativePath = join73(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8803
|
+
const fileContent = await readFileContent(join73(baseDir, relativePath));
|
|
8525
8804
|
return new _CodexcliRule({
|
|
8526
8805
|
baseDir,
|
|
8527
8806
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -8580,12 +8859,12 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8580
8859
|
};
|
|
8581
8860
|
|
|
8582
8861
|
// src/features/rules/copilot-rule.ts
|
|
8583
|
-
import { join as
|
|
8584
|
-
import { z as
|
|
8585
|
-
var CopilotRuleFrontmatterSchema =
|
|
8586
|
-
description:
|
|
8587
|
-
applyTo:
|
|
8588
|
-
excludeAgent:
|
|
8862
|
+
import { join as join74 } from "path";
|
|
8863
|
+
import { z as z37 } from "zod/mini";
|
|
8864
|
+
var CopilotRuleFrontmatterSchema = z37.object({
|
|
8865
|
+
description: z37.optional(z37.string()),
|
|
8866
|
+
applyTo: z37.optional(z37.string()),
|
|
8867
|
+
excludeAgent: z37.optional(z37.union([z37.literal("code-review"), z37.literal("coding-agent")]))
|
|
8589
8868
|
});
|
|
8590
8869
|
var CopilotRule = class _CopilotRule extends ToolRule {
|
|
8591
8870
|
frontmatter;
|
|
@@ -8597,7 +8876,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8597
8876
|
relativeFilePath: "copilot-instructions.md"
|
|
8598
8877
|
},
|
|
8599
8878
|
nonRoot: {
|
|
8600
|
-
relativeDirPath:
|
|
8879
|
+
relativeDirPath: join74(".github", "instructions")
|
|
8601
8880
|
}
|
|
8602
8881
|
};
|
|
8603
8882
|
}
|
|
@@ -8606,7 +8885,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8606
8885
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8607
8886
|
if (!result.success) {
|
|
8608
8887
|
throw new Error(
|
|
8609
|
-
`Invalid frontmatter in ${
|
|
8888
|
+
`Invalid frontmatter in ${join74(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
8610
8889
|
);
|
|
8611
8890
|
}
|
|
8612
8891
|
}
|
|
@@ -8688,11 +8967,11 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8688
8967
|
validate = true
|
|
8689
8968
|
}) {
|
|
8690
8969
|
const isRoot = relativeFilePath === "copilot-instructions.md";
|
|
8691
|
-
const relativePath = isRoot ?
|
|
8970
|
+
const relativePath = isRoot ? join74(
|
|
8692
8971
|
this.getSettablePaths().root.relativeDirPath,
|
|
8693
8972
|
this.getSettablePaths().root.relativeFilePath
|
|
8694
|
-
) :
|
|
8695
|
-
const fileContent = await readFileContent(
|
|
8973
|
+
) : join74(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
8974
|
+
const fileContent = await readFileContent(join74(baseDir, relativePath));
|
|
8696
8975
|
if (isRoot) {
|
|
8697
8976
|
return new _CopilotRule({
|
|
8698
8977
|
baseDir,
|
|
@@ -8708,7 +8987,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8708
8987
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8709
8988
|
if (!result.success) {
|
|
8710
8989
|
throw new Error(
|
|
8711
|
-
`Invalid frontmatter in ${
|
|
8990
|
+
`Invalid frontmatter in ${join74(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
8712
8991
|
);
|
|
8713
8992
|
}
|
|
8714
8993
|
return new _CopilotRule({
|
|
@@ -8748,7 +9027,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8748
9027
|
return {
|
|
8749
9028
|
success: false,
|
|
8750
9029
|
error: new Error(
|
|
8751
|
-
`Invalid frontmatter in ${
|
|
9030
|
+
`Invalid frontmatter in ${join74(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
8752
9031
|
)
|
|
8753
9032
|
};
|
|
8754
9033
|
}
|
|
@@ -8768,12 +9047,12 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8768
9047
|
};
|
|
8769
9048
|
|
|
8770
9049
|
// src/features/rules/cursor-rule.ts
|
|
8771
|
-
import { basename as
|
|
8772
|
-
import { z as
|
|
8773
|
-
var CursorRuleFrontmatterSchema =
|
|
8774
|
-
description:
|
|
8775
|
-
globs:
|
|
8776
|
-
alwaysApply:
|
|
9050
|
+
import { basename as basename20, join as join75 } from "path";
|
|
9051
|
+
import { z as z38 } from "zod/mini";
|
|
9052
|
+
var CursorRuleFrontmatterSchema = z38.object({
|
|
9053
|
+
description: z38.optional(z38.string()),
|
|
9054
|
+
globs: z38.optional(z38.string()),
|
|
9055
|
+
alwaysApply: z38.optional(z38.boolean())
|
|
8777
9056
|
});
|
|
8778
9057
|
var CursorRule = class _CursorRule extends ToolRule {
|
|
8779
9058
|
frontmatter;
|
|
@@ -8781,7 +9060,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8781
9060
|
static getSettablePaths() {
|
|
8782
9061
|
return {
|
|
8783
9062
|
nonRoot: {
|
|
8784
|
-
relativeDirPath:
|
|
9063
|
+
relativeDirPath: join75(".cursor", "rules")
|
|
8785
9064
|
}
|
|
8786
9065
|
};
|
|
8787
9066
|
}
|
|
@@ -8790,7 +9069,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8790
9069
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8791
9070
|
if (!result.success) {
|
|
8792
9071
|
throw new Error(
|
|
8793
|
-
`Invalid frontmatter in ${
|
|
9072
|
+
`Invalid frontmatter in ${join75(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
8794
9073
|
);
|
|
8795
9074
|
}
|
|
8796
9075
|
}
|
|
@@ -8907,19 +9186,19 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8907
9186
|
validate = true
|
|
8908
9187
|
}) {
|
|
8909
9188
|
const fileContent = await readFileContent(
|
|
8910
|
-
|
|
9189
|
+
join75(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
8911
9190
|
);
|
|
8912
9191
|
const { frontmatter, body: content } = _CursorRule.parseCursorFrontmatter(fileContent);
|
|
8913
9192
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8914
9193
|
if (!result.success) {
|
|
8915
9194
|
throw new Error(
|
|
8916
|
-
`Invalid frontmatter in ${
|
|
9195
|
+
`Invalid frontmatter in ${join75(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
8917
9196
|
);
|
|
8918
9197
|
}
|
|
8919
9198
|
return new _CursorRule({
|
|
8920
9199
|
baseDir,
|
|
8921
9200
|
relativeDirPath: this.getSettablePaths().nonRoot.relativeDirPath,
|
|
8922
|
-
relativeFilePath:
|
|
9201
|
+
relativeFilePath: basename20(relativeFilePath),
|
|
8923
9202
|
frontmatter: result.data,
|
|
8924
9203
|
body: content.trim(),
|
|
8925
9204
|
validate
|
|
@@ -8950,7 +9229,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8950
9229
|
return {
|
|
8951
9230
|
success: false,
|
|
8952
9231
|
error: new Error(
|
|
8953
|
-
`Invalid frontmatter in ${
|
|
9232
|
+
`Invalid frontmatter in ${join75(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
8954
9233
|
)
|
|
8955
9234
|
};
|
|
8956
9235
|
}
|
|
@@ -8970,7 +9249,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8970
9249
|
};
|
|
8971
9250
|
|
|
8972
9251
|
// src/features/rules/geminicli-rule.ts
|
|
8973
|
-
import { join as
|
|
9252
|
+
import { join as join76 } from "path";
|
|
8974
9253
|
var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
8975
9254
|
static getSettablePaths({
|
|
8976
9255
|
global
|
|
@@ -8989,7 +9268,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
8989
9268
|
relativeFilePath: "GEMINI.md"
|
|
8990
9269
|
},
|
|
8991
9270
|
nonRoot: {
|
|
8992
|
-
relativeDirPath:
|
|
9271
|
+
relativeDirPath: join76(".gemini", "memories")
|
|
8993
9272
|
}
|
|
8994
9273
|
};
|
|
8995
9274
|
}
|
|
@@ -9004,7 +9283,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
9004
9283
|
if (isRoot) {
|
|
9005
9284
|
const relativePath2 = paths.root.relativeFilePath;
|
|
9006
9285
|
const fileContent2 = await readFileContent(
|
|
9007
|
-
|
|
9286
|
+
join76(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
9008
9287
|
);
|
|
9009
9288
|
return new _GeminiCliRule({
|
|
9010
9289
|
baseDir,
|
|
@@ -9018,8 +9297,8 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
9018
9297
|
if (!paths.nonRoot) {
|
|
9019
9298
|
throw new Error("nonRoot path is not set");
|
|
9020
9299
|
}
|
|
9021
|
-
const relativePath =
|
|
9022
|
-
const fileContent = await readFileContent(
|
|
9300
|
+
const relativePath = join76(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
9301
|
+
const fileContent = await readFileContent(join76(baseDir, relativePath));
|
|
9023
9302
|
return new _GeminiCliRule({
|
|
9024
9303
|
baseDir,
|
|
9025
9304
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -9078,7 +9357,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
9078
9357
|
};
|
|
9079
9358
|
|
|
9080
9359
|
// src/features/rules/junie-rule.ts
|
|
9081
|
-
import { join as
|
|
9360
|
+
import { join as join77 } from "path";
|
|
9082
9361
|
var JunieRule = class _JunieRule extends ToolRule {
|
|
9083
9362
|
static getSettablePaths() {
|
|
9084
9363
|
return {
|
|
@@ -9087,7 +9366,7 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
9087
9366
|
relativeFilePath: "guidelines.md"
|
|
9088
9367
|
},
|
|
9089
9368
|
nonRoot: {
|
|
9090
|
-
relativeDirPath:
|
|
9369
|
+
relativeDirPath: join77(".junie", "memories")
|
|
9091
9370
|
}
|
|
9092
9371
|
};
|
|
9093
9372
|
}
|
|
@@ -9097,8 +9376,8 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
9097
9376
|
validate = true
|
|
9098
9377
|
}) {
|
|
9099
9378
|
const isRoot = relativeFilePath === "guidelines.md";
|
|
9100
|
-
const relativePath = isRoot ? "guidelines.md" :
|
|
9101
|
-
const fileContent = await readFileContent(
|
|
9379
|
+
const relativePath = isRoot ? "guidelines.md" : join77(".junie", "memories", relativeFilePath);
|
|
9380
|
+
const fileContent = await readFileContent(join77(baseDir, relativePath));
|
|
9102
9381
|
return new _JunieRule({
|
|
9103
9382
|
baseDir,
|
|
9104
9383
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -9153,12 +9432,12 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
9153
9432
|
};
|
|
9154
9433
|
|
|
9155
9434
|
// src/features/rules/kiro-rule.ts
|
|
9156
|
-
import { join as
|
|
9435
|
+
import { join as join78 } from "path";
|
|
9157
9436
|
var KiroRule = class _KiroRule extends ToolRule {
|
|
9158
9437
|
static getSettablePaths() {
|
|
9159
9438
|
return {
|
|
9160
9439
|
nonRoot: {
|
|
9161
|
-
relativeDirPath:
|
|
9440
|
+
relativeDirPath: join78(".kiro", "steering")
|
|
9162
9441
|
}
|
|
9163
9442
|
};
|
|
9164
9443
|
}
|
|
@@ -9168,7 +9447,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
9168
9447
|
validate = true
|
|
9169
9448
|
}) {
|
|
9170
9449
|
const fileContent = await readFileContent(
|
|
9171
|
-
|
|
9450
|
+
join78(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
9172
9451
|
);
|
|
9173
9452
|
return new _KiroRule({
|
|
9174
9453
|
baseDir,
|
|
@@ -9222,7 +9501,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
9222
9501
|
};
|
|
9223
9502
|
|
|
9224
9503
|
// src/features/rules/opencode-rule.ts
|
|
9225
|
-
import { join as
|
|
9504
|
+
import { join as join79 } from "path";
|
|
9226
9505
|
var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
9227
9506
|
static getSettablePaths() {
|
|
9228
9507
|
return {
|
|
@@ -9231,7 +9510,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
9231
9510
|
relativeFilePath: "AGENTS.md"
|
|
9232
9511
|
},
|
|
9233
9512
|
nonRoot: {
|
|
9234
|
-
relativeDirPath:
|
|
9513
|
+
relativeDirPath: join79(".opencode", "memories")
|
|
9235
9514
|
}
|
|
9236
9515
|
};
|
|
9237
9516
|
}
|
|
@@ -9241,8 +9520,8 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
9241
9520
|
validate = true
|
|
9242
9521
|
}) {
|
|
9243
9522
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
9244
|
-
const relativePath = isRoot ? "AGENTS.md" :
|
|
9245
|
-
const fileContent = await readFileContent(
|
|
9523
|
+
const relativePath = isRoot ? "AGENTS.md" : join79(".opencode", "memories", relativeFilePath);
|
|
9524
|
+
const fileContent = await readFileContent(join79(baseDir, relativePath));
|
|
9246
9525
|
return new _OpenCodeRule({
|
|
9247
9526
|
baseDir,
|
|
9248
9527
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -9297,7 +9576,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
9297
9576
|
};
|
|
9298
9577
|
|
|
9299
9578
|
// src/features/rules/qwencode-rule.ts
|
|
9300
|
-
import { join as
|
|
9579
|
+
import { join as join80 } from "path";
|
|
9301
9580
|
var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
9302
9581
|
static getSettablePaths() {
|
|
9303
9582
|
return {
|
|
@@ -9306,7 +9585,7 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
9306
9585
|
relativeFilePath: "QWEN.md"
|
|
9307
9586
|
},
|
|
9308
9587
|
nonRoot: {
|
|
9309
|
-
relativeDirPath:
|
|
9588
|
+
relativeDirPath: join80(".qwen", "memories")
|
|
9310
9589
|
}
|
|
9311
9590
|
};
|
|
9312
9591
|
}
|
|
@@ -9316,8 +9595,8 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
9316
9595
|
validate = true
|
|
9317
9596
|
}) {
|
|
9318
9597
|
const isRoot = relativeFilePath === "QWEN.md";
|
|
9319
|
-
const relativePath = isRoot ? "QWEN.md" :
|
|
9320
|
-
const fileContent = await readFileContent(
|
|
9598
|
+
const relativePath = isRoot ? "QWEN.md" : join80(".qwen", "memories", relativeFilePath);
|
|
9599
|
+
const fileContent = await readFileContent(join80(baseDir, relativePath));
|
|
9321
9600
|
return new _QwencodeRule({
|
|
9322
9601
|
baseDir,
|
|
9323
9602
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -9369,12 +9648,12 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
9369
9648
|
};
|
|
9370
9649
|
|
|
9371
9650
|
// src/features/rules/roo-rule.ts
|
|
9372
|
-
import { join as
|
|
9651
|
+
import { join as join81 } from "path";
|
|
9373
9652
|
var RooRule = class _RooRule extends ToolRule {
|
|
9374
9653
|
static getSettablePaths() {
|
|
9375
9654
|
return {
|
|
9376
9655
|
nonRoot: {
|
|
9377
|
-
relativeDirPath:
|
|
9656
|
+
relativeDirPath: join81(".roo", "rules")
|
|
9378
9657
|
}
|
|
9379
9658
|
};
|
|
9380
9659
|
}
|
|
@@ -9384,7 +9663,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
9384
9663
|
validate = true
|
|
9385
9664
|
}) {
|
|
9386
9665
|
const fileContent = await readFileContent(
|
|
9387
|
-
|
|
9666
|
+
join81(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
9388
9667
|
);
|
|
9389
9668
|
return new _RooRule({
|
|
9390
9669
|
baseDir,
|
|
@@ -9453,7 +9732,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
9453
9732
|
};
|
|
9454
9733
|
|
|
9455
9734
|
// src/features/rules/warp-rule.ts
|
|
9456
|
-
import { join as
|
|
9735
|
+
import { join as join82 } from "path";
|
|
9457
9736
|
var WarpRule = class _WarpRule extends ToolRule {
|
|
9458
9737
|
constructor({ fileContent, root, ...rest }) {
|
|
9459
9738
|
super({
|
|
@@ -9469,7 +9748,7 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
9469
9748
|
relativeFilePath: "WARP.md"
|
|
9470
9749
|
},
|
|
9471
9750
|
nonRoot: {
|
|
9472
|
-
relativeDirPath:
|
|
9751
|
+
relativeDirPath: join82(".warp", "memories")
|
|
9473
9752
|
}
|
|
9474
9753
|
};
|
|
9475
9754
|
}
|
|
@@ -9479,8 +9758,8 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
9479
9758
|
validate = true
|
|
9480
9759
|
}) {
|
|
9481
9760
|
const isRoot = relativeFilePath === this.getSettablePaths().root.relativeFilePath;
|
|
9482
|
-
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath :
|
|
9483
|
-
const fileContent = await readFileContent(
|
|
9761
|
+
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath : join82(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
9762
|
+
const fileContent = await readFileContent(join82(baseDir, relativePath));
|
|
9484
9763
|
return new _WarpRule({
|
|
9485
9764
|
baseDir,
|
|
9486
9765
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : ".warp",
|
|
@@ -9535,12 +9814,12 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
9535
9814
|
};
|
|
9536
9815
|
|
|
9537
9816
|
// src/features/rules/windsurf-rule.ts
|
|
9538
|
-
import { join as
|
|
9817
|
+
import { join as join83 } from "path";
|
|
9539
9818
|
var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
9540
9819
|
static getSettablePaths() {
|
|
9541
9820
|
return {
|
|
9542
9821
|
nonRoot: {
|
|
9543
|
-
relativeDirPath:
|
|
9822
|
+
relativeDirPath: join83(".windsurf", "rules")
|
|
9544
9823
|
}
|
|
9545
9824
|
};
|
|
9546
9825
|
}
|
|
@@ -9550,7 +9829,7 @@ var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
|
9550
9829
|
validate = true
|
|
9551
9830
|
}) {
|
|
9552
9831
|
const fileContent = await readFileContent(
|
|
9553
|
-
|
|
9832
|
+
join83(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
9554
9833
|
);
|
|
9555
9834
|
return new _WindsurfRule({
|
|
9556
9835
|
baseDir,
|
|
@@ -9623,7 +9902,7 @@ var rulesProcessorToolTargets = [
|
|
|
9623
9902
|
"warp",
|
|
9624
9903
|
"windsurf"
|
|
9625
9904
|
];
|
|
9626
|
-
var RulesProcessorToolTargetSchema =
|
|
9905
|
+
var RulesProcessorToolTargetSchema = z39.enum(rulesProcessorToolTargets);
|
|
9627
9906
|
var toolRuleFactories = /* @__PURE__ */ new Map([
|
|
9628
9907
|
[
|
|
9629
9908
|
"agentsmd",
|
|
@@ -9908,7 +10187,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9908
10187
|
}).relativeDirPath;
|
|
9909
10188
|
return this.skills.filter((skill) => skillClass.isTargetedByRulesyncSkill(skill)).map((skill) => {
|
|
9910
10189
|
const frontmatter = skill.getFrontmatter();
|
|
9911
|
-
const relativePath =
|
|
10190
|
+
const relativePath = join84(toolRelativeDirPath, skill.getDirName(), SKILL_FILE_NAME);
|
|
9912
10191
|
return {
|
|
9913
10192
|
name: frontmatter.name,
|
|
9914
10193
|
description: frontmatter.description,
|
|
@@ -9975,10 +10254,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9975
10254
|
* Load and parse rulesync rule files from .rulesync/rules/ directory
|
|
9976
10255
|
*/
|
|
9977
10256
|
async loadRulesyncFiles() {
|
|
9978
|
-
const files = await findFilesByGlobs(
|
|
10257
|
+
const files = await findFilesByGlobs(join84(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md"));
|
|
9979
10258
|
logger.debug(`Found ${files.length} rulesync files`);
|
|
9980
10259
|
const rulesyncRules = await Promise.all(
|
|
9981
|
-
files.map((file) => RulesyncRule.fromFile({ relativeFilePath:
|
|
10260
|
+
files.map((file) => RulesyncRule.fromFile({ relativeFilePath: basename21(file) }))
|
|
9982
10261
|
);
|
|
9983
10262
|
const rootRules = rulesyncRules.filter((rule) => rule.getFrontmatter().root);
|
|
9984
10263
|
if (rootRules.length > 1) {
|
|
@@ -9996,10 +10275,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9996
10275
|
return rulesyncRules;
|
|
9997
10276
|
}
|
|
9998
10277
|
async loadRulesyncFilesLegacy() {
|
|
9999
|
-
const legacyFiles = await findFilesByGlobs(
|
|
10278
|
+
const legacyFiles = await findFilesByGlobs(join84(RULESYNC_RELATIVE_DIR_PATH, "*.md"));
|
|
10000
10279
|
logger.debug(`Found ${legacyFiles.length} legacy rulesync files`);
|
|
10001
10280
|
return Promise.all(
|
|
10002
|
-
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath:
|
|
10281
|
+
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath: basename21(file) }))
|
|
10003
10282
|
);
|
|
10004
10283
|
}
|
|
10005
10284
|
/**
|
|
@@ -10017,7 +10296,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10017
10296
|
return [];
|
|
10018
10297
|
}
|
|
10019
10298
|
const rootFilePaths = await findFilesByGlobs(
|
|
10020
|
-
|
|
10299
|
+
join84(
|
|
10021
10300
|
this.baseDir,
|
|
10022
10301
|
settablePaths.root.relativeDirPath ?? ".",
|
|
10023
10302
|
settablePaths.root.relativeFilePath
|
|
@@ -10028,7 +10307,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10028
10307
|
(filePath) => factory.class.forDeletion({
|
|
10029
10308
|
baseDir: this.baseDir,
|
|
10030
10309
|
relativeDirPath: settablePaths.root?.relativeDirPath ?? ".",
|
|
10031
|
-
relativeFilePath:
|
|
10310
|
+
relativeFilePath: basename21(filePath),
|
|
10032
10311
|
global: this.global
|
|
10033
10312
|
})
|
|
10034
10313
|
).filter((rule) => rule.isDeletable());
|
|
@@ -10037,7 +10316,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10037
10316
|
rootFilePaths.map(
|
|
10038
10317
|
(filePath) => factory.class.fromFile({
|
|
10039
10318
|
baseDir: this.baseDir,
|
|
10040
|
-
relativeFilePath:
|
|
10319
|
+
relativeFilePath: basename21(filePath),
|
|
10041
10320
|
global: this.global
|
|
10042
10321
|
})
|
|
10043
10322
|
)
|
|
@@ -10049,14 +10328,14 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10049
10328
|
return [];
|
|
10050
10329
|
}
|
|
10051
10330
|
const nonRootFilePaths = await findFilesByGlobs(
|
|
10052
|
-
|
|
10331
|
+
join84(this.baseDir, settablePaths.nonRoot.relativeDirPath, `*.${factory.meta.extension}`)
|
|
10053
10332
|
);
|
|
10054
10333
|
if (forDeletion) {
|
|
10055
10334
|
return nonRootFilePaths.map(
|
|
10056
10335
|
(filePath) => factory.class.forDeletion({
|
|
10057
10336
|
baseDir: this.baseDir,
|
|
10058
10337
|
relativeDirPath: settablePaths.nonRoot?.relativeDirPath ?? ".",
|
|
10059
|
-
relativeFilePath:
|
|
10338
|
+
relativeFilePath: basename21(filePath),
|
|
10060
10339
|
global: this.global
|
|
10061
10340
|
})
|
|
10062
10341
|
).filter((rule) => rule.isDeletable());
|
|
@@ -10065,7 +10344,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10065
10344
|
nonRootFilePaths.map(
|
|
10066
10345
|
(filePath) => factory.class.fromFile({
|
|
10067
10346
|
baseDir: this.baseDir,
|
|
10068
|
-
relativeFilePath:
|
|
10347
|
+
relativeFilePath: basename21(filePath),
|
|
10069
10348
|
global: this.global
|
|
10070
10349
|
})
|
|
10071
10350
|
)
|
|
@@ -10158,14 +10437,14 @@ s/<command> [arguments]
|
|
|
10158
10437
|
This syntax employs a double slash (\`s/\`) to prevent conflicts with built-in slash commands.
|
|
10159
10438
|
The \`s\` in \`s/\` stands for *simulate*. Because custom slash commands are not built-in, this syntax provides a pseudo way to invoke them.
|
|
10160
10439
|
|
|
10161
|
-
When users call a custom slash command, you have to look for the markdown file, \`${
|
|
10440
|
+
When users call a custom slash command, you have to look for the markdown file, \`${join84(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "{command}.md")}\`, then execute the contents of that file as the block of operations.` : "";
|
|
10162
10441
|
const subagentsSection = subagents ? `## Simulated Subagents
|
|
10163
10442
|
|
|
10164
10443
|
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.
|
|
10165
10444
|
|
|
10166
|
-
When users call a simulated subagent, it will look for the corresponding markdown file, \`${
|
|
10445
|
+
When users call a simulated subagent, it will look for the corresponding markdown file, \`${join84(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "{subagent}.md")}\`, and execute its contents as the block of operations.
|
|
10167
10446
|
|
|
10168
|
-
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${
|
|
10447
|
+
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${join84(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "planner.md")}\`, and execute its contents as the block of operations.` : "";
|
|
10169
10448
|
const skillsSection = skills ? this.generateSkillsSection(skills) : "";
|
|
10170
10449
|
const result = [
|
|
10171
10450
|
overview,
|
|
@@ -10447,7 +10726,7 @@ async function generateSkills(config) {
|
|
|
10447
10726
|
}
|
|
10448
10727
|
|
|
10449
10728
|
// src/cli/commands/gitignore.ts
|
|
10450
|
-
import { join as
|
|
10729
|
+
import { join as join85 } from "path";
|
|
10451
10730
|
var RULESYNC_HEADER = "# Generated by Rulesync";
|
|
10452
10731
|
var LEGACY_RULESYNC_HEADER = "# Generated by rulesync - AI tool configuration files";
|
|
10453
10732
|
var RULESYNC_IGNORE_ENTRIES = [
|
|
@@ -10504,6 +10783,7 @@ var RULESYNC_IGNORE_ENTRIES = [
|
|
|
10504
10783
|
// OpenCode
|
|
10505
10784
|
"**/.opencode/memories/",
|
|
10506
10785
|
"**/.opencode/command/",
|
|
10786
|
+
"**/.opencode/agent/",
|
|
10507
10787
|
"**/.opencode/skills/",
|
|
10508
10788
|
"**/opencode.json",
|
|
10509
10789
|
// Qwen
|
|
@@ -10571,7 +10851,7 @@ var removeExistingRulesyncEntries = (content) => {
|
|
|
10571
10851
|
return result;
|
|
10572
10852
|
};
|
|
10573
10853
|
var gitignoreCommand = async () => {
|
|
10574
|
-
const gitignorePath =
|
|
10854
|
+
const gitignorePath = join85(process.cwd(), ".gitignore");
|
|
10575
10855
|
let gitignoreContent = "";
|
|
10576
10856
|
if (await fileExists(gitignorePath)) {
|
|
10577
10857
|
gitignoreContent = await readFileContent(gitignorePath);
|
|
@@ -10770,7 +11050,7 @@ async function importSkills(config, tool) {
|
|
|
10770
11050
|
}
|
|
10771
11051
|
|
|
10772
11052
|
// src/cli/commands/init.ts
|
|
10773
|
-
import { join as
|
|
11053
|
+
import { join as join86 } from "path";
|
|
10774
11054
|
async function initCommand() {
|
|
10775
11055
|
logger.info("Initializing rulesync...");
|
|
10776
11056
|
await ensureDir(RULESYNC_RELATIVE_DIR_PATH);
|
|
@@ -10933,14 +11213,14 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
10933
11213
|
await ensureDir(commandPaths.relativeDirPath);
|
|
10934
11214
|
await ensureDir(subagentPaths.relativeDirPath);
|
|
10935
11215
|
await ensureDir(ignorePaths.recommended.relativeDirPath);
|
|
10936
|
-
const ruleFilepath =
|
|
11216
|
+
const ruleFilepath = join86(rulePaths.recommended.relativeDirPath, sampleRuleFile.filename);
|
|
10937
11217
|
if (!await fileExists(ruleFilepath)) {
|
|
10938
11218
|
await writeFileContent(ruleFilepath, sampleRuleFile.content);
|
|
10939
11219
|
logger.success(`Created ${ruleFilepath}`);
|
|
10940
11220
|
} else {
|
|
10941
11221
|
logger.info(`Skipped ${ruleFilepath} (already exists)`);
|
|
10942
11222
|
}
|
|
10943
|
-
const mcpFilepath =
|
|
11223
|
+
const mcpFilepath = join86(
|
|
10944
11224
|
mcpPaths.recommended.relativeDirPath,
|
|
10945
11225
|
mcpPaths.recommended.relativeFilePath
|
|
10946
11226
|
);
|
|
@@ -10950,21 +11230,21 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
10950
11230
|
} else {
|
|
10951
11231
|
logger.info(`Skipped ${mcpFilepath} (already exists)`);
|
|
10952
11232
|
}
|
|
10953
|
-
const commandFilepath =
|
|
11233
|
+
const commandFilepath = join86(commandPaths.relativeDirPath, sampleCommandFile.filename);
|
|
10954
11234
|
if (!await fileExists(commandFilepath)) {
|
|
10955
11235
|
await writeFileContent(commandFilepath, sampleCommandFile.content);
|
|
10956
11236
|
logger.success(`Created ${commandFilepath}`);
|
|
10957
11237
|
} else {
|
|
10958
11238
|
logger.info(`Skipped ${commandFilepath} (already exists)`);
|
|
10959
11239
|
}
|
|
10960
|
-
const subagentFilepath =
|
|
11240
|
+
const subagentFilepath = join86(subagentPaths.relativeDirPath, sampleSubagentFile.filename);
|
|
10961
11241
|
if (!await fileExists(subagentFilepath)) {
|
|
10962
11242
|
await writeFileContent(subagentFilepath, sampleSubagentFile.content);
|
|
10963
11243
|
logger.success(`Created ${subagentFilepath}`);
|
|
10964
11244
|
} else {
|
|
10965
11245
|
logger.info(`Skipped ${subagentFilepath} (already exists)`);
|
|
10966
11246
|
}
|
|
10967
|
-
const ignoreFilepath =
|
|
11247
|
+
const ignoreFilepath = join86(
|
|
10968
11248
|
ignorePaths.recommended.relativeDirPath,
|
|
10969
11249
|
ignorePaths.recommended.relativeFilePath
|
|
10970
11250
|
);
|
|
@@ -10979,13 +11259,16 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
10979
11259
|
// src/cli/commands/mcp.ts
|
|
10980
11260
|
import { FastMCP } from "fastmcp";
|
|
10981
11261
|
|
|
11262
|
+
// src/mcp/tools.ts
|
|
11263
|
+
import { z as z46 } from "zod/mini";
|
|
11264
|
+
|
|
10982
11265
|
// src/mcp/commands.ts
|
|
10983
|
-
import { basename as
|
|
10984
|
-
import { z as
|
|
11266
|
+
import { basename as basename22, join as join87 } from "path";
|
|
11267
|
+
import { z as z40 } from "zod/mini";
|
|
10985
11268
|
var maxCommandSizeBytes = 1024 * 1024;
|
|
10986
11269
|
var maxCommandsCount = 1e3;
|
|
10987
11270
|
async function listCommands() {
|
|
10988
|
-
const commandsDir =
|
|
11271
|
+
const commandsDir = join87(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
10989
11272
|
try {
|
|
10990
11273
|
const files = await listDirectoryFiles(commandsDir);
|
|
10991
11274
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -10997,7 +11280,7 @@ async function listCommands() {
|
|
|
10997
11280
|
});
|
|
10998
11281
|
const frontmatter = command.getFrontmatter();
|
|
10999
11282
|
return {
|
|
11000
|
-
relativePathFromCwd:
|
|
11283
|
+
relativePathFromCwd: join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, file),
|
|
11001
11284
|
frontmatter
|
|
11002
11285
|
};
|
|
11003
11286
|
} catch (error) {
|
|
@@ -11017,13 +11300,13 @@ async function getCommand({ relativePathFromCwd }) {
|
|
|
11017
11300
|
relativePath: relativePathFromCwd,
|
|
11018
11301
|
intendedRootDir: process.cwd()
|
|
11019
11302
|
});
|
|
11020
|
-
const filename =
|
|
11303
|
+
const filename = basename22(relativePathFromCwd);
|
|
11021
11304
|
try {
|
|
11022
11305
|
const command = await RulesyncCommand.fromFile({
|
|
11023
11306
|
relativeFilePath: filename
|
|
11024
11307
|
});
|
|
11025
11308
|
return {
|
|
11026
|
-
relativePathFromCwd:
|
|
11309
|
+
relativePathFromCwd: join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
11027
11310
|
frontmatter: command.getFrontmatter(),
|
|
11028
11311
|
body: command.getBody()
|
|
11029
11312
|
};
|
|
@@ -11042,7 +11325,7 @@ async function putCommand({
|
|
|
11042
11325
|
relativePath: relativePathFromCwd,
|
|
11043
11326
|
intendedRootDir: process.cwd()
|
|
11044
11327
|
});
|
|
11045
|
-
const filename =
|
|
11328
|
+
const filename = basename22(relativePathFromCwd);
|
|
11046
11329
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
11047
11330
|
if (estimatedSize > maxCommandSizeBytes) {
|
|
11048
11331
|
throw new Error(
|
|
@@ -11052,7 +11335,7 @@ async function putCommand({
|
|
|
11052
11335
|
try {
|
|
11053
11336
|
const existingCommands = await listCommands();
|
|
11054
11337
|
const isUpdate = existingCommands.some(
|
|
11055
|
-
(command2) => command2.relativePathFromCwd ===
|
|
11338
|
+
(command2) => command2.relativePathFromCwd === join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
11056
11339
|
);
|
|
11057
11340
|
if (!isUpdate && existingCommands.length >= maxCommandsCount) {
|
|
11058
11341
|
throw new Error(`Maximum number of commands (${maxCommandsCount}) reached`);
|
|
@@ -11067,11 +11350,11 @@ async function putCommand({
|
|
|
11067
11350
|
fileContent,
|
|
11068
11351
|
validate: true
|
|
11069
11352
|
});
|
|
11070
|
-
const commandsDir =
|
|
11353
|
+
const commandsDir = join87(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
11071
11354
|
await ensureDir(commandsDir);
|
|
11072
11355
|
await writeFileContent(command.getFilePath(), command.getFileContent());
|
|
11073
11356
|
return {
|
|
11074
|
-
relativePathFromCwd:
|
|
11357
|
+
relativePathFromCwd: join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
11075
11358
|
frontmatter: command.getFrontmatter(),
|
|
11076
11359
|
body: command.getBody()
|
|
11077
11360
|
};
|
|
@@ -11086,12 +11369,12 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
11086
11369
|
relativePath: relativePathFromCwd,
|
|
11087
11370
|
intendedRootDir: process.cwd()
|
|
11088
11371
|
});
|
|
11089
|
-
const filename =
|
|
11090
|
-
const fullPath =
|
|
11372
|
+
const filename = basename22(relativePathFromCwd);
|
|
11373
|
+
const fullPath = join87(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename);
|
|
11091
11374
|
try {
|
|
11092
11375
|
await removeFile(fullPath);
|
|
11093
11376
|
return {
|
|
11094
|
-
relativePathFromCwd:
|
|
11377
|
+
relativePathFromCwd: join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
11095
11378
|
};
|
|
11096
11379
|
} catch (error) {
|
|
11097
11380
|
throw new Error(`Failed to delete command file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -11100,23 +11383,23 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
11100
11383
|
}
|
|
11101
11384
|
}
|
|
11102
11385
|
var commandToolSchemas = {
|
|
11103
|
-
listCommands:
|
|
11104
|
-
getCommand:
|
|
11105
|
-
relativePathFromCwd:
|
|
11386
|
+
listCommands: z40.object({}),
|
|
11387
|
+
getCommand: z40.object({
|
|
11388
|
+
relativePathFromCwd: z40.string()
|
|
11106
11389
|
}),
|
|
11107
|
-
putCommand:
|
|
11108
|
-
relativePathFromCwd:
|
|
11390
|
+
putCommand: z40.object({
|
|
11391
|
+
relativePathFromCwd: z40.string(),
|
|
11109
11392
|
frontmatter: RulesyncCommandFrontmatterSchema,
|
|
11110
|
-
body:
|
|
11393
|
+
body: z40.string()
|
|
11111
11394
|
}),
|
|
11112
|
-
deleteCommand:
|
|
11113
|
-
relativePathFromCwd:
|
|
11395
|
+
deleteCommand: z40.object({
|
|
11396
|
+
relativePathFromCwd: z40.string()
|
|
11114
11397
|
})
|
|
11115
11398
|
};
|
|
11116
11399
|
var commandTools = {
|
|
11117
11400
|
listCommands: {
|
|
11118
11401
|
name: "listCommands",
|
|
11119
|
-
description: `List all commands from ${
|
|
11402
|
+
description: `List all commands from ${join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
11120
11403
|
parameters: commandToolSchemas.listCommands,
|
|
11121
11404
|
execute: async () => {
|
|
11122
11405
|
const commands = await listCommands();
|
|
@@ -11158,11 +11441,11 @@ var commandTools = {
|
|
|
11158
11441
|
};
|
|
11159
11442
|
|
|
11160
11443
|
// src/mcp/ignore.ts
|
|
11161
|
-
import { join as
|
|
11162
|
-
import { z as
|
|
11444
|
+
import { join as join88 } from "path";
|
|
11445
|
+
import { z as z41 } from "zod/mini";
|
|
11163
11446
|
var maxIgnoreFileSizeBytes = 100 * 1024;
|
|
11164
11447
|
async function getIgnoreFile() {
|
|
11165
|
-
const ignoreFilePath =
|
|
11448
|
+
const ignoreFilePath = join88(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
11166
11449
|
try {
|
|
11167
11450
|
const content = await readFileContent(ignoreFilePath);
|
|
11168
11451
|
return {
|
|
@@ -11176,7 +11459,7 @@ async function getIgnoreFile() {
|
|
|
11176
11459
|
}
|
|
11177
11460
|
}
|
|
11178
11461
|
async function putIgnoreFile({ content }) {
|
|
11179
|
-
const ignoreFilePath =
|
|
11462
|
+
const ignoreFilePath = join88(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
11180
11463
|
const contentSizeBytes = Buffer.byteLength(content, "utf8");
|
|
11181
11464
|
if (contentSizeBytes > maxIgnoreFileSizeBytes) {
|
|
11182
11465
|
throw new Error(
|
|
@@ -11197,8 +11480,8 @@ async function putIgnoreFile({ content }) {
|
|
|
11197
11480
|
}
|
|
11198
11481
|
}
|
|
11199
11482
|
async function deleteIgnoreFile() {
|
|
11200
|
-
const aiignorePath =
|
|
11201
|
-
const legacyIgnorePath =
|
|
11483
|
+
const aiignorePath = join88(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
11484
|
+
const legacyIgnorePath = join88(process.cwd(), RULESYNC_IGNORE_RELATIVE_FILE_PATH);
|
|
11202
11485
|
try {
|
|
11203
11486
|
await Promise.all([removeFile(aiignorePath), removeFile(legacyIgnorePath)]);
|
|
11204
11487
|
return {
|
|
@@ -11216,11 +11499,11 @@ async function deleteIgnoreFile() {
|
|
|
11216
11499
|
}
|
|
11217
11500
|
}
|
|
11218
11501
|
var ignoreToolSchemas = {
|
|
11219
|
-
getIgnoreFile:
|
|
11220
|
-
putIgnoreFile:
|
|
11221
|
-
content:
|
|
11502
|
+
getIgnoreFile: z41.object({}),
|
|
11503
|
+
putIgnoreFile: z41.object({
|
|
11504
|
+
content: z41.string()
|
|
11222
11505
|
}),
|
|
11223
|
-
deleteIgnoreFile:
|
|
11506
|
+
deleteIgnoreFile: z41.object({})
|
|
11224
11507
|
};
|
|
11225
11508
|
var ignoreTools = {
|
|
11226
11509
|
getIgnoreFile: {
|
|
@@ -11253,8 +11536,8 @@ var ignoreTools = {
|
|
|
11253
11536
|
};
|
|
11254
11537
|
|
|
11255
11538
|
// src/mcp/mcp.ts
|
|
11256
|
-
import { join as
|
|
11257
|
-
import { z as
|
|
11539
|
+
import { join as join89 } from "path";
|
|
11540
|
+
import { z as z42 } from "zod/mini";
|
|
11258
11541
|
var maxMcpSizeBytes = 1024 * 1024;
|
|
11259
11542
|
async function getMcpFile() {
|
|
11260
11543
|
const config = await ConfigResolver.resolve({});
|
|
@@ -11263,7 +11546,7 @@ async function getMcpFile() {
|
|
|
11263
11546
|
validate: true,
|
|
11264
11547
|
modularMcp: config.getModularMcp()
|
|
11265
11548
|
});
|
|
11266
|
-
const relativePathFromCwd =
|
|
11549
|
+
const relativePathFromCwd = join89(
|
|
11267
11550
|
rulesyncMcp.getRelativeDirPath(),
|
|
11268
11551
|
rulesyncMcp.getRelativeFilePath()
|
|
11269
11552
|
);
|
|
@@ -11296,7 +11579,7 @@ async function putMcpFile({ content }) {
|
|
|
11296
11579
|
const paths = RulesyncMcp.getSettablePaths();
|
|
11297
11580
|
const relativeDirPath = paths.recommended.relativeDirPath;
|
|
11298
11581
|
const relativeFilePath = paths.recommended.relativeFilePath;
|
|
11299
|
-
const fullPath =
|
|
11582
|
+
const fullPath = join89(baseDir, relativeDirPath, relativeFilePath);
|
|
11300
11583
|
const rulesyncMcp = new RulesyncMcp({
|
|
11301
11584
|
baseDir,
|
|
11302
11585
|
relativeDirPath,
|
|
@@ -11305,9 +11588,9 @@ async function putMcpFile({ content }) {
|
|
|
11305
11588
|
validate: true,
|
|
11306
11589
|
modularMcp: config.getModularMcp()
|
|
11307
11590
|
});
|
|
11308
|
-
await ensureDir(
|
|
11591
|
+
await ensureDir(join89(baseDir, relativeDirPath));
|
|
11309
11592
|
await writeFileContent(fullPath, content);
|
|
11310
|
-
const relativePathFromCwd =
|
|
11593
|
+
const relativePathFromCwd = join89(relativeDirPath, relativeFilePath);
|
|
11311
11594
|
return {
|
|
11312
11595
|
relativePathFromCwd,
|
|
11313
11596
|
content: rulesyncMcp.getFileContent()
|
|
@@ -11322,15 +11605,15 @@ async function deleteMcpFile() {
|
|
|
11322
11605
|
try {
|
|
11323
11606
|
const baseDir = process.cwd();
|
|
11324
11607
|
const paths = RulesyncMcp.getSettablePaths();
|
|
11325
|
-
const recommendedPath =
|
|
11608
|
+
const recommendedPath = join89(
|
|
11326
11609
|
baseDir,
|
|
11327
11610
|
paths.recommended.relativeDirPath,
|
|
11328
11611
|
paths.recommended.relativeFilePath
|
|
11329
11612
|
);
|
|
11330
|
-
const legacyPath =
|
|
11613
|
+
const legacyPath = join89(baseDir, paths.legacy.relativeDirPath, paths.legacy.relativeFilePath);
|
|
11331
11614
|
await removeFile(recommendedPath);
|
|
11332
11615
|
await removeFile(legacyPath);
|
|
11333
|
-
const relativePathFromCwd =
|
|
11616
|
+
const relativePathFromCwd = join89(
|
|
11334
11617
|
paths.recommended.relativeDirPath,
|
|
11335
11618
|
paths.recommended.relativeFilePath
|
|
11336
11619
|
);
|
|
@@ -11344,11 +11627,11 @@ async function deleteMcpFile() {
|
|
|
11344
11627
|
}
|
|
11345
11628
|
}
|
|
11346
11629
|
var mcpToolSchemas = {
|
|
11347
|
-
getMcpFile:
|
|
11348
|
-
putMcpFile:
|
|
11349
|
-
content:
|
|
11630
|
+
getMcpFile: z42.object({}),
|
|
11631
|
+
putMcpFile: z42.object({
|
|
11632
|
+
content: z42.string()
|
|
11350
11633
|
}),
|
|
11351
|
-
deleteMcpFile:
|
|
11634
|
+
deleteMcpFile: z42.object({})
|
|
11352
11635
|
};
|
|
11353
11636
|
var mcpTools = {
|
|
11354
11637
|
getMcpFile: {
|
|
@@ -11381,12 +11664,12 @@ var mcpTools = {
|
|
|
11381
11664
|
};
|
|
11382
11665
|
|
|
11383
11666
|
// src/mcp/rules.ts
|
|
11384
|
-
import { basename as
|
|
11385
|
-
import { z as
|
|
11667
|
+
import { basename as basename23, join as join90 } from "path";
|
|
11668
|
+
import { z as z43 } from "zod/mini";
|
|
11386
11669
|
var maxRuleSizeBytes = 1024 * 1024;
|
|
11387
11670
|
var maxRulesCount = 1e3;
|
|
11388
11671
|
async function listRules() {
|
|
11389
|
-
const rulesDir =
|
|
11672
|
+
const rulesDir = join90(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
11390
11673
|
try {
|
|
11391
11674
|
const files = await listDirectoryFiles(rulesDir);
|
|
11392
11675
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -11399,7 +11682,7 @@ async function listRules() {
|
|
|
11399
11682
|
});
|
|
11400
11683
|
const frontmatter = rule.getFrontmatter();
|
|
11401
11684
|
return {
|
|
11402
|
-
relativePathFromCwd:
|
|
11685
|
+
relativePathFromCwd: join90(RULESYNC_RULES_RELATIVE_DIR_PATH, file),
|
|
11403
11686
|
frontmatter
|
|
11404
11687
|
};
|
|
11405
11688
|
} catch (error) {
|
|
@@ -11419,14 +11702,14 @@ async function getRule({ relativePathFromCwd }) {
|
|
|
11419
11702
|
relativePath: relativePathFromCwd,
|
|
11420
11703
|
intendedRootDir: process.cwd()
|
|
11421
11704
|
});
|
|
11422
|
-
const filename =
|
|
11705
|
+
const filename = basename23(relativePathFromCwd);
|
|
11423
11706
|
try {
|
|
11424
11707
|
const rule = await RulesyncRule.fromFile({
|
|
11425
11708
|
relativeFilePath: filename,
|
|
11426
11709
|
validate: true
|
|
11427
11710
|
});
|
|
11428
11711
|
return {
|
|
11429
|
-
relativePathFromCwd:
|
|
11712
|
+
relativePathFromCwd: join90(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
11430
11713
|
frontmatter: rule.getFrontmatter(),
|
|
11431
11714
|
body: rule.getBody()
|
|
11432
11715
|
};
|
|
@@ -11445,7 +11728,7 @@ async function putRule({
|
|
|
11445
11728
|
relativePath: relativePathFromCwd,
|
|
11446
11729
|
intendedRootDir: process.cwd()
|
|
11447
11730
|
});
|
|
11448
|
-
const filename =
|
|
11731
|
+
const filename = basename23(relativePathFromCwd);
|
|
11449
11732
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
11450
11733
|
if (estimatedSize > maxRuleSizeBytes) {
|
|
11451
11734
|
throw new Error(
|
|
@@ -11455,7 +11738,7 @@ async function putRule({
|
|
|
11455
11738
|
try {
|
|
11456
11739
|
const existingRules = await listRules();
|
|
11457
11740
|
const isUpdate = existingRules.some(
|
|
11458
|
-
(rule2) => rule2.relativePathFromCwd ===
|
|
11741
|
+
(rule2) => rule2.relativePathFromCwd === join90(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
11459
11742
|
);
|
|
11460
11743
|
if (!isUpdate && existingRules.length >= maxRulesCount) {
|
|
11461
11744
|
throw new Error(`Maximum number of rules (${maxRulesCount}) reached`);
|
|
@@ -11468,11 +11751,11 @@ async function putRule({
|
|
|
11468
11751
|
body,
|
|
11469
11752
|
validate: true
|
|
11470
11753
|
});
|
|
11471
|
-
const rulesDir =
|
|
11754
|
+
const rulesDir = join90(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
11472
11755
|
await ensureDir(rulesDir);
|
|
11473
11756
|
await writeFileContent(rule.getFilePath(), rule.getFileContent());
|
|
11474
11757
|
return {
|
|
11475
|
-
relativePathFromCwd:
|
|
11758
|
+
relativePathFromCwd: join90(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
11476
11759
|
frontmatter: rule.getFrontmatter(),
|
|
11477
11760
|
body: rule.getBody()
|
|
11478
11761
|
};
|
|
@@ -11487,12 +11770,12 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
11487
11770
|
relativePath: relativePathFromCwd,
|
|
11488
11771
|
intendedRootDir: process.cwd()
|
|
11489
11772
|
});
|
|
11490
|
-
const filename =
|
|
11491
|
-
const fullPath =
|
|
11773
|
+
const filename = basename23(relativePathFromCwd);
|
|
11774
|
+
const fullPath = join90(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH, filename);
|
|
11492
11775
|
try {
|
|
11493
11776
|
await removeFile(fullPath);
|
|
11494
11777
|
return {
|
|
11495
|
-
relativePathFromCwd:
|
|
11778
|
+
relativePathFromCwd: join90(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
11496
11779
|
};
|
|
11497
11780
|
} catch (error) {
|
|
11498
11781
|
throw new Error(`Failed to delete rule file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -11501,23 +11784,23 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
11501
11784
|
}
|
|
11502
11785
|
}
|
|
11503
11786
|
var ruleToolSchemas = {
|
|
11504
|
-
listRules:
|
|
11505
|
-
getRule:
|
|
11506
|
-
relativePathFromCwd:
|
|
11787
|
+
listRules: z43.object({}),
|
|
11788
|
+
getRule: z43.object({
|
|
11789
|
+
relativePathFromCwd: z43.string()
|
|
11507
11790
|
}),
|
|
11508
|
-
putRule:
|
|
11509
|
-
relativePathFromCwd:
|
|
11791
|
+
putRule: z43.object({
|
|
11792
|
+
relativePathFromCwd: z43.string(),
|
|
11510
11793
|
frontmatter: RulesyncRuleFrontmatterSchema,
|
|
11511
|
-
body:
|
|
11794
|
+
body: z43.string()
|
|
11512
11795
|
}),
|
|
11513
|
-
deleteRule:
|
|
11514
|
-
relativePathFromCwd:
|
|
11796
|
+
deleteRule: z43.object({
|
|
11797
|
+
relativePathFromCwd: z43.string()
|
|
11515
11798
|
})
|
|
11516
11799
|
};
|
|
11517
11800
|
var ruleTools = {
|
|
11518
11801
|
listRules: {
|
|
11519
11802
|
name: "listRules",
|
|
11520
|
-
description: `List all rules from ${
|
|
11803
|
+
description: `List all rules from ${join90(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
11521
11804
|
parameters: ruleToolSchemas.listRules,
|
|
11522
11805
|
execute: async () => {
|
|
11523
11806
|
const rules = await listRules();
|
|
@@ -11559,8 +11842,8 @@ var ruleTools = {
|
|
|
11559
11842
|
};
|
|
11560
11843
|
|
|
11561
11844
|
// src/mcp/skills.ts
|
|
11562
|
-
import { basename as
|
|
11563
|
-
import { z as
|
|
11845
|
+
import { basename as basename24, dirname as dirname2, join as join91 } from "path";
|
|
11846
|
+
import { z as z44 } from "zod/mini";
|
|
11564
11847
|
var maxSkillSizeBytes = 1024 * 1024;
|
|
11565
11848
|
var maxSkillsCount = 1e3;
|
|
11566
11849
|
function aiDirFileToMcpSkillFile(file) {
|
|
@@ -11576,19 +11859,19 @@ function mcpSkillFileToAiDirFile(file) {
|
|
|
11576
11859
|
};
|
|
11577
11860
|
}
|
|
11578
11861
|
function extractDirName(relativeDirPathFromCwd) {
|
|
11579
|
-
const dirName =
|
|
11862
|
+
const dirName = basename24(relativeDirPathFromCwd);
|
|
11580
11863
|
if (!dirName) {
|
|
11581
11864
|
throw new Error(`Invalid path: ${relativeDirPathFromCwd}`);
|
|
11582
11865
|
}
|
|
11583
11866
|
return dirName;
|
|
11584
11867
|
}
|
|
11585
11868
|
async function listSkills() {
|
|
11586
|
-
const skillsDir =
|
|
11869
|
+
const skillsDir = join91(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH);
|
|
11587
11870
|
try {
|
|
11588
|
-
const skillDirPaths = await findFilesByGlobs(
|
|
11871
|
+
const skillDirPaths = await findFilesByGlobs(join91(skillsDir, "*"), { type: "dir" });
|
|
11589
11872
|
const skills = await Promise.all(
|
|
11590
11873
|
skillDirPaths.map(async (dirPath) => {
|
|
11591
|
-
const dirName =
|
|
11874
|
+
const dirName = basename24(dirPath);
|
|
11592
11875
|
if (!dirName) return null;
|
|
11593
11876
|
try {
|
|
11594
11877
|
const skill = await RulesyncSkill.fromDir({
|
|
@@ -11596,7 +11879,7 @@ async function listSkills() {
|
|
|
11596
11879
|
});
|
|
11597
11880
|
const frontmatter = skill.getFrontmatter();
|
|
11598
11881
|
return {
|
|
11599
|
-
relativeDirPathFromCwd:
|
|
11882
|
+
relativeDirPathFromCwd: join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
11600
11883
|
frontmatter
|
|
11601
11884
|
};
|
|
11602
11885
|
} catch (error) {
|
|
@@ -11622,7 +11905,7 @@ async function getSkill({ relativeDirPathFromCwd }) {
|
|
|
11622
11905
|
dirName
|
|
11623
11906
|
});
|
|
11624
11907
|
return {
|
|
11625
|
-
relativeDirPathFromCwd:
|
|
11908
|
+
relativeDirPathFromCwd: join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
11626
11909
|
frontmatter: skill.getFrontmatter(),
|
|
11627
11910
|
body: skill.getBody(),
|
|
11628
11911
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -11656,7 +11939,7 @@ async function putSkill({
|
|
|
11656
11939
|
try {
|
|
11657
11940
|
const existingSkills = await listSkills();
|
|
11658
11941
|
const isUpdate = existingSkills.some(
|
|
11659
|
-
(skill2) => skill2.relativeDirPathFromCwd ===
|
|
11942
|
+
(skill2) => skill2.relativeDirPathFromCwd === join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
11660
11943
|
);
|
|
11661
11944
|
if (!isUpdate && existingSkills.length >= maxSkillsCount) {
|
|
11662
11945
|
throw new Error(`Maximum number of skills (${maxSkillsCount}) reached`);
|
|
@@ -11671,9 +11954,9 @@ async function putSkill({
|
|
|
11671
11954
|
otherFiles: aiDirFiles,
|
|
11672
11955
|
validate: true
|
|
11673
11956
|
});
|
|
11674
|
-
const skillDirPath =
|
|
11957
|
+
const skillDirPath = join91(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
11675
11958
|
await ensureDir(skillDirPath);
|
|
11676
|
-
const skillFilePath =
|
|
11959
|
+
const skillFilePath = join91(skillDirPath, SKILL_FILE_NAME);
|
|
11677
11960
|
const skillFileContent = stringifyFrontmatter(body, frontmatter);
|
|
11678
11961
|
await writeFileContent(skillFilePath, skillFileContent);
|
|
11679
11962
|
for (const file of otherFiles) {
|
|
@@ -11681,15 +11964,15 @@ async function putSkill({
|
|
|
11681
11964
|
relativePath: file.name,
|
|
11682
11965
|
intendedRootDir: skillDirPath
|
|
11683
11966
|
});
|
|
11684
|
-
const filePath =
|
|
11685
|
-
const fileDir =
|
|
11967
|
+
const filePath = join91(skillDirPath, file.name);
|
|
11968
|
+
const fileDir = join91(skillDirPath, dirname2(file.name));
|
|
11686
11969
|
if (fileDir !== skillDirPath) {
|
|
11687
11970
|
await ensureDir(fileDir);
|
|
11688
11971
|
}
|
|
11689
11972
|
await writeFileContent(filePath, file.body);
|
|
11690
11973
|
}
|
|
11691
11974
|
return {
|
|
11692
|
-
relativeDirPathFromCwd:
|
|
11975
|
+
relativeDirPathFromCwd: join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
11693
11976
|
frontmatter: skill.getFrontmatter(),
|
|
11694
11977
|
body: skill.getBody(),
|
|
11695
11978
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -11711,13 +11994,13 @@ async function deleteSkill({
|
|
|
11711
11994
|
intendedRootDir: process.cwd()
|
|
11712
11995
|
});
|
|
11713
11996
|
const dirName = extractDirName(relativeDirPathFromCwd);
|
|
11714
|
-
const skillDirPath =
|
|
11997
|
+
const skillDirPath = join91(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
11715
11998
|
try {
|
|
11716
11999
|
if (await directoryExists(skillDirPath)) {
|
|
11717
12000
|
await removeDirectory(skillDirPath);
|
|
11718
12001
|
}
|
|
11719
12002
|
return {
|
|
11720
|
-
relativeDirPathFromCwd:
|
|
12003
|
+
relativeDirPathFromCwd: join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
11721
12004
|
};
|
|
11722
12005
|
} catch (error) {
|
|
11723
12006
|
throw new Error(
|
|
@@ -11728,29 +12011,29 @@ async function deleteSkill({
|
|
|
11728
12011
|
);
|
|
11729
12012
|
}
|
|
11730
12013
|
}
|
|
11731
|
-
var McpSkillFileSchema =
|
|
11732
|
-
name:
|
|
11733
|
-
body:
|
|
12014
|
+
var McpSkillFileSchema = z44.object({
|
|
12015
|
+
name: z44.string(),
|
|
12016
|
+
body: z44.string()
|
|
11734
12017
|
});
|
|
11735
12018
|
var skillToolSchemas = {
|
|
11736
|
-
listSkills:
|
|
11737
|
-
getSkill:
|
|
11738
|
-
relativeDirPathFromCwd:
|
|
12019
|
+
listSkills: z44.object({}),
|
|
12020
|
+
getSkill: z44.object({
|
|
12021
|
+
relativeDirPathFromCwd: z44.string()
|
|
11739
12022
|
}),
|
|
11740
|
-
putSkill:
|
|
11741
|
-
relativeDirPathFromCwd:
|
|
12023
|
+
putSkill: z44.object({
|
|
12024
|
+
relativeDirPathFromCwd: z44.string(),
|
|
11742
12025
|
frontmatter: RulesyncSkillFrontmatterSchema,
|
|
11743
|
-
body:
|
|
11744
|
-
otherFiles:
|
|
12026
|
+
body: z44.string(),
|
|
12027
|
+
otherFiles: z44.optional(z44.array(McpSkillFileSchema))
|
|
11745
12028
|
}),
|
|
11746
|
-
deleteSkill:
|
|
11747
|
-
relativeDirPathFromCwd:
|
|
12029
|
+
deleteSkill: z44.object({
|
|
12030
|
+
relativeDirPathFromCwd: z44.string()
|
|
11748
12031
|
})
|
|
11749
12032
|
};
|
|
11750
12033
|
var skillTools = {
|
|
11751
12034
|
listSkills: {
|
|
11752
12035
|
name: "listSkills",
|
|
11753
|
-
description: `List all skills from ${
|
|
12036
|
+
description: `List all skills from ${join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "*", SKILL_FILE_NAME)} with their frontmatter.`,
|
|
11754
12037
|
parameters: skillToolSchemas.listSkills,
|
|
11755
12038
|
execute: async () => {
|
|
11756
12039
|
const skills = await listSkills();
|
|
@@ -11793,12 +12076,12 @@ var skillTools = {
|
|
|
11793
12076
|
};
|
|
11794
12077
|
|
|
11795
12078
|
// src/mcp/subagents.ts
|
|
11796
|
-
import { basename as
|
|
11797
|
-
import { z as
|
|
12079
|
+
import { basename as basename25, join as join92 } from "path";
|
|
12080
|
+
import { z as z45 } from "zod/mini";
|
|
11798
12081
|
var maxSubagentSizeBytes = 1024 * 1024;
|
|
11799
12082
|
var maxSubagentsCount = 1e3;
|
|
11800
12083
|
async function listSubagents() {
|
|
11801
|
-
const subagentsDir =
|
|
12084
|
+
const subagentsDir = join92(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
11802
12085
|
try {
|
|
11803
12086
|
const files = await listDirectoryFiles(subagentsDir);
|
|
11804
12087
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -11811,7 +12094,7 @@ async function listSubagents() {
|
|
|
11811
12094
|
});
|
|
11812
12095
|
const frontmatter = subagent.getFrontmatter();
|
|
11813
12096
|
return {
|
|
11814
|
-
relativePathFromCwd:
|
|
12097
|
+
relativePathFromCwd: join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, file),
|
|
11815
12098
|
frontmatter
|
|
11816
12099
|
};
|
|
11817
12100
|
} catch (error) {
|
|
@@ -11833,14 +12116,14 @@ async function getSubagent({ relativePathFromCwd }) {
|
|
|
11833
12116
|
relativePath: relativePathFromCwd,
|
|
11834
12117
|
intendedRootDir: process.cwd()
|
|
11835
12118
|
});
|
|
11836
|
-
const filename =
|
|
12119
|
+
const filename = basename25(relativePathFromCwd);
|
|
11837
12120
|
try {
|
|
11838
12121
|
const subagent = await RulesyncSubagent.fromFile({
|
|
11839
12122
|
relativeFilePath: filename,
|
|
11840
12123
|
validate: true
|
|
11841
12124
|
});
|
|
11842
12125
|
return {
|
|
11843
|
-
relativePathFromCwd:
|
|
12126
|
+
relativePathFromCwd: join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
11844
12127
|
frontmatter: subagent.getFrontmatter(),
|
|
11845
12128
|
body: subagent.getBody()
|
|
11846
12129
|
};
|
|
@@ -11859,7 +12142,7 @@ async function putSubagent({
|
|
|
11859
12142
|
relativePath: relativePathFromCwd,
|
|
11860
12143
|
intendedRootDir: process.cwd()
|
|
11861
12144
|
});
|
|
11862
|
-
const filename =
|
|
12145
|
+
const filename = basename25(relativePathFromCwd);
|
|
11863
12146
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
11864
12147
|
if (estimatedSize > maxSubagentSizeBytes) {
|
|
11865
12148
|
throw new Error(
|
|
@@ -11869,7 +12152,7 @@ async function putSubagent({
|
|
|
11869
12152
|
try {
|
|
11870
12153
|
const existingSubagents = await listSubagents();
|
|
11871
12154
|
const isUpdate = existingSubagents.some(
|
|
11872
|
-
(subagent2) => subagent2.relativePathFromCwd ===
|
|
12155
|
+
(subagent2) => subagent2.relativePathFromCwd === join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
11873
12156
|
);
|
|
11874
12157
|
if (!isUpdate && existingSubagents.length >= maxSubagentsCount) {
|
|
11875
12158
|
throw new Error(`Maximum number of subagents (${maxSubagentsCount}) reached`);
|
|
@@ -11882,11 +12165,11 @@ async function putSubagent({
|
|
|
11882
12165
|
body,
|
|
11883
12166
|
validate: true
|
|
11884
12167
|
});
|
|
11885
|
-
const subagentsDir =
|
|
12168
|
+
const subagentsDir = join92(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
11886
12169
|
await ensureDir(subagentsDir);
|
|
11887
12170
|
await writeFileContent(subagent.getFilePath(), subagent.getFileContent());
|
|
11888
12171
|
return {
|
|
11889
|
-
relativePathFromCwd:
|
|
12172
|
+
relativePathFromCwd: join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
11890
12173
|
frontmatter: subagent.getFrontmatter(),
|
|
11891
12174
|
body: subagent.getBody()
|
|
11892
12175
|
};
|
|
@@ -11901,12 +12184,12 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
11901
12184
|
relativePath: relativePathFromCwd,
|
|
11902
12185
|
intendedRootDir: process.cwd()
|
|
11903
12186
|
});
|
|
11904
|
-
const filename =
|
|
11905
|
-
const fullPath =
|
|
12187
|
+
const filename = basename25(relativePathFromCwd);
|
|
12188
|
+
const fullPath = join92(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename);
|
|
11906
12189
|
try {
|
|
11907
12190
|
await removeFile(fullPath);
|
|
11908
12191
|
return {
|
|
11909
|
-
relativePathFromCwd:
|
|
12192
|
+
relativePathFromCwd: join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
11910
12193
|
};
|
|
11911
12194
|
} catch (error) {
|
|
11912
12195
|
throw new Error(
|
|
@@ -11918,23 +12201,23 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
11918
12201
|
}
|
|
11919
12202
|
}
|
|
11920
12203
|
var subagentToolSchemas = {
|
|
11921
|
-
listSubagents:
|
|
11922
|
-
getSubagent:
|
|
11923
|
-
relativePathFromCwd:
|
|
12204
|
+
listSubagents: z45.object({}),
|
|
12205
|
+
getSubagent: z45.object({
|
|
12206
|
+
relativePathFromCwd: z45.string()
|
|
11924
12207
|
}),
|
|
11925
|
-
putSubagent:
|
|
11926
|
-
relativePathFromCwd:
|
|
12208
|
+
putSubagent: z45.object({
|
|
12209
|
+
relativePathFromCwd: z45.string(),
|
|
11927
12210
|
frontmatter: RulesyncSubagentFrontmatterSchema,
|
|
11928
|
-
body:
|
|
12211
|
+
body: z45.string()
|
|
11929
12212
|
}),
|
|
11930
|
-
deleteSubagent:
|
|
11931
|
-
relativePathFromCwd:
|
|
12213
|
+
deleteSubagent: z45.object({
|
|
12214
|
+
relativePathFromCwd: z45.string()
|
|
11932
12215
|
})
|
|
11933
12216
|
};
|
|
11934
12217
|
var subagentTools = {
|
|
11935
12218
|
listSubagents: {
|
|
11936
12219
|
name: "listSubagents",
|
|
11937
|
-
description: `List all subagents from ${
|
|
12220
|
+
description: `List all subagents from ${join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
11938
12221
|
parameters: subagentToolSchemas.listSubagents,
|
|
11939
12222
|
execute: async () => {
|
|
11940
12223
|
const subagents = await listSubagents();
|
|
@@ -11975,6 +12258,200 @@ var subagentTools = {
|
|
|
11975
12258
|
}
|
|
11976
12259
|
};
|
|
11977
12260
|
|
|
12261
|
+
// src/mcp/tools.ts
|
|
12262
|
+
var rulesyncFeatureSchema = z46.enum(["rule", "command", "subagent", "skill", "ignore", "mcp"]);
|
|
12263
|
+
var rulesyncOperationSchema = z46.enum(["list", "get", "put", "delete"]);
|
|
12264
|
+
var skillFileSchema = z46.object({
|
|
12265
|
+
name: z46.string(),
|
|
12266
|
+
body: z46.string()
|
|
12267
|
+
});
|
|
12268
|
+
var rulesyncToolSchema = z46.object({
|
|
12269
|
+
feature: rulesyncFeatureSchema,
|
|
12270
|
+
operation: rulesyncOperationSchema,
|
|
12271
|
+
targetPathFromCwd: z46.optional(z46.string()),
|
|
12272
|
+
frontmatter: z46.optional(z46.unknown()),
|
|
12273
|
+
body: z46.optional(z46.string()),
|
|
12274
|
+
otherFiles: z46.optional(z46.array(skillFileSchema)),
|
|
12275
|
+
content: z46.optional(z46.string())
|
|
12276
|
+
});
|
|
12277
|
+
var supportedOperationsByFeature = {
|
|
12278
|
+
rule: ["list", "get", "put", "delete"],
|
|
12279
|
+
command: ["list", "get", "put", "delete"],
|
|
12280
|
+
subagent: ["list", "get", "put", "delete"],
|
|
12281
|
+
skill: ["list", "get", "put", "delete"],
|
|
12282
|
+
ignore: ["get", "put", "delete"],
|
|
12283
|
+
mcp: ["get", "put", "delete"]
|
|
12284
|
+
};
|
|
12285
|
+
function assertSupported({
|
|
12286
|
+
feature,
|
|
12287
|
+
operation
|
|
12288
|
+
}) {
|
|
12289
|
+
const supportedOperations = supportedOperationsByFeature[feature];
|
|
12290
|
+
if (!supportedOperations.includes(operation)) {
|
|
12291
|
+
throw new Error(
|
|
12292
|
+
`Operation ${operation} is not supported for feature ${feature}. Supported operations: ${supportedOperations.join(
|
|
12293
|
+
", "
|
|
12294
|
+
)}`
|
|
12295
|
+
);
|
|
12296
|
+
}
|
|
12297
|
+
}
|
|
12298
|
+
function requireTargetPath({ targetPathFromCwd, feature, operation }) {
|
|
12299
|
+
if (!targetPathFromCwd) {
|
|
12300
|
+
throw new Error(`targetPathFromCwd is required for ${feature} ${operation} operation`);
|
|
12301
|
+
}
|
|
12302
|
+
return targetPathFromCwd;
|
|
12303
|
+
}
|
|
12304
|
+
function parseFrontmatter2({
|
|
12305
|
+
feature,
|
|
12306
|
+
frontmatter
|
|
12307
|
+
}) {
|
|
12308
|
+
switch (feature) {
|
|
12309
|
+
case "rule": {
|
|
12310
|
+
return RulesyncRuleFrontmatterSchema.parse(frontmatter);
|
|
12311
|
+
}
|
|
12312
|
+
case "command": {
|
|
12313
|
+
return RulesyncCommandFrontmatterSchema.parse(frontmatter);
|
|
12314
|
+
}
|
|
12315
|
+
case "subagent": {
|
|
12316
|
+
return RulesyncSubagentFrontmatterSchema.parse(frontmatter);
|
|
12317
|
+
}
|
|
12318
|
+
case "skill": {
|
|
12319
|
+
return RulesyncSkillFrontmatterSchema.parse(frontmatter);
|
|
12320
|
+
}
|
|
12321
|
+
}
|
|
12322
|
+
}
|
|
12323
|
+
function ensureBody({ body, feature, operation }) {
|
|
12324
|
+
if (!body) {
|
|
12325
|
+
throw new Error(`body is required for ${feature} ${operation} operation`);
|
|
12326
|
+
}
|
|
12327
|
+
return body;
|
|
12328
|
+
}
|
|
12329
|
+
var rulesyncTool = {
|
|
12330
|
+
name: "rulesyncTool",
|
|
12331
|
+
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).",
|
|
12332
|
+
parameters: rulesyncToolSchema,
|
|
12333
|
+
execute: async (args) => {
|
|
12334
|
+
const parsed = rulesyncToolSchema.parse(args);
|
|
12335
|
+
assertSupported({ feature: parsed.feature, operation: parsed.operation });
|
|
12336
|
+
switch (parsed.feature) {
|
|
12337
|
+
case "rule": {
|
|
12338
|
+
if (parsed.operation === "list") {
|
|
12339
|
+
return ruleTools.listRules.execute();
|
|
12340
|
+
}
|
|
12341
|
+
if (parsed.operation === "get") {
|
|
12342
|
+
return ruleTools.getRule.execute({ relativePathFromCwd: requireTargetPath(parsed) });
|
|
12343
|
+
}
|
|
12344
|
+
if (parsed.operation === "put") {
|
|
12345
|
+
return ruleTools.putRule.execute({
|
|
12346
|
+
relativePathFromCwd: requireTargetPath(parsed),
|
|
12347
|
+
frontmatter: parseFrontmatter2({
|
|
12348
|
+
feature: "rule",
|
|
12349
|
+
frontmatter: parsed.frontmatter ?? {}
|
|
12350
|
+
}),
|
|
12351
|
+
body: ensureBody(parsed)
|
|
12352
|
+
});
|
|
12353
|
+
}
|
|
12354
|
+
return ruleTools.deleteRule.execute({ relativePathFromCwd: requireTargetPath(parsed) });
|
|
12355
|
+
}
|
|
12356
|
+
case "command": {
|
|
12357
|
+
if (parsed.operation === "list") {
|
|
12358
|
+
return commandTools.listCommands.execute();
|
|
12359
|
+
}
|
|
12360
|
+
if (parsed.operation === "get") {
|
|
12361
|
+
return commandTools.getCommand.execute({
|
|
12362
|
+
relativePathFromCwd: requireTargetPath(parsed)
|
|
12363
|
+
});
|
|
12364
|
+
}
|
|
12365
|
+
if (parsed.operation === "put") {
|
|
12366
|
+
return commandTools.putCommand.execute({
|
|
12367
|
+
relativePathFromCwd: requireTargetPath(parsed),
|
|
12368
|
+
frontmatter: parseFrontmatter2({
|
|
12369
|
+
feature: "command",
|
|
12370
|
+
frontmatter: parsed.frontmatter ?? {}
|
|
12371
|
+
}),
|
|
12372
|
+
body: ensureBody(parsed)
|
|
12373
|
+
});
|
|
12374
|
+
}
|
|
12375
|
+
return commandTools.deleteCommand.execute({
|
|
12376
|
+
relativePathFromCwd: requireTargetPath(parsed)
|
|
12377
|
+
});
|
|
12378
|
+
}
|
|
12379
|
+
case "subagent": {
|
|
12380
|
+
if (parsed.operation === "list") {
|
|
12381
|
+
return subagentTools.listSubagents.execute();
|
|
12382
|
+
}
|
|
12383
|
+
if (parsed.operation === "get") {
|
|
12384
|
+
return subagentTools.getSubagent.execute({
|
|
12385
|
+
relativePathFromCwd: requireTargetPath(parsed)
|
|
12386
|
+
});
|
|
12387
|
+
}
|
|
12388
|
+
if (parsed.operation === "put") {
|
|
12389
|
+
return subagentTools.putSubagent.execute({
|
|
12390
|
+
relativePathFromCwd: requireTargetPath(parsed),
|
|
12391
|
+
frontmatter: parseFrontmatter2({
|
|
12392
|
+
feature: "subagent",
|
|
12393
|
+
frontmatter: parsed.frontmatter ?? {}
|
|
12394
|
+
}),
|
|
12395
|
+
body: ensureBody(parsed)
|
|
12396
|
+
});
|
|
12397
|
+
}
|
|
12398
|
+
return subagentTools.deleteSubagent.execute({
|
|
12399
|
+
relativePathFromCwd: requireTargetPath(parsed)
|
|
12400
|
+
});
|
|
12401
|
+
}
|
|
12402
|
+
case "skill": {
|
|
12403
|
+
if (parsed.operation === "list") {
|
|
12404
|
+
return skillTools.listSkills.execute();
|
|
12405
|
+
}
|
|
12406
|
+
if (parsed.operation === "get") {
|
|
12407
|
+
return skillTools.getSkill.execute({ relativeDirPathFromCwd: requireTargetPath(parsed) });
|
|
12408
|
+
}
|
|
12409
|
+
if (parsed.operation === "put") {
|
|
12410
|
+
return skillTools.putSkill.execute({
|
|
12411
|
+
relativeDirPathFromCwd: requireTargetPath(parsed),
|
|
12412
|
+
frontmatter: parseFrontmatter2({
|
|
12413
|
+
feature: "skill",
|
|
12414
|
+
frontmatter: parsed.frontmatter ?? {}
|
|
12415
|
+
}),
|
|
12416
|
+
body: ensureBody(parsed),
|
|
12417
|
+
otherFiles: parsed.otherFiles ?? []
|
|
12418
|
+
});
|
|
12419
|
+
}
|
|
12420
|
+
return skillTools.deleteSkill.execute({
|
|
12421
|
+
relativeDirPathFromCwd: requireTargetPath(parsed)
|
|
12422
|
+
});
|
|
12423
|
+
}
|
|
12424
|
+
case "ignore": {
|
|
12425
|
+
if (parsed.operation === "get") {
|
|
12426
|
+
return ignoreTools.getIgnoreFile.execute();
|
|
12427
|
+
}
|
|
12428
|
+
if (parsed.operation === "put") {
|
|
12429
|
+
if (!parsed.content) {
|
|
12430
|
+
throw new Error("content is required for ignore put operation");
|
|
12431
|
+
}
|
|
12432
|
+
return ignoreTools.putIgnoreFile.execute({ content: parsed.content });
|
|
12433
|
+
}
|
|
12434
|
+
return ignoreTools.deleteIgnoreFile.execute();
|
|
12435
|
+
}
|
|
12436
|
+
case "mcp": {
|
|
12437
|
+
if (parsed.operation === "get") {
|
|
12438
|
+
return mcpTools.getMcpFile.execute();
|
|
12439
|
+
}
|
|
12440
|
+
if (parsed.operation === "put") {
|
|
12441
|
+
if (!parsed.content) {
|
|
12442
|
+
throw new Error("content is required for mcp put operation");
|
|
12443
|
+
}
|
|
12444
|
+
return mcpTools.putMcpFile.execute({ content: parsed.content });
|
|
12445
|
+
}
|
|
12446
|
+
return mcpTools.deleteMcpFile.execute();
|
|
12447
|
+
}
|
|
12448
|
+
default: {
|
|
12449
|
+
throw new Error(`Unknown feature: ${parsed.feature}`);
|
|
12450
|
+
}
|
|
12451
|
+
}
|
|
12452
|
+
}
|
|
12453
|
+
};
|
|
12454
|
+
|
|
11978
12455
|
// src/cli/commands/mcp.ts
|
|
11979
12456
|
async function mcpCommand({ version }) {
|
|
11980
12457
|
const server = new FastMCP({
|
|
@@ -11983,28 +12460,7 @@ async function mcpCommand({ version }) {
|
|
|
11983
12460
|
version,
|
|
11984
12461
|
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."
|
|
11985
12462
|
});
|
|
11986
|
-
server.addTool(
|
|
11987
|
-
server.addTool(ruleTools.getRule);
|
|
11988
|
-
server.addTool(ruleTools.putRule);
|
|
11989
|
-
server.addTool(ruleTools.deleteRule);
|
|
11990
|
-
server.addTool(commandTools.listCommands);
|
|
11991
|
-
server.addTool(commandTools.getCommand);
|
|
11992
|
-
server.addTool(commandTools.putCommand);
|
|
11993
|
-
server.addTool(commandTools.deleteCommand);
|
|
11994
|
-
server.addTool(subagentTools.listSubagents);
|
|
11995
|
-
server.addTool(subagentTools.getSubagent);
|
|
11996
|
-
server.addTool(subagentTools.putSubagent);
|
|
11997
|
-
server.addTool(subagentTools.deleteSubagent);
|
|
11998
|
-
server.addTool(skillTools.listSkills);
|
|
11999
|
-
server.addTool(skillTools.getSkill);
|
|
12000
|
-
server.addTool(skillTools.putSkill);
|
|
12001
|
-
server.addTool(skillTools.deleteSkill);
|
|
12002
|
-
server.addTool(ignoreTools.getIgnoreFile);
|
|
12003
|
-
server.addTool(ignoreTools.putIgnoreFile);
|
|
12004
|
-
server.addTool(ignoreTools.deleteIgnoreFile);
|
|
12005
|
-
server.addTool(mcpTools.getMcpFile);
|
|
12006
|
-
server.addTool(mcpTools.putMcpFile);
|
|
12007
|
-
server.addTool(mcpTools.deleteMcpFile);
|
|
12463
|
+
server.addTool(rulesyncTool);
|
|
12008
12464
|
logger.info("Rulesync MCP server started via stdio");
|
|
12009
12465
|
void server.start({
|
|
12010
12466
|
transportType: "stdio"
|
|
@@ -12012,7 +12468,7 @@ async function mcpCommand({ version }) {
|
|
|
12012
12468
|
}
|
|
12013
12469
|
|
|
12014
12470
|
// src/cli/index.ts
|
|
12015
|
-
var getVersion = () => "4.
|
|
12471
|
+
var getVersion = () => "4.3.0";
|
|
12016
12472
|
var main = async () => {
|
|
12017
12473
|
const program = new Command();
|
|
12018
12474
|
const version = getVersion();
|