rulesync 4.1.0 → 4.2.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 +19 -5
- package/dist/index.cjs +639 -346
- package/dist/index.js +638 -345
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -4704,9 +4704,9 @@ var McpProcessor = class extends FeatureProcessor {
|
|
|
4704
4704
|
};
|
|
4705
4705
|
|
|
4706
4706
|
// src/features/rules/rules-processor.ts
|
|
4707
|
-
import { basename as
|
|
4707
|
+
import { basename as basename21, join as join84 } from "path";
|
|
4708
4708
|
import { encode } from "@toon-format/toon";
|
|
4709
|
-
import { z as
|
|
4709
|
+
import { z as z38 } from "zod/mini";
|
|
4710
4710
|
|
|
4711
4711
|
// src/constants/general.ts
|
|
4712
4712
|
var SKILL_FILE_NAME = "SKILL.md";
|
|
@@ -6455,39 +6455,12 @@ var CodexCliSubagent = class _CodexCliSubagent extends SimulatedSubagent {
|
|
|
6455
6455
|
}
|
|
6456
6456
|
};
|
|
6457
6457
|
|
|
6458
|
-
// src/features/subagents/copilot-subagent.ts
|
|
6459
|
-
import { join as join55 } from "path";
|
|
6460
|
-
var CopilotSubagent = class _CopilotSubagent extends SimulatedSubagent {
|
|
6461
|
-
static getSettablePaths() {
|
|
6462
|
-
return {
|
|
6463
|
-
relativeDirPath: join55(".github", "subagents")
|
|
6464
|
-
};
|
|
6465
|
-
}
|
|
6466
|
-
static async fromFile(params) {
|
|
6467
|
-
const baseParams = await this.fromFileDefault(params);
|
|
6468
|
-
return new _CopilotSubagent(baseParams);
|
|
6469
|
-
}
|
|
6470
|
-
static fromRulesyncSubagent(params) {
|
|
6471
|
-
const baseParams = this.fromRulesyncSubagentDefault(params);
|
|
6472
|
-
return new _CopilotSubagent(baseParams);
|
|
6473
|
-
}
|
|
6474
|
-
static isTargetedByRulesyncSubagent(rulesyncSubagent) {
|
|
6475
|
-
return this.isTargetedByRulesyncSubagentDefault({
|
|
6476
|
-
rulesyncSubagent,
|
|
6477
|
-
toolTarget: "copilot"
|
|
6478
|
-
});
|
|
6479
|
-
}
|
|
6480
|
-
static forDeletion(params) {
|
|
6481
|
-
return new _CopilotSubagent(this.forDeletionDefault(params));
|
|
6482
|
-
}
|
|
6483
|
-
};
|
|
6484
|
-
|
|
6485
6458
|
// src/features/subagents/cursor-subagent.ts
|
|
6486
|
-
import { join as
|
|
6459
|
+
import { join as join55 } from "path";
|
|
6487
6460
|
var CursorSubagent = class _CursorSubagent extends SimulatedSubagent {
|
|
6488
6461
|
static getSettablePaths() {
|
|
6489
6462
|
return {
|
|
6490
|
-
relativeDirPath:
|
|
6463
|
+
relativeDirPath: join55(".cursor", "subagents")
|
|
6491
6464
|
};
|
|
6492
6465
|
}
|
|
6493
6466
|
static async fromFile(params) {
|
|
@@ -6510,11 +6483,11 @@ var CursorSubagent = class _CursorSubagent extends SimulatedSubagent {
|
|
|
6510
6483
|
};
|
|
6511
6484
|
|
|
6512
6485
|
// src/features/subagents/geminicli-subagent.ts
|
|
6513
|
-
import { join as
|
|
6486
|
+
import { join as join56 } from "path";
|
|
6514
6487
|
var GeminiCliSubagent = class _GeminiCliSubagent extends SimulatedSubagent {
|
|
6515
6488
|
static getSettablePaths() {
|
|
6516
6489
|
return {
|
|
6517
|
-
relativeDirPath:
|
|
6490
|
+
relativeDirPath: join56(".gemini", "subagents")
|
|
6518
6491
|
};
|
|
6519
6492
|
}
|
|
6520
6493
|
static async fromFile(params) {
|
|
@@ -6537,11 +6510,11 @@ var GeminiCliSubagent = class _GeminiCliSubagent extends SimulatedSubagent {
|
|
|
6537
6510
|
};
|
|
6538
6511
|
|
|
6539
6512
|
// src/features/subagents/roo-subagent.ts
|
|
6540
|
-
import { join as
|
|
6513
|
+
import { join as join57 } from "path";
|
|
6541
6514
|
var RooSubagent = class _RooSubagent extends SimulatedSubagent {
|
|
6542
6515
|
static getSettablePaths() {
|
|
6543
6516
|
return {
|
|
6544
|
-
relativeDirPath:
|
|
6517
|
+
relativeDirPath: join57(".roo", "subagents")
|
|
6545
6518
|
};
|
|
6546
6519
|
}
|
|
6547
6520
|
static async fromFile(params) {
|
|
@@ -6564,15 +6537,15 @@ var RooSubagent = class _RooSubagent extends SimulatedSubagent {
|
|
|
6564
6537
|
};
|
|
6565
6538
|
|
|
6566
6539
|
// src/features/subagents/subagents-processor.ts
|
|
6567
|
-
import { basename as
|
|
6568
|
-
import { z as
|
|
6540
|
+
import { basename as basename18, join as join62 } from "path";
|
|
6541
|
+
import { z as z31 } from "zod/mini";
|
|
6569
6542
|
|
|
6570
6543
|
// src/features/subagents/claudecode-subagent.ts
|
|
6571
|
-
import { join as
|
|
6544
|
+
import { join as join59 } from "path";
|
|
6572
6545
|
import { z as z28 } from "zod/mini";
|
|
6573
6546
|
|
|
6574
6547
|
// src/features/subagents/rulesync-subagent.ts
|
|
6575
|
-
import { basename as basename16, join as
|
|
6548
|
+
import { basename as basename16, join as join58 } from "path";
|
|
6576
6549
|
import { z as z27 } from "zod/mini";
|
|
6577
6550
|
var RulesyncSubagentFrontmatterSchema = z27.looseObject({
|
|
6578
6551
|
targets: RulesyncTargetsSchema,
|
|
@@ -6587,7 +6560,7 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
6587
6560
|
const result = RulesyncSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6588
6561
|
if (!result.success) {
|
|
6589
6562
|
throw new Error(
|
|
6590
|
-
`Invalid frontmatter in ${
|
|
6563
|
+
`Invalid frontmatter in ${join58(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6591
6564
|
);
|
|
6592
6565
|
}
|
|
6593
6566
|
}
|
|
@@ -6620,7 +6593,7 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
6620
6593
|
return {
|
|
6621
6594
|
success: false,
|
|
6622
6595
|
error: new Error(
|
|
6623
|
-
`Invalid frontmatter in ${
|
|
6596
|
+
`Invalid frontmatter in ${join58(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6624
6597
|
)
|
|
6625
6598
|
};
|
|
6626
6599
|
}
|
|
@@ -6629,7 +6602,7 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
6629
6602
|
relativeFilePath
|
|
6630
6603
|
}) {
|
|
6631
6604
|
const fileContent = await readFileContent(
|
|
6632
|
-
|
|
6605
|
+
join58(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, relativeFilePath)
|
|
6633
6606
|
);
|
|
6634
6607
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
6635
6608
|
const result = RulesyncSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -6664,7 +6637,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6664
6637
|
const result = ClaudecodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6665
6638
|
if (!result.success) {
|
|
6666
6639
|
throw new Error(
|
|
6667
|
-
`Invalid frontmatter in ${
|
|
6640
|
+
`Invalid frontmatter in ${join59(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6668
6641
|
);
|
|
6669
6642
|
}
|
|
6670
6643
|
}
|
|
@@ -6676,7 +6649,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6676
6649
|
}
|
|
6677
6650
|
static getSettablePaths(_options = {}) {
|
|
6678
6651
|
return {
|
|
6679
|
-
relativeDirPath:
|
|
6652
|
+
relativeDirPath: join59(".claude", "agents")
|
|
6680
6653
|
};
|
|
6681
6654
|
}
|
|
6682
6655
|
getFrontmatter() {
|
|
@@ -6750,7 +6723,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6750
6723
|
return {
|
|
6751
6724
|
success: false,
|
|
6752
6725
|
error: new Error(
|
|
6753
|
-
`Invalid frontmatter in ${
|
|
6726
|
+
`Invalid frontmatter in ${join59(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6754
6727
|
)
|
|
6755
6728
|
};
|
|
6756
6729
|
}
|
|
@@ -6768,7 +6741,7 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6768
6741
|
global = false
|
|
6769
6742
|
}) {
|
|
6770
6743
|
const paths = this.getSettablePaths({ global });
|
|
6771
|
-
const filePath =
|
|
6744
|
+
const filePath = join59(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
6772
6745
|
const fileContent = await readFileContent(filePath);
|
|
6773
6746
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
6774
6747
|
const result = ClaudecodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
@@ -6802,6 +6775,320 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
6802
6775
|
}
|
|
6803
6776
|
};
|
|
6804
6777
|
|
|
6778
|
+
// src/features/subagents/copilot-subagent.ts
|
|
6779
|
+
import { join as join60 } from "path";
|
|
6780
|
+
import { z as z29 } from "zod/mini";
|
|
6781
|
+
var REQUIRED_TOOL = "agent/runSubagent";
|
|
6782
|
+
var CopilotSubagentFrontmatterSchema = z29.looseObject({
|
|
6783
|
+
name: z29.string(),
|
|
6784
|
+
description: z29.string(),
|
|
6785
|
+
tools: z29.optional(z29.union([z29.string(), z29.array(z29.string())]))
|
|
6786
|
+
});
|
|
6787
|
+
var normalizeTools = (tools) => {
|
|
6788
|
+
if (!tools) {
|
|
6789
|
+
return [];
|
|
6790
|
+
}
|
|
6791
|
+
return Array.isArray(tools) ? tools : [tools];
|
|
6792
|
+
};
|
|
6793
|
+
var ensureRequiredTool = (tools) => {
|
|
6794
|
+
const mergedTools = /* @__PURE__ */ new Set([REQUIRED_TOOL, ...tools]);
|
|
6795
|
+
return Array.from(mergedTools);
|
|
6796
|
+
};
|
|
6797
|
+
var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
6798
|
+
frontmatter;
|
|
6799
|
+
body;
|
|
6800
|
+
constructor({ frontmatter, body, ...rest }) {
|
|
6801
|
+
if (rest.validate !== false) {
|
|
6802
|
+
const result = CopilotSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6803
|
+
if (!result.success) {
|
|
6804
|
+
throw new Error(
|
|
6805
|
+
`Invalid frontmatter in ${join60(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6806
|
+
);
|
|
6807
|
+
}
|
|
6808
|
+
}
|
|
6809
|
+
super({
|
|
6810
|
+
...rest
|
|
6811
|
+
});
|
|
6812
|
+
this.frontmatter = frontmatter;
|
|
6813
|
+
this.body = body;
|
|
6814
|
+
}
|
|
6815
|
+
static getSettablePaths(_options = {}) {
|
|
6816
|
+
return {
|
|
6817
|
+
relativeDirPath: join60(".github", "agents")
|
|
6818
|
+
};
|
|
6819
|
+
}
|
|
6820
|
+
getFrontmatter() {
|
|
6821
|
+
return this.frontmatter;
|
|
6822
|
+
}
|
|
6823
|
+
getBody() {
|
|
6824
|
+
return this.body;
|
|
6825
|
+
}
|
|
6826
|
+
toRulesyncSubagent() {
|
|
6827
|
+
const { name, description, tools, ...rest } = this.frontmatter;
|
|
6828
|
+
const rulesyncFrontmatter = {
|
|
6829
|
+
targets: ["copilot"],
|
|
6830
|
+
name,
|
|
6831
|
+
description,
|
|
6832
|
+
copilot: {
|
|
6833
|
+
...tools && { tools },
|
|
6834
|
+
...rest
|
|
6835
|
+
}
|
|
6836
|
+
};
|
|
6837
|
+
return new RulesyncSubagent({
|
|
6838
|
+
baseDir: ".",
|
|
6839
|
+
// RulesyncCommand baseDir is always the project root directory
|
|
6840
|
+
frontmatter: rulesyncFrontmatter,
|
|
6841
|
+
body: this.body,
|
|
6842
|
+
relativeDirPath: RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH,
|
|
6843
|
+
relativeFilePath: this.getRelativeFilePath(),
|
|
6844
|
+
validate: true
|
|
6845
|
+
});
|
|
6846
|
+
}
|
|
6847
|
+
static fromRulesyncSubagent({
|
|
6848
|
+
baseDir = process.cwd(),
|
|
6849
|
+
rulesyncSubagent,
|
|
6850
|
+
validate = true,
|
|
6851
|
+
global = false
|
|
6852
|
+
}) {
|
|
6853
|
+
const rulesyncFrontmatter = rulesyncSubagent.getFrontmatter();
|
|
6854
|
+
const copilotSection = rulesyncFrontmatter.copilot ?? {};
|
|
6855
|
+
const toolsField = copilotSection.tools;
|
|
6856
|
+
const userTools = normalizeTools(
|
|
6857
|
+
Array.isArray(toolsField) || typeof toolsField === "string" ? toolsField : void 0
|
|
6858
|
+
);
|
|
6859
|
+
const mergedTools = ensureRequiredTool(userTools);
|
|
6860
|
+
const copilotFrontmatter = {
|
|
6861
|
+
name: rulesyncFrontmatter.name,
|
|
6862
|
+
description: rulesyncFrontmatter.description,
|
|
6863
|
+
...copilotSection,
|
|
6864
|
+
...mergedTools.length > 0 && { tools: mergedTools }
|
|
6865
|
+
};
|
|
6866
|
+
const body = rulesyncSubagent.getBody();
|
|
6867
|
+
const fileContent = stringifyFrontmatter(body, copilotFrontmatter);
|
|
6868
|
+
const paths = this.getSettablePaths({ global });
|
|
6869
|
+
return new _CopilotSubagent({
|
|
6870
|
+
baseDir,
|
|
6871
|
+
frontmatter: copilotFrontmatter,
|
|
6872
|
+
body,
|
|
6873
|
+
relativeDirPath: paths.relativeDirPath,
|
|
6874
|
+
relativeFilePath: rulesyncSubagent.getRelativeFilePath(),
|
|
6875
|
+
fileContent,
|
|
6876
|
+
validate,
|
|
6877
|
+
global
|
|
6878
|
+
});
|
|
6879
|
+
}
|
|
6880
|
+
validate() {
|
|
6881
|
+
if (!this.frontmatter) {
|
|
6882
|
+
return { success: true, error: null };
|
|
6883
|
+
}
|
|
6884
|
+
const result = CopilotSubagentFrontmatterSchema.safeParse(this.frontmatter);
|
|
6885
|
+
if (result.success) {
|
|
6886
|
+
return { success: true, error: null };
|
|
6887
|
+
} else {
|
|
6888
|
+
return {
|
|
6889
|
+
success: false,
|
|
6890
|
+
error: new Error(
|
|
6891
|
+
`Invalid frontmatter in ${join60(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
6892
|
+
)
|
|
6893
|
+
};
|
|
6894
|
+
}
|
|
6895
|
+
}
|
|
6896
|
+
static isTargetedByRulesyncSubagent(rulesyncSubagent) {
|
|
6897
|
+
return this.isTargetedByRulesyncSubagentDefault({
|
|
6898
|
+
rulesyncSubagent,
|
|
6899
|
+
toolTarget: "copilot"
|
|
6900
|
+
});
|
|
6901
|
+
}
|
|
6902
|
+
static async fromFile({
|
|
6903
|
+
baseDir = process.cwd(),
|
|
6904
|
+
relativeFilePath,
|
|
6905
|
+
validate = true,
|
|
6906
|
+
global = false
|
|
6907
|
+
}) {
|
|
6908
|
+
const paths = this.getSettablePaths({ global });
|
|
6909
|
+
const filePath = join60(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
6910
|
+
const fileContent = await readFileContent(filePath);
|
|
6911
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
6912
|
+
const result = CopilotSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6913
|
+
if (!result.success) {
|
|
6914
|
+
throw new Error(`Invalid frontmatter in ${filePath}: ${formatError(result.error)}`);
|
|
6915
|
+
}
|
|
6916
|
+
return new _CopilotSubagent({
|
|
6917
|
+
baseDir,
|
|
6918
|
+
relativeDirPath: paths.relativeDirPath,
|
|
6919
|
+
relativeFilePath,
|
|
6920
|
+
frontmatter: result.data,
|
|
6921
|
+
body: content.trim(),
|
|
6922
|
+
fileContent,
|
|
6923
|
+
validate,
|
|
6924
|
+
global
|
|
6925
|
+
});
|
|
6926
|
+
}
|
|
6927
|
+
static forDeletion({
|
|
6928
|
+
baseDir = process.cwd(),
|
|
6929
|
+
relativeDirPath,
|
|
6930
|
+
relativeFilePath
|
|
6931
|
+
}) {
|
|
6932
|
+
return new _CopilotSubagent({
|
|
6933
|
+
baseDir,
|
|
6934
|
+
relativeDirPath,
|
|
6935
|
+
relativeFilePath,
|
|
6936
|
+
frontmatter: { name: "", description: "" },
|
|
6937
|
+
body: "",
|
|
6938
|
+
fileContent: "",
|
|
6939
|
+
validate: false
|
|
6940
|
+
});
|
|
6941
|
+
}
|
|
6942
|
+
};
|
|
6943
|
+
|
|
6944
|
+
// src/features/subagents/opencode-subagent.ts
|
|
6945
|
+
import { basename as basename17, join as join61 } from "path";
|
|
6946
|
+
import { z as z30 } from "zod/mini";
|
|
6947
|
+
var OpenCodeSubagentFrontmatterSchema = z30.looseObject({
|
|
6948
|
+
description: z30.string(),
|
|
6949
|
+
mode: z30.literal("subagent"),
|
|
6950
|
+
name: z30.optional(z30.string())
|
|
6951
|
+
});
|
|
6952
|
+
var OpenCodeSubagent = class _OpenCodeSubagent extends ToolSubagent {
|
|
6953
|
+
frontmatter;
|
|
6954
|
+
body;
|
|
6955
|
+
constructor({ frontmatter, body, ...rest }) {
|
|
6956
|
+
if (rest.validate !== false) {
|
|
6957
|
+
const result = OpenCodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
6958
|
+
if (!result.success) {
|
|
6959
|
+
throw new Error(
|
|
6960
|
+
`Invalid frontmatter in ${join61(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
6961
|
+
);
|
|
6962
|
+
}
|
|
6963
|
+
}
|
|
6964
|
+
super({
|
|
6965
|
+
...rest
|
|
6966
|
+
});
|
|
6967
|
+
this.frontmatter = frontmatter;
|
|
6968
|
+
this.body = body;
|
|
6969
|
+
}
|
|
6970
|
+
static getSettablePaths({
|
|
6971
|
+
global = false
|
|
6972
|
+
} = {}) {
|
|
6973
|
+
return {
|
|
6974
|
+
relativeDirPath: global ? join61(".config", "opencode", "agent") : join61(".opencode", "agent")
|
|
6975
|
+
};
|
|
6976
|
+
}
|
|
6977
|
+
getFrontmatter() {
|
|
6978
|
+
return this.frontmatter;
|
|
6979
|
+
}
|
|
6980
|
+
getBody() {
|
|
6981
|
+
return this.body;
|
|
6982
|
+
}
|
|
6983
|
+
toRulesyncSubagent() {
|
|
6984
|
+
const { description, mode, name, ...opencodeSection } = this.frontmatter;
|
|
6985
|
+
const rulesyncFrontmatter = {
|
|
6986
|
+
targets: ["opencode"],
|
|
6987
|
+
name: name ?? basename17(this.getRelativeFilePath(), ".md"),
|
|
6988
|
+
description,
|
|
6989
|
+
opencode: { mode, ...opencodeSection }
|
|
6990
|
+
};
|
|
6991
|
+
return new RulesyncSubagent({
|
|
6992
|
+
baseDir: ".",
|
|
6993
|
+
// RulesyncSubagent baseDir is always the project root directory
|
|
6994
|
+
frontmatter: rulesyncFrontmatter,
|
|
6995
|
+
body: this.body,
|
|
6996
|
+
relativeDirPath: RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH,
|
|
6997
|
+
relativeFilePath: this.getRelativeFilePath(),
|
|
6998
|
+
validate: true
|
|
6999
|
+
});
|
|
7000
|
+
}
|
|
7001
|
+
static fromRulesyncSubagent({
|
|
7002
|
+
baseDir = process.cwd(),
|
|
7003
|
+
rulesyncSubagent,
|
|
7004
|
+
validate = true,
|
|
7005
|
+
global = false
|
|
7006
|
+
}) {
|
|
7007
|
+
const rulesyncFrontmatter = rulesyncSubagent.getFrontmatter();
|
|
7008
|
+
const opencodeSection = rulesyncFrontmatter.opencode ?? {};
|
|
7009
|
+
const opencodeFrontmatter = {
|
|
7010
|
+
...opencodeSection,
|
|
7011
|
+
description: rulesyncFrontmatter.description,
|
|
7012
|
+
mode: "subagent",
|
|
7013
|
+
...rulesyncFrontmatter.name && { name: rulesyncFrontmatter.name }
|
|
7014
|
+
};
|
|
7015
|
+
const body = rulesyncSubagent.getBody();
|
|
7016
|
+
const fileContent = stringifyFrontmatter(body, opencodeFrontmatter);
|
|
7017
|
+
const paths = this.getSettablePaths({ global });
|
|
7018
|
+
return new _OpenCodeSubagent({
|
|
7019
|
+
baseDir,
|
|
7020
|
+
frontmatter: opencodeFrontmatter,
|
|
7021
|
+
body,
|
|
7022
|
+
relativeDirPath: paths.relativeDirPath,
|
|
7023
|
+
relativeFilePath: rulesyncSubagent.getRelativeFilePath(),
|
|
7024
|
+
fileContent,
|
|
7025
|
+
validate,
|
|
7026
|
+
global
|
|
7027
|
+
});
|
|
7028
|
+
}
|
|
7029
|
+
validate() {
|
|
7030
|
+
if (!this.frontmatter) {
|
|
7031
|
+
return { success: true, error: null };
|
|
7032
|
+
}
|
|
7033
|
+
const result = OpenCodeSubagentFrontmatterSchema.safeParse(this.frontmatter);
|
|
7034
|
+
if (result.success) {
|
|
7035
|
+
return { success: true, error: null };
|
|
7036
|
+
}
|
|
7037
|
+
return {
|
|
7038
|
+
success: false,
|
|
7039
|
+
error: new Error(
|
|
7040
|
+
`Invalid frontmatter in ${join61(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
7041
|
+
)
|
|
7042
|
+
};
|
|
7043
|
+
}
|
|
7044
|
+
static isTargetedByRulesyncSubagent(rulesyncSubagent) {
|
|
7045
|
+
return this.isTargetedByRulesyncSubagentDefault({
|
|
7046
|
+
rulesyncSubagent,
|
|
7047
|
+
toolTarget: "opencode"
|
|
7048
|
+
});
|
|
7049
|
+
}
|
|
7050
|
+
static async fromFile({
|
|
7051
|
+
baseDir = process.cwd(),
|
|
7052
|
+
relativeFilePath,
|
|
7053
|
+
validate = true,
|
|
7054
|
+
global = false
|
|
7055
|
+
}) {
|
|
7056
|
+
const paths = this.getSettablePaths({ global });
|
|
7057
|
+
const filePath = join61(baseDir, paths.relativeDirPath, relativeFilePath);
|
|
7058
|
+
const fileContent = await readFileContent(filePath);
|
|
7059
|
+
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
7060
|
+
const result = OpenCodeSubagentFrontmatterSchema.safeParse(frontmatter);
|
|
7061
|
+
if (!result.success) {
|
|
7062
|
+
throw new Error(`Invalid frontmatter in ${filePath}: ${formatError(result.error)}`);
|
|
7063
|
+
}
|
|
7064
|
+
return new _OpenCodeSubagent({
|
|
7065
|
+
baseDir,
|
|
7066
|
+
relativeDirPath: paths.relativeDirPath,
|
|
7067
|
+
relativeFilePath,
|
|
7068
|
+
frontmatter: result.data,
|
|
7069
|
+
body: content.trim(),
|
|
7070
|
+
fileContent,
|
|
7071
|
+
validate,
|
|
7072
|
+
global
|
|
7073
|
+
});
|
|
7074
|
+
}
|
|
7075
|
+
static forDeletion({
|
|
7076
|
+
baseDir = process.cwd(),
|
|
7077
|
+
relativeDirPath,
|
|
7078
|
+
relativeFilePath
|
|
7079
|
+
}) {
|
|
7080
|
+
return new _OpenCodeSubagent({
|
|
7081
|
+
baseDir,
|
|
7082
|
+
relativeDirPath,
|
|
7083
|
+
relativeFilePath,
|
|
7084
|
+
frontmatter: { description: "", mode: "subagent" },
|
|
7085
|
+
body: "",
|
|
7086
|
+
fileContent: "",
|
|
7087
|
+
validate: false
|
|
7088
|
+
});
|
|
7089
|
+
}
|
|
7090
|
+
};
|
|
7091
|
+
|
|
6805
7092
|
// src/features/subagents/subagents-processor.ts
|
|
6806
7093
|
var subagentsProcessorToolTargetTuple = [
|
|
6807
7094
|
"agentsmd",
|
|
@@ -6810,9 +7097,10 @@ var subagentsProcessorToolTargetTuple = [
|
|
|
6810
7097
|
"copilot",
|
|
6811
7098
|
"cursor",
|
|
6812
7099
|
"geminicli",
|
|
7100
|
+
"opencode",
|
|
6813
7101
|
"roo"
|
|
6814
7102
|
];
|
|
6815
|
-
var SubagentsProcessorToolTargetSchema =
|
|
7103
|
+
var SubagentsProcessorToolTargetSchema = z31.enum(subagentsProcessorToolTargetTuple);
|
|
6816
7104
|
var toolSubagentFactories = /* @__PURE__ */ new Map([
|
|
6817
7105
|
[
|
|
6818
7106
|
"agentsmd",
|
|
@@ -6826,12 +7114,19 @@ var toolSubagentFactories = /* @__PURE__ */ new Map([
|
|
|
6826
7114
|
"codexcli",
|
|
6827
7115
|
{ class: CodexCliSubagent, meta: { supportsSimulated: true, supportsGlobal: false } }
|
|
6828
7116
|
],
|
|
6829
|
-
[
|
|
7117
|
+
[
|
|
7118
|
+
"copilot",
|
|
7119
|
+
{ class: CopilotSubagent, meta: { supportsSimulated: false, supportsGlobal: false } }
|
|
7120
|
+
],
|
|
6830
7121
|
["cursor", { class: CursorSubagent, meta: { supportsSimulated: true, supportsGlobal: false } }],
|
|
6831
7122
|
[
|
|
6832
7123
|
"geminicli",
|
|
6833
7124
|
{ class: GeminiCliSubagent, meta: { supportsSimulated: true, supportsGlobal: false } }
|
|
6834
7125
|
],
|
|
7126
|
+
[
|
|
7127
|
+
"opencode",
|
|
7128
|
+
{ class: OpenCodeSubagent, meta: { supportsSimulated: false, supportsGlobal: true } }
|
|
7129
|
+
],
|
|
6835
7130
|
["roo", { class: RooSubagent, meta: { supportsSimulated: true, supportsGlobal: false } }]
|
|
6836
7131
|
]);
|
|
6837
7132
|
var defaultGetFactory5 = (target) => {
|
|
@@ -6915,7 +7210,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
6915
7210
|
* Load and parse rulesync subagent files from .rulesync/subagents/ directory
|
|
6916
7211
|
*/
|
|
6917
7212
|
async loadRulesyncFiles() {
|
|
6918
|
-
const subagentsDir =
|
|
7213
|
+
const subagentsDir = join62(this.baseDir, RulesyncSubagent.getSettablePaths().relativeDirPath);
|
|
6919
7214
|
const dirExists = await directoryExists(subagentsDir);
|
|
6920
7215
|
if (!dirExists) {
|
|
6921
7216
|
logger.debug(`Rulesync subagents directory not found: ${subagentsDir}`);
|
|
@@ -6930,7 +7225,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
6930
7225
|
logger.info(`Found ${mdFiles.length} subagent files in ${subagentsDir}`);
|
|
6931
7226
|
const rulesyncSubagents = [];
|
|
6932
7227
|
for (const mdFile of mdFiles) {
|
|
6933
|
-
const filepath =
|
|
7228
|
+
const filepath = join62(subagentsDir, mdFile);
|
|
6934
7229
|
try {
|
|
6935
7230
|
const rulesyncSubagent = await RulesyncSubagent.fromFile({
|
|
6936
7231
|
relativeFilePath: mdFile,
|
|
@@ -6960,14 +7255,14 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
6960
7255
|
const factory = this.getFactory(this.toolTarget);
|
|
6961
7256
|
const paths = factory.class.getSettablePaths({ global: this.global });
|
|
6962
7257
|
const subagentFilePaths = await findFilesByGlobs(
|
|
6963
|
-
|
|
7258
|
+
join62(this.baseDir, paths.relativeDirPath, "*.md")
|
|
6964
7259
|
);
|
|
6965
7260
|
if (forDeletion) {
|
|
6966
7261
|
const toolSubagents2 = subagentFilePaths.map(
|
|
6967
7262
|
(path3) => factory.class.forDeletion({
|
|
6968
7263
|
baseDir: this.baseDir,
|
|
6969
7264
|
relativeDirPath: paths.relativeDirPath,
|
|
6970
|
-
relativeFilePath:
|
|
7265
|
+
relativeFilePath: basename18(path3),
|
|
6971
7266
|
global: this.global
|
|
6972
7267
|
})
|
|
6973
7268
|
).filter((subagent) => subagent.isDeletable());
|
|
@@ -6978,7 +7273,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
6978
7273
|
subagentFilePaths.map(
|
|
6979
7274
|
(path3) => factory.class.fromFile({
|
|
6980
7275
|
baseDir: this.baseDir,
|
|
6981
|
-
relativeFilePath:
|
|
7276
|
+
relativeFilePath: basename18(path3),
|
|
6982
7277
|
global: this.global
|
|
6983
7278
|
})
|
|
6984
7279
|
)
|
|
@@ -7010,48 +7305,48 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7010
7305
|
};
|
|
7011
7306
|
|
|
7012
7307
|
// src/features/rules/agentsmd-rule.ts
|
|
7013
|
-
import { join as
|
|
7308
|
+
import { join as join65 } from "path";
|
|
7014
7309
|
|
|
7015
7310
|
// src/features/rules/tool-rule.ts
|
|
7016
|
-
import { join as
|
|
7311
|
+
import { join as join64 } from "path";
|
|
7017
7312
|
|
|
7018
7313
|
// src/features/rules/rulesync-rule.ts
|
|
7019
|
-
import { basename as
|
|
7020
|
-
import { z as
|
|
7021
|
-
var RulesyncRuleFrontmatterSchema =
|
|
7022
|
-
root:
|
|
7023
|
-
targets:
|
|
7024
|
-
description:
|
|
7025
|
-
globs:
|
|
7026
|
-
agentsmd:
|
|
7027
|
-
|
|
7314
|
+
import { basename as basename19, join as join63 } from "path";
|
|
7315
|
+
import { z as z32 } from "zod/mini";
|
|
7316
|
+
var RulesyncRuleFrontmatterSchema = z32.object({
|
|
7317
|
+
root: z32.optional(z32.optional(z32.boolean())),
|
|
7318
|
+
targets: z32.optional(RulesyncTargetsSchema),
|
|
7319
|
+
description: z32.optional(z32.string()),
|
|
7320
|
+
globs: z32.optional(z32.array(z32.string())),
|
|
7321
|
+
agentsmd: z32.optional(
|
|
7322
|
+
z32.object({
|
|
7028
7323
|
// @example "path/to/subproject"
|
|
7029
|
-
subprojectPath:
|
|
7324
|
+
subprojectPath: z32.optional(z32.string())
|
|
7030
7325
|
})
|
|
7031
7326
|
),
|
|
7032
|
-
claudecode:
|
|
7033
|
-
|
|
7327
|
+
claudecode: z32.optional(
|
|
7328
|
+
z32.object({
|
|
7034
7329
|
// Glob patterns for conditional rules (takes precedence over globs)
|
|
7035
7330
|
// @example "src/**/*.ts, tests/**/*.test.ts"
|
|
7036
|
-
paths:
|
|
7331
|
+
paths: z32.optional(z32.string())
|
|
7037
7332
|
})
|
|
7038
7333
|
),
|
|
7039
|
-
cursor:
|
|
7040
|
-
|
|
7041
|
-
alwaysApply:
|
|
7042
|
-
description:
|
|
7043
|
-
globs:
|
|
7334
|
+
cursor: z32.optional(
|
|
7335
|
+
z32.object({
|
|
7336
|
+
alwaysApply: z32.optional(z32.boolean()),
|
|
7337
|
+
description: z32.optional(z32.string()),
|
|
7338
|
+
globs: z32.optional(z32.array(z32.string()))
|
|
7044
7339
|
})
|
|
7045
7340
|
),
|
|
7046
|
-
copilot:
|
|
7047
|
-
|
|
7048
|
-
excludeAgent:
|
|
7341
|
+
copilot: z32.optional(
|
|
7342
|
+
z32.object({
|
|
7343
|
+
excludeAgent: z32.optional(z32.union([z32.literal("code-review"), z32.literal("coding-agent")]))
|
|
7049
7344
|
})
|
|
7050
7345
|
),
|
|
7051
|
-
antigravity:
|
|
7052
|
-
|
|
7053
|
-
trigger:
|
|
7054
|
-
globs:
|
|
7346
|
+
antigravity: z32.optional(
|
|
7347
|
+
z32.looseObject({
|
|
7348
|
+
trigger: z32.optional(z32.string()),
|
|
7349
|
+
globs: z32.optional(z32.array(z32.string()))
|
|
7055
7350
|
})
|
|
7056
7351
|
)
|
|
7057
7352
|
});
|
|
@@ -7063,7 +7358,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7063
7358
|
const result = RulesyncRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7064
7359
|
if (!result.success) {
|
|
7065
7360
|
throw new Error(
|
|
7066
|
-
`Invalid frontmatter in ${
|
|
7361
|
+
`Invalid frontmatter in ${join63(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
7067
7362
|
);
|
|
7068
7363
|
}
|
|
7069
7364
|
}
|
|
@@ -7098,7 +7393,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7098
7393
|
return {
|
|
7099
7394
|
success: false,
|
|
7100
7395
|
error: new Error(
|
|
7101
|
-
`Invalid frontmatter in ${
|
|
7396
|
+
`Invalid frontmatter in ${join63(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
7102
7397
|
)
|
|
7103
7398
|
};
|
|
7104
7399
|
}
|
|
@@ -7107,12 +7402,12 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7107
7402
|
relativeFilePath,
|
|
7108
7403
|
validate = true
|
|
7109
7404
|
}) {
|
|
7110
|
-
const legacyPath =
|
|
7405
|
+
const legacyPath = join63(
|
|
7111
7406
|
process.cwd(),
|
|
7112
7407
|
this.getSettablePaths().legacy.relativeDirPath,
|
|
7113
7408
|
relativeFilePath
|
|
7114
7409
|
);
|
|
7115
|
-
const recommendedPath =
|
|
7410
|
+
const recommendedPath = join63(
|
|
7116
7411
|
this.getSettablePaths().recommended.relativeDirPath,
|
|
7117
7412
|
relativeFilePath
|
|
7118
7413
|
);
|
|
@@ -7131,7 +7426,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7131
7426
|
agentsmd: result.data.agentsmd,
|
|
7132
7427
|
cursor: result.data.cursor
|
|
7133
7428
|
};
|
|
7134
|
-
const filename =
|
|
7429
|
+
const filename = basename19(legacyPath);
|
|
7135
7430
|
return new _RulesyncRule({
|
|
7136
7431
|
baseDir: process.cwd(),
|
|
7137
7432
|
relativeDirPath: this.getSettablePaths().recommended.relativeDirPath,
|
|
@@ -7145,7 +7440,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7145
7440
|
relativeFilePath,
|
|
7146
7441
|
validate = true
|
|
7147
7442
|
}) {
|
|
7148
|
-
const filePath =
|
|
7443
|
+
const filePath = join63(
|
|
7149
7444
|
process.cwd(),
|
|
7150
7445
|
this.getSettablePaths().recommended.relativeDirPath,
|
|
7151
7446
|
relativeFilePath
|
|
@@ -7164,7 +7459,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7164
7459
|
agentsmd: result.data.agentsmd,
|
|
7165
7460
|
cursor: result.data.cursor
|
|
7166
7461
|
};
|
|
7167
|
-
const filename =
|
|
7462
|
+
const filename = basename19(filePath);
|
|
7168
7463
|
return new _RulesyncRule({
|
|
7169
7464
|
baseDir: process.cwd(),
|
|
7170
7465
|
relativeDirPath: this.getSettablePaths().recommended.relativeDirPath,
|
|
@@ -7247,7 +7542,7 @@ var ToolRule = class extends ToolFile {
|
|
|
7247
7542
|
rulesyncRule,
|
|
7248
7543
|
validate = true,
|
|
7249
7544
|
rootPath = { relativeDirPath: ".", relativeFilePath: "AGENTS.md" },
|
|
7250
|
-
nonRootPath = { relativeDirPath:
|
|
7545
|
+
nonRootPath = { relativeDirPath: join64(".agents", "memories") }
|
|
7251
7546
|
}) {
|
|
7252
7547
|
const params = this.buildToolRuleParamsDefault({
|
|
7253
7548
|
baseDir,
|
|
@@ -7258,7 +7553,7 @@ var ToolRule = class extends ToolFile {
|
|
|
7258
7553
|
});
|
|
7259
7554
|
const rulesyncFrontmatter = rulesyncRule.getFrontmatter();
|
|
7260
7555
|
if (!rulesyncFrontmatter.root && rulesyncFrontmatter.agentsmd?.subprojectPath) {
|
|
7261
|
-
params.relativeDirPath =
|
|
7556
|
+
params.relativeDirPath = join64(rulesyncFrontmatter.agentsmd.subprojectPath);
|
|
7262
7557
|
params.relativeFilePath = "AGENTS.md";
|
|
7263
7558
|
}
|
|
7264
7559
|
return params;
|
|
@@ -7323,7 +7618,7 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
7323
7618
|
relativeFilePath: "AGENTS.md"
|
|
7324
7619
|
},
|
|
7325
7620
|
nonRoot: {
|
|
7326
|
-
relativeDirPath:
|
|
7621
|
+
relativeDirPath: join65(".agents", "memories")
|
|
7327
7622
|
}
|
|
7328
7623
|
};
|
|
7329
7624
|
}
|
|
@@ -7333,8 +7628,8 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
7333
7628
|
validate = true
|
|
7334
7629
|
}) {
|
|
7335
7630
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
7336
|
-
const relativePath = isRoot ? "AGENTS.md" :
|
|
7337
|
-
const fileContent = await readFileContent(
|
|
7631
|
+
const relativePath = isRoot ? "AGENTS.md" : join65(".agents", "memories", relativeFilePath);
|
|
7632
|
+
const fileContent = await readFileContent(join65(baseDir, relativePath));
|
|
7338
7633
|
return new _AgentsMdRule({
|
|
7339
7634
|
baseDir,
|
|
7340
7635
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -7389,12 +7684,12 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
7389
7684
|
};
|
|
7390
7685
|
|
|
7391
7686
|
// src/features/rules/amazonqcli-rule.ts
|
|
7392
|
-
import { join as
|
|
7687
|
+
import { join as join66 } from "path";
|
|
7393
7688
|
var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
7394
7689
|
static getSettablePaths() {
|
|
7395
7690
|
return {
|
|
7396
7691
|
nonRoot: {
|
|
7397
|
-
relativeDirPath:
|
|
7692
|
+
relativeDirPath: join66(".amazonq", "rules")
|
|
7398
7693
|
}
|
|
7399
7694
|
};
|
|
7400
7695
|
}
|
|
@@ -7404,7 +7699,7 @@ var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
|
7404
7699
|
validate = true
|
|
7405
7700
|
}) {
|
|
7406
7701
|
const fileContent = await readFileContent(
|
|
7407
|
-
|
|
7702
|
+
join66(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7408
7703
|
);
|
|
7409
7704
|
return new _AmazonQCliRule({
|
|
7410
7705
|
baseDir,
|
|
@@ -7458,21 +7753,21 @@ var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
|
7458
7753
|
};
|
|
7459
7754
|
|
|
7460
7755
|
// src/features/rules/antigravity-rule.ts
|
|
7461
|
-
import { join as
|
|
7462
|
-
import { z as
|
|
7463
|
-
var AntigravityRuleFrontmatterSchema =
|
|
7464
|
-
trigger:
|
|
7465
|
-
|
|
7466
|
-
|
|
7467
|
-
|
|
7468
|
-
|
|
7469
|
-
|
|
7470
|
-
|
|
7756
|
+
import { join as join67 } from "path";
|
|
7757
|
+
import { z as z33 } from "zod/mini";
|
|
7758
|
+
var AntigravityRuleFrontmatterSchema = z33.looseObject({
|
|
7759
|
+
trigger: z33.optional(
|
|
7760
|
+
z33.union([
|
|
7761
|
+
z33.literal("always_on"),
|
|
7762
|
+
z33.literal("glob"),
|
|
7763
|
+
z33.literal("manual"),
|
|
7764
|
+
z33.literal("model_decision"),
|
|
7765
|
+
z33.string()
|
|
7471
7766
|
// accepts any string for forward compatibility
|
|
7472
7767
|
])
|
|
7473
7768
|
),
|
|
7474
|
-
globs:
|
|
7475
|
-
description:
|
|
7769
|
+
globs: z33.optional(z33.string()),
|
|
7770
|
+
description: z33.optional(z33.string())
|
|
7476
7771
|
});
|
|
7477
7772
|
function parseGlobsString(globs) {
|
|
7478
7773
|
if (!globs) {
|
|
@@ -7617,7 +7912,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7617
7912
|
const result = AntigravityRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7618
7913
|
if (!result.success) {
|
|
7619
7914
|
throw new Error(
|
|
7620
|
-
`Invalid frontmatter in ${
|
|
7915
|
+
`Invalid frontmatter in ${join67(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
7621
7916
|
);
|
|
7622
7917
|
}
|
|
7623
7918
|
}
|
|
@@ -7632,7 +7927,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7632
7927
|
static getSettablePaths() {
|
|
7633
7928
|
return {
|
|
7634
7929
|
nonRoot: {
|
|
7635
|
-
relativeDirPath:
|
|
7930
|
+
relativeDirPath: join67(".agent", "rules")
|
|
7636
7931
|
}
|
|
7637
7932
|
};
|
|
7638
7933
|
}
|
|
@@ -7641,7 +7936,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7641
7936
|
relativeFilePath,
|
|
7642
7937
|
validate = true
|
|
7643
7938
|
}) {
|
|
7644
|
-
const filePath =
|
|
7939
|
+
const filePath = join67(
|
|
7645
7940
|
baseDir,
|
|
7646
7941
|
this.getSettablePaths().nonRoot.relativeDirPath,
|
|
7647
7942
|
relativeFilePath
|
|
@@ -7782,7 +8077,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7782
8077
|
};
|
|
7783
8078
|
|
|
7784
8079
|
// src/features/rules/augmentcode-legacy-rule.ts
|
|
7785
|
-
import { join as
|
|
8080
|
+
import { join as join68 } from "path";
|
|
7786
8081
|
var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
7787
8082
|
toRulesyncRule() {
|
|
7788
8083
|
const rulesyncFrontmatter = {
|
|
@@ -7808,7 +8103,7 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
7808
8103
|
relativeFilePath: ".augment-guidelines"
|
|
7809
8104
|
},
|
|
7810
8105
|
nonRoot: {
|
|
7811
|
-
relativeDirPath:
|
|
8106
|
+
relativeDirPath: join68(".augment", "rules")
|
|
7812
8107
|
}
|
|
7813
8108
|
};
|
|
7814
8109
|
}
|
|
@@ -7843,8 +8138,8 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
7843
8138
|
}) {
|
|
7844
8139
|
const settablePaths = this.getSettablePaths();
|
|
7845
8140
|
const isRoot = relativeFilePath === settablePaths.root.relativeFilePath;
|
|
7846
|
-
const relativePath = isRoot ? settablePaths.root.relativeFilePath :
|
|
7847
|
-
const fileContent = await readFileContent(
|
|
8141
|
+
const relativePath = isRoot ? settablePaths.root.relativeFilePath : join68(settablePaths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8142
|
+
const fileContent = await readFileContent(join68(baseDir, relativePath));
|
|
7848
8143
|
return new _AugmentcodeLegacyRule({
|
|
7849
8144
|
baseDir,
|
|
7850
8145
|
relativeDirPath: isRoot ? settablePaths.root.relativeDirPath : settablePaths.nonRoot.relativeDirPath,
|
|
@@ -7873,7 +8168,7 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
7873
8168
|
};
|
|
7874
8169
|
|
|
7875
8170
|
// src/features/rules/augmentcode-rule.ts
|
|
7876
|
-
import { join as
|
|
8171
|
+
import { join as join69 } from "path";
|
|
7877
8172
|
var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
7878
8173
|
toRulesyncRule() {
|
|
7879
8174
|
return this.toRulesyncRuleDefault();
|
|
@@ -7881,7 +8176,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
7881
8176
|
static getSettablePaths() {
|
|
7882
8177
|
return {
|
|
7883
8178
|
nonRoot: {
|
|
7884
|
-
relativeDirPath:
|
|
8179
|
+
relativeDirPath: join69(".augment", "rules")
|
|
7885
8180
|
}
|
|
7886
8181
|
};
|
|
7887
8182
|
}
|
|
@@ -7905,7 +8200,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
7905
8200
|
validate = true
|
|
7906
8201
|
}) {
|
|
7907
8202
|
const fileContent = await readFileContent(
|
|
7908
|
-
|
|
8203
|
+
join69(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7909
8204
|
);
|
|
7910
8205
|
const { body: content } = parseFrontmatter(fileContent);
|
|
7911
8206
|
return new _AugmentcodeRule({
|
|
@@ -7941,7 +8236,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
7941
8236
|
};
|
|
7942
8237
|
|
|
7943
8238
|
// src/features/rules/claudecode-legacy-rule.ts
|
|
7944
|
-
import { join as
|
|
8239
|
+
import { join as join70 } from "path";
|
|
7945
8240
|
var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
7946
8241
|
static getSettablePaths({
|
|
7947
8242
|
global
|
|
@@ -7960,7 +8255,7 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
7960
8255
|
relativeFilePath: "CLAUDE.md"
|
|
7961
8256
|
},
|
|
7962
8257
|
nonRoot: {
|
|
7963
|
-
relativeDirPath:
|
|
8258
|
+
relativeDirPath: join70(".claude", "memories")
|
|
7964
8259
|
}
|
|
7965
8260
|
};
|
|
7966
8261
|
}
|
|
@@ -7975,7 +8270,7 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
7975
8270
|
if (isRoot) {
|
|
7976
8271
|
const relativePath2 = paths.root.relativeFilePath;
|
|
7977
8272
|
const fileContent2 = await readFileContent(
|
|
7978
|
-
|
|
8273
|
+
join70(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
7979
8274
|
);
|
|
7980
8275
|
return new _ClaudecodeLegacyRule({
|
|
7981
8276
|
baseDir,
|
|
@@ -7989,8 +8284,8 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
7989
8284
|
if (!paths.nonRoot) {
|
|
7990
8285
|
throw new Error("nonRoot path is not set");
|
|
7991
8286
|
}
|
|
7992
|
-
const relativePath =
|
|
7993
|
-
const fileContent = await readFileContent(
|
|
8287
|
+
const relativePath = join70(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8288
|
+
const fileContent = await readFileContent(join70(baseDir, relativePath));
|
|
7994
8289
|
return new _ClaudecodeLegacyRule({
|
|
7995
8290
|
baseDir,
|
|
7996
8291
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -8049,10 +8344,10 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
8049
8344
|
};
|
|
8050
8345
|
|
|
8051
8346
|
// src/features/rules/claudecode-rule.ts
|
|
8052
|
-
import { join as
|
|
8053
|
-
import { z as
|
|
8054
|
-
var ClaudecodeRuleFrontmatterSchema =
|
|
8055
|
-
paths:
|
|
8347
|
+
import { join as join71 } from "path";
|
|
8348
|
+
import { z as z34 } from "zod/mini";
|
|
8349
|
+
var ClaudecodeRuleFrontmatterSchema = z34.object({
|
|
8350
|
+
paths: z34.optional(z34.string())
|
|
8056
8351
|
});
|
|
8057
8352
|
var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
8058
8353
|
frontmatter;
|
|
@@ -8074,7 +8369,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8074
8369
|
relativeFilePath: "CLAUDE.md"
|
|
8075
8370
|
},
|
|
8076
8371
|
nonRoot: {
|
|
8077
|
-
relativeDirPath:
|
|
8372
|
+
relativeDirPath: join71(".claude", "rules")
|
|
8078
8373
|
}
|
|
8079
8374
|
};
|
|
8080
8375
|
}
|
|
@@ -8083,7 +8378,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8083
8378
|
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8084
8379
|
if (!result.success) {
|
|
8085
8380
|
throw new Error(
|
|
8086
|
-
`Invalid frontmatter in ${
|
|
8381
|
+
`Invalid frontmatter in ${join71(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
8087
8382
|
);
|
|
8088
8383
|
}
|
|
8089
8384
|
}
|
|
@@ -8111,7 +8406,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8111
8406
|
const isRoot = relativeFilePath === paths.root.relativeFilePath;
|
|
8112
8407
|
if (isRoot) {
|
|
8113
8408
|
const fileContent2 = await readFileContent(
|
|
8114
|
-
|
|
8409
|
+
join71(baseDir, paths.root.relativeDirPath, paths.root.relativeFilePath)
|
|
8115
8410
|
);
|
|
8116
8411
|
return new _ClaudecodeRule({
|
|
8117
8412
|
baseDir,
|
|
@@ -8126,13 +8421,13 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8126
8421
|
if (!paths.nonRoot) {
|
|
8127
8422
|
throw new Error("nonRoot path is not set");
|
|
8128
8423
|
}
|
|
8129
|
-
const relativePath =
|
|
8130
|
-
const fileContent = await readFileContent(
|
|
8424
|
+
const relativePath = join71(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8425
|
+
const fileContent = await readFileContent(join71(baseDir, relativePath));
|
|
8131
8426
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
8132
8427
|
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8133
8428
|
if (!result.success) {
|
|
8134
8429
|
throw new Error(
|
|
8135
|
-
`Invalid frontmatter in ${
|
|
8430
|
+
`Invalid frontmatter in ${join71(baseDir, relativePath)}: ${formatError(result.error)}`
|
|
8136
8431
|
);
|
|
8137
8432
|
}
|
|
8138
8433
|
return new _ClaudecodeRule({
|
|
@@ -8239,7 +8534,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8239
8534
|
return {
|
|
8240
8535
|
success: false,
|
|
8241
8536
|
error: new Error(
|
|
8242
|
-
`Invalid frontmatter in ${
|
|
8537
|
+
`Invalid frontmatter in ${join71(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
8243
8538
|
)
|
|
8244
8539
|
};
|
|
8245
8540
|
}
|
|
@@ -8259,10 +8554,10 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8259
8554
|
};
|
|
8260
8555
|
|
|
8261
8556
|
// src/features/rules/cline-rule.ts
|
|
8262
|
-
import { join as
|
|
8263
|
-
import { z as
|
|
8264
|
-
var ClineRuleFrontmatterSchema =
|
|
8265
|
-
description:
|
|
8557
|
+
import { join as join72 } from "path";
|
|
8558
|
+
import { z as z35 } from "zod/mini";
|
|
8559
|
+
var ClineRuleFrontmatterSchema = z35.object({
|
|
8560
|
+
description: z35.string()
|
|
8266
8561
|
});
|
|
8267
8562
|
var ClineRule = class _ClineRule extends ToolRule {
|
|
8268
8563
|
static getSettablePaths() {
|
|
@@ -8304,7 +8599,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
8304
8599
|
validate = true
|
|
8305
8600
|
}) {
|
|
8306
8601
|
const fileContent = await readFileContent(
|
|
8307
|
-
|
|
8602
|
+
join72(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
8308
8603
|
);
|
|
8309
8604
|
return new _ClineRule({
|
|
8310
8605
|
baseDir,
|
|
@@ -8330,7 +8625,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
8330
8625
|
};
|
|
8331
8626
|
|
|
8332
8627
|
// src/features/rules/codexcli-rule.ts
|
|
8333
|
-
import { join as
|
|
8628
|
+
import { join as join73 } from "path";
|
|
8334
8629
|
var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
8335
8630
|
static getSettablePaths({
|
|
8336
8631
|
global
|
|
@@ -8349,7 +8644,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8349
8644
|
relativeFilePath: "AGENTS.md"
|
|
8350
8645
|
},
|
|
8351
8646
|
nonRoot: {
|
|
8352
|
-
relativeDirPath:
|
|
8647
|
+
relativeDirPath: join73(".codex", "memories")
|
|
8353
8648
|
}
|
|
8354
8649
|
};
|
|
8355
8650
|
}
|
|
@@ -8364,7 +8659,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8364
8659
|
if (isRoot) {
|
|
8365
8660
|
const relativePath2 = paths.root.relativeFilePath;
|
|
8366
8661
|
const fileContent2 = await readFileContent(
|
|
8367
|
-
|
|
8662
|
+
join73(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
8368
8663
|
);
|
|
8369
8664
|
return new _CodexcliRule({
|
|
8370
8665
|
baseDir,
|
|
@@ -8378,8 +8673,8 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8378
8673
|
if (!paths.nonRoot) {
|
|
8379
8674
|
throw new Error("nonRoot path is not set");
|
|
8380
8675
|
}
|
|
8381
|
-
const relativePath =
|
|
8382
|
-
const fileContent = await readFileContent(
|
|
8676
|
+
const relativePath = join73(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8677
|
+
const fileContent = await readFileContent(join73(baseDir, relativePath));
|
|
8383
8678
|
return new _CodexcliRule({
|
|
8384
8679
|
baseDir,
|
|
8385
8680
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -8438,12 +8733,12 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8438
8733
|
};
|
|
8439
8734
|
|
|
8440
8735
|
// src/features/rules/copilot-rule.ts
|
|
8441
|
-
import { join as
|
|
8442
|
-
import { z as
|
|
8443
|
-
var CopilotRuleFrontmatterSchema =
|
|
8444
|
-
description:
|
|
8445
|
-
applyTo:
|
|
8446
|
-
excludeAgent:
|
|
8736
|
+
import { join as join74 } from "path";
|
|
8737
|
+
import { z as z36 } from "zod/mini";
|
|
8738
|
+
var CopilotRuleFrontmatterSchema = z36.object({
|
|
8739
|
+
description: z36.optional(z36.string()),
|
|
8740
|
+
applyTo: z36.optional(z36.string()),
|
|
8741
|
+
excludeAgent: z36.optional(z36.union([z36.literal("code-review"), z36.literal("coding-agent")]))
|
|
8447
8742
|
});
|
|
8448
8743
|
var CopilotRule = class _CopilotRule extends ToolRule {
|
|
8449
8744
|
frontmatter;
|
|
@@ -8455,7 +8750,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8455
8750
|
relativeFilePath: "copilot-instructions.md"
|
|
8456
8751
|
},
|
|
8457
8752
|
nonRoot: {
|
|
8458
|
-
relativeDirPath:
|
|
8753
|
+
relativeDirPath: join74(".github", "instructions")
|
|
8459
8754
|
}
|
|
8460
8755
|
};
|
|
8461
8756
|
}
|
|
@@ -8464,7 +8759,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8464
8759
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8465
8760
|
if (!result.success) {
|
|
8466
8761
|
throw new Error(
|
|
8467
|
-
`Invalid frontmatter in ${
|
|
8762
|
+
`Invalid frontmatter in ${join74(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
8468
8763
|
);
|
|
8469
8764
|
}
|
|
8470
8765
|
}
|
|
@@ -8546,11 +8841,11 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8546
8841
|
validate = true
|
|
8547
8842
|
}) {
|
|
8548
8843
|
const isRoot = relativeFilePath === "copilot-instructions.md";
|
|
8549
|
-
const relativePath = isRoot ?
|
|
8844
|
+
const relativePath = isRoot ? join74(
|
|
8550
8845
|
this.getSettablePaths().root.relativeDirPath,
|
|
8551
8846
|
this.getSettablePaths().root.relativeFilePath
|
|
8552
|
-
) :
|
|
8553
|
-
const fileContent = await readFileContent(
|
|
8847
|
+
) : join74(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
8848
|
+
const fileContent = await readFileContent(join74(baseDir, relativePath));
|
|
8554
8849
|
if (isRoot) {
|
|
8555
8850
|
return new _CopilotRule({
|
|
8556
8851
|
baseDir,
|
|
@@ -8566,7 +8861,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8566
8861
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8567
8862
|
if (!result.success) {
|
|
8568
8863
|
throw new Error(
|
|
8569
|
-
`Invalid frontmatter in ${
|
|
8864
|
+
`Invalid frontmatter in ${join74(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
8570
8865
|
);
|
|
8571
8866
|
}
|
|
8572
8867
|
return new _CopilotRule({
|
|
@@ -8606,7 +8901,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8606
8901
|
return {
|
|
8607
8902
|
success: false,
|
|
8608
8903
|
error: new Error(
|
|
8609
|
-
`Invalid frontmatter in ${
|
|
8904
|
+
`Invalid frontmatter in ${join74(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
8610
8905
|
)
|
|
8611
8906
|
};
|
|
8612
8907
|
}
|
|
@@ -8626,12 +8921,12 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8626
8921
|
};
|
|
8627
8922
|
|
|
8628
8923
|
// src/features/rules/cursor-rule.ts
|
|
8629
|
-
import { basename as
|
|
8630
|
-
import { z as
|
|
8631
|
-
var CursorRuleFrontmatterSchema =
|
|
8632
|
-
description:
|
|
8633
|
-
globs:
|
|
8634
|
-
alwaysApply:
|
|
8924
|
+
import { basename as basename20, join as join75 } from "path";
|
|
8925
|
+
import { z as z37 } from "zod/mini";
|
|
8926
|
+
var CursorRuleFrontmatterSchema = z37.object({
|
|
8927
|
+
description: z37.optional(z37.string()),
|
|
8928
|
+
globs: z37.optional(z37.string()),
|
|
8929
|
+
alwaysApply: z37.optional(z37.boolean())
|
|
8635
8930
|
});
|
|
8636
8931
|
var CursorRule = class _CursorRule extends ToolRule {
|
|
8637
8932
|
frontmatter;
|
|
@@ -8639,7 +8934,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8639
8934
|
static getSettablePaths() {
|
|
8640
8935
|
return {
|
|
8641
8936
|
nonRoot: {
|
|
8642
|
-
relativeDirPath:
|
|
8937
|
+
relativeDirPath: join75(".cursor", "rules")
|
|
8643
8938
|
}
|
|
8644
8939
|
};
|
|
8645
8940
|
}
|
|
@@ -8648,7 +8943,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8648
8943
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8649
8944
|
if (!result.success) {
|
|
8650
8945
|
throw new Error(
|
|
8651
|
-
`Invalid frontmatter in ${
|
|
8946
|
+
`Invalid frontmatter in ${join75(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
8652
8947
|
);
|
|
8653
8948
|
}
|
|
8654
8949
|
}
|
|
@@ -8765,19 +9060,19 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8765
9060
|
validate = true
|
|
8766
9061
|
}) {
|
|
8767
9062
|
const fileContent = await readFileContent(
|
|
8768
|
-
|
|
9063
|
+
join75(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
8769
9064
|
);
|
|
8770
9065
|
const { frontmatter, body: content } = _CursorRule.parseCursorFrontmatter(fileContent);
|
|
8771
9066
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8772
9067
|
if (!result.success) {
|
|
8773
9068
|
throw new Error(
|
|
8774
|
-
`Invalid frontmatter in ${
|
|
9069
|
+
`Invalid frontmatter in ${join75(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
8775
9070
|
);
|
|
8776
9071
|
}
|
|
8777
9072
|
return new _CursorRule({
|
|
8778
9073
|
baseDir,
|
|
8779
9074
|
relativeDirPath: this.getSettablePaths().nonRoot.relativeDirPath,
|
|
8780
|
-
relativeFilePath:
|
|
9075
|
+
relativeFilePath: basename20(relativeFilePath),
|
|
8781
9076
|
frontmatter: result.data,
|
|
8782
9077
|
body: content.trim(),
|
|
8783
9078
|
validate
|
|
@@ -8808,7 +9103,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8808
9103
|
return {
|
|
8809
9104
|
success: false,
|
|
8810
9105
|
error: new Error(
|
|
8811
|
-
`Invalid frontmatter in ${
|
|
9106
|
+
`Invalid frontmatter in ${join75(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
8812
9107
|
)
|
|
8813
9108
|
};
|
|
8814
9109
|
}
|
|
@@ -8828,7 +9123,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8828
9123
|
};
|
|
8829
9124
|
|
|
8830
9125
|
// src/features/rules/geminicli-rule.ts
|
|
8831
|
-
import { join as
|
|
9126
|
+
import { join as join76 } from "path";
|
|
8832
9127
|
var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
8833
9128
|
static getSettablePaths({
|
|
8834
9129
|
global
|
|
@@ -8847,7 +9142,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
8847
9142
|
relativeFilePath: "GEMINI.md"
|
|
8848
9143
|
},
|
|
8849
9144
|
nonRoot: {
|
|
8850
|
-
relativeDirPath:
|
|
9145
|
+
relativeDirPath: join76(".gemini", "memories")
|
|
8851
9146
|
}
|
|
8852
9147
|
};
|
|
8853
9148
|
}
|
|
@@ -8862,7 +9157,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
8862
9157
|
if (isRoot) {
|
|
8863
9158
|
const relativePath2 = paths.root.relativeFilePath;
|
|
8864
9159
|
const fileContent2 = await readFileContent(
|
|
8865
|
-
|
|
9160
|
+
join76(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
8866
9161
|
);
|
|
8867
9162
|
return new _GeminiCliRule({
|
|
8868
9163
|
baseDir,
|
|
@@ -8876,8 +9171,8 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
8876
9171
|
if (!paths.nonRoot) {
|
|
8877
9172
|
throw new Error("nonRoot path is not set");
|
|
8878
9173
|
}
|
|
8879
|
-
const relativePath =
|
|
8880
|
-
const fileContent = await readFileContent(
|
|
9174
|
+
const relativePath = join76(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
9175
|
+
const fileContent = await readFileContent(join76(baseDir, relativePath));
|
|
8881
9176
|
return new _GeminiCliRule({
|
|
8882
9177
|
baseDir,
|
|
8883
9178
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -8936,7 +9231,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
8936
9231
|
};
|
|
8937
9232
|
|
|
8938
9233
|
// src/features/rules/junie-rule.ts
|
|
8939
|
-
import { join as
|
|
9234
|
+
import { join as join77 } from "path";
|
|
8940
9235
|
var JunieRule = class _JunieRule extends ToolRule {
|
|
8941
9236
|
static getSettablePaths() {
|
|
8942
9237
|
return {
|
|
@@ -8945,7 +9240,7 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
8945
9240
|
relativeFilePath: "guidelines.md"
|
|
8946
9241
|
},
|
|
8947
9242
|
nonRoot: {
|
|
8948
|
-
relativeDirPath:
|
|
9243
|
+
relativeDirPath: join77(".junie", "memories")
|
|
8949
9244
|
}
|
|
8950
9245
|
};
|
|
8951
9246
|
}
|
|
@@ -8955,8 +9250,8 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
8955
9250
|
validate = true
|
|
8956
9251
|
}) {
|
|
8957
9252
|
const isRoot = relativeFilePath === "guidelines.md";
|
|
8958
|
-
const relativePath = isRoot ? "guidelines.md" :
|
|
8959
|
-
const fileContent = await readFileContent(
|
|
9253
|
+
const relativePath = isRoot ? "guidelines.md" : join77(".junie", "memories", relativeFilePath);
|
|
9254
|
+
const fileContent = await readFileContent(join77(baseDir, relativePath));
|
|
8960
9255
|
return new _JunieRule({
|
|
8961
9256
|
baseDir,
|
|
8962
9257
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -9011,12 +9306,12 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
9011
9306
|
};
|
|
9012
9307
|
|
|
9013
9308
|
// src/features/rules/kiro-rule.ts
|
|
9014
|
-
import { join as
|
|
9309
|
+
import { join as join78 } from "path";
|
|
9015
9310
|
var KiroRule = class _KiroRule extends ToolRule {
|
|
9016
9311
|
static getSettablePaths() {
|
|
9017
9312
|
return {
|
|
9018
9313
|
nonRoot: {
|
|
9019
|
-
relativeDirPath:
|
|
9314
|
+
relativeDirPath: join78(".kiro", "steering")
|
|
9020
9315
|
}
|
|
9021
9316
|
};
|
|
9022
9317
|
}
|
|
@@ -9026,7 +9321,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
9026
9321
|
validate = true
|
|
9027
9322
|
}) {
|
|
9028
9323
|
const fileContent = await readFileContent(
|
|
9029
|
-
|
|
9324
|
+
join78(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
9030
9325
|
);
|
|
9031
9326
|
return new _KiroRule({
|
|
9032
9327
|
baseDir,
|
|
@@ -9080,7 +9375,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
9080
9375
|
};
|
|
9081
9376
|
|
|
9082
9377
|
// src/features/rules/opencode-rule.ts
|
|
9083
|
-
import { join as
|
|
9378
|
+
import { join as join79 } from "path";
|
|
9084
9379
|
var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
9085
9380
|
static getSettablePaths() {
|
|
9086
9381
|
return {
|
|
@@ -9089,7 +9384,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
9089
9384
|
relativeFilePath: "AGENTS.md"
|
|
9090
9385
|
},
|
|
9091
9386
|
nonRoot: {
|
|
9092
|
-
relativeDirPath:
|
|
9387
|
+
relativeDirPath: join79(".opencode", "memories")
|
|
9093
9388
|
}
|
|
9094
9389
|
};
|
|
9095
9390
|
}
|
|
@@ -9099,8 +9394,8 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
9099
9394
|
validate = true
|
|
9100
9395
|
}) {
|
|
9101
9396
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
9102
|
-
const relativePath = isRoot ? "AGENTS.md" :
|
|
9103
|
-
const fileContent = await readFileContent(
|
|
9397
|
+
const relativePath = isRoot ? "AGENTS.md" : join79(".opencode", "memories", relativeFilePath);
|
|
9398
|
+
const fileContent = await readFileContent(join79(baseDir, relativePath));
|
|
9104
9399
|
return new _OpenCodeRule({
|
|
9105
9400
|
baseDir,
|
|
9106
9401
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -9155,7 +9450,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
9155
9450
|
};
|
|
9156
9451
|
|
|
9157
9452
|
// src/features/rules/qwencode-rule.ts
|
|
9158
|
-
import { join as
|
|
9453
|
+
import { join as join80 } from "path";
|
|
9159
9454
|
var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
9160
9455
|
static getSettablePaths() {
|
|
9161
9456
|
return {
|
|
@@ -9164,7 +9459,7 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
9164
9459
|
relativeFilePath: "QWEN.md"
|
|
9165
9460
|
},
|
|
9166
9461
|
nonRoot: {
|
|
9167
|
-
relativeDirPath:
|
|
9462
|
+
relativeDirPath: join80(".qwen", "memories")
|
|
9168
9463
|
}
|
|
9169
9464
|
};
|
|
9170
9465
|
}
|
|
@@ -9174,8 +9469,8 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
9174
9469
|
validate = true
|
|
9175
9470
|
}) {
|
|
9176
9471
|
const isRoot = relativeFilePath === "QWEN.md";
|
|
9177
|
-
const relativePath = isRoot ? "QWEN.md" :
|
|
9178
|
-
const fileContent = await readFileContent(
|
|
9472
|
+
const relativePath = isRoot ? "QWEN.md" : join80(".qwen", "memories", relativeFilePath);
|
|
9473
|
+
const fileContent = await readFileContent(join80(baseDir, relativePath));
|
|
9179
9474
|
return new _QwencodeRule({
|
|
9180
9475
|
baseDir,
|
|
9181
9476
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -9227,12 +9522,12 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
9227
9522
|
};
|
|
9228
9523
|
|
|
9229
9524
|
// src/features/rules/roo-rule.ts
|
|
9230
|
-
import { join as
|
|
9525
|
+
import { join as join81 } from "path";
|
|
9231
9526
|
var RooRule = class _RooRule extends ToolRule {
|
|
9232
9527
|
static getSettablePaths() {
|
|
9233
9528
|
return {
|
|
9234
9529
|
nonRoot: {
|
|
9235
|
-
relativeDirPath:
|
|
9530
|
+
relativeDirPath: join81(".roo", "rules")
|
|
9236
9531
|
}
|
|
9237
9532
|
};
|
|
9238
9533
|
}
|
|
@@ -9242,7 +9537,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
9242
9537
|
validate = true
|
|
9243
9538
|
}) {
|
|
9244
9539
|
const fileContent = await readFileContent(
|
|
9245
|
-
|
|
9540
|
+
join81(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
9246
9541
|
);
|
|
9247
9542
|
return new _RooRule({
|
|
9248
9543
|
baseDir,
|
|
@@ -9311,7 +9606,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
9311
9606
|
};
|
|
9312
9607
|
|
|
9313
9608
|
// src/features/rules/warp-rule.ts
|
|
9314
|
-
import { join as
|
|
9609
|
+
import { join as join82 } from "path";
|
|
9315
9610
|
var WarpRule = class _WarpRule extends ToolRule {
|
|
9316
9611
|
constructor({ fileContent, root, ...rest }) {
|
|
9317
9612
|
super({
|
|
@@ -9327,7 +9622,7 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
9327
9622
|
relativeFilePath: "WARP.md"
|
|
9328
9623
|
},
|
|
9329
9624
|
nonRoot: {
|
|
9330
|
-
relativeDirPath:
|
|
9625
|
+
relativeDirPath: join82(".warp", "memories")
|
|
9331
9626
|
}
|
|
9332
9627
|
};
|
|
9333
9628
|
}
|
|
@@ -9337,8 +9632,8 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
9337
9632
|
validate = true
|
|
9338
9633
|
}) {
|
|
9339
9634
|
const isRoot = relativeFilePath === this.getSettablePaths().root.relativeFilePath;
|
|
9340
|
-
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath :
|
|
9341
|
-
const fileContent = await readFileContent(
|
|
9635
|
+
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath : join82(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
9636
|
+
const fileContent = await readFileContent(join82(baseDir, relativePath));
|
|
9342
9637
|
return new _WarpRule({
|
|
9343
9638
|
baseDir,
|
|
9344
9639
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : ".warp",
|
|
@@ -9393,12 +9688,12 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
9393
9688
|
};
|
|
9394
9689
|
|
|
9395
9690
|
// src/features/rules/windsurf-rule.ts
|
|
9396
|
-
import { join as
|
|
9691
|
+
import { join as join83 } from "path";
|
|
9397
9692
|
var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
9398
9693
|
static getSettablePaths() {
|
|
9399
9694
|
return {
|
|
9400
9695
|
nonRoot: {
|
|
9401
|
-
relativeDirPath:
|
|
9696
|
+
relativeDirPath: join83(".windsurf", "rules")
|
|
9402
9697
|
}
|
|
9403
9698
|
};
|
|
9404
9699
|
}
|
|
@@ -9408,7 +9703,7 @@ var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
|
9408
9703
|
validate = true
|
|
9409
9704
|
}) {
|
|
9410
9705
|
const fileContent = await readFileContent(
|
|
9411
|
-
|
|
9706
|
+
join83(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
9412
9707
|
);
|
|
9413
9708
|
return new _WindsurfRule({
|
|
9414
9709
|
baseDir,
|
|
@@ -9481,7 +9776,7 @@ var rulesProcessorToolTargets = [
|
|
|
9481
9776
|
"warp",
|
|
9482
9777
|
"windsurf"
|
|
9483
9778
|
];
|
|
9484
|
-
var RulesProcessorToolTargetSchema =
|
|
9779
|
+
var RulesProcessorToolTargetSchema = z38.enum(rulesProcessorToolTargets);
|
|
9485
9780
|
var toolRuleFactories = /* @__PURE__ */ new Map([
|
|
9486
9781
|
[
|
|
9487
9782
|
"agentsmd",
|
|
@@ -9569,10 +9864,7 @@ var toolRuleFactories = /* @__PURE__ */ new Map([
|
|
|
9569
9864
|
meta: {
|
|
9570
9865
|
extension: "md",
|
|
9571
9866
|
supportsGlobal: false,
|
|
9572
|
-
ruleDiscoveryMode: "auto"
|
|
9573
|
-
additionalConventions: {
|
|
9574
|
-
subagents: { subagentClass: CopilotSubagent }
|
|
9575
|
-
}
|
|
9867
|
+
ruleDiscoveryMode: "auto"
|
|
9576
9868
|
}
|
|
9577
9869
|
}
|
|
9578
9870
|
],
|
|
@@ -9769,7 +10061,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9769
10061
|
}).relativeDirPath;
|
|
9770
10062
|
return this.skills.filter((skill) => skillClass.isTargetedByRulesyncSkill(skill)).map((skill) => {
|
|
9771
10063
|
const frontmatter = skill.getFrontmatter();
|
|
9772
|
-
const relativePath =
|
|
10064
|
+
const relativePath = join84(toolRelativeDirPath, skill.getDirName(), SKILL_FILE_NAME);
|
|
9773
10065
|
return {
|
|
9774
10066
|
name: frontmatter.name,
|
|
9775
10067
|
description: frontmatter.description,
|
|
@@ -9836,10 +10128,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9836
10128
|
* Load and parse rulesync rule files from .rulesync/rules/ directory
|
|
9837
10129
|
*/
|
|
9838
10130
|
async loadRulesyncFiles() {
|
|
9839
|
-
const files = await findFilesByGlobs(
|
|
10131
|
+
const files = await findFilesByGlobs(join84(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md"));
|
|
9840
10132
|
logger.debug(`Found ${files.length} rulesync files`);
|
|
9841
10133
|
const rulesyncRules = await Promise.all(
|
|
9842
|
-
files.map((file) => RulesyncRule.fromFile({ relativeFilePath:
|
|
10134
|
+
files.map((file) => RulesyncRule.fromFile({ relativeFilePath: basename21(file) }))
|
|
9843
10135
|
);
|
|
9844
10136
|
const rootRules = rulesyncRules.filter((rule) => rule.getFrontmatter().root);
|
|
9845
10137
|
if (rootRules.length > 1) {
|
|
@@ -9857,10 +10149,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9857
10149
|
return rulesyncRules;
|
|
9858
10150
|
}
|
|
9859
10151
|
async loadRulesyncFilesLegacy() {
|
|
9860
|
-
const legacyFiles = await findFilesByGlobs(
|
|
10152
|
+
const legacyFiles = await findFilesByGlobs(join84(RULESYNC_RELATIVE_DIR_PATH, "*.md"));
|
|
9861
10153
|
logger.debug(`Found ${legacyFiles.length} legacy rulesync files`);
|
|
9862
10154
|
return Promise.all(
|
|
9863
|
-
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath:
|
|
10155
|
+
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath: basename21(file) }))
|
|
9864
10156
|
);
|
|
9865
10157
|
}
|
|
9866
10158
|
/**
|
|
@@ -9878,7 +10170,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9878
10170
|
return [];
|
|
9879
10171
|
}
|
|
9880
10172
|
const rootFilePaths = await findFilesByGlobs(
|
|
9881
|
-
|
|
10173
|
+
join84(
|
|
9882
10174
|
this.baseDir,
|
|
9883
10175
|
settablePaths.root.relativeDirPath ?? ".",
|
|
9884
10176
|
settablePaths.root.relativeFilePath
|
|
@@ -9889,7 +10181,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9889
10181
|
(filePath) => factory.class.forDeletion({
|
|
9890
10182
|
baseDir: this.baseDir,
|
|
9891
10183
|
relativeDirPath: settablePaths.root?.relativeDirPath ?? ".",
|
|
9892
|
-
relativeFilePath:
|
|
10184
|
+
relativeFilePath: basename21(filePath),
|
|
9893
10185
|
global: this.global
|
|
9894
10186
|
})
|
|
9895
10187
|
).filter((rule) => rule.isDeletable());
|
|
@@ -9898,7 +10190,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9898
10190
|
rootFilePaths.map(
|
|
9899
10191
|
(filePath) => factory.class.fromFile({
|
|
9900
10192
|
baseDir: this.baseDir,
|
|
9901
|
-
relativeFilePath:
|
|
10193
|
+
relativeFilePath: basename21(filePath),
|
|
9902
10194
|
global: this.global
|
|
9903
10195
|
})
|
|
9904
10196
|
)
|
|
@@ -9910,14 +10202,14 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9910
10202
|
return [];
|
|
9911
10203
|
}
|
|
9912
10204
|
const nonRootFilePaths = await findFilesByGlobs(
|
|
9913
|
-
|
|
10205
|
+
join84(this.baseDir, settablePaths.nonRoot.relativeDirPath, `*.${factory.meta.extension}`)
|
|
9914
10206
|
);
|
|
9915
10207
|
if (forDeletion) {
|
|
9916
10208
|
return nonRootFilePaths.map(
|
|
9917
10209
|
(filePath) => factory.class.forDeletion({
|
|
9918
10210
|
baseDir: this.baseDir,
|
|
9919
10211
|
relativeDirPath: settablePaths.nonRoot?.relativeDirPath ?? ".",
|
|
9920
|
-
relativeFilePath:
|
|
10212
|
+
relativeFilePath: basename21(filePath),
|
|
9921
10213
|
global: this.global
|
|
9922
10214
|
})
|
|
9923
10215
|
).filter((rule) => rule.isDeletable());
|
|
@@ -9926,7 +10218,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9926
10218
|
nonRootFilePaths.map(
|
|
9927
10219
|
(filePath) => factory.class.fromFile({
|
|
9928
10220
|
baseDir: this.baseDir,
|
|
9929
|
-
relativeFilePath:
|
|
10221
|
+
relativeFilePath: basename21(filePath),
|
|
9930
10222
|
global: this.global
|
|
9931
10223
|
})
|
|
9932
10224
|
)
|
|
@@ -10019,14 +10311,14 @@ s/<command> [arguments]
|
|
|
10019
10311
|
This syntax employs a double slash (\`s/\`) to prevent conflicts with built-in slash commands.
|
|
10020
10312
|
The \`s\` in \`s/\` stands for *simulate*. Because custom slash commands are not built-in, this syntax provides a pseudo way to invoke them.
|
|
10021
10313
|
|
|
10022
|
-
When users call a custom slash command, you have to look for the markdown file, \`${
|
|
10314
|
+
When users call a custom slash command, you have to look for the markdown file, \`${join84(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "{command}.md")}\`, then execute the contents of that file as the block of operations.` : "";
|
|
10023
10315
|
const subagentsSection = subagents ? `## Simulated Subagents
|
|
10024
10316
|
|
|
10025
10317
|
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.
|
|
10026
10318
|
|
|
10027
|
-
When users call a simulated subagent, it will look for the corresponding markdown file, \`${
|
|
10319
|
+
When users call a simulated subagent, it will look for the corresponding markdown file, \`${join84(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "{subagent}.md")}\`, and execute its contents as the block of operations.
|
|
10028
10320
|
|
|
10029
|
-
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${
|
|
10321
|
+
For example, if the user instructs \`Call planner subagent to plan the refactoring\`, you have to look for the markdown file, \`${join84(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "planner.md")}\`, and execute its contents as the block of operations.` : "";
|
|
10030
10322
|
const skillsSection = skills ? this.generateSkillsSection(skills) : "";
|
|
10031
10323
|
const result = [
|
|
10032
10324
|
overview,
|
|
@@ -10308,7 +10600,7 @@ async function generateSkills(config) {
|
|
|
10308
10600
|
}
|
|
10309
10601
|
|
|
10310
10602
|
// src/cli/commands/gitignore.ts
|
|
10311
|
-
import { join as
|
|
10603
|
+
import { join as join85 } from "path";
|
|
10312
10604
|
var RULESYNC_HEADER = "# Generated by Rulesync";
|
|
10313
10605
|
var LEGACY_RULESYNC_HEADER = "# Generated by rulesync - AI tool configuration files";
|
|
10314
10606
|
var RULESYNC_IGNORE_ENTRIES = [
|
|
@@ -10353,7 +10645,7 @@ var RULESYNC_IGNORE_ENTRIES = [
|
|
|
10353
10645
|
"**/.github/copilot-instructions.md",
|
|
10354
10646
|
"**/.github/instructions/",
|
|
10355
10647
|
"**/.github/prompts/",
|
|
10356
|
-
"**/.github/
|
|
10648
|
+
"**/.github/agents/",
|
|
10357
10649
|
"**/.github/skills/",
|
|
10358
10650
|
"**/.vscode/mcp.json",
|
|
10359
10651
|
// Junie
|
|
@@ -10365,6 +10657,7 @@ var RULESYNC_IGNORE_ENTRIES = [
|
|
|
10365
10657
|
// OpenCode
|
|
10366
10658
|
"**/.opencode/memories/",
|
|
10367
10659
|
"**/.opencode/command/",
|
|
10660
|
+
"**/.opencode/agent/",
|
|
10368
10661
|
"**/.opencode/skills/",
|
|
10369
10662
|
"**/opencode.json",
|
|
10370
10663
|
// Qwen
|
|
@@ -10432,7 +10725,7 @@ var removeExistingRulesyncEntries = (content) => {
|
|
|
10432
10725
|
return result;
|
|
10433
10726
|
};
|
|
10434
10727
|
var gitignoreCommand = async () => {
|
|
10435
|
-
const gitignorePath =
|
|
10728
|
+
const gitignorePath = join85(process.cwd(), ".gitignore");
|
|
10436
10729
|
let gitignoreContent = "";
|
|
10437
10730
|
if (await fileExists(gitignorePath)) {
|
|
10438
10731
|
gitignoreContent = await readFileContent(gitignorePath);
|
|
@@ -10631,7 +10924,7 @@ async function importSkills(config, tool) {
|
|
|
10631
10924
|
}
|
|
10632
10925
|
|
|
10633
10926
|
// src/cli/commands/init.ts
|
|
10634
|
-
import { join as
|
|
10927
|
+
import { join as join86 } from "path";
|
|
10635
10928
|
async function initCommand() {
|
|
10636
10929
|
logger.info("Initializing rulesync...");
|
|
10637
10930
|
await ensureDir(RULESYNC_RELATIVE_DIR_PATH);
|
|
@@ -10794,14 +11087,14 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
10794
11087
|
await ensureDir(commandPaths.relativeDirPath);
|
|
10795
11088
|
await ensureDir(subagentPaths.relativeDirPath);
|
|
10796
11089
|
await ensureDir(ignorePaths.recommended.relativeDirPath);
|
|
10797
|
-
const ruleFilepath =
|
|
11090
|
+
const ruleFilepath = join86(rulePaths.recommended.relativeDirPath, sampleRuleFile.filename);
|
|
10798
11091
|
if (!await fileExists(ruleFilepath)) {
|
|
10799
11092
|
await writeFileContent(ruleFilepath, sampleRuleFile.content);
|
|
10800
11093
|
logger.success(`Created ${ruleFilepath}`);
|
|
10801
11094
|
} else {
|
|
10802
11095
|
logger.info(`Skipped ${ruleFilepath} (already exists)`);
|
|
10803
11096
|
}
|
|
10804
|
-
const mcpFilepath =
|
|
11097
|
+
const mcpFilepath = join86(
|
|
10805
11098
|
mcpPaths.recommended.relativeDirPath,
|
|
10806
11099
|
mcpPaths.recommended.relativeFilePath
|
|
10807
11100
|
);
|
|
@@ -10811,21 +11104,21 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
10811
11104
|
} else {
|
|
10812
11105
|
logger.info(`Skipped ${mcpFilepath} (already exists)`);
|
|
10813
11106
|
}
|
|
10814
|
-
const commandFilepath =
|
|
11107
|
+
const commandFilepath = join86(commandPaths.relativeDirPath, sampleCommandFile.filename);
|
|
10815
11108
|
if (!await fileExists(commandFilepath)) {
|
|
10816
11109
|
await writeFileContent(commandFilepath, sampleCommandFile.content);
|
|
10817
11110
|
logger.success(`Created ${commandFilepath}`);
|
|
10818
11111
|
} else {
|
|
10819
11112
|
logger.info(`Skipped ${commandFilepath} (already exists)`);
|
|
10820
11113
|
}
|
|
10821
|
-
const subagentFilepath =
|
|
11114
|
+
const subagentFilepath = join86(subagentPaths.relativeDirPath, sampleSubagentFile.filename);
|
|
10822
11115
|
if (!await fileExists(subagentFilepath)) {
|
|
10823
11116
|
await writeFileContent(subagentFilepath, sampleSubagentFile.content);
|
|
10824
11117
|
logger.success(`Created ${subagentFilepath}`);
|
|
10825
11118
|
} else {
|
|
10826
11119
|
logger.info(`Skipped ${subagentFilepath} (already exists)`);
|
|
10827
11120
|
}
|
|
10828
|
-
const ignoreFilepath =
|
|
11121
|
+
const ignoreFilepath = join86(
|
|
10829
11122
|
ignorePaths.recommended.relativeDirPath,
|
|
10830
11123
|
ignorePaths.recommended.relativeFilePath
|
|
10831
11124
|
);
|
|
@@ -10841,12 +11134,12 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
10841
11134
|
import { FastMCP } from "fastmcp";
|
|
10842
11135
|
|
|
10843
11136
|
// src/mcp/commands.ts
|
|
10844
|
-
import { basename as
|
|
10845
|
-
import { z as
|
|
11137
|
+
import { basename as basename22, join as join87 } from "path";
|
|
11138
|
+
import { z as z39 } from "zod/mini";
|
|
10846
11139
|
var maxCommandSizeBytes = 1024 * 1024;
|
|
10847
11140
|
var maxCommandsCount = 1e3;
|
|
10848
11141
|
async function listCommands() {
|
|
10849
|
-
const commandsDir =
|
|
11142
|
+
const commandsDir = join87(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
10850
11143
|
try {
|
|
10851
11144
|
const files = await listDirectoryFiles(commandsDir);
|
|
10852
11145
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -10858,7 +11151,7 @@ async function listCommands() {
|
|
|
10858
11151
|
});
|
|
10859
11152
|
const frontmatter = command.getFrontmatter();
|
|
10860
11153
|
return {
|
|
10861
|
-
relativePathFromCwd:
|
|
11154
|
+
relativePathFromCwd: join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, file),
|
|
10862
11155
|
frontmatter
|
|
10863
11156
|
};
|
|
10864
11157
|
} catch (error) {
|
|
@@ -10878,13 +11171,13 @@ async function getCommand({ relativePathFromCwd }) {
|
|
|
10878
11171
|
relativePath: relativePathFromCwd,
|
|
10879
11172
|
intendedRootDir: process.cwd()
|
|
10880
11173
|
});
|
|
10881
|
-
const filename =
|
|
11174
|
+
const filename = basename22(relativePathFromCwd);
|
|
10882
11175
|
try {
|
|
10883
11176
|
const command = await RulesyncCommand.fromFile({
|
|
10884
11177
|
relativeFilePath: filename
|
|
10885
11178
|
});
|
|
10886
11179
|
return {
|
|
10887
|
-
relativePathFromCwd:
|
|
11180
|
+
relativePathFromCwd: join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
10888
11181
|
frontmatter: command.getFrontmatter(),
|
|
10889
11182
|
body: command.getBody()
|
|
10890
11183
|
};
|
|
@@ -10903,7 +11196,7 @@ async function putCommand({
|
|
|
10903
11196
|
relativePath: relativePathFromCwd,
|
|
10904
11197
|
intendedRootDir: process.cwd()
|
|
10905
11198
|
});
|
|
10906
|
-
const filename =
|
|
11199
|
+
const filename = basename22(relativePathFromCwd);
|
|
10907
11200
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
10908
11201
|
if (estimatedSize > maxCommandSizeBytes) {
|
|
10909
11202
|
throw new Error(
|
|
@@ -10913,7 +11206,7 @@ async function putCommand({
|
|
|
10913
11206
|
try {
|
|
10914
11207
|
const existingCommands = await listCommands();
|
|
10915
11208
|
const isUpdate = existingCommands.some(
|
|
10916
|
-
(command2) => command2.relativePathFromCwd ===
|
|
11209
|
+
(command2) => command2.relativePathFromCwd === join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
10917
11210
|
);
|
|
10918
11211
|
if (!isUpdate && existingCommands.length >= maxCommandsCount) {
|
|
10919
11212
|
throw new Error(`Maximum number of commands (${maxCommandsCount}) reached`);
|
|
@@ -10928,11 +11221,11 @@ async function putCommand({
|
|
|
10928
11221
|
fileContent,
|
|
10929
11222
|
validate: true
|
|
10930
11223
|
});
|
|
10931
|
-
const commandsDir =
|
|
11224
|
+
const commandsDir = join87(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
10932
11225
|
await ensureDir(commandsDir);
|
|
10933
11226
|
await writeFileContent(command.getFilePath(), command.getFileContent());
|
|
10934
11227
|
return {
|
|
10935
|
-
relativePathFromCwd:
|
|
11228
|
+
relativePathFromCwd: join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
10936
11229
|
frontmatter: command.getFrontmatter(),
|
|
10937
11230
|
body: command.getBody()
|
|
10938
11231
|
};
|
|
@@ -10947,12 +11240,12 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
10947
11240
|
relativePath: relativePathFromCwd,
|
|
10948
11241
|
intendedRootDir: process.cwd()
|
|
10949
11242
|
});
|
|
10950
|
-
const filename =
|
|
10951
|
-
const fullPath =
|
|
11243
|
+
const filename = basename22(relativePathFromCwd);
|
|
11244
|
+
const fullPath = join87(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename);
|
|
10952
11245
|
try {
|
|
10953
11246
|
await removeFile(fullPath);
|
|
10954
11247
|
return {
|
|
10955
|
-
relativePathFromCwd:
|
|
11248
|
+
relativePathFromCwd: join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
10956
11249
|
};
|
|
10957
11250
|
} catch (error) {
|
|
10958
11251
|
throw new Error(`Failed to delete command file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -10961,23 +11254,23 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
10961
11254
|
}
|
|
10962
11255
|
}
|
|
10963
11256
|
var commandToolSchemas = {
|
|
10964
|
-
listCommands:
|
|
10965
|
-
getCommand:
|
|
10966
|
-
relativePathFromCwd:
|
|
11257
|
+
listCommands: z39.object({}),
|
|
11258
|
+
getCommand: z39.object({
|
|
11259
|
+
relativePathFromCwd: z39.string()
|
|
10967
11260
|
}),
|
|
10968
|
-
putCommand:
|
|
10969
|
-
relativePathFromCwd:
|
|
11261
|
+
putCommand: z39.object({
|
|
11262
|
+
relativePathFromCwd: z39.string(),
|
|
10970
11263
|
frontmatter: RulesyncCommandFrontmatterSchema,
|
|
10971
|
-
body:
|
|
11264
|
+
body: z39.string()
|
|
10972
11265
|
}),
|
|
10973
|
-
deleteCommand:
|
|
10974
|
-
relativePathFromCwd:
|
|
11266
|
+
deleteCommand: z39.object({
|
|
11267
|
+
relativePathFromCwd: z39.string()
|
|
10975
11268
|
})
|
|
10976
11269
|
};
|
|
10977
11270
|
var commandTools = {
|
|
10978
11271
|
listCommands: {
|
|
10979
11272
|
name: "listCommands",
|
|
10980
|
-
description: `List all commands from ${
|
|
11273
|
+
description: `List all commands from ${join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
10981
11274
|
parameters: commandToolSchemas.listCommands,
|
|
10982
11275
|
execute: async () => {
|
|
10983
11276
|
const commands = await listCommands();
|
|
@@ -11019,11 +11312,11 @@ var commandTools = {
|
|
|
11019
11312
|
};
|
|
11020
11313
|
|
|
11021
11314
|
// src/mcp/ignore.ts
|
|
11022
|
-
import { join as
|
|
11023
|
-
import { z as
|
|
11315
|
+
import { join as join88 } from "path";
|
|
11316
|
+
import { z as z40 } from "zod/mini";
|
|
11024
11317
|
var maxIgnoreFileSizeBytes = 100 * 1024;
|
|
11025
11318
|
async function getIgnoreFile() {
|
|
11026
|
-
const ignoreFilePath =
|
|
11319
|
+
const ignoreFilePath = join88(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
11027
11320
|
try {
|
|
11028
11321
|
const content = await readFileContent(ignoreFilePath);
|
|
11029
11322
|
return {
|
|
@@ -11037,7 +11330,7 @@ async function getIgnoreFile() {
|
|
|
11037
11330
|
}
|
|
11038
11331
|
}
|
|
11039
11332
|
async function putIgnoreFile({ content }) {
|
|
11040
|
-
const ignoreFilePath =
|
|
11333
|
+
const ignoreFilePath = join88(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
11041
11334
|
const contentSizeBytes = Buffer.byteLength(content, "utf8");
|
|
11042
11335
|
if (contentSizeBytes > maxIgnoreFileSizeBytes) {
|
|
11043
11336
|
throw new Error(
|
|
@@ -11058,8 +11351,8 @@ async function putIgnoreFile({ content }) {
|
|
|
11058
11351
|
}
|
|
11059
11352
|
}
|
|
11060
11353
|
async function deleteIgnoreFile() {
|
|
11061
|
-
const aiignorePath =
|
|
11062
|
-
const legacyIgnorePath =
|
|
11354
|
+
const aiignorePath = join88(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
11355
|
+
const legacyIgnorePath = join88(process.cwd(), RULESYNC_IGNORE_RELATIVE_FILE_PATH);
|
|
11063
11356
|
try {
|
|
11064
11357
|
await Promise.all([removeFile(aiignorePath), removeFile(legacyIgnorePath)]);
|
|
11065
11358
|
return {
|
|
@@ -11077,11 +11370,11 @@ async function deleteIgnoreFile() {
|
|
|
11077
11370
|
}
|
|
11078
11371
|
}
|
|
11079
11372
|
var ignoreToolSchemas = {
|
|
11080
|
-
getIgnoreFile:
|
|
11081
|
-
putIgnoreFile:
|
|
11082
|
-
content:
|
|
11373
|
+
getIgnoreFile: z40.object({}),
|
|
11374
|
+
putIgnoreFile: z40.object({
|
|
11375
|
+
content: z40.string()
|
|
11083
11376
|
}),
|
|
11084
|
-
deleteIgnoreFile:
|
|
11377
|
+
deleteIgnoreFile: z40.object({})
|
|
11085
11378
|
};
|
|
11086
11379
|
var ignoreTools = {
|
|
11087
11380
|
getIgnoreFile: {
|
|
@@ -11114,8 +11407,8 @@ var ignoreTools = {
|
|
|
11114
11407
|
};
|
|
11115
11408
|
|
|
11116
11409
|
// src/mcp/mcp.ts
|
|
11117
|
-
import { join as
|
|
11118
|
-
import { z as
|
|
11410
|
+
import { join as join89 } from "path";
|
|
11411
|
+
import { z as z41 } from "zod/mini";
|
|
11119
11412
|
var maxMcpSizeBytes = 1024 * 1024;
|
|
11120
11413
|
async function getMcpFile() {
|
|
11121
11414
|
const config = await ConfigResolver.resolve({});
|
|
@@ -11124,7 +11417,7 @@ async function getMcpFile() {
|
|
|
11124
11417
|
validate: true,
|
|
11125
11418
|
modularMcp: config.getModularMcp()
|
|
11126
11419
|
});
|
|
11127
|
-
const relativePathFromCwd =
|
|
11420
|
+
const relativePathFromCwd = join89(
|
|
11128
11421
|
rulesyncMcp.getRelativeDirPath(),
|
|
11129
11422
|
rulesyncMcp.getRelativeFilePath()
|
|
11130
11423
|
);
|
|
@@ -11157,7 +11450,7 @@ async function putMcpFile({ content }) {
|
|
|
11157
11450
|
const paths = RulesyncMcp.getSettablePaths();
|
|
11158
11451
|
const relativeDirPath = paths.recommended.relativeDirPath;
|
|
11159
11452
|
const relativeFilePath = paths.recommended.relativeFilePath;
|
|
11160
|
-
const fullPath =
|
|
11453
|
+
const fullPath = join89(baseDir, relativeDirPath, relativeFilePath);
|
|
11161
11454
|
const rulesyncMcp = new RulesyncMcp({
|
|
11162
11455
|
baseDir,
|
|
11163
11456
|
relativeDirPath,
|
|
@@ -11166,9 +11459,9 @@ async function putMcpFile({ content }) {
|
|
|
11166
11459
|
validate: true,
|
|
11167
11460
|
modularMcp: config.getModularMcp()
|
|
11168
11461
|
});
|
|
11169
|
-
await ensureDir(
|
|
11462
|
+
await ensureDir(join89(baseDir, relativeDirPath));
|
|
11170
11463
|
await writeFileContent(fullPath, content);
|
|
11171
|
-
const relativePathFromCwd =
|
|
11464
|
+
const relativePathFromCwd = join89(relativeDirPath, relativeFilePath);
|
|
11172
11465
|
return {
|
|
11173
11466
|
relativePathFromCwd,
|
|
11174
11467
|
content: rulesyncMcp.getFileContent()
|
|
@@ -11183,15 +11476,15 @@ async function deleteMcpFile() {
|
|
|
11183
11476
|
try {
|
|
11184
11477
|
const baseDir = process.cwd();
|
|
11185
11478
|
const paths = RulesyncMcp.getSettablePaths();
|
|
11186
|
-
const recommendedPath =
|
|
11479
|
+
const recommendedPath = join89(
|
|
11187
11480
|
baseDir,
|
|
11188
11481
|
paths.recommended.relativeDirPath,
|
|
11189
11482
|
paths.recommended.relativeFilePath
|
|
11190
11483
|
);
|
|
11191
|
-
const legacyPath =
|
|
11484
|
+
const legacyPath = join89(baseDir, paths.legacy.relativeDirPath, paths.legacy.relativeFilePath);
|
|
11192
11485
|
await removeFile(recommendedPath);
|
|
11193
11486
|
await removeFile(legacyPath);
|
|
11194
|
-
const relativePathFromCwd =
|
|
11487
|
+
const relativePathFromCwd = join89(
|
|
11195
11488
|
paths.recommended.relativeDirPath,
|
|
11196
11489
|
paths.recommended.relativeFilePath
|
|
11197
11490
|
);
|
|
@@ -11205,11 +11498,11 @@ async function deleteMcpFile() {
|
|
|
11205
11498
|
}
|
|
11206
11499
|
}
|
|
11207
11500
|
var mcpToolSchemas = {
|
|
11208
|
-
getMcpFile:
|
|
11209
|
-
putMcpFile:
|
|
11210
|
-
content:
|
|
11501
|
+
getMcpFile: z41.object({}),
|
|
11502
|
+
putMcpFile: z41.object({
|
|
11503
|
+
content: z41.string()
|
|
11211
11504
|
}),
|
|
11212
|
-
deleteMcpFile:
|
|
11505
|
+
deleteMcpFile: z41.object({})
|
|
11213
11506
|
};
|
|
11214
11507
|
var mcpTools = {
|
|
11215
11508
|
getMcpFile: {
|
|
@@ -11242,12 +11535,12 @@ var mcpTools = {
|
|
|
11242
11535
|
};
|
|
11243
11536
|
|
|
11244
11537
|
// src/mcp/rules.ts
|
|
11245
|
-
import { basename as
|
|
11246
|
-
import { z as
|
|
11538
|
+
import { basename as basename23, join as join90 } from "path";
|
|
11539
|
+
import { z as z42 } from "zod/mini";
|
|
11247
11540
|
var maxRuleSizeBytes = 1024 * 1024;
|
|
11248
11541
|
var maxRulesCount = 1e3;
|
|
11249
11542
|
async function listRules() {
|
|
11250
|
-
const rulesDir =
|
|
11543
|
+
const rulesDir = join90(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
11251
11544
|
try {
|
|
11252
11545
|
const files = await listDirectoryFiles(rulesDir);
|
|
11253
11546
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -11260,7 +11553,7 @@ async function listRules() {
|
|
|
11260
11553
|
});
|
|
11261
11554
|
const frontmatter = rule.getFrontmatter();
|
|
11262
11555
|
return {
|
|
11263
|
-
relativePathFromCwd:
|
|
11556
|
+
relativePathFromCwd: join90(RULESYNC_RULES_RELATIVE_DIR_PATH, file),
|
|
11264
11557
|
frontmatter
|
|
11265
11558
|
};
|
|
11266
11559
|
} catch (error) {
|
|
@@ -11280,14 +11573,14 @@ async function getRule({ relativePathFromCwd }) {
|
|
|
11280
11573
|
relativePath: relativePathFromCwd,
|
|
11281
11574
|
intendedRootDir: process.cwd()
|
|
11282
11575
|
});
|
|
11283
|
-
const filename =
|
|
11576
|
+
const filename = basename23(relativePathFromCwd);
|
|
11284
11577
|
try {
|
|
11285
11578
|
const rule = await RulesyncRule.fromFile({
|
|
11286
11579
|
relativeFilePath: filename,
|
|
11287
11580
|
validate: true
|
|
11288
11581
|
});
|
|
11289
11582
|
return {
|
|
11290
|
-
relativePathFromCwd:
|
|
11583
|
+
relativePathFromCwd: join90(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
11291
11584
|
frontmatter: rule.getFrontmatter(),
|
|
11292
11585
|
body: rule.getBody()
|
|
11293
11586
|
};
|
|
@@ -11306,7 +11599,7 @@ async function putRule({
|
|
|
11306
11599
|
relativePath: relativePathFromCwd,
|
|
11307
11600
|
intendedRootDir: process.cwd()
|
|
11308
11601
|
});
|
|
11309
|
-
const filename =
|
|
11602
|
+
const filename = basename23(relativePathFromCwd);
|
|
11310
11603
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
11311
11604
|
if (estimatedSize > maxRuleSizeBytes) {
|
|
11312
11605
|
throw new Error(
|
|
@@ -11316,7 +11609,7 @@ async function putRule({
|
|
|
11316
11609
|
try {
|
|
11317
11610
|
const existingRules = await listRules();
|
|
11318
11611
|
const isUpdate = existingRules.some(
|
|
11319
|
-
(rule2) => rule2.relativePathFromCwd ===
|
|
11612
|
+
(rule2) => rule2.relativePathFromCwd === join90(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
11320
11613
|
);
|
|
11321
11614
|
if (!isUpdate && existingRules.length >= maxRulesCount) {
|
|
11322
11615
|
throw new Error(`Maximum number of rules (${maxRulesCount}) reached`);
|
|
@@ -11329,11 +11622,11 @@ async function putRule({
|
|
|
11329
11622
|
body,
|
|
11330
11623
|
validate: true
|
|
11331
11624
|
});
|
|
11332
|
-
const rulesDir =
|
|
11625
|
+
const rulesDir = join90(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
11333
11626
|
await ensureDir(rulesDir);
|
|
11334
11627
|
await writeFileContent(rule.getFilePath(), rule.getFileContent());
|
|
11335
11628
|
return {
|
|
11336
|
-
relativePathFromCwd:
|
|
11629
|
+
relativePathFromCwd: join90(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
11337
11630
|
frontmatter: rule.getFrontmatter(),
|
|
11338
11631
|
body: rule.getBody()
|
|
11339
11632
|
};
|
|
@@ -11348,12 +11641,12 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
11348
11641
|
relativePath: relativePathFromCwd,
|
|
11349
11642
|
intendedRootDir: process.cwd()
|
|
11350
11643
|
});
|
|
11351
|
-
const filename =
|
|
11352
|
-
const fullPath =
|
|
11644
|
+
const filename = basename23(relativePathFromCwd);
|
|
11645
|
+
const fullPath = join90(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH, filename);
|
|
11353
11646
|
try {
|
|
11354
11647
|
await removeFile(fullPath);
|
|
11355
11648
|
return {
|
|
11356
|
-
relativePathFromCwd:
|
|
11649
|
+
relativePathFromCwd: join90(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
11357
11650
|
};
|
|
11358
11651
|
} catch (error) {
|
|
11359
11652
|
throw new Error(`Failed to delete rule file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -11362,23 +11655,23 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
11362
11655
|
}
|
|
11363
11656
|
}
|
|
11364
11657
|
var ruleToolSchemas = {
|
|
11365
|
-
listRules:
|
|
11366
|
-
getRule:
|
|
11367
|
-
relativePathFromCwd:
|
|
11658
|
+
listRules: z42.object({}),
|
|
11659
|
+
getRule: z42.object({
|
|
11660
|
+
relativePathFromCwd: z42.string()
|
|
11368
11661
|
}),
|
|
11369
|
-
putRule:
|
|
11370
|
-
relativePathFromCwd:
|
|
11662
|
+
putRule: z42.object({
|
|
11663
|
+
relativePathFromCwd: z42.string(),
|
|
11371
11664
|
frontmatter: RulesyncRuleFrontmatterSchema,
|
|
11372
|
-
body:
|
|
11665
|
+
body: z42.string()
|
|
11373
11666
|
}),
|
|
11374
|
-
deleteRule:
|
|
11375
|
-
relativePathFromCwd:
|
|
11667
|
+
deleteRule: z42.object({
|
|
11668
|
+
relativePathFromCwd: z42.string()
|
|
11376
11669
|
})
|
|
11377
11670
|
};
|
|
11378
11671
|
var ruleTools = {
|
|
11379
11672
|
listRules: {
|
|
11380
11673
|
name: "listRules",
|
|
11381
|
-
description: `List all rules from ${
|
|
11674
|
+
description: `List all rules from ${join90(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
11382
11675
|
parameters: ruleToolSchemas.listRules,
|
|
11383
11676
|
execute: async () => {
|
|
11384
11677
|
const rules = await listRules();
|
|
@@ -11420,8 +11713,8 @@ var ruleTools = {
|
|
|
11420
11713
|
};
|
|
11421
11714
|
|
|
11422
11715
|
// src/mcp/skills.ts
|
|
11423
|
-
import { basename as
|
|
11424
|
-
import { z as
|
|
11716
|
+
import { basename as basename24, dirname as dirname2, join as join91 } from "path";
|
|
11717
|
+
import { z as z43 } from "zod/mini";
|
|
11425
11718
|
var maxSkillSizeBytes = 1024 * 1024;
|
|
11426
11719
|
var maxSkillsCount = 1e3;
|
|
11427
11720
|
function aiDirFileToMcpSkillFile(file) {
|
|
@@ -11437,19 +11730,19 @@ function mcpSkillFileToAiDirFile(file) {
|
|
|
11437
11730
|
};
|
|
11438
11731
|
}
|
|
11439
11732
|
function extractDirName(relativeDirPathFromCwd) {
|
|
11440
|
-
const dirName =
|
|
11733
|
+
const dirName = basename24(relativeDirPathFromCwd);
|
|
11441
11734
|
if (!dirName) {
|
|
11442
11735
|
throw new Error(`Invalid path: ${relativeDirPathFromCwd}`);
|
|
11443
11736
|
}
|
|
11444
11737
|
return dirName;
|
|
11445
11738
|
}
|
|
11446
11739
|
async function listSkills() {
|
|
11447
|
-
const skillsDir =
|
|
11740
|
+
const skillsDir = join91(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH);
|
|
11448
11741
|
try {
|
|
11449
|
-
const skillDirPaths = await findFilesByGlobs(
|
|
11742
|
+
const skillDirPaths = await findFilesByGlobs(join91(skillsDir, "*"), { type: "dir" });
|
|
11450
11743
|
const skills = await Promise.all(
|
|
11451
11744
|
skillDirPaths.map(async (dirPath) => {
|
|
11452
|
-
const dirName =
|
|
11745
|
+
const dirName = basename24(dirPath);
|
|
11453
11746
|
if (!dirName) return null;
|
|
11454
11747
|
try {
|
|
11455
11748
|
const skill = await RulesyncSkill.fromDir({
|
|
@@ -11457,7 +11750,7 @@ async function listSkills() {
|
|
|
11457
11750
|
});
|
|
11458
11751
|
const frontmatter = skill.getFrontmatter();
|
|
11459
11752
|
return {
|
|
11460
|
-
relativeDirPathFromCwd:
|
|
11753
|
+
relativeDirPathFromCwd: join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
11461
11754
|
frontmatter
|
|
11462
11755
|
};
|
|
11463
11756
|
} catch (error) {
|
|
@@ -11483,7 +11776,7 @@ async function getSkill({ relativeDirPathFromCwd }) {
|
|
|
11483
11776
|
dirName
|
|
11484
11777
|
});
|
|
11485
11778
|
return {
|
|
11486
|
-
relativeDirPathFromCwd:
|
|
11779
|
+
relativeDirPathFromCwd: join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
11487
11780
|
frontmatter: skill.getFrontmatter(),
|
|
11488
11781
|
body: skill.getBody(),
|
|
11489
11782
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -11517,7 +11810,7 @@ async function putSkill({
|
|
|
11517
11810
|
try {
|
|
11518
11811
|
const existingSkills = await listSkills();
|
|
11519
11812
|
const isUpdate = existingSkills.some(
|
|
11520
|
-
(skill2) => skill2.relativeDirPathFromCwd ===
|
|
11813
|
+
(skill2) => skill2.relativeDirPathFromCwd === join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
11521
11814
|
);
|
|
11522
11815
|
if (!isUpdate && existingSkills.length >= maxSkillsCount) {
|
|
11523
11816
|
throw new Error(`Maximum number of skills (${maxSkillsCount}) reached`);
|
|
@@ -11532,9 +11825,9 @@ async function putSkill({
|
|
|
11532
11825
|
otherFiles: aiDirFiles,
|
|
11533
11826
|
validate: true
|
|
11534
11827
|
});
|
|
11535
|
-
const skillDirPath =
|
|
11828
|
+
const skillDirPath = join91(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
11536
11829
|
await ensureDir(skillDirPath);
|
|
11537
|
-
const skillFilePath =
|
|
11830
|
+
const skillFilePath = join91(skillDirPath, SKILL_FILE_NAME);
|
|
11538
11831
|
const skillFileContent = stringifyFrontmatter(body, frontmatter);
|
|
11539
11832
|
await writeFileContent(skillFilePath, skillFileContent);
|
|
11540
11833
|
for (const file of otherFiles) {
|
|
@@ -11542,15 +11835,15 @@ async function putSkill({
|
|
|
11542
11835
|
relativePath: file.name,
|
|
11543
11836
|
intendedRootDir: skillDirPath
|
|
11544
11837
|
});
|
|
11545
|
-
const filePath =
|
|
11546
|
-
const fileDir =
|
|
11838
|
+
const filePath = join91(skillDirPath, file.name);
|
|
11839
|
+
const fileDir = join91(skillDirPath, dirname2(file.name));
|
|
11547
11840
|
if (fileDir !== skillDirPath) {
|
|
11548
11841
|
await ensureDir(fileDir);
|
|
11549
11842
|
}
|
|
11550
11843
|
await writeFileContent(filePath, file.body);
|
|
11551
11844
|
}
|
|
11552
11845
|
return {
|
|
11553
|
-
relativeDirPathFromCwd:
|
|
11846
|
+
relativeDirPathFromCwd: join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
11554
11847
|
frontmatter: skill.getFrontmatter(),
|
|
11555
11848
|
body: skill.getBody(),
|
|
11556
11849
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -11572,13 +11865,13 @@ async function deleteSkill({
|
|
|
11572
11865
|
intendedRootDir: process.cwd()
|
|
11573
11866
|
});
|
|
11574
11867
|
const dirName = extractDirName(relativeDirPathFromCwd);
|
|
11575
|
-
const skillDirPath =
|
|
11868
|
+
const skillDirPath = join91(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
11576
11869
|
try {
|
|
11577
11870
|
if (await directoryExists(skillDirPath)) {
|
|
11578
11871
|
await removeDirectory(skillDirPath);
|
|
11579
11872
|
}
|
|
11580
11873
|
return {
|
|
11581
|
-
relativeDirPathFromCwd:
|
|
11874
|
+
relativeDirPathFromCwd: join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
11582
11875
|
};
|
|
11583
11876
|
} catch (error) {
|
|
11584
11877
|
throw new Error(
|
|
@@ -11589,29 +11882,29 @@ async function deleteSkill({
|
|
|
11589
11882
|
);
|
|
11590
11883
|
}
|
|
11591
11884
|
}
|
|
11592
|
-
var McpSkillFileSchema =
|
|
11593
|
-
name:
|
|
11594
|
-
body:
|
|
11885
|
+
var McpSkillFileSchema = z43.object({
|
|
11886
|
+
name: z43.string(),
|
|
11887
|
+
body: z43.string()
|
|
11595
11888
|
});
|
|
11596
11889
|
var skillToolSchemas = {
|
|
11597
|
-
listSkills:
|
|
11598
|
-
getSkill:
|
|
11599
|
-
relativeDirPathFromCwd:
|
|
11890
|
+
listSkills: z43.object({}),
|
|
11891
|
+
getSkill: z43.object({
|
|
11892
|
+
relativeDirPathFromCwd: z43.string()
|
|
11600
11893
|
}),
|
|
11601
|
-
putSkill:
|
|
11602
|
-
relativeDirPathFromCwd:
|
|
11894
|
+
putSkill: z43.object({
|
|
11895
|
+
relativeDirPathFromCwd: z43.string(),
|
|
11603
11896
|
frontmatter: RulesyncSkillFrontmatterSchema,
|
|
11604
|
-
body:
|
|
11605
|
-
otherFiles:
|
|
11897
|
+
body: z43.string(),
|
|
11898
|
+
otherFiles: z43.optional(z43.array(McpSkillFileSchema))
|
|
11606
11899
|
}),
|
|
11607
|
-
deleteSkill:
|
|
11608
|
-
relativeDirPathFromCwd:
|
|
11900
|
+
deleteSkill: z43.object({
|
|
11901
|
+
relativeDirPathFromCwd: z43.string()
|
|
11609
11902
|
})
|
|
11610
11903
|
};
|
|
11611
11904
|
var skillTools = {
|
|
11612
11905
|
listSkills: {
|
|
11613
11906
|
name: "listSkills",
|
|
11614
|
-
description: `List all skills from ${
|
|
11907
|
+
description: `List all skills from ${join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "*", SKILL_FILE_NAME)} with their frontmatter.`,
|
|
11615
11908
|
parameters: skillToolSchemas.listSkills,
|
|
11616
11909
|
execute: async () => {
|
|
11617
11910
|
const skills = await listSkills();
|
|
@@ -11654,12 +11947,12 @@ var skillTools = {
|
|
|
11654
11947
|
};
|
|
11655
11948
|
|
|
11656
11949
|
// src/mcp/subagents.ts
|
|
11657
|
-
import { basename as
|
|
11658
|
-
import { z as
|
|
11950
|
+
import { basename as basename25, join as join92 } from "path";
|
|
11951
|
+
import { z as z44 } from "zod/mini";
|
|
11659
11952
|
var maxSubagentSizeBytes = 1024 * 1024;
|
|
11660
11953
|
var maxSubagentsCount = 1e3;
|
|
11661
11954
|
async function listSubagents() {
|
|
11662
|
-
const subagentsDir =
|
|
11955
|
+
const subagentsDir = join92(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
11663
11956
|
try {
|
|
11664
11957
|
const files = await listDirectoryFiles(subagentsDir);
|
|
11665
11958
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -11672,7 +11965,7 @@ async function listSubagents() {
|
|
|
11672
11965
|
});
|
|
11673
11966
|
const frontmatter = subagent.getFrontmatter();
|
|
11674
11967
|
return {
|
|
11675
|
-
relativePathFromCwd:
|
|
11968
|
+
relativePathFromCwd: join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, file),
|
|
11676
11969
|
frontmatter
|
|
11677
11970
|
};
|
|
11678
11971
|
} catch (error) {
|
|
@@ -11694,14 +11987,14 @@ async function getSubagent({ relativePathFromCwd }) {
|
|
|
11694
11987
|
relativePath: relativePathFromCwd,
|
|
11695
11988
|
intendedRootDir: process.cwd()
|
|
11696
11989
|
});
|
|
11697
|
-
const filename =
|
|
11990
|
+
const filename = basename25(relativePathFromCwd);
|
|
11698
11991
|
try {
|
|
11699
11992
|
const subagent = await RulesyncSubagent.fromFile({
|
|
11700
11993
|
relativeFilePath: filename,
|
|
11701
11994
|
validate: true
|
|
11702
11995
|
});
|
|
11703
11996
|
return {
|
|
11704
|
-
relativePathFromCwd:
|
|
11997
|
+
relativePathFromCwd: join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
11705
11998
|
frontmatter: subagent.getFrontmatter(),
|
|
11706
11999
|
body: subagent.getBody()
|
|
11707
12000
|
};
|
|
@@ -11720,7 +12013,7 @@ async function putSubagent({
|
|
|
11720
12013
|
relativePath: relativePathFromCwd,
|
|
11721
12014
|
intendedRootDir: process.cwd()
|
|
11722
12015
|
});
|
|
11723
|
-
const filename =
|
|
12016
|
+
const filename = basename25(relativePathFromCwd);
|
|
11724
12017
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
11725
12018
|
if (estimatedSize > maxSubagentSizeBytes) {
|
|
11726
12019
|
throw new Error(
|
|
@@ -11730,7 +12023,7 @@ async function putSubagent({
|
|
|
11730
12023
|
try {
|
|
11731
12024
|
const existingSubagents = await listSubagents();
|
|
11732
12025
|
const isUpdate = existingSubagents.some(
|
|
11733
|
-
(subagent2) => subagent2.relativePathFromCwd ===
|
|
12026
|
+
(subagent2) => subagent2.relativePathFromCwd === join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
11734
12027
|
);
|
|
11735
12028
|
if (!isUpdate && existingSubagents.length >= maxSubagentsCount) {
|
|
11736
12029
|
throw new Error(`Maximum number of subagents (${maxSubagentsCount}) reached`);
|
|
@@ -11743,11 +12036,11 @@ async function putSubagent({
|
|
|
11743
12036
|
body,
|
|
11744
12037
|
validate: true
|
|
11745
12038
|
});
|
|
11746
|
-
const subagentsDir =
|
|
12039
|
+
const subagentsDir = join92(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
11747
12040
|
await ensureDir(subagentsDir);
|
|
11748
12041
|
await writeFileContent(subagent.getFilePath(), subagent.getFileContent());
|
|
11749
12042
|
return {
|
|
11750
|
-
relativePathFromCwd:
|
|
12043
|
+
relativePathFromCwd: join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
11751
12044
|
frontmatter: subagent.getFrontmatter(),
|
|
11752
12045
|
body: subagent.getBody()
|
|
11753
12046
|
};
|
|
@@ -11762,12 +12055,12 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
11762
12055
|
relativePath: relativePathFromCwd,
|
|
11763
12056
|
intendedRootDir: process.cwd()
|
|
11764
12057
|
});
|
|
11765
|
-
const filename =
|
|
11766
|
-
const fullPath =
|
|
12058
|
+
const filename = basename25(relativePathFromCwd);
|
|
12059
|
+
const fullPath = join92(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename);
|
|
11767
12060
|
try {
|
|
11768
12061
|
await removeFile(fullPath);
|
|
11769
12062
|
return {
|
|
11770
|
-
relativePathFromCwd:
|
|
12063
|
+
relativePathFromCwd: join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
11771
12064
|
};
|
|
11772
12065
|
} catch (error) {
|
|
11773
12066
|
throw new Error(
|
|
@@ -11779,23 +12072,23 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
11779
12072
|
}
|
|
11780
12073
|
}
|
|
11781
12074
|
var subagentToolSchemas = {
|
|
11782
|
-
listSubagents:
|
|
11783
|
-
getSubagent:
|
|
11784
|
-
relativePathFromCwd:
|
|
12075
|
+
listSubagents: z44.object({}),
|
|
12076
|
+
getSubagent: z44.object({
|
|
12077
|
+
relativePathFromCwd: z44.string()
|
|
11785
12078
|
}),
|
|
11786
|
-
putSubagent:
|
|
11787
|
-
relativePathFromCwd:
|
|
12079
|
+
putSubagent: z44.object({
|
|
12080
|
+
relativePathFromCwd: z44.string(),
|
|
11788
12081
|
frontmatter: RulesyncSubagentFrontmatterSchema,
|
|
11789
|
-
body:
|
|
12082
|
+
body: z44.string()
|
|
11790
12083
|
}),
|
|
11791
|
-
deleteSubagent:
|
|
11792
|
-
relativePathFromCwd:
|
|
12084
|
+
deleteSubagent: z44.object({
|
|
12085
|
+
relativePathFromCwd: z44.string()
|
|
11793
12086
|
})
|
|
11794
12087
|
};
|
|
11795
12088
|
var subagentTools = {
|
|
11796
12089
|
listSubagents: {
|
|
11797
12090
|
name: "listSubagents",
|
|
11798
|
-
description: `List all subagents from ${
|
|
12091
|
+
description: `List all subagents from ${join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
11799
12092
|
parameters: subagentToolSchemas.listSubagents,
|
|
11800
12093
|
execute: async () => {
|
|
11801
12094
|
const subagents = await listSubagents();
|
|
@@ -11873,7 +12166,7 @@ async function mcpCommand({ version }) {
|
|
|
11873
12166
|
}
|
|
11874
12167
|
|
|
11875
12168
|
// src/cli/index.ts
|
|
11876
|
-
var getVersion = () => "4.
|
|
12169
|
+
var getVersion = () => "4.2.0";
|
|
11877
12170
|
var main = async () => {
|
|
11878
12171
|
const program = new Command();
|
|
11879
12172
|
const version = getVersion();
|