rulesync 8.4.0 → 8.6.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 +1 -1
- package/dist/{chunk-MMBSR2RA.js → chunk-ILMHM7BF.js} +1027 -604
- package/dist/cli/index.cjs +1494 -971
- package/dist/cli/index.js +127 -25
- package/dist/index.cjs +965 -541
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/cli/index.cjs
CHANGED
|
@@ -41,8 +41,13 @@ var ALL_FEATURES = [
|
|
|
41
41
|
var ALL_FEATURES_WITH_WILDCARD = [...ALL_FEATURES, "*"];
|
|
42
42
|
var FeatureSchema = import_mini.z.enum(ALL_FEATURES);
|
|
43
43
|
var FeaturesSchema = import_mini.z.array(FeatureSchema);
|
|
44
|
+
var GitignoreDestinationSchema = import_mini.z.enum(["gitignore", "gitattributes"]);
|
|
44
45
|
var FeatureOptionsSchema = import_mini.z.record(import_mini.z.string(), import_mini.z.unknown());
|
|
45
|
-
var FeatureValueSchema = import_mini.z.union([
|
|
46
|
+
var FeatureValueSchema = import_mini.z.union([
|
|
47
|
+
import_mini.z.boolean(),
|
|
48
|
+
FeatureOptionsSchema,
|
|
49
|
+
GitignoreDestinationSchema
|
|
50
|
+
]);
|
|
46
51
|
var PerFeatureConfigSchema = import_mini.z.record(import_mini.z.string(), FeatureValueSchema);
|
|
47
52
|
var PerTargetFeaturesValueSchema = import_mini.z.union([
|
|
48
53
|
import_mini.z.array(import_mini.z.enum(ALL_FEATURES_WITH_WILDCARD)),
|
|
@@ -79,7 +84,7 @@ function formatError(error) {
|
|
|
79
84
|
var parseCommaSeparatedList = (value) => value.split(",").map((s) => s.trim()).filter(Boolean);
|
|
80
85
|
|
|
81
86
|
// src/lib/fetch.ts
|
|
82
|
-
var
|
|
87
|
+
var import_node_path133 = require("path");
|
|
83
88
|
var import_promise = require("es-toolkit/promise");
|
|
84
89
|
|
|
85
90
|
// src/constants/rulesync-paths.ts
|
|
@@ -8652,9 +8657,9 @@ var McpProcessor = class extends FeatureProcessor {
|
|
|
8652
8657
|
};
|
|
8653
8658
|
|
|
8654
8659
|
// src/features/rules/rules-processor.ts
|
|
8655
|
-
var
|
|
8660
|
+
var import_node_path132 = require("path");
|
|
8656
8661
|
var import_toon = require("@toon-format/toon");
|
|
8657
|
-
var
|
|
8662
|
+
var import_mini66 = require("zod/mini");
|
|
8658
8663
|
|
|
8659
8664
|
// src/constants/general.ts
|
|
8660
8665
|
var SKILL_FILE_NAME = "SKILL.md";
|
|
@@ -9442,8 +9447,8 @@ var RovodevSkill = class _RovodevSkill extends ToolSkill {
|
|
|
9442
9447
|
};
|
|
9443
9448
|
|
|
9444
9449
|
// src/features/skills/skills-processor.ts
|
|
9445
|
-
var
|
|
9446
|
-
var
|
|
9450
|
+
var import_node_path87 = require("path");
|
|
9451
|
+
var import_mini46 = require("zod/mini");
|
|
9447
9452
|
|
|
9448
9453
|
// src/types/dir-feature-processor.ts
|
|
9449
9454
|
var import_node_path69 = require("path");
|
|
@@ -12083,6 +12088,166 @@ async function getLocalSkillDirNames(baseDir) {
|
|
|
12083
12088
|
return names;
|
|
12084
12089
|
}
|
|
12085
12090
|
|
|
12091
|
+
// src/features/skills/windsurf-skill.ts
|
|
12092
|
+
var import_node_path86 = require("path");
|
|
12093
|
+
var import_mini45 = require("zod/mini");
|
|
12094
|
+
var WindsurfSkillFrontmatterSchema = import_mini45.z.looseObject({
|
|
12095
|
+
name: import_mini45.z.string(),
|
|
12096
|
+
description: import_mini45.z.string()
|
|
12097
|
+
});
|
|
12098
|
+
var WindsurfSkill = class _WindsurfSkill extends ToolSkill {
|
|
12099
|
+
constructor({
|
|
12100
|
+
baseDir = process.cwd(),
|
|
12101
|
+
relativeDirPath = _WindsurfSkill.getSettablePaths().relativeDirPath,
|
|
12102
|
+
dirName,
|
|
12103
|
+
frontmatter,
|
|
12104
|
+
body,
|
|
12105
|
+
otherFiles = [],
|
|
12106
|
+
validate = true,
|
|
12107
|
+
global = false
|
|
12108
|
+
}) {
|
|
12109
|
+
super({
|
|
12110
|
+
baseDir,
|
|
12111
|
+
relativeDirPath,
|
|
12112
|
+
dirName,
|
|
12113
|
+
mainFile: {
|
|
12114
|
+
name: SKILL_FILE_NAME,
|
|
12115
|
+
body,
|
|
12116
|
+
frontmatter: { ...frontmatter }
|
|
12117
|
+
},
|
|
12118
|
+
otherFiles,
|
|
12119
|
+
global
|
|
12120
|
+
});
|
|
12121
|
+
if (validate) {
|
|
12122
|
+
const result = this.validate();
|
|
12123
|
+
if (!result.success) {
|
|
12124
|
+
throw result.error;
|
|
12125
|
+
}
|
|
12126
|
+
}
|
|
12127
|
+
}
|
|
12128
|
+
static getSettablePaths({ global = false } = {}) {
|
|
12129
|
+
if (global) {
|
|
12130
|
+
return {
|
|
12131
|
+
relativeDirPath: (0, import_node_path86.join)(".codeium", "windsurf", "skills")
|
|
12132
|
+
};
|
|
12133
|
+
}
|
|
12134
|
+
return {
|
|
12135
|
+
relativeDirPath: (0, import_node_path86.join)(".windsurf", "skills")
|
|
12136
|
+
};
|
|
12137
|
+
}
|
|
12138
|
+
getFrontmatter() {
|
|
12139
|
+
const result = WindsurfSkillFrontmatterSchema.parse(this.requireMainFileFrontmatter());
|
|
12140
|
+
return result;
|
|
12141
|
+
}
|
|
12142
|
+
getBody() {
|
|
12143
|
+
return this.mainFile?.body ?? "";
|
|
12144
|
+
}
|
|
12145
|
+
validate() {
|
|
12146
|
+
if (!this.mainFile) {
|
|
12147
|
+
return {
|
|
12148
|
+
success: false,
|
|
12149
|
+
error: new Error(`${this.getDirPath()}: ${SKILL_FILE_NAME} file does not exist`)
|
|
12150
|
+
};
|
|
12151
|
+
}
|
|
12152
|
+
const result = WindsurfSkillFrontmatterSchema.safeParse(this.mainFile.frontmatter);
|
|
12153
|
+
if (!result.success) {
|
|
12154
|
+
return {
|
|
12155
|
+
success: false,
|
|
12156
|
+
error: new Error(
|
|
12157
|
+
`Invalid frontmatter in ${this.getDirPath()}: ${formatError(result.error)}`
|
|
12158
|
+
)
|
|
12159
|
+
};
|
|
12160
|
+
}
|
|
12161
|
+
return { success: true, error: null };
|
|
12162
|
+
}
|
|
12163
|
+
toRulesyncSkill() {
|
|
12164
|
+
const frontmatter = this.getFrontmatter();
|
|
12165
|
+
const rulesyncFrontmatter = {
|
|
12166
|
+
name: frontmatter.name,
|
|
12167
|
+
description: frontmatter.description,
|
|
12168
|
+
targets: ["*"]
|
|
12169
|
+
};
|
|
12170
|
+
return new RulesyncSkill({
|
|
12171
|
+
baseDir: this.baseDir,
|
|
12172
|
+
relativeDirPath: RULESYNC_SKILLS_RELATIVE_DIR_PATH,
|
|
12173
|
+
dirName: this.getDirName(),
|
|
12174
|
+
frontmatter: rulesyncFrontmatter,
|
|
12175
|
+
body: this.getBody(),
|
|
12176
|
+
otherFiles: this.getOtherFiles(),
|
|
12177
|
+
validate: true,
|
|
12178
|
+
global: this.global
|
|
12179
|
+
});
|
|
12180
|
+
}
|
|
12181
|
+
static fromRulesyncSkill({
|
|
12182
|
+
baseDir = process.cwd(),
|
|
12183
|
+
rulesyncSkill,
|
|
12184
|
+
validate = true,
|
|
12185
|
+
global = false
|
|
12186
|
+
}) {
|
|
12187
|
+
const settablePaths = _WindsurfSkill.getSettablePaths({ global });
|
|
12188
|
+
const rulesyncFrontmatter = rulesyncSkill.getFrontmatter();
|
|
12189
|
+
const windsurfFrontmatter = {
|
|
12190
|
+
name: rulesyncFrontmatter.name,
|
|
12191
|
+
description: rulesyncFrontmatter.description
|
|
12192
|
+
};
|
|
12193
|
+
return new _WindsurfSkill({
|
|
12194
|
+
baseDir,
|
|
12195
|
+
relativeDirPath: settablePaths.relativeDirPath,
|
|
12196
|
+
dirName: rulesyncSkill.getDirName(),
|
|
12197
|
+
frontmatter: windsurfFrontmatter,
|
|
12198
|
+
body: rulesyncSkill.getBody(),
|
|
12199
|
+
otherFiles: rulesyncSkill.getOtherFiles(),
|
|
12200
|
+
validate,
|
|
12201
|
+
global
|
|
12202
|
+
});
|
|
12203
|
+
}
|
|
12204
|
+
static isTargetedByRulesyncSkill(rulesyncSkill) {
|
|
12205
|
+
const targets = rulesyncSkill.getFrontmatter().targets;
|
|
12206
|
+
return targets.includes("*") || targets.includes("windsurf");
|
|
12207
|
+
}
|
|
12208
|
+
static async fromDir(params) {
|
|
12209
|
+
const loaded = await this.loadSkillDirContent({
|
|
12210
|
+
...params,
|
|
12211
|
+
getSettablePaths: _WindsurfSkill.getSettablePaths
|
|
12212
|
+
});
|
|
12213
|
+
const result = WindsurfSkillFrontmatterSchema.safeParse(loaded.frontmatter);
|
|
12214
|
+
if (!result.success) {
|
|
12215
|
+
const skillDirPath = (0, import_node_path86.join)(loaded.baseDir, loaded.relativeDirPath, loaded.dirName);
|
|
12216
|
+
throw new Error(
|
|
12217
|
+
`Invalid frontmatter in ${(0, import_node_path86.join)(skillDirPath, SKILL_FILE_NAME)}: ${formatError(result.error)}`
|
|
12218
|
+
);
|
|
12219
|
+
}
|
|
12220
|
+
return new _WindsurfSkill({
|
|
12221
|
+
baseDir: loaded.baseDir,
|
|
12222
|
+
relativeDirPath: loaded.relativeDirPath,
|
|
12223
|
+
dirName: loaded.dirName,
|
|
12224
|
+
frontmatter: result.data,
|
|
12225
|
+
body: loaded.body,
|
|
12226
|
+
otherFiles: loaded.otherFiles,
|
|
12227
|
+
validate: true,
|
|
12228
|
+
global: loaded.global
|
|
12229
|
+
});
|
|
12230
|
+
}
|
|
12231
|
+
static forDeletion({
|
|
12232
|
+
baseDir = process.cwd(),
|
|
12233
|
+
relativeDirPath,
|
|
12234
|
+
dirName,
|
|
12235
|
+
global = false
|
|
12236
|
+
}) {
|
|
12237
|
+
const settablePaths = _WindsurfSkill.getSettablePaths({ global });
|
|
12238
|
+
return new _WindsurfSkill({
|
|
12239
|
+
baseDir,
|
|
12240
|
+
relativeDirPath: relativeDirPath ?? settablePaths.relativeDirPath,
|
|
12241
|
+
dirName,
|
|
12242
|
+
frontmatter: { name: "", description: "" },
|
|
12243
|
+
body: "",
|
|
12244
|
+
otherFiles: [],
|
|
12245
|
+
validate: false,
|
|
12246
|
+
global
|
|
12247
|
+
});
|
|
12248
|
+
}
|
|
12249
|
+
};
|
|
12250
|
+
|
|
12086
12251
|
// src/features/skills/skills-processor.ts
|
|
12087
12252
|
var skillsProcessorToolTargetTuple = [
|
|
12088
12253
|
"agentsmd",
|
|
@@ -12103,9 +12268,10 @@ var skillsProcessorToolTargetTuple = [
|
|
|
12103
12268
|
"opencode",
|
|
12104
12269
|
"replit",
|
|
12105
12270
|
"roo",
|
|
12106
|
-
"rovodev"
|
|
12271
|
+
"rovodev",
|
|
12272
|
+
"windsurf"
|
|
12107
12273
|
];
|
|
12108
|
-
var SkillsProcessorToolTargetSchema =
|
|
12274
|
+
var SkillsProcessorToolTargetSchema = import_mini46.z.enum(skillsProcessorToolTargetTuple);
|
|
12109
12275
|
var toolSkillFactories = /* @__PURE__ */ new Map([
|
|
12110
12276
|
[
|
|
12111
12277
|
"agentsmd",
|
|
@@ -12239,6 +12405,13 @@ var toolSkillFactories = /* @__PURE__ */ new Map([
|
|
|
12239
12405
|
class: RovodevSkill,
|
|
12240
12406
|
meta: { supportsProject: true, supportsSimulated: false, supportsGlobal: true }
|
|
12241
12407
|
}
|
|
12408
|
+
],
|
|
12409
|
+
[
|
|
12410
|
+
"windsurf",
|
|
12411
|
+
{
|
|
12412
|
+
class: WindsurfSkill,
|
|
12413
|
+
meta: { supportsProject: true, supportsSimulated: false, supportsGlobal: true }
|
|
12414
|
+
}
|
|
12242
12415
|
]
|
|
12243
12416
|
]);
|
|
12244
12417
|
var defaultGetFactory4 = (target) => {
|
|
@@ -12329,11 +12502,11 @@ var SkillsProcessor = class extends DirFeatureProcessor {
|
|
|
12329
12502
|
)
|
|
12330
12503
|
);
|
|
12331
12504
|
const localSkillNames = new Set(localDirNames);
|
|
12332
|
-
const curatedDirPath = (0,
|
|
12505
|
+
const curatedDirPath = (0, import_node_path87.join)(process.cwd(), RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH);
|
|
12333
12506
|
let curatedSkills = [];
|
|
12334
12507
|
if (await directoryExists(curatedDirPath)) {
|
|
12335
|
-
const curatedDirPaths = await findFilesByGlobs((0,
|
|
12336
|
-
const curatedDirNames = curatedDirPaths.map((path4) => (0,
|
|
12508
|
+
const curatedDirPaths = await findFilesByGlobs((0, import_node_path87.join)(curatedDirPath, "*"), { type: "dir" });
|
|
12509
|
+
const curatedDirNames = curatedDirPaths.map((path4) => (0, import_node_path87.basename)(path4));
|
|
12337
12510
|
const nonConflicting = curatedDirNames.filter((name) => {
|
|
12338
12511
|
if (localSkillNames.has(name)) {
|
|
12339
12512
|
this.logger.debug(`Skipping curated skill "${name}": local skill takes precedence.`);
|
|
@@ -12370,13 +12543,13 @@ var SkillsProcessor = class extends DirFeatureProcessor {
|
|
|
12370
12543
|
const seenDirNames = /* @__PURE__ */ new Set();
|
|
12371
12544
|
const loadEntries = [];
|
|
12372
12545
|
for (const root of roots) {
|
|
12373
|
-
const skillsDirPath = (0,
|
|
12546
|
+
const skillsDirPath = (0, import_node_path87.join)(this.baseDir, root);
|
|
12374
12547
|
if (!await directoryExists(skillsDirPath)) {
|
|
12375
12548
|
continue;
|
|
12376
12549
|
}
|
|
12377
|
-
const dirPaths = await findFilesByGlobs((0,
|
|
12550
|
+
const dirPaths = await findFilesByGlobs((0, import_node_path87.join)(skillsDirPath, "*"), { type: "dir" });
|
|
12378
12551
|
for (const dirPath of dirPaths) {
|
|
12379
|
-
const dirName = (0,
|
|
12552
|
+
const dirName = (0, import_node_path87.basename)(dirPath);
|
|
12380
12553
|
if (seenDirNames.has(dirName)) {
|
|
12381
12554
|
continue;
|
|
12382
12555
|
}
|
|
@@ -12405,13 +12578,13 @@ var SkillsProcessor = class extends DirFeatureProcessor {
|
|
|
12405
12578
|
const roots = toolSkillSearchRoots(paths);
|
|
12406
12579
|
const toolSkills = [];
|
|
12407
12580
|
for (const root of roots) {
|
|
12408
|
-
const skillsDirPath = (0,
|
|
12581
|
+
const skillsDirPath = (0, import_node_path87.join)(this.baseDir, root);
|
|
12409
12582
|
if (!await directoryExists(skillsDirPath)) {
|
|
12410
12583
|
continue;
|
|
12411
12584
|
}
|
|
12412
|
-
const dirPaths = await findFilesByGlobs((0,
|
|
12585
|
+
const dirPaths = await findFilesByGlobs((0, import_node_path87.join)(skillsDirPath, "*"), { type: "dir" });
|
|
12413
12586
|
for (const dirPath of dirPaths) {
|
|
12414
|
-
const dirName = (0,
|
|
12587
|
+
const dirName = (0, import_node_path87.basename)(dirPath);
|
|
12415
12588
|
const toolSkill = factory.class.forDeletion({
|
|
12416
12589
|
baseDir: this.baseDir,
|
|
12417
12590
|
relativeDirPath: root,
|
|
@@ -12473,11 +12646,11 @@ var SkillsProcessor = class extends DirFeatureProcessor {
|
|
|
12473
12646
|
};
|
|
12474
12647
|
|
|
12475
12648
|
// src/features/subagents/agentsmd-subagent.ts
|
|
12476
|
-
var
|
|
12649
|
+
var import_node_path89 = require("path");
|
|
12477
12650
|
|
|
12478
12651
|
// src/features/subagents/simulated-subagent.ts
|
|
12479
|
-
var
|
|
12480
|
-
var
|
|
12652
|
+
var import_node_path88 = require("path");
|
|
12653
|
+
var import_mini47 = require("zod/mini");
|
|
12481
12654
|
|
|
12482
12655
|
// src/features/subagents/tool-subagent.ts
|
|
12483
12656
|
var ToolSubagent = class extends ToolFile {
|
|
@@ -12529,9 +12702,9 @@ var ToolSubagent = class extends ToolFile {
|
|
|
12529
12702
|
};
|
|
12530
12703
|
|
|
12531
12704
|
// src/features/subagents/simulated-subagent.ts
|
|
12532
|
-
var SimulatedSubagentFrontmatterSchema =
|
|
12533
|
-
name:
|
|
12534
|
-
description:
|
|
12705
|
+
var SimulatedSubagentFrontmatterSchema = import_mini47.z.object({
|
|
12706
|
+
name: import_mini47.z.string(),
|
|
12707
|
+
description: import_mini47.z.optional(import_mini47.z.string())
|
|
12535
12708
|
});
|
|
12536
12709
|
var SimulatedSubagent = class extends ToolSubagent {
|
|
12537
12710
|
frontmatter;
|
|
@@ -12541,7 +12714,7 @@ var SimulatedSubagent = class extends ToolSubagent {
|
|
|
12541
12714
|
const result = SimulatedSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
12542
12715
|
if (!result.success) {
|
|
12543
12716
|
throw new Error(
|
|
12544
|
-
`Invalid frontmatter in ${(0,
|
|
12717
|
+
`Invalid frontmatter in ${(0, import_node_path88.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
12545
12718
|
);
|
|
12546
12719
|
}
|
|
12547
12720
|
}
|
|
@@ -12592,7 +12765,7 @@ var SimulatedSubagent = class extends ToolSubagent {
|
|
|
12592
12765
|
return {
|
|
12593
12766
|
success: false,
|
|
12594
12767
|
error: new Error(
|
|
12595
|
-
`Invalid frontmatter in ${(0,
|
|
12768
|
+
`Invalid frontmatter in ${(0, import_node_path88.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
12596
12769
|
)
|
|
12597
12770
|
};
|
|
12598
12771
|
}
|
|
@@ -12602,7 +12775,7 @@ var SimulatedSubagent = class extends ToolSubagent {
|
|
|
12602
12775
|
relativeFilePath,
|
|
12603
12776
|
validate = true
|
|
12604
12777
|
}) {
|
|
12605
|
-
const filePath = (0,
|
|
12778
|
+
const filePath = (0, import_node_path88.join)(baseDir, this.getSettablePaths().relativeDirPath, relativeFilePath);
|
|
12606
12779
|
const fileContent = await readFileContent(filePath);
|
|
12607
12780
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
12608
12781
|
const result = SimulatedSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -12612,7 +12785,7 @@ var SimulatedSubagent = class extends ToolSubagent {
|
|
|
12612
12785
|
return {
|
|
12613
12786
|
baseDir,
|
|
12614
12787
|
relativeDirPath: this.getSettablePaths().relativeDirPath,
|
|
12615
|
-
relativeFilePath: (0,
|
|
12788
|
+
relativeFilePath: (0, import_node_path88.basename)(relativeFilePath),
|
|
12616
12789
|
frontmatter: result.data,
|
|
12617
12790
|
body: content.trim(),
|
|
12618
12791
|
validate
|
|
@@ -12638,7 +12811,7 @@ var SimulatedSubagent = class extends ToolSubagent {
|
|
|
12638
12811
|
var AgentsmdSubagent = class _AgentsmdSubagent extends SimulatedSubagent {
|
|
12639
12812
|
static getSettablePaths() {
|
|
12640
12813
|
return {
|
|
12641
|
-
relativeDirPath: (0,
|
|
12814
|
+
relativeDirPath: (0, import_node_path89.join)(".agents", "subagents")
|
|
12642
12815
|
};
|
|
12643
12816
|
}
|
|
12644
12817
|
static async fromFile(params) {
|
|
@@ -12661,11 +12834,11 @@ var AgentsmdSubagent = class _AgentsmdSubagent extends SimulatedSubagent {
|
|
|
12661
12834
|
};
|
|
12662
12835
|
|
|
12663
12836
|
// src/features/subagents/factorydroid-subagent.ts
|
|
12664
|
-
var
|
|
12837
|
+
var import_node_path90 = require("path");
|
|
12665
12838
|
var FactorydroidSubagent = class _FactorydroidSubagent extends SimulatedSubagent {
|
|
12666
12839
|
static getSettablePaths(_options) {
|
|
12667
12840
|
return {
|
|
12668
|
-
relativeDirPath: (0,
|
|
12841
|
+
relativeDirPath: (0, import_node_path90.join)(".factory", "droids")
|
|
12669
12842
|
};
|
|
12670
12843
|
}
|
|
12671
12844
|
static async fromFile(params) {
|
|
@@ -12688,16 +12861,16 @@ var FactorydroidSubagent = class _FactorydroidSubagent extends SimulatedSubagent
|
|
|
12688
12861
|
};
|
|
12689
12862
|
|
|
12690
12863
|
// src/features/subagents/geminicli-subagent.ts
|
|
12691
|
-
var
|
|
12692
|
-
var
|
|
12864
|
+
var import_node_path92 = require("path");
|
|
12865
|
+
var import_mini49 = require("zod/mini");
|
|
12693
12866
|
|
|
12694
12867
|
// src/features/subagents/rulesync-subagent.ts
|
|
12695
|
-
var
|
|
12696
|
-
var
|
|
12697
|
-
var RulesyncSubagentFrontmatterSchema =
|
|
12698
|
-
targets:
|
|
12699
|
-
name:
|
|
12700
|
-
description:
|
|
12868
|
+
var import_node_path91 = require("path");
|
|
12869
|
+
var import_mini48 = require("zod/mini");
|
|
12870
|
+
var RulesyncSubagentFrontmatterSchema = import_mini48.z.looseObject({
|
|
12871
|
+
targets: import_mini48.z._default(RulesyncTargetsSchema, ["*"]),
|
|
12872
|
+
name: import_mini48.z.string(),
|
|
12873
|
+
description: import_mini48.z.optional(import_mini48.z.string())
|
|
12701
12874
|
});
|
|
12702
12875
|
var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
12703
12876
|
frontmatter;
|
|
@@ -12706,7 +12879,7 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
12706
12879
|
const parseResult = RulesyncSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
12707
12880
|
if (!parseResult.success && rest.validate !== false) {
|
|
12708
12881
|
throw new Error(
|
|
12709
|
-
`Invalid frontmatter in ${(0,
|
|
12882
|
+
`Invalid frontmatter in ${(0, import_node_path91.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(parseResult.error)}`
|
|
12710
12883
|
);
|
|
12711
12884
|
}
|
|
12712
12885
|
const parsedFrontmatter = parseResult.success ? { ...frontmatter, ...parseResult.data } : { ...frontmatter, targets: frontmatter?.targets ?? ["*"] };
|
|
@@ -12739,7 +12912,7 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
12739
12912
|
return {
|
|
12740
12913
|
success: false,
|
|
12741
12914
|
error: new Error(
|
|
12742
|
-
`Invalid frontmatter in ${(0,
|
|
12915
|
+
`Invalid frontmatter in ${(0, import_node_path91.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
12743
12916
|
)
|
|
12744
12917
|
};
|
|
12745
12918
|
}
|
|
@@ -12747,14 +12920,14 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
12747
12920
|
static async fromFile({
|
|
12748
12921
|
relativeFilePath
|
|
12749
12922
|
}) {
|
|
12750
|
-
const filePath = (0,
|
|
12923
|
+
const filePath = (0, import_node_path91.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, relativeFilePath);
|
|
12751
12924
|
const fileContent = await readFileContent(filePath);
|
|
12752
12925
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
12753
12926
|
const result = RulesyncSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
12754
12927
|
if (!result.success) {
|
|
12755
12928
|
throw new Error(`Invalid frontmatter in ${relativeFilePath}: ${formatError(result.error)}`);
|
|
12756
12929
|
}
|
|
12757
|
-
const filename = (0,
|
|
12930
|
+
const filename = (0, import_node_path91.basename)(relativeFilePath);
|
|
12758
12931
|
return new _RulesyncSubagent({
|
|
12759
12932
|
baseDir: process.cwd(),
|
|
12760
12933
|
relativeDirPath: this.getSettablePaths().relativeDirPath,
|
|
@@ -12766,9 +12939,9 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
12766
12939
|
};
|
|
12767
12940
|
|
|
12768
12941
|
// src/features/subagents/geminicli-subagent.ts
|
|
12769
|
-
var GeminiCliSubagentFrontmatterSchema =
|
|
12770
|
-
name:
|
|
12771
|
-
description:
|
|
12942
|
+
var GeminiCliSubagentFrontmatterSchema = import_mini49.z.looseObject({
|
|
12943
|
+
name: import_mini49.z.string(),
|
|
12944
|
+
description: import_mini49.z.optional(import_mini49.z.string())
|
|
12772
12945
|
});
|
|
12773
12946
|
var GeminiCliSubagent = class _GeminiCliSubagent extends ToolSubagent {
|
|
12774
12947
|
frontmatter;
|
|
@@ -12778,7 +12951,7 @@ var GeminiCliSubagent = class _GeminiCliSubagent extends ToolSubagent {
|
|
|
12778
12951
|
const result = GeminiCliSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
12779
12952
|
if (!result.success) {
|
|
12780
12953
|
throw new Error(
|
|
12781
|
-
`Invalid frontmatter in ${(0,
|
|
12954
|
+
`Invalid frontmatter in ${(0, import_node_path92.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
12782
12955
|
);
|
|
12783
12956
|
}
|
|
12784
12957
|
}
|
|
@@ -12791,7 +12964,7 @@ var GeminiCliSubagent = class _GeminiCliSubagent extends ToolSubagent {
|
|
|
12791
12964
|
}
|
|
12792
12965
|
static getSettablePaths(_options = {}) {
|
|
12793
12966
|
return {
|
|
12794
|
-
relativeDirPath: (0,
|
|
12967
|
+
relativeDirPath: (0, import_node_path92.join)(".gemini", "agents")
|
|
12795
12968
|
};
|
|
12796
12969
|
}
|
|
12797
12970
|
getFrontmatter() {
|
|
@@ -12859,7 +13032,7 @@ var GeminiCliSubagent = class _GeminiCliSubagent extends ToolSubagent {
|
|
|
12859
13032
|
return {
|
|
12860
13033
|
success: false,
|
|
12861
13034
|
error: new Error(
|
|
12862
|
-
`Invalid frontmatter in ${(0,
|
|
13035
|
+
`Invalid frontmatter in ${(0, import_node_path92.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
12863
13036
|
)
|
|
12864
13037
|
};
|
|
12865
13038
|
}
|
|
@@ -12877,7 +13050,7 @@ var GeminiCliSubagent = class _GeminiCliSubagent extends ToolSubagent {
|
|
|
12877
13050
|
global = false
|
|
12878
13051
|
}) {
|
|
12879
13052
|
const paths = this.getSettablePaths({ global });
|
|
12880
|
-
const filePath = (0,
|
|
13053
|
+
const filePath = (0, import_node_path92.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
12881
13054
|
const fileContent = await readFileContent(filePath);
|
|
12882
13055
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
12883
13056
|
const result = GeminiCliSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -12913,11 +13086,11 @@ var GeminiCliSubagent = class _GeminiCliSubagent extends ToolSubagent {
|
|
|
12913
13086
|
};
|
|
12914
13087
|
|
|
12915
13088
|
// src/features/subagents/roo-subagent.ts
|
|
12916
|
-
var
|
|
13089
|
+
var import_node_path93 = require("path");
|
|
12917
13090
|
var RooSubagent = class _RooSubagent extends SimulatedSubagent {
|
|
12918
13091
|
static getSettablePaths() {
|
|
12919
13092
|
return {
|
|
12920
|
-
relativeDirPath: (0,
|
|
13093
|
+
relativeDirPath: (0, import_node_path93.join)(".roo", "subagents")
|
|
12921
13094
|
};
|
|
12922
13095
|
}
|
|
12923
13096
|
static async fromFile(params) {
|
|
@@ -12940,11 +13113,11 @@ var RooSubagent = class _RooSubagent extends SimulatedSubagent {
|
|
|
12940
13113
|
};
|
|
12941
13114
|
|
|
12942
13115
|
// src/features/subagents/rovodev-subagent.ts
|
|
12943
|
-
var
|
|
12944
|
-
var
|
|
12945
|
-
var RovodevSubagentFrontmatterSchema =
|
|
12946
|
-
name:
|
|
12947
|
-
description:
|
|
13116
|
+
var import_node_path94 = require("path");
|
|
13117
|
+
var import_mini50 = require("zod/mini");
|
|
13118
|
+
var RovodevSubagentFrontmatterSchema = import_mini50.z.looseObject({
|
|
13119
|
+
name: import_mini50.z.string(),
|
|
13120
|
+
description: import_mini50.z.optional(import_mini50.z.string())
|
|
12948
13121
|
});
|
|
12949
13122
|
var RovodevSubagent = class _RovodevSubagent extends ToolSubagent {
|
|
12950
13123
|
frontmatter;
|
|
@@ -12954,7 +13127,7 @@ var RovodevSubagent = class _RovodevSubagent extends ToolSubagent {
|
|
|
12954
13127
|
const result = RovodevSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
12955
13128
|
if (!result.success) {
|
|
12956
13129
|
throw new Error(
|
|
12957
|
-
`Invalid frontmatter in ${(0,
|
|
13130
|
+
`Invalid frontmatter in ${(0, import_node_path94.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
12958
13131
|
);
|
|
12959
13132
|
}
|
|
12960
13133
|
}
|
|
@@ -12966,7 +13139,7 @@ var RovodevSubagent = class _RovodevSubagent extends ToolSubagent {
|
|
|
12966
13139
|
}
|
|
12967
13140
|
static getSettablePaths(_options = {}) {
|
|
12968
13141
|
return {
|
|
12969
|
-
relativeDirPath: (0,
|
|
13142
|
+
relativeDirPath: (0, import_node_path94.join)(".rovodev", "subagents")
|
|
12970
13143
|
};
|
|
12971
13144
|
}
|
|
12972
13145
|
getFrontmatter() {
|
|
@@ -13029,7 +13202,7 @@ var RovodevSubagent = class _RovodevSubagent extends ToolSubagent {
|
|
|
13029
13202
|
return {
|
|
13030
13203
|
success: false,
|
|
13031
13204
|
error: new Error(
|
|
13032
|
-
`Invalid frontmatter in ${(0,
|
|
13205
|
+
`Invalid frontmatter in ${(0, import_node_path94.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
13033
13206
|
)
|
|
13034
13207
|
};
|
|
13035
13208
|
}
|
|
@@ -13046,7 +13219,7 @@ var RovodevSubagent = class _RovodevSubagent extends ToolSubagent {
|
|
|
13046
13219
|
global = false
|
|
13047
13220
|
}) {
|
|
13048
13221
|
const paths = this.getSettablePaths({ global });
|
|
13049
|
-
const filePath = (0,
|
|
13222
|
+
const filePath = (0, import_node_path94.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
13050
13223
|
const fileContent = await readFileContent(filePath);
|
|
13051
13224
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
13052
13225
|
const result = RovodevSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -13085,19 +13258,19 @@ var RovodevSubagent = class _RovodevSubagent extends ToolSubagent {
|
|
|
13085
13258
|
};
|
|
13086
13259
|
|
|
13087
13260
|
// src/features/subagents/subagents-processor.ts
|
|
13088
|
-
var
|
|
13089
|
-
var
|
|
13261
|
+
var import_node_path105 = require("path");
|
|
13262
|
+
var import_mini59 = require("zod/mini");
|
|
13090
13263
|
|
|
13091
13264
|
// src/features/subagents/claudecode-subagent.ts
|
|
13092
|
-
var
|
|
13093
|
-
var
|
|
13094
|
-
var ClaudecodeSubagentFrontmatterSchema =
|
|
13095
|
-
name:
|
|
13096
|
-
description:
|
|
13097
|
-
model:
|
|
13098
|
-
tools:
|
|
13099
|
-
permissionMode:
|
|
13100
|
-
skills:
|
|
13265
|
+
var import_node_path95 = require("path");
|
|
13266
|
+
var import_mini51 = require("zod/mini");
|
|
13267
|
+
var ClaudecodeSubagentFrontmatterSchema = import_mini51.z.looseObject({
|
|
13268
|
+
name: import_mini51.z.string(),
|
|
13269
|
+
description: import_mini51.z.optional(import_mini51.z.string()),
|
|
13270
|
+
model: import_mini51.z.optional(import_mini51.z.string()),
|
|
13271
|
+
tools: import_mini51.z.optional(import_mini51.z.union([import_mini51.z.string(), import_mini51.z.array(import_mini51.z.string())])),
|
|
13272
|
+
permissionMode: import_mini51.z.optional(import_mini51.z.string()),
|
|
13273
|
+
skills: import_mini51.z.optional(import_mini51.z.union([import_mini51.z.string(), import_mini51.z.array(import_mini51.z.string())]))
|
|
13101
13274
|
});
|
|
13102
13275
|
var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
13103
13276
|
frontmatter;
|
|
@@ -13107,7 +13280,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
13107
13280
|
const result = ClaudecodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
13108
13281
|
if (!result.success) {
|
|
13109
13282
|
throw new Error(
|
|
13110
|
-
`Invalid frontmatter in ${(0,
|
|
13283
|
+
`Invalid frontmatter in ${(0, import_node_path95.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
13111
13284
|
);
|
|
13112
13285
|
}
|
|
13113
13286
|
}
|
|
@@ -13119,7 +13292,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
13119
13292
|
}
|
|
13120
13293
|
static getSettablePaths(_options = {}) {
|
|
13121
13294
|
return {
|
|
13122
|
-
relativeDirPath: (0,
|
|
13295
|
+
relativeDirPath: (0, import_node_path95.join)(".claude", "agents")
|
|
13123
13296
|
};
|
|
13124
13297
|
}
|
|
13125
13298
|
getFrontmatter() {
|
|
@@ -13198,7 +13371,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
13198
13371
|
return {
|
|
13199
13372
|
success: false,
|
|
13200
13373
|
error: new Error(
|
|
13201
|
-
`Invalid frontmatter in ${(0,
|
|
13374
|
+
`Invalid frontmatter in ${(0, import_node_path95.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
13202
13375
|
)
|
|
13203
13376
|
};
|
|
13204
13377
|
}
|
|
@@ -13216,7 +13389,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
13216
13389
|
global = false
|
|
13217
13390
|
}) {
|
|
13218
13391
|
const paths = this.getSettablePaths({ global });
|
|
13219
|
-
const filePath = (0,
|
|
13392
|
+
const filePath = (0, import_node_path95.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
13220
13393
|
const fileContent = await readFileContent(filePath);
|
|
13221
13394
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
13222
13395
|
const result = ClaudecodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -13251,16 +13424,16 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
13251
13424
|
};
|
|
13252
13425
|
|
|
13253
13426
|
// src/features/subagents/codexcli-subagent.ts
|
|
13254
|
-
var
|
|
13427
|
+
var import_node_path96 = require("path");
|
|
13255
13428
|
var smolToml4 = __toESM(require("smol-toml"), 1);
|
|
13256
|
-
var
|
|
13257
|
-
var CodexCliSubagentTomlSchema =
|
|
13258
|
-
name:
|
|
13259
|
-
description:
|
|
13260
|
-
developer_instructions:
|
|
13261
|
-
model:
|
|
13262
|
-
model_reasoning_effort:
|
|
13263
|
-
sandbox_mode:
|
|
13429
|
+
var import_mini52 = require("zod/mini");
|
|
13430
|
+
var CodexCliSubagentTomlSchema = import_mini52.z.looseObject({
|
|
13431
|
+
name: import_mini52.z.string(),
|
|
13432
|
+
description: import_mini52.z.optional(import_mini52.z.string()),
|
|
13433
|
+
developer_instructions: import_mini52.z.optional(import_mini52.z.string()),
|
|
13434
|
+
model: import_mini52.z.optional(import_mini52.z.string()),
|
|
13435
|
+
model_reasoning_effort: import_mini52.z.optional(import_mini52.z.string()),
|
|
13436
|
+
sandbox_mode: import_mini52.z.optional(import_mini52.z.string())
|
|
13264
13437
|
});
|
|
13265
13438
|
function stringifyCodexCliSubagentToml(tomlObj) {
|
|
13266
13439
|
const { developer_instructions, ...restFields } = tomlObj;
|
|
@@ -13282,7 +13455,7 @@ var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
|
|
|
13282
13455
|
CodexCliSubagentTomlSchema.parse(parsed);
|
|
13283
13456
|
} catch (error) {
|
|
13284
13457
|
throw new Error(
|
|
13285
|
-
`Invalid TOML in ${(0,
|
|
13458
|
+
`Invalid TOML in ${(0, import_node_path96.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${error instanceof Error ? error.message : String(error)}`,
|
|
13286
13459
|
{ cause: error }
|
|
13287
13460
|
);
|
|
13288
13461
|
}
|
|
@@ -13294,7 +13467,7 @@ var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
|
|
|
13294
13467
|
}
|
|
13295
13468
|
static getSettablePaths(_options = {}) {
|
|
13296
13469
|
return {
|
|
13297
|
-
relativeDirPath: (0,
|
|
13470
|
+
relativeDirPath: (0, import_node_path96.join)(".codex", "agents")
|
|
13298
13471
|
};
|
|
13299
13472
|
}
|
|
13300
13473
|
getBody() {
|
|
@@ -13306,7 +13479,7 @@ var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
|
|
|
13306
13479
|
parsed = CodexCliSubagentTomlSchema.parse(smolToml4.parse(this.body));
|
|
13307
13480
|
} catch (error) {
|
|
13308
13481
|
throw new Error(
|
|
13309
|
-
`Failed to parse TOML in ${(0,
|
|
13482
|
+
`Failed to parse TOML in ${(0, import_node_path96.join)(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${error instanceof Error ? error.message : String(error)}`,
|
|
13310
13483
|
{ cause: error }
|
|
13311
13484
|
);
|
|
13312
13485
|
}
|
|
@@ -13387,7 +13560,7 @@ var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
|
|
|
13387
13560
|
global = false
|
|
13388
13561
|
}) {
|
|
13389
13562
|
const paths = this.getSettablePaths({ global });
|
|
13390
|
-
const filePath = (0,
|
|
13563
|
+
const filePath = (0, import_node_path96.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
13391
13564
|
const fileContent = await readFileContent(filePath);
|
|
13392
13565
|
const subagent = new _CodexCliSubagent({
|
|
13393
13566
|
baseDir,
|
|
@@ -13425,13 +13598,13 @@ var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
|
|
|
13425
13598
|
};
|
|
13426
13599
|
|
|
13427
13600
|
// src/features/subagents/copilot-subagent.ts
|
|
13428
|
-
var
|
|
13429
|
-
var
|
|
13601
|
+
var import_node_path97 = require("path");
|
|
13602
|
+
var import_mini53 = require("zod/mini");
|
|
13430
13603
|
var REQUIRED_TOOL = "agent/runSubagent";
|
|
13431
|
-
var CopilotSubagentFrontmatterSchema =
|
|
13432
|
-
name:
|
|
13433
|
-
description:
|
|
13434
|
-
tools:
|
|
13604
|
+
var CopilotSubagentFrontmatterSchema = import_mini53.z.looseObject({
|
|
13605
|
+
name: import_mini53.z.string(),
|
|
13606
|
+
description: import_mini53.z.optional(import_mini53.z.string()),
|
|
13607
|
+
tools: import_mini53.z.optional(import_mini53.z.union([import_mini53.z.string(), import_mini53.z.array(import_mini53.z.string())]))
|
|
13435
13608
|
});
|
|
13436
13609
|
var normalizeTools = (tools) => {
|
|
13437
13610
|
if (!tools) {
|
|
@@ -13451,7 +13624,7 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
13451
13624
|
const result = CopilotSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
13452
13625
|
if (!result.success) {
|
|
13453
13626
|
throw new Error(
|
|
13454
|
-
`Invalid frontmatter in ${(0,
|
|
13627
|
+
`Invalid frontmatter in ${(0, import_node_path97.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
13455
13628
|
);
|
|
13456
13629
|
}
|
|
13457
13630
|
}
|
|
@@ -13463,7 +13636,7 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
13463
13636
|
}
|
|
13464
13637
|
static getSettablePaths(_options = {}) {
|
|
13465
13638
|
return {
|
|
13466
|
-
relativeDirPath: (0,
|
|
13639
|
+
relativeDirPath: (0, import_node_path97.join)(".github", "agents")
|
|
13467
13640
|
};
|
|
13468
13641
|
}
|
|
13469
13642
|
getFrontmatter() {
|
|
@@ -13541,7 +13714,7 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
13541
13714
|
return {
|
|
13542
13715
|
success: false,
|
|
13543
13716
|
error: new Error(
|
|
13544
|
-
`Invalid frontmatter in ${(0,
|
|
13717
|
+
`Invalid frontmatter in ${(0, import_node_path97.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
13545
13718
|
)
|
|
13546
13719
|
};
|
|
13547
13720
|
}
|
|
@@ -13559,7 +13732,7 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
13559
13732
|
global = false
|
|
13560
13733
|
}) {
|
|
13561
13734
|
const paths = this.getSettablePaths({ global });
|
|
13562
|
-
const filePath = (0,
|
|
13735
|
+
const filePath = (0, import_node_path97.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
13563
13736
|
const fileContent = await readFileContent(filePath);
|
|
13564
13737
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
13565
13738
|
const result = CopilotSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -13595,11 +13768,11 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
13595
13768
|
};
|
|
13596
13769
|
|
|
13597
13770
|
// src/features/subagents/cursor-subagent.ts
|
|
13598
|
-
var
|
|
13599
|
-
var
|
|
13600
|
-
var CursorSubagentFrontmatterSchema =
|
|
13601
|
-
name:
|
|
13602
|
-
description:
|
|
13771
|
+
var import_node_path98 = require("path");
|
|
13772
|
+
var import_mini54 = require("zod/mini");
|
|
13773
|
+
var CursorSubagentFrontmatterSchema = import_mini54.z.looseObject({
|
|
13774
|
+
name: import_mini54.z.string(),
|
|
13775
|
+
description: import_mini54.z.optional(import_mini54.z.string())
|
|
13603
13776
|
});
|
|
13604
13777
|
var CursorSubagent = class _CursorSubagent extends ToolSubagent {
|
|
13605
13778
|
frontmatter;
|
|
@@ -13609,7 +13782,7 @@ var CursorSubagent = class _CursorSubagent extends ToolSubagent {
|
|
|
13609
13782
|
const result = CursorSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
13610
13783
|
if (!result.success) {
|
|
13611
13784
|
throw new Error(
|
|
13612
|
-
`Invalid frontmatter in ${(0,
|
|
13785
|
+
`Invalid frontmatter in ${(0, import_node_path98.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
13613
13786
|
);
|
|
13614
13787
|
}
|
|
13615
13788
|
}
|
|
@@ -13621,7 +13794,7 @@ var CursorSubagent = class _CursorSubagent extends ToolSubagent {
|
|
|
13621
13794
|
}
|
|
13622
13795
|
static getSettablePaths(_options = {}) {
|
|
13623
13796
|
return {
|
|
13624
|
-
relativeDirPath: (0,
|
|
13797
|
+
relativeDirPath: (0, import_node_path98.join)(".cursor", "agents")
|
|
13625
13798
|
};
|
|
13626
13799
|
}
|
|
13627
13800
|
getFrontmatter() {
|
|
@@ -13688,7 +13861,7 @@ var CursorSubagent = class _CursorSubagent extends ToolSubagent {
|
|
|
13688
13861
|
return {
|
|
13689
13862
|
success: false,
|
|
13690
13863
|
error: new Error(
|
|
13691
|
-
`Invalid frontmatter in ${(0,
|
|
13864
|
+
`Invalid frontmatter in ${(0, import_node_path98.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
13692
13865
|
)
|
|
13693
13866
|
};
|
|
13694
13867
|
}
|
|
@@ -13706,7 +13879,7 @@ var CursorSubagent = class _CursorSubagent extends ToolSubagent {
|
|
|
13706
13879
|
global = false
|
|
13707
13880
|
}) {
|
|
13708
13881
|
const paths = this.getSettablePaths({ global });
|
|
13709
|
-
const filePath = (0,
|
|
13882
|
+
const filePath = (0, import_node_path98.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
13710
13883
|
const fileContent = await readFileContent(filePath);
|
|
13711
13884
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
13712
13885
|
const result = CursorSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -13742,12 +13915,12 @@ var CursorSubagent = class _CursorSubagent extends ToolSubagent {
|
|
|
13742
13915
|
};
|
|
13743
13916
|
|
|
13744
13917
|
// src/features/subagents/deepagents-subagent.ts
|
|
13745
|
-
var
|
|
13746
|
-
var
|
|
13747
|
-
var DeepagentsSubagentFrontmatterSchema =
|
|
13748
|
-
name:
|
|
13749
|
-
description:
|
|
13750
|
-
model:
|
|
13918
|
+
var import_node_path99 = require("path");
|
|
13919
|
+
var import_mini55 = require("zod/mini");
|
|
13920
|
+
var DeepagentsSubagentFrontmatterSchema = import_mini55.z.looseObject({
|
|
13921
|
+
name: import_mini55.z.string(),
|
|
13922
|
+
description: import_mini55.z.optional(import_mini55.z.string()),
|
|
13923
|
+
model: import_mini55.z.optional(import_mini55.z.string())
|
|
13751
13924
|
});
|
|
13752
13925
|
var DeepagentsSubagent = class _DeepagentsSubagent extends ToolSubagent {
|
|
13753
13926
|
frontmatter;
|
|
@@ -13757,7 +13930,7 @@ var DeepagentsSubagent = class _DeepagentsSubagent extends ToolSubagent {
|
|
|
13757
13930
|
const result = DeepagentsSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
13758
13931
|
if (!result.success) {
|
|
13759
13932
|
throw new Error(
|
|
13760
|
-
`Invalid frontmatter in ${(0,
|
|
13933
|
+
`Invalid frontmatter in ${(0, import_node_path99.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
13761
13934
|
);
|
|
13762
13935
|
}
|
|
13763
13936
|
}
|
|
@@ -13767,7 +13940,7 @@ var DeepagentsSubagent = class _DeepagentsSubagent extends ToolSubagent {
|
|
|
13767
13940
|
}
|
|
13768
13941
|
static getSettablePaths(_options = {}) {
|
|
13769
13942
|
return {
|
|
13770
|
-
relativeDirPath: (0,
|
|
13943
|
+
relativeDirPath: (0, import_node_path99.join)(".deepagents", "agents")
|
|
13771
13944
|
};
|
|
13772
13945
|
}
|
|
13773
13946
|
getFrontmatter() {
|
|
@@ -13842,7 +14015,7 @@ var DeepagentsSubagent = class _DeepagentsSubagent extends ToolSubagent {
|
|
|
13842
14015
|
return {
|
|
13843
14016
|
success: false,
|
|
13844
14017
|
error: new Error(
|
|
13845
|
-
`Invalid frontmatter in ${(0,
|
|
14018
|
+
`Invalid frontmatter in ${(0, import_node_path99.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
13846
14019
|
)
|
|
13847
14020
|
};
|
|
13848
14021
|
}
|
|
@@ -13860,7 +14033,7 @@ var DeepagentsSubagent = class _DeepagentsSubagent extends ToolSubagent {
|
|
|
13860
14033
|
global = false
|
|
13861
14034
|
}) {
|
|
13862
14035
|
const paths = this.getSettablePaths({ global });
|
|
13863
|
-
const filePath = (0,
|
|
14036
|
+
const filePath = (0, import_node_path99.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
13864
14037
|
const fileContent = await readFileContent(filePath);
|
|
13865
14038
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
13866
14039
|
const result = DeepagentsSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -13895,11 +14068,11 @@ var DeepagentsSubagent = class _DeepagentsSubagent extends ToolSubagent {
|
|
|
13895
14068
|
};
|
|
13896
14069
|
|
|
13897
14070
|
// src/features/subagents/junie-subagent.ts
|
|
13898
|
-
var
|
|
13899
|
-
var
|
|
13900
|
-
var JunieSubagentFrontmatterSchema =
|
|
13901
|
-
name:
|
|
13902
|
-
description:
|
|
14071
|
+
var import_node_path100 = require("path");
|
|
14072
|
+
var import_mini56 = require("zod/mini");
|
|
14073
|
+
var JunieSubagentFrontmatterSchema = import_mini56.z.looseObject({
|
|
14074
|
+
name: import_mini56.z.optional(import_mini56.z.string()),
|
|
14075
|
+
description: import_mini56.z.string()
|
|
13903
14076
|
});
|
|
13904
14077
|
var JunieSubagent = class _JunieSubagent extends ToolSubagent {
|
|
13905
14078
|
frontmatter;
|
|
@@ -13909,7 +14082,7 @@ var JunieSubagent = class _JunieSubagent extends ToolSubagent {
|
|
|
13909
14082
|
const result = JunieSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
13910
14083
|
if (!result.success) {
|
|
13911
14084
|
throw new Error(
|
|
13912
|
-
`Invalid frontmatter in ${(0,
|
|
14085
|
+
`Invalid frontmatter in ${(0, import_node_path100.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
13913
14086
|
);
|
|
13914
14087
|
}
|
|
13915
14088
|
}
|
|
@@ -13924,7 +14097,7 @@ var JunieSubagent = class _JunieSubagent extends ToolSubagent {
|
|
|
13924
14097
|
throw new Error("JunieSubagent does not support global mode.");
|
|
13925
14098
|
}
|
|
13926
14099
|
return {
|
|
13927
|
-
relativeDirPath: (0,
|
|
14100
|
+
relativeDirPath: (0, import_node_path100.join)(".junie", "agents")
|
|
13928
14101
|
};
|
|
13929
14102
|
}
|
|
13930
14103
|
getFrontmatter() {
|
|
@@ -14000,7 +14173,7 @@ var JunieSubagent = class _JunieSubagent extends ToolSubagent {
|
|
|
14000
14173
|
return {
|
|
14001
14174
|
success: false,
|
|
14002
14175
|
error: new Error(
|
|
14003
|
-
`Invalid frontmatter in ${(0,
|
|
14176
|
+
`Invalid frontmatter in ${(0, import_node_path100.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
14004
14177
|
)
|
|
14005
14178
|
};
|
|
14006
14179
|
}
|
|
@@ -14018,7 +14191,7 @@ var JunieSubagent = class _JunieSubagent extends ToolSubagent {
|
|
|
14018
14191
|
global = false
|
|
14019
14192
|
}) {
|
|
14020
14193
|
const paths = this.getSettablePaths({ global });
|
|
14021
|
-
const filePath = (0,
|
|
14194
|
+
const filePath = (0, import_node_path100.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
14022
14195
|
const fileContent = await readFileContent(filePath);
|
|
14023
14196
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
14024
14197
|
const result = JunieSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -14053,15 +14226,15 @@ var JunieSubagent = class _JunieSubagent extends ToolSubagent {
|
|
|
14053
14226
|
};
|
|
14054
14227
|
|
|
14055
14228
|
// src/features/subagents/kilo-subagent.ts
|
|
14056
|
-
var
|
|
14229
|
+
var import_node_path102 = require("path");
|
|
14057
14230
|
|
|
14058
14231
|
// src/features/subagents/opencode-style-subagent.ts
|
|
14059
|
-
var
|
|
14060
|
-
var
|
|
14061
|
-
var OpenCodeStyleSubagentFrontmatterSchema =
|
|
14062
|
-
description:
|
|
14063
|
-
mode:
|
|
14064
|
-
name:
|
|
14232
|
+
var import_node_path101 = require("path");
|
|
14233
|
+
var import_mini57 = require("zod/mini");
|
|
14234
|
+
var OpenCodeStyleSubagentFrontmatterSchema = import_mini57.z.looseObject({
|
|
14235
|
+
description: import_mini57.z.optional(import_mini57.z.string()),
|
|
14236
|
+
mode: import_mini57.z._default(import_mini57.z.string(), "subagent"),
|
|
14237
|
+
name: import_mini57.z.optional(import_mini57.z.string())
|
|
14065
14238
|
});
|
|
14066
14239
|
var OpenCodeStyleSubagent = class extends ToolSubagent {
|
|
14067
14240
|
frontmatter;
|
|
@@ -14071,7 +14244,7 @@ var OpenCodeStyleSubagent = class extends ToolSubagent {
|
|
|
14071
14244
|
const result = OpenCodeStyleSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
14072
14245
|
if (!result.success) {
|
|
14073
14246
|
throw new Error(
|
|
14074
|
-
`Invalid frontmatter in ${(0,
|
|
14247
|
+
`Invalid frontmatter in ${(0, import_node_path101.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
14075
14248
|
);
|
|
14076
14249
|
}
|
|
14077
14250
|
}
|
|
@@ -14091,7 +14264,7 @@ var OpenCodeStyleSubagent = class extends ToolSubagent {
|
|
|
14091
14264
|
const { description, mode, name, ...toolSection } = this.frontmatter;
|
|
14092
14265
|
const rulesyncFrontmatter = {
|
|
14093
14266
|
targets: ["*"],
|
|
14094
|
-
name: name ?? (0,
|
|
14267
|
+
name: name ?? (0, import_node_path101.basename)(this.getRelativeFilePath(), ".md"),
|
|
14095
14268
|
description,
|
|
14096
14269
|
[this.getToolTarget()]: { mode, ...toolSection }
|
|
14097
14270
|
};
|
|
@@ -14113,7 +14286,7 @@ var OpenCodeStyleSubagent = class extends ToolSubagent {
|
|
|
14113
14286
|
return {
|
|
14114
14287
|
success: false,
|
|
14115
14288
|
error: new Error(
|
|
14116
|
-
`Invalid frontmatter in ${(0,
|
|
14289
|
+
`Invalid frontmatter in ${(0, import_node_path101.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
14117
14290
|
)
|
|
14118
14291
|
};
|
|
14119
14292
|
}
|
|
@@ -14129,7 +14302,7 @@ var KiloSubagent = class _KiloSubagent extends OpenCodeStyleSubagent {
|
|
|
14129
14302
|
global = false
|
|
14130
14303
|
} = {}) {
|
|
14131
14304
|
return {
|
|
14132
|
-
relativeDirPath: global ? (0,
|
|
14305
|
+
relativeDirPath: global ? (0, import_node_path102.join)(".config", "kilo", "agent") : (0, import_node_path102.join)(".kilo", "agent")
|
|
14133
14306
|
};
|
|
14134
14307
|
}
|
|
14135
14308
|
static fromRulesyncSubagent({
|
|
@@ -14173,7 +14346,7 @@ var KiloSubagent = class _KiloSubagent extends OpenCodeStyleSubagent {
|
|
|
14173
14346
|
global = false
|
|
14174
14347
|
}) {
|
|
14175
14348
|
const paths = this.getSettablePaths({ global });
|
|
14176
|
-
const filePath = (0,
|
|
14349
|
+
const filePath = (0, import_node_path102.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
14177
14350
|
const fileContent = await readFileContent(filePath);
|
|
14178
14351
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
14179
14352
|
const result = KiloSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -14209,23 +14382,23 @@ var KiloSubagent = class _KiloSubagent extends OpenCodeStyleSubagent {
|
|
|
14209
14382
|
};
|
|
14210
14383
|
|
|
14211
14384
|
// src/features/subagents/kiro-subagent.ts
|
|
14212
|
-
var
|
|
14213
|
-
var
|
|
14214
|
-
var KiroCliSubagentJsonSchema =
|
|
14215
|
-
name:
|
|
14216
|
-
description:
|
|
14217
|
-
prompt:
|
|
14218
|
-
tools:
|
|
14219
|
-
toolAliases:
|
|
14220
|
-
toolSettings:
|
|
14221
|
-
toolSchema:
|
|
14222
|
-
hooks:
|
|
14223
|
-
model:
|
|
14224
|
-
mcpServers:
|
|
14225
|
-
useLegacyMcpJson:
|
|
14226
|
-
resources:
|
|
14227
|
-
allowedTools:
|
|
14228
|
-
includeMcpJson:
|
|
14385
|
+
var import_node_path103 = require("path");
|
|
14386
|
+
var import_mini58 = require("zod/mini");
|
|
14387
|
+
var KiroCliSubagentJsonSchema = import_mini58.z.looseObject({
|
|
14388
|
+
name: import_mini58.z.string(),
|
|
14389
|
+
description: import_mini58.z.optional(import_mini58.z.nullable(import_mini58.z.string())),
|
|
14390
|
+
prompt: import_mini58.z.optional(import_mini58.z.nullable(import_mini58.z.string())),
|
|
14391
|
+
tools: import_mini58.z.optional(import_mini58.z.nullable(import_mini58.z.array(import_mini58.z.string()))),
|
|
14392
|
+
toolAliases: import_mini58.z.optional(import_mini58.z.nullable(import_mini58.z.record(import_mini58.z.string(), import_mini58.z.string()))),
|
|
14393
|
+
toolSettings: import_mini58.z.optional(import_mini58.z.nullable(import_mini58.z.unknown())),
|
|
14394
|
+
toolSchema: import_mini58.z.optional(import_mini58.z.nullable(import_mini58.z.unknown())),
|
|
14395
|
+
hooks: import_mini58.z.optional(import_mini58.z.nullable(import_mini58.z.record(import_mini58.z.string(), import_mini58.z.array(import_mini58.z.unknown())))),
|
|
14396
|
+
model: import_mini58.z.optional(import_mini58.z.nullable(import_mini58.z.string())),
|
|
14397
|
+
mcpServers: import_mini58.z.optional(import_mini58.z.nullable(import_mini58.z.record(import_mini58.z.string(), import_mini58.z.unknown()))),
|
|
14398
|
+
useLegacyMcpJson: import_mini58.z.optional(import_mini58.z.nullable(import_mini58.z.boolean())),
|
|
14399
|
+
resources: import_mini58.z.optional(import_mini58.z.nullable(import_mini58.z.array(import_mini58.z.string()))),
|
|
14400
|
+
allowedTools: import_mini58.z.optional(import_mini58.z.nullable(import_mini58.z.array(import_mini58.z.string()))),
|
|
14401
|
+
includeMcpJson: import_mini58.z.optional(import_mini58.z.nullable(import_mini58.z.boolean()))
|
|
14229
14402
|
});
|
|
14230
14403
|
var KiroSubagent = class _KiroSubagent extends ToolSubagent {
|
|
14231
14404
|
body;
|
|
@@ -14236,7 +14409,7 @@ var KiroSubagent = class _KiroSubagent extends ToolSubagent {
|
|
|
14236
14409
|
KiroCliSubagentJsonSchema.parse(parsed);
|
|
14237
14410
|
} catch (error) {
|
|
14238
14411
|
throw new Error(
|
|
14239
|
-
`Invalid JSON in ${(0,
|
|
14412
|
+
`Invalid JSON in ${(0, import_node_path103.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${error instanceof Error ? error.message : String(error)}`,
|
|
14240
14413
|
{ cause: error }
|
|
14241
14414
|
);
|
|
14242
14415
|
}
|
|
@@ -14248,7 +14421,7 @@ var KiroSubagent = class _KiroSubagent extends ToolSubagent {
|
|
|
14248
14421
|
}
|
|
14249
14422
|
static getSettablePaths(_options = {}) {
|
|
14250
14423
|
return {
|
|
14251
|
-
relativeDirPath: (0,
|
|
14424
|
+
relativeDirPath: (0, import_node_path103.join)(".kiro", "agents")
|
|
14252
14425
|
};
|
|
14253
14426
|
}
|
|
14254
14427
|
getBody() {
|
|
@@ -14260,7 +14433,7 @@ var KiroSubagent = class _KiroSubagent extends ToolSubagent {
|
|
|
14260
14433
|
parsed = JSON.parse(this.body);
|
|
14261
14434
|
} catch (error) {
|
|
14262
14435
|
throw new Error(
|
|
14263
|
-
`Failed to parse JSON in ${(0,
|
|
14436
|
+
`Failed to parse JSON in ${(0, import_node_path103.join)(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${error instanceof Error ? error.message : String(error)}`,
|
|
14264
14437
|
{ cause: error }
|
|
14265
14438
|
);
|
|
14266
14439
|
}
|
|
@@ -14341,7 +14514,7 @@ var KiroSubagent = class _KiroSubagent extends ToolSubagent {
|
|
|
14341
14514
|
global = false
|
|
14342
14515
|
}) {
|
|
14343
14516
|
const paths = this.getSettablePaths({ global });
|
|
14344
|
-
const filePath = (0,
|
|
14517
|
+
const filePath = (0, import_node_path103.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
14345
14518
|
const fileContent = await readFileContent(filePath);
|
|
14346
14519
|
const subagent = new _KiroSubagent({
|
|
14347
14520
|
baseDir,
|
|
@@ -14379,7 +14552,7 @@ var KiroSubagent = class _KiroSubagent extends ToolSubagent {
|
|
|
14379
14552
|
};
|
|
14380
14553
|
|
|
14381
14554
|
// src/features/subagents/opencode-subagent.ts
|
|
14382
|
-
var
|
|
14555
|
+
var import_node_path104 = require("path");
|
|
14383
14556
|
var OpenCodeSubagentFrontmatterSchema = OpenCodeStyleSubagentFrontmatterSchema;
|
|
14384
14557
|
var OpenCodeSubagent = class _OpenCodeSubagent extends OpenCodeStyleSubagent {
|
|
14385
14558
|
getToolTarget() {
|
|
@@ -14389,7 +14562,7 @@ var OpenCodeSubagent = class _OpenCodeSubagent extends OpenCodeStyleSubagent {
|
|
|
14389
14562
|
global = false
|
|
14390
14563
|
} = {}) {
|
|
14391
14564
|
return {
|
|
14392
|
-
relativeDirPath: global ? (0,
|
|
14565
|
+
relativeDirPath: global ? (0, import_node_path104.join)(".config", "opencode", "agent") : (0, import_node_path104.join)(".opencode", "agent")
|
|
14393
14566
|
};
|
|
14394
14567
|
}
|
|
14395
14568
|
static fromRulesyncSubagent({
|
|
@@ -14433,7 +14606,7 @@ var OpenCodeSubagent = class _OpenCodeSubagent extends OpenCodeStyleSubagent {
|
|
|
14433
14606
|
global = false
|
|
14434
14607
|
}) {
|
|
14435
14608
|
const paths = this.getSettablePaths({ global });
|
|
14436
|
-
const filePath = (0,
|
|
14609
|
+
const filePath = (0, import_node_path104.join)(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
14437
14610
|
const fileContent = await readFileContent(filePath);
|
|
14438
14611
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
14439
14612
|
const result = OpenCodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -14486,7 +14659,7 @@ var subagentsProcessorToolTargetTuple = [
|
|
|
14486
14659
|
"roo",
|
|
14487
14660
|
"rovodev"
|
|
14488
14661
|
];
|
|
14489
|
-
var SubagentsProcessorToolTargetSchema =
|
|
14662
|
+
var SubagentsProcessorToolTargetSchema = import_mini59.z.enum(subagentsProcessorToolTargetTuple);
|
|
14490
14663
|
var toolSubagentFactories = /* @__PURE__ */ new Map([
|
|
14491
14664
|
[
|
|
14492
14665
|
"agentsmd",
|
|
@@ -14677,7 +14850,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
14677
14850
|
* Load and parse rulesync subagent files from .rulesync/subagents/ directory
|
|
14678
14851
|
*/
|
|
14679
14852
|
async loadRulesyncFiles() {
|
|
14680
|
-
const subagentsDir = (0,
|
|
14853
|
+
const subagentsDir = (0, import_node_path105.join)(process.cwd(), RulesyncSubagent.getSettablePaths().relativeDirPath);
|
|
14681
14854
|
const dirExists = await directoryExists(subagentsDir);
|
|
14682
14855
|
if (!dirExists) {
|
|
14683
14856
|
this.logger.debug(`Rulesync subagents directory not found: ${subagentsDir}`);
|
|
@@ -14692,7 +14865,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
14692
14865
|
this.logger.debug(`Found ${mdFiles.length} subagent files in ${subagentsDir}`);
|
|
14693
14866
|
const rulesyncSubagents = [];
|
|
14694
14867
|
for (const mdFile of mdFiles) {
|
|
14695
|
-
const filepath = (0,
|
|
14868
|
+
const filepath = (0, import_node_path105.join)(subagentsDir, mdFile);
|
|
14696
14869
|
try {
|
|
14697
14870
|
const rulesyncSubagent = await RulesyncSubagent.fromFile({
|
|
14698
14871
|
relativeFilePath: mdFile,
|
|
@@ -14722,14 +14895,14 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
14722
14895
|
const factory = this.getFactory(this.toolTarget);
|
|
14723
14896
|
const paths = factory.class.getSettablePaths({ global: this.global });
|
|
14724
14897
|
const subagentFilePaths = await findFilesByGlobs(
|
|
14725
|
-
(0,
|
|
14898
|
+
(0, import_node_path105.join)(this.baseDir, paths.relativeDirPath, factory.meta.filePattern)
|
|
14726
14899
|
);
|
|
14727
14900
|
if (forDeletion) {
|
|
14728
14901
|
const toolSubagents2 = subagentFilePaths.map(
|
|
14729
14902
|
(path4) => factory.class.forDeletion({
|
|
14730
14903
|
baseDir: this.baseDir,
|
|
14731
14904
|
relativeDirPath: paths.relativeDirPath,
|
|
14732
|
-
relativeFilePath: (0,
|
|
14905
|
+
relativeFilePath: (0, import_node_path105.basename)(path4),
|
|
14733
14906
|
global: this.global
|
|
14734
14907
|
})
|
|
14735
14908
|
).filter((subagent) => subagent.isDeletable());
|
|
@@ -14742,7 +14915,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
14742
14915
|
subagentFilePaths.map(
|
|
14743
14916
|
(path4) => factory.class.fromFile({
|
|
14744
14917
|
baseDir: this.baseDir,
|
|
14745
|
-
relativeFilePath: (0,
|
|
14918
|
+
relativeFilePath: (0, import_node_path105.basename)(path4),
|
|
14746
14919
|
global: this.global
|
|
14747
14920
|
})
|
|
14748
14921
|
)
|
|
@@ -14789,49 +14962,49 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
14789
14962
|
};
|
|
14790
14963
|
|
|
14791
14964
|
// src/features/rules/agentsmd-rule.ts
|
|
14792
|
-
var
|
|
14965
|
+
var import_node_path108 = require("path");
|
|
14793
14966
|
|
|
14794
14967
|
// src/features/rules/tool-rule.ts
|
|
14795
|
-
var
|
|
14968
|
+
var import_node_path107 = require("path");
|
|
14796
14969
|
|
|
14797
14970
|
// src/features/rules/rulesync-rule.ts
|
|
14798
|
-
var
|
|
14799
|
-
var
|
|
14800
|
-
var RulesyncRuleFrontmatterSchema =
|
|
14801
|
-
root:
|
|
14802
|
-
localRoot:
|
|
14803
|
-
targets:
|
|
14804
|
-
description:
|
|
14805
|
-
globs:
|
|
14806
|
-
agentsmd:
|
|
14807
|
-
|
|
14971
|
+
var import_node_path106 = require("path");
|
|
14972
|
+
var import_mini60 = require("zod/mini");
|
|
14973
|
+
var RulesyncRuleFrontmatterSchema = import_mini60.z.object({
|
|
14974
|
+
root: import_mini60.z.optional(import_mini60.z.boolean()),
|
|
14975
|
+
localRoot: import_mini60.z.optional(import_mini60.z.boolean()),
|
|
14976
|
+
targets: import_mini60.z._default(RulesyncTargetsSchema, ["*"]),
|
|
14977
|
+
description: import_mini60.z.optional(import_mini60.z.string()),
|
|
14978
|
+
globs: import_mini60.z.optional(import_mini60.z.array(import_mini60.z.string())),
|
|
14979
|
+
agentsmd: import_mini60.z.optional(
|
|
14980
|
+
import_mini60.z.looseObject({
|
|
14808
14981
|
// @example "path/to/subproject"
|
|
14809
|
-
subprojectPath:
|
|
14982
|
+
subprojectPath: import_mini60.z.optional(import_mini60.z.string())
|
|
14810
14983
|
})
|
|
14811
14984
|
),
|
|
14812
|
-
claudecode:
|
|
14813
|
-
|
|
14985
|
+
claudecode: import_mini60.z.optional(
|
|
14986
|
+
import_mini60.z.looseObject({
|
|
14814
14987
|
// Glob patterns for conditional rules (takes precedence over globs)
|
|
14815
14988
|
// @example ["src/**/*.ts", "tests/**/*.test.ts"]
|
|
14816
|
-
paths:
|
|
14989
|
+
paths: import_mini60.z.optional(import_mini60.z.array(import_mini60.z.string()))
|
|
14817
14990
|
})
|
|
14818
14991
|
),
|
|
14819
|
-
cursor:
|
|
14820
|
-
|
|
14821
|
-
alwaysApply:
|
|
14822
|
-
description:
|
|
14823
|
-
globs:
|
|
14992
|
+
cursor: import_mini60.z.optional(
|
|
14993
|
+
import_mini60.z.looseObject({
|
|
14994
|
+
alwaysApply: import_mini60.z.optional(import_mini60.z.boolean()),
|
|
14995
|
+
description: import_mini60.z.optional(import_mini60.z.string()),
|
|
14996
|
+
globs: import_mini60.z.optional(import_mini60.z.array(import_mini60.z.string()))
|
|
14824
14997
|
})
|
|
14825
14998
|
),
|
|
14826
|
-
copilot:
|
|
14827
|
-
|
|
14828
|
-
excludeAgent:
|
|
14999
|
+
copilot: import_mini60.z.optional(
|
|
15000
|
+
import_mini60.z.looseObject({
|
|
15001
|
+
excludeAgent: import_mini60.z.optional(import_mini60.z.union([import_mini60.z.literal("code-review"), import_mini60.z.literal("coding-agent")]))
|
|
14829
15002
|
})
|
|
14830
15003
|
),
|
|
14831
|
-
antigravity:
|
|
14832
|
-
|
|
14833
|
-
trigger:
|
|
14834
|
-
globs:
|
|
15004
|
+
antigravity: import_mini60.z.optional(
|
|
15005
|
+
import_mini60.z.looseObject({
|
|
15006
|
+
trigger: import_mini60.z.optional(import_mini60.z.string()),
|
|
15007
|
+
globs: import_mini60.z.optional(import_mini60.z.array(import_mini60.z.string()))
|
|
14835
15008
|
})
|
|
14836
15009
|
)
|
|
14837
15010
|
});
|
|
@@ -14842,7 +15015,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
14842
15015
|
const parseResult = RulesyncRuleFrontmatterSchema.safeParse(frontmatter);
|
|
14843
15016
|
if (!parseResult.success && rest.validate !== false) {
|
|
14844
15017
|
throw new Error(
|
|
14845
|
-
`Invalid frontmatter in ${(0,
|
|
15018
|
+
`Invalid frontmatter in ${(0, import_node_path106.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(parseResult.error)}`
|
|
14846
15019
|
);
|
|
14847
15020
|
}
|
|
14848
15021
|
const parsedFrontmatter = parseResult.success ? parseResult.data : { ...frontmatter, targets: frontmatter.targets ?? ["*"] };
|
|
@@ -14877,7 +15050,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
14877
15050
|
return {
|
|
14878
15051
|
success: false,
|
|
14879
15052
|
error: new Error(
|
|
14880
|
-
`Invalid frontmatter in ${(0,
|
|
15053
|
+
`Invalid frontmatter in ${(0, import_node_path106.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
14881
15054
|
)
|
|
14882
15055
|
};
|
|
14883
15056
|
}
|
|
@@ -14886,7 +15059,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
14886
15059
|
relativeFilePath,
|
|
14887
15060
|
validate = true
|
|
14888
15061
|
}) {
|
|
14889
|
-
const filePath = (0,
|
|
15062
|
+
const filePath = (0, import_node_path106.join)(
|
|
14890
15063
|
process.cwd(),
|
|
14891
15064
|
this.getSettablePaths().recommended.relativeDirPath,
|
|
14892
15065
|
relativeFilePath
|
|
@@ -14985,7 +15158,7 @@ var ToolRule = class extends ToolFile {
|
|
|
14985
15158
|
rulesyncRule,
|
|
14986
15159
|
validate = true,
|
|
14987
15160
|
rootPath = { relativeDirPath: ".", relativeFilePath: "AGENTS.md" },
|
|
14988
|
-
nonRootPath = { relativeDirPath: (0,
|
|
15161
|
+
nonRootPath = { relativeDirPath: (0, import_node_path107.join)(".agents", "memories") }
|
|
14989
15162
|
}) {
|
|
14990
15163
|
const params = this.buildToolRuleParamsDefault({
|
|
14991
15164
|
baseDir,
|
|
@@ -14996,7 +15169,7 @@ var ToolRule = class extends ToolFile {
|
|
|
14996
15169
|
});
|
|
14997
15170
|
const rulesyncFrontmatter = rulesyncRule.getFrontmatter();
|
|
14998
15171
|
if (!rulesyncFrontmatter.root && rulesyncFrontmatter.agentsmd?.subprojectPath) {
|
|
14999
|
-
params.relativeDirPath = (0,
|
|
15172
|
+
params.relativeDirPath = (0, import_node_path107.join)(rulesyncFrontmatter.agentsmd.subprojectPath);
|
|
15000
15173
|
params.relativeFilePath = "AGENTS.md";
|
|
15001
15174
|
}
|
|
15002
15175
|
return params;
|
|
@@ -15045,7 +15218,7 @@ var ToolRule = class extends ToolFile {
|
|
|
15045
15218
|
}
|
|
15046
15219
|
};
|
|
15047
15220
|
function buildToolPath(toolDir, subDir, excludeToolDir) {
|
|
15048
|
-
return excludeToolDir ? subDir : (0,
|
|
15221
|
+
return excludeToolDir ? subDir : (0, import_node_path107.join)(toolDir, subDir);
|
|
15049
15222
|
}
|
|
15050
15223
|
|
|
15051
15224
|
// src/features/rules/agentsmd-rule.ts
|
|
@@ -15074,8 +15247,8 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
15074
15247
|
validate = true
|
|
15075
15248
|
}) {
|
|
15076
15249
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
15077
|
-
const relativePath = isRoot ? "AGENTS.md" : (0,
|
|
15078
|
-
const fileContent = await readFileContent((0,
|
|
15250
|
+
const relativePath = isRoot ? "AGENTS.md" : (0, import_node_path108.join)(".agents", "memories", relativeFilePath);
|
|
15251
|
+
const fileContent = await readFileContent((0, import_node_path108.join)(baseDir, relativePath));
|
|
15079
15252
|
return new _AgentsMdRule({
|
|
15080
15253
|
baseDir,
|
|
15081
15254
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -15130,21 +15303,21 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
15130
15303
|
};
|
|
15131
15304
|
|
|
15132
15305
|
// src/features/rules/antigravity-rule.ts
|
|
15133
|
-
var
|
|
15134
|
-
var
|
|
15135
|
-
var AntigravityRuleFrontmatterSchema =
|
|
15136
|
-
trigger:
|
|
15137
|
-
|
|
15138
|
-
|
|
15139
|
-
|
|
15140
|
-
|
|
15141
|
-
|
|
15142
|
-
|
|
15306
|
+
var import_node_path109 = require("path");
|
|
15307
|
+
var import_mini61 = require("zod/mini");
|
|
15308
|
+
var AntigravityRuleFrontmatterSchema = import_mini61.z.looseObject({
|
|
15309
|
+
trigger: import_mini61.z.optional(
|
|
15310
|
+
import_mini61.z.union([
|
|
15311
|
+
import_mini61.z.literal("always_on"),
|
|
15312
|
+
import_mini61.z.literal("glob"),
|
|
15313
|
+
import_mini61.z.literal("manual"),
|
|
15314
|
+
import_mini61.z.literal("model_decision"),
|
|
15315
|
+
import_mini61.z.string()
|
|
15143
15316
|
// accepts any string for forward compatibility
|
|
15144
15317
|
])
|
|
15145
15318
|
),
|
|
15146
|
-
globs:
|
|
15147
|
-
description:
|
|
15319
|
+
globs: import_mini61.z.optional(import_mini61.z.string()),
|
|
15320
|
+
description: import_mini61.z.optional(import_mini61.z.string())
|
|
15148
15321
|
});
|
|
15149
15322
|
function parseGlobsString(globs) {
|
|
15150
15323
|
if (!globs) {
|
|
@@ -15289,7 +15462,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
15289
15462
|
const result = AntigravityRuleFrontmatterSchema.safeParse(frontmatter);
|
|
15290
15463
|
if (!result.success) {
|
|
15291
15464
|
throw new Error(
|
|
15292
|
-
`Invalid frontmatter in ${(0,
|
|
15465
|
+
`Invalid frontmatter in ${(0, import_node_path109.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
15293
15466
|
);
|
|
15294
15467
|
}
|
|
15295
15468
|
}
|
|
@@ -15313,7 +15486,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
15313
15486
|
relativeFilePath,
|
|
15314
15487
|
validate = true
|
|
15315
15488
|
}) {
|
|
15316
|
-
const filePath = (0,
|
|
15489
|
+
const filePath = (0, import_node_path109.join)(
|
|
15317
15490
|
baseDir,
|
|
15318
15491
|
this.getSettablePaths().nonRoot.relativeDirPath,
|
|
15319
15492
|
relativeFilePath
|
|
@@ -15453,7 +15626,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
15453
15626
|
};
|
|
15454
15627
|
|
|
15455
15628
|
// src/features/rules/augmentcode-legacy-rule.ts
|
|
15456
|
-
var
|
|
15629
|
+
var import_node_path110 = require("path");
|
|
15457
15630
|
var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
15458
15631
|
toRulesyncRule() {
|
|
15459
15632
|
const rulesyncFrontmatter = {
|
|
@@ -15513,8 +15686,8 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
15513
15686
|
}) {
|
|
15514
15687
|
const settablePaths = this.getSettablePaths();
|
|
15515
15688
|
const isRoot = relativeFilePath === settablePaths.root.relativeFilePath;
|
|
15516
|
-
const relativePath = isRoot ? settablePaths.root.relativeFilePath : (0,
|
|
15517
|
-
const fileContent = await readFileContent((0,
|
|
15689
|
+
const relativePath = isRoot ? settablePaths.root.relativeFilePath : (0, import_node_path110.join)(settablePaths.nonRoot.relativeDirPath, relativeFilePath);
|
|
15690
|
+
const fileContent = await readFileContent((0, import_node_path110.join)(baseDir, relativePath));
|
|
15518
15691
|
return new _AugmentcodeLegacyRule({
|
|
15519
15692
|
baseDir,
|
|
15520
15693
|
relativeDirPath: isRoot ? settablePaths.root.relativeDirPath : settablePaths.nonRoot.relativeDirPath,
|
|
@@ -15543,7 +15716,7 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
15543
15716
|
};
|
|
15544
15717
|
|
|
15545
15718
|
// src/features/rules/augmentcode-rule.ts
|
|
15546
|
-
var
|
|
15719
|
+
var import_node_path111 = require("path");
|
|
15547
15720
|
var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
15548
15721
|
toRulesyncRule() {
|
|
15549
15722
|
return this.toRulesyncRuleDefault();
|
|
@@ -15574,7 +15747,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
15574
15747
|
relativeFilePath,
|
|
15575
15748
|
validate = true
|
|
15576
15749
|
}) {
|
|
15577
|
-
const filePath = (0,
|
|
15750
|
+
const filePath = (0, import_node_path111.join)(
|
|
15578
15751
|
baseDir,
|
|
15579
15752
|
this.getSettablePaths().nonRoot.relativeDirPath,
|
|
15580
15753
|
relativeFilePath
|
|
@@ -15614,7 +15787,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
15614
15787
|
};
|
|
15615
15788
|
|
|
15616
15789
|
// src/features/rules/claudecode-legacy-rule.ts
|
|
15617
|
-
var
|
|
15790
|
+
var import_node_path112 = require("path");
|
|
15618
15791
|
var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
15619
15792
|
static getSettablePaths({
|
|
15620
15793
|
global,
|
|
@@ -15656,7 +15829,7 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
15656
15829
|
if (isRoot) {
|
|
15657
15830
|
const rootDirPath = overrideDirPath ?? paths.root.relativeDirPath;
|
|
15658
15831
|
const fileContent2 = await readFileContent(
|
|
15659
|
-
(0,
|
|
15832
|
+
(0, import_node_path112.join)(baseDir, rootDirPath, paths.root.relativeFilePath)
|
|
15660
15833
|
);
|
|
15661
15834
|
return new _ClaudecodeLegacyRule({
|
|
15662
15835
|
baseDir,
|
|
@@ -15670,8 +15843,8 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
15670
15843
|
if (!paths.nonRoot) {
|
|
15671
15844
|
throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
|
|
15672
15845
|
}
|
|
15673
|
-
const relativePath = (0,
|
|
15674
|
-
const fileContent = await readFileContent((0,
|
|
15846
|
+
const relativePath = (0, import_node_path112.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
15847
|
+
const fileContent = await readFileContent((0, import_node_path112.join)(baseDir, relativePath));
|
|
15675
15848
|
return new _ClaudecodeLegacyRule({
|
|
15676
15849
|
baseDir,
|
|
15677
15850
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -15730,10 +15903,10 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
15730
15903
|
};
|
|
15731
15904
|
|
|
15732
15905
|
// src/features/rules/claudecode-rule.ts
|
|
15733
|
-
var
|
|
15734
|
-
var
|
|
15735
|
-
var ClaudecodeRuleFrontmatterSchema =
|
|
15736
|
-
paths:
|
|
15906
|
+
var import_node_path113 = require("path");
|
|
15907
|
+
var import_mini62 = require("zod/mini");
|
|
15908
|
+
var ClaudecodeRuleFrontmatterSchema = import_mini62.z.object({
|
|
15909
|
+
paths: import_mini62.z.optional(import_mini62.z.array(import_mini62.z.string()))
|
|
15737
15910
|
});
|
|
15738
15911
|
var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
15739
15912
|
frontmatter;
|
|
@@ -15771,7 +15944,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
15771
15944
|
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
15772
15945
|
if (!result.success) {
|
|
15773
15946
|
throw new Error(
|
|
15774
|
-
`Invalid frontmatter in ${(0,
|
|
15947
|
+
`Invalid frontmatter in ${(0, import_node_path113.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
15775
15948
|
);
|
|
15776
15949
|
}
|
|
15777
15950
|
}
|
|
@@ -15801,7 +15974,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
15801
15974
|
if (isRoot) {
|
|
15802
15975
|
const rootDirPath = overrideDirPath ?? paths.root.relativeDirPath;
|
|
15803
15976
|
const fileContent2 = await readFileContent(
|
|
15804
|
-
(0,
|
|
15977
|
+
(0, import_node_path113.join)(baseDir, rootDirPath, paths.root.relativeFilePath)
|
|
15805
15978
|
);
|
|
15806
15979
|
return new _ClaudecodeRule({
|
|
15807
15980
|
baseDir,
|
|
@@ -15816,8 +15989,8 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
15816
15989
|
if (!paths.nonRoot) {
|
|
15817
15990
|
throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
|
|
15818
15991
|
}
|
|
15819
|
-
const relativePath = (0,
|
|
15820
|
-
const filePath = (0,
|
|
15992
|
+
const relativePath = (0, import_node_path113.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
15993
|
+
const filePath = (0, import_node_path113.join)(baseDir, relativePath);
|
|
15821
15994
|
const fileContent = await readFileContent(filePath);
|
|
15822
15995
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
15823
15996
|
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -15928,7 +16101,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
15928
16101
|
return {
|
|
15929
16102
|
success: false,
|
|
15930
16103
|
error: new Error(
|
|
15931
|
-
`Invalid frontmatter in ${(0,
|
|
16104
|
+
`Invalid frontmatter in ${(0, import_node_path113.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
15932
16105
|
)
|
|
15933
16106
|
};
|
|
15934
16107
|
}
|
|
@@ -15948,10 +16121,10 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
15948
16121
|
};
|
|
15949
16122
|
|
|
15950
16123
|
// src/features/rules/cline-rule.ts
|
|
15951
|
-
var
|
|
15952
|
-
var
|
|
15953
|
-
var ClineRuleFrontmatterSchema =
|
|
15954
|
-
description:
|
|
16124
|
+
var import_node_path114 = require("path");
|
|
16125
|
+
var import_mini63 = require("zod/mini");
|
|
16126
|
+
var ClineRuleFrontmatterSchema = import_mini63.z.object({
|
|
16127
|
+
description: import_mini63.z.string()
|
|
15955
16128
|
});
|
|
15956
16129
|
var ClineRule = class _ClineRule extends ToolRule {
|
|
15957
16130
|
static getSettablePaths(_options = {}) {
|
|
@@ -15994,7 +16167,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
15994
16167
|
validate = true
|
|
15995
16168
|
}) {
|
|
15996
16169
|
const fileContent = await readFileContent(
|
|
15997
|
-
(0,
|
|
16170
|
+
(0, import_node_path114.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
15998
16171
|
);
|
|
15999
16172
|
return new _ClineRule({
|
|
16000
16173
|
baseDir,
|
|
@@ -16020,7 +16193,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
16020
16193
|
};
|
|
16021
16194
|
|
|
16022
16195
|
// src/features/rules/codexcli-rule.ts
|
|
16023
|
-
var
|
|
16196
|
+
var import_node_path115 = require("path");
|
|
16024
16197
|
var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
16025
16198
|
static getSettablePaths({
|
|
16026
16199
|
global,
|
|
@@ -16055,7 +16228,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
16055
16228
|
if (isRoot) {
|
|
16056
16229
|
const relativePath2 = paths.root.relativeFilePath;
|
|
16057
16230
|
const fileContent2 = await readFileContent(
|
|
16058
|
-
(0,
|
|
16231
|
+
(0, import_node_path115.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
16059
16232
|
);
|
|
16060
16233
|
return new _CodexcliRule({
|
|
16061
16234
|
baseDir,
|
|
@@ -16069,8 +16242,8 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
16069
16242
|
if (!paths.nonRoot) {
|
|
16070
16243
|
throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
|
|
16071
16244
|
}
|
|
16072
|
-
const relativePath = (0,
|
|
16073
|
-
const fileContent = await readFileContent((0,
|
|
16245
|
+
const relativePath = (0, import_node_path115.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
16246
|
+
const fileContent = await readFileContent((0, import_node_path115.join)(baseDir, relativePath));
|
|
16074
16247
|
return new _CodexcliRule({
|
|
16075
16248
|
baseDir,
|
|
16076
16249
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -16129,12 +16302,12 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
16129
16302
|
};
|
|
16130
16303
|
|
|
16131
16304
|
// src/features/rules/copilot-rule.ts
|
|
16132
|
-
var
|
|
16133
|
-
var
|
|
16134
|
-
var CopilotRuleFrontmatterSchema =
|
|
16135
|
-
description:
|
|
16136
|
-
applyTo:
|
|
16137
|
-
excludeAgent:
|
|
16305
|
+
var import_node_path116 = require("path");
|
|
16306
|
+
var import_mini64 = require("zod/mini");
|
|
16307
|
+
var CopilotRuleFrontmatterSchema = import_mini64.z.object({
|
|
16308
|
+
description: import_mini64.z.optional(import_mini64.z.string()),
|
|
16309
|
+
applyTo: import_mini64.z.optional(import_mini64.z.string()),
|
|
16310
|
+
excludeAgent: import_mini64.z.optional(import_mini64.z.union([import_mini64.z.literal("code-review"), import_mini64.z.literal("coding-agent")]))
|
|
16138
16311
|
});
|
|
16139
16312
|
var CopilotRule = class _CopilotRule extends ToolRule {
|
|
16140
16313
|
frontmatter;
|
|
@@ -16166,7 +16339,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
16166
16339
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
16167
16340
|
if (!result.success) {
|
|
16168
16341
|
throw new Error(
|
|
16169
|
-
`Invalid frontmatter in ${(0,
|
|
16342
|
+
`Invalid frontmatter in ${(0, import_node_path116.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
16170
16343
|
);
|
|
16171
16344
|
}
|
|
16172
16345
|
}
|
|
@@ -16256,8 +16429,8 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
16256
16429
|
const paths = this.getSettablePaths({ global });
|
|
16257
16430
|
const isRoot = relativeFilePath === paths.root.relativeFilePath;
|
|
16258
16431
|
if (isRoot) {
|
|
16259
|
-
const relativePath2 = (0,
|
|
16260
|
-
const filePath2 = (0,
|
|
16432
|
+
const relativePath2 = (0, import_node_path116.join)(paths.root.relativeDirPath, paths.root.relativeFilePath);
|
|
16433
|
+
const filePath2 = (0, import_node_path116.join)(baseDir, relativePath2);
|
|
16261
16434
|
const fileContent2 = await readFileContent(filePath2);
|
|
16262
16435
|
return new _CopilotRule({
|
|
16263
16436
|
baseDir,
|
|
@@ -16272,8 +16445,8 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
16272
16445
|
if (!paths.nonRoot) {
|
|
16273
16446
|
throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
|
|
16274
16447
|
}
|
|
16275
|
-
const relativePath = (0,
|
|
16276
|
-
const filePath = (0,
|
|
16448
|
+
const relativePath = (0, import_node_path116.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
16449
|
+
const filePath = (0, import_node_path116.join)(baseDir, relativePath);
|
|
16277
16450
|
const fileContent = await readFileContent(filePath);
|
|
16278
16451
|
const { frontmatter, body: content } = parseFrontmatter(fileContent, filePath);
|
|
16279
16452
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -16319,7 +16492,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
16319
16492
|
return {
|
|
16320
16493
|
success: false,
|
|
16321
16494
|
error: new Error(
|
|
16322
|
-
`Invalid frontmatter in ${(0,
|
|
16495
|
+
`Invalid frontmatter in ${(0, import_node_path116.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
16323
16496
|
)
|
|
16324
16497
|
};
|
|
16325
16498
|
}
|
|
@@ -16375,12 +16548,12 @@ var CopilotcliRule = class _CopilotcliRule extends CopilotRule {
|
|
|
16375
16548
|
};
|
|
16376
16549
|
|
|
16377
16550
|
// src/features/rules/cursor-rule.ts
|
|
16378
|
-
var
|
|
16379
|
-
var
|
|
16380
|
-
var CursorRuleFrontmatterSchema =
|
|
16381
|
-
description:
|
|
16382
|
-
globs:
|
|
16383
|
-
alwaysApply:
|
|
16551
|
+
var import_node_path117 = require("path");
|
|
16552
|
+
var import_mini65 = require("zod/mini");
|
|
16553
|
+
var CursorRuleFrontmatterSchema = import_mini65.z.object({
|
|
16554
|
+
description: import_mini65.z.optional(import_mini65.z.string()),
|
|
16555
|
+
globs: import_mini65.z.optional(import_mini65.z.string()),
|
|
16556
|
+
alwaysApply: import_mini65.z.optional(import_mini65.z.boolean())
|
|
16384
16557
|
});
|
|
16385
16558
|
var CursorRule = class _CursorRule extends ToolRule {
|
|
16386
16559
|
frontmatter;
|
|
@@ -16397,7 +16570,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
16397
16570
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
16398
16571
|
if (!result.success) {
|
|
16399
16572
|
throw new Error(
|
|
16400
|
-
`Invalid frontmatter in ${(0,
|
|
16573
|
+
`Invalid frontmatter in ${(0, import_node_path117.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
16401
16574
|
);
|
|
16402
16575
|
}
|
|
16403
16576
|
}
|
|
@@ -16513,7 +16686,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
16513
16686
|
relativeFilePath,
|
|
16514
16687
|
validate = true
|
|
16515
16688
|
}) {
|
|
16516
|
-
const filePath = (0,
|
|
16689
|
+
const filePath = (0, import_node_path117.join)(
|
|
16517
16690
|
baseDir,
|
|
16518
16691
|
this.getSettablePaths().nonRoot.relativeDirPath,
|
|
16519
16692
|
relativeFilePath
|
|
@@ -16523,7 +16696,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
16523
16696
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
16524
16697
|
if (!result.success) {
|
|
16525
16698
|
throw new Error(
|
|
16526
|
-
`Invalid frontmatter in ${(0,
|
|
16699
|
+
`Invalid frontmatter in ${(0, import_node_path117.join)(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
16527
16700
|
);
|
|
16528
16701
|
}
|
|
16529
16702
|
return new _CursorRule({
|
|
@@ -16560,7 +16733,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
16560
16733
|
return {
|
|
16561
16734
|
success: false,
|
|
16562
16735
|
error: new Error(
|
|
16563
|
-
`Invalid frontmatter in ${(0,
|
|
16736
|
+
`Invalid frontmatter in ${(0, import_node_path117.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
16564
16737
|
)
|
|
16565
16738
|
};
|
|
16566
16739
|
}
|
|
@@ -16580,7 +16753,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
16580
16753
|
};
|
|
16581
16754
|
|
|
16582
16755
|
// src/features/rules/deepagents-rule.ts
|
|
16583
|
-
var
|
|
16756
|
+
var import_node_path118 = require("path");
|
|
16584
16757
|
var DeepagentsRule = class _DeepagentsRule extends ToolRule {
|
|
16585
16758
|
constructor({ fileContent, root, ...rest }) {
|
|
16586
16759
|
super({
|
|
@@ -16607,8 +16780,8 @@ var DeepagentsRule = class _DeepagentsRule extends ToolRule {
|
|
|
16607
16780
|
}) {
|
|
16608
16781
|
const settablePaths = this.getSettablePaths();
|
|
16609
16782
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
16610
|
-
const relativePath = isRoot ? (0,
|
|
16611
|
-
const fileContent = await readFileContent((0,
|
|
16783
|
+
const relativePath = isRoot ? (0, import_node_path118.join)(".deepagents", "AGENTS.md") : (0, import_node_path118.join)(".deepagents", "memories", relativeFilePath);
|
|
16784
|
+
const fileContent = await readFileContent((0, import_node_path118.join)(baseDir, relativePath));
|
|
16612
16785
|
return new _DeepagentsRule({
|
|
16613
16786
|
baseDir,
|
|
16614
16787
|
relativeDirPath: isRoot ? settablePaths.root.relativeDirPath : settablePaths.nonRoot.relativeDirPath,
|
|
@@ -16663,7 +16836,7 @@ var DeepagentsRule = class _DeepagentsRule extends ToolRule {
|
|
|
16663
16836
|
};
|
|
16664
16837
|
|
|
16665
16838
|
// src/features/rules/factorydroid-rule.ts
|
|
16666
|
-
var
|
|
16839
|
+
var import_node_path119 = require("path");
|
|
16667
16840
|
var FactorydroidRule = class _FactorydroidRule extends ToolRule {
|
|
16668
16841
|
constructor({ fileContent, root, ...rest }) {
|
|
16669
16842
|
super({
|
|
@@ -16703,8 +16876,8 @@ var FactorydroidRule = class _FactorydroidRule extends ToolRule {
|
|
|
16703
16876
|
const paths = this.getSettablePaths({ global });
|
|
16704
16877
|
const isRoot = relativeFilePath === paths.root.relativeFilePath;
|
|
16705
16878
|
if (isRoot) {
|
|
16706
|
-
const relativePath2 = (0,
|
|
16707
|
-
const fileContent2 = await readFileContent((0,
|
|
16879
|
+
const relativePath2 = (0, import_node_path119.join)(paths.root.relativeDirPath, paths.root.relativeFilePath);
|
|
16880
|
+
const fileContent2 = await readFileContent((0, import_node_path119.join)(baseDir, relativePath2));
|
|
16708
16881
|
return new _FactorydroidRule({
|
|
16709
16882
|
baseDir,
|
|
16710
16883
|
relativeDirPath: paths.root.relativeDirPath,
|
|
@@ -16717,8 +16890,8 @@ var FactorydroidRule = class _FactorydroidRule extends ToolRule {
|
|
|
16717
16890
|
if (!paths.nonRoot) {
|
|
16718
16891
|
throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
|
|
16719
16892
|
}
|
|
16720
|
-
const relativePath = (0,
|
|
16721
|
-
const fileContent = await readFileContent((0,
|
|
16893
|
+
const relativePath = (0, import_node_path119.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
16894
|
+
const fileContent = await readFileContent((0, import_node_path119.join)(baseDir, relativePath));
|
|
16722
16895
|
return new _FactorydroidRule({
|
|
16723
16896
|
baseDir,
|
|
16724
16897
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -16777,7 +16950,7 @@ var FactorydroidRule = class _FactorydroidRule extends ToolRule {
|
|
|
16777
16950
|
};
|
|
16778
16951
|
|
|
16779
16952
|
// src/features/rules/geminicli-rule.ts
|
|
16780
|
-
var
|
|
16953
|
+
var import_node_path120 = require("path");
|
|
16781
16954
|
var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
16782
16955
|
static getSettablePaths({
|
|
16783
16956
|
global,
|
|
@@ -16812,7 +16985,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
16812
16985
|
if (isRoot) {
|
|
16813
16986
|
const relativePath2 = paths.root.relativeFilePath;
|
|
16814
16987
|
const fileContent2 = await readFileContent(
|
|
16815
|
-
(0,
|
|
16988
|
+
(0, import_node_path120.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
16816
16989
|
);
|
|
16817
16990
|
return new _GeminiCliRule({
|
|
16818
16991
|
baseDir,
|
|
@@ -16826,8 +16999,8 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
16826
16999
|
if (!paths.nonRoot) {
|
|
16827
17000
|
throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
|
|
16828
17001
|
}
|
|
16829
|
-
const relativePath = (0,
|
|
16830
|
-
const fileContent = await readFileContent((0,
|
|
17002
|
+
const relativePath = (0, import_node_path120.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
17003
|
+
const fileContent = await readFileContent((0, import_node_path120.join)(baseDir, relativePath));
|
|
16831
17004
|
return new _GeminiCliRule({
|
|
16832
17005
|
baseDir,
|
|
16833
17006
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -16886,7 +17059,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
16886
17059
|
};
|
|
16887
17060
|
|
|
16888
17061
|
// src/features/rules/goose-rule.ts
|
|
16889
|
-
var
|
|
17062
|
+
var import_node_path121 = require("path");
|
|
16890
17063
|
var GooseRule = class _GooseRule extends ToolRule {
|
|
16891
17064
|
static getSettablePaths({
|
|
16892
17065
|
global,
|
|
@@ -16921,7 +17094,7 @@ var GooseRule = class _GooseRule extends ToolRule {
|
|
|
16921
17094
|
if (isRoot) {
|
|
16922
17095
|
const relativePath2 = paths.root.relativeFilePath;
|
|
16923
17096
|
const fileContent2 = await readFileContent(
|
|
16924
|
-
(0,
|
|
17097
|
+
(0, import_node_path121.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
16925
17098
|
);
|
|
16926
17099
|
return new _GooseRule({
|
|
16927
17100
|
baseDir,
|
|
@@ -16935,8 +17108,8 @@ var GooseRule = class _GooseRule extends ToolRule {
|
|
|
16935
17108
|
if (!paths.nonRoot) {
|
|
16936
17109
|
throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
|
|
16937
17110
|
}
|
|
16938
|
-
const relativePath = (0,
|
|
16939
|
-
const fileContent = await readFileContent((0,
|
|
17111
|
+
const relativePath = (0, import_node_path121.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
17112
|
+
const fileContent = await readFileContent((0, import_node_path121.join)(baseDir, relativePath));
|
|
16940
17113
|
return new _GooseRule({
|
|
16941
17114
|
baseDir,
|
|
16942
17115
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -16995,7 +17168,7 @@ var GooseRule = class _GooseRule extends ToolRule {
|
|
|
16995
17168
|
};
|
|
16996
17169
|
|
|
16997
17170
|
// src/features/rules/junie-rule.ts
|
|
16998
|
-
var
|
|
17171
|
+
var import_node_path122 = require("path");
|
|
16999
17172
|
var JunieRule = class _JunieRule extends ToolRule {
|
|
17000
17173
|
static getSettablePaths(_options = {}) {
|
|
17001
17174
|
return {
|
|
@@ -17024,8 +17197,8 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
17024
17197
|
}) {
|
|
17025
17198
|
const isRoot = _JunieRule.isRootRelativeFilePath(relativeFilePath);
|
|
17026
17199
|
const settablePaths = this.getSettablePaths();
|
|
17027
|
-
const relativePath = isRoot ? (0,
|
|
17028
|
-
const fileContent = await readFileContent((0,
|
|
17200
|
+
const relativePath = isRoot ? (0, import_node_path122.join)(settablePaths.root.relativeDirPath, settablePaths.root.relativeFilePath) : (0, import_node_path122.join)(settablePaths.nonRoot.relativeDirPath, relativeFilePath);
|
|
17201
|
+
const fileContent = await readFileContent((0, import_node_path122.join)(baseDir, relativePath));
|
|
17029
17202
|
return new _JunieRule({
|
|
17030
17203
|
baseDir,
|
|
17031
17204
|
relativeDirPath: isRoot ? settablePaths.root.relativeDirPath : settablePaths.nonRoot.relativeDirPath,
|
|
@@ -17080,7 +17253,7 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
17080
17253
|
};
|
|
17081
17254
|
|
|
17082
17255
|
// src/features/rules/kilo-rule.ts
|
|
17083
|
-
var
|
|
17256
|
+
var import_node_path123 = require("path");
|
|
17084
17257
|
var KiloRule = class _KiloRule extends ToolRule {
|
|
17085
17258
|
static getSettablePaths({
|
|
17086
17259
|
global,
|
|
@@ -17115,7 +17288,7 @@ var KiloRule = class _KiloRule extends ToolRule {
|
|
|
17115
17288
|
if (isRoot) {
|
|
17116
17289
|
const relativePath2 = paths.root.relativeFilePath;
|
|
17117
17290
|
const fileContent2 = await readFileContent(
|
|
17118
|
-
(0,
|
|
17291
|
+
(0, import_node_path123.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
17119
17292
|
);
|
|
17120
17293
|
return new _KiloRule({
|
|
17121
17294
|
baseDir,
|
|
@@ -17129,8 +17302,8 @@ var KiloRule = class _KiloRule extends ToolRule {
|
|
|
17129
17302
|
if (!paths.nonRoot) {
|
|
17130
17303
|
throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
|
|
17131
17304
|
}
|
|
17132
|
-
const relativePath = (0,
|
|
17133
|
-
const fileContent = await readFileContent((0,
|
|
17305
|
+
const relativePath = (0, import_node_path123.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
17306
|
+
const fileContent = await readFileContent((0, import_node_path123.join)(baseDir, relativePath));
|
|
17134
17307
|
return new _KiloRule({
|
|
17135
17308
|
baseDir,
|
|
17136
17309
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -17189,7 +17362,7 @@ var KiloRule = class _KiloRule extends ToolRule {
|
|
|
17189
17362
|
};
|
|
17190
17363
|
|
|
17191
17364
|
// src/features/rules/kiro-rule.ts
|
|
17192
|
-
var
|
|
17365
|
+
var import_node_path124 = require("path");
|
|
17193
17366
|
var KiroRule = class _KiroRule extends ToolRule {
|
|
17194
17367
|
static getSettablePaths(_options = {}) {
|
|
17195
17368
|
return {
|
|
@@ -17204,7 +17377,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
17204
17377
|
validate = true
|
|
17205
17378
|
}) {
|
|
17206
17379
|
const fileContent = await readFileContent(
|
|
17207
|
-
(0,
|
|
17380
|
+
(0, import_node_path124.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
17208
17381
|
);
|
|
17209
17382
|
return new _KiroRule({
|
|
17210
17383
|
baseDir,
|
|
@@ -17258,7 +17431,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
17258
17431
|
};
|
|
17259
17432
|
|
|
17260
17433
|
// src/features/rules/opencode-rule.ts
|
|
17261
|
-
var
|
|
17434
|
+
var import_node_path125 = require("path");
|
|
17262
17435
|
var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
17263
17436
|
static getSettablePaths({
|
|
17264
17437
|
global,
|
|
@@ -17293,7 +17466,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
17293
17466
|
if (isRoot) {
|
|
17294
17467
|
const relativePath2 = paths.root.relativeFilePath;
|
|
17295
17468
|
const fileContent2 = await readFileContent(
|
|
17296
|
-
(0,
|
|
17469
|
+
(0, import_node_path125.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
17297
17470
|
);
|
|
17298
17471
|
return new _OpenCodeRule({
|
|
17299
17472
|
baseDir,
|
|
@@ -17307,8 +17480,8 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
17307
17480
|
if (!paths.nonRoot) {
|
|
17308
17481
|
throw new Error(`nonRoot path is not set for ${relativeFilePath}`);
|
|
17309
17482
|
}
|
|
17310
|
-
const relativePath = (0,
|
|
17311
|
-
const fileContent = await readFileContent((0,
|
|
17483
|
+
const relativePath = (0, import_node_path125.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
17484
|
+
const fileContent = await readFileContent((0, import_node_path125.join)(baseDir, relativePath));
|
|
17312
17485
|
return new _OpenCodeRule({
|
|
17313
17486
|
baseDir,
|
|
17314
17487
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -17367,7 +17540,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
17367
17540
|
};
|
|
17368
17541
|
|
|
17369
17542
|
// src/features/rules/qwencode-rule.ts
|
|
17370
|
-
var
|
|
17543
|
+
var import_node_path126 = require("path");
|
|
17371
17544
|
var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
17372
17545
|
static getSettablePaths(_options = {}) {
|
|
17373
17546
|
return {
|
|
@@ -17386,8 +17559,8 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
17386
17559
|
validate = true
|
|
17387
17560
|
}) {
|
|
17388
17561
|
const isRoot = relativeFilePath === "QWEN.md";
|
|
17389
|
-
const relativePath = isRoot ? "QWEN.md" : (0,
|
|
17390
|
-
const fileContent = await readFileContent((0,
|
|
17562
|
+
const relativePath = isRoot ? "QWEN.md" : (0, import_node_path126.join)(".qwen", "memories", relativeFilePath);
|
|
17563
|
+
const fileContent = await readFileContent((0, import_node_path126.join)(baseDir, relativePath));
|
|
17391
17564
|
return new _QwencodeRule({
|
|
17392
17565
|
baseDir,
|
|
17393
17566
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -17439,7 +17612,7 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
17439
17612
|
};
|
|
17440
17613
|
|
|
17441
17614
|
// src/features/rules/replit-rule.ts
|
|
17442
|
-
var
|
|
17615
|
+
var import_node_path127 = require("path");
|
|
17443
17616
|
var ReplitRule = class _ReplitRule extends ToolRule {
|
|
17444
17617
|
static getSettablePaths(_options = {}) {
|
|
17445
17618
|
return {
|
|
@@ -17461,7 +17634,7 @@ var ReplitRule = class _ReplitRule extends ToolRule {
|
|
|
17461
17634
|
}
|
|
17462
17635
|
const relativePath = paths.root.relativeFilePath;
|
|
17463
17636
|
const fileContent = await readFileContent(
|
|
17464
|
-
(0,
|
|
17637
|
+
(0, import_node_path127.join)(baseDir, paths.root.relativeDirPath, relativePath)
|
|
17465
17638
|
);
|
|
17466
17639
|
return new _ReplitRule({
|
|
17467
17640
|
baseDir,
|
|
@@ -17527,7 +17700,7 @@ var ReplitRule = class _ReplitRule extends ToolRule {
|
|
|
17527
17700
|
};
|
|
17528
17701
|
|
|
17529
17702
|
// src/features/rules/roo-rule.ts
|
|
17530
|
-
var
|
|
17703
|
+
var import_node_path128 = require("path");
|
|
17531
17704
|
var RooRule = class _RooRule extends ToolRule {
|
|
17532
17705
|
static getSettablePaths(_options = {}) {
|
|
17533
17706
|
return {
|
|
@@ -17542,7 +17715,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
17542
17715
|
validate = true
|
|
17543
17716
|
}) {
|
|
17544
17717
|
const fileContent = await readFileContent(
|
|
17545
|
-
(0,
|
|
17718
|
+
(0, import_node_path128.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
17546
17719
|
);
|
|
17547
17720
|
return new _RooRule({
|
|
17548
17721
|
baseDir,
|
|
@@ -17611,7 +17784,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
17611
17784
|
};
|
|
17612
17785
|
|
|
17613
17786
|
// src/features/rules/rovodev-rule.ts
|
|
17614
|
-
var
|
|
17787
|
+
var import_node_path129 = require("path");
|
|
17615
17788
|
var DISALLOWED_ROVODEV_MODULAR_RULE_BASENAMES = /* @__PURE__ */ new Set(["agents.md", "agents.local.md"]);
|
|
17616
17789
|
var RovodevRule = class _RovodevRule extends ToolRule {
|
|
17617
17790
|
/**
|
|
@@ -17655,7 +17828,7 @@ var RovodevRule = class _RovodevRule extends ToolRule {
|
|
|
17655
17828
|
root: rovodevAgents,
|
|
17656
17829
|
alternativeRoots: [{ relativeDirPath: ".", relativeFilePath: "AGENTS.md" }],
|
|
17657
17830
|
nonRoot: {
|
|
17658
|
-
relativeDirPath: (0,
|
|
17831
|
+
relativeDirPath: (0, import_node_path129.join)(".rovodev", ".rulesync", "modular-rules")
|
|
17659
17832
|
}
|
|
17660
17833
|
};
|
|
17661
17834
|
}
|
|
@@ -17694,10 +17867,10 @@ var RovodevRule = class _RovodevRule extends ToolRule {
|
|
|
17694
17867
|
}) {
|
|
17695
17868
|
if (!this.isAllowedModularRulesRelativePath(relativeFilePath)) {
|
|
17696
17869
|
throw new Error(
|
|
17697
|
-
`Reserved Rovodev memory basename under modular-rules (not a modular rule): ${(0,
|
|
17870
|
+
`Reserved Rovodev memory basename under modular-rules (not a modular rule): ${(0, import_node_path129.join)(relativeDirPath, relativeFilePath)}`
|
|
17698
17871
|
);
|
|
17699
17872
|
}
|
|
17700
|
-
const fileContent = await readFileContent((0,
|
|
17873
|
+
const fileContent = await readFileContent((0, import_node_path129.join)(baseDir, relativeDirPath, relativeFilePath));
|
|
17701
17874
|
return new _RovodevRule({
|
|
17702
17875
|
baseDir,
|
|
17703
17876
|
relativeDirPath,
|
|
@@ -17717,10 +17890,10 @@ var RovodevRule = class _RovodevRule extends ToolRule {
|
|
|
17717
17890
|
paths
|
|
17718
17891
|
}) {
|
|
17719
17892
|
const relativeDirPath = overrideDirPath ?? paths.root.relativeDirPath;
|
|
17720
|
-
const agentsMdExpectedLocationsDescription = "alternativeRoots" in paths && paths.alternativeRoots && paths.alternativeRoots.length > 0 ? `${(0,
|
|
17893
|
+
const agentsMdExpectedLocationsDescription = "alternativeRoots" in paths && paths.alternativeRoots && paths.alternativeRoots.length > 0 ? `${(0, import_node_path129.join)(paths.root.relativeDirPath, paths.root.relativeFilePath)} or project root` : (0, import_node_path129.join)(paths.root.relativeDirPath, paths.root.relativeFilePath);
|
|
17721
17894
|
if (relativeFilePath !== "AGENTS.md") {
|
|
17722
17895
|
throw new Error(
|
|
17723
|
-
`Rovodev rules support only AGENTS.md at ${agentsMdExpectedLocationsDescription}, got: ${(0,
|
|
17896
|
+
`Rovodev rules support only AGENTS.md at ${agentsMdExpectedLocationsDescription}, got: ${(0, import_node_path129.join)(relativeDirPath, relativeFilePath)}`
|
|
17724
17897
|
);
|
|
17725
17898
|
}
|
|
17726
17899
|
const allowed = relativeDirPath === paths.root.relativeDirPath || "alternativeRoots" in paths && paths.alternativeRoots?.some(
|
|
@@ -17728,10 +17901,10 @@ var RovodevRule = class _RovodevRule extends ToolRule {
|
|
|
17728
17901
|
);
|
|
17729
17902
|
if (!allowed) {
|
|
17730
17903
|
throw new Error(
|
|
17731
|
-
`Rovodev AGENTS.md must be at ${agentsMdExpectedLocationsDescription}, got: ${(0,
|
|
17904
|
+
`Rovodev AGENTS.md must be at ${agentsMdExpectedLocationsDescription}, got: ${(0, import_node_path129.join)(relativeDirPath, relativeFilePath)}`
|
|
17732
17905
|
);
|
|
17733
17906
|
}
|
|
17734
|
-
const fileContent = await readFileContent((0,
|
|
17907
|
+
const fileContent = await readFileContent((0, import_node_path129.join)(baseDir, relativeDirPath, relativeFilePath));
|
|
17735
17908
|
return new _RovodevRule({
|
|
17736
17909
|
baseDir,
|
|
17737
17910
|
relativeDirPath,
|
|
@@ -17845,7 +18018,7 @@ var RovodevRule = class _RovodevRule extends ToolRule {
|
|
|
17845
18018
|
};
|
|
17846
18019
|
|
|
17847
18020
|
// src/features/rules/warp-rule.ts
|
|
17848
|
-
var
|
|
18021
|
+
var import_node_path130 = require("path");
|
|
17849
18022
|
var WarpRule = class _WarpRule extends ToolRule {
|
|
17850
18023
|
constructor({ fileContent, root, ...rest }) {
|
|
17851
18024
|
super({
|
|
@@ -17871,8 +18044,8 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
17871
18044
|
validate = true
|
|
17872
18045
|
}) {
|
|
17873
18046
|
const isRoot = relativeFilePath === this.getSettablePaths().root.relativeFilePath;
|
|
17874
|
-
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath : (0,
|
|
17875
|
-
const fileContent = await readFileContent((0,
|
|
18047
|
+
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath : (0, import_node_path130.join)(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
18048
|
+
const fileContent = await readFileContent((0, import_node_path130.join)(baseDir, relativePath));
|
|
17876
18049
|
return new _WarpRule({
|
|
17877
18050
|
baseDir,
|
|
17878
18051
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : ".warp",
|
|
@@ -17927,7 +18100,7 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
17927
18100
|
};
|
|
17928
18101
|
|
|
17929
18102
|
// src/features/rules/windsurf-rule.ts
|
|
17930
|
-
var
|
|
18103
|
+
var import_node_path131 = require("path");
|
|
17931
18104
|
var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
17932
18105
|
static getSettablePaths(_options = {}) {
|
|
17933
18106
|
return {
|
|
@@ -17942,7 +18115,7 @@ var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
|
17942
18115
|
validate = true
|
|
17943
18116
|
}) {
|
|
17944
18117
|
const fileContent = await readFileContent(
|
|
17945
|
-
(0,
|
|
18118
|
+
(0, import_node_path131.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
17946
18119
|
);
|
|
17947
18120
|
return new _WindsurfRule({
|
|
17948
18121
|
baseDir,
|
|
@@ -18040,11 +18213,11 @@ var rulesProcessorToolTargets = [
|
|
|
18040
18213
|
"warp",
|
|
18041
18214
|
"windsurf"
|
|
18042
18215
|
];
|
|
18043
|
-
var RulesProcessorToolTargetSchema =
|
|
18044
|
-
var formatRulePaths = (rules) => rules.map((r) => (0,
|
|
18045
|
-
var RulesFeatureOptionsSchema =
|
|
18046
|
-
ruleDiscoveryMode:
|
|
18047
|
-
includeLocalRoot:
|
|
18216
|
+
var RulesProcessorToolTargetSchema = import_mini66.z.enum(rulesProcessorToolTargets);
|
|
18217
|
+
var formatRulePaths = (rules) => rules.map((r) => (0, import_node_path132.join)(r.getRelativeDirPath(), r.getRelativeFilePath())).join(", ");
|
|
18218
|
+
var RulesFeatureOptionsSchema = import_mini66.z.looseObject({
|
|
18219
|
+
ruleDiscoveryMode: import_mini66.z.optional(import_mini66.z.enum(["none", "explicit"])),
|
|
18220
|
+
includeLocalRoot: import_mini66.z.optional(import_mini66.z.boolean())
|
|
18048
18221
|
});
|
|
18049
18222
|
var resolveRuleDiscoveryMode = ({
|
|
18050
18223
|
defaultMode,
|
|
@@ -18065,8 +18238,8 @@ var resolveRuleDiscoveryMode = ({
|
|
|
18065
18238
|
}
|
|
18066
18239
|
return parsed.data.ruleDiscoveryMode === "none" ? "auto" : "toon";
|
|
18067
18240
|
};
|
|
18068
|
-
var IncludeLocalRootSchema =
|
|
18069
|
-
includeLocalRoot:
|
|
18241
|
+
var IncludeLocalRootSchema = import_mini66.z.looseObject({
|
|
18242
|
+
includeLocalRoot: import_mini66.z.optional(import_mini66.z.boolean())
|
|
18070
18243
|
});
|
|
18071
18244
|
var resolveIncludeLocalRoot = (options) => {
|
|
18072
18245
|
if (!options) return true;
|
|
@@ -18372,6 +18545,8 @@ var toolRuleFactories = /* @__PURE__ */ new Map([
|
|
|
18372
18545
|
extension: "md",
|
|
18373
18546
|
supportsGlobal: false,
|
|
18374
18547
|
ruleDiscoveryMode: "auto"
|
|
18548
|
+
// No additionalConventions.skills needed: Windsurf Cascade auto-discovers
|
|
18549
|
+
// skills from .windsurf/skills/ and ~/.codeium/windsurf/skills/ directories.
|
|
18375
18550
|
}
|
|
18376
18551
|
}
|
|
18377
18552
|
]
|
|
@@ -18509,7 +18684,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18509
18684
|
}).relativeDirPath;
|
|
18510
18685
|
return this.skills.filter((skill) => skillClass.isTargetedByRulesyncSkill(skill)).map((skill) => {
|
|
18511
18686
|
const frontmatter = skill.getFrontmatter();
|
|
18512
|
-
const relativePath = (0,
|
|
18687
|
+
const relativePath = (0, import_node_path132.join)(toolRelativeDirPath, skill.getDirName(), SKILL_FILE_NAME);
|
|
18513
18688
|
return {
|
|
18514
18689
|
name: frontmatter.name,
|
|
18515
18690
|
description: frontmatter.description,
|
|
@@ -18638,12 +18813,12 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18638
18813
|
* Load and parse rulesync rule files from .rulesync/rules/ directory
|
|
18639
18814
|
*/
|
|
18640
18815
|
async loadRulesyncFiles() {
|
|
18641
|
-
const rulesyncBaseDir = (0,
|
|
18642
|
-
const files = await findFilesByGlobs((0,
|
|
18816
|
+
const rulesyncBaseDir = (0, import_node_path132.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
18817
|
+
const files = await findFilesByGlobs((0, import_node_path132.join)(rulesyncBaseDir, "**", "*.md"));
|
|
18643
18818
|
this.logger.debug(`Found ${files.length} rulesync files`);
|
|
18644
18819
|
const rulesyncRules = await Promise.all(
|
|
18645
18820
|
files.map((file) => {
|
|
18646
|
-
const relativeFilePath = (0,
|
|
18821
|
+
const relativeFilePath = (0, import_node_path132.relative)(rulesyncBaseDir, file);
|
|
18647
18822
|
checkPathTraversal({
|
|
18648
18823
|
relativePath: relativeFilePath,
|
|
18649
18824
|
intendedRootDir: rulesyncBaseDir
|
|
@@ -18718,7 +18893,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18718
18893
|
global: this.global
|
|
18719
18894
|
});
|
|
18720
18895
|
const resolveRelativeDirPath = (filePath) => {
|
|
18721
|
-
const dirName = (0,
|
|
18896
|
+
const dirName = (0, import_node_path132.dirname)((0, import_node_path132.relative)(this.baseDir, filePath));
|
|
18722
18897
|
return dirName === "" ? "." : dirName;
|
|
18723
18898
|
};
|
|
18724
18899
|
const buildDeletionRulesFromPaths = (filePaths, opts) => {
|
|
@@ -18726,7 +18901,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18726
18901
|
const effectiveBaseDir = isNonRoot ? opts.baseDirOverride : this.baseDir;
|
|
18727
18902
|
return filePaths.map((filePath) => {
|
|
18728
18903
|
const relativeDirPath = isNonRoot ? opts.relativeDirPathOverride : resolveRelativeDirPath(filePath);
|
|
18729
|
-
const relativeFilePath = isNonRoot ? (0,
|
|
18904
|
+
const relativeFilePath = isNonRoot ? (0, import_node_path132.relative)(effectiveBaseDir, filePath) : (0, import_node_path132.basename)(filePath);
|
|
18730
18905
|
checkPathTraversal({
|
|
18731
18906
|
relativePath: isNonRoot ? relativeFilePath : relativeDirPath,
|
|
18732
18907
|
intendedRootDir: effectiveBaseDir
|
|
@@ -18754,13 +18929,13 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18754
18929
|
return [];
|
|
18755
18930
|
}
|
|
18756
18931
|
const uniqueRootFilePaths = await findFilesWithFallback(
|
|
18757
|
-
(0,
|
|
18932
|
+
(0, import_node_path132.join)(
|
|
18758
18933
|
this.baseDir,
|
|
18759
18934
|
settablePaths.root.relativeDirPath ?? ".",
|
|
18760
18935
|
settablePaths.root.relativeFilePath
|
|
18761
18936
|
),
|
|
18762
18937
|
settablePaths.alternativeRoots,
|
|
18763
|
-
(alt) => (0,
|
|
18938
|
+
(alt) => (0, import_node_path132.join)(this.baseDir, alt.relativeDirPath, alt.relativeFilePath)
|
|
18764
18939
|
);
|
|
18765
18940
|
if (forDeletion) {
|
|
18766
18941
|
return buildDeletionRulesFromPaths(uniqueRootFilePaths);
|
|
@@ -18774,7 +18949,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18774
18949
|
});
|
|
18775
18950
|
return factory.class.fromFile({
|
|
18776
18951
|
baseDir: this.baseDir,
|
|
18777
|
-
relativeFilePath: (0,
|
|
18952
|
+
relativeFilePath: (0, import_node_path132.basename)(filePath),
|
|
18778
18953
|
relativeDirPath,
|
|
18779
18954
|
global: this.global
|
|
18780
18955
|
});
|
|
@@ -18791,7 +18966,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18791
18966
|
return [];
|
|
18792
18967
|
}
|
|
18793
18968
|
const uniqueLocalRootFilePaths2 = await findFilesByGlobs(
|
|
18794
|
-
(0,
|
|
18969
|
+
(0, import_node_path132.join)(this.baseDir, "AGENTS.local.md")
|
|
18795
18970
|
);
|
|
18796
18971
|
return buildDeletionRulesFromPaths(uniqueLocalRootFilePaths2);
|
|
18797
18972
|
}
|
|
@@ -18802,9 +18977,9 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18802
18977
|
return [];
|
|
18803
18978
|
}
|
|
18804
18979
|
const uniqueLocalRootFilePaths = await findFilesWithFallback(
|
|
18805
|
-
(0,
|
|
18980
|
+
(0, import_node_path132.join)(this.baseDir, settablePaths.root.relativeDirPath ?? ".", "CLAUDE.local.md"),
|
|
18806
18981
|
settablePaths.alternativeRoots,
|
|
18807
|
-
(alt) => (0,
|
|
18982
|
+
(alt) => (0, import_node_path132.join)(this.baseDir, alt.relativeDirPath, "CLAUDE.local.md")
|
|
18808
18983
|
);
|
|
18809
18984
|
return buildDeletionRulesFromPaths(uniqueLocalRootFilePaths);
|
|
18810
18985
|
})();
|
|
@@ -18815,20 +18990,20 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18815
18990
|
if (!forDeletion || this.toolTarget !== "rovodev" || this.global) {
|
|
18816
18991
|
return [];
|
|
18817
18992
|
}
|
|
18818
|
-
const primaryPaths = await findFilesByGlobs((0,
|
|
18993
|
+
const primaryPaths = await findFilesByGlobs((0, import_node_path132.join)(this.baseDir, ".rovodev", "AGENTS.md"));
|
|
18819
18994
|
if (primaryPaths.length === 0) {
|
|
18820
18995
|
return [];
|
|
18821
18996
|
}
|
|
18822
|
-
const mirrorPaths = await findFilesByGlobs((0,
|
|
18997
|
+
const mirrorPaths = await findFilesByGlobs((0, import_node_path132.join)(this.baseDir, "AGENTS.md"));
|
|
18823
18998
|
return buildDeletionRulesFromPaths(mirrorPaths);
|
|
18824
18999
|
})();
|
|
18825
19000
|
const nonRootToolRules = await (async () => {
|
|
18826
19001
|
if (!settablePaths.nonRoot) {
|
|
18827
19002
|
return [];
|
|
18828
19003
|
}
|
|
18829
|
-
const nonRootBaseDir = (0,
|
|
19004
|
+
const nonRootBaseDir = (0, import_node_path132.join)(this.baseDir, settablePaths.nonRoot.relativeDirPath);
|
|
18830
19005
|
const nonRootFilePaths = await findFilesByGlobs(
|
|
18831
|
-
(0,
|
|
19006
|
+
(0, import_node_path132.join)(nonRootBaseDir, "**", `*.${factory.meta.extension}`)
|
|
18832
19007
|
);
|
|
18833
19008
|
if (forDeletion) {
|
|
18834
19009
|
return buildDeletionRulesFromPaths(nonRootFilePaths, {
|
|
@@ -18838,18 +19013,18 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18838
19013
|
}
|
|
18839
19014
|
const modularRootRelative = settablePaths.nonRoot.relativeDirPath;
|
|
18840
19015
|
const nonRootPathsForImport = this.toolTarget === "rovodev" ? nonRootFilePaths.filter((filePath) => {
|
|
18841
|
-
const relativeFilePath = (0,
|
|
19016
|
+
const relativeFilePath = (0, import_node_path132.relative)(nonRootBaseDir, filePath);
|
|
18842
19017
|
const ok = RovodevRule.isAllowedModularRulesRelativePath(relativeFilePath);
|
|
18843
19018
|
if (!ok) {
|
|
18844
19019
|
this.logger.warn(
|
|
18845
|
-
`Skipping reserved Rovodev path under modular-rules (import): ${(0,
|
|
19020
|
+
`Skipping reserved Rovodev path under modular-rules (import): ${(0, import_node_path132.join)(modularRootRelative, relativeFilePath)}`
|
|
18846
19021
|
);
|
|
18847
19022
|
}
|
|
18848
19023
|
return ok;
|
|
18849
19024
|
}) : nonRootFilePaths;
|
|
18850
19025
|
return await Promise.all(
|
|
18851
19026
|
nonRootPathsForImport.map((filePath) => {
|
|
18852
|
-
const relativeFilePath = (0,
|
|
19027
|
+
const relativeFilePath = (0, import_node_path132.relative)(nonRootBaseDir, filePath);
|
|
18853
19028
|
checkPathTraversal({
|
|
18854
19029
|
relativePath: relativeFilePath,
|
|
18855
19030
|
intendedRootDir: nonRootBaseDir
|
|
@@ -18968,14 +19143,14 @@ s/<command> [arguments]
|
|
|
18968
19143
|
This syntax employs a double slash (\`s/\`) to prevent conflicts with built-in slash commands.
|
|
18969
19144
|
The \`s\` in \`s/\` stands for *simulate*. Because custom slash commands are not built-in, this syntax provides a pseudo way to invoke them.
|
|
18970
19145
|
|
|
18971
|
-
When users call a custom slash command, you have to look for the markdown file, \`${(0,
|
|
19146
|
+
When users call a custom slash command, you have to look for the markdown file, \`${(0, import_node_path132.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "{command}.md")}\`, then execute the contents of that file as the block of operations.` : "";
|
|
18972
19147
|
const subagentsSection = subagents ? `## Simulated Subagents
|
|
18973
19148
|
|
|
18974
19149
|
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.
|
|
18975
19150
|
|
|
18976
|
-
When users call a simulated subagent, it will look for the corresponding markdown file, \`${(0,
|
|
19151
|
+
When users call a simulated subagent, it will look for the corresponding markdown file, \`${(0, import_node_path132.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "{subagent}.md")}\`, and execute its contents as the block of operations.
|
|
18977
19152
|
|
|
18978
|
-
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${(0,
|
|
19153
|
+
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${(0, import_node_path132.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "planner.md")}\`, and execute its contents as the block of operations.` : "";
|
|
18979
19154
|
const skillsSection = skills ? this.generateSkillsSection(skills) : "";
|
|
18980
19155
|
const result = [
|
|
18981
19156
|
overview,
|
|
@@ -19007,51 +19182,51 @@ var import_request_error = require("@octokit/request-error");
|
|
|
19007
19182
|
var import_rest = require("@octokit/rest");
|
|
19008
19183
|
|
|
19009
19184
|
// src/types/fetch.ts
|
|
19010
|
-
var
|
|
19185
|
+
var import_mini68 = require("zod/mini");
|
|
19011
19186
|
|
|
19012
19187
|
// src/types/fetch-targets.ts
|
|
19013
|
-
var
|
|
19188
|
+
var import_mini67 = require("zod/mini");
|
|
19014
19189
|
var ALL_FETCH_TARGETS = ["rulesync", ...ALL_TOOL_TARGETS];
|
|
19015
|
-
var FetchTargetSchema =
|
|
19190
|
+
var FetchTargetSchema = import_mini67.z.enum(ALL_FETCH_TARGETS);
|
|
19016
19191
|
|
|
19017
19192
|
// src/types/fetch.ts
|
|
19018
|
-
var ConflictStrategySchema =
|
|
19019
|
-
var GitHubFileTypeSchema =
|
|
19020
|
-
var GitHubFileEntrySchema =
|
|
19021
|
-
name:
|
|
19022
|
-
path:
|
|
19023
|
-
sha:
|
|
19024
|
-
size:
|
|
19193
|
+
var ConflictStrategySchema = import_mini68.z.enum(["skip", "overwrite"]);
|
|
19194
|
+
var GitHubFileTypeSchema = import_mini68.z.enum(["file", "dir", "symlink", "submodule"]);
|
|
19195
|
+
var GitHubFileEntrySchema = import_mini68.z.looseObject({
|
|
19196
|
+
name: import_mini68.z.string(),
|
|
19197
|
+
path: import_mini68.z.string(),
|
|
19198
|
+
sha: import_mini68.z.string(),
|
|
19199
|
+
size: import_mini68.z.number(),
|
|
19025
19200
|
type: GitHubFileTypeSchema,
|
|
19026
|
-
download_url:
|
|
19201
|
+
download_url: import_mini68.z.nullable(import_mini68.z.string())
|
|
19027
19202
|
});
|
|
19028
|
-
var FetchOptionsSchema =
|
|
19029
|
-
target:
|
|
19030
|
-
features:
|
|
19031
|
-
ref:
|
|
19032
|
-
path:
|
|
19033
|
-
output:
|
|
19034
|
-
conflict:
|
|
19035
|
-
token:
|
|
19036
|
-
verbose:
|
|
19037
|
-
silent:
|
|
19203
|
+
var FetchOptionsSchema = import_mini68.z.looseObject({
|
|
19204
|
+
target: import_mini68.z.optional(FetchTargetSchema),
|
|
19205
|
+
features: import_mini68.z.optional(import_mini68.z.array(import_mini68.z.enum(ALL_FEATURES_WITH_WILDCARD))),
|
|
19206
|
+
ref: import_mini68.z.optional(import_mini68.z.string()),
|
|
19207
|
+
path: import_mini68.z.optional(import_mini68.z.string()),
|
|
19208
|
+
output: import_mini68.z.optional(import_mini68.z.string()),
|
|
19209
|
+
conflict: import_mini68.z.optional(ConflictStrategySchema),
|
|
19210
|
+
token: import_mini68.z.optional(import_mini68.z.string()),
|
|
19211
|
+
verbose: import_mini68.z.optional(import_mini68.z.boolean()),
|
|
19212
|
+
silent: import_mini68.z.optional(import_mini68.z.boolean())
|
|
19038
19213
|
});
|
|
19039
|
-
var FetchFileStatusSchema =
|
|
19040
|
-
var GitHubRepoInfoSchema =
|
|
19041
|
-
default_branch:
|
|
19042
|
-
private:
|
|
19214
|
+
var FetchFileStatusSchema = import_mini68.z.enum(["created", "overwritten", "skipped"]);
|
|
19215
|
+
var GitHubRepoInfoSchema = import_mini68.z.looseObject({
|
|
19216
|
+
default_branch: import_mini68.z.string(),
|
|
19217
|
+
private: import_mini68.z.boolean()
|
|
19043
19218
|
});
|
|
19044
|
-
var GitHubReleaseAssetSchema =
|
|
19045
|
-
name:
|
|
19046
|
-
browser_download_url:
|
|
19047
|
-
size:
|
|
19219
|
+
var GitHubReleaseAssetSchema = import_mini68.z.looseObject({
|
|
19220
|
+
name: import_mini68.z.string(),
|
|
19221
|
+
browser_download_url: import_mini68.z.string(),
|
|
19222
|
+
size: import_mini68.z.number()
|
|
19048
19223
|
});
|
|
19049
|
-
var GitHubReleaseSchema =
|
|
19050
|
-
tag_name:
|
|
19051
|
-
name:
|
|
19052
|
-
prerelease:
|
|
19053
|
-
draft:
|
|
19054
|
-
assets:
|
|
19224
|
+
var GitHubReleaseSchema = import_mini68.z.looseObject({
|
|
19225
|
+
tag_name: import_mini68.z.string(),
|
|
19226
|
+
name: import_mini68.z.nullable(import_mini68.z.string()),
|
|
19227
|
+
prerelease: import_mini68.z.boolean(),
|
|
19228
|
+
draft: import_mini68.z.boolean(),
|
|
19229
|
+
assets: import_mini68.z.array(GitHubReleaseAssetSchema)
|
|
19055
19230
|
});
|
|
19056
19231
|
|
|
19057
19232
|
// src/lib/github-client.ts
|
|
@@ -19352,9 +19527,9 @@ async function listDirectoryRecursive(params) {
|
|
|
19352
19527
|
}
|
|
19353
19528
|
|
|
19354
19529
|
// src/types/git-provider.ts
|
|
19355
|
-
var
|
|
19530
|
+
var import_mini69 = require("zod/mini");
|
|
19356
19531
|
var ALL_GIT_PROVIDERS = ["github", "gitlab"];
|
|
19357
|
-
var GitProviderSchema =
|
|
19532
|
+
var GitProviderSchema = import_mini69.z.enum(ALL_GIT_PROVIDERS);
|
|
19358
19533
|
|
|
19359
19534
|
// src/lib/source-parser.ts
|
|
19360
19535
|
var GITHUB_HOSTS = /* @__PURE__ */ new Set(["github.com", "www.github.com"]);
|
|
@@ -19480,8 +19655,8 @@ async function processFeatureConversion(params) {
|
|
|
19480
19655
|
}
|
|
19481
19656
|
const rulesyncFiles = await processor.convertToolFilesToRulesyncFiles(toolFiles);
|
|
19482
19657
|
for (const file of rulesyncFiles) {
|
|
19483
|
-
const relativePath = (0,
|
|
19484
|
-
const outputPath = (0,
|
|
19658
|
+
const relativePath = (0, import_node_path133.join)(file.getRelativeDirPath(), file.getRelativeFilePath());
|
|
19659
|
+
const outputPath = (0, import_node_path133.join)(outputDir, relativePath);
|
|
19485
19660
|
await writeFileContent(outputPath, file.getFileContent());
|
|
19486
19661
|
paths.push(relativePath);
|
|
19487
19662
|
}
|
|
@@ -19629,7 +19804,7 @@ async function fetchFiles(params) {
|
|
|
19629
19804
|
skipped: 0
|
|
19630
19805
|
};
|
|
19631
19806
|
}
|
|
19632
|
-
const outputBasePath = (0,
|
|
19807
|
+
const outputBasePath = (0, import_node_path133.join)(baseDir, outputDir);
|
|
19633
19808
|
for (const { relativePath, size } of filesToFetch) {
|
|
19634
19809
|
checkPathTraversal({
|
|
19635
19810
|
relativePath,
|
|
@@ -19639,7 +19814,7 @@ async function fetchFiles(params) {
|
|
|
19639
19814
|
}
|
|
19640
19815
|
const results = await Promise.all(
|
|
19641
19816
|
filesToFetch.map(async ({ remotePath, relativePath }) => {
|
|
19642
|
-
const localPath = (0,
|
|
19817
|
+
const localPath = (0, import_node_path133.join)(outputBasePath, relativePath);
|
|
19643
19818
|
const exists = await fileExists(localPath);
|
|
19644
19819
|
if (exists && conflictStrategy === "skip") {
|
|
19645
19820
|
logger5.debug(`Skipping existing file: ${relativePath}`);
|
|
@@ -19681,7 +19856,7 @@ async function collectFeatureFiles(params) {
|
|
|
19681
19856
|
);
|
|
19682
19857
|
const results = await Promise.all(
|
|
19683
19858
|
tasks.map(async ({ featurePath }) => {
|
|
19684
|
-
const fullPath = basePath === "." || basePath === "" ? featurePath :
|
|
19859
|
+
const fullPath = basePath === "." || basePath === "" ? featurePath : import_node_path133.posix.join(basePath, featurePath);
|
|
19685
19860
|
const collected = [];
|
|
19686
19861
|
try {
|
|
19687
19862
|
if (featurePath.includes(".")) {
|
|
@@ -19783,7 +19958,7 @@ async function fetchAndConvertToolFiles(params) {
|
|
|
19783
19958
|
relativePath: toolRelativePath,
|
|
19784
19959
|
intendedRootDir: tempDir
|
|
19785
19960
|
});
|
|
19786
|
-
const localPath = (0,
|
|
19961
|
+
const localPath = (0, import_node_path133.join)(tempDir, toolRelativePath);
|
|
19787
19962
|
const content = await withSemaphore(
|
|
19788
19963
|
semaphore,
|
|
19789
19964
|
() => client.getFileContent(parsed.owner, parsed.repo, remotePath, ref)
|
|
@@ -19792,7 +19967,7 @@ async function fetchAndConvertToolFiles(params) {
|
|
|
19792
19967
|
logger5.debug(`Fetched to temp: ${toolRelativePath}`);
|
|
19793
19968
|
})
|
|
19794
19969
|
);
|
|
19795
|
-
const outputBasePath = (0,
|
|
19970
|
+
const outputBasePath = (0, import_node_path133.join)(baseDir, outputDir);
|
|
19796
19971
|
const { converted, convertedPaths } = await convertFetchedFilesToRulesync({
|
|
19797
19972
|
tempDir,
|
|
19798
19973
|
outputDir: outputBasePath,
|
|
@@ -19866,7 +20041,7 @@ function mapToToolPath(relativePath, toolPaths) {
|
|
|
19866
20041
|
if (relativePath.startsWith("rules/")) {
|
|
19867
20042
|
const restPath = relativePath.substring("rules/".length);
|
|
19868
20043
|
if (toolPaths.rules?.nonRoot) {
|
|
19869
|
-
return (0,
|
|
20044
|
+
return (0, import_node_path133.join)(toolPaths.rules.nonRoot, restPath);
|
|
19870
20045
|
}
|
|
19871
20046
|
}
|
|
19872
20047
|
if (toolPaths.rules?.root && relativePath === toolPaths.rules.root) {
|
|
@@ -19875,19 +20050,19 @@ function mapToToolPath(relativePath, toolPaths) {
|
|
|
19875
20050
|
if (relativePath.startsWith("commands/")) {
|
|
19876
20051
|
const restPath = relativePath.substring("commands/".length);
|
|
19877
20052
|
if (toolPaths.commands) {
|
|
19878
|
-
return (0,
|
|
20053
|
+
return (0, import_node_path133.join)(toolPaths.commands, restPath);
|
|
19879
20054
|
}
|
|
19880
20055
|
}
|
|
19881
20056
|
if (relativePath.startsWith("subagents/")) {
|
|
19882
20057
|
const restPath = relativePath.substring("subagents/".length);
|
|
19883
20058
|
if (toolPaths.subagents) {
|
|
19884
|
-
return (0,
|
|
20059
|
+
return (0, import_node_path133.join)(toolPaths.subagents, restPath);
|
|
19885
20060
|
}
|
|
19886
20061
|
}
|
|
19887
20062
|
if (relativePath.startsWith("skills/")) {
|
|
19888
20063
|
const restPath = relativePath.substring("skills/".length);
|
|
19889
20064
|
if (toolPaths.skills) {
|
|
19890
|
-
return (0,
|
|
20065
|
+
return (0, import_node_path133.join)(toolPaths.skills, restPath);
|
|
19891
20066
|
}
|
|
19892
20067
|
}
|
|
19893
20068
|
return relativePath;
|
|
@@ -19972,12 +20147,12 @@ async function fetchCommand(logger5, options) {
|
|
|
19972
20147
|
}
|
|
19973
20148
|
|
|
19974
20149
|
// src/config/config-resolver.ts
|
|
19975
|
-
var
|
|
20150
|
+
var import_node_path135 = require("path");
|
|
19976
20151
|
var import_jsonc_parser4 = require("jsonc-parser");
|
|
19977
20152
|
|
|
19978
20153
|
// src/config/config.ts
|
|
19979
|
-
var
|
|
19980
|
-
var
|
|
20154
|
+
var import_node_path134 = require("path");
|
|
20155
|
+
var import_mini70 = require("zod/mini");
|
|
19981
20156
|
|
|
19982
20157
|
// src/utils/validation.ts
|
|
19983
20158
|
function findControlCharacter(value) {
|
|
@@ -19994,48 +20169,50 @@ function hasControlCharacters(value) {
|
|
|
19994
20169
|
}
|
|
19995
20170
|
|
|
19996
20171
|
// src/config/config.ts
|
|
19997
|
-
var
|
|
19998
|
-
|
|
19999
|
-
|
|
20000
|
-
|
|
20001
|
-
|
|
20002
|
-
|
|
20003
|
-
|
|
20004
|
-
(0,
|
|
20172
|
+
var GITIGNORE_DESTINATION_KEY = "gitignoreDestination";
|
|
20173
|
+
var SourceEntrySchema = import_mini70.z.object({
|
|
20174
|
+
source: import_mini70.z.string().check((0, import_mini70.minLength)(1, "source must be a non-empty string")),
|
|
20175
|
+
skills: (0, import_mini70.optional)(import_mini70.z.array(import_mini70.z.string())),
|
|
20176
|
+
transport: (0, import_mini70.optional)(import_mini70.z.enum(["github", "git"])),
|
|
20177
|
+
ref: (0, import_mini70.optional)(
|
|
20178
|
+
import_mini70.z.string().check(
|
|
20179
|
+
(0, import_mini70.refine)((v) => !v.startsWith("-"), 'ref must not start with "-"'),
|
|
20180
|
+
(0, import_mini70.refine)((v) => !hasControlCharacters(v), "ref must not contain control characters")
|
|
20005
20181
|
)
|
|
20006
20182
|
),
|
|
20007
|
-
path: (0,
|
|
20008
|
-
|
|
20009
|
-
(0,
|
|
20010
|
-
(0,
|
|
20011
|
-
(0,
|
|
20183
|
+
path: (0, import_mini70.optional)(
|
|
20184
|
+
import_mini70.z.string().check(
|
|
20185
|
+
(0, import_mini70.refine)((v) => !v.includes(".."), 'path must not contain ".."'),
|
|
20186
|
+
(0, import_mini70.refine)((v) => !(0, import_node_path134.isAbsolute)(v), "path must not be absolute"),
|
|
20187
|
+
(0, import_mini70.refine)((v) => !hasControlCharacters(v), "path must not contain control characters")
|
|
20012
20188
|
)
|
|
20013
20189
|
)
|
|
20014
20190
|
});
|
|
20015
|
-
var ConfigParamsSchema =
|
|
20016
|
-
baseDirs:
|
|
20191
|
+
var ConfigParamsSchema = import_mini70.z.object({
|
|
20192
|
+
baseDirs: import_mini70.z.array(import_mini70.z.string()),
|
|
20017
20193
|
targets: RulesyncConfigTargetsSchema,
|
|
20018
20194
|
features: RulesyncFeaturesSchema,
|
|
20019
|
-
verbose:
|
|
20020
|
-
delete:
|
|
20195
|
+
verbose: import_mini70.z.boolean(),
|
|
20196
|
+
delete: import_mini70.z.boolean(),
|
|
20021
20197
|
// New non-experimental options
|
|
20022
|
-
global: (0,
|
|
20023
|
-
silent: (0,
|
|
20024
|
-
simulateCommands: (0,
|
|
20025
|
-
simulateSubagents: (0,
|
|
20026
|
-
simulateSkills: (0,
|
|
20027
|
-
gitignoreTargetsOnly: (0,
|
|
20028
|
-
|
|
20029
|
-
|
|
20198
|
+
global: (0, import_mini70.optional)(import_mini70.z.boolean()),
|
|
20199
|
+
silent: (0, import_mini70.optional)(import_mini70.z.boolean()),
|
|
20200
|
+
simulateCommands: (0, import_mini70.optional)(import_mini70.z.boolean()),
|
|
20201
|
+
simulateSubagents: (0, import_mini70.optional)(import_mini70.z.boolean()),
|
|
20202
|
+
simulateSkills: (0, import_mini70.optional)(import_mini70.z.boolean()),
|
|
20203
|
+
gitignoreTargetsOnly: (0, import_mini70.optional)(import_mini70.z.boolean()),
|
|
20204
|
+
gitignoreDestination: (0, import_mini70.optional)(GitignoreDestinationSchema),
|
|
20205
|
+
dryRun: (0, import_mini70.optional)(import_mini70.z.boolean()),
|
|
20206
|
+
check: (0, import_mini70.optional)(import_mini70.z.boolean()),
|
|
20030
20207
|
// Declarative skill sources
|
|
20031
|
-
sources: (0,
|
|
20208
|
+
sources: (0, import_mini70.optional)(import_mini70.z.array(SourceEntrySchema))
|
|
20032
20209
|
});
|
|
20033
|
-
var PartialConfigParamsSchema =
|
|
20034
|
-
var ConfigFileSchema =
|
|
20035
|
-
$schema: (0,
|
|
20036
|
-
...
|
|
20210
|
+
var PartialConfigParamsSchema = import_mini70.z.partial(ConfigParamsSchema);
|
|
20211
|
+
var ConfigFileSchema = import_mini70.z.object({
|
|
20212
|
+
$schema: (0, import_mini70.optional)(import_mini70.z.string()),
|
|
20213
|
+
...import_mini70.z.partial(ConfigParamsSchema).shape
|
|
20037
20214
|
});
|
|
20038
|
-
var RequiredConfigParamsSchema =
|
|
20215
|
+
var RequiredConfigParamsSchema = import_mini70.z.required(ConfigParamsSchema);
|
|
20039
20216
|
var CONFLICTING_TARGET_PAIRS = [
|
|
20040
20217
|
["augmentcode", "augmentcode-legacy"],
|
|
20041
20218
|
["claudecode", "claudecode-legacy"]
|
|
@@ -20085,6 +20262,7 @@ var Config = class _Config {
|
|
|
20085
20262
|
simulateSubagents;
|
|
20086
20263
|
simulateSkills;
|
|
20087
20264
|
gitignoreTargetsOnly;
|
|
20265
|
+
gitignoreDestination;
|
|
20088
20266
|
dryRun;
|
|
20089
20267
|
check;
|
|
20090
20268
|
sources;
|
|
@@ -20100,6 +20278,7 @@ var Config = class _Config {
|
|
|
20100
20278
|
simulateSubagents,
|
|
20101
20279
|
simulateSkills,
|
|
20102
20280
|
gitignoreTargetsOnly,
|
|
20281
|
+
gitignoreDestination,
|
|
20103
20282
|
dryRun,
|
|
20104
20283
|
check,
|
|
20105
20284
|
sources
|
|
@@ -20125,6 +20304,7 @@ var Config = class _Config {
|
|
|
20125
20304
|
this.simulateSubagents = simulateSubagents ?? false;
|
|
20126
20305
|
this.simulateSkills = simulateSkills ?? false;
|
|
20127
20306
|
this.gitignoreTargetsOnly = gitignoreTargetsOnly ?? true;
|
|
20307
|
+
this.gitignoreDestination = gitignoreDestination ?? "gitignore";
|
|
20128
20308
|
this.dryRun = dryRun ?? false;
|
|
20129
20309
|
this.check = check ?? false;
|
|
20130
20310
|
this.sources = sources ?? [];
|
|
@@ -20282,6 +20462,36 @@ var Config = class _Config {
|
|
|
20282
20462
|
}
|
|
20283
20463
|
return void 0;
|
|
20284
20464
|
}
|
|
20465
|
+
getGitignoreDestination(target, feature) {
|
|
20466
|
+
const rootLevel = this.gitignoreDestination;
|
|
20467
|
+
if (!isRulesyncConfigTargetsObject(this.targets)) {
|
|
20468
|
+
return rootLevel;
|
|
20469
|
+
}
|
|
20470
|
+
const targetValue = this.targets[target];
|
|
20471
|
+
if (!targetValue || Array.isArray(targetValue)) {
|
|
20472
|
+
return rootLevel;
|
|
20473
|
+
}
|
|
20474
|
+
const perFeature = targetValue;
|
|
20475
|
+
const toolLevel = _Config.parseGitignoreDestination(perFeature[GITIGNORE_DESTINATION_KEY]);
|
|
20476
|
+
if (feature) {
|
|
20477
|
+
const featureValue = perFeature[feature];
|
|
20478
|
+
if (featureValue && typeof featureValue === "object" && !Array.isArray(featureValue)) {
|
|
20479
|
+
const featureLevel = _Config.parseGitignoreDestination(
|
|
20480
|
+
featureValue[GITIGNORE_DESTINATION_KEY]
|
|
20481
|
+
);
|
|
20482
|
+
if (featureLevel) {
|
|
20483
|
+
return featureLevel;
|
|
20484
|
+
}
|
|
20485
|
+
}
|
|
20486
|
+
}
|
|
20487
|
+
return toolLevel ?? rootLevel;
|
|
20488
|
+
}
|
|
20489
|
+
static parseGitignoreDestination(value) {
|
|
20490
|
+
if (value === "gitignore" || value === "gitattributes") {
|
|
20491
|
+
return value;
|
|
20492
|
+
}
|
|
20493
|
+
return void 0;
|
|
20494
|
+
}
|
|
20285
20495
|
/**
|
|
20286
20496
|
* Check if per-target features configuration is being used.
|
|
20287
20497
|
*/
|
|
@@ -20362,6 +20572,7 @@ var getDefaults = () => ({
|
|
|
20362
20572
|
simulateSubagents: false,
|
|
20363
20573
|
simulateSkills: false,
|
|
20364
20574
|
gitignoreTargetsOnly: true,
|
|
20575
|
+
gitignoreDestination: "gitignore",
|
|
20365
20576
|
dryRun: false,
|
|
20366
20577
|
check: false,
|
|
20367
20578
|
sources: []
|
|
@@ -20393,6 +20604,7 @@ var mergeConfigs = (baseConfig, localConfig) => {
|
|
|
20393
20604
|
simulateSubagents: localConfig.simulateSubagents ?? baseConfig.simulateSubagents,
|
|
20394
20605
|
simulateSkills: localConfig.simulateSkills ?? baseConfig.simulateSkills,
|
|
20395
20606
|
gitignoreTargetsOnly: localConfig.gitignoreTargetsOnly ?? baseConfig.gitignoreTargetsOnly,
|
|
20607
|
+
gitignoreDestination: localConfig.gitignoreDestination ?? baseConfig.gitignoreDestination,
|
|
20396
20608
|
dryRun: localConfig.dryRun ?? baseConfig.dryRun,
|
|
20397
20609
|
check: localConfig.check ?? baseConfig.check,
|
|
20398
20610
|
sources: localConfig.sources ?? baseConfig.sources
|
|
@@ -20413,12 +20625,13 @@ var ConfigResolver = class {
|
|
|
20413
20625
|
simulateSkills,
|
|
20414
20626
|
gitignoreTargetsOnly,
|
|
20415
20627
|
dryRun,
|
|
20416
|
-
check
|
|
20628
|
+
check,
|
|
20629
|
+
gitignoreDestination
|
|
20417
20630
|
}) {
|
|
20418
20631
|
const validatedConfigPath = resolvePath(configPath, process.cwd());
|
|
20419
20632
|
const baseConfig = await loadConfigFromFile(validatedConfigPath);
|
|
20420
|
-
const configDir = (0,
|
|
20421
|
-
const localConfigPath = (0,
|
|
20633
|
+
const configDir = (0, import_node_path135.dirname)(validatedConfigPath);
|
|
20634
|
+
const localConfigPath = (0, import_node_path135.join)(configDir, RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH);
|
|
20422
20635
|
const localConfig = await loadConfigFromFile(localConfigPath);
|
|
20423
20636
|
const configByFile = mergeConfigs(baseConfig, localConfig);
|
|
20424
20637
|
try {
|
|
@@ -20462,6 +20675,7 @@ var ConfigResolver = class {
|
|
|
20462
20675
|
simulateSubagents: resolvedSimulateSubagents,
|
|
20463
20676
|
simulateSkills: resolvedSimulateSkills,
|
|
20464
20677
|
gitignoreTargetsOnly: resolvedGitignoreTargetsOnly,
|
|
20678
|
+
gitignoreDestination: gitignoreDestination ?? configByFile.gitignoreDestination ?? getDefaults().gitignoreDestination,
|
|
20465
20679
|
dryRun: dryRun ?? configByFile.dryRun ?? getDefaults().dryRun,
|
|
20466
20680
|
check: check ?? configByFile.check ?? getDefaults().check,
|
|
20467
20681
|
sources: configByFile.sources ?? getDefaults().sources
|
|
@@ -20476,7 +20690,7 @@ function getBaseDirsInLightOfGlobal({
|
|
|
20476
20690
|
if (global) {
|
|
20477
20691
|
return [getHomeDirectory()];
|
|
20478
20692
|
}
|
|
20479
|
-
const resolvedBaseDirs = baseDirs.map((baseDir) => (0,
|
|
20693
|
+
const resolvedBaseDirs = baseDirs.map((baseDir) => (0, import_node_path135.resolve)(baseDir));
|
|
20480
20694
|
resolvedBaseDirs.forEach((baseDir) => {
|
|
20481
20695
|
validateBaseDir(baseDir);
|
|
20482
20696
|
});
|
|
@@ -20484,28 +20698,28 @@ function getBaseDirsInLightOfGlobal({
|
|
|
20484
20698
|
}
|
|
20485
20699
|
|
|
20486
20700
|
// src/lib/generate.ts
|
|
20487
|
-
var
|
|
20701
|
+
var import_node_path142 = require("path");
|
|
20488
20702
|
var import_es_toolkit5 = require("es-toolkit");
|
|
20489
20703
|
|
|
20490
20704
|
// src/features/permissions/permissions-processor.ts
|
|
20491
|
-
var
|
|
20705
|
+
var import_mini75 = require("zod/mini");
|
|
20492
20706
|
|
|
20493
20707
|
// src/features/permissions/claudecode-permissions.ts
|
|
20494
|
-
var
|
|
20708
|
+
var import_node_path137 = require("path");
|
|
20495
20709
|
var import_es_toolkit4 = require("es-toolkit");
|
|
20496
20710
|
|
|
20497
20711
|
// src/features/permissions/rulesync-permissions.ts
|
|
20498
|
-
var
|
|
20712
|
+
var import_node_path136 = require("path");
|
|
20499
20713
|
|
|
20500
20714
|
// src/types/permissions.ts
|
|
20501
|
-
var
|
|
20502
|
-
var PermissionActionSchema =
|
|
20503
|
-
var PermissionRulesSchema =
|
|
20504
|
-
var PermissionsConfigSchema =
|
|
20505
|
-
permission:
|
|
20715
|
+
var import_mini71 = require("zod/mini");
|
|
20716
|
+
var PermissionActionSchema = import_mini71.z.enum(["allow", "ask", "deny"]);
|
|
20717
|
+
var PermissionRulesSchema = import_mini71.z.record(import_mini71.z.string(), PermissionActionSchema);
|
|
20718
|
+
var PermissionsConfigSchema = import_mini71.z.looseObject({
|
|
20719
|
+
permission: import_mini71.z.record(import_mini71.z.string(), PermissionRulesSchema)
|
|
20506
20720
|
});
|
|
20507
|
-
var RulesyncPermissionsFileSchema =
|
|
20508
|
-
$schema:
|
|
20721
|
+
var RulesyncPermissionsFileSchema = import_mini71.z.looseObject({
|
|
20722
|
+
$schema: import_mini71.z.optional(import_mini71.z.string()),
|
|
20509
20723
|
...PermissionsConfigSchema.shape
|
|
20510
20724
|
});
|
|
20511
20725
|
|
|
@@ -20540,7 +20754,7 @@ var RulesyncPermissions = class _RulesyncPermissions extends RulesyncFile {
|
|
|
20540
20754
|
validate = true
|
|
20541
20755
|
}) {
|
|
20542
20756
|
const paths = _RulesyncPermissions.getSettablePaths();
|
|
20543
|
-
const filePath = (0,
|
|
20757
|
+
const filePath = (0, import_node_path136.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
20544
20758
|
if (!await fileExists(filePath)) {
|
|
20545
20759
|
throw new Error(`No ${RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH} found.`);
|
|
20546
20760
|
}
|
|
@@ -20648,7 +20862,7 @@ var ClaudecodePermissions = class _ClaudecodePermissions extends ToolPermissions
|
|
|
20648
20862
|
validate = true
|
|
20649
20863
|
}) {
|
|
20650
20864
|
const paths = _ClaudecodePermissions.getSettablePaths();
|
|
20651
|
-
const filePath = (0,
|
|
20865
|
+
const filePath = (0, import_node_path137.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
20652
20866
|
const fileContent = await readFileContentOrNull(filePath) ?? '{"permissions":{}}';
|
|
20653
20867
|
return new _ClaudecodePermissions({
|
|
20654
20868
|
baseDir,
|
|
@@ -20664,7 +20878,7 @@ var ClaudecodePermissions = class _ClaudecodePermissions extends ToolPermissions
|
|
|
20664
20878
|
logger: logger5
|
|
20665
20879
|
}) {
|
|
20666
20880
|
const paths = _ClaudecodePermissions.getSettablePaths();
|
|
20667
|
-
const filePath = (0,
|
|
20881
|
+
const filePath = (0, import_node_path137.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
20668
20882
|
const existingContent = await readOrInitializeFileContent(
|
|
20669
20883
|
filePath,
|
|
20670
20884
|
JSON.stringify({}, null, 2)
|
|
@@ -20741,7 +20955,7 @@ var ClaudecodePermissions = class _ClaudecodePermissions extends ToolPermissions
|
|
|
20741
20955
|
settings = JSON.parse(this.getFileContent());
|
|
20742
20956
|
} catch (error) {
|
|
20743
20957
|
throw new Error(
|
|
20744
|
-
`Failed to parse Claude permissions content in ${(0,
|
|
20958
|
+
`Failed to parse Claude permissions content in ${(0, import_node_path137.join)(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${formatError(error)}`,
|
|
20745
20959
|
{ cause: error }
|
|
20746
20960
|
);
|
|
20747
20961
|
}
|
|
@@ -20814,7 +21028,7 @@ function convertClaudeToRulesyncPermissions(params) {
|
|
|
20814
21028
|
}
|
|
20815
21029
|
|
|
20816
21030
|
// src/features/permissions/codexcli-permissions.ts
|
|
20817
|
-
var
|
|
21031
|
+
var import_node_path138 = require("path");
|
|
20818
21032
|
var smolToml5 = __toESM(require("smol-toml"), 1);
|
|
20819
21033
|
var RULESYNC_PROFILE_NAME = "rulesync";
|
|
20820
21034
|
var RULESYNC_BASH_RULES_FILE_NAME = "rulesync.rules";
|
|
@@ -20834,7 +21048,7 @@ var CodexcliPermissions = class _CodexcliPermissions extends ToolPermissions {
|
|
|
20834
21048
|
global = false
|
|
20835
21049
|
}) {
|
|
20836
21050
|
const paths = this.getSettablePaths({ global });
|
|
20837
|
-
const filePath = (0,
|
|
21051
|
+
const filePath = (0, import_node_path138.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
20838
21052
|
const fileContent = await readFileContentOrNull(filePath) ?? smolToml5.stringify({});
|
|
20839
21053
|
return new _CodexcliPermissions({
|
|
20840
21054
|
baseDir,
|
|
@@ -20852,7 +21066,7 @@ var CodexcliPermissions = class _CodexcliPermissions extends ToolPermissions {
|
|
|
20852
21066
|
global = false
|
|
20853
21067
|
}) {
|
|
20854
21068
|
const paths = this.getSettablePaths({ global });
|
|
20855
|
-
const filePath = (0,
|
|
21069
|
+
const filePath = (0, import_node_path138.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
20856
21070
|
const existingContent = await readFileContentOrNull(filePath) ?? smolToml5.stringify({});
|
|
20857
21071
|
const parsed = toMutableTable(smolToml5.parse(existingContent));
|
|
20858
21072
|
const profile = convertRulesyncToCodexProfile({
|
|
@@ -20877,7 +21091,7 @@ var CodexcliPermissions = class _CodexcliPermissions extends ToolPermissions {
|
|
|
20877
21091
|
parsed = smolToml5.parse(this.getFileContent());
|
|
20878
21092
|
} catch (error) {
|
|
20879
21093
|
throw new Error(
|
|
20880
|
-
`Failed to parse Codex CLI permissions content in ${(0,
|
|
21094
|
+
`Failed to parse Codex CLI permissions content in ${(0, import_node_path138.join)(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${formatError(error)}`,
|
|
20881
21095
|
{ cause: error }
|
|
20882
21096
|
);
|
|
20883
21097
|
}
|
|
@@ -20918,7 +21132,7 @@ function createCodexcliBashRulesFile({
|
|
|
20918
21132
|
}) {
|
|
20919
21133
|
return new CodexcliRulesFile({
|
|
20920
21134
|
baseDir,
|
|
20921
|
-
relativeDirPath: (0,
|
|
21135
|
+
relativeDirPath: (0, import_node_path138.join)(".codex", "rules"),
|
|
20922
21136
|
relativeFilePath: RULESYNC_BASH_RULES_FILE_NAME,
|
|
20923
21137
|
fileContent: buildCodexBashRulesContent(config)
|
|
20924
21138
|
});
|
|
@@ -21073,110 +21287,276 @@ function mapBashActionToDecision(action) {
|
|
|
21073
21287
|
}
|
|
21074
21288
|
|
|
21075
21289
|
// src/features/permissions/geminicli-permissions.ts
|
|
21076
|
-
var
|
|
21077
|
-
var
|
|
21078
|
-
var
|
|
21079
|
-
|
|
21080
|
-
|
|
21081
|
-
|
|
21082
|
-
|
|
21083
|
-
|
|
21084
|
-
)
|
|
21085
|
-
|
|
21086
|
-
|
|
21087
|
-
bash: "run_shell_command",
|
|
21088
|
-
read: "read_file",
|
|
21089
|
-
edit: "replace",
|
|
21090
|
-
write: "write_file",
|
|
21091
|
-
webfetch: "web_fetch"
|
|
21092
|
-
};
|
|
21093
|
-
var GeminicliPermissions = class _GeminicliPermissions extends ToolPermissions {
|
|
21094
|
-
static getSettablePaths(_options = {}) {
|
|
21095
|
-
return {
|
|
21096
|
-
relativeDirPath: ".gemini",
|
|
21097
|
-
relativeFilePath: "settings.json"
|
|
21098
|
-
};
|
|
21290
|
+
var import_node_path139 = require("path");
|
|
21291
|
+
var smolToml6 = __toESM(require("smol-toml"), 1);
|
|
21292
|
+
var import_mini72 = require("zod/mini");
|
|
21293
|
+
|
|
21294
|
+
// src/utils/logger.ts
|
|
21295
|
+
var BaseLogger = class {
|
|
21296
|
+
_verbose = false;
|
|
21297
|
+
_silent = false;
|
|
21298
|
+
constructor({ verbose = false, silent = false } = {}) {
|
|
21299
|
+
this._silent = silent;
|
|
21300
|
+
this._verbose = verbose && !silent;
|
|
21099
21301
|
}
|
|
21100
|
-
|
|
21101
|
-
return
|
|
21302
|
+
get verbose() {
|
|
21303
|
+
return this._verbose;
|
|
21102
21304
|
}
|
|
21103
|
-
|
|
21104
|
-
|
|
21105
|
-
validate = true,
|
|
21106
|
-
global = false
|
|
21107
|
-
}) {
|
|
21108
|
-
const paths = this.getSettablePaths({ global });
|
|
21109
|
-
const filePath = (0, import_node_path138.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
21110
|
-
const fileContent = await readFileContentOrNull(filePath) ?? JSON.stringify({}, null, 2);
|
|
21111
|
-
return new _GeminicliPermissions({
|
|
21112
|
-
baseDir,
|
|
21113
|
-
relativeDirPath: paths.relativeDirPath,
|
|
21114
|
-
relativeFilePath: paths.relativeFilePath,
|
|
21115
|
-
fileContent,
|
|
21116
|
-
validate
|
|
21117
|
-
});
|
|
21305
|
+
get silent() {
|
|
21306
|
+
return this._silent;
|
|
21118
21307
|
}
|
|
21119
|
-
|
|
21120
|
-
|
|
21121
|
-
|
|
21122
|
-
|
|
21123
|
-
|
|
21124
|
-
global = false
|
|
21125
|
-
}) {
|
|
21126
|
-
const paths = this.getSettablePaths({ global });
|
|
21127
|
-
const filePath = (0, import_node_path138.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
21128
|
-
const existingContent = await readFileContentOrNull(filePath) ?? JSON.stringify({}, null, 2);
|
|
21129
|
-
const settingsResult = GeminiCliSettingsSchema.safeParse(JSON.parse(existingContent));
|
|
21130
|
-
if (!settingsResult.success) {
|
|
21131
|
-
throw new Error(
|
|
21132
|
-
`Failed to parse existing Gemini CLI settings at ${filePath}: ${formatError(settingsResult.error)}`
|
|
21133
|
-
);
|
|
21134
|
-
}
|
|
21135
|
-
const { allowed, exclude } = convertRulesyncToGeminicliTools({
|
|
21136
|
-
config: rulesyncPermissions.getJson(),
|
|
21137
|
-
logger: logger5
|
|
21138
|
-
});
|
|
21139
|
-
const merged = {
|
|
21140
|
-
...settingsResult.data,
|
|
21141
|
-
tools: {
|
|
21142
|
-
...settingsResult.data.tools,
|
|
21143
|
-
...allowed.length > 0 ? { allowed } : {},
|
|
21144
|
-
...exclude.length > 0 ? { exclude } : {}
|
|
21308
|
+
configure({ verbose, silent }) {
|
|
21309
|
+
if (verbose && silent) {
|
|
21310
|
+
this._silent = false;
|
|
21311
|
+
if (!isEnvTest()) {
|
|
21312
|
+
this.onConflictingFlags();
|
|
21145
21313
|
}
|
|
21146
|
-
};
|
|
21147
|
-
return new _GeminicliPermissions({
|
|
21148
|
-
baseDir,
|
|
21149
|
-
relativeDirPath: paths.relativeDirPath,
|
|
21150
|
-
relativeFilePath: paths.relativeFilePath,
|
|
21151
|
-
fileContent: JSON.stringify(merged, null, 2),
|
|
21152
|
-
validate
|
|
21153
|
-
});
|
|
21154
|
-
}
|
|
21155
|
-
toRulesyncPermissions() {
|
|
21156
|
-
let settings;
|
|
21157
|
-
try {
|
|
21158
|
-
const parsed = JSON.parse(this.getFileContent());
|
|
21159
|
-
settings = GeminiCliSettingsSchema.parse(parsed);
|
|
21160
|
-
} catch (error) {
|
|
21161
|
-
throw new Error(
|
|
21162
|
-
`Failed to parse Gemini CLI permissions content in ${(0, import_node_path138.join)(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${formatError(error)}`,
|
|
21163
|
-
{ cause: error }
|
|
21164
|
-
);
|
|
21165
21314
|
}
|
|
21166
|
-
|
|
21167
|
-
|
|
21168
|
-
|
|
21169
|
-
|
|
21170
|
-
|
|
21171
|
-
|
|
21172
|
-
|
|
21173
|
-
|
|
21174
|
-
|
|
21175
|
-
|
|
21176
|
-
|
|
21177
|
-
|
|
21178
|
-
|
|
21179
|
-
|
|
21315
|
+
this._silent = silent;
|
|
21316
|
+
this._verbose = verbose && !silent;
|
|
21317
|
+
}
|
|
21318
|
+
onConflictingFlags() {
|
|
21319
|
+
console.warn("Both --verbose and --silent specified; --silent takes precedence");
|
|
21320
|
+
}
|
|
21321
|
+
};
|
|
21322
|
+
var ConsoleLogger = class extends BaseLogger {
|
|
21323
|
+
isSuppressed() {
|
|
21324
|
+
return isEnvTest() || this._silent;
|
|
21325
|
+
}
|
|
21326
|
+
get jsonMode() {
|
|
21327
|
+
return false;
|
|
21328
|
+
}
|
|
21329
|
+
captureData(_key, _value) {
|
|
21330
|
+
}
|
|
21331
|
+
getJsonData() {
|
|
21332
|
+
return {};
|
|
21333
|
+
}
|
|
21334
|
+
outputJson(_success, _error) {
|
|
21335
|
+
}
|
|
21336
|
+
info(message, ...args) {
|
|
21337
|
+
if (this.isSuppressed()) return;
|
|
21338
|
+
console.log(message, ...args);
|
|
21339
|
+
}
|
|
21340
|
+
success(message, ...args) {
|
|
21341
|
+
if (this.isSuppressed()) return;
|
|
21342
|
+
console.log(message, ...args);
|
|
21343
|
+
}
|
|
21344
|
+
warn(message, ...args) {
|
|
21345
|
+
if (this.isSuppressed()) return;
|
|
21346
|
+
console.warn(message, ...args);
|
|
21347
|
+
}
|
|
21348
|
+
// Errors are always emitted, even in silent mode
|
|
21349
|
+
error(message, _code, ...args) {
|
|
21350
|
+
if (isEnvTest()) return;
|
|
21351
|
+
const errorMessage = message instanceof Error ? message.message : message;
|
|
21352
|
+
console.error(errorMessage, ...args);
|
|
21353
|
+
}
|
|
21354
|
+
debug(message, ...args) {
|
|
21355
|
+
if (!this._verbose || this.isSuppressed()) return;
|
|
21356
|
+
console.log(message, ...args);
|
|
21357
|
+
}
|
|
21358
|
+
};
|
|
21359
|
+
var JsonLogger = class extends BaseLogger {
|
|
21360
|
+
_jsonOutputDone = false;
|
|
21361
|
+
_jsonData = {};
|
|
21362
|
+
_commandName;
|
|
21363
|
+
_version;
|
|
21364
|
+
constructor({
|
|
21365
|
+
command,
|
|
21366
|
+
version,
|
|
21367
|
+
verbose = false,
|
|
21368
|
+
silent = false
|
|
21369
|
+
}) {
|
|
21370
|
+
super({ verbose, silent });
|
|
21371
|
+
this._commandName = command;
|
|
21372
|
+
this._version = version;
|
|
21373
|
+
}
|
|
21374
|
+
// Suppress raw console.warn in JSON mode to avoid non-JSON text on stderr
|
|
21375
|
+
onConflictingFlags() {
|
|
21376
|
+
}
|
|
21377
|
+
get jsonMode() {
|
|
21378
|
+
return true;
|
|
21379
|
+
}
|
|
21380
|
+
captureData(key, value) {
|
|
21381
|
+
this._jsonData[key] = value;
|
|
21382
|
+
}
|
|
21383
|
+
getJsonData() {
|
|
21384
|
+
return { ...this._jsonData };
|
|
21385
|
+
}
|
|
21386
|
+
outputJson(success, error) {
|
|
21387
|
+
if (this._jsonOutputDone) return;
|
|
21388
|
+
this._jsonOutputDone = true;
|
|
21389
|
+
const output = {
|
|
21390
|
+
success,
|
|
21391
|
+
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
21392
|
+
command: this._commandName,
|
|
21393
|
+
version: this._version
|
|
21394
|
+
};
|
|
21395
|
+
if (success) {
|
|
21396
|
+
output.data = this._jsonData;
|
|
21397
|
+
} else if (error) {
|
|
21398
|
+
output.error = {
|
|
21399
|
+
code: error.code,
|
|
21400
|
+
message: error.message
|
|
21401
|
+
};
|
|
21402
|
+
if (error.details) {
|
|
21403
|
+
output.error.details = error.details;
|
|
21404
|
+
}
|
|
21405
|
+
if (error.stack) {
|
|
21406
|
+
output.error.stack = error.stack;
|
|
21407
|
+
}
|
|
21408
|
+
}
|
|
21409
|
+
const jsonStr = JSON.stringify(output, null, 2);
|
|
21410
|
+
if (success) {
|
|
21411
|
+
console.log(jsonStr);
|
|
21412
|
+
} else {
|
|
21413
|
+
console.error(jsonStr);
|
|
21414
|
+
}
|
|
21415
|
+
}
|
|
21416
|
+
info(_message, ..._args) {
|
|
21417
|
+
}
|
|
21418
|
+
success(_message, ..._args) {
|
|
21419
|
+
}
|
|
21420
|
+
warn(_message, ..._args) {
|
|
21421
|
+
}
|
|
21422
|
+
error(message, code, ..._args) {
|
|
21423
|
+
if (isEnvTest()) return;
|
|
21424
|
+
const errorMessage = message instanceof Error ? message.message : message;
|
|
21425
|
+
const errorInfo = {
|
|
21426
|
+
code: code || ErrorCodes.UNKNOWN_ERROR,
|
|
21427
|
+
message: errorMessage
|
|
21428
|
+
};
|
|
21429
|
+
if (this._verbose && message instanceof Error && message.stack) {
|
|
21430
|
+
errorInfo.stack = message.stack;
|
|
21431
|
+
}
|
|
21432
|
+
this.outputJson(false, errorInfo);
|
|
21433
|
+
}
|
|
21434
|
+
debug(_message, ..._args) {
|
|
21435
|
+
}
|
|
21436
|
+
};
|
|
21437
|
+
|
|
21438
|
+
// src/features/permissions/geminicli-permissions.ts
|
|
21439
|
+
var GEMINICLI_POLICY_RELATIVE_DIR_PATH = (0, import_node_path139.join)(".gemini", "policies");
|
|
21440
|
+
var GEMINICLI_POLICY_FILE_NAME = "rulesync.toml";
|
|
21441
|
+
var RULESYNC_TO_GEMINICLI_TOOL_NAME = {
|
|
21442
|
+
bash: "run_shell_command",
|
|
21443
|
+
read: "read_file",
|
|
21444
|
+
edit: "replace",
|
|
21445
|
+
write: "write_file",
|
|
21446
|
+
webfetch: "web_fetch"
|
|
21447
|
+
};
|
|
21448
|
+
var GEMINICLI_TO_RULESYNC_TOOL_NAME = Object.fromEntries(
|
|
21449
|
+
Object.entries(RULESYNC_TO_GEMINICLI_TOOL_NAME).map(([k, v]) => [v, k])
|
|
21450
|
+
);
|
|
21451
|
+
var PRIORITY_DENY = 1e6;
|
|
21452
|
+
var PRIORITY_ASK = 1e3;
|
|
21453
|
+
var PRIORITY_ALLOW = 1;
|
|
21454
|
+
var SINGLE_STAR_REGEX = '[^/\\"]*';
|
|
21455
|
+
var DOUBLE_STAR_REGEX = '[^\\"]*';
|
|
21456
|
+
var SINGLE_CHAR_REGEX = '[^/\\"]';
|
|
21457
|
+
var LEGACY_SINGLE_STAR_REGEX = '[^\\"]*';
|
|
21458
|
+
var LEGACY_DOUBLE_STAR_REGEX = ".*";
|
|
21459
|
+
var COMMAND_ARGS_ANCHOR = '"command":"';
|
|
21460
|
+
var VALUE_END_ANCHOR = '\\"';
|
|
21461
|
+
var RESERVED_OBJECT_KEYS = /* @__PURE__ */ new Set([
|
|
21462
|
+
"__proto__",
|
|
21463
|
+
"constructor",
|
|
21464
|
+
"prototype"
|
|
21465
|
+
]);
|
|
21466
|
+
var moduleLogger = new ConsoleLogger();
|
|
21467
|
+
var GeminicliPermissions = class _GeminicliPermissions extends ToolPermissions {
|
|
21468
|
+
static getSettablePaths(_options = {}) {
|
|
21469
|
+
return {
|
|
21470
|
+
relativeDirPath: GEMINICLI_POLICY_RELATIVE_DIR_PATH,
|
|
21471
|
+
relativeFilePath: GEMINICLI_POLICY_FILE_NAME
|
|
21472
|
+
};
|
|
21473
|
+
}
|
|
21474
|
+
static async fromFile({
|
|
21475
|
+
baseDir = process.cwd(),
|
|
21476
|
+
validate = true,
|
|
21477
|
+
global = false
|
|
21478
|
+
}) {
|
|
21479
|
+
const paths = this.getSettablePaths({ global });
|
|
21480
|
+
const filePath = (0, import_node_path139.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
21481
|
+
const fileContent = await readFileContentOrNull(filePath) ?? "";
|
|
21482
|
+
return new _GeminicliPermissions({
|
|
21483
|
+
baseDir,
|
|
21484
|
+
relativeDirPath: paths.relativeDirPath,
|
|
21485
|
+
relativeFilePath: paths.relativeFilePath,
|
|
21486
|
+
fileContent,
|
|
21487
|
+
validate
|
|
21488
|
+
});
|
|
21489
|
+
}
|
|
21490
|
+
static fromRulesyncPermissions({
|
|
21491
|
+
baseDir = process.cwd(),
|
|
21492
|
+
rulesyncPermissions,
|
|
21493
|
+
validate = true,
|
|
21494
|
+
global = false,
|
|
21495
|
+
logger: logger5 = moduleLogger
|
|
21496
|
+
}) {
|
|
21497
|
+
const paths = this.getSettablePaths({ global });
|
|
21498
|
+
const fileContent = buildGeminicliPolicyContent(rulesyncPermissions.getJson(), logger5);
|
|
21499
|
+
return new _GeminicliPermissions({
|
|
21500
|
+
baseDir,
|
|
21501
|
+
relativeDirPath: paths.relativeDirPath,
|
|
21502
|
+
relativeFilePath: paths.relativeFilePath,
|
|
21503
|
+
fileContent,
|
|
21504
|
+
validate
|
|
21505
|
+
});
|
|
21506
|
+
}
|
|
21507
|
+
toRulesyncPermissions() {
|
|
21508
|
+
const permission = {};
|
|
21509
|
+
const fileContent = this.getFileContent();
|
|
21510
|
+
if (fileContent.trim().length > 0) {
|
|
21511
|
+
let parsed;
|
|
21512
|
+
try {
|
|
21513
|
+
parsed = smolToml6.parse(fileContent);
|
|
21514
|
+
} catch (error) {
|
|
21515
|
+
throw new Error(
|
|
21516
|
+
`Failed to parse Gemini CLI policy TOML in ${(0, import_node_path139.join)(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${formatError(error)}`,
|
|
21517
|
+
{ cause: error }
|
|
21518
|
+
);
|
|
21519
|
+
}
|
|
21520
|
+
const rules = extractRules(parsed, moduleLogger);
|
|
21521
|
+
for (const [index, rule] of rules.entries()) {
|
|
21522
|
+
const mappedCategory = Object.hasOwn(GEMINICLI_TO_RULESYNC_TOOL_NAME, rule.toolName) ? GEMINICLI_TO_RULESYNC_TOOL_NAME[rule.toolName] : void 0;
|
|
21523
|
+
const category = mappedCategory ?? rule.toolName;
|
|
21524
|
+
if (RESERVED_OBJECT_KEYS.has(category)) {
|
|
21525
|
+
moduleLogger.warn(
|
|
21526
|
+
`Skipping rule #${index} in ${this.getRelativeFilePath()}: toolName "${rule.toolName}" maps to a reserved object key ("${category}") and would risk prototype pollution.`
|
|
21527
|
+
);
|
|
21528
|
+
continue;
|
|
21529
|
+
}
|
|
21530
|
+
const action = mapFromGeminicliDecision(rule.decision);
|
|
21531
|
+
if (!action) {
|
|
21532
|
+
moduleLogger.warn(
|
|
21533
|
+
`Skipping rule #${index} (toolName="${rule.toolName}", commandPrefix=${JSON.stringify(rule.commandPrefix)}, argsPattern=${JSON.stringify(rule.argsPattern)}) in ${this.getRelativeFilePath()}: unknown decision ${JSON.stringify(rule.decision)}`
|
|
21534
|
+
);
|
|
21535
|
+
continue;
|
|
21536
|
+
}
|
|
21537
|
+
if (rule.toolName === "run_shell_command" && rule.commandPrefix !== void 0 && rule.argsPattern !== void 0) {
|
|
21538
|
+
moduleLogger.warn(
|
|
21539
|
+
`Rule #${index} in ${this.getRelativeFilePath()} sets both commandPrefix and argsPattern; rulesync will honor argsPattern and ignore commandPrefix=${JSON.stringify(rule.commandPrefix)}.`
|
|
21540
|
+
);
|
|
21541
|
+
}
|
|
21542
|
+
const pattern = extractPattern(rule);
|
|
21543
|
+
if (RESERVED_OBJECT_KEYS.has(pattern)) {
|
|
21544
|
+
moduleLogger.warn(
|
|
21545
|
+
`Skipping rule #${index} in ${this.getRelativeFilePath()}: pattern "${pattern}" is a reserved object key.`
|
|
21546
|
+
);
|
|
21547
|
+
continue;
|
|
21548
|
+
}
|
|
21549
|
+
const existing = Object.hasOwn(permission, category) ? permission[category] : void 0;
|
|
21550
|
+
const target = existing ?? {};
|
|
21551
|
+
if (existing === void 0) {
|
|
21552
|
+
permission[category] = target;
|
|
21553
|
+
}
|
|
21554
|
+
target[pattern] = action;
|
|
21555
|
+
}
|
|
21556
|
+
}
|
|
21557
|
+
return this.toRulesyncPermissionsDefault({
|
|
21558
|
+
fileContent: JSON.stringify({ permission }, null, 2)
|
|
21559
|
+
});
|
|
21180
21560
|
}
|
|
21181
21561
|
validate() {
|
|
21182
21562
|
return { success: true, error: null };
|
|
@@ -21190,64 +21570,252 @@ var GeminicliPermissions = class _GeminicliPermissions extends ToolPermissions {
|
|
|
21190
21570
|
baseDir,
|
|
21191
21571
|
relativeDirPath,
|
|
21192
21572
|
relativeFilePath,
|
|
21193
|
-
fileContent:
|
|
21573
|
+
fileContent: "",
|
|
21194
21574
|
validate: false
|
|
21195
21575
|
});
|
|
21196
21576
|
}
|
|
21197
21577
|
};
|
|
21198
|
-
function
|
|
21199
|
-
|
|
21578
|
+
function buildGeminicliPolicyContent(config, logger5) {
|
|
21579
|
+
const rules = [];
|
|
21580
|
+
let order = 0;
|
|
21581
|
+
for (const [toolName, entries] of Object.entries(config.permission)) {
|
|
21582
|
+
const mappedToolName = RULESYNC_TO_GEMINICLI_TOOL_NAME[toolName] ?? toolName;
|
|
21583
|
+
for (const [pattern, action] of Object.entries(entries)) {
|
|
21584
|
+
if (pattern === "") {
|
|
21585
|
+
logger5.warn(
|
|
21586
|
+
`Skipping rule "${toolName}: "": empty pattern is not a valid permission target and would silently match every invocation (bash) or nothing (other tools).`
|
|
21587
|
+
);
|
|
21588
|
+
continue;
|
|
21589
|
+
}
|
|
21590
|
+
if (hasUnsafeAnchorChar(pattern)) {
|
|
21591
|
+
logger5.warn(
|
|
21592
|
+
`Skipping rule "${toolName}: ${pattern}": pattern contains a character (" or \\) that would break JSON-anchor matching in the Gemini CLI Policy Engine.`
|
|
21593
|
+
);
|
|
21594
|
+
continue;
|
|
21595
|
+
}
|
|
21596
|
+
const decision = mapToGeminicliDecision(action);
|
|
21597
|
+
if (mappedToolName === "run_shell_command" && (pattern === "*" || pattern === "**") && decision !== "ask_user") {
|
|
21598
|
+
logger5.warn(
|
|
21599
|
+
`Skipping rule "${toolName}: ${pattern}" with decision ${decision}: bash match-all patterns are only supported with "ask" because they would otherwise affect every shell command.`
|
|
21600
|
+
);
|
|
21601
|
+
continue;
|
|
21602
|
+
}
|
|
21603
|
+
const currentRule = {
|
|
21604
|
+
toolName: mappedToolName,
|
|
21605
|
+
decision,
|
|
21606
|
+
priority: priorityForDecision(decision)
|
|
21607
|
+
};
|
|
21608
|
+
if (mappedToolName === "run_shell_command") {
|
|
21609
|
+
applyShellPattern({ rule: currentRule, pattern, toolName, logger: logger5 });
|
|
21610
|
+
} else if (pattern !== "*") {
|
|
21611
|
+
currentRule.argsPattern = buildNonShellArgsPattern(pattern);
|
|
21612
|
+
}
|
|
21613
|
+
rules.push({ rule: currentRule, order: order++ });
|
|
21614
|
+
}
|
|
21615
|
+
}
|
|
21616
|
+
rules.sort((a, b) => {
|
|
21617
|
+
const diff = toNumber(b.rule.priority) - toNumber(a.rule.priority);
|
|
21618
|
+
return diff !== 0 ? diff : a.order - b.order;
|
|
21619
|
+
});
|
|
21620
|
+
return smolToml6.stringify({ rule: rules.map((entry) => entry.rule) });
|
|
21621
|
+
}
|
|
21622
|
+
function buildNonShellArgsPattern(pattern) {
|
|
21623
|
+
return `"${globPatternToRegex(pattern)}${VALUE_END_ANCHOR}`;
|
|
21624
|
+
}
|
|
21625
|
+
function hasUnsafeAnchorChar(pattern) {
|
|
21626
|
+
return pattern.includes('"') || pattern.includes("\\");
|
|
21627
|
+
}
|
|
21628
|
+
function toNumber(value) {
|
|
21629
|
+
return typeof value === "number" ? value : 0;
|
|
21630
|
+
}
|
|
21631
|
+
function applyShellPattern({
|
|
21632
|
+
rule,
|
|
21633
|
+
pattern,
|
|
21634
|
+
toolName,
|
|
21200
21635
|
logger: logger5
|
|
21201
21636
|
}) {
|
|
21202
|
-
|
|
21203
|
-
|
|
21204
|
-
|
|
21205
|
-
|
|
21206
|
-
|
|
21207
|
-
|
|
21637
|
+
if (pattern === "*") {
|
|
21638
|
+
return;
|
|
21639
|
+
}
|
|
21640
|
+
const trailingWildcardStripped = pattern.endsWith(" *") ? pattern.slice(0, -2) : pattern;
|
|
21641
|
+
if (hasGlobMetacharacter(trailingWildcardStripped)) {
|
|
21642
|
+
rule.argsPattern = `${COMMAND_ARGS_ANCHOR}${globPatternToRegex(pattern)}`;
|
|
21643
|
+
logger5.warn(
|
|
21644
|
+
`Gemini CLI does not support glob metacharacters inside a bash command prefix; emitting argsPattern for rule "${toolName}: ${pattern}".`
|
|
21645
|
+
);
|
|
21646
|
+
return;
|
|
21647
|
+
}
|
|
21648
|
+
rule.commandPrefix = trailingWildcardStripped;
|
|
21649
|
+
}
|
|
21650
|
+
function hasGlobMetacharacter(pattern) {
|
|
21651
|
+
return /[*?[\]]/.test(pattern);
|
|
21652
|
+
}
|
|
21653
|
+
function priorityForDecision(decision) {
|
|
21654
|
+
if (decision === "deny") return PRIORITY_DENY;
|
|
21655
|
+
if (decision === "ask_user") return PRIORITY_ASK;
|
|
21656
|
+
return PRIORITY_ALLOW;
|
|
21657
|
+
}
|
|
21658
|
+
function mapToGeminicliDecision(action) {
|
|
21659
|
+
if (action === "ask") {
|
|
21660
|
+
return "ask_user";
|
|
21661
|
+
}
|
|
21662
|
+
return action;
|
|
21663
|
+
}
|
|
21664
|
+
function mapFromGeminicliDecision(decision) {
|
|
21665
|
+
if (decision === "allow") return "allow";
|
|
21666
|
+
if (decision === "deny") return "deny";
|
|
21667
|
+
if (decision === "ask_user") return "ask";
|
|
21668
|
+
return null;
|
|
21669
|
+
}
|
|
21670
|
+
function globPatternToRegex(pattern) {
|
|
21671
|
+
let regex = "";
|
|
21672
|
+
let i = 0;
|
|
21673
|
+
while (i < pattern.length) {
|
|
21674
|
+
const char = pattern[i];
|
|
21675
|
+
if (char === void 0) {
|
|
21676
|
+
break;
|
|
21677
|
+
}
|
|
21678
|
+
if (char === "*" && pattern[i + 1] === "*") {
|
|
21679
|
+
regex += DOUBLE_STAR_REGEX;
|
|
21680
|
+
i += 2;
|
|
21681
|
+
continue;
|
|
21682
|
+
}
|
|
21683
|
+
if (char === "*") {
|
|
21684
|
+
regex += SINGLE_STAR_REGEX;
|
|
21685
|
+
i += 1;
|
|
21686
|
+
continue;
|
|
21687
|
+
}
|
|
21688
|
+
if (char === "?") {
|
|
21689
|
+
regex += SINGLE_CHAR_REGEX;
|
|
21690
|
+
i += 1;
|
|
21691
|
+
continue;
|
|
21692
|
+
}
|
|
21693
|
+
if (char === "[") {
|
|
21694
|
+
regex += escapeRegexChar(char);
|
|
21695
|
+
i += 1;
|
|
21696
|
+
continue;
|
|
21697
|
+
}
|
|
21698
|
+
if (char === "]") {
|
|
21699
|
+
regex += escapeRegexChar(char);
|
|
21700
|
+
i += 1;
|
|
21701
|
+
continue;
|
|
21702
|
+
}
|
|
21703
|
+
if (isRegexMetacharacter(char)) {
|
|
21704
|
+
regex += `\\${char}`;
|
|
21705
|
+
i += 1;
|
|
21706
|
+
continue;
|
|
21707
|
+
}
|
|
21708
|
+
regex += char;
|
|
21709
|
+
i += 1;
|
|
21710
|
+
}
|
|
21711
|
+
return regex;
|
|
21712
|
+
}
|
|
21713
|
+
function escapeRegexChar(char) {
|
|
21714
|
+
return `\\${char}`;
|
|
21715
|
+
}
|
|
21716
|
+
function isRegexMetacharacter(char) {
|
|
21717
|
+
return /[.+^${}()|\\]/.test(char);
|
|
21718
|
+
}
|
|
21719
|
+
function regexToGlobPattern(regex) {
|
|
21720
|
+
let source = regex;
|
|
21721
|
+
if (source.endsWith(VALUE_END_ANCHOR)) {
|
|
21722
|
+
source = source.slice(0, -VALUE_END_ANCHOR.length);
|
|
21723
|
+
}
|
|
21724
|
+
let glob = "";
|
|
21725
|
+
let i = 0;
|
|
21726
|
+
while (i < source.length) {
|
|
21727
|
+
if (source.startsWith(DOUBLE_STAR_REGEX, i)) {
|
|
21728
|
+
glob += "**";
|
|
21729
|
+
i += DOUBLE_STAR_REGEX.length;
|
|
21730
|
+
continue;
|
|
21731
|
+
}
|
|
21732
|
+
if (source.startsWith(LEGACY_DOUBLE_STAR_REGEX, i)) {
|
|
21733
|
+
glob += "**";
|
|
21734
|
+
i += LEGACY_DOUBLE_STAR_REGEX.length;
|
|
21735
|
+
continue;
|
|
21736
|
+
}
|
|
21737
|
+
if (source.startsWith(SINGLE_STAR_REGEX, i)) {
|
|
21738
|
+
glob += "*";
|
|
21739
|
+
i += SINGLE_STAR_REGEX.length;
|
|
21740
|
+
continue;
|
|
21741
|
+
}
|
|
21742
|
+
if (source.startsWith(LEGACY_SINGLE_STAR_REGEX, i)) {
|
|
21743
|
+
glob += "*";
|
|
21744
|
+
i += LEGACY_SINGLE_STAR_REGEX.length;
|
|
21745
|
+
continue;
|
|
21746
|
+
}
|
|
21747
|
+
if (source.startsWith(SINGLE_CHAR_REGEX, i)) {
|
|
21748
|
+
glob += "?";
|
|
21749
|
+
i += SINGLE_CHAR_REGEX.length;
|
|
21750
|
+
continue;
|
|
21208
21751
|
}
|
|
21209
|
-
|
|
21210
|
-
|
|
21211
|
-
|
|
21212
|
-
|
|
21213
|
-
|
|
21752
|
+
const char = source[i];
|
|
21753
|
+
if (char === "\\") {
|
|
21754
|
+
const escaped = source[i + 1];
|
|
21755
|
+
if (escaped !== void 0) {
|
|
21756
|
+
glob += escaped;
|
|
21757
|
+
i += 2;
|
|
21214
21758
|
continue;
|
|
21215
21759
|
}
|
|
21216
|
-
const geminiEntry = pattern === "*" ? mappedToolName : `${mappedToolName}(${pattern})`;
|
|
21217
|
-
if (action === "allow") {
|
|
21218
|
-
allowed.push(geminiEntry);
|
|
21219
|
-
} else {
|
|
21220
|
-
exclude.push(geminiEntry);
|
|
21221
|
-
}
|
|
21222
21760
|
}
|
|
21761
|
+
glob += char ?? "";
|
|
21762
|
+
i += 1;
|
|
21223
21763
|
}
|
|
21224
|
-
return
|
|
21764
|
+
return glob;
|
|
21225
21765
|
}
|
|
21226
|
-
|
|
21227
|
-
|
|
21228
|
-
|
|
21229
|
-
|
|
21230
|
-
|
|
21231
|
-
|
|
21232
|
-
|
|
21233
|
-
|
|
21234
|
-
|
|
21235
|
-
|
|
21236
|
-
|
|
21766
|
+
var GeminicliPolicyRuleSchema = import_mini72.z.looseObject({
|
|
21767
|
+
toolName: import_mini72.z.string(),
|
|
21768
|
+
decision: import_mini72.z.optional(import_mini72.z.unknown()),
|
|
21769
|
+
commandPrefix: import_mini72.z.optional(import_mini72.z.string()),
|
|
21770
|
+
argsPattern: import_mini72.z.optional(import_mini72.z.string())
|
|
21771
|
+
});
|
|
21772
|
+
var GeminicliPolicyFileSchema = import_mini72.z.looseObject({
|
|
21773
|
+
rule: import_mini72.z.optional(import_mini72.z.array(import_mini72.z.looseObject({})))
|
|
21774
|
+
});
|
|
21775
|
+
function extractRules(parsed, logger5) {
|
|
21776
|
+
const parsedFile = GeminicliPolicyFileSchema.safeParse(parsed);
|
|
21777
|
+
if (!parsedFile.success || !parsedFile.data.rule) {
|
|
21778
|
+
return [];
|
|
21779
|
+
}
|
|
21780
|
+
const rules = [];
|
|
21781
|
+
for (const [index, entry] of parsedFile.data.rule.entries()) {
|
|
21782
|
+
const result = GeminicliPolicyRuleSchema.safeParse(entry);
|
|
21783
|
+
if (result.success) {
|
|
21784
|
+
rules.push(result.data);
|
|
21785
|
+
continue;
|
|
21786
|
+
}
|
|
21787
|
+
logger5.warn(
|
|
21788
|
+
`Skipping malformed Gemini CLI policy rule at index ${index}: ${formatError(result.error)}`
|
|
21789
|
+
);
|
|
21790
|
+
}
|
|
21791
|
+
return rules;
|
|
21792
|
+
}
|
|
21793
|
+
function extractPattern(rule) {
|
|
21794
|
+
if (rule.toolName === "run_shell_command") {
|
|
21795
|
+
if (rule.argsPattern) {
|
|
21796
|
+
const stripped = rule.argsPattern.startsWith(COMMAND_ARGS_ANCHOR) ? rule.argsPattern.slice(COMMAND_ARGS_ANCHOR.length) : rule.argsPattern;
|
|
21797
|
+
return regexToGlobPattern(stripped);
|
|
21798
|
+
}
|
|
21799
|
+
if (!rule.commandPrefix) return "*";
|
|
21800
|
+
return rule.commandPrefix.endsWith(" *") || rule.commandPrefix.endsWith("*") ? rule.commandPrefix : `${rule.commandPrefix} *`;
|
|
21801
|
+
}
|
|
21802
|
+
if (!rule.argsPattern) return "*";
|
|
21803
|
+
const regex = rule.argsPattern.startsWith('"') ? rule.argsPattern.slice(1) : rule.argsPattern;
|
|
21804
|
+
return regexToGlobPattern(regex);
|
|
21237
21805
|
}
|
|
21238
21806
|
|
|
21239
21807
|
// src/features/permissions/kiro-permissions.ts
|
|
21240
|
-
var
|
|
21241
|
-
var
|
|
21242
|
-
var KiroAgentSchema =
|
|
21243
|
-
allowedTools:
|
|
21244
|
-
toolsSettings:
|
|
21808
|
+
var import_node_path140 = require("path");
|
|
21809
|
+
var import_mini73 = require("zod/mini");
|
|
21810
|
+
var KiroAgentSchema = import_mini73.z.looseObject({
|
|
21811
|
+
allowedTools: import_mini73.z.optional(import_mini73.z.array(import_mini73.z.string())),
|
|
21812
|
+
toolsSettings: import_mini73.z.optional(import_mini73.z.record(import_mini73.z.string(), import_mini73.z.unknown()))
|
|
21245
21813
|
});
|
|
21246
|
-
var UnknownRecordSchema =
|
|
21814
|
+
var UnknownRecordSchema = import_mini73.z.record(import_mini73.z.string(), import_mini73.z.unknown());
|
|
21247
21815
|
var KiroPermissions = class _KiroPermissions extends ToolPermissions {
|
|
21248
21816
|
static getSettablePaths(_options = {}) {
|
|
21249
21817
|
return {
|
|
21250
|
-
relativeDirPath: (0,
|
|
21818
|
+
relativeDirPath: (0, import_node_path140.join)(".kiro", "agents"),
|
|
21251
21819
|
relativeFilePath: "default.json"
|
|
21252
21820
|
};
|
|
21253
21821
|
}
|
|
@@ -21259,7 +21827,7 @@ var KiroPermissions = class _KiroPermissions extends ToolPermissions {
|
|
|
21259
21827
|
validate = true
|
|
21260
21828
|
}) {
|
|
21261
21829
|
const paths = this.getSettablePaths();
|
|
21262
|
-
const filePath = (0,
|
|
21830
|
+
const filePath = (0, import_node_path140.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
21263
21831
|
const fileContent = await readFileContentOrNull(filePath) ?? JSON.stringify({}, null, 2);
|
|
21264
21832
|
return new _KiroPermissions({
|
|
21265
21833
|
baseDir,
|
|
@@ -21276,7 +21844,7 @@ var KiroPermissions = class _KiroPermissions extends ToolPermissions {
|
|
|
21276
21844
|
logger: logger5
|
|
21277
21845
|
}) {
|
|
21278
21846
|
const paths = this.getSettablePaths();
|
|
21279
|
-
const filePath = (0,
|
|
21847
|
+
const filePath = (0, import_node_path140.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
21280
21848
|
const existingContent = await readFileContentOrNull(filePath) ?? JSON.stringify({}, null, 2);
|
|
21281
21849
|
const parsedResult = KiroAgentSchema.safeParse(JSON.parse(existingContent));
|
|
21282
21850
|
if (!parsedResult.success) {
|
|
@@ -21300,7 +21868,7 @@ var KiroPermissions = class _KiroPermissions extends ToolPermissions {
|
|
|
21300
21868
|
parsed = KiroAgentSchema.parse(JSON.parse(this.getFileContent()));
|
|
21301
21869
|
} catch (error) {
|
|
21302
21870
|
throw new Error(
|
|
21303
|
-
`Failed to parse Kiro permissions content in ${(0,
|
|
21871
|
+
`Failed to parse Kiro permissions content in ${(0, import_node_path140.join)(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${formatError(error)}`,
|
|
21304
21872
|
{ cause: error }
|
|
21305
21873
|
);
|
|
21306
21874
|
}
|
|
@@ -21421,15 +21989,15 @@ function asStringArray(value) {
|
|
|
21421
21989
|
}
|
|
21422
21990
|
|
|
21423
21991
|
// src/features/permissions/opencode-permissions.ts
|
|
21424
|
-
var
|
|
21992
|
+
var import_node_path141 = require("path");
|
|
21425
21993
|
var import_jsonc_parser5 = require("jsonc-parser");
|
|
21426
|
-
var
|
|
21427
|
-
var OpencodePermissionSchema =
|
|
21428
|
-
|
|
21429
|
-
|
|
21994
|
+
var import_mini74 = require("zod/mini");
|
|
21995
|
+
var OpencodePermissionSchema = import_mini74.z.union([
|
|
21996
|
+
import_mini74.z.enum(["allow", "ask", "deny"]),
|
|
21997
|
+
import_mini74.z.record(import_mini74.z.string(), import_mini74.z.enum(["allow", "ask", "deny"]))
|
|
21430
21998
|
]);
|
|
21431
|
-
var OpencodePermissionsConfigSchema =
|
|
21432
|
-
permission:
|
|
21999
|
+
var OpencodePermissionsConfigSchema = import_mini74.z.looseObject({
|
|
22000
|
+
permission: import_mini74.z.optional(import_mini74.z.record(import_mini74.z.string(), OpencodePermissionSchema))
|
|
21433
22001
|
});
|
|
21434
22002
|
var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
|
|
21435
22003
|
json;
|
|
@@ -21446,7 +22014,7 @@ var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
|
|
|
21446
22014
|
static getSettablePaths({
|
|
21447
22015
|
global = false
|
|
21448
22016
|
} = {}) {
|
|
21449
|
-
return global ? { relativeDirPath: (0,
|
|
22017
|
+
return global ? { relativeDirPath: (0, import_node_path141.join)(".config", "opencode"), relativeFilePath: "opencode.json" } : { relativeDirPath: ".", relativeFilePath: "opencode.json" };
|
|
21450
22018
|
}
|
|
21451
22019
|
static async fromFile({
|
|
21452
22020
|
baseDir = process.cwd(),
|
|
@@ -21454,9 +22022,9 @@ var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
|
|
|
21454
22022
|
global = false
|
|
21455
22023
|
}) {
|
|
21456
22024
|
const basePaths = _OpencodePermissions.getSettablePaths({ global });
|
|
21457
|
-
const jsonDir = (0,
|
|
21458
|
-
const jsoncPath = (0,
|
|
21459
|
-
const jsonPath = (0,
|
|
22025
|
+
const jsonDir = (0, import_node_path141.join)(baseDir, basePaths.relativeDirPath);
|
|
22026
|
+
const jsoncPath = (0, import_node_path141.join)(jsonDir, "opencode.jsonc");
|
|
22027
|
+
const jsonPath = (0, import_node_path141.join)(jsonDir, "opencode.json");
|
|
21460
22028
|
let fileContent = await readFileContentOrNull(jsoncPath);
|
|
21461
22029
|
let relativeFilePath = "opencode.jsonc";
|
|
21462
22030
|
if (!fileContent) {
|
|
@@ -21481,9 +22049,9 @@ var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
|
|
|
21481
22049
|
global = false
|
|
21482
22050
|
}) {
|
|
21483
22051
|
const basePaths = _OpencodePermissions.getSettablePaths({ global });
|
|
21484
|
-
const jsonDir = (0,
|
|
21485
|
-
const jsoncPath = (0,
|
|
21486
|
-
const jsonPath = (0,
|
|
22052
|
+
const jsonDir = (0, import_node_path141.join)(baseDir, basePaths.relativeDirPath);
|
|
22053
|
+
const jsoncPath = (0, import_node_path141.join)(jsonDir, "opencode.jsonc");
|
|
22054
|
+
const jsonPath = (0, import_node_path141.join)(jsonDir, "opencode.json");
|
|
21487
22055
|
let fileContent = await readFileContentOrNull(jsoncPath);
|
|
21488
22056
|
let relativeFilePath = "opencode.jsonc";
|
|
21489
22057
|
if (!fileContent) {
|
|
@@ -21560,7 +22128,7 @@ var permissionsProcessorToolTargetTuple = [
|
|
|
21560
22128
|
"kiro",
|
|
21561
22129
|
"opencode"
|
|
21562
22130
|
];
|
|
21563
|
-
var PermissionsProcessorToolTargetSchema =
|
|
22131
|
+
var PermissionsProcessorToolTargetSchema = import_mini75.z.enum(permissionsProcessorToolTargetTuple);
|
|
21564
22132
|
var toolPermissionsFactories = /* @__PURE__ */ new Map([
|
|
21565
22133
|
[
|
|
21566
22134
|
"claudecode",
|
|
@@ -21795,7 +22363,7 @@ function warnUnsupportedTargets(params) {
|
|
|
21795
22363
|
}
|
|
21796
22364
|
}
|
|
21797
22365
|
async function checkRulesyncDirExists(params) {
|
|
21798
|
-
return fileExists((0,
|
|
22366
|
+
return fileExists((0, import_node_path142.join)(params.baseDir, RULESYNC_RELATIVE_DIR_PATH));
|
|
21799
22367
|
}
|
|
21800
22368
|
async function generate(params) {
|
|
21801
22369
|
const { config, logger: logger5 } = params;
|
|
@@ -22265,7 +22833,7 @@ async function generateCommand(logger5, options) {
|
|
|
22265
22833
|
}
|
|
22266
22834
|
|
|
22267
22835
|
// src/cli/commands/gitignore.ts
|
|
22268
|
-
var
|
|
22836
|
+
var import_node_path143 = require("path");
|
|
22269
22837
|
|
|
22270
22838
|
// src/cli/commands/gitignore-entries.ts
|
|
22271
22839
|
var normalizeGitignoreEntryTargets = (target) => {
|
|
@@ -22450,6 +23018,9 @@ var GITIGNORE_ENTRY_REGISTRY = [
|
|
|
22450
23018
|
entry: "**/.rovodev/.rulesync/"
|
|
22451
23019
|
},
|
|
22452
23020
|
{ target: "rovodev", feature: "skills", entry: "**/.agents/skills/" },
|
|
23021
|
+
// Windsurf
|
|
23022
|
+
{ target: "windsurf", feature: "skills", entry: "**/.windsurf/skills/" },
|
|
23023
|
+
{ target: "windsurf", feature: "skills", entry: "**/.codeium/windsurf/skills/" },
|
|
22453
23024
|
// Warp
|
|
22454
23025
|
{ target: "warp", feature: "rules", entry: "**/.warp/" },
|
|
22455
23026
|
{ target: "warp", feature: "rules", entry: "**/WARP.md" }
|
|
@@ -22529,13 +23100,14 @@ var warnInvalidFeatures = (features, logger5) => {
|
|
|
22529
23100
|
}
|
|
22530
23101
|
} else {
|
|
22531
23102
|
for (const feature of Object.keys(targetFeatures)) {
|
|
23103
|
+
if (feature === GITIGNORE_DESTINATION_KEY) continue;
|
|
22532
23104
|
warnOnce(feature);
|
|
22533
23105
|
}
|
|
22534
23106
|
}
|
|
22535
23107
|
}
|
|
22536
23108
|
}
|
|
22537
23109
|
};
|
|
22538
|
-
var
|
|
23110
|
+
var resolveGitignoreEntries = (params) => {
|
|
22539
23111
|
const { targets, features, logger: logger5 } = params ?? {};
|
|
22540
23112
|
if (targets && targets.length > 0) {
|
|
22541
23113
|
warnInvalidTargets(targets, logger5);
|
|
@@ -22551,7 +23123,11 @@ var filterGitignoreEntries = (params) => {
|
|
|
22551
23123
|
if (!isFeatureSelected(tag.feature, selectedTagTargets, features)) continue;
|
|
22552
23124
|
if (seen.has(tag.entry)) continue;
|
|
22553
23125
|
seen.add(tag.entry);
|
|
22554
|
-
result.push(
|
|
23126
|
+
result.push({
|
|
23127
|
+
entry: tag.entry,
|
|
23128
|
+
target: selectedTagTargets,
|
|
23129
|
+
feature: tag.feature
|
|
23130
|
+
});
|
|
22555
23131
|
}
|
|
22556
23132
|
return result;
|
|
22557
23133
|
};
|
|
@@ -22608,48 +23184,129 @@ var removeExistingRulesyncEntries = (content) => {
|
|
|
22608
23184
|
}
|
|
22609
23185
|
return result;
|
|
22610
23186
|
};
|
|
22611
|
-
var
|
|
22612
|
-
|
|
22613
|
-
|
|
22614
|
-
|
|
22615
|
-
|
|
23187
|
+
var groupEntriesByDestination = ({
|
|
23188
|
+
entries,
|
|
23189
|
+
resolveDestination
|
|
23190
|
+
}) => {
|
|
23191
|
+
const gitignore = /* @__PURE__ */ new Set();
|
|
23192
|
+
const gitattributes = /* @__PURE__ */ new Set();
|
|
23193
|
+
for (const entry of entries) {
|
|
23194
|
+
const selectedToolTargets = entry.target.filter(
|
|
23195
|
+
(target) => target !== "common"
|
|
23196
|
+
);
|
|
23197
|
+
const destinations = /* @__PURE__ */ new Set();
|
|
23198
|
+
for (const target of selectedToolTargets) {
|
|
23199
|
+
if (entry.feature === "general") {
|
|
23200
|
+
destinations.add(resolveDestination(target));
|
|
23201
|
+
} else {
|
|
23202
|
+
destinations.add(resolveDestination(target, entry.feature));
|
|
23203
|
+
}
|
|
23204
|
+
}
|
|
23205
|
+
if (destinations.has("gitattributes")) {
|
|
23206
|
+
gitattributes.add(entry.entry);
|
|
23207
|
+
}
|
|
23208
|
+
if (destinations.size === 0 || destinations.has("gitignore")) {
|
|
23209
|
+
gitignore.add(entry.entry);
|
|
23210
|
+
}
|
|
22616
23211
|
}
|
|
22617
|
-
|
|
22618
|
-
|
|
23212
|
+
return {
|
|
23213
|
+
gitignore: [...gitignore],
|
|
23214
|
+
gitattributes: [...gitattributes]
|
|
23215
|
+
};
|
|
23216
|
+
};
|
|
23217
|
+
var gitignoreCommand = async (logger5, options) => {
|
|
23218
|
+
const gitignorePath = (0, import_node_path143.join)(process.cwd(), ".gitignore");
|
|
23219
|
+
const gitattributesPath = (0, import_node_path143.join)(process.cwd(), ".gitattributes");
|
|
23220
|
+
const config = await ConfigResolver.resolve({});
|
|
23221
|
+
const resolvedEntries = resolveGitignoreEntries({
|
|
22619
23222
|
targets: options?.targets,
|
|
22620
23223
|
features: options?.features,
|
|
22621
23224
|
logger: logger5
|
|
22622
23225
|
});
|
|
22623
|
-
const
|
|
22624
|
-
|
|
22625
|
-
|
|
22626
|
-
|
|
22627
|
-
|
|
22628
|
-
|
|
22629
|
-
|
|
23226
|
+
const { gitignore: gitignoreEntries, gitattributes: gitattributesEntries } = groupEntriesByDestination({
|
|
23227
|
+
entries: resolvedEntries,
|
|
23228
|
+
resolveDestination: (target, feature) => {
|
|
23229
|
+
if (feature === void 0 || feature === "general") {
|
|
23230
|
+
return config.getGitignoreDestination(target);
|
|
23231
|
+
}
|
|
23232
|
+
return config.getGitignoreDestination(target, feature);
|
|
23233
|
+
}
|
|
23234
|
+
});
|
|
23235
|
+
const updateRulesyncFile = async ({
|
|
23236
|
+
filePath,
|
|
23237
|
+
entries
|
|
23238
|
+
}) => {
|
|
23239
|
+
let content = "";
|
|
23240
|
+
if (await fileExists(filePath)) {
|
|
23241
|
+
content = await readFileContent(filePath);
|
|
23242
|
+
}
|
|
23243
|
+
const cleanedContent = removeExistingRulesyncEntries(content);
|
|
23244
|
+
const existingEntries = new Set(
|
|
23245
|
+
content.split("\n").map((line) => line.trim()).filter((line) => line !== "" && !isRulesyncHeader(line))
|
|
23246
|
+
);
|
|
23247
|
+
const alreadyExistedEntries = entries.filter((entry) => existingEntries.has(entry));
|
|
23248
|
+
const entriesToAdd = entries.filter((entry) => !existingEntries.has(entry));
|
|
23249
|
+
const rulesyncBlock = [RULESYNC_HEADER, ...entries].join("\n");
|
|
23250
|
+
const newContent = entries.length === 0 ? cleanedContent.trim() ? `${cleanedContent.trimEnd()}
|
|
23251
|
+
` : "" : cleanedContent.trim() ? `${cleanedContent.trimEnd()}
|
|
22630
23252
|
|
|
22631
23253
|
${rulesyncBlock}
|
|
22632
23254
|
` : `${rulesyncBlock}
|
|
22633
23255
|
`;
|
|
22634
|
-
|
|
23256
|
+
if (content === newContent) {
|
|
23257
|
+
return { updated: false, alreadyExistedEntries, entriesToAdd: [] };
|
|
23258
|
+
}
|
|
23259
|
+
await writeFileContent(filePath, newContent);
|
|
23260
|
+
return { updated: true, alreadyExistedEntries, entriesToAdd };
|
|
23261
|
+
};
|
|
23262
|
+
const gitignoreResult = await updateRulesyncFile({
|
|
23263
|
+
filePath: gitignorePath,
|
|
23264
|
+
entries: gitignoreEntries
|
|
23265
|
+
});
|
|
23266
|
+
const gitattributesResult = await updateRulesyncFile({
|
|
23267
|
+
filePath: gitattributesPath,
|
|
23268
|
+
entries: gitattributesEntries
|
|
23269
|
+
});
|
|
23270
|
+
if (!gitignoreResult.updated && !gitattributesResult.updated) {
|
|
22635
23271
|
if (logger5.jsonMode) {
|
|
22636
23272
|
logger5.captureData("entriesAdded", []);
|
|
22637
23273
|
logger5.captureData("gitignorePath", gitignorePath);
|
|
22638
|
-
logger5.captureData("
|
|
23274
|
+
logger5.captureData("gitattributesPath", gitattributesPath);
|
|
23275
|
+
logger5.captureData("alreadyExisted", [...gitignoreEntries, ...gitattributesEntries]);
|
|
22639
23276
|
}
|
|
22640
|
-
logger5.success(".gitignore
|
|
23277
|
+
logger5.success(".gitignore / .gitattributes are already up to date");
|
|
22641
23278
|
return;
|
|
22642
23279
|
}
|
|
22643
|
-
await writeFileContent(gitignorePath, newContent);
|
|
22644
23280
|
if (logger5.jsonMode) {
|
|
22645
|
-
logger5.captureData("entriesAdded",
|
|
23281
|
+
logger5.captureData("entriesAdded", [
|
|
23282
|
+
...gitignoreResult.entriesToAdd,
|
|
23283
|
+
...gitattributesResult.entriesToAdd
|
|
23284
|
+
]);
|
|
22646
23285
|
logger5.captureData("gitignorePath", gitignorePath);
|
|
22647
|
-
logger5.captureData("
|
|
23286
|
+
logger5.captureData("gitattributesPath", gitattributesPath);
|
|
23287
|
+
logger5.captureData("alreadyExisted", [
|
|
23288
|
+
...gitignoreResult.alreadyExistedEntries,
|
|
23289
|
+
...gitattributesResult.alreadyExistedEntries
|
|
23290
|
+
]);
|
|
23291
|
+
}
|
|
23292
|
+
if (gitignoreResult.updated) {
|
|
23293
|
+
logger5.success("Updated .gitignore with rulesync entries:");
|
|
23294
|
+
} else {
|
|
23295
|
+
logger5.success(".gitignore is already up to date");
|
|
22648
23296
|
}
|
|
22649
|
-
|
|
22650
|
-
for (const entry of filteredEntries) {
|
|
23297
|
+
for (const entry of gitignoreEntries) {
|
|
22651
23298
|
logger5.info(` ${entry}`);
|
|
22652
23299
|
}
|
|
23300
|
+
if (gitattributesEntries.length > 0) {
|
|
23301
|
+
if (gitattributesResult.updated) {
|
|
23302
|
+
logger5.success("Updated .gitattributes with rulesync entries:");
|
|
23303
|
+
} else {
|
|
23304
|
+
logger5.success(".gitattributes is already up to date");
|
|
23305
|
+
}
|
|
23306
|
+
for (const entry of gitattributesEntries) {
|
|
23307
|
+
logger5.info(` ${entry}`);
|
|
23308
|
+
}
|
|
23309
|
+
}
|
|
22653
23310
|
logger5.info("");
|
|
22654
23311
|
logger5.info(
|
|
22655
23312
|
"\u{1F4A1} If you're using Google Antigravity, note that rules, workflows, and skills won't load if they're gitignored."
|
|
@@ -22976,7 +23633,7 @@ async function importCommand(logger5, options) {
|
|
|
22976
23633
|
}
|
|
22977
23634
|
|
|
22978
23635
|
// src/lib/init.ts
|
|
22979
|
-
var
|
|
23636
|
+
var import_node_path144 = require("path");
|
|
22980
23637
|
async function init() {
|
|
22981
23638
|
const sampleFiles = await createSampleFiles();
|
|
22982
23639
|
const configFile = await createConfigFile();
|
|
@@ -23169,27 +23826,27 @@ Keep the summary concise and ready to reuse in future tasks.`
|
|
|
23169
23826
|
await ensureDir(subagentPaths.relativeDirPath);
|
|
23170
23827
|
await ensureDir(skillPaths.relativeDirPath);
|
|
23171
23828
|
await ensureDir(ignorePaths.recommended.relativeDirPath);
|
|
23172
|
-
const ruleFilepath = (0,
|
|
23829
|
+
const ruleFilepath = (0, import_node_path144.join)(rulePaths.recommended.relativeDirPath, sampleRuleFile.filename);
|
|
23173
23830
|
results.push(await writeIfNotExists(ruleFilepath, sampleRuleFile.content));
|
|
23174
|
-
const mcpFilepath = (0,
|
|
23831
|
+
const mcpFilepath = (0, import_node_path144.join)(
|
|
23175
23832
|
mcpPaths.recommended.relativeDirPath,
|
|
23176
23833
|
mcpPaths.recommended.relativeFilePath
|
|
23177
23834
|
);
|
|
23178
23835
|
results.push(await writeIfNotExists(mcpFilepath, sampleMcpFile.content));
|
|
23179
|
-
const commandFilepath = (0,
|
|
23836
|
+
const commandFilepath = (0, import_node_path144.join)(commandPaths.relativeDirPath, sampleCommandFile.filename);
|
|
23180
23837
|
results.push(await writeIfNotExists(commandFilepath, sampleCommandFile.content));
|
|
23181
|
-
const subagentFilepath = (0,
|
|
23838
|
+
const subagentFilepath = (0, import_node_path144.join)(subagentPaths.relativeDirPath, sampleSubagentFile.filename);
|
|
23182
23839
|
results.push(await writeIfNotExists(subagentFilepath, sampleSubagentFile.content));
|
|
23183
|
-
const skillDirPath = (0,
|
|
23840
|
+
const skillDirPath = (0, import_node_path144.join)(skillPaths.relativeDirPath, sampleSkillFile.dirName);
|
|
23184
23841
|
await ensureDir(skillDirPath);
|
|
23185
|
-
const skillFilepath = (0,
|
|
23842
|
+
const skillFilepath = (0, import_node_path144.join)(skillDirPath, SKILL_FILE_NAME);
|
|
23186
23843
|
results.push(await writeIfNotExists(skillFilepath, sampleSkillFile.content));
|
|
23187
|
-
const ignoreFilepath = (0,
|
|
23844
|
+
const ignoreFilepath = (0, import_node_path144.join)(
|
|
23188
23845
|
ignorePaths.recommended.relativeDirPath,
|
|
23189
23846
|
ignorePaths.recommended.relativeFilePath
|
|
23190
23847
|
);
|
|
23191
23848
|
results.push(await writeIfNotExists(ignoreFilepath, sampleIgnoreFile.content));
|
|
23192
|
-
const hooksFilepath = (0,
|
|
23849
|
+
const hooksFilepath = (0, import_node_path144.join)(hooksPaths.relativeDirPath, hooksPaths.relativeFilePath);
|
|
23193
23850
|
results.push(await writeIfNotExists(hooksFilepath, sampleHooksFile.content));
|
|
23194
23851
|
return results;
|
|
23195
23852
|
}
|
|
@@ -23237,12 +23894,12 @@ async function initCommand(logger5) {
|
|
|
23237
23894
|
}
|
|
23238
23895
|
|
|
23239
23896
|
// src/lib/sources.ts
|
|
23240
|
-
var
|
|
23897
|
+
var import_node_path147 = require("path");
|
|
23241
23898
|
var import_promise2 = require("es-toolkit/promise");
|
|
23242
23899
|
|
|
23243
23900
|
// src/lib/git-client.ts
|
|
23244
23901
|
var import_node_child_process = require("child_process");
|
|
23245
|
-
var
|
|
23902
|
+
var import_node_path145 = require("path");
|
|
23246
23903
|
var import_node_util2 = require("util");
|
|
23247
23904
|
var execFileAsync = (0, import_node_util2.promisify)(import_node_child_process.execFile);
|
|
23248
23905
|
var GIT_TIMEOUT_MS = 6e4;
|
|
@@ -23330,7 +23987,7 @@ async function fetchSkillFiles(params) {
|
|
|
23330
23987
|
const { url, ref, skillsPath, logger: logger5 } = params;
|
|
23331
23988
|
validateGitUrl(url, { logger: logger5 });
|
|
23332
23989
|
validateRef(ref);
|
|
23333
|
-
if (skillsPath.split(/[/\\]/).includes("..") || (0,
|
|
23990
|
+
if (skillsPath.split(/[/\\]/).includes("..") || (0, import_node_path145.isAbsolute)(skillsPath)) {
|
|
23334
23991
|
throw new GitClientError(
|
|
23335
23992
|
`Invalid skillsPath "${skillsPath}": must be a relative path without ".."`
|
|
23336
23993
|
);
|
|
@@ -23364,7 +24021,7 @@ async function fetchSkillFiles(params) {
|
|
|
23364
24021
|
timeout: GIT_TIMEOUT_MS
|
|
23365
24022
|
});
|
|
23366
24023
|
await execFileAsync("git", ["-C", tmpDir, "checkout"], { timeout: GIT_TIMEOUT_MS });
|
|
23367
|
-
const skillsDir = (0,
|
|
24024
|
+
const skillsDir = (0, import_node_path145.join)(tmpDir, skillsPath);
|
|
23368
24025
|
if (!await directoryExists(skillsDir)) return [];
|
|
23369
24026
|
return await walkDirectory(skillsDir, skillsDir, 0, { totalFiles: 0, totalSize: 0 }, logger5);
|
|
23370
24027
|
} catch (error) {
|
|
@@ -23386,7 +24043,7 @@ async function walkDirectory(dir, baseDir, depth = 0, ctx = { totalFiles: 0, tot
|
|
|
23386
24043
|
const results = [];
|
|
23387
24044
|
for (const name of await listDirectoryFiles(dir)) {
|
|
23388
24045
|
if (name === ".git") continue;
|
|
23389
|
-
const fullPath = (0,
|
|
24046
|
+
const fullPath = (0, import_node_path145.join)(dir, name);
|
|
23390
24047
|
if (await isSymlink(fullPath)) {
|
|
23391
24048
|
logger5?.warn(`Skipping symlink "${fullPath}".`);
|
|
23392
24049
|
continue;
|
|
@@ -23414,7 +24071,7 @@ async function walkDirectory(dir, baseDir, depth = 0, ctx = { totalFiles: 0, tot
|
|
|
23414
24071
|
);
|
|
23415
24072
|
}
|
|
23416
24073
|
const content = await readFileContent(fullPath);
|
|
23417
|
-
results.push({ relativePath: (0,
|
|
24074
|
+
results.push({ relativePath: (0, import_node_path145.relative)(baseDir, fullPath), content, size });
|
|
23418
24075
|
}
|
|
23419
24076
|
}
|
|
23420
24077
|
return results;
|
|
@@ -23422,28 +24079,28 @@ async function walkDirectory(dir, baseDir, depth = 0, ctx = { totalFiles: 0, tot
|
|
|
23422
24079
|
|
|
23423
24080
|
// src/lib/sources-lock.ts
|
|
23424
24081
|
var import_node_crypto = require("crypto");
|
|
23425
|
-
var
|
|
23426
|
-
var
|
|
24082
|
+
var import_node_path146 = require("path");
|
|
24083
|
+
var import_mini76 = require("zod/mini");
|
|
23427
24084
|
var LOCKFILE_VERSION = 1;
|
|
23428
|
-
var LockedSkillSchema =
|
|
23429
|
-
integrity:
|
|
24085
|
+
var LockedSkillSchema = import_mini76.z.object({
|
|
24086
|
+
integrity: import_mini76.z.string()
|
|
23430
24087
|
});
|
|
23431
|
-
var LockedSourceSchema =
|
|
23432
|
-
requestedRef: (0,
|
|
23433
|
-
resolvedRef:
|
|
23434
|
-
resolvedAt: (0,
|
|
23435
|
-
skills:
|
|
24088
|
+
var LockedSourceSchema = import_mini76.z.object({
|
|
24089
|
+
requestedRef: (0, import_mini76.optional)(import_mini76.z.string()),
|
|
24090
|
+
resolvedRef: import_mini76.z.string().check((0, import_mini76.refine)((v) => /^[0-9a-f]{40}$/.test(v), "resolvedRef must be a 40-character hex SHA")),
|
|
24091
|
+
resolvedAt: (0, import_mini76.optional)(import_mini76.z.string()),
|
|
24092
|
+
skills: import_mini76.z.record(import_mini76.z.string(), LockedSkillSchema)
|
|
23436
24093
|
});
|
|
23437
|
-
var SourcesLockSchema =
|
|
23438
|
-
lockfileVersion:
|
|
23439
|
-
sources:
|
|
24094
|
+
var SourcesLockSchema = import_mini76.z.object({
|
|
24095
|
+
lockfileVersion: import_mini76.z.number(),
|
|
24096
|
+
sources: import_mini76.z.record(import_mini76.z.string(), LockedSourceSchema)
|
|
23440
24097
|
});
|
|
23441
|
-
var LegacyLockedSourceSchema =
|
|
23442
|
-
resolvedRef:
|
|
23443
|
-
skills:
|
|
24098
|
+
var LegacyLockedSourceSchema = import_mini76.z.object({
|
|
24099
|
+
resolvedRef: import_mini76.z.string(),
|
|
24100
|
+
skills: import_mini76.z.array(import_mini76.z.string())
|
|
23444
24101
|
});
|
|
23445
|
-
var LegacySourcesLockSchema =
|
|
23446
|
-
sources:
|
|
24102
|
+
var LegacySourcesLockSchema = import_mini76.z.object({
|
|
24103
|
+
sources: import_mini76.z.record(import_mini76.z.string(), LegacyLockedSourceSchema)
|
|
23447
24104
|
});
|
|
23448
24105
|
function migrateLegacyLock(params) {
|
|
23449
24106
|
const { legacy, logger: logger5 } = params;
|
|
@@ -23468,7 +24125,7 @@ function createEmptyLock() {
|
|
|
23468
24125
|
}
|
|
23469
24126
|
async function readLockFile(params) {
|
|
23470
24127
|
const { logger: logger5 } = params;
|
|
23471
|
-
const lockPath = (0,
|
|
24128
|
+
const lockPath = (0, import_node_path146.join)(params.baseDir, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH);
|
|
23472
24129
|
if (!await fileExists(lockPath)) {
|
|
23473
24130
|
logger5.debug("No sources lockfile found, starting fresh.");
|
|
23474
24131
|
return createEmptyLock();
|
|
@@ -23497,7 +24154,7 @@ async function readLockFile(params) {
|
|
|
23497
24154
|
}
|
|
23498
24155
|
async function writeLockFile(params) {
|
|
23499
24156
|
const { logger: logger5 } = params;
|
|
23500
|
-
const lockPath = (0,
|
|
24157
|
+
const lockPath = (0, import_node_path146.join)(params.baseDir, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH);
|
|
23501
24158
|
const content = JSON.stringify(params.lock, null, 2) + "\n";
|
|
23502
24159
|
await writeFileContent(lockPath, content);
|
|
23503
24160
|
logger5.debug(`Wrote sources lockfile to ${lockPath}`);
|
|
@@ -23671,7 +24328,7 @@ function logGitClientHints(params) {
|
|
|
23671
24328
|
async function checkLockedSkillsExist(curatedDir, skillNames) {
|
|
23672
24329
|
if (skillNames.length === 0) return true;
|
|
23673
24330
|
for (const name of skillNames) {
|
|
23674
|
-
if (!await directoryExists((0,
|
|
24331
|
+
if (!await directoryExists((0, import_node_path147.join)(curatedDir, name))) {
|
|
23675
24332
|
return false;
|
|
23676
24333
|
}
|
|
23677
24334
|
}
|
|
@@ -23679,10 +24336,10 @@ async function checkLockedSkillsExist(curatedDir, skillNames) {
|
|
|
23679
24336
|
}
|
|
23680
24337
|
async function cleanPreviousCuratedSkills(params) {
|
|
23681
24338
|
const { curatedDir, lockedSkillNames, logger: logger5 } = params;
|
|
23682
|
-
const resolvedCuratedDir = (0,
|
|
24339
|
+
const resolvedCuratedDir = (0, import_node_path147.resolve)(curatedDir);
|
|
23683
24340
|
for (const prevSkill of lockedSkillNames) {
|
|
23684
|
-
const prevDir = (0,
|
|
23685
|
-
if (!(0,
|
|
24341
|
+
const prevDir = (0, import_node_path147.join)(curatedDir, prevSkill);
|
|
24342
|
+
if (!(0, import_node_path147.resolve)(prevDir).startsWith(resolvedCuratedDir + import_node_path147.sep)) {
|
|
23686
24343
|
logger5.warn(
|
|
23687
24344
|
`Skipping removal of "${prevSkill}": resolved path is outside the curated directory.`
|
|
23688
24345
|
);
|
|
@@ -23721,9 +24378,9 @@ async function writeSkillAndComputeIntegrity(params) {
|
|
|
23721
24378
|
for (const file of files) {
|
|
23722
24379
|
checkPathTraversal({
|
|
23723
24380
|
relativePath: file.relativePath,
|
|
23724
|
-
intendedRootDir: (0,
|
|
24381
|
+
intendedRootDir: (0, import_node_path147.join)(curatedDir, skillName)
|
|
23725
24382
|
});
|
|
23726
|
-
await writeFileContent((0,
|
|
24383
|
+
await writeFileContent((0, import_node_path147.join)(curatedDir, skillName, file.relativePath), file.content);
|
|
23727
24384
|
written.push({ path: file.relativePath, content: file.content });
|
|
23728
24385
|
}
|
|
23729
24386
|
const integrity = computeSkillIntegrity(written);
|
|
@@ -23800,7 +24457,7 @@ async function fetchSource(params) {
|
|
|
23800
24457
|
ref = resolvedSha;
|
|
23801
24458
|
logger5.debug(`Resolved ${sourceKey} ref "${requestedRef}" to SHA: ${resolvedSha}`);
|
|
23802
24459
|
}
|
|
23803
|
-
const curatedDir = (0,
|
|
24460
|
+
const curatedDir = (0, import_node_path147.join)(baseDir, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH);
|
|
23804
24461
|
if (locked && resolvedSha === locked.resolvedRef && !updateSources) {
|
|
23805
24462
|
const allExist = await checkLockedSkillsExist(curatedDir, lockedSkillNames);
|
|
23806
24463
|
if (allExist) {
|
|
@@ -23925,7 +24582,7 @@ async function fetchSourceViaGit(params) {
|
|
|
23925
24582
|
requestedRef = def.ref;
|
|
23926
24583
|
resolvedSha = def.sha;
|
|
23927
24584
|
}
|
|
23928
|
-
const curatedDir = (0,
|
|
24585
|
+
const curatedDir = (0, import_node_path147.join)(baseDir, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH);
|
|
23929
24586
|
if (locked && resolvedSha === locked.resolvedRef && !updateSources) {
|
|
23930
24587
|
if (await checkLockedSkillsExist(curatedDir, lockedSkillNames)) {
|
|
23931
24588
|
return { skillCount: 0, fetchedSkillNames: lockedSkillNames, updatedLock: lock };
|
|
@@ -23958,6 +24615,18 @@ async function fetchSourceViaGit(params) {
|
|
|
23958
24615
|
arr.push({ relativePath: inner, content: file.content });
|
|
23959
24616
|
skillFileMap.set(name, arr);
|
|
23960
24617
|
}
|
|
24618
|
+
if (skillFileMap.size === 0 && !isWildcard && skillFilter.length === 1) {
|
|
24619
|
+
const [singleSkillName] = skillFilter;
|
|
24620
|
+
if (singleSkillName !== void 0) {
|
|
24621
|
+
const rootFiles = remoteFiles.filter((f) => f.relativePath.indexOf("/") === -1);
|
|
24622
|
+
if (rootFiles.length > 0) {
|
|
24623
|
+
skillFileMap.set(
|
|
24624
|
+
singleSkillName,
|
|
24625
|
+
rootFiles.map((f) => ({ relativePath: f.relativePath, content: f.content }))
|
|
24626
|
+
);
|
|
24627
|
+
}
|
|
24628
|
+
}
|
|
24629
|
+
}
|
|
23961
24630
|
const allNames = [...skillFileMap.keys()];
|
|
23962
24631
|
const filteredNames = isWildcard ? allNames : allNames.filter((n) => skillFilter.includes(n));
|
|
23963
24632
|
if (locked) {
|
|
@@ -24041,162 +24710,16 @@ async function installCommand(logger5, options) {
|
|
|
24041
24710
|
var import_fastmcp = require("fastmcp");
|
|
24042
24711
|
|
|
24043
24712
|
// src/mcp/tools.ts
|
|
24044
|
-
var
|
|
24045
|
-
|
|
24046
|
-
// src/mcp/commands.ts
|
|
24047
|
-
var import_node_path147 = require("path");
|
|
24048
|
-
var import_mini76 = require("zod/mini");
|
|
24049
|
-
|
|
24050
|
-
// src/utils/logger.ts
|
|
24051
|
-
var BaseLogger = class {
|
|
24052
|
-
_verbose = false;
|
|
24053
|
-
_silent = false;
|
|
24054
|
-
constructor({ verbose = false, silent = false } = {}) {
|
|
24055
|
-
this._silent = silent;
|
|
24056
|
-
this._verbose = verbose && !silent;
|
|
24057
|
-
}
|
|
24058
|
-
get verbose() {
|
|
24059
|
-
return this._verbose;
|
|
24060
|
-
}
|
|
24061
|
-
get silent() {
|
|
24062
|
-
return this._silent;
|
|
24063
|
-
}
|
|
24064
|
-
configure({ verbose, silent }) {
|
|
24065
|
-
if (verbose && silent) {
|
|
24066
|
-
this._silent = false;
|
|
24067
|
-
if (!isEnvTest()) {
|
|
24068
|
-
this.onConflictingFlags();
|
|
24069
|
-
}
|
|
24070
|
-
}
|
|
24071
|
-
this._silent = silent;
|
|
24072
|
-
this._verbose = verbose && !silent;
|
|
24073
|
-
}
|
|
24074
|
-
onConflictingFlags() {
|
|
24075
|
-
console.warn("Both --verbose and --silent specified; --silent takes precedence");
|
|
24076
|
-
}
|
|
24077
|
-
};
|
|
24078
|
-
var ConsoleLogger = class extends BaseLogger {
|
|
24079
|
-
isSuppressed() {
|
|
24080
|
-
return isEnvTest() || this._silent;
|
|
24081
|
-
}
|
|
24082
|
-
get jsonMode() {
|
|
24083
|
-
return false;
|
|
24084
|
-
}
|
|
24085
|
-
captureData(_key, _value) {
|
|
24086
|
-
}
|
|
24087
|
-
getJsonData() {
|
|
24088
|
-
return {};
|
|
24089
|
-
}
|
|
24090
|
-
outputJson(_success, _error) {
|
|
24091
|
-
}
|
|
24092
|
-
info(message, ...args) {
|
|
24093
|
-
if (this.isSuppressed()) return;
|
|
24094
|
-
console.log(message, ...args);
|
|
24095
|
-
}
|
|
24096
|
-
success(message, ...args) {
|
|
24097
|
-
if (this.isSuppressed()) return;
|
|
24098
|
-
console.log(message, ...args);
|
|
24099
|
-
}
|
|
24100
|
-
warn(message, ...args) {
|
|
24101
|
-
if (this.isSuppressed()) return;
|
|
24102
|
-
console.warn(message, ...args);
|
|
24103
|
-
}
|
|
24104
|
-
// Errors are always emitted, even in silent mode
|
|
24105
|
-
error(message, _code, ...args) {
|
|
24106
|
-
if (isEnvTest()) return;
|
|
24107
|
-
const errorMessage = message instanceof Error ? message.message : message;
|
|
24108
|
-
console.error(errorMessage, ...args);
|
|
24109
|
-
}
|
|
24110
|
-
debug(message, ...args) {
|
|
24111
|
-
if (!this._verbose || this.isSuppressed()) return;
|
|
24112
|
-
console.log(message, ...args);
|
|
24113
|
-
}
|
|
24114
|
-
};
|
|
24115
|
-
var JsonLogger = class extends BaseLogger {
|
|
24116
|
-
_jsonOutputDone = false;
|
|
24117
|
-
_jsonData = {};
|
|
24118
|
-
_commandName;
|
|
24119
|
-
_version;
|
|
24120
|
-
constructor({
|
|
24121
|
-
command,
|
|
24122
|
-
version,
|
|
24123
|
-
verbose = false,
|
|
24124
|
-
silent = false
|
|
24125
|
-
}) {
|
|
24126
|
-
super({ verbose, silent });
|
|
24127
|
-
this._commandName = command;
|
|
24128
|
-
this._version = version;
|
|
24129
|
-
}
|
|
24130
|
-
// Suppress raw console.warn in JSON mode to avoid non-JSON text on stderr
|
|
24131
|
-
onConflictingFlags() {
|
|
24132
|
-
}
|
|
24133
|
-
get jsonMode() {
|
|
24134
|
-
return true;
|
|
24135
|
-
}
|
|
24136
|
-
captureData(key, value) {
|
|
24137
|
-
this._jsonData[key] = value;
|
|
24138
|
-
}
|
|
24139
|
-
getJsonData() {
|
|
24140
|
-
return { ...this._jsonData };
|
|
24141
|
-
}
|
|
24142
|
-
outputJson(success, error) {
|
|
24143
|
-
if (this._jsonOutputDone) return;
|
|
24144
|
-
this._jsonOutputDone = true;
|
|
24145
|
-
const output = {
|
|
24146
|
-
success,
|
|
24147
|
-
timestamp: (/* @__PURE__ */ new Date()).toISOString(),
|
|
24148
|
-
command: this._commandName,
|
|
24149
|
-
version: this._version
|
|
24150
|
-
};
|
|
24151
|
-
if (success) {
|
|
24152
|
-
output.data = this._jsonData;
|
|
24153
|
-
} else if (error) {
|
|
24154
|
-
output.error = {
|
|
24155
|
-
code: error.code,
|
|
24156
|
-
message: error.message
|
|
24157
|
-
};
|
|
24158
|
-
if (error.details) {
|
|
24159
|
-
output.error.details = error.details;
|
|
24160
|
-
}
|
|
24161
|
-
if (error.stack) {
|
|
24162
|
-
output.error.stack = error.stack;
|
|
24163
|
-
}
|
|
24164
|
-
}
|
|
24165
|
-
const jsonStr = JSON.stringify(output, null, 2);
|
|
24166
|
-
if (success) {
|
|
24167
|
-
console.log(jsonStr);
|
|
24168
|
-
} else {
|
|
24169
|
-
console.error(jsonStr);
|
|
24170
|
-
}
|
|
24171
|
-
}
|
|
24172
|
-
info(_message, ..._args) {
|
|
24173
|
-
}
|
|
24174
|
-
success(_message, ..._args) {
|
|
24175
|
-
}
|
|
24176
|
-
warn(_message, ..._args) {
|
|
24177
|
-
}
|
|
24178
|
-
error(message, code, ..._args) {
|
|
24179
|
-
if (isEnvTest()) return;
|
|
24180
|
-
const errorMessage = message instanceof Error ? message.message : message;
|
|
24181
|
-
const errorInfo = {
|
|
24182
|
-
code: code || ErrorCodes.UNKNOWN_ERROR,
|
|
24183
|
-
message: errorMessage
|
|
24184
|
-
};
|
|
24185
|
-
if (this._verbose && message instanceof Error && message.stack) {
|
|
24186
|
-
errorInfo.stack = message.stack;
|
|
24187
|
-
}
|
|
24188
|
-
this.outputJson(false, errorInfo);
|
|
24189
|
-
}
|
|
24190
|
-
debug(_message, ..._args) {
|
|
24191
|
-
}
|
|
24192
|
-
};
|
|
24713
|
+
var import_mini85 = require("zod/mini");
|
|
24193
24714
|
|
|
24194
24715
|
// src/mcp/commands.ts
|
|
24716
|
+
var import_node_path148 = require("path");
|
|
24717
|
+
var import_mini77 = require("zod/mini");
|
|
24195
24718
|
var logger = new ConsoleLogger({ verbose: false, silent: true });
|
|
24196
24719
|
var maxCommandSizeBytes = 1024 * 1024;
|
|
24197
24720
|
var maxCommandsCount = 1e3;
|
|
24198
24721
|
async function listCommands() {
|
|
24199
|
-
const commandsDir = (0,
|
|
24722
|
+
const commandsDir = (0, import_node_path148.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
24200
24723
|
try {
|
|
24201
24724
|
const files = await listDirectoryFiles(commandsDir);
|
|
24202
24725
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -24212,7 +24735,7 @@ async function listCommands() {
|
|
|
24212
24735
|
});
|
|
24213
24736
|
const frontmatter = command.getFrontmatter();
|
|
24214
24737
|
return {
|
|
24215
|
-
relativePathFromCwd: (0,
|
|
24738
|
+
relativePathFromCwd: (0, import_node_path148.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, file),
|
|
24216
24739
|
frontmatter
|
|
24217
24740
|
};
|
|
24218
24741
|
} catch (error) {
|
|
@@ -24234,13 +24757,13 @@ async function getCommand({ relativePathFromCwd }) {
|
|
|
24234
24757
|
relativePath: relativePathFromCwd,
|
|
24235
24758
|
intendedRootDir: process.cwd()
|
|
24236
24759
|
});
|
|
24237
|
-
const filename = (0,
|
|
24760
|
+
const filename = (0, import_node_path148.basename)(relativePathFromCwd);
|
|
24238
24761
|
try {
|
|
24239
24762
|
const command = await RulesyncCommand.fromFile({
|
|
24240
24763
|
relativeFilePath: filename
|
|
24241
24764
|
});
|
|
24242
24765
|
return {
|
|
24243
|
-
relativePathFromCwd: (0,
|
|
24766
|
+
relativePathFromCwd: (0, import_node_path148.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
24244
24767
|
frontmatter: command.getFrontmatter(),
|
|
24245
24768
|
body: command.getBody()
|
|
24246
24769
|
};
|
|
@@ -24259,7 +24782,7 @@ async function putCommand({
|
|
|
24259
24782
|
relativePath: relativePathFromCwd,
|
|
24260
24783
|
intendedRootDir: process.cwd()
|
|
24261
24784
|
});
|
|
24262
|
-
const filename = (0,
|
|
24785
|
+
const filename = (0, import_node_path148.basename)(relativePathFromCwd);
|
|
24263
24786
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
24264
24787
|
if (estimatedSize > maxCommandSizeBytes) {
|
|
24265
24788
|
throw new Error(
|
|
@@ -24269,7 +24792,7 @@ async function putCommand({
|
|
|
24269
24792
|
try {
|
|
24270
24793
|
const existingCommands = await listCommands();
|
|
24271
24794
|
const isUpdate = existingCommands.some(
|
|
24272
|
-
(command2) => command2.relativePathFromCwd === (0,
|
|
24795
|
+
(command2) => command2.relativePathFromCwd === (0, import_node_path148.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
24273
24796
|
);
|
|
24274
24797
|
if (!isUpdate && existingCommands.length >= maxCommandsCount) {
|
|
24275
24798
|
throw new Error(
|
|
@@ -24286,11 +24809,11 @@ async function putCommand({
|
|
|
24286
24809
|
fileContent,
|
|
24287
24810
|
validate: true
|
|
24288
24811
|
});
|
|
24289
|
-
const commandsDir = (0,
|
|
24812
|
+
const commandsDir = (0, import_node_path148.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
24290
24813
|
await ensureDir(commandsDir);
|
|
24291
24814
|
await writeFileContent(command.getFilePath(), command.getFileContent());
|
|
24292
24815
|
return {
|
|
24293
|
-
relativePathFromCwd: (0,
|
|
24816
|
+
relativePathFromCwd: (0, import_node_path148.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
24294
24817
|
frontmatter: command.getFrontmatter(),
|
|
24295
24818
|
body: command.getBody()
|
|
24296
24819
|
};
|
|
@@ -24305,12 +24828,12 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
24305
24828
|
relativePath: relativePathFromCwd,
|
|
24306
24829
|
intendedRootDir: process.cwd()
|
|
24307
24830
|
});
|
|
24308
|
-
const filename = (0,
|
|
24309
|
-
const fullPath = (0,
|
|
24831
|
+
const filename = (0, import_node_path148.basename)(relativePathFromCwd);
|
|
24832
|
+
const fullPath = (0, import_node_path148.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename);
|
|
24310
24833
|
try {
|
|
24311
24834
|
await removeFile(fullPath);
|
|
24312
24835
|
return {
|
|
24313
|
-
relativePathFromCwd: (0,
|
|
24836
|
+
relativePathFromCwd: (0, import_node_path148.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
24314
24837
|
};
|
|
24315
24838
|
} catch (error) {
|
|
24316
24839
|
throw new Error(`Failed to delete command file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -24319,23 +24842,23 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
24319
24842
|
}
|
|
24320
24843
|
}
|
|
24321
24844
|
var commandToolSchemas = {
|
|
24322
|
-
listCommands:
|
|
24323
|
-
getCommand:
|
|
24324
|
-
relativePathFromCwd:
|
|
24845
|
+
listCommands: import_mini77.z.object({}),
|
|
24846
|
+
getCommand: import_mini77.z.object({
|
|
24847
|
+
relativePathFromCwd: import_mini77.z.string()
|
|
24325
24848
|
}),
|
|
24326
|
-
putCommand:
|
|
24327
|
-
relativePathFromCwd:
|
|
24849
|
+
putCommand: import_mini77.z.object({
|
|
24850
|
+
relativePathFromCwd: import_mini77.z.string(),
|
|
24328
24851
|
frontmatter: RulesyncCommandFrontmatterSchema,
|
|
24329
|
-
body:
|
|
24852
|
+
body: import_mini77.z.string()
|
|
24330
24853
|
}),
|
|
24331
|
-
deleteCommand:
|
|
24332
|
-
relativePathFromCwd:
|
|
24854
|
+
deleteCommand: import_mini77.z.object({
|
|
24855
|
+
relativePathFromCwd: import_mini77.z.string()
|
|
24333
24856
|
})
|
|
24334
24857
|
};
|
|
24335
24858
|
var commandTools = {
|
|
24336
24859
|
listCommands: {
|
|
24337
24860
|
name: "listCommands",
|
|
24338
|
-
description: `List all commands from ${(0,
|
|
24861
|
+
description: `List all commands from ${(0, import_node_path148.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
24339
24862
|
parameters: commandToolSchemas.listCommands,
|
|
24340
24863
|
execute: async () => {
|
|
24341
24864
|
const commands = await listCommands();
|
|
@@ -24377,15 +24900,15 @@ var commandTools = {
|
|
|
24377
24900
|
};
|
|
24378
24901
|
|
|
24379
24902
|
// src/mcp/generate.ts
|
|
24380
|
-
var
|
|
24381
|
-
var generateOptionsSchema =
|
|
24382
|
-
targets:
|
|
24383
|
-
features:
|
|
24384
|
-
delete:
|
|
24385
|
-
global:
|
|
24386
|
-
simulateCommands:
|
|
24387
|
-
simulateSubagents:
|
|
24388
|
-
simulateSkills:
|
|
24903
|
+
var import_mini78 = require("zod/mini");
|
|
24904
|
+
var generateOptionsSchema = import_mini78.z.object({
|
|
24905
|
+
targets: import_mini78.z.optional(import_mini78.z.array(import_mini78.z.string())),
|
|
24906
|
+
features: import_mini78.z.optional(import_mini78.z.array(import_mini78.z.string())),
|
|
24907
|
+
delete: import_mini78.z.optional(import_mini78.z.boolean()),
|
|
24908
|
+
global: import_mini78.z.optional(import_mini78.z.boolean()),
|
|
24909
|
+
simulateCommands: import_mini78.z.optional(import_mini78.z.boolean()),
|
|
24910
|
+
simulateSubagents: import_mini78.z.optional(import_mini78.z.boolean()),
|
|
24911
|
+
simulateSkills: import_mini78.z.optional(import_mini78.z.boolean())
|
|
24389
24912
|
});
|
|
24390
24913
|
async function executeGenerate(options = {}) {
|
|
24391
24914
|
try {
|
|
@@ -24464,11 +24987,11 @@ var generateTools = {
|
|
|
24464
24987
|
};
|
|
24465
24988
|
|
|
24466
24989
|
// src/mcp/ignore.ts
|
|
24467
|
-
var
|
|
24468
|
-
var
|
|
24990
|
+
var import_node_path149 = require("path");
|
|
24991
|
+
var import_mini79 = require("zod/mini");
|
|
24469
24992
|
var maxIgnoreFileSizeBytes = 100 * 1024;
|
|
24470
24993
|
async function getIgnoreFile() {
|
|
24471
|
-
const ignoreFilePath = (0,
|
|
24994
|
+
const ignoreFilePath = (0, import_node_path149.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
24472
24995
|
try {
|
|
24473
24996
|
const content = await readFileContent(ignoreFilePath);
|
|
24474
24997
|
return {
|
|
@@ -24485,7 +25008,7 @@ async function getIgnoreFile() {
|
|
|
24485
25008
|
}
|
|
24486
25009
|
}
|
|
24487
25010
|
async function putIgnoreFile({ content }) {
|
|
24488
|
-
const ignoreFilePath = (0,
|
|
25011
|
+
const ignoreFilePath = (0, import_node_path149.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
24489
25012
|
const contentSizeBytes = Buffer.byteLength(content, "utf8");
|
|
24490
25013
|
if (contentSizeBytes > maxIgnoreFileSizeBytes) {
|
|
24491
25014
|
throw new Error(
|
|
@@ -24509,8 +25032,8 @@ async function putIgnoreFile({ content }) {
|
|
|
24509
25032
|
}
|
|
24510
25033
|
}
|
|
24511
25034
|
async function deleteIgnoreFile() {
|
|
24512
|
-
const aiignorePath = (0,
|
|
24513
|
-
const legacyIgnorePath = (0,
|
|
25035
|
+
const aiignorePath = (0, import_node_path149.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
25036
|
+
const legacyIgnorePath = (0, import_node_path149.join)(process.cwd(), RULESYNC_IGNORE_RELATIVE_FILE_PATH);
|
|
24514
25037
|
try {
|
|
24515
25038
|
await Promise.all([removeFile(aiignorePath), removeFile(legacyIgnorePath)]);
|
|
24516
25039
|
return {
|
|
@@ -24528,11 +25051,11 @@ async function deleteIgnoreFile() {
|
|
|
24528
25051
|
}
|
|
24529
25052
|
}
|
|
24530
25053
|
var ignoreToolSchemas = {
|
|
24531
|
-
getIgnoreFile:
|
|
24532
|
-
putIgnoreFile:
|
|
24533
|
-
content:
|
|
25054
|
+
getIgnoreFile: import_mini79.z.object({}),
|
|
25055
|
+
putIgnoreFile: import_mini79.z.object({
|
|
25056
|
+
content: import_mini79.z.string()
|
|
24534
25057
|
}),
|
|
24535
|
-
deleteIgnoreFile:
|
|
25058
|
+
deleteIgnoreFile: import_mini79.z.object({})
|
|
24536
25059
|
};
|
|
24537
25060
|
var ignoreTools = {
|
|
24538
25061
|
getIgnoreFile: {
|
|
@@ -24565,11 +25088,11 @@ var ignoreTools = {
|
|
|
24565
25088
|
};
|
|
24566
25089
|
|
|
24567
25090
|
// src/mcp/import.ts
|
|
24568
|
-
var
|
|
24569
|
-
var importOptionsSchema =
|
|
24570
|
-
target:
|
|
24571
|
-
features:
|
|
24572
|
-
global:
|
|
25091
|
+
var import_mini80 = require("zod/mini");
|
|
25092
|
+
var importOptionsSchema = import_mini80.z.object({
|
|
25093
|
+
target: import_mini80.z.string(),
|
|
25094
|
+
features: import_mini80.z.optional(import_mini80.z.array(import_mini80.z.string())),
|
|
25095
|
+
global: import_mini80.z.optional(import_mini80.z.boolean())
|
|
24573
25096
|
});
|
|
24574
25097
|
async function executeImport(options) {
|
|
24575
25098
|
try {
|
|
@@ -24640,15 +25163,15 @@ var importTools = {
|
|
|
24640
25163
|
};
|
|
24641
25164
|
|
|
24642
25165
|
// src/mcp/mcp.ts
|
|
24643
|
-
var
|
|
24644
|
-
var
|
|
25166
|
+
var import_node_path150 = require("path");
|
|
25167
|
+
var import_mini81 = require("zod/mini");
|
|
24645
25168
|
var maxMcpSizeBytes = 1024 * 1024;
|
|
24646
25169
|
async function getMcpFile() {
|
|
24647
25170
|
try {
|
|
24648
25171
|
const rulesyncMcp = await RulesyncMcp.fromFile({
|
|
24649
25172
|
validate: true
|
|
24650
25173
|
});
|
|
24651
|
-
const relativePathFromCwd = (0,
|
|
25174
|
+
const relativePathFromCwd = (0, import_node_path150.join)(
|
|
24652
25175
|
rulesyncMcp.getRelativeDirPath(),
|
|
24653
25176
|
rulesyncMcp.getRelativeFilePath()
|
|
24654
25177
|
);
|
|
@@ -24686,7 +25209,7 @@ async function putMcpFile({ content }) {
|
|
|
24686
25209
|
const paths = RulesyncMcp.getSettablePaths();
|
|
24687
25210
|
const relativeDirPath = paths.recommended.relativeDirPath;
|
|
24688
25211
|
const relativeFilePath = paths.recommended.relativeFilePath;
|
|
24689
|
-
const fullPath = (0,
|
|
25212
|
+
const fullPath = (0, import_node_path150.join)(baseDir, relativeDirPath, relativeFilePath);
|
|
24690
25213
|
const rulesyncMcp = new RulesyncMcp({
|
|
24691
25214
|
baseDir,
|
|
24692
25215
|
relativeDirPath,
|
|
@@ -24694,9 +25217,9 @@ async function putMcpFile({ content }) {
|
|
|
24694
25217
|
fileContent: content,
|
|
24695
25218
|
validate: true
|
|
24696
25219
|
});
|
|
24697
|
-
await ensureDir((0,
|
|
25220
|
+
await ensureDir((0, import_node_path150.join)(baseDir, relativeDirPath));
|
|
24698
25221
|
await writeFileContent(fullPath, content);
|
|
24699
|
-
const relativePathFromCwd = (0,
|
|
25222
|
+
const relativePathFromCwd = (0, import_node_path150.join)(relativeDirPath, relativeFilePath);
|
|
24700
25223
|
return {
|
|
24701
25224
|
relativePathFromCwd,
|
|
24702
25225
|
content: rulesyncMcp.getFileContent()
|
|
@@ -24714,15 +25237,15 @@ async function deleteMcpFile() {
|
|
|
24714
25237
|
try {
|
|
24715
25238
|
const baseDir = process.cwd();
|
|
24716
25239
|
const paths = RulesyncMcp.getSettablePaths();
|
|
24717
|
-
const recommendedPath = (0,
|
|
25240
|
+
const recommendedPath = (0, import_node_path150.join)(
|
|
24718
25241
|
baseDir,
|
|
24719
25242
|
paths.recommended.relativeDirPath,
|
|
24720
25243
|
paths.recommended.relativeFilePath
|
|
24721
25244
|
);
|
|
24722
|
-
const legacyPath = (0,
|
|
25245
|
+
const legacyPath = (0, import_node_path150.join)(baseDir, paths.legacy.relativeDirPath, paths.legacy.relativeFilePath);
|
|
24723
25246
|
await removeFile(recommendedPath);
|
|
24724
25247
|
await removeFile(legacyPath);
|
|
24725
|
-
const relativePathFromCwd = (0,
|
|
25248
|
+
const relativePathFromCwd = (0, import_node_path150.join)(
|
|
24726
25249
|
paths.recommended.relativeDirPath,
|
|
24727
25250
|
paths.recommended.relativeFilePath
|
|
24728
25251
|
);
|
|
@@ -24739,11 +25262,11 @@ async function deleteMcpFile() {
|
|
|
24739
25262
|
}
|
|
24740
25263
|
}
|
|
24741
25264
|
var mcpToolSchemas = {
|
|
24742
|
-
getMcpFile:
|
|
24743
|
-
putMcpFile:
|
|
24744
|
-
content:
|
|
25265
|
+
getMcpFile: import_mini81.z.object({}),
|
|
25266
|
+
putMcpFile: import_mini81.z.object({
|
|
25267
|
+
content: import_mini81.z.string()
|
|
24745
25268
|
}),
|
|
24746
|
-
deleteMcpFile:
|
|
25269
|
+
deleteMcpFile: import_mini81.z.object({})
|
|
24747
25270
|
};
|
|
24748
25271
|
var mcpTools = {
|
|
24749
25272
|
getMcpFile: {
|
|
@@ -24776,13 +25299,13 @@ var mcpTools = {
|
|
|
24776
25299
|
};
|
|
24777
25300
|
|
|
24778
25301
|
// src/mcp/rules.ts
|
|
24779
|
-
var
|
|
24780
|
-
var
|
|
25302
|
+
var import_node_path151 = require("path");
|
|
25303
|
+
var import_mini82 = require("zod/mini");
|
|
24781
25304
|
var logger2 = new ConsoleLogger({ verbose: false, silent: true });
|
|
24782
25305
|
var maxRuleSizeBytes = 1024 * 1024;
|
|
24783
25306
|
var maxRulesCount = 1e3;
|
|
24784
25307
|
async function listRules() {
|
|
24785
|
-
const rulesDir = (0,
|
|
25308
|
+
const rulesDir = (0, import_node_path151.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
24786
25309
|
try {
|
|
24787
25310
|
const files = await listDirectoryFiles(rulesDir);
|
|
24788
25311
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -24795,7 +25318,7 @@ async function listRules() {
|
|
|
24795
25318
|
});
|
|
24796
25319
|
const frontmatter = rule.getFrontmatter();
|
|
24797
25320
|
return {
|
|
24798
|
-
relativePathFromCwd: (0,
|
|
25321
|
+
relativePathFromCwd: (0, import_node_path151.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, file),
|
|
24799
25322
|
frontmatter
|
|
24800
25323
|
};
|
|
24801
25324
|
} catch (error) {
|
|
@@ -24817,14 +25340,14 @@ async function getRule({ relativePathFromCwd }) {
|
|
|
24817
25340
|
relativePath: relativePathFromCwd,
|
|
24818
25341
|
intendedRootDir: process.cwd()
|
|
24819
25342
|
});
|
|
24820
|
-
const filename = (0,
|
|
25343
|
+
const filename = (0, import_node_path151.basename)(relativePathFromCwd);
|
|
24821
25344
|
try {
|
|
24822
25345
|
const rule = await RulesyncRule.fromFile({
|
|
24823
25346
|
relativeFilePath: filename,
|
|
24824
25347
|
validate: true
|
|
24825
25348
|
});
|
|
24826
25349
|
return {
|
|
24827
|
-
relativePathFromCwd: (0,
|
|
25350
|
+
relativePathFromCwd: (0, import_node_path151.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
24828
25351
|
frontmatter: rule.getFrontmatter(),
|
|
24829
25352
|
body: rule.getBody()
|
|
24830
25353
|
};
|
|
@@ -24843,7 +25366,7 @@ async function putRule({
|
|
|
24843
25366
|
relativePath: relativePathFromCwd,
|
|
24844
25367
|
intendedRootDir: process.cwd()
|
|
24845
25368
|
});
|
|
24846
|
-
const filename = (0,
|
|
25369
|
+
const filename = (0, import_node_path151.basename)(relativePathFromCwd);
|
|
24847
25370
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
24848
25371
|
if (estimatedSize > maxRuleSizeBytes) {
|
|
24849
25372
|
throw new Error(
|
|
@@ -24853,7 +25376,7 @@ async function putRule({
|
|
|
24853
25376
|
try {
|
|
24854
25377
|
const existingRules = await listRules();
|
|
24855
25378
|
const isUpdate = existingRules.some(
|
|
24856
|
-
(rule2) => rule2.relativePathFromCwd === (0,
|
|
25379
|
+
(rule2) => rule2.relativePathFromCwd === (0, import_node_path151.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
24857
25380
|
);
|
|
24858
25381
|
if (!isUpdate && existingRules.length >= maxRulesCount) {
|
|
24859
25382
|
throw new Error(
|
|
@@ -24868,11 +25391,11 @@ async function putRule({
|
|
|
24868
25391
|
body,
|
|
24869
25392
|
validate: true
|
|
24870
25393
|
});
|
|
24871
|
-
const rulesDir = (0,
|
|
25394
|
+
const rulesDir = (0, import_node_path151.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
24872
25395
|
await ensureDir(rulesDir);
|
|
24873
25396
|
await writeFileContent(rule.getFilePath(), rule.getFileContent());
|
|
24874
25397
|
return {
|
|
24875
|
-
relativePathFromCwd: (0,
|
|
25398
|
+
relativePathFromCwd: (0, import_node_path151.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
24876
25399
|
frontmatter: rule.getFrontmatter(),
|
|
24877
25400
|
body: rule.getBody()
|
|
24878
25401
|
};
|
|
@@ -24887,12 +25410,12 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
24887
25410
|
relativePath: relativePathFromCwd,
|
|
24888
25411
|
intendedRootDir: process.cwd()
|
|
24889
25412
|
});
|
|
24890
|
-
const filename = (0,
|
|
24891
|
-
const fullPath = (0,
|
|
25413
|
+
const filename = (0, import_node_path151.basename)(relativePathFromCwd);
|
|
25414
|
+
const fullPath = (0, import_node_path151.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH, filename);
|
|
24892
25415
|
try {
|
|
24893
25416
|
await removeFile(fullPath);
|
|
24894
25417
|
return {
|
|
24895
|
-
relativePathFromCwd: (0,
|
|
25418
|
+
relativePathFromCwd: (0, import_node_path151.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
24896
25419
|
};
|
|
24897
25420
|
} catch (error) {
|
|
24898
25421
|
throw new Error(`Failed to delete rule file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -24901,23 +25424,23 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
24901
25424
|
}
|
|
24902
25425
|
}
|
|
24903
25426
|
var ruleToolSchemas = {
|
|
24904
|
-
listRules:
|
|
24905
|
-
getRule:
|
|
24906
|
-
relativePathFromCwd:
|
|
25427
|
+
listRules: import_mini82.z.object({}),
|
|
25428
|
+
getRule: import_mini82.z.object({
|
|
25429
|
+
relativePathFromCwd: import_mini82.z.string()
|
|
24907
25430
|
}),
|
|
24908
|
-
putRule:
|
|
24909
|
-
relativePathFromCwd:
|
|
25431
|
+
putRule: import_mini82.z.object({
|
|
25432
|
+
relativePathFromCwd: import_mini82.z.string(),
|
|
24910
25433
|
frontmatter: RulesyncRuleFrontmatterSchema,
|
|
24911
|
-
body:
|
|
25434
|
+
body: import_mini82.z.string()
|
|
24912
25435
|
}),
|
|
24913
|
-
deleteRule:
|
|
24914
|
-
relativePathFromCwd:
|
|
25436
|
+
deleteRule: import_mini82.z.object({
|
|
25437
|
+
relativePathFromCwd: import_mini82.z.string()
|
|
24915
25438
|
})
|
|
24916
25439
|
};
|
|
24917
25440
|
var ruleTools = {
|
|
24918
25441
|
listRules: {
|
|
24919
25442
|
name: "listRules",
|
|
24920
|
-
description: `List all rules from ${(0,
|
|
25443
|
+
description: `List all rules from ${(0, import_node_path151.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
24921
25444
|
parameters: ruleToolSchemas.listRules,
|
|
24922
25445
|
execute: async () => {
|
|
24923
25446
|
const rules = await listRules();
|
|
@@ -24959,8 +25482,8 @@ var ruleTools = {
|
|
|
24959
25482
|
};
|
|
24960
25483
|
|
|
24961
25484
|
// src/mcp/skills.ts
|
|
24962
|
-
var
|
|
24963
|
-
var
|
|
25485
|
+
var import_node_path152 = require("path");
|
|
25486
|
+
var import_mini83 = require("zod/mini");
|
|
24964
25487
|
var logger3 = new ConsoleLogger({ verbose: false, silent: true });
|
|
24965
25488
|
var maxSkillSizeBytes = 1024 * 1024;
|
|
24966
25489
|
var maxSkillsCount = 1e3;
|
|
@@ -24977,19 +25500,19 @@ function mcpSkillFileToAiDirFile(file) {
|
|
|
24977
25500
|
};
|
|
24978
25501
|
}
|
|
24979
25502
|
function extractDirName(relativeDirPathFromCwd) {
|
|
24980
|
-
const dirName = (0,
|
|
25503
|
+
const dirName = (0, import_node_path152.basename)(relativeDirPathFromCwd);
|
|
24981
25504
|
if (!dirName) {
|
|
24982
25505
|
throw new Error(`Invalid path: ${relativeDirPathFromCwd}`);
|
|
24983
25506
|
}
|
|
24984
25507
|
return dirName;
|
|
24985
25508
|
}
|
|
24986
25509
|
async function listSkills() {
|
|
24987
|
-
const skillsDir = (0,
|
|
25510
|
+
const skillsDir = (0, import_node_path152.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH);
|
|
24988
25511
|
try {
|
|
24989
|
-
const skillDirPaths = await findFilesByGlobs((0,
|
|
25512
|
+
const skillDirPaths = await findFilesByGlobs((0, import_node_path152.join)(skillsDir, "*"), { type: "dir" });
|
|
24990
25513
|
const skills = await Promise.all(
|
|
24991
25514
|
skillDirPaths.map(async (dirPath) => {
|
|
24992
|
-
const dirName = (0,
|
|
25515
|
+
const dirName = (0, import_node_path152.basename)(dirPath);
|
|
24993
25516
|
if (!dirName) return null;
|
|
24994
25517
|
try {
|
|
24995
25518
|
const skill = await RulesyncSkill.fromDir({
|
|
@@ -24997,7 +25520,7 @@ async function listSkills() {
|
|
|
24997
25520
|
});
|
|
24998
25521
|
const frontmatter = skill.getFrontmatter();
|
|
24999
25522
|
return {
|
|
25000
|
-
relativeDirPathFromCwd: (0,
|
|
25523
|
+
relativeDirPathFromCwd: (0, import_node_path152.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
25001
25524
|
frontmatter
|
|
25002
25525
|
};
|
|
25003
25526
|
} catch (error) {
|
|
@@ -25025,7 +25548,7 @@ async function getSkill({ relativeDirPathFromCwd }) {
|
|
|
25025
25548
|
dirName
|
|
25026
25549
|
});
|
|
25027
25550
|
return {
|
|
25028
|
-
relativeDirPathFromCwd: (0,
|
|
25551
|
+
relativeDirPathFromCwd: (0, import_node_path152.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
25029
25552
|
frontmatter: skill.getFrontmatter(),
|
|
25030
25553
|
body: skill.getBody(),
|
|
25031
25554
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -25059,7 +25582,7 @@ async function putSkill({
|
|
|
25059
25582
|
try {
|
|
25060
25583
|
const existingSkills = await listSkills();
|
|
25061
25584
|
const isUpdate = existingSkills.some(
|
|
25062
|
-
(skill2) => skill2.relativeDirPathFromCwd === (0,
|
|
25585
|
+
(skill2) => skill2.relativeDirPathFromCwd === (0, import_node_path152.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
25063
25586
|
);
|
|
25064
25587
|
if (!isUpdate && existingSkills.length >= maxSkillsCount) {
|
|
25065
25588
|
throw new Error(
|
|
@@ -25076,9 +25599,9 @@ async function putSkill({
|
|
|
25076
25599
|
otherFiles: aiDirFiles,
|
|
25077
25600
|
validate: true
|
|
25078
25601
|
});
|
|
25079
|
-
const skillDirPath = (0,
|
|
25602
|
+
const skillDirPath = (0, import_node_path152.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
25080
25603
|
await ensureDir(skillDirPath);
|
|
25081
|
-
const skillFilePath = (0,
|
|
25604
|
+
const skillFilePath = (0, import_node_path152.join)(skillDirPath, SKILL_FILE_NAME);
|
|
25082
25605
|
const skillFileContent = stringifyFrontmatter(body, frontmatter);
|
|
25083
25606
|
await writeFileContent(skillFilePath, skillFileContent);
|
|
25084
25607
|
for (const file of otherFiles) {
|
|
@@ -25086,15 +25609,15 @@ async function putSkill({
|
|
|
25086
25609
|
relativePath: file.name,
|
|
25087
25610
|
intendedRootDir: skillDirPath
|
|
25088
25611
|
});
|
|
25089
|
-
const filePath = (0,
|
|
25090
|
-
const fileDir = (0,
|
|
25612
|
+
const filePath = (0, import_node_path152.join)(skillDirPath, file.name);
|
|
25613
|
+
const fileDir = (0, import_node_path152.join)(skillDirPath, (0, import_node_path152.dirname)(file.name));
|
|
25091
25614
|
if (fileDir !== skillDirPath) {
|
|
25092
25615
|
await ensureDir(fileDir);
|
|
25093
25616
|
}
|
|
25094
25617
|
await writeFileContent(filePath, file.body);
|
|
25095
25618
|
}
|
|
25096
25619
|
return {
|
|
25097
|
-
relativeDirPathFromCwd: (0,
|
|
25620
|
+
relativeDirPathFromCwd: (0, import_node_path152.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
25098
25621
|
frontmatter: skill.getFrontmatter(),
|
|
25099
25622
|
body: skill.getBody(),
|
|
25100
25623
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -25116,13 +25639,13 @@ async function deleteSkill({
|
|
|
25116
25639
|
intendedRootDir: process.cwd()
|
|
25117
25640
|
});
|
|
25118
25641
|
const dirName = extractDirName(relativeDirPathFromCwd);
|
|
25119
|
-
const skillDirPath = (0,
|
|
25642
|
+
const skillDirPath = (0, import_node_path152.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
25120
25643
|
try {
|
|
25121
25644
|
if (await directoryExists(skillDirPath)) {
|
|
25122
25645
|
await removeDirectory(skillDirPath);
|
|
25123
25646
|
}
|
|
25124
25647
|
return {
|
|
25125
|
-
relativeDirPathFromCwd: (0,
|
|
25648
|
+
relativeDirPathFromCwd: (0, import_node_path152.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
25126
25649
|
};
|
|
25127
25650
|
} catch (error) {
|
|
25128
25651
|
throw new Error(
|
|
@@ -25133,29 +25656,29 @@ async function deleteSkill({
|
|
|
25133
25656
|
);
|
|
25134
25657
|
}
|
|
25135
25658
|
}
|
|
25136
|
-
var McpSkillFileSchema =
|
|
25137
|
-
name:
|
|
25138
|
-
body:
|
|
25659
|
+
var McpSkillFileSchema = import_mini83.z.object({
|
|
25660
|
+
name: import_mini83.z.string(),
|
|
25661
|
+
body: import_mini83.z.string()
|
|
25139
25662
|
});
|
|
25140
25663
|
var skillToolSchemas = {
|
|
25141
|
-
listSkills:
|
|
25142
|
-
getSkill:
|
|
25143
|
-
relativeDirPathFromCwd:
|
|
25664
|
+
listSkills: import_mini83.z.object({}),
|
|
25665
|
+
getSkill: import_mini83.z.object({
|
|
25666
|
+
relativeDirPathFromCwd: import_mini83.z.string()
|
|
25144
25667
|
}),
|
|
25145
|
-
putSkill:
|
|
25146
|
-
relativeDirPathFromCwd:
|
|
25668
|
+
putSkill: import_mini83.z.object({
|
|
25669
|
+
relativeDirPathFromCwd: import_mini83.z.string(),
|
|
25147
25670
|
frontmatter: RulesyncSkillFrontmatterSchema,
|
|
25148
|
-
body:
|
|
25149
|
-
otherFiles:
|
|
25671
|
+
body: import_mini83.z.string(),
|
|
25672
|
+
otherFiles: import_mini83.z.optional(import_mini83.z.array(McpSkillFileSchema))
|
|
25150
25673
|
}),
|
|
25151
|
-
deleteSkill:
|
|
25152
|
-
relativeDirPathFromCwd:
|
|
25674
|
+
deleteSkill: import_mini83.z.object({
|
|
25675
|
+
relativeDirPathFromCwd: import_mini83.z.string()
|
|
25153
25676
|
})
|
|
25154
25677
|
};
|
|
25155
25678
|
var skillTools = {
|
|
25156
25679
|
listSkills: {
|
|
25157
25680
|
name: "listSkills",
|
|
25158
|
-
description: `List all skills from ${(0,
|
|
25681
|
+
description: `List all skills from ${(0, import_node_path152.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "*", SKILL_FILE_NAME)} with their frontmatter.`,
|
|
25159
25682
|
parameters: skillToolSchemas.listSkills,
|
|
25160
25683
|
execute: async () => {
|
|
25161
25684
|
const skills = await listSkills();
|
|
@@ -25198,13 +25721,13 @@ var skillTools = {
|
|
|
25198
25721
|
};
|
|
25199
25722
|
|
|
25200
25723
|
// src/mcp/subagents.ts
|
|
25201
|
-
var
|
|
25202
|
-
var
|
|
25724
|
+
var import_node_path153 = require("path");
|
|
25725
|
+
var import_mini84 = require("zod/mini");
|
|
25203
25726
|
var logger4 = new ConsoleLogger({ verbose: false, silent: true });
|
|
25204
25727
|
var maxSubagentSizeBytes = 1024 * 1024;
|
|
25205
25728
|
var maxSubagentsCount = 1e3;
|
|
25206
25729
|
async function listSubagents() {
|
|
25207
|
-
const subagentsDir = (0,
|
|
25730
|
+
const subagentsDir = (0, import_node_path153.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
25208
25731
|
try {
|
|
25209
25732
|
const files = await listDirectoryFiles(subagentsDir);
|
|
25210
25733
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -25217,7 +25740,7 @@ async function listSubagents() {
|
|
|
25217
25740
|
});
|
|
25218
25741
|
const frontmatter = subagent.getFrontmatter();
|
|
25219
25742
|
return {
|
|
25220
|
-
relativePathFromCwd: (0,
|
|
25743
|
+
relativePathFromCwd: (0, import_node_path153.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, file),
|
|
25221
25744
|
frontmatter
|
|
25222
25745
|
};
|
|
25223
25746
|
} catch (error) {
|
|
@@ -25241,14 +25764,14 @@ async function getSubagent({ relativePathFromCwd }) {
|
|
|
25241
25764
|
relativePath: relativePathFromCwd,
|
|
25242
25765
|
intendedRootDir: process.cwd()
|
|
25243
25766
|
});
|
|
25244
|
-
const filename = (0,
|
|
25767
|
+
const filename = (0, import_node_path153.basename)(relativePathFromCwd);
|
|
25245
25768
|
try {
|
|
25246
25769
|
const subagent = await RulesyncSubagent.fromFile({
|
|
25247
25770
|
relativeFilePath: filename,
|
|
25248
25771
|
validate: true
|
|
25249
25772
|
});
|
|
25250
25773
|
return {
|
|
25251
|
-
relativePathFromCwd: (0,
|
|
25774
|
+
relativePathFromCwd: (0, import_node_path153.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
25252
25775
|
frontmatter: subagent.getFrontmatter(),
|
|
25253
25776
|
body: subagent.getBody()
|
|
25254
25777
|
};
|
|
@@ -25267,7 +25790,7 @@ async function putSubagent({
|
|
|
25267
25790
|
relativePath: relativePathFromCwd,
|
|
25268
25791
|
intendedRootDir: process.cwd()
|
|
25269
25792
|
});
|
|
25270
|
-
const filename = (0,
|
|
25793
|
+
const filename = (0, import_node_path153.basename)(relativePathFromCwd);
|
|
25271
25794
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
25272
25795
|
if (estimatedSize > maxSubagentSizeBytes) {
|
|
25273
25796
|
throw new Error(
|
|
@@ -25277,7 +25800,7 @@ async function putSubagent({
|
|
|
25277
25800
|
try {
|
|
25278
25801
|
const existingSubagents = await listSubagents();
|
|
25279
25802
|
const isUpdate = existingSubagents.some(
|
|
25280
|
-
(subagent2) => subagent2.relativePathFromCwd === (0,
|
|
25803
|
+
(subagent2) => subagent2.relativePathFromCwd === (0, import_node_path153.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
25281
25804
|
);
|
|
25282
25805
|
if (!isUpdate && existingSubagents.length >= maxSubagentsCount) {
|
|
25283
25806
|
throw new Error(
|
|
@@ -25292,11 +25815,11 @@ async function putSubagent({
|
|
|
25292
25815
|
body,
|
|
25293
25816
|
validate: true
|
|
25294
25817
|
});
|
|
25295
|
-
const subagentsDir = (0,
|
|
25818
|
+
const subagentsDir = (0, import_node_path153.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
25296
25819
|
await ensureDir(subagentsDir);
|
|
25297
25820
|
await writeFileContent(subagent.getFilePath(), subagent.getFileContent());
|
|
25298
25821
|
return {
|
|
25299
|
-
relativePathFromCwd: (0,
|
|
25822
|
+
relativePathFromCwd: (0, import_node_path153.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
25300
25823
|
frontmatter: subagent.getFrontmatter(),
|
|
25301
25824
|
body: subagent.getBody()
|
|
25302
25825
|
};
|
|
@@ -25311,12 +25834,12 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
25311
25834
|
relativePath: relativePathFromCwd,
|
|
25312
25835
|
intendedRootDir: process.cwd()
|
|
25313
25836
|
});
|
|
25314
|
-
const filename = (0,
|
|
25315
|
-
const fullPath = (0,
|
|
25837
|
+
const filename = (0, import_node_path153.basename)(relativePathFromCwd);
|
|
25838
|
+
const fullPath = (0, import_node_path153.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename);
|
|
25316
25839
|
try {
|
|
25317
25840
|
await removeFile(fullPath);
|
|
25318
25841
|
return {
|
|
25319
|
-
relativePathFromCwd: (0,
|
|
25842
|
+
relativePathFromCwd: (0, import_node_path153.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
25320
25843
|
};
|
|
25321
25844
|
} catch (error) {
|
|
25322
25845
|
throw new Error(
|
|
@@ -25328,23 +25851,23 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
25328
25851
|
}
|
|
25329
25852
|
}
|
|
25330
25853
|
var subagentToolSchemas = {
|
|
25331
|
-
listSubagents:
|
|
25332
|
-
getSubagent:
|
|
25333
|
-
relativePathFromCwd:
|
|
25854
|
+
listSubagents: import_mini84.z.object({}),
|
|
25855
|
+
getSubagent: import_mini84.z.object({
|
|
25856
|
+
relativePathFromCwd: import_mini84.z.string()
|
|
25334
25857
|
}),
|
|
25335
|
-
putSubagent:
|
|
25336
|
-
relativePathFromCwd:
|
|
25858
|
+
putSubagent: import_mini84.z.object({
|
|
25859
|
+
relativePathFromCwd: import_mini84.z.string(),
|
|
25337
25860
|
frontmatter: RulesyncSubagentFrontmatterSchema,
|
|
25338
|
-
body:
|
|
25861
|
+
body: import_mini84.z.string()
|
|
25339
25862
|
}),
|
|
25340
|
-
deleteSubagent:
|
|
25341
|
-
relativePathFromCwd:
|
|
25863
|
+
deleteSubagent: import_mini84.z.object({
|
|
25864
|
+
relativePathFromCwd: import_mini84.z.string()
|
|
25342
25865
|
})
|
|
25343
25866
|
};
|
|
25344
25867
|
var subagentTools = {
|
|
25345
25868
|
listSubagents: {
|
|
25346
25869
|
name: "listSubagents",
|
|
25347
|
-
description: `List all subagents from ${(0,
|
|
25870
|
+
description: `List all subagents from ${(0, import_node_path153.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
25348
25871
|
parameters: subagentToolSchemas.listSubagents,
|
|
25349
25872
|
execute: async () => {
|
|
25350
25873
|
const subagents = await listSubagents();
|
|
@@ -25386,7 +25909,7 @@ var subagentTools = {
|
|
|
25386
25909
|
};
|
|
25387
25910
|
|
|
25388
25911
|
// src/mcp/tools.ts
|
|
25389
|
-
var rulesyncFeatureSchema =
|
|
25912
|
+
var rulesyncFeatureSchema = import_mini85.z.enum([
|
|
25390
25913
|
"rule",
|
|
25391
25914
|
"command",
|
|
25392
25915
|
"subagent",
|
|
@@ -25396,21 +25919,21 @@ var rulesyncFeatureSchema = import_mini84.z.enum([
|
|
|
25396
25919
|
"generate",
|
|
25397
25920
|
"import"
|
|
25398
25921
|
]);
|
|
25399
|
-
var rulesyncOperationSchema =
|
|
25400
|
-
var skillFileSchema =
|
|
25401
|
-
name:
|
|
25402
|
-
body:
|
|
25922
|
+
var rulesyncOperationSchema = import_mini85.z.enum(["list", "get", "put", "delete", "run"]);
|
|
25923
|
+
var skillFileSchema = import_mini85.z.object({
|
|
25924
|
+
name: import_mini85.z.string(),
|
|
25925
|
+
body: import_mini85.z.string()
|
|
25403
25926
|
});
|
|
25404
|
-
var rulesyncToolSchema =
|
|
25927
|
+
var rulesyncToolSchema = import_mini85.z.object({
|
|
25405
25928
|
feature: rulesyncFeatureSchema,
|
|
25406
25929
|
operation: rulesyncOperationSchema,
|
|
25407
|
-
targetPathFromCwd:
|
|
25408
|
-
frontmatter:
|
|
25409
|
-
body:
|
|
25410
|
-
otherFiles:
|
|
25411
|
-
content:
|
|
25412
|
-
generateOptions:
|
|
25413
|
-
importOptions:
|
|
25930
|
+
targetPathFromCwd: import_mini85.z.optional(import_mini85.z.string()),
|
|
25931
|
+
frontmatter: import_mini85.z.optional(import_mini85.z.unknown()),
|
|
25932
|
+
body: import_mini85.z.optional(import_mini85.z.string()),
|
|
25933
|
+
otherFiles: import_mini85.z.optional(import_mini85.z.array(skillFileSchema)),
|
|
25934
|
+
content: import_mini85.z.optional(import_mini85.z.string()),
|
|
25935
|
+
generateOptions: import_mini85.z.optional(generateOptionsSchema),
|
|
25936
|
+
importOptions: import_mini85.z.optional(importOptionsSchema)
|
|
25414
25937
|
});
|
|
25415
25938
|
var supportedOperationsByFeature = {
|
|
25416
25939
|
rule: ["list", "get", "put", "delete"],
|
|
@@ -25617,7 +26140,7 @@ async function mcpCommand(logger5, { version }) {
|
|
|
25617
26140
|
}
|
|
25618
26141
|
|
|
25619
26142
|
// src/cli/commands/resolve-gitignore-targets.ts
|
|
25620
|
-
var
|
|
26143
|
+
var import_node_path154 = require("path");
|
|
25621
26144
|
var resolveGitignoreTargets = async ({
|
|
25622
26145
|
cliTargets,
|
|
25623
26146
|
cwd = process.cwd()
|
|
@@ -25625,8 +26148,8 @@ var resolveGitignoreTargets = async ({
|
|
|
25625
26148
|
if (cliTargets !== void 0) {
|
|
25626
26149
|
return cliTargets;
|
|
25627
26150
|
}
|
|
25628
|
-
const baseConfigPath = (0,
|
|
25629
|
-
const localConfigPath = (0,
|
|
26151
|
+
const baseConfigPath = (0, import_node_path154.join)(cwd, RULESYNC_CONFIG_RELATIVE_FILE_PATH);
|
|
26152
|
+
const localConfigPath = (0, import_node_path154.join)(cwd, RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH);
|
|
25630
26153
|
const [hasBase, hasLocal] = await Promise.all([
|
|
25631
26154
|
fileExists(baseConfigPath),
|
|
25632
26155
|
fileExists(localConfigPath)
|
|
@@ -26047,7 +26570,7 @@ function wrapCommand({
|
|
|
26047
26570
|
}
|
|
26048
26571
|
|
|
26049
26572
|
// src/cli/index.ts
|
|
26050
|
-
var getVersion = () => "8.
|
|
26573
|
+
var getVersion = () => "8.6.0";
|
|
26051
26574
|
function wrapCommand2(name, errorCode, handler) {
|
|
26052
26575
|
return wrapCommand({ name, errorCode, handler, getVersion });
|
|
26053
26576
|
}
|