rulesync 3.31.0 → 3.32.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/README.md +28 -0
- package/dist/index.cjs +578 -305
- package/dist/index.js +562 -289
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -252,17 +252,18 @@ var ALL_TOOL_TARGETS = [
|
|
|
252
252
|
"antigravity",
|
|
253
253
|
"augmentcode",
|
|
254
254
|
"augmentcode-legacy",
|
|
255
|
-
"copilot",
|
|
256
|
-
"cursor",
|
|
257
|
-
"cline",
|
|
258
255
|
"claudecode",
|
|
256
|
+
"claudecode-legacy",
|
|
257
|
+
"cline",
|
|
259
258
|
"codexcli",
|
|
259
|
+
"copilot",
|
|
260
|
+
"cursor",
|
|
261
|
+
"geminicli",
|
|
262
|
+
"junie",
|
|
263
|
+
"kiro",
|
|
260
264
|
"opencode",
|
|
261
265
|
"qwencode",
|
|
262
266
|
"roo",
|
|
263
|
-
"geminicli",
|
|
264
|
-
"kiro",
|
|
265
|
-
"junie",
|
|
266
267
|
"warp",
|
|
267
268
|
"windsurf"
|
|
268
269
|
];
|
|
@@ -295,6 +296,11 @@ var ConfigFileSchema = import_mini3.z.object({
|
|
|
295
296
|
...import_mini3.z.partial(ConfigParamsSchema).shape
|
|
296
297
|
});
|
|
297
298
|
var RequiredConfigParamsSchema = import_mini3.z.required(ConfigParamsSchema);
|
|
299
|
+
var CONFLICTING_TARGET_PAIRS = [
|
|
300
|
+
["augmentcode", "augmentcode-legacy"],
|
|
301
|
+
["claudecode", "claudecode-legacy"]
|
|
302
|
+
];
|
|
303
|
+
var LEGACY_TARGETS = ["augmentcode-legacy", "claudecode-legacy"];
|
|
298
304
|
var Config = class {
|
|
299
305
|
baseDirs;
|
|
300
306
|
targets;
|
|
@@ -321,6 +327,7 @@ var Config = class {
|
|
|
321
327
|
experimentalSimulateCommands,
|
|
322
328
|
experimentalSimulateSubagents
|
|
323
329
|
}) {
|
|
330
|
+
this.validateConflictingTargets(targets);
|
|
324
331
|
this.baseDirs = baseDirs;
|
|
325
332
|
this.targets = targets;
|
|
326
333
|
this.features = features;
|
|
@@ -332,12 +339,26 @@ var Config = class {
|
|
|
332
339
|
this.simulateSkills = simulateSkills ?? false;
|
|
333
340
|
this.modularMcp = modularMcp ?? false;
|
|
334
341
|
}
|
|
342
|
+
validateConflictingTargets(targets) {
|
|
343
|
+
for (const [target1, target2] of CONFLICTING_TARGET_PAIRS) {
|
|
344
|
+
const hasTarget1 = targets.includes(target1);
|
|
345
|
+
const hasTarget2 = targets.includes(target2);
|
|
346
|
+
if (hasTarget1 && hasTarget2) {
|
|
347
|
+
throw new Error(
|
|
348
|
+
`Conflicting targets: '${target1}' and '${target2}' cannot be used together. Please choose one.`
|
|
349
|
+
);
|
|
350
|
+
}
|
|
351
|
+
}
|
|
352
|
+
}
|
|
335
353
|
getBaseDirs() {
|
|
336
354
|
return this.baseDirs;
|
|
337
355
|
}
|
|
338
356
|
getTargets() {
|
|
339
357
|
if (this.targets.includes("*")) {
|
|
340
|
-
return
|
|
358
|
+
return ALL_TOOL_TARGETS.filter(
|
|
359
|
+
// eslint-disable-next-line no-type-assertion/no-type-assertion
|
|
360
|
+
(target) => !LEGACY_TARGETS.includes(target)
|
|
361
|
+
);
|
|
341
362
|
}
|
|
342
363
|
return this.targets.filter((target) => target !== "*");
|
|
343
364
|
}
|
|
@@ -4237,9 +4258,9 @@ var McpProcessor = class extends FeatureProcessor {
|
|
|
4237
4258
|
};
|
|
4238
4259
|
|
|
4239
4260
|
// src/features/rules/rules-processor.ts
|
|
4240
|
-
var
|
|
4261
|
+
var import_node_path84 = require("path");
|
|
4241
4262
|
var import_toon = require("@toon-format/toon");
|
|
4242
|
-
var
|
|
4263
|
+
var import_mini33 = require("zod/mini");
|
|
4243
4264
|
|
|
4244
4265
|
// src/features/skills/codexcli-skill.ts
|
|
4245
4266
|
var import_node_path44 = require("path");
|
|
@@ -6085,6 +6106,13 @@ var RulesyncRuleFrontmatterSchema = import_mini28.z.object({
|
|
|
6085
6106
|
subprojectPath: import_mini28.z.optional(import_mini28.z.string())
|
|
6086
6107
|
})
|
|
6087
6108
|
),
|
|
6109
|
+
claudecode: import_mini28.z.optional(
|
|
6110
|
+
import_mini28.z.object({
|
|
6111
|
+
// Glob patterns for conditional rules (takes precedence over globs)
|
|
6112
|
+
// @example "src/**/*.ts, tests/**/*.test.ts"
|
|
6113
|
+
paths: import_mini28.z.optional(import_mini28.z.string())
|
|
6114
|
+
})
|
|
6115
|
+
),
|
|
6088
6116
|
cursor: import_mini28.z.optional(
|
|
6089
6117
|
import_mini28.z.object({
|
|
6090
6118
|
alwaysApply: import_mini28.z.optional(import_mini28.z.boolean()),
|
|
@@ -6648,9 +6676,9 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
6648
6676
|
}
|
|
6649
6677
|
};
|
|
6650
6678
|
|
|
6651
|
-
// src/features/rules/claudecode-rule.ts
|
|
6679
|
+
// src/features/rules/claudecode-legacy-rule.ts
|
|
6652
6680
|
var import_node_path70 = require("path");
|
|
6653
|
-
var
|
|
6681
|
+
var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
6654
6682
|
static getSettablePaths({
|
|
6655
6683
|
global
|
|
6656
6684
|
} = {}) {
|
|
@@ -6685,7 +6713,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
6685
6713
|
const fileContent2 = await readFileContent(
|
|
6686
6714
|
(0, import_node_path70.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
6687
6715
|
);
|
|
6688
|
-
return new
|
|
6716
|
+
return new _ClaudecodeLegacyRule({
|
|
6689
6717
|
baseDir,
|
|
6690
6718
|
relativeDirPath: paths.root.relativeDirPath,
|
|
6691
6719
|
relativeFilePath: paths.root.relativeFilePath,
|
|
@@ -6699,7 +6727,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
6699
6727
|
}
|
|
6700
6728
|
const relativePath = (0, import_node_path70.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
6701
6729
|
const fileContent = await readFileContent((0, import_node_path70.join)(baseDir, relativePath));
|
|
6702
|
-
return new
|
|
6730
|
+
return new _ClaudecodeLegacyRule({
|
|
6703
6731
|
baseDir,
|
|
6704
6732
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
6705
6733
|
relativeFilePath,
|
|
@@ -6715,7 +6743,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
6715
6743
|
global = false
|
|
6716
6744
|
}) {
|
|
6717
6745
|
const paths = this.getSettablePaths({ global });
|
|
6718
|
-
return new
|
|
6746
|
+
return new _ClaudecodeLegacyRule(
|
|
6719
6747
|
this.buildToolRuleParamsDefault({
|
|
6720
6748
|
baseDir,
|
|
6721
6749
|
rulesyncRule,
|
|
@@ -6734,16 +6762,208 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
6734
6762
|
static isTargetedByRulesyncRule(rulesyncRule) {
|
|
6735
6763
|
return this.isTargetedByRulesyncRuleDefault({
|
|
6736
6764
|
rulesyncRule,
|
|
6737
|
-
toolTarget: "claudecode"
|
|
6765
|
+
toolTarget: "claudecode-legacy"
|
|
6738
6766
|
});
|
|
6739
6767
|
}
|
|
6740
6768
|
};
|
|
6741
6769
|
|
|
6742
|
-
// src/features/rules/
|
|
6770
|
+
// src/features/rules/claudecode-rule.ts
|
|
6743
6771
|
var import_node_path71 = require("path");
|
|
6744
6772
|
var import_mini29 = require("zod/mini");
|
|
6745
|
-
var
|
|
6746
|
-
|
|
6773
|
+
var ClaudecodeRuleFrontmatterSchema = import_mini29.z.object({
|
|
6774
|
+
paths: import_mini29.z.optional(import_mini29.z.string())
|
|
6775
|
+
});
|
|
6776
|
+
var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
6777
|
+
frontmatter;
|
|
6778
|
+
body;
|
|
6779
|
+
static getSettablePaths({
|
|
6780
|
+
global
|
|
6781
|
+
} = {}) {
|
|
6782
|
+
if (global) {
|
|
6783
|
+
return {
|
|
6784
|
+
root: {
|
|
6785
|
+
relativeDirPath: ".claude",
|
|
6786
|
+
relativeFilePath: "CLAUDE.md"
|
|
6787
|
+
}
|
|
6788
|
+
};
|
|
6789
|
+
}
|
|
6790
|
+
return {
|
|
6791
|
+
root: {
|
|
6792
|
+
relativeDirPath: ".claude",
|
|
6793
|
+
relativeFilePath: "CLAUDE.md"
|
|
6794
|
+
},
|
|
6795
|
+
nonRoot: {
|
|
6796
|
+
relativeDirPath: (0, import_node_path71.join)(".claude", "rules")
|
|
6797
|
+
}
|
|
6798
|
+
};
|
|
6799
|
+
}
|
|
6800
|
+
constructor({ frontmatter, body, ...rest }) {
|
|
6801
|
+
if (rest.validate) {
|
|
6802
|
+
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
6803
|
+
if (!result.success) {
|
|
6804
|
+
throw new Error(
|
|
6805
|
+
`Invalid frontmatter in ${(0, import_node_path71.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6806
|
+
);
|
|
6807
|
+
}
|
|
6808
|
+
}
|
|
6809
|
+
super({
|
|
6810
|
+
...rest,
|
|
6811
|
+
// Root file: no frontmatter; Non-root file: with optional paths frontmatter
|
|
6812
|
+
fileContent: rest.root ? body : _ClaudecodeRule.generateFileContent(body, frontmatter)
|
|
6813
|
+
});
|
|
6814
|
+
this.frontmatter = frontmatter;
|
|
6815
|
+
this.body = body;
|
|
6816
|
+
}
|
|
6817
|
+
static generateFileContent(body, frontmatter) {
|
|
6818
|
+
if (frontmatter.paths) {
|
|
6819
|
+
return stringifyFrontmatter(body, { paths: frontmatter.paths });
|
|
6820
|
+
}
|
|
6821
|
+
return body;
|
|
6822
|
+
}
|
|
6823
|
+
static async fromFile({
|
|
6824
|
+
baseDir = process.cwd(),
|
|
6825
|
+
relativeFilePath,
|
|
6826
|
+
validate = true,
|
|
6827
|
+
global = false
|
|
6828
|
+
}) {
|
|
6829
|
+
const paths = this.getSettablePaths({ global });
|
|
6830
|
+
const isRoot = relativeFilePath === paths.root.relativeFilePath;
|
|
6831
|
+
if (isRoot) {
|
|
6832
|
+
const fileContent2 = await readFileContent(
|
|
6833
|
+
(0, import_node_path71.join)(baseDir, paths.root.relativeDirPath, paths.root.relativeFilePath)
|
|
6834
|
+
);
|
|
6835
|
+
return new _ClaudecodeRule({
|
|
6836
|
+
baseDir,
|
|
6837
|
+
relativeDirPath: paths.root.relativeDirPath,
|
|
6838
|
+
relativeFilePath: paths.root.relativeFilePath,
|
|
6839
|
+
frontmatter: {},
|
|
6840
|
+
body: fileContent2.trim(),
|
|
6841
|
+
validate,
|
|
6842
|
+
root: true
|
|
6843
|
+
});
|
|
6844
|
+
}
|
|
6845
|
+
if (!paths.nonRoot) {
|
|
6846
|
+
throw new Error("nonRoot path is not set");
|
|
6847
|
+
}
|
|
6848
|
+
const relativePath = (0, import_node_path71.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
6849
|
+
const fileContent = await readFileContent((0, import_node_path71.join)(baseDir, relativePath));
|
|
6850
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
6851
|
+
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
6852
|
+
if (!result.success) {
|
|
6853
|
+
throw new Error(
|
|
6854
|
+
`Invalid frontmatter in ${(0, import_node_path71.join)(baseDir, relativePath)}: ${formatError(result.error)}`
|
|
6855
|
+
);
|
|
6856
|
+
}
|
|
6857
|
+
return new _ClaudecodeRule({
|
|
6858
|
+
baseDir,
|
|
6859
|
+
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
6860
|
+
relativeFilePath,
|
|
6861
|
+
frontmatter: result.data,
|
|
6862
|
+
body: content.trim(),
|
|
6863
|
+
validate,
|
|
6864
|
+
root: false
|
|
6865
|
+
});
|
|
6866
|
+
}
|
|
6867
|
+
static fromRulesyncRule({
|
|
6868
|
+
baseDir = process.cwd(),
|
|
6869
|
+
rulesyncRule,
|
|
6870
|
+
validate = true,
|
|
6871
|
+
global = false
|
|
6872
|
+
}) {
|
|
6873
|
+
const rulesyncFrontmatter = rulesyncRule.getFrontmatter();
|
|
6874
|
+
const root = rulesyncFrontmatter.root ?? false;
|
|
6875
|
+
const paths = this.getSettablePaths({ global });
|
|
6876
|
+
const claudecodePaths = rulesyncFrontmatter.claudecode?.paths;
|
|
6877
|
+
const globs = rulesyncFrontmatter.globs;
|
|
6878
|
+
const pathsValue = claudecodePaths ?? (globs?.length ? globs.join(", ") : void 0);
|
|
6879
|
+
const claudecodeFrontmatter = {
|
|
6880
|
+
paths: root ? void 0 : pathsValue
|
|
6881
|
+
};
|
|
6882
|
+
const body = rulesyncRule.getBody();
|
|
6883
|
+
if (root) {
|
|
6884
|
+
return new _ClaudecodeRule({
|
|
6885
|
+
baseDir,
|
|
6886
|
+
frontmatter: claudecodeFrontmatter,
|
|
6887
|
+
body,
|
|
6888
|
+
relativeDirPath: paths.root.relativeDirPath,
|
|
6889
|
+
relativeFilePath: paths.root.relativeFilePath,
|
|
6890
|
+
validate,
|
|
6891
|
+
root
|
|
6892
|
+
});
|
|
6893
|
+
}
|
|
6894
|
+
if (!paths.nonRoot) {
|
|
6895
|
+
throw new Error("nonRoot path is not set");
|
|
6896
|
+
}
|
|
6897
|
+
return new _ClaudecodeRule({
|
|
6898
|
+
baseDir,
|
|
6899
|
+
frontmatter: claudecodeFrontmatter,
|
|
6900
|
+
body,
|
|
6901
|
+
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
6902
|
+
relativeFilePath: rulesyncRule.getRelativeFilePath(),
|
|
6903
|
+
validate,
|
|
6904
|
+
root
|
|
6905
|
+
});
|
|
6906
|
+
}
|
|
6907
|
+
toRulesyncRule() {
|
|
6908
|
+
let globs;
|
|
6909
|
+
if (this.isRoot()) {
|
|
6910
|
+
globs = ["**/*"];
|
|
6911
|
+
} else if (this.frontmatter.paths) {
|
|
6912
|
+
globs = this.frontmatter.paths.split(",").map((g) => g.trim());
|
|
6913
|
+
}
|
|
6914
|
+
const rulesyncFrontmatter = {
|
|
6915
|
+
targets: ["*"],
|
|
6916
|
+
root: this.isRoot(),
|
|
6917
|
+
description: this.description,
|
|
6918
|
+
globs,
|
|
6919
|
+
...this.frontmatter.paths && {
|
|
6920
|
+
claudecode: { paths: this.frontmatter.paths }
|
|
6921
|
+
}
|
|
6922
|
+
};
|
|
6923
|
+
return new RulesyncRule({
|
|
6924
|
+
baseDir: this.getBaseDir(),
|
|
6925
|
+
frontmatter: rulesyncFrontmatter,
|
|
6926
|
+
body: this.body,
|
|
6927
|
+
relativeDirPath: RULESYNC_RULES_RELATIVE_DIR_PATH,
|
|
6928
|
+
relativeFilePath: this.getRelativeFilePath(),
|
|
6929
|
+
validate: true
|
|
6930
|
+
});
|
|
6931
|
+
}
|
|
6932
|
+
validate() {
|
|
6933
|
+
if (!this.frontmatter) {
|
|
6934
|
+
return { success: true, error: null };
|
|
6935
|
+
}
|
|
6936
|
+
const result = ClaudecodeRuleFrontmatterSchema.safeParse(this.frontmatter);
|
|
6937
|
+
if (result.success) {
|
|
6938
|
+
return { success: true, error: null };
|
|
6939
|
+
} else {
|
|
6940
|
+
return {
|
|
6941
|
+
success: false,
|
|
6942
|
+
error: new Error(
|
|
6943
|
+
`Invalid frontmatter in ${(0, import_node_path71.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6944
|
+
)
|
|
6945
|
+
};
|
|
6946
|
+
}
|
|
6947
|
+
}
|
|
6948
|
+
getFrontmatter() {
|
|
6949
|
+
return this.frontmatter;
|
|
6950
|
+
}
|
|
6951
|
+
getBody() {
|
|
6952
|
+
return this.body;
|
|
6953
|
+
}
|
|
6954
|
+
static isTargetedByRulesyncRule(rulesyncRule) {
|
|
6955
|
+
return this.isTargetedByRulesyncRuleDefault({
|
|
6956
|
+
rulesyncRule,
|
|
6957
|
+
toolTarget: "claudecode"
|
|
6958
|
+
});
|
|
6959
|
+
}
|
|
6960
|
+
};
|
|
6961
|
+
|
|
6962
|
+
// src/features/rules/cline-rule.ts
|
|
6963
|
+
var import_node_path72 = require("path");
|
|
6964
|
+
var import_mini30 = require("zod/mini");
|
|
6965
|
+
var ClineRuleFrontmatterSchema = import_mini30.z.object({
|
|
6966
|
+
description: import_mini30.z.string()
|
|
6747
6967
|
});
|
|
6748
6968
|
var ClineRule = class _ClineRule extends ToolRule {
|
|
6749
6969
|
static getSettablePaths() {
|
|
@@ -6785,7 +7005,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
6785
7005
|
validate = true
|
|
6786
7006
|
}) {
|
|
6787
7007
|
const fileContent = await readFileContent(
|
|
6788
|
-
(0,
|
|
7008
|
+
(0, import_node_path72.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
6789
7009
|
);
|
|
6790
7010
|
return new _ClineRule({
|
|
6791
7011
|
baseDir,
|
|
@@ -6798,7 +7018,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
6798
7018
|
};
|
|
6799
7019
|
|
|
6800
7020
|
// src/features/rules/codexcli-rule.ts
|
|
6801
|
-
var
|
|
7021
|
+
var import_node_path73 = require("path");
|
|
6802
7022
|
var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
6803
7023
|
static getSettablePaths({
|
|
6804
7024
|
global
|
|
@@ -6817,7 +7037,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
6817
7037
|
relativeFilePath: "AGENTS.md"
|
|
6818
7038
|
},
|
|
6819
7039
|
nonRoot: {
|
|
6820
|
-
relativeDirPath: (0,
|
|
7040
|
+
relativeDirPath: (0, import_node_path73.join)(".codex", "memories")
|
|
6821
7041
|
}
|
|
6822
7042
|
};
|
|
6823
7043
|
}
|
|
@@ -6832,7 +7052,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
6832
7052
|
if (isRoot) {
|
|
6833
7053
|
const relativePath2 = paths.root.relativeFilePath;
|
|
6834
7054
|
const fileContent2 = await readFileContent(
|
|
6835
|
-
(0,
|
|
7055
|
+
(0, import_node_path73.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
6836
7056
|
);
|
|
6837
7057
|
return new _CodexcliRule({
|
|
6838
7058
|
baseDir,
|
|
@@ -6846,8 +7066,8 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
6846
7066
|
if (!paths.nonRoot) {
|
|
6847
7067
|
throw new Error("nonRoot path is not set");
|
|
6848
7068
|
}
|
|
6849
|
-
const relativePath = (0,
|
|
6850
|
-
const fileContent = await readFileContent((0,
|
|
7069
|
+
const relativePath = (0, import_node_path73.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
7070
|
+
const fileContent = await readFileContent((0, import_node_path73.join)(baseDir, relativePath));
|
|
6851
7071
|
return new _CodexcliRule({
|
|
6852
7072
|
baseDir,
|
|
6853
7073
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -6889,12 +7109,12 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
6889
7109
|
};
|
|
6890
7110
|
|
|
6891
7111
|
// src/features/rules/copilot-rule.ts
|
|
6892
|
-
var
|
|
6893
|
-
var
|
|
6894
|
-
var CopilotRuleFrontmatterSchema =
|
|
6895
|
-
description:
|
|
6896
|
-
applyTo:
|
|
6897
|
-
excludeAgent:
|
|
7112
|
+
var import_node_path74 = require("path");
|
|
7113
|
+
var import_mini31 = require("zod/mini");
|
|
7114
|
+
var CopilotRuleFrontmatterSchema = import_mini31.z.object({
|
|
7115
|
+
description: import_mini31.z.optional(import_mini31.z.string()),
|
|
7116
|
+
applyTo: import_mini31.z.optional(import_mini31.z.string()),
|
|
7117
|
+
excludeAgent: import_mini31.z.optional(import_mini31.z.union([import_mini31.z.literal("code-review"), import_mini31.z.literal("coding-agent")]))
|
|
6898
7118
|
});
|
|
6899
7119
|
var CopilotRule = class _CopilotRule extends ToolRule {
|
|
6900
7120
|
frontmatter;
|
|
@@ -6906,7 +7126,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
6906
7126
|
relativeFilePath: "copilot-instructions.md"
|
|
6907
7127
|
},
|
|
6908
7128
|
nonRoot: {
|
|
6909
|
-
relativeDirPath: (0,
|
|
7129
|
+
relativeDirPath: (0, import_node_path74.join)(".github", "instructions")
|
|
6910
7130
|
}
|
|
6911
7131
|
};
|
|
6912
7132
|
}
|
|
@@ -6915,7 +7135,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
6915
7135
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
6916
7136
|
if (!result.success) {
|
|
6917
7137
|
throw new Error(
|
|
6918
|
-
`Invalid frontmatter in ${(0,
|
|
7138
|
+
`Invalid frontmatter in ${(0, import_node_path74.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6919
7139
|
);
|
|
6920
7140
|
}
|
|
6921
7141
|
}
|
|
@@ -6997,11 +7217,11 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
6997
7217
|
validate = true
|
|
6998
7218
|
}) {
|
|
6999
7219
|
const isRoot = relativeFilePath === "copilot-instructions.md";
|
|
7000
|
-
const relativePath = isRoot ? (0,
|
|
7220
|
+
const relativePath = isRoot ? (0, import_node_path74.join)(
|
|
7001
7221
|
this.getSettablePaths().root.relativeDirPath,
|
|
7002
7222
|
this.getSettablePaths().root.relativeFilePath
|
|
7003
|
-
) : (0,
|
|
7004
|
-
const fileContent = await readFileContent((0,
|
|
7223
|
+
) : (0, import_node_path74.join)(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
7224
|
+
const fileContent = await readFileContent((0, import_node_path74.join)(baseDir, relativePath));
|
|
7005
7225
|
if (isRoot) {
|
|
7006
7226
|
return new _CopilotRule({
|
|
7007
7227
|
baseDir,
|
|
@@ -7017,7 +7237,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
7017
7237
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7018
7238
|
if (!result.success) {
|
|
7019
7239
|
throw new Error(
|
|
7020
|
-
`Invalid frontmatter in ${(0,
|
|
7240
|
+
`Invalid frontmatter in ${(0, import_node_path74.join)(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
7021
7241
|
);
|
|
7022
7242
|
}
|
|
7023
7243
|
return new _CopilotRule({
|
|
@@ -7041,7 +7261,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
7041
7261
|
return {
|
|
7042
7262
|
success: false,
|
|
7043
7263
|
error: new Error(
|
|
7044
|
-
`Invalid frontmatter in ${(0,
|
|
7264
|
+
`Invalid frontmatter in ${(0, import_node_path74.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
7045
7265
|
)
|
|
7046
7266
|
};
|
|
7047
7267
|
}
|
|
@@ -7061,12 +7281,12 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
7061
7281
|
};
|
|
7062
7282
|
|
|
7063
7283
|
// src/features/rules/cursor-rule.ts
|
|
7064
|
-
var
|
|
7065
|
-
var
|
|
7066
|
-
var CursorRuleFrontmatterSchema =
|
|
7067
|
-
description:
|
|
7068
|
-
globs:
|
|
7069
|
-
alwaysApply:
|
|
7284
|
+
var import_node_path75 = require("path");
|
|
7285
|
+
var import_mini32 = require("zod/mini");
|
|
7286
|
+
var CursorRuleFrontmatterSchema = import_mini32.z.object({
|
|
7287
|
+
description: import_mini32.z.optional(import_mini32.z.string()),
|
|
7288
|
+
globs: import_mini32.z.optional(import_mini32.z.string()),
|
|
7289
|
+
alwaysApply: import_mini32.z.optional(import_mini32.z.boolean())
|
|
7070
7290
|
});
|
|
7071
7291
|
var CursorRule = class _CursorRule extends ToolRule {
|
|
7072
7292
|
frontmatter;
|
|
@@ -7074,7 +7294,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
7074
7294
|
static getSettablePaths() {
|
|
7075
7295
|
return {
|
|
7076
7296
|
nonRoot: {
|
|
7077
|
-
relativeDirPath: (0,
|
|
7297
|
+
relativeDirPath: (0, import_node_path75.join)(".cursor", "rules")
|
|
7078
7298
|
}
|
|
7079
7299
|
};
|
|
7080
7300
|
}
|
|
@@ -7083,7 +7303,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
7083
7303
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7084
7304
|
if (!result.success) {
|
|
7085
7305
|
throw new Error(
|
|
7086
|
-
`Invalid frontmatter in ${(0,
|
|
7306
|
+
`Invalid frontmatter in ${(0, import_node_path75.join)(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
7087
7307
|
);
|
|
7088
7308
|
}
|
|
7089
7309
|
}
|
|
@@ -7200,19 +7420,19 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
7200
7420
|
validate = true
|
|
7201
7421
|
}) {
|
|
7202
7422
|
const fileContent = await readFileContent(
|
|
7203
|
-
(0,
|
|
7423
|
+
(0, import_node_path75.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7204
7424
|
);
|
|
7205
7425
|
const { frontmatter, body: content } = _CursorRule.parseCursorFrontmatter(fileContent);
|
|
7206
7426
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7207
7427
|
if (!result.success) {
|
|
7208
7428
|
throw new Error(
|
|
7209
|
-
`Invalid frontmatter in ${(0,
|
|
7429
|
+
`Invalid frontmatter in ${(0, import_node_path75.join)(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
7210
7430
|
);
|
|
7211
7431
|
}
|
|
7212
7432
|
return new _CursorRule({
|
|
7213
7433
|
baseDir,
|
|
7214
7434
|
relativeDirPath: this.getSettablePaths().nonRoot.relativeDirPath,
|
|
7215
|
-
relativeFilePath: (0,
|
|
7435
|
+
relativeFilePath: (0, import_node_path75.basename)(relativeFilePath),
|
|
7216
7436
|
frontmatter: result.data,
|
|
7217
7437
|
body: content.trim(),
|
|
7218
7438
|
validate
|
|
@@ -7229,7 +7449,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
7229
7449
|
return {
|
|
7230
7450
|
success: false,
|
|
7231
7451
|
error: new Error(
|
|
7232
|
-
`Invalid frontmatter in ${(0,
|
|
7452
|
+
`Invalid frontmatter in ${(0, import_node_path75.join)(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
7233
7453
|
)
|
|
7234
7454
|
};
|
|
7235
7455
|
}
|
|
@@ -7249,7 +7469,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
7249
7469
|
};
|
|
7250
7470
|
|
|
7251
7471
|
// src/features/rules/geminicli-rule.ts
|
|
7252
|
-
var
|
|
7472
|
+
var import_node_path76 = require("path");
|
|
7253
7473
|
var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
7254
7474
|
static getSettablePaths({
|
|
7255
7475
|
global
|
|
@@ -7268,7 +7488,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
7268
7488
|
relativeFilePath: "GEMINI.md"
|
|
7269
7489
|
},
|
|
7270
7490
|
nonRoot: {
|
|
7271
|
-
relativeDirPath: (0,
|
|
7491
|
+
relativeDirPath: (0, import_node_path76.join)(".gemini", "memories")
|
|
7272
7492
|
}
|
|
7273
7493
|
};
|
|
7274
7494
|
}
|
|
@@ -7283,7 +7503,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
7283
7503
|
if (isRoot) {
|
|
7284
7504
|
const relativePath2 = paths.root.relativeFilePath;
|
|
7285
7505
|
const fileContent2 = await readFileContent(
|
|
7286
|
-
(0,
|
|
7506
|
+
(0, import_node_path76.join)(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
7287
7507
|
);
|
|
7288
7508
|
return new _GeminiCliRule({
|
|
7289
7509
|
baseDir,
|
|
@@ -7297,8 +7517,8 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
7297
7517
|
if (!paths.nonRoot) {
|
|
7298
7518
|
throw new Error("nonRoot path is not set");
|
|
7299
7519
|
}
|
|
7300
|
-
const relativePath = (0,
|
|
7301
|
-
const fileContent = await readFileContent((0,
|
|
7520
|
+
const relativePath = (0, import_node_path76.join)(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
7521
|
+
const fileContent = await readFileContent((0, import_node_path76.join)(baseDir, relativePath));
|
|
7302
7522
|
return new _GeminiCliRule({
|
|
7303
7523
|
baseDir,
|
|
7304
7524
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -7340,7 +7560,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
7340
7560
|
};
|
|
7341
7561
|
|
|
7342
7562
|
// src/features/rules/junie-rule.ts
|
|
7343
|
-
var
|
|
7563
|
+
var import_node_path77 = require("path");
|
|
7344
7564
|
var JunieRule = class _JunieRule extends ToolRule {
|
|
7345
7565
|
static getSettablePaths() {
|
|
7346
7566
|
return {
|
|
@@ -7349,7 +7569,7 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
7349
7569
|
relativeFilePath: "guidelines.md"
|
|
7350
7570
|
},
|
|
7351
7571
|
nonRoot: {
|
|
7352
|
-
relativeDirPath: (0,
|
|
7572
|
+
relativeDirPath: (0, import_node_path77.join)(".junie", "memories")
|
|
7353
7573
|
}
|
|
7354
7574
|
};
|
|
7355
7575
|
}
|
|
@@ -7359,8 +7579,8 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
7359
7579
|
validate = true
|
|
7360
7580
|
}) {
|
|
7361
7581
|
const isRoot = relativeFilePath === "guidelines.md";
|
|
7362
|
-
const relativePath = isRoot ? "guidelines.md" : (0,
|
|
7363
|
-
const fileContent = await readFileContent((0,
|
|
7582
|
+
const relativePath = isRoot ? "guidelines.md" : (0, import_node_path77.join)(".junie", "memories", relativeFilePath);
|
|
7583
|
+
const fileContent = await readFileContent((0, import_node_path77.join)(baseDir, relativePath));
|
|
7364
7584
|
return new _JunieRule({
|
|
7365
7585
|
baseDir,
|
|
7366
7586
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -7400,12 +7620,12 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
7400
7620
|
};
|
|
7401
7621
|
|
|
7402
7622
|
// src/features/rules/kiro-rule.ts
|
|
7403
|
-
var
|
|
7623
|
+
var import_node_path78 = require("path");
|
|
7404
7624
|
var KiroRule = class _KiroRule extends ToolRule {
|
|
7405
7625
|
static getSettablePaths() {
|
|
7406
7626
|
return {
|
|
7407
7627
|
nonRoot: {
|
|
7408
|
-
relativeDirPath: (0,
|
|
7628
|
+
relativeDirPath: (0, import_node_path78.join)(".kiro", "steering")
|
|
7409
7629
|
}
|
|
7410
7630
|
};
|
|
7411
7631
|
}
|
|
@@ -7415,7 +7635,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
7415
7635
|
validate = true
|
|
7416
7636
|
}) {
|
|
7417
7637
|
const fileContent = await readFileContent(
|
|
7418
|
-
(0,
|
|
7638
|
+
(0, import_node_path78.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7419
7639
|
);
|
|
7420
7640
|
return new _KiroRule({
|
|
7421
7641
|
baseDir,
|
|
@@ -7455,7 +7675,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
7455
7675
|
};
|
|
7456
7676
|
|
|
7457
7677
|
// src/features/rules/opencode-rule.ts
|
|
7458
|
-
var
|
|
7678
|
+
var import_node_path79 = require("path");
|
|
7459
7679
|
var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
7460
7680
|
static getSettablePaths() {
|
|
7461
7681
|
return {
|
|
@@ -7464,7 +7684,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
7464
7684
|
relativeFilePath: "AGENTS.md"
|
|
7465
7685
|
},
|
|
7466
7686
|
nonRoot: {
|
|
7467
|
-
relativeDirPath: (0,
|
|
7687
|
+
relativeDirPath: (0, import_node_path79.join)(".opencode", "memories")
|
|
7468
7688
|
}
|
|
7469
7689
|
};
|
|
7470
7690
|
}
|
|
@@ -7474,8 +7694,8 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
7474
7694
|
validate = true
|
|
7475
7695
|
}) {
|
|
7476
7696
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
7477
|
-
const relativePath = isRoot ? "AGENTS.md" : (0,
|
|
7478
|
-
const fileContent = await readFileContent((0,
|
|
7697
|
+
const relativePath = isRoot ? "AGENTS.md" : (0, import_node_path79.join)(".opencode", "memories", relativeFilePath);
|
|
7698
|
+
const fileContent = await readFileContent((0, import_node_path79.join)(baseDir, relativePath));
|
|
7479
7699
|
return new _OpenCodeRule({
|
|
7480
7700
|
baseDir,
|
|
7481
7701
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -7515,7 +7735,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
7515
7735
|
};
|
|
7516
7736
|
|
|
7517
7737
|
// src/features/rules/qwencode-rule.ts
|
|
7518
|
-
var
|
|
7738
|
+
var import_node_path80 = require("path");
|
|
7519
7739
|
var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
7520
7740
|
static getSettablePaths() {
|
|
7521
7741
|
return {
|
|
@@ -7524,7 +7744,7 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
7524
7744
|
relativeFilePath: "QWEN.md"
|
|
7525
7745
|
},
|
|
7526
7746
|
nonRoot: {
|
|
7527
|
-
relativeDirPath: (0,
|
|
7747
|
+
relativeDirPath: (0, import_node_path80.join)(".qwen", "memories")
|
|
7528
7748
|
}
|
|
7529
7749
|
};
|
|
7530
7750
|
}
|
|
@@ -7534,8 +7754,8 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
7534
7754
|
validate = true
|
|
7535
7755
|
}) {
|
|
7536
7756
|
const isRoot = relativeFilePath === "QWEN.md";
|
|
7537
|
-
const relativePath = isRoot ? "QWEN.md" : (0,
|
|
7538
|
-
const fileContent = await readFileContent((0,
|
|
7757
|
+
const relativePath = isRoot ? "QWEN.md" : (0, import_node_path80.join)(".qwen", "memories", relativeFilePath);
|
|
7758
|
+
const fileContent = await readFileContent((0, import_node_path80.join)(baseDir, relativePath));
|
|
7539
7759
|
return new _QwencodeRule({
|
|
7540
7760
|
baseDir,
|
|
7541
7761
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -7572,12 +7792,12 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
7572
7792
|
};
|
|
7573
7793
|
|
|
7574
7794
|
// src/features/rules/roo-rule.ts
|
|
7575
|
-
var
|
|
7795
|
+
var import_node_path81 = require("path");
|
|
7576
7796
|
var RooRule = class _RooRule extends ToolRule {
|
|
7577
7797
|
static getSettablePaths() {
|
|
7578
7798
|
return {
|
|
7579
7799
|
nonRoot: {
|
|
7580
|
-
relativeDirPath: (0,
|
|
7800
|
+
relativeDirPath: (0, import_node_path81.join)(".roo", "rules")
|
|
7581
7801
|
}
|
|
7582
7802
|
};
|
|
7583
7803
|
}
|
|
@@ -7587,7 +7807,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
7587
7807
|
validate = true
|
|
7588
7808
|
}) {
|
|
7589
7809
|
const fileContent = await readFileContent(
|
|
7590
|
-
(0,
|
|
7810
|
+
(0, import_node_path81.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7591
7811
|
);
|
|
7592
7812
|
return new _RooRule({
|
|
7593
7813
|
baseDir,
|
|
@@ -7642,7 +7862,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
7642
7862
|
};
|
|
7643
7863
|
|
|
7644
7864
|
// src/features/rules/warp-rule.ts
|
|
7645
|
-
var
|
|
7865
|
+
var import_node_path82 = require("path");
|
|
7646
7866
|
var WarpRule = class _WarpRule extends ToolRule {
|
|
7647
7867
|
constructor({ fileContent, root, ...rest }) {
|
|
7648
7868
|
super({
|
|
@@ -7658,7 +7878,7 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
7658
7878
|
relativeFilePath: "WARP.md"
|
|
7659
7879
|
},
|
|
7660
7880
|
nonRoot: {
|
|
7661
|
-
relativeDirPath: (0,
|
|
7881
|
+
relativeDirPath: (0, import_node_path82.join)(".warp", "memories")
|
|
7662
7882
|
}
|
|
7663
7883
|
};
|
|
7664
7884
|
}
|
|
@@ -7668,8 +7888,8 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
7668
7888
|
validate = true
|
|
7669
7889
|
}) {
|
|
7670
7890
|
const isRoot = relativeFilePath === this.getSettablePaths().root.relativeFilePath;
|
|
7671
|
-
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath : (0,
|
|
7672
|
-
const fileContent = await readFileContent((0,
|
|
7891
|
+
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath : (0, import_node_path82.join)(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
7892
|
+
const fileContent = await readFileContent((0, import_node_path82.join)(baseDir, relativePath));
|
|
7673
7893
|
return new _WarpRule({
|
|
7674
7894
|
baseDir,
|
|
7675
7895
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : ".warp",
|
|
@@ -7709,12 +7929,12 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
7709
7929
|
};
|
|
7710
7930
|
|
|
7711
7931
|
// src/features/rules/windsurf-rule.ts
|
|
7712
|
-
var
|
|
7932
|
+
var import_node_path83 = require("path");
|
|
7713
7933
|
var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
7714
7934
|
static getSettablePaths() {
|
|
7715
7935
|
return {
|
|
7716
7936
|
nonRoot: {
|
|
7717
|
-
relativeDirPath: (0,
|
|
7937
|
+
relativeDirPath: (0, import_node_path83.join)(".windsurf", "rules")
|
|
7718
7938
|
}
|
|
7719
7939
|
};
|
|
7720
7940
|
}
|
|
@@ -7724,7 +7944,7 @@ var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
|
7724
7944
|
validate = true
|
|
7725
7945
|
}) {
|
|
7726
7946
|
const fileContent = await readFileContent(
|
|
7727
|
-
(0,
|
|
7947
|
+
(0, import_node_path83.join)(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7728
7948
|
);
|
|
7729
7949
|
return new _WindsurfRule({
|
|
7730
7950
|
baseDir,
|
|
@@ -7770,6 +7990,7 @@ var rulesProcessorToolTargets = [
|
|
|
7770
7990
|
"augmentcode",
|
|
7771
7991
|
"augmentcode-legacy",
|
|
7772
7992
|
"claudecode",
|
|
7993
|
+
"claudecode-legacy",
|
|
7773
7994
|
"cline",
|
|
7774
7995
|
"codexcli",
|
|
7775
7996
|
"copilot",
|
|
@@ -7783,9 +8004,10 @@ var rulesProcessorToolTargets = [
|
|
|
7783
8004
|
"warp",
|
|
7784
8005
|
"windsurf"
|
|
7785
8006
|
];
|
|
7786
|
-
var RulesProcessorToolTargetSchema =
|
|
8007
|
+
var RulesProcessorToolTargetSchema = import_mini33.z.enum(rulesProcessorToolTargets);
|
|
7787
8008
|
var rulesProcessorToolTargetsGlobal = [
|
|
7788
8009
|
"claudecode",
|
|
8010
|
+
"claudecode-legacy",
|
|
7789
8011
|
"codexcli",
|
|
7790
8012
|
"geminicli"
|
|
7791
8013
|
];
|
|
@@ -7796,6 +8018,7 @@ var toolRuleFactories = /* @__PURE__ */ new Map([
|
|
|
7796
8018
|
["augmentcode", { class: AugmentcodeRule, meta: { extension: "md" } }],
|
|
7797
8019
|
["augmentcode-legacy", { class: AugmentcodeLegacyRule, meta: { extension: "md" } }],
|
|
7798
8020
|
["claudecode", { class: ClaudecodeRule, meta: { extension: "md" } }],
|
|
8021
|
+
["claudecode-legacy", { class: ClaudecodeLegacyRule, meta: { extension: "md" } }],
|
|
7799
8022
|
["cline", { class: ClineRule, meta: { extension: "md" } }],
|
|
7800
8023
|
["codexcli", { class: CodexcliRule, meta: { extension: "md" } }],
|
|
7801
8024
|
["copilot", { class: CopilotRule, meta: { extension: "md" } }],
|
|
@@ -7926,6 +8149,9 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
7926
8149
|
return toolRules;
|
|
7927
8150
|
}
|
|
7928
8151
|
case "claudecode": {
|
|
8152
|
+
return toolRules;
|
|
8153
|
+
}
|
|
8154
|
+
case "claudecode-legacy": {
|
|
7929
8155
|
const rootRule = toolRules[rootRuleIndex];
|
|
7930
8156
|
rootRule?.setFileContent(
|
|
7931
8157
|
this.generateReferencesSection(toolRules) + rootRule.getFileContent()
|
|
@@ -8020,10 +8246,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
8020
8246
|
* Load and parse rulesync rule files from .rulesync/rules/ directory
|
|
8021
8247
|
*/
|
|
8022
8248
|
async loadRulesyncFiles() {
|
|
8023
|
-
const files = await findFilesByGlobs((0,
|
|
8249
|
+
const files = await findFilesByGlobs((0, import_node_path84.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md"));
|
|
8024
8250
|
logger.debug(`Found ${files.length} rulesync files`);
|
|
8025
8251
|
const rulesyncRules = await Promise.all(
|
|
8026
|
-
files.map((file) => RulesyncRule.fromFile({ relativeFilePath: (0,
|
|
8252
|
+
files.map((file) => RulesyncRule.fromFile({ relativeFilePath: (0, import_node_path84.basename)(file) }))
|
|
8027
8253
|
);
|
|
8028
8254
|
const rootRules = rulesyncRules.filter((rule) => rule.getFrontmatter().root);
|
|
8029
8255
|
if (rootRules.length > 1) {
|
|
@@ -8041,10 +8267,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
8041
8267
|
return rulesyncRules;
|
|
8042
8268
|
}
|
|
8043
8269
|
async loadRulesyncFilesLegacy() {
|
|
8044
|
-
const legacyFiles = await findFilesByGlobs((0,
|
|
8270
|
+
const legacyFiles = await findFilesByGlobs((0, import_node_path84.join)(RULESYNC_RELATIVE_DIR_PATH, "*.md"));
|
|
8045
8271
|
logger.debug(`Found ${legacyFiles.length} legacy rulesync files`);
|
|
8046
8272
|
return Promise.all(
|
|
8047
|
-
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath: (0,
|
|
8273
|
+
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath: (0, import_node_path84.basename)(file) }))
|
|
8048
8274
|
);
|
|
8049
8275
|
}
|
|
8050
8276
|
/**
|
|
@@ -8062,7 +8288,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
8062
8288
|
return [];
|
|
8063
8289
|
}
|
|
8064
8290
|
const rootFilePaths = await findFilesByGlobs(
|
|
8065
|
-
(0,
|
|
8291
|
+
(0, import_node_path84.join)(
|
|
8066
8292
|
this.baseDir,
|
|
8067
8293
|
settablePaths.root.relativeDirPath ?? ".",
|
|
8068
8294
|
settablePaths.root.relativeFilePath
|
|
@@ -8072,7 +8298,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
8072
8298
|
rootFilePaths.map(
|
|
8073
8299
|
(filePath) => factory.class.fromFile({
|
|
8074
8300
|
baseDir: this.baseDir,
|
|
8075
|
-
relativeFilePath: (0,
|
|
8301
|
+
relativeFilePath: (0, import_node_path84.basename)(filePath),
|
|
8076
8302
|
global: this.global
|
|
8077
8303
|
})
|
|
8078
8304
|
)
|
|
@@ -8084,13 +8310,13 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
8084
8310
|
return [];
|
|
8085
8311
|
}
|
|
8086
8312
|
const nonRootFilePaths = await findFilesByGlobs(
|
|
8087
|
-
(0,
|
|
8313
|
+
(0, import_node_path84.join)(this.baseDir, settablePaths.nonRoot.relativeDirPath, `*.${factory.meta.extension}`)
|
|
8088
8314
|
);
|
|
8089
8315
|
return await Promise.all(
|
|
8090
8316
|
nonRootFilePaths.map(
|
|
8091
8317
|
(filePath) => factory.class.fromFile({
|
|
8092
8318
|
baseDir: this.baseDir,
|
|
8093
|
-
relativeFilePath: (0,
|
|
8319
|
+
relativeFilePath: (0, import_node_path84.basename)(filePath),
|
|
8094
8320
|
global: this.global
|
|
8095
8321
|
})
|
|
8096
8322
|
)
|
|
@@ -8183,21 +8409,21 @@ s/<command> [arguments]
|
|
|
8183
8409
|
This syntax employs a double slash (\`s/\`) to prevent conflicts with built-in slash commands.
|
|
8184
8410
|
The \`s\` in \`s/\` stands for *simulate*. Because custom slash commands are not built-in, this syntax provides a pseudo way to invoke them.
|
|
8185
8411
|
|
|
8186
|
-
When users call a custom slash command, you have to look for the markdown file, \`${(0,
|
|
8412
|
+
When users call a custom slash command, you have to look for the markdown file, \`${(0, import_node_path84.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "{command}.md")}\`, then execute the contents of that file as the block of operations.` : "";
|
|
8187
8413
|
const subagentsSection = subagents ? `## Simulated Subagents
|
|
8188
8414
|
|
|
8189
8415
|
Simulated subagents are specialized AI assistants that can be invoked to handle specific types of tasks. In this case, it can be appear something like custom slash commands simply. Simulated subagents can be called by custom slash commands.
|
|
8190
8416
|
|
|
8191
|
-
When users call a simulated subagent, it will look for the corresponding markdown file, \`${(0,
|
|
8417
|
+
When users call a simulated subagent, it will look for the corresponding markdown file, \`${(0, import_node_path84.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "{subagent}.md")}\`, and execute its contents as the block of operations.
|
|
8192
8418
|
|
|
8193
|
-
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${(0,
|
|
8419
|
+
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${(0, import_node_path84.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "planner.md")}\`, and execute its contents as the block of operations.` : "";
|
|
8194
8420
|
const skillsSection = skills ? `## Simulated Skills
|
|
8195
8421
|
|
|
8196
8422
|
Simulated skills are specialized capabilities that can be invoked to handle specific types of tasks.
|
|
8197
8423
|
|
|
8198
|
-
When users invoke a simulated skill, look for the corresponding SKILL.md file in \`${(0,
|
|
8424
|
+
When users invoke a simulated skill, look for the corresponding SKILL.md file in \`${(0, import_node_path84.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "{skill}/SKILL.md")}\` and execute its contents as the block of operations.
|
|
8199
8425
|
|
|
8200
|
-
For example, if the user instructs \`Use the skill example-skill to achieve something\`, look for \`${(0,
|
|
8426
|
+
For example, if the user instructs \`Use the skill example-skill to achieve something\`, look for \`${(0, import_node_path84.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "example-skill/SKILL.md")}\` and execute its contents.
|
|
8201
8427
|
|
|
8202
8428
|
Additionally, you should proactively consider using available skills when they would help accomplish a task more effectively, even if the user doesn't explicitly request them.` : "";
|
|
8203
8429
|
const result = [
|
|
@@ -8459,102 +8685,149 @@ async function generateSkills(config) {
|
|
|
8459
8685
|
}
|
|
8460
8686
|
|
|
8461
8687
|
// src/cli/commands/gitignore.ts
|
|
8462
|
-
var
|
|
8688
|
+
var import_node_path85 = require("path");
|
|
8689
|
+
var RULESYNC_HEADER = "# Generated by Rulesync";
|
|
8690
|
+
var LEGACY_RULESYNC_HEADER = "# Generated by rulesync - AI tool configuration files";
|
|
8691
|
+
var RULESYNC_IGNORE_ENTRIES = [
|
|
8692
|
+
// AGENTS.md
|
|
8693
|
+
"**/AGENTS.md",
|
|
8694
|
+
"**/.agents/",
|
|
8695
|
+
// Amazon Q
|
|
8696
|
+
"**/.amazonq/",
|
|
8697
|
+
// Augment
|
|
8698
|
+
"**/.augmentignore",
|
|
8699
|
+
"**/.augment/rules/",
|
|
8700
|
+
"**/.augment-guidelines",
|
|
8701
|
+
// Claude Code
|
|
8702
|
+
"**/CLAUDE.md",
|
|
8703
|
+
"**/.claude/CLAUDE.md",
|
|
8704
|
+
"**/.claude/memories/",
|
|
8705
|
+
"**/.claude/rules/",
|
|
8706
|
+
"**/.claude/commands/",
|
|
8707
|
+
"**/.claude/agents/",
|
|
8708
|
+
"**/.claude/skills/",
|
|
8709
|
+
"**/.claude/settings.local.json",
|
|
8710
|
+
"**/.mcp.json",
|
|
8711
|
+
// Cline
|
|
8712
|
+
"**/.clinerules/",
|
|
8713
|
+
"**/.clineignore",
|
|
8714
|
+
"**/.cline/mcp.json",
|
|
8715
|
+
// Codex
|
|
8716
|
+
"**/.codexignore",
|
|
8717
|
+
"**/.codex/",
|
|
8718
|
+
"**/.codex/skills/",
|
|
8719
|
+
// Cursor
|
|
8720
|
+
"**/.cursor/",
|
|
8721
|
+
"**/.cursorignore",
|
|
8722
|
+
// Gemini
|
|
8723
|
+
"**/GEMINI.md",
|
|
8724
|
+
"**/.gemini/memories/",
|
|
8725
|
+
"**/.gemini/commands/",
|
|
8726
|
+
"**/.gemini/subagents/",
|
|
8727
|
+
"**/.gemini/skills/",
|
|
8728
|
+
"**/.geminiignore",
|
|
8729
|
+
// GitHub Copilot
|
|
8730
|
+
"**/.github/copilot-instructions.md",
|
|
8731
|
+
"**/.github/instructions/",
|
|
8732
|
+
"**/.github/prompts/",
|
|
8733
|
+
"**/.github/subagents/",
|
|
8734
|
+
"**/.github/skills/",
|
|
8735
|
+
"**/.vscode/mcp.json",
|
|
8736
|
+
// Junie
|
|
8737
|
+
"**/.junie/guidelines.md",
|
|
8738
|
+
"**/.junie/mcp.json",
|
|
8739
|
+
// Kiro
|
|
8740
|
+
"**/.kiro/steering/",
|
|
8741
|
+
"**/.aiignore",
|
|
8742
|
+
// OpenCode
|
|
8743
|
+
"**/.opencode/memories/",
|
|
8744
|
+
"**/.opencode/command/",
|
|
8745
|
+
"**/opencode.json",
|
|
8746
|
+
// Qwen
|
|
8747
|
+
"**/QWEN.md",
|
|
8748
|
+
"**/.qwen/memories/",
|
|
8749
|
+
// Roo
|
|
8750
|
+
"**/.roo/rules/",
|
|
8751
|
+
"**/.rooignore",
|
|
8752
|
+
"**/.roo/mcp.json",
|
|
8753
|
+
"**/.roo/subagents/",
|
|
8754
|
+
// Warp
|
|
8755
|
+
"**/.warp/",
|
|
8756
|
+
"**/WARP.md",
|
|
8757
|
+
// Others
|
|
8758
|
+
"**/modular-mcp.json",
|
|
8759
|
+
"!.rulesync/.aiignore"
|
|
8760
|
+
];
|
|
8761
|
+
var isRulesyncHeader = (line) => {
|
|
8762
|
+
const trimmed = line.trim();
|
|
8763
|
+
return trimmed === RULESYNC_HEADER || trimmed === LEGACY_RULESYNC_HEADER;
|
|
8764
|
+
};
|
|
8765
|
+
var isRulesyncEntry = (line) => {
|
|
8766
|
+
const trimmed = line.trim();
|
|
8767
|
+
if (trimmed === "" || isRulesyncHeader(line)) {
|
|
8768
|
+
return false;
|
|
8769
|
+
}
|
|
8770
|
+
return RULESYNC_IGNORE_ENTRIES.includes(trimmed);
|
|
8771
|
+
};
|
|
8772
|
+
var removeExistingRulesyncEntries = (content) => {
|
|
8773
|
+
const lines = content.split("\n");
|
|
8774
|
+
const filteredLines = [];
|
|
8775
|
+
let inRulesyncBlock = false;
|
|
8776
|
+
let consecutiveEmptyLines = 0;
|
|
8777
|
+
for (const line of lines) {
|
|
8778
|
+
const trimmed = line.trim();
|
|
8779
|
+
if (isRulesyncHeader(line)) {
|
|
8780
|
+
inRulesyncBlock = true;
|
|
8781
|
+
continue;
|
|
8782
|
+
}
|
|
8783
|
+
if (inRulesyncBlock) {
|
|
8784
|
+
if (trimmed === "") {
|
|
8785
|
+
consecutiveEmptyLines++;
|
|
8786
|
+
if (consecutiveEmptyLines >= 2) {
|
|
8787
|
+
inRulesyncBlock = false;
|
|
8788
|
+
consecutiveEmptyLines = 0;
|
|
8789
|
+
}
|
|
8790
|
+
continue;
|
|
8791
|
+
}
|
|
8792
|
+
if (isRulesyncEntry(line)) {
|
|
8793
|
+
consecutiveEmptyLines = 0;
|
|
8794
|
+
continue;
|
|
8795
|
+
}
|
|
8796
|
+
inRulesyncBlock = false;
|
|
8797
|
+
consecutiveEmptyLines = 0;
|
|
8798
|
+
}
|
|
8799
|
+
if (isRulesyncEntry(line)) {
|
|
8800
|
+
continue;
|
|
8801
|
+
}
|
|
8802
|
+
filteredLines.push(line);
|
|
8803
|
+
}
|
|
8804
|
+
let result = filteredLines.join("\n");
|
|
8805
|
+
while (result.endsWith("\n\n")) {
|
|
8806
|
+
result = result.slice(0, -1);
|
|
8807
|
+
}
|
|
8808
|
+
return result;
|
|
8809
|
+
};
|
|
8463
8810
|
var gitignoreCommand = async () => {
|
|
8464
|
-
const gitignorePath = (0,
|
|
8465
|
-
const rulesFilesToIgnore = [
|
|
8466
|
-
"# Generated by rulesync - AI tool configuration files",
|
|
8467
|
-
// AGENTS.md
|
|
8468
|
-
"**/AGENTS.md",
|
|
8469
|
-
"**/.agents/",
|
|
8470
|
-
// Amazon Q
|
|
8471
|
-
"**/.amazonq/",
|
|
8472
|
-
// Augment
|
|
8473
|
-
"**/.augmentignore",
|
|
8474
|
-
"**/.augment/rules/",
|
|
8475
|
-
"**/.augment-guidelines",
|
|
8476
|
-
// Claude Code
|
|
8477
|
-
"**/CLAUDE.md",
|
|
8478
|
-
"**/.claude/memories/",
|
|
8479
|
-
"**/.claude/commands/",
|
|
8480
|
-
"**/.claude/agents/",
|
|
8481
|
-
"**/.claude/skills/",
|
|
8482
|
-
"**/.claude/settings.local.json",
|
|
8483
|
-
"**/.mcp.json",
|
|
8484
|
-
// Cline
|
|
8485
|
-
"**/.clinerules/",
|
|
8486
|
-
"**/.clineignore",
|
|
8487
|
-
"**/.cline/mcp.json",
|
|
8488
|
-
// Codex
|
|
8489
|
-
"**/.codexignore",
|
|
8490
|
-
"**/.codex/",
|
|
8491
|
-
"**/.codex/skills/",
|
|
8492
|
-
// Cursor
|
|
8493
|
-
"**/.cursor/",
|
|
8494
|
-
"**/.cursorignore",
|
|
8495
|
-
// Gemini
|
|
8496
|
-
"**/GEMINI.md",
|
|
8497
|
-
"**/.gemini/memories/",
|
|
8498
|
-
"**/.gemini/commands/",
|
|
8499
|
-
"**/.gemini/subagents/",
|
|
8500
|
-
"**/.gemini/skills/",
|
|
8501
|
-
// GitHub Copilot
|
|
8502
|
-
"**/.github/copilot-instructions.md",
|
|
8503
|
-
"**/.github/instructions/",
|
|
8504
|
-
"**/.github/prompts/",
|
|
8505
|
-
"**/.github/subagents/",
|
|
8506
|
-
"**/.github/skills/",
|
|
8507
|
-
"**/.vscode/mcp.json",
|
|
8508
|
-
// Junie
|
|
8509
|
-
"**/.junie/guidelines.md",
|
|
8510
|
-
"**/.junie/mcp.json",
|
|
8511
|
-
// Kiro
|
|
8512
|
-
"**/.kiro/steering/",
|
|
8513
|
-
"**/.aiignore",
|
|
8514
|
-
// OpenCode
|
|
8515
|
-
"**/.opencode/memories/",
|
|
8516
|
-
"**/.opencode/command/",
|
|
8517
|
-
"**/opencode.json",
|
|
8518
|
-
// Qwen
|
|
8519
|
-
"**/QWEN.md",
|
|
8520
|
-
"**/.qwen/memories/",
|
|
8521
|
-
// Roo
|
|
8522
|
-
"**/.roo/rules/",
|
|
8523
|
-
"**/.rooignore",
|
|
8524
|
-
"**/.roo/mcp.json",
|
|
8525
|
-
"**/.roo/subagents/",
|
|
8526
|
-
// Warp
|
|
8527
|
-
"**/.warp/",
|
|
8528
|
-
"**/WARP.md",
|
|
8529
|
-
// Others
|
|
8530
|
-
"**/modular-mcp.json",
|
|
8531
|
-
"!.rulesync/.aiignore"
|
|
8532
|
-
];
|
|
8811
|
+
const gitignorePath = (0, import_node_path85.join)(process.cwd(), ".gitignore");
|
|
8533
8812
|
let gitignoreContent = "";
|
|
8534
8813
|
if (await fileExists(gitignorePath)) {
|
|
8535
8814
|
gitignoreContent = await readFileContent(gitignorePath);
|
|
8536
8815
|
}
|
|
8537
|
-
const
|
|
8538
|
-
|
|
8539
|
-
|
|
8540
|
-
|
|
8541
|
-
|
|
8542
|
-
|
|
8543
|
-
|
|
8816
|
+
const cleanedContent = removeExistingRulesyncEntries(gitignoreContent);
|
|
8817
|
+
const rulesyncBlock = [RULESYNC_HEADER, ...RULESYNC_IGNORE_ENTRIES].join("\n");
|
|
8818
|
+
const newContent = cleanedContent.trim() ? `${cleanedContent.trimEnd()}
|
|
8819
|
+
|
|
8820
|
+
${rulesyncBlock}
|
|
8821
|
+
` : `${rulesyncBlock}
|
|
8822
|
+
`;
|
|
8823
|
+
if (gitignoreContent === newContent) {
|
|
8544
8824
|
logger.success(".gitignore is already up to date");
|
|
8545
8825
|
return;
|
|
8546
8826
|
}
|
|
8547
|
-
const newContent = gitignoreContent ? `${gitignoreContent.trimEnd()}
|
|
8548
|
-
|
|
8549
|
-
${linesToAdd.join("\n")}
|
|
8550
|
-
` : `${linesToAdd.join("\n")}
|
|
8551
|
-
`;
|
|
8552
8827
|
await writeFileContent(gitignorePath, newContent);
|
|
8553
|
-
logger.success(
|
|
8554
|
-
for (const
|
|
8555
|
-
|
|
8556
|
-
logger.info(` ${line}`);
|
|
8557
|
-
}
|
|
8828
|
+
logger.success("Updated .gitignore with rulesync entries:");
|
|
8829
|
+
for (const entry of RULESYNC_IGNORE_ENTRIES) {
|
|
8830
|
+
logger.info(` ${entry}`);
|
|
8558
8831
|
}
|
|
8559
8832
|
};
|
|
8560
8833
|
|
|
@@ -8734,7 +9007,7 @@ async function importSkills(config, tool) {
|
|
|
8734
9007
|
}
|
|
8735
9008
|
|
|
8736
9009
|
// src/cli/commands/init.ts
|
|
8737
|
-
var
|
|
9010
|
+
var import_node_path86 = require("path");
|
|
8738
9011
|
async function initCommand() {
|
|
8739
9012
|
logger.info("Initializing rulesync...");
|
|
8740
9013
|
await ensureDir(RULESYNC_RELATIVE_DIR_PATH);
|
|
@@ -8897,14 +9170,14 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
8897
9170
|
await ensureDir(commandPaths.relativeDirPath);
|
|
8898
9171
|
await ensureDir(subagentPaths.relativeDirPath);
|
|
8899
9172
|
await ensureDir(ignorePaths.recommended.relativeDirPath);
|
|
8900
|
-
const ruleFilepath = (0,
|
|
9173
|
+
const ruleFilepath = (0, import_node_path86.join)(rulePaths.recommended.relativeDirPath, sampleRuleFile.filename);
|
|
8901
9174
|
if (!await fileExists(ruleFilepath)) {
|
|
8902
9175
|
await writeFileContent(ruleFilepath, sampleRuleFile.content);
|
|
8903
9176
|
logger.success(`Created ${ruleFilepath}`);
|
|
8904
9177
|
} else {
|
|
8905
9178
|
logger.info(`Skipped ${ruleFilepath} (already exists)`);
|
|
8906
9179
|
}
|
|
8907
|
-
const mcpFilepath = (0,
|
|
9180
|
+
const mcpFilepath = (0, import_node_path86.join)(
|
|
8908
9181
|
mcpPaths.recommended.relativeDirPath,
|
|
8909
9182
|
mcpPaths.recommended.relativeFilePath
|
|
8910
9183
|
);
|
|
@@ -8914,21 +9187,21 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
8914
9187
|
} else {
|
|
8915
9188
|
logger.info(`Skipped ${mcpFilepath} (already exists)`);
|
|
8916
9189
|
}
|
|
8917
|
-
const commandFilepath = (0,
|
|
9190
|
+
const commandFilepath = (0, import_node_path86.join)(commandPaths.relativeDirPath, sampleCommandFile.filename);
|
|
8918
9191
|
if (!await fileExists(commandFilepath)) {
|
|
8919
9192
|
await writeFileContent(commandFilepath, sampleCommandFile.content);
|
|
8920
9193
|
logger.success(`Created ${commandFilepath}`);
|
|
8921
9194
|
} else {
|
|
8922
9195
|
logger.info(`Skipped ${commandFilepath} (already exists)`);
|
|
8923
9196
|
}
|
|
8924
|
-
const subagentFilepath = (0,
|
|
9197
|
+
const subagentFilepath = (0, import_node_path86.join)(subagentPaths.relativeDirPath, sampleSubagentFile.filename);
|
|
8925
9198
|
if (!await fileExists(subagentFilepath)) {
|
|
8926
9199
|
await writeFileContent(subagentFilepath, sampleSubagentFile.content);
|
|
8927
9200
|
logger.success(`Created ${subagentFilepath}`);
|
|
8928
9201
|
} else {
|
|
8929
9202
|
logger.info(`Skipped ${subagentFilepath} (already exists)`);
|
|
8930
9203
|
}
|
|
8931
|
-
const ignoreFilepath = (0,
|
|
9204
|
+
const ignoreFilepath = (0, import_node_path86.join)(
|
|
8932
9205
|
ignorePaths.recommended.relativeDirPath,
|
|
8933
9206
|
ignorePaths.recommended.relativeFilePath
|
|
8934
9207
|
);
|
|
@@ -8944,12 +9217,12 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
8944
9217
|
var import_fastmcp = require("fastmcp");
|
|
8945
9218
|
|
|
8946
9219
|
// src/mcp/commands.ts
|
|
8947
|
-
var
|
|
8948
|
-
var
|
|
9220
|
+
var import_node_path87 = require("path");
|
|
9221
|
+
var import_mini34 = require("zod/mini");
|
|
8949
9222
|
var maxCommandSizeBytes = 1024 * 1024;
|
|
8950
9223
|
var maxCommandsCount = 1e3;
|
|
8951
9224
|
async function listCommands() {
|
|
8952
|
-
const commandsDir = (0,
|
|
9225
|
+
const commandsDir = (0, import_node_path87.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
8953
9226
|
try {
|
|
8954
9227
|
const files = await listDirectoryFiles(commandsDir);
|
|
8955
9228
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -8961,7 +9234,7 @@ async function listCommands() {
|
|
|
8961
9234
|
});
|
|
8962
9235
|
const frontmatter = command.getFrontmatter();
|
|
8963
9236
|
return {
|
|
8964
|
-
relativePathFromCwd: (0,
|
|
9237
|
+
relativePathFromCwd: (0, import_node_path87.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, file),
|
|
8965
9238
|
frontmatter
|
|
8966
9239
|
};
|
|
8967
9240
|
} catch (error) {
|
|
@@ -8981,13 +9254,13 @@ async function getCommand({ relativePathFromCwd }) {
|
|
|
8981
9254
|
relativePath: relativePathFromCwd,
|
|
8982
9255
|
intendedRootDir: process.cwd()
|
|
8983
9256
|
});
|
|
8984
|
-
const filename = (0,
|
|
9257
|
+
const filename = (0, import_node_path87.basename)(relativePathFromCwd);
|
|
8985
9258
|
try {
|
|
8986
9259
|
const command = await RulesyncCommand.fromFile({
|
|
8987
9260
|
relativeFilePath: filename
|
|
8988
9261
|
});
|
|
8989
9262
|
return {
|
|
8990
|
-
relativePathFromCwd: (0,
|
|
9263
|
+
relativePathFromCwd: (0, import_node_path87.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
8991
9264
|
frontmatter: command.getFrontmatter(),
|
|
8992
9265
|
body: command.getBody()
|
|
8993
9266
|
};
|
|
@@ -9006,7 +9279,7 @@ async function putCommand({
|
|
|
9006
9279
|
relativePath: relativePathFromCwd,
|
|
9007
9280
|
intendedRootDir: process.cwd()
|
|
9008
9281
|
});
|
|
9009
|
-
const filename = (0,
|
|
9282
|
+
const filename = (0, import_node_path87.basename)(relativePathFromCwd);
|
|
9010
9283
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
9011
9284
|
if (estimatedSize > maxCommandSizeBytes) {
|
|
9012
9285
|
throw new Error(
|
|
@@ -9016,7 +9289,7 @@ async function putCommand({
|
|
|
9016
9289
|
try {
|
|
9017
9290
|
const existingCommands = await listCommands();
|
|
9018
9291
|
const isUpdate = existingCommands.some(
|
|
9019
|
-
(command2) => command2.relativePathFromCwd === (0,
|
|
9292
|
+
(command2) => command2.relativePathFromCwd === (0, import_node_path87.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
9020
9293
|
);
|
|
9021
9294
|
if (!isUpdate && existingCommands.length >= maxCommandsCount) {
|
|
9022
9295
|
throw new Error(`Maximum number of commands (${maxCommandsCount}) reached`);
|
|
@@ -9031,11 +9304,11 @@ async function putCommand({
|
|
|
9031
9304
|
fileContent,
|
|
9032
9305
|
validate: true
|
|
9033
9306
|
});
|
|
9034
|
-
const commandsDir = (0,
|
|
9307
|
+
const commandsDir = (0, import_node_path87.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
9035
9308
|
await ensureDir(commandsDir);
|
|
9036
9309
|
await writeFileContent(command.getFilePath(), command.getFileContent());
|
|
9037
9310
|
return {
|
|
9038
|
-
relativePathFromCwd: (0,
|
|
9311
|
+
relativePathFromCwd: (0, import_node_path87.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
9039
9312
|
frontmatter: command.getFrontmatter(),
|
|
9040
9313
|
body: command.getBody()
|
|
9041
9314
|
};
|
|
@@ -9050,12 +9323,12 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
9050
9323
|
relativePath: relativePathFromCwd,
|
|
9051
9324
|
intendedRootDir: process.cwd()
|
|
9052
9325
|
});
|
|
9053
|
-
const filename = (0,
|
|
9054
|
-
const fullPath = (0,
|
|
9326
|
+
const filename = (0, import_node_path87.basename)(relativePathFromCwd);
|
|
9327
|
+
const fullPath = (0, import_node_path87.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename);
|
|
9055
9328
|
try {
|
|
9056
9329
|
await removeFile(fullPath);
|
|
9057
9330
|
return {
|
|
9058
|
-
relativePathFromCwd: (0,
|
|
9331
|
+
relativePathFromCwd: (0, import_node_path87.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
9059
9332
|
};
|
|
9060
9333
|
} catch (error) {
|
|
9061
9334
|
throw new Error(`Failed to delete command file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -9064,23 +9337,23 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
9064
9337
|
}
|
|
9065
9338
|
}
|
|
9066
9339
|
var commandToolSchemas = {
|
|
9067
|
-
listCommands:
|
|
9068
|
-
getCommand:
|
|
9069
|
-
relativePathFromCwd:
|
|
9340
|
+
listCommands: import_mini34.z.object({}),
|
|
9341
|
+
getCommand: import_mini34.z.object({
|
|
9342
|
+
relativePathFromCwd: import_mini34.z.string()
|
|
9070
9343
|
}),
|
|
9071
|
-
putCommand:
|
|
9072
|
-
relativePathFromCwd:
|
|
9344
|
+
putCommand: import_mini34.z.object({
|
|
9345
|
+
relativePathFromCwd: import_mini34.z.string(),
|
|
9073
9346
|
frontmatter: RulesyncCommandFrontmatterSchema,
|
|
9074
|
-
body:
|
|
9347
|
+
body: import_mini34.z.string()
|
|
9075
9348
|
}),
|
|
9076
|
-
deleteCommand:
|
|
9077
|
-
relativePathFromCwd:
|
|
9349
|
+
deleteCommand: import_mini34.z.object({
|
|
9350
|
+
relativePathFromCwd: import_mini34.z.string()
|
|
9078
9351
|
})
|
|
9079
9352
|
};
|
|
9080
9353
|
var commandTools = {
|
|
9081
9354
|
listCommands: {
|
|
9082
9355
|
name: "listCommands",
|
|
9083
|
-
description: `List all commands from ${(0,
|
|
9356
|
+
description: `List all commands from ${(0, import_node_path87.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
9084
9357
|
parameters: commandToolSchemas.listCommands,
|
|
9085
9358
|
execute: async () => {
|
|
9086
9359
|
const commands = await listCommands();
|
|
@@ -9122,11 +9395,11 @@ var commandTools = {
|
|
|
9122
9395
|
};
|
|
9123
9396
|
|
|
9124
9397
|
// src/mcp/ignore.ts
|
|
9125
|
-
var
|
|
9126
|
-
var
|
|
9398
|
+
var import_node_path88 = require("path");
|
|
9399
|
+
var import_mini35 = require("zod/mini");
|
|
9127
9400
|
var maxIgnoreFileSizeBytes = 100 * 1024;
|
|
9128
9401
|
async function getIgnoreFile() {
|
|
9129
|
-
const ignoreFilePath = (0,
|
|
9402
|
+
const ignoreFilePath = (0, import_node_path88.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
9130
9403
|
try {
|
|
9131
9404
|
const content = await readFileContent(ignoreFilePath);
|
|
9132
9405
|
return {
|
|
@@ -9140,7 +9413,7 @@ async function getIgnoreFile() {
|
|
|
9140
9413
|
}
|
|
9141
9414
|
}
|
|
9142
9415
|
async function putIgnoreFile({ content }) {
|
|
9143
|
-
const ignoreFilePath = (0,
|
|
9416
|
+
const ignoreFilePath = (0, import_node_path88.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
9144
9417
|
const contentSizeBytes = Buffer.byteLength(content, "utf8");
|
|
9145
9418
|
if (contentSizeBytes > maxIgnoreFileSizeBytes) {
|
|
9146
9419
|
throw new Error(
|
|
@@ -9161,8 +9434,8 @@ async function putIgnoreFile({ content }) {
|
|
|
9161
9434
|
}
|
|
9162
9435
|
}
|
|
9163
9436
|
async function deleteIgnoreFile() {
|
|
9164
|
-
const aiignorePath = (0,
|
|
9165
|
-
const legacyIgnorePath = (0,
|
|
9437
|
+
const aiignorePath = (0, import_node_path88.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
9438
|
+
const legacyIgnorePath = (0, import_node_path88.join)(process.cwd(), RULESYNC_IGNORE_RELATIVE_FILE_PATH);
|
|
9166
9439
|
try {
|
|
9167
9440
|
await Promise.all([removeFile(aiignorePath), removeFile(legacyIgnorePath)]);
|
|
9168
9441
|
return {
|
|
@@ -9180,11 +9453,11 @@ async function deleteIgnoreFile() {
|
|
|
9180
9453
|
}
|
|
9181
9454
|
}
|
|
9182
9455
|
var ignoreToolSchemas = {
|
|
9183
|
-
getIgnoreFile:
|
|
9184
|
-
putIgnoreFile:
|
|
9185
|
-
content:
|
|
9456
|
+
getIgnoreFile: import_mini35.z.object({}),
|
|
9457
|
+
putIgnoreFile: import_mini35.z.object({
|
|
9458
|
+
content: import_mini35.z.string()
|
|
9186
9459
|
}),
|
|
9187
|
-
deleteIgnoreFile:
|
|
9460
|
+
deleteIgnoreFile: import_mini35.z.object({})
|
|
9188
9461
|
};
|
|
9189
9462
|
var ignoreTools = {
|
|
9190
9463
|
getIgnoreFile: {
|
|
@@ -9217,8 +9490,8 @@ var ignoreTools = {
|
|
|
9217
9490
|
};
|
|
9218
9491
|
|
|
9219
9492
|
// src/mcp/mcp.ts
|
|
9220
|
-
var
|
|
9221
|
-
var
|
|
9493
|
+
var import_node_path89 = require("path");
|
|
9494
|
+
var import_mini36 = require("zod/mini");
|
|
9222
9495
|
var maxMcpSizeBytes = 1024 * 1024;
|
|
9223
9496
|
async function getMcpFile() {
|
|
9224
9497
|
const config = await ConfigResolver.resolve({});
|
|
@@ -9227,7 +9500,7 @@ async function getMcpFile() {
|
|
|
9227
9500
|
validate: true,
|
|
9228
9501
|
modularMcp: config.getModularMcp()
|
|
9229
9502
|
});
|
|
9230
|
-
const relativePathFromCwd = (0,
|
|
9503
|
+
const relativePathFromCwd = (0, import_node_path89.join)(
|
|
9231
9504
|
rulesyncMcp.getRelativeDirPath(),
|
|
9232
9505
|
rulesyncMcp.getRelativeFilePath()
|
|
9233
9506
|
);
|
|
@@ -9260,7 +9533,7 @@ async function putMcpFile({ content }) {
|
|
|
9260
9533
|
const paths = RulesyncMcp.getSettablePaths();
|
|
9261
9534
|
const relativeDirPath = paths.recommended.relativeDirPath;
|
|
9262
9535
|
const relativeFilePath = paths.recommended.relativeFilePath;
|
|
9263
|
-
const fullPath = (0,
|
|
9536
|
+
const fullPath = (0, import_node_path89.join)(baseDir, relativeDirPath, relativeFilePath);
|
|
9264
9537
|
const rulesyncMcp = new RulesyncMcp({
|
|
9265
9538
|
baseDir,
|
|
9266
9539
|
relativeDirPath,
|
|
@@ -9269,9 +9542,9 @@ async function putMcpFile({ content }) {
|
|
|
9269
9542
|
validate: true,
|
|
9270
9543
|
modularMcp: config.getModularMcp()
|
|
9271
9544
|
});
|
|
9272
|
-
await ensureDir((0,
|
|
9545
|
+
await ensureDir((0, import_node_path89.join)(baseDir, relativeDirPath));
|
|
9273
9546
|
await writeFileContent(fullPath, content);
|
|
9274
|
-
const relativePathFromCwd = (0,
|
|
9547
|
+
const relativePathFromCwd = (0, import_node_path89.join)(relativeDirPath, relativeFilePath);
|
|
9275
9548
|
return {
|
|
9276
9549
|
relativePathFromCwd,
|
|
9277
9550
|
content: rulesyncMcp.getFileContent()
|
|
@@ -9286,15 +9559,15 @@ async function deleteMcpFile() {
|
|
|
9286
9559
|
try {
|
|
9287
9560
|
const baseDir = process.cwd();
|
|
9288
9561
|
const paths = RulesyncMcp.getSettablePaths();
|
|
9289
|
-
const recommendedPath = (0,
|
|
9562
|
+
const recommendedPath = (0, import_node_path89.join)(
|
|
9290
9563
|
baseDir,
|
|
9291
9564
|
paths.recommended.relativeDirPath,
|
|
9292
9565
|
paths.recommended.relativeFilePath
|
|
9293
9566
|
);
|
|
9294
|
-
const legacyPath = (0,
|
|
9567
|
+
const legacyPath = (0, import_node_path89.join)(baseDir, paths.legacy.relativeDirPath, paths.legacy.relativeFilePath);
|
|
9295
9568
|
await removeFile(recommendedPath);
|
|
9296
9569
|
await removeFile(legacyPath);
|
|
9297
|
-
const relativePathFromCwd = (0,
|
|
9570
|
+
const relativePathFromCwd = (0, import_node_path89.join)(
|
|
9298
9571
|
paths.recommended.relativeDirPath,
|
|
9299
9572
|
paths.recommended.relativeFilePath
|
|
9300
9573
|
);
|
|
@@ -9308,11 +9581,11 @@ async function deleteMcpFile() {
|
|
|
9308
9581
|
}
|
|
9309
9582
|
}
|
|
9310
9583
|
var mcpToolSchemas = {
|
|
9311
|
-
getMcpFile:
|
|
9312
|
-
putMcpFile:
|
|
9313
|
-
content:
|
|
9584
|
+
getMcpFile: import_mini36.z.object({}),
|
|
9585
|
+
putMcpFile: import_mini36.z.object({
|
|
9586
|
+
content: import_mini36.z.string()
|
|
9314
9587
|
}),
|
|
9315
|
-
deleteMcpFile:
|
|
9588
|
+
deleteMcpFile: import_mini36.z.object({})
|
|
9316
9589
|
};
|
|
9317
9590
|
var mcpTools = {
|
|
9318
9591
|
getMcpFile: {
|
|
@@ -9345,12 +9618,12 @@ var mcpTools = {
|
|
|
9345
9618
|
};
|
|
9346
9619
|
|
|
9347
9620
|
// src/mcp/rules.ts
|
|
9348
|
-
var
|
|
9349
|
-
var
|
|
9621
|
+
var import_node_path90 = require("path");
|
|
9622
|
+
var import_mini37 = require("zod/mini");
|
|
9350
9623
|
var maxRuleSizeBytes = 1024 * 1024;
|
|
9351
9624
|
var maxRulesCount = 1e3;
|
|
9352
9625
|
async function listRules() {
|
|
9353
|
-
const rulesDir = (0,
|
|
9626
|
+
const rulesDir = (0, import_node_path90.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
9354
9627
|
try {
|
|
9355
9628
|
const files = await listDirectoryFiles(rulesDir);
|
|
9356
9629
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -9363,7 +9636,7 @@ async function listRules() {
|
|
|
9363
9636
|
});
|
|
9364
9637
|
const frontmatter = rule.getFrontmatter();
|
|
9365
9638
|
return {
|
|
9366
|
-
relativePathFromCwd: (0,
|
|
9639
|
+
relativePathFromCwd: (0, import_node_path90.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, file),
|
|
9367
9640
|
frontmatter
|
|
9368
9641
|
};
|
|
9369
9642
|
} catch (error) {
|
|
@@ -9383,14 +9656,14 @@ async function getRule({ relativePathFromCwd }) {
|
|
|
9383
9656
|
relativePath: relativePathFromCwd,
|
|
9384
9657
|
intendedRootDir: process.cwd()
|
|
9385
9658
|
});
|
|
9386
|
-
const filename = (0,
|
|
9659
|
+
const filename = (0, import_node_path90.basename)(relativePathFromCwd);
|
|
9387
9660
|
try {
|
|
9388
9661
|
const rule = await RulesyncRule.fromFile({
|
|
9389
9662
|
relativeFilePath: filename,
|
|
9390
9663
|
validate: true
|
|
9391
9664
|
});
|
|
9392
9665
|
return {
|
|
9393
|
-
relativePathFromCwd: (0,
|
|
9666
|
+
relativePathFromCwd: (0, import_node_path90.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
9394
9667
|
frontmatter: rule.getFrontmatter(),
|
|
9395
9668
|
body: rule.getBody()
|
|
9396
9669
|
};
|
|
@@ -9409,7 +9682,7 @@ async function putRule({
|
|
|
9409
9682
|
relativePath: relativePathFromCwd,
|
|
9410
9683
|
intendedRootDir: process.cwd()
|
|
9411
9684
|
});
|
|
9412
|
-
const filename = (0,
|
|
9685
|
+
const filename = (0, import_node_path90.basename)(relativePathFromCwd);
|
|
9413
9686
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
9414
9687
|
if (estimatedSize > maxRuleSizeBytes) {
|
|
9415
9688
|
throw new Error(
|
|
@@ -9419,7 +9692,7 @@ async function putRule({
|
|
|
9419
9692
|
try {
|
|
9420
9693
|
const existingRules = await listRules();
|
|
9421
9694
|
const isUpdate = existingRules.some(
|
|
9422
|
-
(rule2) => rule2.relativePathFromCwd === (0,
|
|
9695
|
+
(rule2) => rule2.relativePathFromCwd === (0, import_node_path90.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
9423
9696
|
);
|
|
9424
9697
|
if (!isUpdate && existingRules.length >= maxRulesCount) {
|
|
9425
9698
|
throw new Error(`Maximum number of rules (${maxRulesCount}) reached`);
|
|
@@ -9432,11 +9705,11 @@ async function putRule({
|
|
|
9432
9705
|
body,
|
|
9433
9706
|
validate: true
|
|
9434
9707
|
});
|
|
9435
|
-
const rulesDir = (0,
|
|
9708
|
+
const rulesDir = (0, import_node_path90.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
9436
9709
|
await ensureDir(rulesDir);
|
|
9437
9710
|
await writeFileContent(rule.getFilePath(), rule.getFileContent());
|
|
9438
9711
|
return {
|
|
9439
|
-
relativePathFromCwd: (0,
|
|
9712
|
+
relativePathFromCwd: (0, import_node_path90.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
9440
9713
|
frontmatter: rule.getFrontmatter(),
|
|
9441
9714
|
body: rule.getBody()
|
|
9442
9715
|
};
|
|
@@ -9451,12 +9724,12 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
9451
9724
|
relativePath: relativePathFromCwd,
|
|
9452
9725
|
intendedRootDir: process.cwd()
|
|
9453
9726
|
});
|
|
9454
|
-
const filename = (0,
|
|
9455
|
-
const fullPath = (0,
|
|
9727
|
+
const filename = (0, import_node_path90.basename)(relativePathFromCwd);
|
|
9728
|
+
const fullPath = (0, import_node_path90.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH, filename);
|
|
9456
9729
|
try {
|
|
9457
9730
|
await removeFile(fullPath);
|
|
9458
9731
|
return {
|
|
9459
|
-
relativePathFromCwd: (0,
|
|
9732
|
+
relativePathFromCwd: (0, import_node_path90.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
9460
9733
|
};
|
|
9461
9734
|
} catch (error) {
|
|
9462
9735
|
throw new Error(`Failed to delete rule file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -9465,23 +9738,23 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
9465
9738
|
}
|
|
9466
9739
|
}
|
|
9467
9740
|
var ruleToolSchemas = {
|
|
9468
|
-
listRules:
|
|
9469
|
-
getRule:
|
|
9470
|
-
relativePathFromCwd:
|
|
9741
|
+
listRules: import_mini37.z.object({}),
|
|
9742
|
+
getRule: import_mini37.z.object({
|
|
9743
|
+
relativePathFromCwd: import_mini37.z.string()
|
|
9471
9744
|
}),
|
|
9472
|
-
putRule:
|
|
9473
|
-
relativePathFromCwd:
|
|
9745
|
+
putRule: import_mini37.z.object({
|
|
9746
|
+
relativePathFromCwd: import_mini37.z.string(),
|
|
9474
9747
|
frontmatter: RulesyncRuleFrontmatterSchema,
|
|
9475
|
-
body:
|
|
9748
|
+
body: import_mini37.z.string()
|
|
9476
9749
|
}),
|
|
9477
|
-
deleteRule:
|
|
9478
|
-
relativePathFromCwd:
|
|
9750
|
+
deleteRule: import_mini37.z.object({
|
|
9751
|
+
relativePathFromCwd: import_mini37.z.string()
|
|
9479
9752
|
})
|
|
9480
9753
|
};
|
|
9481
9754
|
var ruleTools = {
|
|
9482
9755
|
listRules: {
|
|
9483
9756
|
name: "listRules",
|
|
9484
|
-
description: `List all rules from ${(0,
|
|
9757
|
+
description: `List all rules from ${(0, import_node_path90.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
9485
9758
|
parameters: ruleToolSchemas.listRules,
|
|
9486
9759
|
execute: async () => {
|
|
9487
9760
|
const rules = await listRules();
|
|
@@ -9523,8 +9796,8 @@ var ruleTools = {
|
|
|
9523
9796
|
};
|
|
9524
9797
|
|
|
9525
9798
|
// src/mcp/skills.ts
|
|
9526
|
-
var
|
|
9527
|
-
var
|
|
9799
|
+
var import_node_path91 = require("path");
|
|
9800
|
+
var import_mini38 = require("zod/mini");
|
|
9528
9801
|
var maxSkillSizeBytes = 1024 * 1024;
|
|
9529
9802
|
var maxSkillsCount = 1e3;
|
|
9530
9803
|
function aiDirFileToMcpSkillFile(file) {
|
|
@@ -9540,19 +9813,19 @@ function mcpSkillFileToAiDirFile(file) {
|
|
|
9540
9813
|
};
|
|
9541
9814
|
}
|
|
9542
9815
|
function extractDirName(relativeDirPathFromCwd) {
|
|
9543
|
-
const dirName = (0,
|
|
9816
|
+
const dirName = (0, import_node_path91.basename)(relativeDirPathFromCwd);
|
|
9544
9817
|
if (!dirName) {
|
|
9545
9818
|
throw new Error(`Invalid path: ${relativeDirPathFromCwd}`);
|
|
9546
9819
|
}
|
|
9547
9820
|
return dirName;
|
|
9548
9821
|
}
|
|
9549
9822
|
async function listSkills() {
|
|
9550
|
-
const skillsDir = (0,
|
|
9823
|
+
const skillsDir = (0, import_node_path91.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH);
|
|
9551
9824
|
try {
|
|
9552
|
-
const skillDirPaths = await findFilesByGlobs((0,
|
|
9825
|
+
const skillDirPaths = await findFilesByGlobs((0, import_node_path91.join)(skillsDir, "*"), { type: "dir" });
|
|
9553
9826
|
const skills = await Promise.all(
|
|
9554
9827
|
skillDirPaths.map(async (dirPath) => {
|
|
9555
|
-
const dirName = (0,
|
|
9828
|
+
const dirName = (0, import_node_path91.basename)(dirPath);
|
|
9556
9829
|
if (!dirName) return null;
|
|
9557
9830
|
try {
|
|
9558
9831
|
const skill = await RulesyncSkill.fromDir({
|
|
@@ -9560,7 +9833,7 @@ async function listSkills() {
|
|
|
9560
9833
|
});
|
|
9561
9834
|
const frontmatter = skill.getFrontmatter();
|
|
9562
9835
|
return {
|
|
9563
|
-
relativeDirPathFromCwd: (0,
|
|
9836
|
+
relativeDirPathFromCwd: (0, import_node_path91.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
9564
9837
|
frontmatter
|
|
9565
9838
|
};
|
|
9566
9839
|
} catch (error) {
|
|
@@ -9586,7 +9859,7 @@ async function getSkill({ relativeDirPathFromCwd }) {
|
|
|
9586
9859
|
dirName
|
|
9587
9860
|
});
|
|
9588
9861
|
return {
|
|
9589
|
-
relativeDirPathFromCwd: (0,
|
|
9862
|
+
relativeDirPathFromCwd: (0, import_node_path91.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
9590
9863
|
frontmatter: skill.getFrontmatter(),
|
|
9591
9864
|
body: skill.getBody(),
|
|
9592
9865
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -9620,7 +9893,7 @@ async function putSkill({
|
|
|
9620
9893
|
try {
|
|
9621
9894
|
const existingSkills = await listSkills();
|
|
9622
9895
|
const isUpdate = existingSkills.some(
|
|
9623
|
-
(skill2) => skill2.relativeDirPathFromCwd === (0,
|
|
9896
|
+
(skill2) => skill2.relativeDirPathFromCwd === (0, import_node_path91.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
9624
9897
|
);
|
|
9625
9898
|
if (!isUpdate && existingSkills.length >= maxSkillsCount) {
|
|
9626
9899
|
throw new Error(`Maximum number of skills (${maxSkillsCount}) reached`);
|
|
@@ -9635,9 +9908,9 @@ async function putSkill({
|
|
|
9635
9908
|
otherFiles: aiDirFiles,
|
|
9636
9909
|
validate: true
|
|
9637
9910
|
});
|
|
9638
|
-
const skillDirPath = (0,
|
|
9911
|
+
const skillDirPath = (0, import_node_path91.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
9639
9912
|
await ensureDir(skillDirPath);
|
|
9640
|
-
const skillFilePath = (0,
|
|
9913
|
+
const skillFilePath = (0, import_node_path91.join)(skillDirPath, SKILL_FILE_NAME);
|
|
9641
9914
|
const skillFileContent = stringifyFrontmatter(body, frontmatter);
|
|
9642
9915
|
await writeFileContent(skillFilePath, skillFileContent);
|
|
9643
9916
|
for (const file of otherFiles) {
|
|
@@ -9645,15 +9918,15 @@ async function putSkill({
|
|
|
9645
9918
|
relativePath: file.name,
|
|
9646
9919
|
intendedRootDir: skillDirPath
|
|
9647
9920
|
});
|
|
9648
|
-
const filePath = (0,
|
|
9649
|
-
const fileDir = (0,
|
|
9921
|
+
const filePath = (0, import_node_path91.join)(skillDirPath, file.name);
|
|
9922
|
+
const fileDir = (0, import_node_path91.join)(skillDirPath, (0, import_node_path91.dirname)(file.name));
|
|
9650
9923
|
if (fileDir !== skillDirPath) {
|
|
9651
9924
|
await ensureDir(fileDir);
|
|
9652
9925
|
}
|
|
9653
9926
|
await writeFileContent(filePath, file.body);
|
|
9654
9927
|
}
|
|
9655
9928
|
return {
|
|
9656
|
-
relativeDirPathFromCwd: (0,
|
|
9929
|
+
relativeDirPathFromCwd: (0, import_node_path91.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
9657
9930
|
frontmatter: skill.getFrontmatter(),
|
|
9658
9931
|
body: skill.getBody(),
|
|
9659
9932
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -9675,13 +9948,13 @@ async function deleteSkill({
|
|
|
9675
9948
|
intendedRootDir: process.cwd()
|
|
9676
9949
|
});
|
|
9677
9950
|
const dirName = extractDirName(relativeDirPathFromCwd);
|
|
9678
|
-
const skillDirPath = (0,
|
|
9951
|
+
const skillDirPath = (0, import_node_path91.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
9679
9952
|
try {
|
|
9680
9953
|
if (await directoryExists(skillDirPath)) {
|
|
9681
9954
|
await removeDirectory(skillDirPath);
|
|
9682
9955
|
}
|
|
9683
9956
|
return {
|
|
9684
|
-
relativeDirPathFromCwd: (0,
|
|
9957
|
+
relativeDirPathFromCwd: (0, import_node_path91.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
9685
9958
|
};
|
|
9686
9959
|
} catch (error) {
|
|
9687
9960
|
throw new Error(
|
|
@@ -9692,29 +9965,29 @@ async function deleteSkill({
|
|
|
9692
9965
|
);
|
|
9693
9966
|
}
|
|
9694
9967
|
}
|
|
9695
|
-
var McpSkillFileSchema =
|
|
9696
|
-
name:
|
|
9697
|
-
body:
|
|
9968
|
+
var McpSkillFileSchema = import_mini38.z.object({
|
|
9969
|
+
name: import_mini38.z.string(),
|
|
9970
|
+
body: import_mini38.z.string()
|
|
9698
9971
|
});
|
|
9699
9972
|
var skillToolSchemas = {
|
|
9700
|
-
listSkills:
|
|
9701
|
-
getSkill:
|
|
9702
|
-
relativeDirPathFromCwd:
|
|
9973
|
+
listSkills: import_mini38.z.object({}),
|
|
9974
|
+
getSkill: import_mini38.z.object({
|
|
9975
|
+
relativeDirPathFromCwd: import_mini38.z.string()
|
|
9703
9976
|
}),
|
|
9704
|
-
putSkill:
|
|
9705
|
-
relativeDirPathFromCwd:
|
|
9977
|
+
putSkill: import_mini38.z.object({
|
|
9978
|
+
relativeDirPathFromCwd: import_mini38.z.string(),
|
|
9706
9979
|
frontmatter: RulesyncSkillFrontmatterSchema,
|
|
9707
|
-
body:
|
|
9708
|
-
otherFiles:
|
|
9980
|
+
body: import_mini38.z.string(),
|
|
9981
|
+
otherFiles: import_mini38.z.optional(import_mini38.z.array(McpSkillFileSchema))
|
|
9709
9982
|
}),
|
|
9710
|
-
deleteSkill:
|
|
9711
|
-
relativeDirPathFromCwd:
|
|
9983
|
+
deleteSkill: import_mini38.z.object({
|
|
9984
|
+
relativeDirPathFromCwd: import_mini38.z.string()
|
|
9712
9985
|
})
|
|
9713
9986
|
};
|
|
9714
9987
|
var skillTools = {
|
|
9715
9988
|
listSkills: {
|
|
9716
9989
|
name: "listSkills",
|
|
9717
|
-
description: `List all skills from ${(0,
|
|
9990
|
+
description: `List all skills from ${(0, import_node_path91.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "*", SKILL_FILE_NAME)} with their frontmatter.`,
|
|
9718
9991
|
parameters: skillToolSchemas.listSkills,
|
|
9719
9992
|
execute: async () => {
|
|
9720
9993
|
const skills = await listSkills();
|
|
@@ -9757,12 +10030,12 @@ var skillTools = {
|
|
|
9757
10030
|
};
|
|
9758
10031
|
|
|
9759
10032
|
// src/mcp/subagents.ts
|
|
9760
|
-
var
|
|
9761
|
-
var
|
|
10033
|
+
var import_node_path92 = require("path");
|
|
10034
|
+
var import_mini39 = require("zod/mini");
|
|
9762
10035
|
var maxSubagentSizeBytes = 1024 * 1024;
|
|
9763
10036
|
var maxSubagentsCount = 1e3;
|
|
9764
10037
|
async function listSubagents() {
|
|
9765
|
-
const subagentsDir = (0,
|
|
10038
|
+
const subagentsDir = (0, import_node_path92.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
9766
10039
|
try {
|
|
9767
10040
|
const files = await listDirectoryFiles(subagentsDir);
|
|
9768
10041
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -9775,7 +10048,7 @@ async function listSubagents() {
|
|
|
9775
10048
|
});
|
|
9776
10049
|
const frontmatter = subagent.getFrontmatter();
|
|
9777
10050
|
return {
|
|
9778
|
-
relativePathFromCwd: (0,
|
|
10051
|
+
relativePathFromCwd: (0, import_node_path92.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, file),
|
|
9779
10052
|
frontmatter
|
|
9780
10053
|
};
|
|
9781
10054
|
} catch (error) {
|
|
@@ -9797,14 +10070,14 @@ async function getSubagent({ relativePathFromCwd }) {
|
|
|
9797
10070
|
relativePath: relativePathFromCwd,
|
|
9798
10071
|
intendedRootDir: process.cwd()
|
|
9799
10072
|
});
|
|
9800
|
-
const filename = (0,
|
|
10073
|
+
const filename = (0, import_node_path92.basename)(relativePathFromCwd);
|
|
9801
10074
|
try {
|
|
9802
10075
|
const subagent = await RulesyncSubagent.fromFile({
|
|
9803
10076
|
relativeFilePath: filename,
|
|
9804
10077
|
validate: true
|
|
9805
10078
|
});
|
|
9806
10079
|
return {
|
|
9807
|
-
relativePathFromCwd: (0,
|
|
10080
|
+
relativePathFromCwd: (0, import_node_path92.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
9808
10081
|
frontmatter: subagent.getFrontmatter(),
|
|
9809
10082
|
body: subagent.getBody()
|
|
9810
10083
|
};
|
|
@@ -9823,7 +10096,7 @@ async function putSubagent({
|
|
|
9823
10096
|
relativePath: relativePathFromCwd,
|
|
9824
10097
|
intendedRootDir: process.cwd()
|
|
9825
10098
|
});
|
|
9826
|
-
const filename = (0,
|
|
10099
|
+
const filename = (0, import_node_path92.basename)(relativePathFromCwd);
|
|
9827
10100
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
9828
10101
|
if (estimatedSize > maxSubagentSizeBytes) {
|
|
9829
10102
|
throw new Error(
|
|
@@ -9833,7 +10106,7 @@ async function putSubagent({
|
|
|
9833
10106
|
try {
|
|
9834
10107
|
const existingSubagents = await listSubagents();
|
|
9835
10108
|
const isUpdate = existingSubagents.some(
|
|
9836
|
-
(subagent2) => subagent2.relativePathFromCwd === (0,
|
|
10109
|
+
(subagent2) => subagent2.relativePathFromCwd === (0, import_node_path92.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
9837
10110
|
);
|
|
9838
10111
|
if (!isUpdate && existingSubagents.length >= maxSubagentsCount) {
|
|
9839
10112
|
throw new Error(`Maximum number of subagents (${maxSubagentsCount}) reached`);
|
|
@@ -9846,11 +10119,11 @@ async function putSubagent({
|
|
|
9846
10119
|
body,
|
|
9847
10120
|
validate: true
|
|
9848
10121
|
});
|
|
9849
|
-
const subagentsDir = (0,
|
|
10122
|
+
const subagentsDir = (0, import_node_path92.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
9850
10123
|
await ensureDir(subagentsDir);
|
|
9851
10124
|
await writeFileContent(subagent.getFilePath(), subagent.getFileContent());
|
|
9852
10125
|
return {
|
|
9853
|
-
relativePathFromCwd: (0,
|
|
10126
|
+
relativePathFromCwd: (0, import_node_path92.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
9854
10127
|
frontmatter: subagent.getFrontmatter(),
|
|
9855
10128
|
body: subagent.getBody()
|
|
9856
10129
|
};
|
|
@@ -9865,12 +10138,12 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
9865
10138
|
relativePath: relativePathFromCwd,
|
|
9866
10139
|
intendedRootDir: process.cwd()
|
|
9867
10140
|
});
|
|
9868
|
-
const filename = (0,
|
|
9869
|
-
const fullPath = (0,
|
|
10141
|
+
const filename = (0, import_node_path92.basename)(relativePathFromCwd);
|
|
10142
|
+
const fullPath = (0, import_node_path92.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename);
|
|
9870
10143
|
try {
|
|
9871
10144
|
await removeFile(fullPath);
|
|
9872
10145
|
return {
|
|
9873
|
-
relativePathFromCwd: (0,
|
|
10146
|
+
relativePathFromCwd: (0, import_node_path92.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
9874
10147
|
};
|
|
9875
10148
|
} catch (error) {
|
|
9876
10149
|
throw new Error(
|
|
@@ -9882,23 +10155,23 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
9882
10155
|
}
|
|
9883
10156
|
}
|
|
9884
10157
|
var subagentToolSchemas = {
|
|
9885
|
-
listSubagents:
|
|
9886
|
-
getSubagent:
|
|
9887
|
-
relativePathFromCwd:
|
|
10158
|
+
listSubagents: import_mini39.z.object({}),
|
|
10159
|
+
getSubagent: import_mini39.z.object({
|
|
10160
|
+
relativePathFromCwd: import_mini39.z.string()
|
|
9888
10161
|
}),
|
|
9889
|
-
putSubagent:
|
|
9890
|
-
relativePathFromCwd:
|
|
10162
|
+
putSubagent: import_mini39.z.object({
|
|
10163
|
+
relativePathFromCwd: import_mini39.z.string(),
|
|
9891
10164
|
frontmatter: RulesyncSubagentFrontmatterSchema,
|
|
9892
|
-
body:
|
|
10165
|
+
body: import_mini39.z.string()
|
|
9893
10166
|
}),
|
|
9894
|
-
deleteSubagent:
|
|
9895
|
-
relativePathFromCwd:
|
|
10167
|
+
deleteSubagent: import_mini39.z.object({
|
|
10168
|
+
relativePathFromCwd: import_mini39.z.string()
|
|
9896
10169
|
})
|
|
9897
10170
|
};
|
|
9898
10171
|
var subagentTools = {
|
|
9899
10172
|
listSubagents: {
|
|
9900
10173
|
name: "listSubagents",
|
|
9901
|
-
description: `List all subagents from ${(0,
|
|
10174
|
+
description: `List all subagents from ${(0, import_node_path92.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
9902
10175
|
parameters: subagentToolSchemas.listSubagents,
|
|
9903
10176
|
execute: async () => {
|
|
9904
10177
|
const subagents = await listSubagents();
|
|
@@ -9976,7 +10249,7 @@ async function mcpCommand({ version }) {
|
|
|
9976
10249
|
}
|
|
9977
10250
|
|
|
9978
10251
|
// src/cli/index.ts
|
|
9979
|
-
var getVersion = () => "3.
|
|
10252
|
+
var getVersion = () => "3.32.0";
|
|
9980
10253
|
var main = async () => {
|
|
9981
10254
|
const program = new import_commander.Command();
|
|
9982
10255
|
const version = getVersion();
|