rulesync 4.1.1 → 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 +12 -1
- package/dist/index.cjs +451 -297
- package/dist/index.js +451 -297
- 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";
|
|
@@ -6537,8 +6537,8 @@ var RooSubagent = class _RooSubagent extends SimulatedSubagent {
|
|
|
6537
6537
|
};
|
|
6538
6538
|
|
|
6539
6539
|
// src/features/subagents/subagents-processor.ts
|
|
6540
|
-
import { basename as
|
|
6541
|
-
import { z as
|
|
6540
|
+
import { basename as basename18, join as join62 } from "path";
|
|
6541
|
+
import { z as z31 } from "zod/mini";
|
|
6542
6542
|
|
|
6543
6543
|
// src/features/subagents/claudecode-subagent.ts
|
|
6544
6544
|
import { join as join59 } from "path";
|
|
@@ -6941,6 +6941,154 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
6941
6941
|
}
|
|
6942
6942
|
};
|
|
6943
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
|
+
|
|
6944
7092
|
// src/features/subagents/subagents-processor.ts
|
|
6945
7093
|
var subagentsProcessorToolTargetTuple = [
|
|
6946
7094
|
"agentsmd",
|
|
@@ -6949,9 +7097,10 @@ var subagentsProcessorToolTargetTuple = [
|
|
|
6949
7097
|
"copilot",
|
|
6950
7098
|
"cursor",
|
|
6951
7099
|
"geminicli",
|
|
7100
|
+
"opencode",
|
|
6952
7101
|
"roo"
|
|
6953
7102
|
];
|
|
6954
|
-
var SubagentsProcessorToolTargetSchema =
|
|
7103
|
+
var SubagentsProcessorToolTargetSchema = z31.enum(subagentsProcessorToolTargetTuple);
|
|
6955
7104
|
var toolSubagentFactories = /* @__PURE__ */ new Map([
|
|
6956
7105
|
[
|
|
6957
7106
|
"agentsmd",
|
|
@@ -6974,6 +7123,10 @@ var toolSubagentFactories = /* @__PURE__ */ new Map([
|
|
|
6974
7123
|
"geminicli",
|
|
6975
7124
|
{ class: GeminiCliSubagent, meta: { supportsSimulated: true, supportsGlobal: false } }
|
|
6976
7125
|
],
|
|
7126
|
+
[
|
|
7127
|
+
"opencode",
|
|
7128
|
+
{ class: OpenCodeSubagent, meta: { supportsSimulated: false, supportsGlobal: true } }
|
|
7129
|
+
],
|
|
6977
7130
|
["roo", { class: RooSubagent, meta: { supportsSimulated: true, supportsGlobal: false } }]
|
|
6978
7131
|
]);
|
|
6979
7132
|
var defaultGetFactory5 = (target) => {
|
|
@@ -7057,7 +7210,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7057
7210
|
* Load and parse rulesync subagent files from .rulesync/subagents/ directory
|
|
7058
7211
|
*/
|
|
7059
7212
|
async loadRulesyncFiles() {
|
|
7060
|
-
const subagentsDir =
|
|
7213
|
+
const subagentsDir = join62(this.baseDir, RulesyncSubagent.getSettablePaths().relativeDirPath);
|
|
7061
7214
|
const dirExists = await directoryExists(subagentsDir);
|
|
7062
7215
|
if (!dirExists) {
|
|
7063
7216
|
logger.debug(`Rulesync subagents directory not found: ${subagentsDir}`);
|
|
@@ -7072,7 +7225,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7072
7225
|
logger.info(`Found ${mdFiles.length} subagent files in ${subagentsDir}`);
|
|
7073
7226
|
const rulesyncSubagents = [];
|
|
7074
7227
|
for (const mdFile of mdFiles) {
|
|
7075
|
-
const filepath =
|
|
7228
|
+
const filepath = join62(subagentsDir, mdFile);
|
|
7076
7229
|
try {
|
|
7077
7230
|
const rulesyncSubagent = await RulesyncSubagent.fromFile({
|
|
7078
7231
|
relativeFilePath: mdFile,
|
|
@@ -7102,14 +7255,14 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7102
7255
|
const factory = this.getFactory(this.toolTarget);
|
|
7103
7256
|
const paths = factory.class.getSettablePaths({ global: this.global });
|
|
7104
7257
|
const subagentFilePaths = await findFilesByGlobs(
|
|
7105
|
-
|
|
7258
|
+
join62(this.baseDir, paths.relativeDirPath, "*.md")
|
|
7106
7259
|
);
|
|
7107
7260
|
if (forDeletion) {
|
|
7108
7261
|
const toolSubagents2 = subagentFilePaths.map(
|
|
7109
7262
|
(path3) => factory.class.forDeletion({
|
|
7110
7263
|
baseDir: this.baseDir,
|
|
7111
7264
|
relativeDirPath: paths.relativeDirPath,
|
|
7112
|
-
relativeFilePath:
|
|
7265
|
+
relativeFilePath: basename18(path3),
|
|
7113
7266
|
global: this.global
|
|
7114
7267
|
})
|
|
7115
7268
|
).filter((subagent) => subagent.isDeletable());
|
|
@@ -7120,7 +7273,7 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7120
7273
|
subagentFilePaths.map(
|
|
7121
7274
|
(path3) => factory.class.fromFile({
|
|
7122
7275
|
baseDir: this.baseDir,
|
|
7123
|
-
relativeFilePath:
|
|
7276
|
+
relativeFilePath: basename18(path3),
|
|
7124
7277
|
global: this.global
|
|
7125
7278
|
})
|
|
7126
7279
|
)
|
|
@@ -7152,48 +7305,48 @@ var SubagentsProcessor = class extends FeatureProcessor {
|
|
|
7152
7305
|
};
|
|
7153
7306
|
|
|
7154
7307
|
// src/features/rules/agentsmd-rule.ts
|
|
7155
|
-
import { join as
|
|
7308
|
+
import { join as join65 } from "path";
|
|
7156
7309
|
|
|
7157
7310
|
// src/features/rules/tool-rule.ts
|
|
7158
|
-
import { join as
|
|
7311
|
+
import { join as join64 } from "path";
|
|
7159
7312
|
|
|
7160
7313
|
// src/features/rules/rulesync-rule.ts
|
|
7161
|
-
import { basename as
|
|
7162
|
-
import { z as
|
|
7163
|
-
var RulesyncRuleFrontmatterSchema =
|
|
7164
|
-
root:
|
|
7165
|
-
targets:
|
|
7166
|
-
description:
|
|
7167
|
-
globs:
|
|
7168
|
-
agentsmd:
|
|
7169
|
-
|
|
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({
|
|
7170
7323
|
// @example "path/to/subproject"
|
|
7171
|
-
subprojectPath:
|
|
7324
|
+
subprojectPath: z32.optional(z32.string())
|
|
7172
7325
|
})
|
|
7173
7326
|
),
|
|
7174
|
-
claudecode:
|
|
7175
|
-
|
|
7327
|
+
claudecode: z32.optional(
|
|
7328
|
+
z32.object({
|
|
7176
7329
|
// Glob patterns for conditional rules (takes precedence over globs)
|
|
7177
7330
|
// @example "src/**/*.ts, tests/**/*.test.ts"
|
|
7178
|
-
paths:
|
|
7331
|
+
paths: z32.optional(z32.string())
|
|
7179
7332
|
})
|
|
7180
7333
|
),
|
|
7181
|
-
cursor:
|
|
7182
|
-
|
|
7183
|
-
alwaysApply:
|
|
7184
|
-
description:
|
|
7185
|
-
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()))
|
|
7186
7339
|
})
|
|
7187
7340
|
),
|
|
7188
|
-
copilot:
|
|
7189
|
-
|
|
7190
|
-
excludeAgent:
|
|
7341
|
+
copilot: z32.optional(
|
|
7342
|
+
z32.object({
|
|
7343
|
+
excludeAgent: z32.optional(z32.union([z32.literal("code-review"), z32.literal("coding-agent")]))
|
|
7191
7344
|
})
|
|
7192
7345
|
),
|
|
7193
|
-
antigravity:
|
|
7194
|
-
|
|
7195
|
-
trigger:
|
|
7196
|
-
globs:
|
|
7346
|
+
antigravity: z32.optional(
|
|
7347
|
+
z32.looseObject({
|
|
7348
|
+
trigger: z32.optional(z32.string()),
|
|
7349
|
+
globs: z32.optional(z32.array(z32.string()))
|
|
7197
7350
|
})
|
|
7198
7351
|
)
|
|
7199
7352
|
});
|
|
@@ -7205,7 +7358,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7205
7358
|
const result = RulesyncRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7206
7359
|
if (!result.success) {
|
|
7207
7360
|
throw new Error(
|
|
7208
|
-
`Invalid frontmatter in ${
|
|
7361
|
+
`Invalid frontmatter in ${join63(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
7209
7362
|
);
|
|
7210
7363
|
}
|
|
7211
7364
|
}
|
|
@@ -7240,7 +7393,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7240
7393
|
return {
|
|
7241
7394
|
success: false,
|
|
7242
7395
|
error: new Error(
|
|
7243
|
-
`Invalid frontmatter in ${
|
|
7396
|
+
`Invalid frontmatter in ${join63(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
7244
7397
|
)
|
|
7245
7398
|
};
|
|
7246
7399
|
}
|
|
@@ -7249,12 +7402,12 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7249
7402
|
relativeFilePath,
|
|
7250
7403
|
validate = true
|
|
7251
7404
|
}) {
|
|
7252
|
-
const legacyPath =
|
|
7405
|
+
const legacyPath = join63(
|
|
7253
7406
|
process.cwd(),
|
|
7254
7407
|
this.getSettablePaths().legacy.relativeDirPath,
|
|
7255
7408
|
relativeFilePath
|
|
7256
7409
|
);
|
|
7257
|
-
const recommendedPath =
|
|
7410
|
+
const recommendedPath = join63(
|
|
7258
7411
|
this.getSettablePaths().recommended.relativeDirPath,
|
|
7259
7412
|
relativeFilePath
|
|
7260
7413
|
);
|
|
@@ -7273,7 +7426,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7273
7426
|
agentsmd: result.data.agentsmd,
|
|
7274
7427
|
cursor: result.data.cursor
|
|
7275
7428
|
};
|
|
7276
|
-
const filename =
|
|
7429
|
+
const filename = basename19(legacyPath);
|
|
7277
7430
|
return new _RulesyncRule({
|
|
7278
7431
|
baseDir: process.cwd(),
|
|
7279
7432
|
relativeDirPath: this.getSettablePaths().recommended.relativeDirPath,
|
|
@@ -7287,7 +7440,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7287
7440
|
relativeFilePath,
|
|
7288
7441
|
validate = true
|
|
7289
7442
|
}) {
|
|
7290
|
-
const filePath =
|
|
7443
|
+
const filePath = join63(
|
|
7291
7444
|
process.cwd(),
|
|
7292
7445
|
this.getSettablePaths().recommended.relativeDirPath,
|
|
7293
7446
|
relativeFilePath
|
|
@@ -7306,7 +7459,7 @@ var RulesyncRule = class _RulesyncRule extends RulesyncFile {
|
|
|
7306
7459
|
agentsmd: result.data.agentsmd,
|
|
7307
7460
|
cursor: result.data.cursor
|
|
7308
7461
|
};
|
|
7309
|
-
const filename =
|
|
7462
|
+
const filename = basename19(filePath);
|
|
7310
7463
|
return new _RulesyncRule({
|
|
7311
7464
|
baseDir: process.cwd(),
|
|
7312
7465
|
relativeDirPath: this.getSettablePaths().recommended.relativeDirPath,
|
|
@@ -7389,7 +7542,7 @@ var ToolRule = class extends ToolFile {
|
|
|
7389
7542
|
rulesyncRule,
|
|
7390
7543
|
validate = true,
|
|
7391
7544
|
rootPath = { relativeDirPath: ".", relativeFilePath: "AGENTS.md" },
|
|
7392
|
-
nonRootPath = { relativeDirPath:
|
|
7545
|
+
nonRootPath = { relativeDirPath: join64(".agents", "memories") }
|
|
7393
7546
|
}) {
|
|
7394
7547
|
const params = this.buildToolRuleParamsDefault({
|
|
7395
7548
|
baseDir,
|
|
@@ -7400,7 +7553,7 @@ var ToolRule = class extends ToolFile {
|
|
|
7400
7553
|
});
|
|
7401
7554
|
const rulesyncFrontmatter = rulesyncRule.getFrontmatter();
|
|
7402
7555
|
if (!rulesyncFrontmatter.root && rulesyncFrontmatter.agentsmd?.subprojectPath) {
|
|
7403
|
-
params.relativeDirPath =
|
|
7556
|
+
params.relativeDirPath = join64(rulesyncFrontmatter.agentsmd.subprojectPath);
|
|
7404
7557
|
params.relativeFilePath = "AGENTS.md";
|
|
7405
7558
|
}
|
|
7406
7559
|
return params;
|
|
@@ -7465,7 +7618,7 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
7465
7618
|
relativeFilePath: "AGENTS.md"
|
|
7466
7619
|
},
|
|
7467
7620
|
nonRoot: {
|
|
7468
|
-
relativeDirPath:
|
|
7621
|
+
relativeDirPath: join65(".agents", "memories")
|
|
7469
7622
|
}
|
|
7470
7623
|
};
|
|
7471
7624
|
}
|
|
@@ -7475,8 +7628,8 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
7475
7628
|
validate = true
|
|
7476
7629
|
}) {
|
|
7477
7630
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
7478
|
-
const relativePath = isRoot ? "AGENTS.md" :
|
|
7479
|
-
const fileContent = await readFileContent(
|
|
7631
|
+
const relativePath = isRoot ? "AGENTS.md" : join65(".agents", "memories", relativeFilePath);
|
|
7632
|
+
const fileContent = await readFileContent(join65(baseDir, relativePath));
|
|
7480
7633
|
return new _AgentsMdRule({
|
|
7481
7634
|
baseDir,
|
|
7482
7635
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -7531,12 +7684,12 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
7531
7684
|
};
|
|
7532
7685
|
|
|
7533
7686
|
// src/features/rules/amazonqcli-rule.ts
|
|
7534
|
-
import { join as
|
|
7687
|
+
import { join as join66 } from "path";
|
|
7535
7688
|
var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
7536
7689
|
static getSettablePaths() {
|
|
7537
7690
|
return {
|
|
7538
7691
|
nonRoot: {
|
|
7539
|
-
relativeDirPath:
|
|
7692
|
+
relativeDirPath: join66(".amazonq", "rules")
|
|
7540
7693
|
}
|
|
7541
7694
|
};
|
|
7542
7695
|
}
|
|
@@ -7546,7 +7699,7 @@ var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
|
7546
7699
|
validate = true
|
|
7547
7700
|
}) {
|
|
7548
7701
|
const fileContent = await readFileContent(
|
|
7549
|
-
|
|
7702
|
+
join66(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
7550
7703
|
);
|
|
7551
7704
|
return new _AmazonQCliRule({
|
|
7552
7705
|
baseDir,
|
|
@@ -7600,21 +7753,21 @@ var AmazonQCliRule = class _AmazonQCliRule extends ToolRule {
|
|
|
7600
7753
|
};
|
|
7601
7754
|
|
|
7602
7755
|
// src/features/rules/antigravity-rule.ts
|
|
7603
|
-
import { join as
|
|
7604
|
-
import { z as
|
|
7605
|
-
var AntigravityRuleFrontmatterSchema =
|
|
7606
|
-
trigger:
|
|
7607
|
-
|
|
7608
|
-
|
|
7609
|
-
|
|
7610
|
-
|
|
7611
|
-
|
|
7612
|
-
|
|
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()
|
|
7613
7766
|
// accepts any string for forward compatibility
|
|
7614
7767
|
])
|
|
7615
7768
|
),
|
|
7616
|
-
globs:
|
|
7617
|
-
description:
|
|
7769
|
+
globs: z33.optional(z33.string()),
|
|
7770
|
+
description: z33.optional(z33.string())
|
|
7618
7771
|
});
|
|
7619
7772
|
function parseGlobsString(globs) {
|
|
7620
7773
|
if (!globs) {
|
|
@@ -7759,7 +7912,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7759
7912
|
const result = AntigravityRuleFrontmatterSchema.safeParse(frontmatter);
|
|
7760
7913
|
if (!result.success) {
|
|
7761
7914
|
throw new Error(
|
|
7762
|
-
`Invalid frontmatter in ${
|
|
7915
|
+
`Invalid frontmatter in ${join67(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
7763
7916
|
);
|
|
7764
7917
|
}
|
|
7765
7918
|
}
|
|
@@ -7774,7 +7927,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7774
7927
|
static getSettablePaths() {
|
|
7775
7928
|
return {
|
|
7776
7929
|
nonRoot: {
|
|
7777
|
-
relativeDirPath:
|
|
7930
|
+
relativeDirPath: join67(".agent", "rules")
|
|
7778
7931
|
}
|
|
7779
7932
|
};
|
|
7780
7933
|
}
|
|
@@ -7783,7 +7936,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7783
7936
|
relativeFilePath,
|
|
7784
7937
|
validate = true
|
|
7785
7938
|
}) {
|
|
7786
|
-
const filePath =
|
|
7939
|
+
const filePath = join67(
|
|
7787
7940
|
baseDir,
|
|
7788
7941
|
this.getSettablePaths().nonRoot.relativeDirPath,
|
|
7789
7942
|
relativeFilePath
|
|
@@ -7924,7 +8077,7 @@ var AntigravityRule = class _AntigravityRule extends ToolRule {
|
|
|
7924
8077
|
};
|
|
7925
8078
|
|
|
7926
8079
|
// src/features/rules/augmentcode-legacy-rule.ts
|
|
7927
|
-
import { join as
|
|
8080
|
+
import { join as join68 } from "path";
|
|
7928
8081
|
var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
7929
8082
|
toRulesyncRule() {
|
|
7930
8083
|
const rulesyncFrontmatter = {
|
|
@@ -7950,7 +8103,7 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
7950
8103
|
relativeFilePath: ".augment-guidelines"
|
|
7951
8104
|
},
|
|
7952
8105
|
nonRoot: {
|
|
7953
|
-
relativeDirPath:
|
|
8106
|
+
relativeDirPath: join68(".augment", "rules")
|
|
7954
8107
|
}
|
|
7955
8108
|
};
|
|
7956
8109
|
}
|
|
@@ -7985,8 +8138,8 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
7985
8138
|
}) {
|
|
7986
8139
|
const settablePaths = this.getSettablePaths();
|
|
7987
8140
|
const isRoot = relativeFilePath === settablePaths.root.relativeFilePath;
|
|
7988
|
-
const relativePath = isRoot ? settablePaths.root.relativeFilePath :
|
|
7989
|
-
const fileContent = await readFileContent(
|
|
8141
|
+
const relativePath = isRoot ? settablePaths.root.relativeFilePath : join68(settablePaths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8142
|
+
const fileContent = await readFileContent(join68(baseDir, relativePath));
|
|
7990
8143
|
return new _AugmentcodeLegacyRule({
|
|
7991
8144
|
baseDir,
|
|
7992
8145
|
relativeDirPath: isRoot ? settablePaths.root.relativeDirPath : settablePaths.nonRoot.relativeDirPath,
|
|
@@ -8015,7 +8168,7 @@ var AugmentcodeLegacyRule = class _AugmentcodeLegacyRule extends ToolRule {
|
|
|
8015
8168
|
};
|
|
8016
8169
|
|
|
8017
8170
|
// src/features/rules/augmentcode-rule.ts
|
|
8018
|
-
import { join as
|
|
8171
|
+
import { join as join69 } from "path";
|
|
8019
8172
|
var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
8020
8173
|
toRulesyncRule() {
|
|
8021
8174
|
return this.toRulesyncRuleDefault();
|
|
@@ -8023,7 +8176,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
8023
8176
|
static getSettablePaths() {
|
|
8024
8177
|
return {
|
|
8025
8178
|
nonRoot: {
|
|
8026
|
-
relativeDirPath:
|
|
8179
|
+
relativeDirPath: join69(".augment", "rules")
|
|
8027
8180
|
}
|
|
8028
8181
|
};
|
|
8029
8182
|
}
|
|
@@ -8047,7 +8200,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
8047
8200
|
validate = true
|
|
8048
8201
|
}) {
|
|
8049
8202
|
const fileContent = await readFileContent(
|
|
8050
|
-
|
|
8203
|
+
join69(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
8051
8204
|
);
|
|
8052
8205
|
const { body: content } = parseFrontmatter(fileContent);
|
|
8053
8206
|
return new _AugmentcodeRule({
|
|
@@ -8083,7 +8236,7 @@ var AugmentcodeRule = class _AugmentcodeRule extends ToolRule {
|
|
|
8083
8236
|
};
|
|
8084
8237
|
|
|
8085
8238
|
// src/features/rules/claudecode-legacy-rule.ts
|
|
8086
|
-
import { join as
|
|
8239
|
+
import { join as join70 } from "path";
|
|
8087
8240
|
var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
8088
8241
|
static getSettablePaths({
|
|
8089
8242
|
global
|
|
@@ -8102,7 +8255,7 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
8102
8255
|
relativeFilePath: "CLAUDE.md"
|
|
8103
8256
|
},
|
|
8104
8257
|
nonRoot: {
|
|
8105
|
-
relativeDirPath:
|
|
8258
|
+
relativeDirPath: join70(".claude", "memories")
|
|
8106
8259
|
}
|
|
8107
8260
|
};
|
|
8108
8261
|
}
|
|
@@ -8117,7 +8270,7 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
8117
8270
|
if (isRoot) {
|
|
8118
8271
|
const relativePath2 = paths.root.relativeFilePath;
|
|
8119
8272
|
const fileContent2 = await readFileContent(
|
|
8120
|
-
|
|
8273
|
+
join70(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
8121
8274
|
);
|
|
8122
8275
|
return new _ClaudecodeLegacyRule({
|
|
8123
8276
|
baseDir,
|
|
@@ -8131,8 +8284,8 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
8131
8284
|
if (!paths.nonRoot) {
|
|
8132
8285
|
throw new Error("nonRoot path is not set");
|
|
8133
8286
|
}
|
|
8134
|
-
const relativePath =
|
|
8135
|
-
const fileContent = await readFileContent(
|
|
8287
|
+
const relativePath = join70(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8288
|
+
const fileContent = await readFileContent(join70(baseDir, relativePath));
|
|
8136
8289
|
return new _ClaudecodeLegacyRule({
|
|
8137
8290
|
baseDir,
|
|
8138
8291
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -8191,10 +8344,10 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
8191
8344
|
};
|
|
8192
8345
|
|
|
8193
8346
|
// src/features/rules/claudecode-rule.ts
|
|
8194
|
-
import { join as
|
|
8195
|
-
import { z as
|
|
8196
|
-
var ClaudecodeRuleFrontmatterSchema =
|
|
8197
|
-
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())
|
|
8198
8351
|
});
|
|
8199
8352
|
var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
8200
8353
|
frontmatter;
|
|
@@ -8216,7 +8369,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8216
8369
|
relativeFilePath: "CLAUDE.md"
|
|
8217
8370
|
},
|
|
8218
8371
|
nonRoot: {
|
|
8219
|
-
relativeDirPath:
|
|
8372
|
+
relativeDirPath: join71(".claude", "rules")
|
|
8220
8373
|
}
|
|
8221
8374
|
};
|
|
8222
8375
|
}
|
|
@@ -8225,7 +8378,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8225
8378
|
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8226
8379
|
if (!result.success) {
|
|
8227
8380
|
throw new Error(
|
|
8228
|
-
`Invalid frontmatter in ${
|
|
8381
|
+
`Invalid frontmatter in ${join71(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
8229
8382
|
);
|
|
8230
8383
|
}
|
|
8231
8384
|
}
|
|
@@ -8253,7 +8406,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8253
8406
|
const isRoot = relativeFilePath === paths.root.relativeFilePath;
|
|
8254
8407
|
if (isRoot) {
|
|
8255
8408
|
const fileContent2 = await readFileContent(
|
|
8256
|
-
|
|
8409
|
+
join71(baseDir, paths.root.relativeDirPath, paths.root.relativeFilePath)
|
|
8257
8410
|
);
|
|
8258
8411
|
return new _ClaudecodeRule({
|
|
8259
8412
|
baseDir,
|
|
@@ -8268,13 +8421,13 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8268
8421
|
if (!paths.nonRoot) {
|
|
8269
8422
|
throw new Error("nonRoot path is not set");
|
|
8270
8423
|
}
|
|
8271
|
-
const relativePath =
|
|
8272
|
-
const fileContent = await readFileContent(
|
|
8424
|
+
const relativePath = join71(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8425
|
+
const fileContent = await readFileContent(join71(baseDir, relativePath));
|
|
8273
8426
|
const { frontmatter, body: content } = parseFrontmatter(fileContent);
|
|
8274
8427
|
const result = ClaudecodeRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8275
8428
|
if (!result.success) {
|
|
8276
8429
|
throw new Error(
|
|
8277
|
-
`Invalid frontmatter in ${
|
|
8430
|
+
`Invalid frontmatter in ${join71(baseDir, relativePath)}: ${formatError(result.error)}`
|
|
8278
8431
|
);
|
|
8279
8432
|
}
|
|
8280
8433
|
return new _ClaudecodeRule({
|
|
@@ -8381,7 +8534,7 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8381
8534
|
return {
|
|
8382
8535
|
success: false,
|
|
8383
8536
|
error: new Error(
|
|
8384
|
-
`Invalid frontmatter in ${
|
|
8537
|
+
`Invalid frontmatter in ${join71(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
8385
8538
|
)
|
|
8386
8539
|
};
|
|
8387
8540
|
}
|
|
@@ -8401,10 +8554,10 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
8401
8554
|
};
|
|
8402
8555
|
|
|
8403
8556
|
// src/features/rules/cline-rule.ts
|
|
8404
|
-
import { join as
|
|
8405
|
-
import { z as
|
|
8406
|
-
var ClineRuleFrontmatterSchema =
|
|
8407
|
-
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()
|
|
8408
8561
|
});
|
|
8409
8562
|
var ClineRule = class _ClineRule extends ToolRule {
|
|
8410
8563
|
static getSettablePaths() {
|
|
@@ -8446,7 +8599,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
8446
8599
|
validate = true
|
|
8447
8600
|
}) {
|
|
8448
8601
|
const fileContent = await readFileContent(
|
|
8449
|
-
|
|
8602
|
+
join72(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
8450
8603
|
);
|
|
8451
8604
|
return new _ClineRule({
|
|
8452
8605
|
baseDir,
|
|
@@ -8472,7 +8625,7 @@ var ClineRule = class _ClineRule extends ToolRule {
|
|
|
8472
8625
|
};
|
|
8473
8626
|
|
|
8474
8627
|
// src/features/rules/codexcli-rule.ts
|
|
8475
|
-
import { join as
|
|
8628
|
+
import { join as join73 } from "path";
|
|
8476
8629
|
var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
8477
8630
|
static getSettablePaths({
|
|
8478
8631
|
global
|
|
@@ -8491,7 +8644,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8491
8644
|
relativeFilePath: "AGENTS.md"
|
|
8492
8645
|
},
|
|
8493
8646
|
nonRoot: {
|
|
8494
|
-
relativeDirPath:
|
|
8647
|
+
relativeDirPath: join73(".codex", "memories")
|
|
8495
8648
|
}
|
|
8496
8649
|
};
|
|
8497
8650
|
}
|
|
@@ -8506,7 +8659,7 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8506
8659
|
if (isRoot) {
|
|
8507
8660
|
const relativePath2 = paths.root.relativeFilePath;
|
|
8508
8661
|
const fileContent2 = await readFileContent(
|
|
8509
|
-
|
|
8662
|
+
join73(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
8510
8663
|
);
|
|
8511
8664
|
return new _CodexcliRule({
|
|
8512
8665
|
baseDir,
|
|
@@ -8520,8 +8673,8 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8520
8673
|
if (!paths.nonRoot) {
|
|
8521
8674
|
throw new Error("nonRoot path is not set");
|
|
8522
8675
|
}
|
|
8523
|
-
const relativePath =
|
|
8524
|
-
const fileContent = await readFileContent(
|
|
8676
|
+
const relativePath = join73(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
8677
|
+
const fileContent = await readFileContent(join73(baseDir, relativePath));
|
|
8525
8678
|
return new _CodexcliRule({
|
|
8526
8679
|
baseDir,
|
|
8527
8680
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -8580,12 +8733,12 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
8580
8733
|
};
|
|
8581
8734
|
|
|
8582
8735
|
// src/features/rules/copilot-rule.ts
|
|
8583
|
-
import { join as
|
|
8584
|
-
import { z as
|
|
8585
|
-
var CopilotRuleFrontmatterSchema =
|
|
8586
|
-
description:
|
|
8587
|
-
applyTo:
|
|
8588
|
-
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")]))
|
|
8589
8742
|
});
|
|
8590
8743
|
var CopilotRule = class _CopilotRule extends ToolRule {
|
|
8591
8744
|
frontmatter;
|
|
@@ -8597,7 +8750,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8597
8750
|
relativeFilePath: "copilot-instructions.md"
|
|
8598
8751
|
},
|
|
8599
8752
|
nonRoot: {
|
|
8600
|
-
relativeDirPath:
|
|
8753
|
+
relativeDirPath: join74(".github", "instructions")
|
|
8601
8754
|
}
|
|
8602
8755
|
};
|
|
8603
8756
|
}
|
|
@@ -8606,7 +8759,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8606
8759
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8607
8760
|
if (!result.success) {
|
|
8608
8761
|
throw new Error(
|
|
8609
|
-
`Invalid frontmatter in ${
|
|
8762
|
+
`Invalid frontmatter in ${join74(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
8610
8763
|
);
|
|
8611
8764
|
}
|
|
8612
8765
|
}
|
|
@@ -8688,11 +8841,11 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8688
8841
|
validate = true
|
|
8689
8842
|
}) {
|
|
8690
8843
|
const isRoot = relativeFilePath === "copilot-instructions.md";
|
|
8691
|
-
const relativePath = isRoot ?
|
|
8844
|
+
const relativePath = isRoot ? join74(
|
|
8692
8845
|
this.getSettablePaths().root.relativeDirPath,
|
|
8693
8846
|
this.getSettablePaths().root.relativeFilePath
|
|
8694
|
-
) :
|
|
8695
|
-
const fileContent = await readFileContent(
|
|
8847
|
+
) : join74(this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath);
|
|
8848
|
+
const fileContent = await readFileContent(join74(baseDir, relativePath));
|
|
8696
8849
|
if (isRoot) {
|
|
8697
8850
|
return new _CopilotRule({
|
|
8698
8851
|
baseDir,
|
|
@@ -8708,7 +8861,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8708
8861
|
const result = CopilotRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8709
8862
|
if (!result.success) {
|
|
8710
8863
|
throw new Error(
|
|
8711
|
-
`Invalid frontmatter in ${
|
|
8864
|
+
`Invalid frontmatter in ${join74(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
8712
8865
|
);
|
|
8713
8866
|
}
|
|
8714
8867
|
return new _CopilotRule({
|
|
@@ -8748,7 +8901,7 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8748
8901
|
return {
|
|
8749
8902
|
success: false,
|
|
8750
8903
|
error: new Error(
|
|
8751
|
-
`Invalid frontmatter in ${
|
|
8904
|
+
`Invalid frontmatter in ${join74(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
8752
8905
|
)
|
|
8753
8906
|
};
|
|
8754
8907
|
}
|
|
@@ -8768,12 +8921,12 @@ var CopilotRule = class _CopilotRule extends ToolRule {
|
|
|
8768
8921
|
};
|
|
8769
8922
|
|
|
8770
8923
|
// src/features/rules/cursor-rule.ts
|
|
8771
|
-
import { basename as
|
|
8772
|
-
import { z as
|
|
8773
|
-
var CursorRuleFrontmatterSchema =
|
|
8774
|
-
description:
|
|
8775
|
-
globs:
|
|
8776
|
-
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())
|
|
8777
8930
|
});
|
|
8778
8931
|
var CursorRule = class _CursorRule extends ToolRule {
|
|
8779
8932
|
frontmatter;
|
|
@@ -8781,7 +8934,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8781
8934
|
static getSettablePaths() {
|
|
8782
8935
|
return {
|
|
8783
8936
|
nonRoot: {
|
|
8784
|
-
relativeDirPath:
|
|
8937
|
+
relativeDirPath: join75(".cursor", "rules")
|
|
8785
8938
|
}
|
|
8786
8939
|
};
|
|
8787
8940
|
}
|
|
@@ -8790,7 +8943,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8790
8943
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8791
8944
|
if (!result.success) {
|
|
8792
8945
|
throw new Error(
|
|
8793
|
-
`Invalid frontmatter in ${
|
|
8946
|
+
`Invalid frontmatter in ${join75(rest.relativeDirPath, rest.relativeFilePath)}: ${formatError(result.error)}`
|
|
8794
8947
|
);
|
|
8795
8948
|
}
|
|
8796
8949
|
}
|
|
@@ -8907,19 +9060,19 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8907
9060
|
validate = true
|
|
8908
9061
|
}) {
|
|
8909
9062
|
const fileContent = await readFileContent(
|
|
8910
|
-
|
|
9063
|
+
join75(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
8911
9064
|
);
|
|
8912
9065
|
const { frontmatter, body: content } = _CursorRule.parseCursorFrontmatter(fileContent);
|
|
8913
9066
|
const result = CursorRuleFrontmatterSchema.safeParse(frontmatter);
|
|
8914
9067
|
if (!result.success) {
|
|
8915
9068
|
throw new Error(
|
|
8916
|
-
`Invalid frontmatter in ${
|
|
9069
|
+
`Invalid frontmatter in ${join75(baseDir, relativeFilePath)}: ${formatError(result.error)}`
|
|
8917
9070
|
);
|
|
8918
9071
|
}
|
|
8919
9072
|
return new _CursorRule({
|
|
8920
9073
|
baseDir,
|
|
8921
9074
|
relativeDirPath: this.getSettablePaths().nonRoot.relativeDirPath,
|
|
8922
|
-
relativeFilePath:
|
|
9075
|
+
relativeFilePath: basename20(relativeFilePath),
|
|
8923
9076
|
frontmatter: result.data,
|
|
8924
9077
|
body: content.trim(),
|
|
8925
9078
|
validate
|
|
@@ -8950,7 +9103,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8950
9103
|
return {
|
|
8951
9104
|
success: false,
|
|
8952
9105
|
error: new Error(
|
|
8953
|
-
`Invalid frontmatter in ${
|
|
9106
|
+
`Invalid frontmatter in ${join75(this.relativeDirPath, this.relativeFilePath)}: ${formatError(result.error)}`
|
|
8954
9107
|
)
|
|
8955
9108
|
};
|
|
8956
9109
|
}
|
|
@@ -8970,7 +9123,7 @@ var CursorRule = class _CursorRule extends ToolRule {
|
|
|
8970
9123
|
};
|
|
8971
9124
|
|
|
8972
9125
|
// src/features/rules/geminicli-rule.ts
|
|
8973
|
-
import { join as
|
|
9126
|
+
import { join as join76 } from "path";
|
|
8974
9127
|
var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
8975
9128
|
static getSettablePaths({
|
|
8976
9129
|
global
|
|
@@ -8989,7 +9142,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
8989
9142
|
relativeFilePath: "GEMINI.md"
|
|
8990
9143
|
},
|
|
8991
9144
|
nonRoot: {
|
|
8992
|
-
relativeDirPath:
|
|
9145
|
+
relativeDirPath: join76(".gemini", "memories")
|
|
8993
9146
|
}
|
|
8994
9147
|
};
|
|
8995
9148
|
}
|
|
@@ -9004,7 +9157,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
9004
9157
|
if (isRoot) {
|
|
9005
9158
|
const relativePath2 = paths.root.relativeFilePath;
|
|
9006
9159
|
const fileContent2 = await readFileContent(
|
|
9007
|
-
|
|
9160
|
+
join76(baseDir, paths.root.relativeDirPath, relativePath2)
|
|
9008
9161
|
);
|
|
9009
9162
|
return new _GeminiCliRule({
|
|
9010
9163
|
baseDir,
|
|
@@ -9018,8 +9171,8 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
9018
9171
|
if (!paths.nonRoot) {
|
|
9019
9172
|
throw new Error("nonRoot path is not set");
|
|
9020
9173
|
}
|
|
9021
|
-
const relativePath =
|
|
9022
|
-
const fileContent = await readFileContent(
|
|
9174
|
+
const relativePath = join76(paths.nonRoot.relativeDirPath, relativeFilePath);
|
|
9175
|
+
const fileContent = await readFileContent(join76(baseDir, relativePath));
|
|
9023
9176
|
return new _GeminiCliRule({
|
|
9024
9177
|
baseDir,
|
|
9025
9178
|
relativeDirPath: paths.nonRoot.relativeDirPath,
|
|
@@ -9078,7 +9231,7 @@ var GeminiCliRule = class _GeminiCliRule extends ToolRule {
|
|
|
9078
9231
|
};
|
|
9079
9232
|
|
|
9080
9233
|
// src/features/rules/junie-rule.ts
|
|
9081
|
-
import { join as
|
|
9234
|
+
import { join as join77 } from "path";
|
|
9082
9235
|
var JunieRule = class _JunieRule extends ToolRule {
|
|
9083
9236
|
static getSettablePaths() {
|
|
9084
9237
|
return {
|
|
@@ -9087,7 +9240,7 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
9087
9240
|
relativeFilePath: "guidelines.md"
|
|
9088
9241
|
},
|
|
9089
9242
|
nonRoot: {
|
|
9090
|
-
relativeDirPath:
|
|
9243
|
+
relativeDirPath: join77(".junie", "memories")
|
|
9091
9244
|
}
|
|
9092
9245
|
};
|
|
9093
9246
|
}
|
|
@@ -9097,8 +9250,8 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
9097
9250
|
validate = true
|
|
9098
9251
|
}) {
|
|
9099
9252
|
const isRoot = relativeFilePath === "guidelines.md";
|
|
9100
|
-
const relativePath = isRoot ? "guidelines.md" :
|
|
9101
|
-
const fileContent = await readFileContent(
|
|
9253
|
+
const relativePath = isRoot ? "guidelines.md" : join77(".junie", "memories", relativeFilePath);
|
|
9254
|
+
const fileContent = await readFileContent(join77(baseDir, relativePath));
|
|
9102
9255
|
return new _JunieRule({
|
|
9103
9256
|
baseDir,
|
|
9104
9257
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -9153,12 +9306,12 @@ var JunieRule = class _JunieRule extends ToolRule {
|
|
|
9153
9306
|
};
|
|
9154
9307
|
|
|
9155
9308
|
// src/features/rules/kiro-rule.ts
|
|
9156
|
-
import { join as
|
|
9309
|
+
import { join as join78 } from "path";
|
|
9157
9310
|
var KiroRule = class _KiroRule extends ToolRule {
|
|
9158
9311
|
static getSettablePaths() {
|
|
9159
9312
|
return {
|
|
9160
9313
|
nonRoot: {
|
|
9161
|
-
relativeDirPath:
|
|
9314
|
+
relativeDirPath: join78(".kiro", "steering")
|
|
9162
9315
|
}
|
|
9163
9316
|
};
|
|
9164
9317
|
}
|
|
@@ -9168,7 +9321,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
9168
9321
|
validate = true
|
|
9169
9322
|
}) {
|
|
9170
9323
|
const fileContent = await readFileContent(
|
|
9171
|
-
|
|
9324
|
+
join78(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
9172
9325
|
);
|
|
9173
9326
|
return new _KiroRule({
|
|
9174
9327
|
baseDir,
|
|
@@ -9222,7 +9375,7 @@ var KiroRule = class _KiroRule extends ToolRule {
|
|
|
9222
9375
|
};
|
|
9223
9376
|
|
|
9224
9377
|
// src/features/rules/opencode-rule.ts
|
|
9225
|
-
import { join as
|
|
9378
|
+
import { join as join79 } from "path";
|
|
9226
9379
|
var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
9227
9380
|
static getSettablePaths() {
|
|
9228
9381
|
return {
|
|
@@ -9231,7 +9384,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
9231
9384
|
relativeFilePath: "AGENTS.md"
|
|
9232
9385
|
},
|
|
9233
9386
|
nonRoot: {
|
|
9234
|
-
relativeDirPath:
|
|
9387
|
+
relativeDirPath: join79(".opencode", "memories")
|
|
9235
9388
|
}
|
|
9236
9389
|
};
|
|
9237
9390
|
}
|
|
@@ -9241,8 +9394,8 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
9241
9394
|
validate = true
|
|
9242
9395
|
}) {
|
|
9243
9396
|
const isRoot = relativeFilePath === "AGENTS.md";
|
|
9244
|
-
const relativePath = isRoot ? "AGENTS.md" :
|
|
9245
|
-
const fileContent = await readFileContent(
|
|
9397
|
+
const relativePath = isRoot ? "AGENTS.md" : join79(".opencode", "memories", relativeFilePath);
|
|
9398
|
+
const fileContent = await readFileContent(join79(baseDir, relativePath));
|
|
9246
9399
|
return new _OpenCodeRule({
|
|
9247
9400
|
baseDir,
|
|
9248
9401
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -9297,7 +9450,7 @@ var OpenCodeRule = class _OpenCodeRule extends ToolRule {
|
|
|
9297
9450
|
};
|
|
9298
9451
|
|
|
9299
9452
|
// src/features/rules/qwencode-rule.ts
|
|
9300
|
-
import { join as
|
|
9453
|
+
import { join as join80 } from "path";
|
|
9301
9454
|
var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
9302
9455
|
static getSettablePaths() {
|
|
9303
9456
|
return {
|
|
@@ -9306,7 +9459,7 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
9306
9459
|
relativeFilePath: "QWEN.md"
|
|
9307
9460
|
},
|
|
9308
9461
|
nonRoot: {
|
|
9309
|
-
relativeDirPath:
|
|
9462
|
+
relativeDirPath: join80(".qwen", "memories")
|
|
9310
9463
|
}
|
|
9311
9464
|
};
|
|
9312
9465
|
}
|
|
@@ -9316,8 +9469,8 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
9316
9469
|
validate = true
|
|
9317
9470
|
}) {
|
|
9318
9471
|
const isRoot = relativeFilePath === "QWEN.md";
|
|
9319
|
-
const relativePath = isRoot ? "QWEN.md" :
|
|
9320
|
-
const fileContent = await readFileContent(
|
|
9472
|
+
const relativePath = isRoot ? "QWEN.md" : join80(".qwen", "memories", relativeFilePath);
|
|
9473
|
+
const fileContent = await readFileContent(join80(baseDir, relativePath));
|
|
9321
9474
|
return new _QwencodeRule({
|
|
9322
9475
|
baseDir,
|
|
9323
9476
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : this.getSettablePaths().nonRoot.relativeDirPath,
|
|
@@ -9369,12 +9522,12 @@ var QwencodeRule = class _QwencodeRule extends ToolRule {
|
|
|
9369
9522
|
};
|
|
9370
9523
|
|
|
9371
9524
|
// src/features/rules/roo-rule.ts
|
|
9372
|
-
import { join as
|
|
9525
|
+
import { join as join81 } from "path";
|
|
9373
9526
|
var RooRule = class _RooRule extends ToolRule {
|
|
9374
9527
|
static getSettablePaths() {
|
|
9375
9528
|
return {
|
|
9376
9529
|
nonRoot: {
|
|
9377
|
-
relativeDirPath:
|
|
9530
|
+
relativeDirPath: join81(".roo", "rules")
|
|
9378
9531
|
}
|
|
9379
9532
|
};
|
|
9380
9533
|
}
|
|
@@ -9384,7 +9537,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
9384
9537
|
validate = true
|
|
9385
9538
|
}) {
|
|
9386
9539
|
const fileContent = await readFileContent(
|
|
9387
|
-
|
|
9540
|
+
join81(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
9388
9541
|
);
|
|
9389
9542
|
return new _RooRule({
|
|
9390
9543
|
baseDir,
|
|
@@ -9453,7 +9606,7 @@ var RooRule = class _RooRule extends ToolRule {
|
|
|
9453
9606
|
};
|
|
9454
9607
|
|
|
9455
9608
|
// src/features/rules/warp-rule.ts
|
|
9456
|
-
import { join as
|
|
9609
|
+
import { join as join82 } from "path";
|
|
9457
9610
|
var WarpRule = class _WarpRule extends ToolRule {
|
|
9458
9611
|
constructor({ fileContent, root, ...rest }) {
|
|
9459
9612
|
super({
|
|
@@ -9469,7 +9622,7 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
9469
9622
|
relativeFilePath: "WARP.md"
|
|
9470
9623
|
},
|
|
9471
9624
|
nonRoot: {
|
|
9472
|
-
relativeDirPath:
|
|
9625
|
+
relativeDirPath: join82(".warp", "memories")
|
|
9473
9626
|
}
|
|
9474
9627
|
};
|
|
9475
9628
|
}
|
|
@@ -9479,8 +9632,8 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
9479
9632
|
validate = true
|
|
9480
9633
|
}) {
|
|
9481
9634
|
const isRoot = relativeFilePath === this.getSettablePaths().root.relativeFilePath;
|
|
9482
|
-
const relativePath = isRoot ? this.getSettablePaths().root.relativeFilePath :
|
|
9483
|
-
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));
|
|
9484
9637
|
return new _WarpRule({
|
|
9485
9638
|
baseDir,
|
|
9486
9639
|
relativeDirPath: isRoot ? this.getSettablePaths().root.relativeDirPath : ".warp",
|
|
@@ -9535,12 +9688,12 @@ var WarpRule = class _WarpRule extends ToolRule {
|
|
|
9535
9688
|
};
|
|
9536
9689
|
|
|
9537
9690
|
// src/features/rules/windsurf-rule.ts
|
|
9538
|
-
import { join as
|
|
9691
|
+
import { join as join83 } from "path";
|
|
9539
9692
|
var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
9540
9693
|
static getSettablePaths() {
|
|
9541
9694
|
return {
|
|
9542
9695
|
nonRoot: {
|
|
9543
|
-
relativeDirPath:
|
|
9696
|
+
relativeDirPath: join83(".windsurf", "rules")
|
|
9544
9697
|
}
|
|
9545
9698
|
};
|
|
9546
9699
|
}
|
|
@@ -9550,7 +9703,7 @@ var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
|
9550
9703
|
validate = true
|
|
9551
9704
|
}) {
|
|
9552
9705
|
const fileContent = await readFileContent(
|
|
9553
|
-
|
|
9706
|
+
join83(baseDir, this.getSettablePaths().nonRoot.relativeDirPath, relativeFilePath)
|
|
9554
9707
|
);
|
|
9555
9708
|
return new _WindsurfRule({
|
|
9556
9709
|
baseDir,
|
|
@@ -9623,7 +9776,7 @@ var rulesProcessorToolTargets = [
|
|
|
9623
9776
|
"warp",
|
|
9624
9777
|
"windsurf"
|
|
9625
9778
|
];
|
|
9626
|
-
var RulesProcessorToolTargetSchema =
|
|
9779
|
+
var RulesProcessorToolTargetSchema = z38.enum(rulesProcessorToolTargets);
|
|
9627
9780
|
var toolRuleFactories = /* @__PURE__ */ new Map([
|
|
9628
9781
|
[
|
|
9629
9782
|
"agentsmd",
|
|
@@ -9908,7 +10061,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9908
10061
|
}).relativeDirPath;
|
|
9909
10062
|
return this.skills.filter((skill) => skillClass.isTargetedByRulesyncSkill(skill)).map((skill) => {
|
|
9910
10063
|
const frontmatter = skill.getFrontmatter();
|
|
9911
|
-
const relativePath =
|
|
10064
|
+
const relativePath = join84(toolRelativeDirPath, skill.getDirName(), SKILL_FILE_NAME);
|
|
9912
10065
|
return {
|
|
9913
10066
|
name: frontmatter.name,
|
|
9914
10067
|
description: frontmatter.description,
|
|
@@ -9975,10 +10128,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9975
10128
|
* Load and parse rulesync rule files from .rulesync/rules/ directory
|
|
9976
10129
|
*/
|
|
9977
10130
|
async loadRulesyncFiles() {
|
|
9978
|
-
const files = await findFilesByGlobs(
|
|
10131
|
+
const files = await findFilesByGlobs(join84(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md"));
|
|
9979
10132
|
logger.debug(`Found ${files.length} rulesync files`);
|
|
9980
10133
|
const rulesyncRules = await Promise.all(
|
|
9981
|
-
files.map((file) => RulesyncRule.fromFile({ relativeFilePath:
|
|
10134
|
+
files.map((file) => RulesyncRule.fromFile({ relativeFilePath: basename21(file) }))
|
|
9982
10135
|
);
|
|
9983
10136
|
const rootRules = rulesyncRules.filter((rule) => rule.getFrontmatter().root);
|
|
9984
10137
|
if (rootRules.length > 1) {
|
|
@@ -9996,10 +10149,10 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
9996
10149
|
return rulesyncRules;
|
|
9997
10150
|
}
|
|
9998
10151
|
async loadRulesyncFilesLegacy() {
|
|
9999
|
-
const legacyFiles = await findFilesByGlobs(
|
|
10152
|
+
const legacyFiles = await findFilesByGlobs(join84(RULESYNC_RELATIVE_DIR_PATH, "*.md"));
|
|
10000
10153
|
logger.debug(`Found ${legacyFiles.length} legacy rulesync files`);
|
|
10001
10154
|
return Promise.all(
|
|
10002
|
-
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath:
|
|
10155
|
+
legacyFiles.map((file) => RulesyncRule.fromFileLegacy({ relativeFilePath: basename21(file) }))
|
|
10003
10156
|
);
|
|
10004
10157
|
}
|
|
10005
10158
|
/**
|
|
@@ -10017,7 +10170,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10017
10170
|
return [];
|
|
10018
10171
|
}
|
|
10019
10172
|
const rootFilePaths = await findFilesByGlobs(
|
|
10020
|
-
|
|
10173
|
+
join84(
|
|
10021
10174
|
this.baseDir,
|
|
10022
10175
|
settablePaths.root.relativeDirPath ?? ".",
|
|
10023
10176
|
settablePaths.root.relativeFilePath
|
|
@@ -10028,7 +10181,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10028
10181
|
(filePath) => factory.class.forDeletion({
|
|
10029
10182
|
baseDir: this.baseDir,
|
|
10030
10183
|
relativeDirPath: settablePaths.root?.relativeDirPath ?? ".",
|
|
10031
|
-
relativeFilePath:
|
|
10184
|
+
relativeFilePath: basename21(filePath),
|
|
10032
10185
|
global: this.global
|
|
10033
10186
|
})
|
|
10034
10187
|
).filter((rule) => rule.isDeletable());
|
|
@@ -10037,7 +10190,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10037
10190
|
rootFilePaths.map(
|
|
10038
10191
|
(filePath) => factory.class.fromFile({
|
|
10039
10192
|
baseDir: this.baseDir,
|
|
10040
|
-
relativeFilePath:
|
|
10193
|
+
relativeFilePath: basename21(filePath),
|
|
10041
10194
|
global: this.global
|
|
10042
10195
|
})
|
|
10043
10196
|
)
|
|
@@ -10049,14 +10202,14 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10049
10202
|
return [];
|
|
10050
10203
|
}
|
|
10051
10204
|
const nonRootFilePaths = await findFilesByGlobs(
|
|
10052
|
-
|
|
10205
|
+
join84(this.baseDir, settablePaths.nonRoot.relativeDirPath, `*.${factory.meta.extension}`)
|
|
10053
10206
|
);
|
|
10054
10207
|
if (forDeletion) {
|
|
10055
10208
|
return nonRootFilePaths.map(
|
|
10056
10209
|
(filePath) => factory.class.forDeletion({
|
|
10057
10210
|
baseDir: this.baseDir,
|
|
10058
10211
|
relativeDirPath: settablePaths.nonRoot?.relativeDirPath ?? ".",
|
|
10059
|
-
relativeFilePath:
|
|
10212
|
+
relativeFilePath: basename21(filePath),
|
|
10060
10213
|
global: this.global
|
|
10061
10214
|
})
|
|
10062
10215
|
).filter((rule) => rule.isDeletable());
|
|
@@ -10065,7 +10218,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
10065
10218
|
nonRootFilePaths.map(
|
|
10066
10219
|
(filePath) => factory.class.fromFile({
|
|
10067
10220
|
baseDir: this.baseDir,
|
|
10068
|
-
relativeFilePath:
|
|
10221
|
+
relativeFilePath: basename21(filePath),
|
|
10069
10222
|
global: this.global
|
|
10070
10223
|
})
|
|
10071
10224
|
)
|
|
@@ -10158,14 +10311,14 @@ s/<command> [arguments]
|
|
|
10158
10311
|
This syntax employs a double slash (\`s/\`) to prevent conflicts with built-in slash commands.
|
|
10159
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.
|
|
10160
10313
|
|
|
10161
|
-
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.` : "";
|
|
10162
10315
|
const subagentsSection = subagents ? `## Simulated Subagents
|
|
10163
10316
|
|
|
10164
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.
|
|
10165
10318
|
|
|
10166
|
-
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.
|
|
10167
10320
|
|
|
10168
|
-
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.` : "";
|
|
10169
10322
|
const skillsSection = skills ? this.generateSkillsSection(skills) : "";
|
|
10170
10323
|
const result = [
|
|
10171
10324
|
overview,
|
|
@@ -10447,7 +10600,7 @@ async function generateSkills(config) {
|
|
|
10447
10600
|
}
|
|
10448
10601
|
|
|
10449
10602
|
// src/cli/commands/gitignore.ts
|
|
10450
|
-
import { join as
|
|
10603
|
+
import { join as join85 } from "path";
|
|
10451
10604
|
var RULESYNC_HEADER = "# Generated by Rulesync";
|
|
10452
10605
|
var LEGACY_RULESYNC_HEADER = "# Generated by rulesync - AI tool configuration files";
|
|
10453
10606
|
var RULESYNC_IGNORE_ENTRIES = [
|
|
@@ -10504,6 +10657,7 @@ var RULESYNC_IGNORE_ENTRIES = [
|
|
|
10504
10657
|
// OpenCode
|
|
10505
10658
|
"**/.opencode/memories/",
|
|
10506
10659
|
"**/.opencode/command/",
|
|
10660
|
+
"**/.opencode/agent/",
|
|
10507
10661
|
"**/.opencode/skills/",
|
|
10508
10662
|
"**/opencode.json",
|
|
10509
10663
|
// Qwen
|
|
@@ -10571,7 +10725,7 @@ var removeExistingRulesyncEntries = (content) => {
|
|
|
10571
10725
|
return result;
|
|
10572
10726
|
};
|
|
10573
10727
|
var gitignoreCommand = async () => {
|
|
10574
|
-
const gitignorePath =
|
|
10728
|
+
const gitignorePath = join85(process.cwd(), ".gitignore");
|
|
10575
10729
|
let gitignoreContent = "";
|
|
10576
10730
|
if (await fileExists(gitignorePath)) {
|
|
10577
10731
|
gitignoreContent = await readFileContent(gitignorePath);
|
|
@@ -10770,7 +10924,7 @@ async function importSkills(config, tool) {
|
|
|
10770
10924
|
}
|
|
10771
10925
|
|
|
10772
10926
|
// src/cli/commands/init.ts
|
|
10773
|
-
import { join as
|
|
10927
|
+
import { join as join86 } from "path";
|
|
10774
10928
|
async function initCommand() {
|
|
10775
10929
|
logger.info("Initializing rulesync...");
|
|
10776
10930
|
await ensureDir(RULESYNC_RELATIVE_DIR_PATH);
|
|
@@ -10933,14 +11087,14 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
10933
11087
|
await ensureDir(commandPaths.relativeDirPath);
|
|
10934
11088
|
await ensureDir(subagentPaths.relativeDirPath);
|
|
10935
11089
|
await ensureDir(ignorePaths.recommended.relativeDirPath);
|
|
10936
|
-
const ruleFilepath =
|
|
11090
|
+
const ruleFilepath = join86(rulePaths.recommended.relativeDirPath, sampleRuleFile.filename);
|
|
10937
11091
|
if (!await fileExists(ruleFilepath)) {
|
|
10938
11092
|
await writeFileContent(ruleFilepath, sampleRuleFile.content);
|
|
10939
11093
|
logger.success(`Created ${ruleFilepath}`);
|
|
10940
11094
|
} else {
|
|
10941
11095
|
logger.info(`Skipped ${ruleFilepath} (already exists)`);
|
|
10942
11096
|
}
|
|
10943
|
-
const mcpFilepath =
|
|
11097
|
+
const mcpFilepath = join86(
|
|
10944
11098
|
mcpPaths.recommended.relativeDirPath,
|
|
10945
11099
|
mcpPaths.recommended.relativeFilePath
|
|
10946
11100
|
);
|
|
@@ -10950,21 +11104,21 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
10950
11104
|
} else {
|
|
10951
11105
|
logger.info(`Skipped ${mcpFilepath} (already exists)`);
|
|
10952
11106
|
}
|
|
10953
|
-
const commandFilepath =
|
|
11107
|
+
const commandFilepath = join86(commandPaths.relativeDirPath, sampleCommandFile.filename);
|
|
10954
11108
|
if (!await fileExists(commandFilepath)) {
|
|
10955
11109
|
await writeFileContent(commandFilepath, sampleCommandFile.content);
|
|
10956
11110
|
logger.success(`Created ${commandFilepath}`);
|
|
10957
11111
|
} else {
|
|
10958
11112
|
logger.info(`Skipped ${commandFilepath} (already exists)`);
|
|
10959
11113
|
}
|
|
10960
|
-
const subagentFilepath =
|
|
11114
|
+
const subagentFilepath = join86(subagentPaths.relativeDirPath, sampleSubagentFile.filename);
|
|
10961
11115
|
if (!await fileExists(subagentFilepath)) {
|
|
10962
11116
|
await writeFileContent(subagentFilepath, sampleSubagentFile.content);
|
|
10963
11117
|
logger.success(`Created ${subagentFilepath}`);
|
|
10964
11118
|
} else {
|
|
10965
11119
|
logger.info(`Skipped ${subagentFilepath} (already exists)`);
|
|
10966
11120
|
}
|
|
10967
|
-
const ignoreFilepath =
|
|
11121
|
+
const ignoreFilepath = join86(
|
|
10968
11122
|
ignorePaths.recommended.relativeDirPath,
|
|
10969
11123
|
ignorePaths.recommended.relativeFilePath
|
|
10970
11124
|
);
|
|
@@ -10980,12 +11134,12 @@ Attention, again, you are just the planner, so though you can read any files and
|
|
|
10980
11134
|
import { FastMCP } from "fastmcp";
|
|
10981
11135
|
|
|
10982
11136
|
// src/mcp/commands.ts
|
|
10983
|
-
import { basename as
|
|
10984
|
-
import { z as
|
|
11137
|
+
import { basename as basename22, join as join87 } from "path";
|
|
11138
|
+
import { z as z39 } from "zod/mini";
|
|
10985
11139
|
var maxCommandSizeBytes = 1024 * 1024;
|
|
10986
11140
|
var maxCommandsCount = 1e3;
|
|
10987
11141
|
async function listCommands() {
|
|
10988
|
-
const commandsDir =
|
|
11142
|
+
const commandsDir = join87(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
10989
11143
|
try {
|
|
10990
11144
|
const files = await listDirectoryFiles(commandsDir);
|
|
10991
11145
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -10997,7 +11151,7 @@ async function listCommands() {
|
|
|
10997
11151
|
});
|
|
10998
11152
|
const frontmatter = command.getFrontmatter();
|
|
10999
11153
|
return {
|
|
11000
|
-
relativePathFromCwd:
|
|
11154
|
+
relativePathFromCwd: join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, file),
|
|
11001
11155
|
frontmatter
|
|
11002
11156
|
};
|
|
11003
11157
|
} catch (error) {
|
|
@@ -11017,13 +11171,13 @@ async function getCommand({ relativePathFromCwd }) {
|
|
|
11017
11171
|
relativePath: relativePathFromCwd,
|
|
11018
11172
|
intendedRootDir: process.cwd()
|
|
11019
11173
|
});
|
|
11020
|
-
const filename =
|
|
11174
|
+
const filename = basename22(relativePathFromCwd);
|
|
11021
11175
|
try {
|
|
11022
11176
|
const command = await RulesyncCommand.fromFile({
|
|
11023
11177
|
relativeFilePath: filename
|
|
11024
11178
|
});
|
|
11025
11179
|
return {
|
|
11026
|
-
relativePathFromCwd:
|
|
11180
|
+
relativePathFromCwd: join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
11027
11181
|
frontmatter: command.getFrontmatter(),
|
|
11028
11182
|
body: command.getBody()
|
|
11029
11183
|
};
|
|
@@ -11042,7 +11196,7 @@ async function putCommand({
|
|
|
11042
11196
|
relativePath: relativePathFromCwd,
|
|
11043
11197
|
intendedRootDir: process.cwd()
|
|
11044
11198
|
});
|
|
11045
|
-
const filename =
|
|
11199
|
+
const filename = basename22(relativePathFromCwd);
|
|
11046
11200
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
11047
11201
|
if (estimatedSize > maxCommandSizeBytes) {
|
|
11048
11202
|
throw new Error(
|
|
@@ -11052,7 +11206,7 @@ async function putCommand({
|
|
|
11052
11206
|
try {
|
|
11053
11207
|
const existingCommands = await listCommands();
|
|
11054
11208
|
const isUpdate = existingCommands.some(
|
|
11055
|
-
(command2) => command2.relativePathFromCwd ===
|
|
11209
|
+
(command2) => command2.relativePathFromCwd === join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
11056
11210
|
);
|
|
11057
11211
|
if (!isUpdate && existingCommands.length >= maxCommandsCount) {
|
|
11058
11212
|
throw new Error(`Maximum number of commands (${maxCommandsCount}) reached`);
|
|
@@ -11067,11 +11221,11 @@ async function putCommand({
|
|
|
11067
11221
|
fileContent,
|
|
11068
11222
|
validate: true
|
|
11069
11223
|
});
|
|
11070
|
-
const commandsDir =
|
|
11224
|
+
const commandsDir = join87(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
11071
11225
|
await ensureDir(commandsDir);
|
|
11072
11226
|
await writeFileContent(command.getFilePath(), command.getFileContent());
|
|
11073
11227
|
return {
|
|
11074
|
-
relativePathFromCwd:
|
|
11228
|
+
relativePathFromCwd: join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
11075
11229
|
frontmatter: command.getFrontmatter(),
|
|
11076
11230
|
body: command.getBody()
|
|
11077
11231
|
};
|
|
@@ -11086,12 +11240,12 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
11086
11240
|
relativePath: relativePathFromCwd,
|
|
11087
11241
|
intendedRootDir: process.cwd()
|
|
11088
11242
|
});
|
|
11089
|
-
const filename =
|
|
11090
|
-
const fullPath =
|
|
11243
|
+
const filename = basename22(relativePathFromCwd);
|
|
11244
|
+
const fullPath = join87(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename);
|
|
11091
11245
|
try {
|
|
11092
11246
|
await removeFile(fullPath);
|
|
11093
11247
|
return {
|
|
11094
|
-
relativePathFromCwd:
|
|
11248
|
+
relativePathFromCwd: join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
11095
11249
|
};
|
|
11096
11250
|
} catch (error) {
|
|
11097
11251
|
throw new Error(`Failed to delete command file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -11100,23 +11254,23 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
11100
11254
|
}
|
|
11101
11255
|
}
|
|
11102
11256
|
var commandToolSchemas = {
|
|
11103
|
-
listCommands:
|
|
11104
|
-
getCommand:
|
|
11105
|
-
relativePathFromCwd:
|
|
11257
|
+
listCommands: z39.object({}),
|
|
11258
|
+
getCommand: z39.object({
|
|
11259
|
+
relativePathFromCwd: z39.string()
|
|
11106
11260
|
}),
|
|
11107
|
-
putCommand:
|
|
11108
|
-
relativePathFromCwd:
|
|
11261
|
+
putCommand: z39.object({
|
|
11262
|
+
relativePathFromCwd: z39.string(),
|
|
11109
11263
|
frontmatter: RulesyncCommandFrontmatterSchema,
|
|
11110
|
-
body:
|
|
11264
|
+
body: z39.string()
|
|
11111
11265
|
}),
|
|
11112
|
-
deleteCommand:
|
|
11113
|
-
relativePathFromCwd:
|
|
11266
|
+
deleteCommand: z39.object({
|
|
11267
|
+
relativePathFromCwd: z39.string()
|
|
11114
11268
|
})
|
|
11115
11269
|
};
|
|
11116
11270
|
var commandTools = {
|
|
11117
11271
|
listCommands: {
|
|
11118
11272
|
name: "listCommands",
|
|
11119
|
-
description: `List all commands from ${
|
|
11273
|
+
description: `List all commands from ${join87(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
11120
11274
|
parameters: commandToolSchemas.listCommands,
|
|
11121
11275
|
execute: async () => {
|
|
11122
11276
|
const commands = await listCommands();
|
|
@@ -11158,11 +11312,11 @@ var commandTools = {
|
|
|
11158
11312
|
};
|
|
11159
11313
|
|
|
11160
11314
|
// src/mcp/ignore.ts
|
|
11161
|
-
import { join as
|
|
11162
|
-
import { z as
|
|
11315
|
+
import { join as join88 } from "path";
|
|
11316
|
+
import { z as z40 } from "zod/mini";
|
|
11163
11317
|
var maxIgnoreFileSizeBytes = 100 * 1024;
|
|
11164
11318
|
async function getIgnoreFile() {
|
|
11165
|
-
const ignoreFilePath =
|
|
11319
|
+
const ignoreFilePath = join88(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
11166
11320
|
try {
|
|
11167
11321
|
const content = await readFileContent(ignoreFilePath);
|
|
11168
11322
|
return {
|
|
@@ -11176,7 +11330,7 @@ async function getIgnoreFile() {
|
|
|
11176
11330
|
}
|
|
11177
11331
|
}
|
|
11178
11332
|
async function putIgnoreFile({ content }) {
|
|
11179
|
-
const ignoreFilePath =
|
|
11333
|
+
const ignoreFilePath = join88(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
11180
11334
|
const contentSizeBytes = Buffer.byteLength(content, "utf8");
|
|
11181
11335
|
if (contentSizeBytes > maxIgnoreFileSizeBytes) {
|
|
11182
11336
|
throw new Error(
|
|
@@ -11197,8 +11351,8 @@ async function putIgnoreFile({ content }) {
|
|
|
11197
11351
|
}
|
|
11198
11352
|
}
|
|
11199
11353
|
async function deleteIgnoreFile() {
|
|
11200
|
-
const aiignorePath =
|
|
11201
|
-
const legacyIgnorePath =
|
|
11354
|
+
const aiignorePath = join88(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
11355
|
+
const legacyIgnorePath = join88(process.cwd(), RULESYNC_IGNORE_RELATIVE_FILE_PATH);
|
|
11202
11356
|
try {
|
|
11203
11357
|
await Promise.all([removeFile(aiignorePath), removeFile(legacyIgnorePath)]);
|
|
11204
11358
|
return {
|
|
@@ -11216,11 +11370,11 @@ async function deleteIgnoreFile() {
|
|
|
11216
11370
|
}
|
|
11217
11371
|
}
|
|
11218
11372
|
var ignoreToolSchemas = {
|
|
11219
|
-
getIgnoreFile:
|
|
11220
|
-
putIgnoreFile:
|
|
11221
|
-
content:
|
|
11373
|
+
getIgnoreFile: z40.object({}),
|
|
11374
|
+
putIgnoreFile: z40.object({
|
|
11375
|
+
content: z40.string()
|
|
11222
11376
|
}),
|
|
11223
|
-
deleteIgnoreFile:
|
|
11377
|
+
deleteIgnoreFile: z40.object({})
|
|
11224
11378
|
};
|
|
11225
11379
|
var ignoreTools = {
|
|
11226
11380
|
getIgnoreFile: {
|
|
@@ -11253,8 +11407,8 @@ var ignoreTools = {
|
|
|
11253
11407
|
};
|
|
11254
11408
|
|
|
11255
11409
|
// src/mcp/mcp.ts
|
|
11256
|
-
import { join as
|
|
11257
|
-
import { z as
|
|
11410
|
+
import { join as join89 } from "path";
|
|
11411
|
+
import { z as z41 } from "zod/mini";
|
|
11258
11412
|
var maxMcpSizeBytes = 1024 * 1024;
|
|
11259
11413
|
async function getMcpFile() {
|
|
11260
11414
|
const config = await ConfigResolver.resolve({});
|
|
@@ -11263,7 +11417,7 @@ async function getMcpFile() {
|
|
|
11263
11417
|
validate: true,
|
|
11264
11418
|
modularMcp: config.getModularMcp()
|
|
11265
11419
|
});
|
|
11266
|
-
const relativePathFromCwd =
|
|
11420
|
+
const relativePathFromCwd = join89(
|
|
11267
11421
|
rulesyncMcp.getRelativeDirPath(),
|
|
11268
11422
|
rulesyncMcp.getRelativeFilePath()
|
|
11269
11423
|
);
|
|
@@ -11296,7 +11450,7 @@ async function putMcpFile({ content }) {
|
|
|
11296
11450
|
const paths = RulesyncMcp.getSettablePaths();
|
|
11297
11451
|
const relativeDirPath = paths.recommended.relativeDirPath;
|
|
11298
11452
|
const relativeFilePath = paths.recommended.relativeFilePath;
|
|
11299
|
-
const fullPath =
|
|
11453
|
+
const fullPath = join89(baseDir, relativeDirPath, relativeFilePath);
|
|
11300
11454
|
const rulesyncMcp = new RulesyncMcp({
|
|
11301
11455
|
baseDir,
|
|
11302
11456
|
relativeDirPath,
|
|
@@ -11305,9 +11459,9 @@ async function putMcpFile({ content }) {
|
|
|
11305
11459
|
validate: true,
|
|
11306
11460
|
modularMcp: config.getModularMcp()
|
|
11307
11461
|
});
|
|
11308
|
-
await ensureDir(
|
|
11462
|
+
await ensureDir(join89(baseDir, relativeDirPath));
|
|
11309
11463
|
await writeFileContent(fullPath, content);
|
|
11310
|
-
const relativePathFromCwd =
|
|
11464
|
+
const relativePathFromCwd = join89(relativeDirPath, relativeFilePath);
|
|
11311
11465
|
return {
|
|
11312
11466
|
relativePathFromCwd,
|
|
11313
11467
|
content: rulesyncMcp.getFileContent()
|
|
@@ -11322,15 +11476,15 @@ async function deleteMcpFile() {
|
|
|
11322
11476
|
try {
|
|
11323
11477
|
const baseDir = process.cwd();
|
|
11324
11478
|
const paths = RulesyncMcp.getSettablePaths();
|
|
11325
|
-
const recommendedPath =
|
|
11479
|
+
const recommendedPath = join89(
|
|
11326
11480
|
baseDir,
|
|
11327
11481
|
paths.recommended.relativeDirPath,
|
|
11328
11482
|
paths.recommended.relativeFilePath
|
|
11329
11483
|
);
|
|
11330
|
-
const legacyPath =
|
|
11484
|
+
const legacyPath = join89(baseDir, paths.legacy.relativeDirPath, paths.legacy.relativeFilePath);
|
|
11331
11485
|
await removeFile(recommendedPath);
|
|
11332
11486
|
await removeFile(legacyPath);
|
|
11333
|
-
const relativePathFromCwd =
|
|
11487
|
+
const relativePathFromCwd = join89(
|
|
11334
11488
|
paths.recommended.relativeDirPath,
|
|
11335
11489
|
paths.recommended.relativeFilePath
|
|
11336
11490
|
);
|
|
@@ -11344,11 +11498,11 @@ async function deleteMcpFile() {
|
|
|
11344
11498
|
}
|
|
11345
11499
|
}
|
|
11346
11500
|
var mcpToolSchemas = {
|
|
11347
|
-
getMcpFile:
|
|
11348
|
-
putMcpFile:
|
|
11349
|
-
content:
|
|
11501
|
+
getMcpFile: z41.object({}),
|
|
11502
|
+
putMcpFile: z41.object({
|
|
11503
|
+
content: z41.string()
|
|
11350
11504
|
}),
|
|
11351
|
-
deleteMcpFile:
|
|
11505
|
+
deleteMcpFile: z41.object({})
|
|
11352
11506
|
};
|
|
11353
11507
|
var mcpTools = {
|
|
11354
11508
|
getMcpFile: {
|
|
@@ -11381,12 +11535,12 @@ var mcpTools = {
|
|
|
11381
11535
|
};
|
|
11382
11536
|
|
|
11383
11537
|
// src/mcp/rules.ts
|
|
11384
|
-
import { basename as
|
|
11385
|
-
import { z as
|
|
11538
|
+
import { basename as basename23, join as join90 } from "path";
|
|
11539
|
+
import { z as z42 } from "zod/mini";
|
|
11386
11540
|
var maxRuleSizeBytes = 1024 * 1024;
|
|
11387
11541
|
var maxRulesCount = 1e3;
|
|
11388
11542
|
async function listRules() {
|
|
11389
|
-
const rulesDir =
|
|
11543
|
+
const rulesDir = join90(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
11390
11544
|
try {
|
|
11391
11545
|
const files = await listDirectoryFiles(rulesDir);
|
|
11392
11546
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -11399,7 +11553,7 @@ async function listRules() {
|
|
|
11399
11553
|
});
|
|
11400
11554
|
const frontmatter = rule.getFrontmatter();
|
|
11401
11555
|
return {
|
|
11402
|
-
relativePathFromCwd:
|
|
11556
|
+
relativePathFromCwd: join90(RULESYNC_RULES_RELATIVE_DIR_PATH, file),
|
|
11403
11557
|
frontmatter
|
|
11404
11558
|
};
|
|
11405
11559
|
} catch (error) {
|
|
@@ -11419,14 +11573,14 @@ async function getRule({ relativePathFromCwd }) {
|
|
|
11419
11573
|
relativePath: relativePathFromCwd,
|
|
11420
11574
|
intendedRootDir: process.cwd()
|
|
11421
11575
|
});
|
|
11422
|
-
const filename =
|
|
11576
|
+
const filename = basename23(relativePathFromCwd);
|
|
11423
11577
|
try {
|
|
11424
11578
|
const rule = await RulesyncRule.fromFile({
|
|
11425
11579
|
relativeFilePath: filename,
|
|
11426
11580
|
validate: true
|
|
11427
11581
|
});
|
|
11428
11582
|
return {
|
|
11429
|
-
relativePathFromCwd:
|
|
11583
|
+
relativePathFromCwd: join90(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
11430
11584
|
frontmatter: rule.getFrontmatter(),
|
|
11431
11585
|
body: rule.getBody()
|
|
11432
11586
|
};
|
|
@@ -11445,7 +11599,7 @@ async function putRule({
|
|
|
11445
11599
|
relativePath: relativePathFromCwd,
|
|
11446
11600
|
intendedRootDir: process.cwd()
|
|
11447
11601
|
});
|
|
11448
|
-
const filename =
|
|
11602
|
+
const filename = basename23(relativePathFromCwd);
|
|
11449
11603
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
11450
11604
|
if (estimatedSize > maxRuleSizeBytes) {
|
|
11451
11605
|
throw new Error(
|
|
@@ -11455,7 +11609,7 @@ async function putRule({
|
|
|
11455
11609
|
try {
|
|
11456
11610
|
const existingRules = await listRules();
|
|
11457
11611
|
const isUpdate = existingRules.some(
|
|
11458
|
-
(rule2) => rule2.relativePathFromCwd ===
|
|
11612
|
+
(rule2) => rule2.relativePathFromCwd === join90(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
11459
11613
|
);
|
|
11460
11614
|
if (!isUpdate && existingRules.length >= maxRulesCount) {
|
|
11461
11615
|
throw new Error(`Maximum number of rules (${maxRulesCount}) reached`);
|
|
@@ -11468,11 +11622,11 @@ async function putRule({
|
|
|
11468
11622
|
body,
|
|
11469
11623
|
validate: true
|
|
11470
11624
|
});
|
|
11471
|
-
const rulesDir =
|
|
11625
|
+
const rulesDir = join90(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
11472
11626
|
await ensureDir(rulesDir);
|
|
11473
11627
|
await writeFileContent(rule.getFilePath(), rule.getFileContent());
|
|
11474
11628
|
return {
|
|
11475
|
-
relativePathFromCwd:
|
|
11629
|
+
relativePathFromCwd: join90(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
11476
11630
|
frontmatter: rule.getFrontmatter(),
|
|
11477
11631
|
body: rule.getBody()
|
|
11478
11632
|
};
|
|
@@ -11487,12 +11641,12 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
11487
11641
|
relativePath: relativePathFromCwd,
|
|
11488
11642
|
intendedRootDir: process.cwd()
|
|
11489
11643
|
});
|
|
11490
|
-
const filename =
|
|
11491
|
-
const fullPath =
|
|
11644
|
+
const filename = basename23(relativePathFromCwd);
|
|
11645
|
+
const fullPath = join90(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH, filename);
|
|
11492
11646
|
try {
|
|
11493
11647
|
await removeFile(fullPath);
|
|
11494
11648
|
return {
|
|
11495
|
-
relativePathFromCwd:
|
|
11649
|
+
relativePathFromCwd: join90(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
11496
11650
|
};
|
|
11497
11651
|
} catch (error) {
|
|
11498
11652
|
throw new Error(`Failed to delete rule file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -11501,23 +11655,23 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
11501
11655
|
}
|
|
11502
11656
|
}
|
|
11503
11657
|
var ruleToolSchemas = {
|
|
11504
|
-
listRules:
|
|
11505
|
-
getRule:
|
|
11506
|
-
relativePathFromCwd:
|
|
11658
|
+
listRules: z42.object({}),
|
|
11659
|
+
getRule: z42.object({
|
|
11660
|
+
relativePathFromCwd: z42.string()
|
|
11507
11661
|
}),
|
|
11508
|
-
putRule:
|
|
11509
|
-
relativePathFromCwd:
|
|
11662
|
+
putRule: z42.object({
|
|
11663
|
+
relativePathFromCwd: z42.string(),
|
|
11510
11664
|
frontmatter: RulesyncRuleFrontmatterSchema,
|
|
11511
|
-
body:
|
|
11665
|
+
body: z42.string()
|
|
11512
11666
|
}),
|
|
11513
|
-
deleteRule:
|
|
11514
|
-
relativePathFromCwd:
|
|
11667
|
+
deleteRule: z42.object({
|
|
11668
|
+
relativePathFromCwd: z42.string()
|
|
11515
11669
|
})
|
|
11516
11670
|
};
|
|
11517
11671
|
var ruleTools = {
|
|
11518
11672
|
listRules: {
|
|
11519
11673
|
name: "listRules",
|
|
11520
|
-
description: `List all rules from ${
|
|
11674
|
+
description: `List all rules from ${join90(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
11521
11675
|
parameters: ruleToolSchemas.listRules,
|
|
11522
11676
|
execute: async () => {
|
|
11523
11677
|
const rules = await listRules();
|
|
@@ -11559,8 +11713,8 @@ var ruleTools = {
|
|
|
11559
11713
|
};
|
|
11560
11714
|
|
|
11561
11715
|
// src/mcp/skills.ts
|
|
11562
|
-
import { basename as
|
|
11563
|
-
import { z as
|
|
11716
|
+
import { basename as basename24, dirname as dirname2, join as join91 } from "path";
|
|
11717
|
+
import { z as z43 } from "zod/mini";
|
|
11564
11718
|
var maxSkillSizeBytes = 1024 * 1024;
|
|
11565
11719
|
var maxSkillsCount = 1e3;
|
|
11566
11720
|
function aiDirFileToMcpSkillFile(file) {
|
|
@@ -11576,19 +11730,19 @@ function mcpSkillFileToAiDirFile(file) {
|
|
|
11576
11730
|
};
|
|
11577
11731
|
}
|
|
11578
11732
|
function extractDirName(relativeDirPathFromCwd) {
|
|
11579
|
-
const dirName =
|
|
11733
|
+
const dirName = basename24(relativeDirPathFromCwd);
|
|
11580
11734
|
if (!dirName) {
|
|
11581
11735
|
throw new Error(`Invalid path: ${relativeDirPathFromCwd}`);
|
|
11582
11736
|
}
|
|
11583
11737
|
return dirName;
|
|
11584
11738
|
}
|
|
11585
11739
|
async function listSkills() {
|
|
11586
|
-
const skillsDir =
|
|
11740
|
+
const skillsDir = join91(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH);
|
|
11587
11741
|
try {
|
|
11588
|
-
const skillDirPaths = await findFilesByGlobs(
|
|
11742
|
+
const skillDirPaths = await findFilesByGlobs(join91(skillsDir, "*"), { type: "dir" });
|
|
11589
11743
|
const skills = await Promise.all(
|
|
11590
11744
|
skillDirPaths.map(async (dirPath) => {
|
|
11591
|
-
const dirName =
|
|
11745
|
+
const dirName = basename24(dirPath);
|
|
11592
11746
|
if (!dirName) return null;
|
|
11593
11747
|
try {
|
|
11594
11748
|
const skill = await RulesyncSkill.fromDir({
|
|
@@ -11596,7 +11750,7 @@ async function listSkills() {
|
|
|
11596
11750
|
});
|
|
11597
11751
|
const frontmatter = skill.getFrontmatter();
|
|
11598
11752
|
return {
|
|
11599
|
-
relativeDirPathFromCwd:
|
|
11753
|
+
relativeDirPathFromCwd: join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
11600
11754
|
frontmatter
|
|
11601
11755
|
};
|
|
11602
11756
|
} catch (error) {
|
|
@@ -11622,7 +11776,7 @@ async function getSkill({ relativeDirPathFromCwd }) {
|
|
|
11622
11776
|
dirName
|
|
11623
11777
|
});
|
|
11624
11778
|
return {
|
|
11625
|
-
relativeDirPathFromCwd:
|
|
11779
|
+
relativeDirPathFromCwd: join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
11626
11780
|
frontmatter: skill.getFrontmatter(),
|
|
11627
11781
|
body: skill.getBody(),
|
|
11628
11782
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -11656,7 +11810,7 @@ async function putSkill({
|
|
|
11656
11810
|
try {
|
|
11657
11811
|
const existingSkills = await listSkills();
|
|
11658
11812
|
const isUpdate = existingSkills.some(
|
|
11659
|
-
(skill2) => skill2.relativeDirPathFromCwd ===
|
|
11813
|
+
(skill2) => skill2.relativeDirPathFromCwd === join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
11660
11814
|
);
|
|
11661
11815
|
if (!isUpdate && existingSkills.length >= maxSkillsCount) {
|
|
11662
11816
|
throw new Error(`Maximum number of skills (${maxSkillsCount}) reached`);
|
|
@@ -11671,9 +11825,9 @@ async function putSkill({
|
|
|
11671
11825
|
otherFiles: aiDirFiles,
|
|
11672
11826
|
validate: true
|
|
11673
11827
|
});
|
|
11674
|
-
const skillDirPath =
|
|
11828
|
+
const skillDirPath = join91(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
11675
11829
|
await ensureDir(skillDirPath);
|
|
11676
|
-
const skillFilePath =
|
|
11830
|
+
const skillFilePath = join91(skillDirPath, SKILL_FILE_NAME);
|
|
11677
11831
|
const skillFileContent = stringifyFrontmatter(body, frontmatter);
|
|
11678
11832
|
await writeFileContent(skillFilePath, skillFileContent);
|
|
11679
11833
|
for (const file of otherFiles) {
|
|
@@ -11681,15 +11835,15 @@ async function putSkill({
|
|
|
11681
11835
|
relativePath: file.name,
|
|
11682
11836
|
intendedRootDir: skillDirPath
|
|
11683
11837
|
});
|
|
11684
|
-
const filePath =
|
|
11685
|
-
const fileDir =
|
|
11838
|
+
const filePath = join91(skillDirPath, file.name);
|
|
11839
|
+
const fileDir = join91(skillDirPath, dirname2(file.name));
|
|
11686
11840
|
if (fileDir !== skillDirPath) {
|
|
11687
11841
|
await ensureDir(fileDir);
|
|
11688
11842
|
}
|
|
11689
11843
|
await writeFileContent(filePath, file.body);
|
|
11690
11844
|
}
|
|
11691
11845
|
return {
|
|
11692
|
-
relativeDirPathFromCwd:
|
|
11846
|
+
relativeDirPathFromCwd: join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
11693
11847
|
frontmatter: skill.getFrontmatter(),
|
|
11694
11848
|
body: skill.getBody(),
|
|
11695
11849
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -11711,13 +11865,13 @@ async function deleteSkill({
|
|
|
11711
11865
|
intendedRootDir: process.cwd()
|
|
11712
11866
|
});
|
|
11713
11867
|
const dirName = extractDirName(relativeDirPathFromCwd);
|
|
11714
|
-
const skillDirPath =
|
|
11868
|
+
const skillDirPath = join91(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
11715
11869
|
try {
|
|
11716
11870
|
if (await directoryExists(skillDirPath)) {
|
|
11717
11871
|
await removeDirectory(skillDirPath);
|
|
11718
11872
|
}
|
|
11719
11873
|
return {
|
|
11720
|
-
relativeDirPathFromCwd:
|
|
11874
|
+
relativeDirPathFromCwd: join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
11721
11875
|
};
|
|
11722
11876
|
} catch (error) {
|
|
11723
11877
|
throw new Error(
|
|
@@ -11728,29 +11882,29 @@ async function deleteSkill({
|
|
|
11728
11882
|
);
|
|
11729
11883
|
}
|
|
11730
11884
|
}
|
|
11731
|
-
var McpSkillFileSchema =
|
|
11732
|
-
name:
|
|
11733
|
-
body:
|
|
11885
|
+
var McpSkillFileSchema = z43.object({
|
|
11886
|
+
name: z43.string(),
|
|
11887
|
+
body: z43.string()
|
|
11734
11888
|
});
|
|
11735
11889
|
var skillToolSchemas = {
|
|
11736
|
-
listSkills:
|
|
11737
|
-
getSkill:
|
|
11738
|
-
relativeDirPathFromCwd:
|
|
11890
|
+
listSkills: z43.object({}),
|
|
11891
|
+
getSkill: z43.object({
|
|
11892
|
+
relativeDirPathFromCwd: z43.string()
|
|
11739
11893
|
}),
|
|
11740
|
-
putSkill:
|
|
11741
|
-
relativeDirPathFromCwd:
|
|
11894
|
+
putSkill: z43.object({
|
|
11895
|
+
relativeDirPathFromCwd: z43.string(),
|
|
11742
11896
|
frontmatter: RulesyncSkillFrontmatterSchema,
|
|
11743
|
-
body:
|
|
11744
|
-
otherFiles:
|
|
11897
|
+
body: z43.string(),
|
|
11898
|
+
otherFiles: z43.optional(z43.array(McpSkillFileSchema))
|
|
11745
11899
|
}),
|
|
11746
|
-
deleteSkill:
|
|
11747
|
-
relativeDirPathFromCwd:
|
|
11900
|
+
deleteSkill: z43.object({
|
|
11901
|
+
relativeDirPathFromCwd: z43.string()
|
|
11748
11902
|
})
|
|
11749
11903
|
};
|
|
11750
11904
|
var skillTools = {
|
|
11751
11905
|
listSkills: {
|
|
11752
11906
|
name: "listSkills",
|
|
11753
|
-
description: `List all skills from ${
|
|
11907
|
+
description: `List all skills from ${join91(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "*", SKILL_FILE_NAME)} with their frontmatter.`,
|
|
11754
11908
|
parameters: skillToolSchemas.listSkills,
|
|
11755
11909
|
execute: async () => {
|
|
11756
11910
|
const skills = await listSkills();
|
|
@@ -11793,12 +11947,12 @@ var skillTools = {
|
|
|
11793
11947
|
};
|
|
11794
11948
|
|
|
11795
11949
|
// src/mcp/subagents.ts
|
|
11796
|
-
import { basename as
|
|
11797
|
-
import { z as
|
|
11950
|
+
import { basename as basename25, join as join92 } from "path";
|
|
11951
|
+
import { z as z44 } from "zod/mini";
|
|
11798
11952
|
var maxSubagentSizeBytes = 1024 * 1024;
|
|
11799
11953
|
var maxSubagentsCount = 1e3;
|
|
11800
11954
|
async function listSubagents() {
|
|
11801
|
-
const subagentsDir =
|
|
11955
|
+
const subagentsDir = join92(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
11802
11956
|
try {
|
|
11803
11957
|
const files = await listDirectoryFiles(subagentsDir);
|
|
11804
11958
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -11811,7 +11965,7 @@ async function listSubagents() {
|
|
|
11811
11965
|
});
|
|
11812
11966
|
const frontmatter = subagent.getFrontmatter();
|
|
11813
11967
|
return {
|
|
11814
|
-
relativePathFromCwd:
|
|
11968
|
+
relativePathFromCwd: join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, file),
|
|
11815
11969
|
frontmatter
|
|
11816
11970
|
};
|
|
11817
11971
|
} catch (error) {
|
|
@@ -11833,14 +11987,14 @@ async function getSubagent({ relativePathFromCwd }) {
|
|
|
11833
11987
|
relativePath: relativePathFromCwd,
|
|
11834
11988
|
intendedRootDir: process.cwd()
|
|
11835
11989
|
});
|
|
11836
|
-
const filename =
|
|
11990
|
+
const filename = basename25(relativePathFromCwd);
|
|
11837
11991
|
try {
|
|
11838
11992
|
const subagent = await RulesyncSubagent.fromFile({
|
|
11839
11993
|
relativeFilePath: filename,
|
|
11840
11994
|
validate: true
|
|
11841
11995
|
});
|
|
11842
11996
|
return {
|
|
11843
|
-
relativePathFromCwd:
|
|
11997
|
+
relativePathFromCwd: join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
11844
11998
|
frontmatter: subagent.getFrontmatter(),
|
|
11845
11999
|
body: subagent.getBody()
|
|
11846
12000
|
};
|
|
@@ -11859,7 +12013,7 @@ async function putSubagent({
|
|
|
11859
12013
|
relativePath: relativePathFromCwd,
|
|
11860
12014
|
intendedRootDir: process.cwd()
|
|
11861
12015
|
});
|
|
11862
|
-
const filename =
|
|
12016
|
+
const filename = basename25(relativePathFromCwd);
|
|
11863
12017
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
11864
12018
|
if (estimatedSize > maxSubagentSizeBytes) {
|
|
11865
12019
|
throw new Error(
|
|
@@ -11869,7 +12023,7 @@ async function putSubagent({
|
|
|
11869
12023
|
try {
|
|
11870
12024
|
const existingSubagents = await listSubagents();
|
|
11871
12025
|
const isUpdate = existingSubagents.some(
|
|
11872
|
-
(subagent2) => subagent2.relativePathFromCwd ===
|
|
12026
|
+
(subagent2) => subagent2.relativePathFromCwd === join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
11873
12027
|
);
|
|
11874
12028
|
if (!isUpdate && existingSubagents.length >= maxSubagentsCount) {
|
|
11875
12029
|
throw new Error(`Maximum number of subagents (${maxSubagentsCount}) reached`);
|
|
@@ -11882,11 +12036,11 @@ async function putSubagent({
|
|
|
11882
12036
|
body,
|
|
11883
12037
|
validate: true
|
|
11884
12038
|
});
|
|
11885
|
-
const subagentsDir =
|
|
12039
|
+
const subagentsDir = join92(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
11886
12040
|
await ensureDir(subagentsDir);
|
|
11887
12041
|
await writeFileContent(subagent.getFilePath(), subagent.getFileContent());
|
|
11888
12042
|
return {
|
|
11889
|
-
relativePathFromCwd:
|
|
12043
|
+
relativePathFromCwd: join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
11890
12044
|
frontmatter: subagent.getFrontmatter(),
|
|
11891
12045
|
body: subagent.getBody()
|
|
11892
12046
|
};
|
|
@@ -11901,12 +12055,12 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
11901
12055
|
relativePath: relativePathFromCwd,
|
|
11902
12056
|
intendedRootDir: process.cwd()
|
|
11903
12057
|
});
|
|
11904
|
-
const filename =
|
|
11905
|
-
const fullPath =
|
|
12058
|
+
const filename = basename25(relativePathFromCwd);
|
|
12059
|
+
const fullPath = join92(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename);
|
|
11906
12060
|
try {
|
|
11907
12061
|
await removeFile(fullPath);
|
|
11908
12062
|
return {
|
|
11909
|
-
relativePathFromCwd:
|
|
12063
|
+
relativePathFromCwd: join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
11910
12064
|
};
|
|
11911
12065
|
} catch (error) {
|
|
11912
12066
|
throw new Error(
|
|
@@ -11918,23 +12072,23 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
11918
12072
|
}
|
|
11919
12073
|
}
|
|
11920
12074
|
var subagentToolSchemas = {
|
|
11921
|
-
listSubagents:
|
|
11922
|
-
getSubagent:
|
|
11923
|
-
relativePathFromCwd:
|
|
12075
|
+
listSubagents: z44.object({}),
|
|
12076
|
+
getSubagent: z44.object({
|
|
12077
|
+
relativePathFromCwd: z44.string()
|
|
11924
12078
|
}),
|
|
11925
|
-
putSubagent:
|
|
11926
|
-
relativePathFromCwd:
|
|
12079
|
+
putSubagent: z44.object({
|
|
12080
|
+
relativePathFromCwd: z44.string(),
|
|
11927
12081
|
frontmatter: RulesyncSubagentFrontmatterSchema,
|
|
11928
|
-
body:
|
|
12082
|
+
body: z44.string()
|
|
11929
12083
|
}),
|
|
11930
|
-
deleteSubagent:
|
|
11931
|
-
relativePathFromCwd:
|
|
12084
|
+
deleteSubagent: z44.object({
|
|
12085
|
+
relativePathFromCwd: z44.string()
|
|
11932
12086
|
})
|
|
11933
12087
|
};
|
|
11934
12088
|
var subagentTools = {
|
|
11935
12089
|
listSubagents: {
|
|
11936
12090
|
name: "listSubagents",
|
|
11937
|
-
description: `List all subagents from ${
|
|
12091
|
+
description: `List all subagents from ${join92(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
11938
12092
|
parameters: subagentToolSchemas.listSubagents,
|
|
11939
12093
|
execute: async () => {
|
|
11940
12094
|
const subagents = await listSubagents();
|
|
@@ -12012,7 +12166,7 @@ async function mcpCommand({ version }) {
|
|
|
12012
12166
|
}
|
|
12013
12167
|
|
|
12014
12168
|
// src/cli/index.ts
|
|
12015
|
-
var getVersion = () => "4.
|
|
12169
|
+
var getVersion = () => "4.2.0";
|
|
12016
12170
|
var main = async () => {
|
|
12017
12171
|
const program = new Command();
|
|
12018
12172
|
const version = getVersion();
|