rulesync 8.2.0 → 8.4.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 +2 -2
- package/dist/{chunk-K4IN6URH.js → chunk-MMBSR2RA.js} +844 -573
- package/dist/cli/index.cjs +486 -215
- package/dist/cli/index.js +2 -2
- package/dist/index.cjs +869 -598
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/cli/index.cjs
CHANGED
|
@@ -13262,6 +13262,17 @@ var CodexCliSubagentTomlSchema = import_mini51.z.looseObject({
|
|
|
13262
13262
|
model_reasoning_effort: import_mini51.z.optional(import_mini51.z.string()),
|
|
13263
13263
|
sandbox_mode: import_mini51.z.optional(import_mini51.z.string())
|
|
13264
13264
|
});
|
|
13265
|
+
function stringifyCodexCliSubagentToml(tomlObj) {
|
|
13266
|
+
const { developer_instructions, ...restFields } = tomlObj;
|
|
13267
|
+
const restToml = smolToml4.stringify(restFields).trimEnd();
|
|
13268
|
+
if (developer_instructions === void 0) {
|
|
13269
|
+
return restToml;
|
|
13270
|
+
}
|
|
13271
|
+
const developerInstructionsToml = developer_instructions.includes("\n") ? developer_instructions.includes("'''") ? smolToml4.stringify({ developer_instructions }).trimEnd() : `developer_instructions = '''
|
|
13272
|
+
${developer_instructions}
|
|
13273
|
+
'''` : smolToml4.stringify({ developer_instructions }).trimEnd();
|
|
13274
|
+
return [restToml, developerInstructionsToml].filter((value) => value.length > 0).join("\n");
|
|
13275
|
+
}
|
|
13265
13276
|
var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
|
|
13266
13277
|
body;
|
|
13267
13278
|
constructor({ body, ...rest }) {
|
|
@@ -13338,7 +13349,7 @@ var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
|
|
|
13338
13349
|
...rulesyncSubagent.getBody() ? { developer_instructions: rulesyncSubagent.getBody() } : {},
|
|
13339
13350
|
...codexcliSection
|
|
13340
13351
|
};
|
|
13341
|
-
const body =
|
|
13352
|
+
const body = stringifyCodexCliSubagentToml(tomlObj);
|
|
13342
13353
|
const paths = this.getSettablePaths({ global });
|
|
13343
13354
|
const relativeFilePath = rulesyncSubagent.getRelativeFilePath().replace(/\.md$/, ".toml");
|
|
13344
13355
|
return new _CodexCliSubagent({
|
|
@@ -20473,11 +20484,11 @@ function getBaseDirsInLightOfGlobal({
|
|
|
20473
20484
|
}
|
|
20474
20485
|
|
|
20475
20486
|
// src/lib/generate.ts
|
|
20476
|
-
var
|
|
20487
|
+
var import_node_path141 = require("path");
|
|
20477
20488
|
var import_es_toolkit5 = require("es-toolkit");
|
|
20478
20489
|
|
|
20479
20490
|
// src/features/permissions/permissions-processor.ts
|
|
20480
|
-
var
|
|
20491
|
+
var import_mini74 = require("zod/mini");
|
|
20481
20492
|
|
|
20482
20493
|
// src/features/permissions/claudecode-permissions.ts
|
|
20483
20494
|
var import_node_path136 = require("path");
|
|
@@ -20806,6 +20817,7 @@ function convertClaudeToRulesyncPermissions(params) {
|
|
|
20806
20817
|
var import_node_path137 = require("path");
|
|
20807
20818
|
var smolToml5 = __toESM(require("smol-toml"), 1);
|
|
20808
20819
|
var RULESYNC_PROFILE_NAME = "rulesync";
|
|
20820
|
+
var RULESYNC_BASH_RULES_FILE_NAME = "rulesync.rules";
|
|
20809
20821
|
var CodexcliPermissions = class _CodexcliPermissions extends ToolPermissions {
|
|
20810
20822
|
static getSettablePaths(_options = {}) {
|
|
20811
20823
|
return {
|
|
@@ -20895,6 +20907,22 @@ var CodexcliPermissions = class _CodexcliPermissions extends ToolPermissions {
|
|
|
20895
20907
|
});
|
|
20896
20908
|
}
|
|
20897
20909
|
};
|
|
20910
|
+
var CodexcliRulesFile = class extends ToolFile {
|
|
20911
|
+
validate() {
|
|
20912
|
+
return { success: true, error: null };
|
|
20913
|
+
}
|
|
20914
|
+
};
|
|
20915
|
+
function createCodexcliBashRulesFile({
|
|
20916
|
+
baseDir = process.cwd(),
|
|
20917
|
+
config
|
|
20918
|
+
}) {
|
|
20919
|
+
return new CodexcliRulesFile({
|
|
20920
|
+
baseDir,
|
|
20921
|
+
relativeDirPath: (0, import_node_path137.join)(".codex", "rules"),
|
|
20922
|
+
relativeFilePath: RULESYNC_BASH_RULES_FILE_NAME,
|
|
20923
|
+
fileContent: buildCodexBashRulesContent(config)
|
|
20924
|
+
});
|
|
20925
|
+
}
|
|
20898
20926
|
function convertRulesyncToCodexProfile({
|
|
20899
20927
|
config,
|
|
20900
20928
|
logger: logger5
|
|
@@ -21003,6 +21031,46 @@ function mapReadAction(action) {
|
|
|
21003
21031
|
function mapWriteAction(action) {
|
|
21004
21032
|
return action === "allow" ? "write" : "none";
|
|
21005
21033
|
}
|
|
21034
|
+
function buildCodexBashRulesContent(config) {
|
|
21035
|
+
const bashRules = config.permission.bash ?? {};
|
|
21036
|
+
const entries = Object.entries(bashRules);
|
|
21037
|
+
const header = [
|
|
21038
|
+
"# Generated by Rulesync from .rulesync/permissions.json (permission.bash)",
|
|
21039
|
+
"# https://developers.openai.com/codex/rules"
|
|
21040
|
+
];
|
|
21041
|
+
if (entries.length === 0) {
|
|
21042
|
+
return [...header, "# No bash permission rules were configured."].join("\n");
|
|
21043
|
+
}
|
|
21044
|
+
const ruleBlocks = entries.map(([pattern, action]) => {
|
|
21045
|
+
const tokens = toCommandPatternTokens(pattern);
|
|
21046
|
+
if (tokens.length === 0) {
|
|
21047
|
+
return null;
|
|
21048
|
+
}
|
|
21049
|
+
const serializedTokens = tokens.map((token) => JSON.stringify(token)).join(", ");
|
|
21050
|
+
const decision = mapBashActionToDecision(action);
|
|
21051
|
+
return [
|
|
21052
|
+
"",
|
|
21053
|
+
`# ${pattern}`,
|
|
21054
|
+
"prefix_rule(",
|
|
21055
|
+
` pattern = [${serializedTokens}],`,
|
|
21056
|
+
` decision = ${JSON.stringify(decision)},`,
|
|
21057
|
+
` justification = ${JSON.stringify(`Generated from Rulesync permission.bash: ${pattern}`)},`,
|
|
21058
|
+
")"
|
|
21059
|
+
].join("\n");
|
|
21060
|
+
}).filter((block) => block !== null);
|
|
21061
|
+
if (ruleBlocks.length === 0) {
|
|
21062
|
+
return [...header, "# No valid bash patterns were found."].join("\n");
|
|
21063
|
+
}
|
|
21064
|
+
return [...header, ...ruleBlocks].join("\n");
|
|
21065
|
+
}
|
|
21066
|
+
function toCommandPatternTokens(commandPattern) {
|
|
21067
|
+
return commandPattern.trim().split(/\s+/).map((token) => token.trim()).filter((token) => token.length > 0);
|
|
21068
|
+
}
|
|
21069
|
+
function mapBashActionToDecision(action) {
|
|
21070
|
+
if (action === "allow") return "allow";
|
|
21071
|
+
if (action === "ask") return "prompt";
|
|
21072
|
+
return "forbidden";
|
|
21073
|
+
}
|
|
21006
21074
|
|
|
21007
21075
|
// src/features/permissions/geminicli-permissions.ts
|
|
21008
21076
|
var import_node_path138 = require("path");
|
|
@@ -21168,16 +21236,200 @@ function parseGeminicliToolEntry({ entry }) {
|
|
|
21168
21236
|
};
|
|
21169
21237
|
}
|
|
21170
21238
|
|
|
21171
|
-
// src/features/permissions/
|
|
21239
|
+
// src/features/permissions/kiro-permissions.ts
|
|
21172
21240
|
var import_node_path139 = require("path");
|
|
21173
|
-
var import_jsonc_parser5 = require("jsonc-parser");
|
|
21174
21241
|
var import_mini72 = require("zod/mini");
|
|
21175
|
-
var
|
|
21176
|
-
import_mini72.z.
|
|
21177
|
-
import_mini72.z.record(import_mini72.z.string(), import_mini72.z.
|
|
21242
|
+
var KiroAgentSchema = import_mini72.z.looseObject({
|
|
21243
|
+
allowedTools: import_mini72.z.optional(import_mini72.z.array(import_mini72.z.string())),
|
|
21244
|
+
toolsSettings: import_mini72.z.optional(import_mini72.z.record(import_mini72.z.string(), import_mini72.z.unknown()))
|
|
21245
|
+
});
|
|
21246
|
+
var UnknownRecordSchema = import_mini72.z.record(import_mini72.z.string(), import_mini72.z.unknown());
|
|
21247
|
+
var KiroPermissions = class _KiroPermissions extends ToolPermissions {
|
|
21248
|
+
static getSettablePaths(_options = {}) {
|
|
21249
|
+
return {
|
|
21250
|
+
relativeDirPath: (0, import_node_path139.join)(".kiro", "agents"),
|
|
21251
|
+
relativeFilePath: "default.json"
|
|
21252
|
+
};
|
|
21253
|
+
}
|
|
21254
|
+
isDeletable() {
|
|
21255
|
+
return false;
|
|
21256
|
+
}
|
|
21257
|
+
static async fromFile({
|
|
21258
|
+
baseDir = process.cwd(),
|
|
21259
|
+
validate = true
|
|
21260
|
+
}) {
|
|
21261
|
+
const paths = this.getSettablePaths();
|
|
21262
|
+
const filePath = (0, import_node_path139.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
21263
|
+
const fileContent = await readFileContentOrNull(filePath) ?? JSON.stringify({}, null, 2);
|
|
21264
|
+
return new _KiroPermissions({
|
|
21265
|
+
baseDir,
|
|
21266
|
+
relativeDirPath: paths.relativeDirPath,
|
|
21267
|
+
relativeFilePath: paths.relativeFilePath,
|
|
21268
|
+
fileContent,
|
|
21269
|
+
validate
|
|
21270
|
+
});
|
|
21271
|
+
}
|
|
21272
|
+
static async fromRulesyncPermissions({
|
|
21273
|
+
baseDir = process.cwd(),
|
|
21274
|
+
rulesyncPermissions,
|
|
21275
|
+
validate = true,
|
|
21276
|
+
logger: logger5
|
|
21277
|
+
}) {
|
|
21278
|
+
const paths = this.getSettablePaths();
|
|
21279
|
+
const filePath = (0, import_node_path139.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
21280
|
+
const existingContent = await readFileContentOrNull(filePath) ?? JSON.stringify({}, null, 2);
|
|
21281
|
+
const parsedResult = KiroAgentSchema.safeParse(JSON.parse(existingContent));
|
|
21282
|
+
if (!parsedResult.success) {
|
|
21283
|
+
throw new Error(
|
|
21284
|
+
`Failed to parse existing Kiro agent config at ${filePath}: ${formatError(parsedResult.error)}`
|
|
21285
|
+
);
|
|
21286
|
+
}
|
|
21287
|
+
const config = rulesyncPermissions.getJson();
|
|
21288
|
+
const next = buildKiroPermissionsFromRulesync({ config, logger: logger5, existing: parsedResult.data });
|
|
21289
|
+
return new _KiroPermissions({
|
|
21290
|
+
baseDir,
|
|
21291
|
+
relativeDirPath: paths.relativeDirPath,
|
|
21292
|
+
relativeFilePath: paths.relativeFilePath,
|
|
21293
|
+
fileContent: JSON.stringify(next, null, 2),
|
|
21294
|
+
validate
|
|
21295
|
+
});
|
|
21296
|
+
}
|
|
21297
|
+
toRulesyncPermissions() {
|
|
21298
|
+
let parsed;
|
|
21299
|
+
try {
|
|
21300
|
+
parsed = KiroAgentSchema.parse(JSON.parse(this.getFileContent()));
|
|
21301
|
+
} catch (error) {
|
|
21302
|
+
throw new Error(
|
|
21303
|
+
`Failed to parse Kiro permissions content in ${(0, import_node_path139.join)(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${formatError(error)}`,
|
|
21304
|
+
{ cause: error }
|
|
21305
|
+
);
|
|
21306
|
+
}
|
|
21307
|
+
const permission = {};
|
|
21308
|
+
const toolsSettings = parsed.toolsSettings ?? {};
|
|
21309
|
+
const shellSettings = asRecord(toolsSettings.shell);
|
|
21310
|
+
const shellAllow = asStringArray(shellSettings.allowedCommands);
|
|
21311
|
+
const shellDeny = asStringArray(shellSettings.deniedCommands);
|
|
21312
|
+
if (shellAllow.length > 0 || shellDeny.length > 0) {
|
|
21313
|
+
permission.bash = {};
|
|
21314
|
+
for (const pattern of shellAllow) permission.bash[pattern] = "allow";
|
|
21315
|
+
for (const pattern of shellDeny) permission.bash[pattern] = "deny";
|
|
21316
|
+
}
|
|
21317
|
+
const readSettings = asRecord(toolsSettings.read);
|
|
21318
|
+
const readAllow = asStringArray(readSettings.allowedPaths);
|
|
21319
|
+
const readDeny = asStringArray(readSettings.deniedPaths);
|
|
21320
|
+
if (readAllow.length > 0 || readDeny.length > 0) {
|
|
21321
|
+
permission.read = {};
|
|
21322
|
+
for (const pattern of readAllow) permission.read[pattern] = "allow";
|
|
21323
|
+
for (const pattern of readDeny) permission.read[pattern] = "deny";
|
|
21324
|
+
}
|
|
21325
|
+
const writeSettings = asRecord(toolsSettings.write);
|
|
21326
|
+
const writeAllow = asStringArray(writeSettings.allowedPaths);
|
|
21327
|
+
const writeDeny = asStringArray(writeSettings.deniedPaths);
|
|
21328
|
+
if (writeAllow.length > 0 || writeDeny.length > 0) {
|
|
21329
|
+
permission.write = {};
|
|
21330
|
+
for (const pattern of writeAllow) permission.write[pattern] = "allow";
|
|
21331
|
+
for (const pattern of writeDeny) permission.write[pattern] = "deny";
|
|
21332
|
+
}
|
|
21333
|
+
const allowedTools = new Set(parsed.allowedTools ?? []);
|
|
21334
|
+
if (allowedTools.has("web_fetch")) {
|
|
21335
|
+
permission.webfetch = { "*": "allow" };
|
|
21336
|
+
}
|
|
21337
|
+
if (allowedTools.has("web_search")) {
|
|
21338
|
+
permission.websearch = { "*": "allow" };
|
|
21339
|
+
}
|
|
21340
|
+
return this.toRulesyncPermissionsDefault({
|
|
21341
|
+
fileContent: JSON.stringify({ permission }, null, 2)
|
|
21342
|
+
});
|
|
21343
|
+
}
|
|
21344
|
+
validate() {
|
|
21345
|
+
return { success: true, error: null };
|
|
21346
|
+
}
|
|
21347
|
+
static forDeletion({
|
|
21348
|
+
baseDir = process.cwd(),
|
|
21349
|
+
relativeDirPath,
|
|
21350
|
+
relativeFilePath
|
|
21351
|
+
}) {
|
|
21352
|
+
return new _KiroPermissions({
|
|
21353
|
+
baseDir,
|
|
21354
|
+
relativeDirPath,
|
|
21355
|
+
relativeFilePath,
|
|
21356
|
+
fileContent: JSON.stringify({}, null, 2),
|
|
21357
|
+
validate: false
|
|
21358
|
+
});
|
|
21359
|
+
}
|
|
21360
|
+
};
|
|
21361
|
+
function buildKiroPermissionsFromRulesync({
|
|
21362
|
+
config,
|
|
21363
|
+
logger: logger5,
|
|
21364
|
+
existing
|
|
21365
|
+
}) {
|
|
21366
|
+
const nextAllowedTools = new Set(existing.allowedTools ?? []);
|
|
21367
|
+
const nextToolsSettings = { ...asRecord(existing.toolsSettings) };
|
|
21368
|
+
const shell = {
|
|
21369
|
+
allowedCommands: [],
|
|
21370
|
+
deniedCommands: []
|
|
21371
|
+
};
|
|
21372
|
+
const read = {
|
|
21373
|
+
allowedPaths: [],
|
|
21374
|
+
deniedPaths: []
|
|
21375
|
+
};
|
|
21376
|
+
const write = {
|
|
21377
|
+
allowedPaths: [],
|
|
21378
|
+
deniedPaths: []
|
|
21379
|
+
};
|
|
21380
|
+
for (const [category, rules] of Object.entries(config.permission)) {
|
|
21381
|
+
for (const [pattern, action] of Object.entries(rules)) {
|
|
21382
|
+
if (action === "ask") {
|
|
21383
|
+
logger5?.warn(`Kiro permissions do not support "ask". Skipping ${category}:${pattern}`);
|
|
21384
|
+
continue;
|
|
21385
|
+
}
|
|
21386
|
+
if (category === "bash") {
|
|
21387
|
+
(action === "allow" ? shell.allowedCommands : shell.deniedCommands).push(pattern);
|
|
21388
|
+
} else if (category === "read") {
|
|
21389
|
+
(action === "allow" ? read.allowedPaths : read.deniedPaths).push(pattern);
|
|
21390
|
+
} else if (category === "edit" || category === "write") {
|
|
21391
|
+
(action === "allow" ? write.allowedPaths : write.deniedPaths).push(pattern);
|
|
21392
|
+
} else if (category === "webfetch" || category === "websearch") {
|
|
21393
|
+
if (pattern !== "*") {
|
|
21394
|
+
logger5?.warn(
|
|
21395
|
+
`Kiro ${category} supports only wildcard (*) via allowedTools. Skipping rule: ${pattern}`
|
|
21396
|
+
);
|
|
21397
|
+
continue;
|
|
21398
|
+
}
|
|
21399
|
+
if (action === "allow")
|
|
21400
|
+
nextAllowedTools.add(category === "webfetch" ? "web_fetch" : "web_search");
|
|
21401
|
+
} else {
|
|
21402
|
+
logger5?.warn(`Kiro permissions do not support category: ${category}. Skipping.`);
|
|
21403
|
+
}
|
|
21404
|
+
}
|
|
21405
|
+
}
|
|
21406
|
+
nextToolsSettings.shell = shell;
|
|
21407
|
+
nextToolsSettings.read = read;
|
|
21408
|
+
nextToolsSettings.write = write;
|
|
21409
|
+
return {
|
|
21410
|
+
...existing,
|
|
21411
|
+
allowedTools: [...nextAllowedTools].toSorted(),
|
|
21412
|
+
toolsSettings: nextToolsSettings
|
|
21413
|
+
};
|
|
21414
|
+
}
|
|
21415
|
+
function asRecord(value) {
|
|
21416
|
+
const result = UnknownRecordSchema.safeParse(value);
|
|
21417
|
+
return result.success ? result.data : {};
|
|
21418
|
+
}
|
|
21419
|
+
function asStringArray(value) {
|
|
21420
|
+
return Array.isArray(value) ? value.filter((item) => typeof item === "string") : [];
|
|
21421
|
+
}
|
|
21422
|
+
|
|
21423
|
+
// src/features/permissions/opencode-permissions.ts
|
|
21424
|
+
var import_node_path140 = require("path");
|
|
21425
|
+
var import_jsonc_parser5 = require("jsonc-parser");
|
|
21426
|
+
var import_mini73 = require("zod/mini");
|
|
21427
|
+
var OpencodePermissionSchema = import_mini73.z.union([
|
|
21428
|
+
import_mini73.z.enum(["allow", "ask", "deny"]),
|
|
21429
|
+
import_mini73.z.record(import_mini73.z.string(), import_mini73.z.enum(["allow", "ask", "deny"]))
|
|
21178
21430
|
]);
|
|
21179
|
-
var OpencodePermissionsConfigSchema =
|
|
21180
|
-
permission:
|
|
21431
|
+
var OpencodePermissionsConfigSchema = import_mini73.z.looseObject({
|
|
21432
|
+
permission: import_mini73.z.optional(import_mini73.z.record(import_mini73.z.string(), OpencodePermissionSchema))
|
|
21181
21433
|
});
|
|
21182
21434
|
var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
|
|
21183
21435
|
json;
|
|
@@ -21194,7 +21446,7 @@ var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
|
|
|
21194
21446
|
static getSettablePaths({
|
|
21195
21447
|
global = false
|
|
21196
21448
|
} = {}) {
|
|
21197
|
-
return global ? { relativeDirPath: (0,
|
|
21449
|
+
return global ? { relativeDirPath: (0, import_node_path140.join)(".config", "opencode"), relativeFilePath: "opencode.json" } : { relativeDirPath: ".", relativeFilePath: "opencode.json" };
|
|
21198
21450
|
}
|
|
21199
21451
|
static async fromFile({
|
|
21200
21452
|
baseDir = process.cwd(),
|
|
@@ -21202,9 +21454,9 @@ var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
|
|
|
21202
21454
|
global = false
|
|
21203
21455
|
}) {
|
|
21204
21456
|
const basePaths = _OpencodePermissions.getSettablePaths({ global });
|
|
21205
|
-
const jsonDir = (0,
|
|
21206
|
-
const jsoncPath = (0,
|
|
21207
|
-
const jsonPath = (0,
|
|
21457
|
+
const jsonDir = (0, import_node_path140.join)(baseDir, basePaths.relativeDirPath);
|
|
21458
|
+
const jsoncPath = (0, import_node_path140.join)(jsonDir, "opencode.jsonc");
|
|
21459
|
+
const jsonPath = (0, import_node_path140.join)(jsonDir, "opencode.json");
|
|
21208
21460
|
let fileContent = await readFileContentOrNull(jsoncPath);
|
|
21209
21461
|
let relativeFilePath = "opencode.jsonc";
|
|
21210
21462
|
if (!fileContent) {
|
|
@@ -21229,9 +21481,9 @@ var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
|
|
|
21229
21481
|
global = false
|
|
21230
21482
|
}) {
|
|
21231
21483
|
const basePaths = _OpencodePermissions.getSettablePaths({ global });
|
|
21232
|
-
const jsonDir = (0,
|
|
21233
|
-
const jsoncPath = (0,
|
|
21234
|
-
const jsonPath = (0,
|
|
21484
|
+
const jsonDir = (0, import_node_path140.join)(baseDir, basePaths.relativeDirPath);
|
|
21485
|
+
const jsoncPath = (0, import_node_path140.join)(jsonDir, "opencode.jsonc");
|
|
21486
|
+
const jsonPath = (0, import_node_path140.join)(jsonDir, "opencode.json");
|
|
21235
21487
|
let fileContent = await readFileContentOrNull(jsoncPath);
|
|
21236
21488
|
let relativeFilePath = "opencode.jsonc";
|
|
21237
21489
|
if (!fileContent) {
|
|
@@ -21305,9 +21557,10 @@ var permissionsProcessorToolTargetTuple = [
|
|
|
21305
21557
|
"claudecode",
|
|
21306
21558
|
"codexcli",
|
|
21307
21559
|
"geminicli",
|
|
21560
|
+
"kiro",
|
|
21308
21561
|
"opencode"
|
|
21309
21562
|
];
|
|
21310
|
-
var PermissionsProcessorToolTargetSchema =
|
|
21563
|
+
var PermissionsProcessorToolTargetSchema = import_mini74.z.enum(permissionsProcessorToolTargetTuple);
|
|
21311
21564
|
var toolPermissionsFactories = /* @__PURE__ */ new Map([
|
|
21312
21565
|
[
|
|
21313
21566
|
"claudecode",
|
|
@@ -21315,7 +21568,7 @@ var toolPermissionsFactories = /* @__PURE__ */ new Map([
|
|
|
21315
21568
|
class: ClaudecodePermissions,
|
|
21316
21569
|
meta: {
|
|
21317
21570
|
supportsProject: true,
|
|
21318
|
-
supportsGlobal:
|
|
21571
|
+
supportsGlobal: true,
|
|
21319
21572
|
supportsImport: true
|
|
21320
21573
|
}
|
|
21321
21574
|
}
|
|
@@ -21342,6 +21595,17 @@ var toolPermissionsFactories = /* @__PURE__ */ new Map([
|
|
|
21342
21595
|
}
|
|
21343
21596
|
}
|
|
21344
21597
|
],
|
|
21598
|
+
[
|
|
21599
|
+
"kiro",
|
|
21600
|
+
{
|
|
21601
|
+
class: KiroPermissions,
|
|
21602
|
+
meta: {
|
|
21603
|
+
supportsProject: true,
|
|
21604
|
+
supportsGlobal: false,
|
|
21605
|
+
supportsImport: true
|
|
21606
|
+
}
|
|
21607
|
+
}
|
|
21608
|
+
],
|
|
21345
21609
|
[
|
|
21346
21610
|
"opencode",
|
|
21347
21611
|
{
|
|
@@ -21437,7 +21701,14 @@ var PermissionsProcessor = class extends FeatureProcessor {
|
|
|
21437
21701
|
logger: this.logger,
|
|
21438
21702
|
global: this.global
|
|
21439
21703
|
});
|
|
21440
|
-
|
|
21704
|
+
if (this.toolTarget !== "codexcli") {
|
|
21705
|
+
return [toolPermissions];
|
|
21706
|
+
}
|
|
21707
|
+
const bashRulesFile = createCodexcliBashRulesFile({
|
|
21708
|
+
baseDir: this.baseDir,
|
|
21709
|
+
config: rulesyncPermissions.getJson()
|
|
21710
|
+
});
|
|
21711
|
+
return [toolPermissions, bashRulesFile];
|
|
21441
21712
|
}
|
|
21442
21713
|
async convertToolFilesToRulesyncFiles(toolFiles) {
|
|
21443
21714
|
const permissions = toolFiles.filter((f) => f instanceof ToolPermissions);
|
|
@@ -21524,7 +21795,7 @@ function warnUnsupportedTargets(params) {
|
|
|
21524
21795
|
}
|
|
21525
21796
|
}
|
|
21526
21797
|
async function checkRulesyncDirExists(params) {
|
|
21527
|
-
return fileExists((0,
|
|
21798
|
+
return fileExists((0, import_node_path141.join)(params.baseDir, RULESYNC_RELATIVE_DIR_PATH));
|
|
21528
21799
|
}
|
|
21529
21800
|
async function generate(params) {
|
|
21530
21801
|
const { config, logger: logger5 } = params;
|
|
@@ -21994,7 +22265,7 @@ async function generateCommand(logger5, options) {
|
|
|
21994
22265
|
}
|
|
21995
22266
|
|
|
21996
22267
|
// src/cli/commands/gitignore.ts
|
|
21997
|
-
var
|
|
22268
|
+
var import_node_path142 = require("path");
|
|
21998
22269
|
|
|
21999
22270
|
// src/cli/commands/gitignore-entries.ts
|
|
22000
22271
|
var normalizeGitignoreEntryTargets = (target) => {
|
|
@@ -22338,7 +22609,7 @@ var removeExistingRulesyncEntries = (content) => {
|
|
|
22338
22609
|
return result;
|
|
22339
22610
|
};
|
|
22340
22611
|
var gitignoreCommand = async (logger5, options) => {
|
|
22341
|
-
const gitignorePath = (0,
|
|
22612
|
+
const gitignorePath = (0, import_node_path142.join)(process.cwd(), ".gitignore");
|
|
22342
22613
|
let gitignoreContent = "";
|
|
22343
22614
|
if (await fileExists(gitignorePath)) {
|
|
22344
22615
|
gitignoreContent = await readFileContent(gitignorePath);
|
|
@@ -22705,7 +22976,7 @@ async function importCommand(logger5, options) {
|
|
|
22705
22976
|
}
|
|
22706
22977
|
|
|
22707
22978
|
// src/lib/init.ts
|
|
22708
|
-
var
|
|
22979
|
+
var import_node_path143 = require("path");
|
|
22709
22980
|
async function init() {
|
|
22710
22981
|
const sampleFiles = await createSampleFiles();
|
|
22711
22982
|
const configFile = await createConfigFile();
|
|
@@ -22898,27 +23169,27 @@ Keep the summary concise and ready to reuse in future tasks.`
|
|
|
22898
23169
|
await ensureDir(subagentPaths.relativeDirPath);
|
|
22899
23170
|
await ensureDir(skillPaths.relativeDirPath);
|
|
22900
23171
|
await ensureDir(ignorePaths.recommended.relativeDirPath);
|
|
22901
|
-
const ruleFilepath = (0,
|
|
23172
|
+
const ruleFilepath = (0, import_node_path143.join)(rulePaths.recommended.relativeDirPath, sampleRuleFile.filename);
|
|
22902
23173
|
results.push(await writeIfNotExists(ruleFilepath, sampleRuleFile.content));
|
|
22903
|
-
const mcpFilepath = (0,
|
|
23174
|
+
const mcpFilepath = (0, import_node_path143.join)(
|
|
22904
23175
|
mcpPaths.recommended.relativeDirPath,
|
|
22905
23176
|
mcpPaths.recommended.relativeFilePath
|
|
22906
23177
|
);
|
|
22907
23178
|
results.push(await writeIfNotExists(mcpFilepath, sampleMcpFile.content));
|
|
22908
|
-
const commandFilepath = (0,
|
|
23179
|
+
const commandFilepath = (0, import_node_path143.join)(commandPaths.relativeDirPath, sampleCommandFile.filename);
|
|
22909
23180
|
results.push(await writeIfNotExists(commandFilepath, sampleCommandFile.content));
|
|
22910
|
-
const subagentFilepath = (0,
|
|
23181
|
+
const subagentFilepath = (0, import_node_path143.join)(subagentPaths.relativeDirPath, sampleSubagentFile.filename);
|
|
22911
23182
|
results.push(await writeIfNotExists(subagentFilepath, sampleSubagentFile.content));
|
|
22912
|
-
const skillDirPath = (0,
|
|
23183
|
+
const skillDirPath = (0, import_node_path143.join)(skillPaths.relativeDirPath, sampleSkillFile.dirName);
|
|
22913
23184
|
await ensureDir(skillDirPath);
|
|
22914
|
-
const skillFilepath = (0,
|
|
23185
|
+
const skillFilepath = (0, import_node_path143.join)(skillDirPath, SKILL_FILE_NAME);
|
|
22915
23186
|
results.push(await writeIfNotExists(skillFilepath, sampleSkillFile.content));
|
|
22916
|
-
const ignoreFilepath = (0,
|
|
23187
|
+
const ignoreFilepath = (0, import_node_path143.join)(
|
|
22917
23188
|
ignorePaths.recommended.relativeDirPath,
|
|
22918
23189
|
ignorePaths.recommended.relativeFilePath
|
|
22919
23190
|
);
|
|
22920
23191
|
results.push(await writeIfNotExists(ignoreFilepath, sampleIgnoreFile.content));
|
|
22921
|
-
const hooksFilepath = (0,
|
|
23192
|
+
const hooksFilepath = (0, import_node_path143.join)(hooksPaths.relativeDirPath, hooksPaths.relativeFilePath);
|
|
22922
23193
|
results.push(await writeIfNotExists(hooksFilepath, sampleHooksFile.content));
|
|
22923
23194
|
return results;
|
|
22924
23195
|
}
|
|
@@ -22966,12 +23237,12 @@ async function initCommand(logger5) {
|
|
|
22966
23237
|
}
|
|
22967
23238
|
|
|
22968
23239
|
// src/lib/sources.ts
|
|
22969
|
-
var
|
|
23240
|
+
var import_node_path146 = require("path");
|
|
22970
23241
|
var import_promise2 = require("es-toolkit/promise");
|
|
22971
23242
|
|
|
22972
23243
|
// src/lib/git-client.ts
|
|
22973
23244
|
var import_node_child_process = require("child_process");
|
|
22974
|
-
var
|
|
23245
|
+
var import_node_path144 = require("path");
|
|
22975
23246
|
var import_node_util2 = require("util");
|
|
22976
23247
|
var execFileAsync = (0, import_node_util2.promisify)(import_node_child_process.execFile);
|
|
22977
23248
|
var GIT_TIMEOUT_MS = 6e4;
|
|
@@ -23059,7 +23330,7 @@ async function fetchSkillFiles(params) {
|
|
|
23059
23330
|
const { url, ref, skillsPath, logger: logger5 } = params;
|
|
23060
23331
|
validateGitUrl(url, { logger: logger5 });
|
|
23061
23332
|
validateRef(ref);
|
|
23062
|
-
if (skillsPath.split(/[/\\]/).includes("..") || (0,
|
|
23333
|
+
if (skillsPath.split(/[/\\]/).includes("..") || (0, import_node_path144.isAbsolute)(skillsPath)) {
|
|
23063
23334
|
throw new GitClientError(
|
|
23064
23335
|
`Invalid skillsPath "${skillsPath}": must be a relative path without ".."`
|
|
23065
23336
|
);
|
|
@@ -23093,7 +23364,7 @@ async function fetchSkillFiles(params) {
|
|
|
23093
23364
|
timeout: GIT_TIMEOUT_MS
|
|
23094
23365
|
});
|
|
23095
23366
|
await execFileAsync("git", ["-C", tmpDir, "checkout"], { timeout: GIT_TIMEOUT_MS });
|
|
23096
|
-
const skillsDir = (0,
|
|
23367
|
+
const skillsDir = (0, import_node_path144.join)(tmpDir, skillsPath);
|
|
23097
23368
|
if (!await directoryExists(skillsDir)) return [];
|
|
23098
23369
|
return await walkDirectory(skillsDir, skillsDir, 0, { totalFiles: 0, totalSize: 0 }, logger5);
|
|
23099
23370
|
} catch (error) {
|
|
@@ -23115,7 +23386,7 @@ async function walkDirectory(dir, baseDir, depth = 0, ctx = { totalFiles: 0, tot
|
|
|
23115
23386
|
const results = [];
|
|
23116
23387
|
for (const name of await listDirectoryFiles(dir)) {
|
|
23117
23388
|
if (name === ".git") continue;
|
|
23118
|
-
const fullPath = (0,
|
|
23389
|
+
const fullPath = (0, import_node_path144.join)(dir, name);
|
|
23119
23390
|
if (await isSymlink(fullPath)) {
|
|
23120
23391
|
logger5?.warn(`Skipping symlink "${fullPath}".`);
|
|
23121
23392
|
continue;
|
|
@@ -23143,7 +23414,7 @@ async function walkDirectory(dir, baseDir, depth = 0, ctx = { totalFiles: 0, tot
|
|
|
23143
23414
|
);
|
|
23144
23415
|
}
|
|
23145
23416
|
const content = await readFileContent(fullPath);
|
|
23146
|
-
results.push({ relativePath: (0,
|
|
23417
|
+
results.push({ relativePath: (0, import_node_path144.relative)(baseDir, fullPath), content, size });
|
|
23147
23418
|
}
|
|
23148
23419
|
}
|
|
23149
23420
|
return results;
|
|
@@ -23151,28 +23422,28 @@ async function walkDirectory(dir, baseDir, depth = 0, ctx = { totalFiles: 0, tot
|
|
|
23151
23422
|
|
|
23152
23423
|
// src/lib/sources-lock.ts
|
|
23153
23424
|
var import_node_crypto = require("crypto");
|
|
23154
|
-
var
|
|
23155
|
-
var
|
|
23425
|
+
var import_node_path145 = require("path");
|
|
23426
|
+
var import_mini75 = require("zod/mini");
|
|
23156
23427
|
var LOCKFILE_VERSION = 1;
|
|
23157
|
-
var LockedSkillSchema =
|
|
23158
|
-
integrity:
|
|
23428
|
+
var LockedSkillSchema = import_mini75.z.object({
|
|
23429
|
+
integrity: import_mini75.z.string()
|
|
23159
23430
|
});
|
|
23160
|
-
var LockedSourceSchema =
|
|
23161
|
-
requestedRef: (0,
|
|
23162
|
-
resolvedRef:
|
|
23163
|
-
resolvedAt: (0,
|
|
23164
|
-
skills:
|
|
23431
|
+
var LockedSourceSchema = import_mini75.z.object({
|
|
23432
|
+
requestedRef: (0, import_mini75.optional)(import_mini75.z.string()),
|
|
23433
|
+
resolvedRef: import_mini75.z.string().check((0, import_mini75.refine)((v) => /^[0-9a-f]{40}$/.test(v), "resolvedRef must be a 40-character hex SHA")),
|
|
23434
|
+
resolvedAt: (0, import_mini75.optional)(import_mini75.z.string()),
|
|
23435
|
+
skills: import_mini75.z.record(import_mini75.z.string(), LockedSkillSchema)
|
|
23165
23436
|
});
|
|
23166
|
-
var SourcesLockSchema =
|
|
23167
|
-
lockfileVersion:
|
|
23168
|
-
sources:
|
|
23437
|
+
var SourcesLockSchema = import_mini75.z.object({
|
|
23438
|
+
lockfileVersion: import_mini75.z.number(),
|
|
23439
|
+
sources: import_mini75.z.record(import_mini75.z.string(), LockedSourceSchema)
|
|
23169
23440
|
});
|
|
23170
|
-
var LegacyLockedSourceSchema =
|
|
23171
|
-
resolvedRef:
|
|
23172
|
-
skills:
|
|
23441
|
+
var LegacyLockedSourceSchema = import_mini75.z.object({
|
|
23442
|
+
resolvedRef: import_mini75.z.string(),
|
|
23443
|
+
skills: import_mini75.z.array(import_mini75.z.string())
|
|
23173
23444
|
});
|
|
23174
|
-
var LegacySourcesLockSchema =
|
|
23175
|
-
sources:
|
|
23445
|
+
var LegacySourcesLockSchema = import_mini75.z.object({
|
|
23446
|
+
sources: import_mini75.z.record(import_mini75.z.string(), LegacyLockedSourceSchema)
|
|
23176
23447
|
});
|
|
23177
23448
|
function migrateLegacyLock(params) {
|
|
23178
23449
|
const { legacy, logger: logger5 } = params;
|
|
@@ -23197,7 +23468,7 @@ function createEmptyLock() {
|
|
|
23197
23468
|
}
|
|
23198
23469
|
async function readLockFile(params) {
|
|
23199
23470
|
const { logger: logger5 } = params;
|
|
23200
|
-
const lockPath = (0,
|
|
23471
|
+
const lockPath = (0, import_node_path145.join)(params.baseDir, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH);
|
|
23201
23472
|
if (!await fileExists(lockPath)) {
|
|
23202
23473
|
logger5.debug("No sources lockfile found, starting fresh.");
|
|
23203
23474
|
return createEmptyLock();
|
|
@@ -23226,7 +23497,7 @@ async function readLockFile(params) {
|
|
|
23226
23497
|
}
|
|
23227
23498
|
async function writeLockFile(params) {
|
|
23228
23499
|
const { logger: logger5 } = params;
|
|
23229
|
-
const lockPath = (0,
|
|
23500
|
+
const lockPath = (0, import_node_path145.join)(params.baseDir, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH);
|
|
23230
23501
|
const content = JSON.stringify(params.lock, null, 2) + "\n";
|
|
23231
23502
|
await writeFileContent(lockPath, content);
|
|
23232
23503
|
logger5.debug(`Wrote sources lockfile to ${lockPath}`);
|
|
@@ -23400,7 +23671,7 @@ function logGitClientHints(params) {
|
|
|
23400
23671
|
async function checkLockedSkillsExist(curatedDir, skillNames) {
|
|
23401
23672
|
if (skillNames.length === 0) return true;
|
|
23402
23673
|
for (const name of skillNames) {
|
|
23403
|
-
if (!await directoryExists((0,
|
|
23674
|
+
if (!await directoryExists((0, import_node_path146.join)(curatedDir, name))) {
|
|
23404
23675
|
return false;
|
|
23405
23676
|
}
|
|
23406
23677
|
}
|
|
@@ -23408,10 +23679,10 @@ async function checkLockedSkillsExist(curatedDir, skillNames) {
|
|
|
23408
23679
|
}
|
|
23409
23680
|
async function cleanPreviousCuratedSkills(params) {
|
|
23410
23681
|
const { curatedDir, lockedSkillNames, logger: logger5 } = params;
|
|
23411
|
-
const resolvedCuratedDir = (0,
|
|
23682
|
+
const resolvedCuratedDir = (0, import_node_path146.resolve)(curatedDir);
|
|
23412
23683
|
for (const prevSkill of lockedSkillNames) {
|
|
23413
|
-
const prevDir = (0,
|
|
23414
|
-
if (!(0,
|
|
23684
|
+
const prevDir = (0, import_node_path146.join)(curatedDir, prevSkill);
|
|
23685
|
+
if (!(0, import_node_path146.resolve)(prevDir).startsWith(resolvedCuratedDir + import_node_path146.sep)) {
|
|
23415
23686
|
logger5.warn(
|
|
23416
23687
|
`Skipping removal of "${prevSkill}": resolved path is outside the curated directory.`
|
|
23417
23688
|
);
|
|
@@ -23450,9 +23721,9 @@ async function writeSkillAndComputeIntegrity(params) {
|
|
|
23450
23721
|
for (const file of files) {
|
|
23451
23722
|
checkPathTraversal({
|
|
23452
23723
|
relativePath: file.relativePath,
|
|
23453
|
-
intendedRootDir: (0,
|
|
23724
|
+
intendedRootDir: (0, import_node_path146.join)(curatedDir, skillName)
|
|
23454
23725
|
});
|
|
23455
|
-
await writeFileContent((0,
|
|
23726
|
+
await writeFileContent((0, import_node_path146.join)(curatedDir, skillName, file.relativePath), file.content);
|
|
23456
23727
|
written.push({ path: file.relativePath, content: file.content });
|
|
23457
23728
|
}
|
|
23458
23729
|
const integrity = computeSkillIntegrity(written);
|
|
@@ -23529,7 +23800,7 @@ async function fetchSource(params) {
|
|
|
23529
23800
|
ref = resolvedSha;
|
|
23530
23801
|
logger5.debug(`Resolved ${sourceKey} ref "${requestedRef}" to SHA: ${resolvedSha}`);
|
|
23531
23802
|
}
|
|
23532
|
-
const curatedDir = (0,
|
|
23803
|
+
const curatedDir = (0, import_node_path146.join)(baseDir, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH);
|
|
23533
23804
|
if (locked && resolvedSha === locked.resolvedRef && !updateSources) {
|
|
23534
23805
|
const allExist = await checkLockedSkillsExist(curatedDir, lockedSkillNames);
|
|
23535
23806
|
if (allExist) {
|
|
@@ -23654,7 +23925,7 @@ async function fetchSourceViaGit(params) {
|
|
|
23654
23925
|
requestedRef = def.ref;
|
|
23655
23926
|
resolvedSha = def.sha;
|
|
23656
23927
|
}
|
|
23657
|
-
const curatedDir = (0,
|
|
23928
|
+
const curatedDir = (0, import_node_path146.join)(baseDir, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH);
|
|
23658
23929
|
if (locked && resolvedSha === locked.resolvedRef && !updateSources) {
|
|
23659
23930
|
if (await checkLockedSkillsExist(curatedDir, lockedSkillNames)) {
|
|
23660
23931
|
return { skillCount: 0, fetchedSkillNames: lockedSkillNames, updatedLock: lock };
|
|
@@ -23770,11 +24041,11 @@ async function installCommand(logger5, options) {
|
|
|
23770
24041
|
var import_fastmcp = require("fastmcp");
|
|
23771
24042
|
|
|
23772
24043
|
// src/mcp/tools.ts
|
|
23773
|
-
var
|
|
24044
|
+
var import_mini84 = require("zod/mini");
|
|
23774
24045
|
|
|
23775
24046
|
// src/mcp/commands.ts
|
|
23776
|
-
var
|
|
23777
|
-
var
|
|
24047
|
+
var import_node_path147 = require("path");
|
|
24048
|
+
var import_mini76 = require("zod/mini");
|
|
23778
24049
|
|
|
23779
24050
|
// src/utils/logger.ts
|
|
23780
24051
|
var BaseLogger = class {
|
|
@@ -23925,7 +24196,7 @@ var logger = new ConsoleLogger({ verbose: false, silent: true });
|
|
|
23925
24196
|
var maxCommandSizeBytes = 1024 * 1024;
|
|
23926
24197
|
var maxCommandsCount = 1e3;
|
|
23927
24198
|
async function listCommands() {
|
|
23928
|
-
const commandsDir = (0,
|
|
24199
|
+
const commandsDir = (0, import_node_path147.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
23929
24200
|
try {
|
|
23930
24201
|
const files = await listDirectoryFiles(commandsDir);
|
|
23931
24202
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -23941,7 +24212,7 @@ async function listCommands() {
|
|
|
23941
24212
|
});
|
|
23942
24213
|
const frontmatter = command.getFrontmatter();
|
|
23943
24214
|
return {
|
|
23944
|
-
relativePathFromCwd: (0,
|
|
24215
|
+
relativePathFromCwd: (0, import_node_path147.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, file),
|
|
23945
24216
|
frontmatter
|
|
23946
24217
|
};
|
|
23947
24218
|
} catch (error) {
|
|
@@ -23963,13 +24234,13 @@ async function getCommand({ relativePathFromCwd }) {
|
|
|
23963
24234
|
relativePath: relativePathFromCwd,
|
|
23964
24235
|
intendedRootDir: process.cwd()
|
|
23965
24236
|
});
|
|
23966
|
-
const filename = (0,
|
|
24237
|
+
const filename = (0, import_node_path147.basename)(relativePathFromCwd);
|
|
23967
24238
|
try {
|
|
23968
24239
|
const command = await RulesyncCommand.fromFile({
|
|
23969
24240
|
relativeFilePath: filename
|
|
23970
24241
|
});
|
|
23971
24242
|
return {
|
|
23972
|
-
relativePathFromCwd: (0,
|
|
24243
|
+
relativePathFromCwd: (0, import_node_path147.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
23973
24244
|
frontmatter: command.getFrontmatter(),
|
|
23974
24245
|
body: command.getBody()
|
|
23975
24246
|
};
|
|
@@ -23988,7 +24259,7 @@ async function putCommand({
|
|
|
23988
24259
|
relativePath: relativePathFromCwd,
|
|
23989
24260
|
intendedRootDir: process.cwd()
|
|
23990
24261
|
});
|
|
23991
|
-
const filename = (0,
|
|
24262
|
+
const filename = (0, import_node_path147.basename)(relativePathFromCwd);
|
|
23992
24263
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
23993
24264
|
if (estimatedSize > maxCommandSizeBytes) {
|
|
23994
24265
|
throw new Error(
|
|
@@ -23998,7 +24269,7 @@ async function putCommand({
|
|
|
23998
24269
|
try {
|
|
23999
24270
|
const existingCommands = await listCommands();
|
|
24000
24271
|
const isUpdate = existingCommands.some(
|
|
24001
|
-
(command2) => command2.relativePathFromCwd === (0,
|
|
24272
|
+
(command2) => command2.relativePathFromCwd === (0, import_node_path147.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
24002
24273
|
);
|
|
24003
24274
|
if (!isUpdate && existingCommands.length >= maxCommandsCount) {
|
|
24004
24275
|
throw new Error(
|
|
@@ -24015,11 +24286,11 @@ async function putCommand({
|
|
|
24015
24286
|
fileContent,
|
|
24016
24287
|
validate: true
|
|
24017
24288
|
});
|
|
24018
|
-
const commandsDir = (0,
|
|
24289
|
+
const commandsDir = (0, import_node_path147.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
24019
24290
|
await ensureDir(commandsDir);
|
|
24020
24291
|
await writeFileContent(command.getFilePath(), command.getFileContent());
|
|
24021
24292
|
return {
|
|
24022
|
-
relativePathFromCwd: (0,
|
|
24293
|
+
relativePathFromCwd: (0, import_node_path147.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
24023
24294
|
frontmatter: command.getFrontmatter(),
|
|
24024
24295
|
body: command.getBody()
|
|
24025
24296
|
};
|
|
@@ -24034,12 +24305,12 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
24034
24305
|
relativePath: relativePathFromCwd,
|
|
24035
24306
|
intendedRootDir: process.cwd()
|
|
24036
24307
|
});
|
|
24037
|
-
const filename = (0,
|
|
24038
|
-
const fullPath = (0,
|
|
24308
|
+
const filename = (0, import_node_path147.basename)(relativePathFromCwd);
|
|
24309
|
+
const fullPath = (0, import_node_path147.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename);
|
|
24039
24310
|
try {
|
|
24040
24311
|
await removeFile(fullPath);
|
|
24041
24312
|
return {
|
|
24042
|
-
relativePathFromCwd: (0,
|
|
24313
|
+
relativePathFromCwd: (0, import_node_path147.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
24043
24314
|
};
|
|
24044
24315
|
} catch (error) {
|
|
24045
24316
|
throw new Error(`Failed to delete command file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -24048,23 +24319,23 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
24048
24319
|
}
|
|
24049
24320
|
}
|
|
24050
24321
|
var commandToolSchemas = {
|
|
24051
|
-
listCommands:
|
|
24052
|
-
getCommand:
|
|
24053
|
-
relativePathFromCwd:
|
|
24322
|
+
listCommands: import_mini76.z.object({}),
|
|
24323
|
+
getCommand: import_mini76.z.object({
|
|
24324
|
+
relativePathFromCwd: import_mini76.z.string()
|
|
24054
24325
|
}),
|
|
24055
|
-
putCommand:
|
|
24056
|
-
relativePathFromCwd:
|
|
24326
|
+
putCommand: import_mini76.z.object({
|
|
24327
|
+
relativePathFromCwd: import_mini76.z.string(),
|
|
24057
24328
|
frontmatter: RulesyncCommandFrontmatterSchema,
|
|
24058
|
-
body:
|
|
24329
|
+
body: import_mini76.z.string()
|
|
24059
24330
|
}),
|
|
24060
|
-
deleteCommand:
|
|
24061
|
-
relativePathFromCwd:
|
|
24331
|
+
deleteCommand: import_mini76.z.object({
|
|
24332
|
+
relativePathFromCwd: import_mini76.z.string()
|
|
24062
24333
|
})
|
|
24063
24334
|
};
|
|
24064
24335
|
var commandTools = {
|
|
24065
24336
|
listCommands: {
|
|
24066
24337
|
name: "listCommands",
|
|
24067
|
-
description: `List all commands from ${(0,
|
|
24338
|
+
description: `List all commands from ${(0, import_node_path147.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
24068
24339
|
parameters: commandToolSchemas.listCommands,
|
|
24069
24340
|
execute: async () => {
|
|
24070
24341
|
const commands = await listCommands();
|
|
@@ -24106,15 +24377,15 @@ var commandTools = {
|
|
|
24106
24377
|
};
|
|
24107
24378
|
|
|
24108
24379
|
// src/mcp/generate.ts
|
|
24109
|
-
var
|
|
24110
|
-
var generateOptionsSchema =
|
|
24111
|
-
targets:
|
|
24112
|
-
features:
|
|
24113
|
-
delete:
|
|
24114
|
-
global:
|
|
24115
|
-
simulateCommands:
|
|
24116
|
-
simulateSubagents:
|
|
24117
|
-
simulateSkills:
|
|
24380
|
+
var import_mini77 = require("zod/mini");
|
|
24381
|
+
var generateOptionsSchema = import_mini77.z.object({
|
|
24382
|
+
targets: import_mini77.z.optional(import_mini77.z.array(import_mini77.z.string())),
|
|
24383
|
+
features: import_mini77.z.optional(import_mini77.z.array(import_mini77.z.string())),
|
|
24384
|
+
delete: import_mini77.z.optional(import_mini77.z.boolean()),
|
|
24385
|
+
global: import_mini77.z.optional(import_mini77.z.boolean()),
|
|
24386
|
+
simulateCommands: import_mini77.z.optional(import_mini77.z.boolean()),
|
|
24387
|
+
simulateSubagents: import_mini77.z.optional(import_mini77.z.boolean()),
|
|
24388
|
+
simulateSkills: import_mini77.z.optional(import_mini77.z.boolean())
|
|
24118
24389
|
});
|
|
24119
24390
|
async function executeGenerate(options = {}) {
|
|
24120
24391
|
try {
|
|
@@ -24193,11 +24464,11 @@ var generateTools = {
|
|
|
24193
24464
|
};
|
|
24194
24465
|
|
|
24195
24466
|
// src/mcp/ignore.ts
|
|
24196
|
-
var
|
|
24197
|
-
var
|
|
24467
|
+
var import_node_path148 = require("path");
|
|
24468
|
+
var import_mini78 = require("zod/mini");
|
|
24198
24469
|
var maxIgnoreFileSizeBytes = 100 * 1024;
|
|
24199
24470
|
async function getIgnoreFile() {
|
|
24200
|
-
const ignoreFilePath = (0,
|
|
24471
|
+
const ignoreFilePath = (0, import_node_path148.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
24201
24472
|
try {
|
|
24202
24473
|
const content = await readFileContent(ignoreFilePath);
|
|
24203
24474
|
return {
|
|
@@ -24214,7 +24485,7 @@ async function getIgnoreFile() {
|
|
|
24214
24485
|
}
|
|
24215
24486
|
}
|
|
24216
24487
|
async function putIgnoreFile({ content }) {
|
|
24217
|
-
const ignoreFilePath = (0,
|
|
24488
|
+
const ignoreFilePath = (0, import_node_path148.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
24218
24489
|
const contentSizeBytes = Buffer.byteLength(content, "utf8");
|
|
24219
24490
|
if (contentSizeBytes > maxIgnoreFileSizeBytes) {
|
|
24220
24491
|
throw new Error(
|
|
@@ -24238,8 +24509,8 @@ async function putIgnoreFile({ content }) {
|
|
|
24238
24509
|
}
|
|
24239
24510
|
}
|
|
24240
24511
|
async function deleteIgnoreFile() {
|
|
24241
|
-
const aiignorePath = (0,
|
|
24242
|
-
const legacyIgnorePath = (0,
|
|
24512
|
+
const aiignorePath = (0, import_node_path148.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
24513
|
+
const legacyIgnorePath = (0, import_node_path148.join)(process.cwd(), RULESYNC_IGNORE_RELATIVE_FILE_PATH);
|
|
24243
24514
|
try {
|
|
24244
24515
|
await Promise.all([removeFile(aiignorePath), removeFile(legacyIgnorePath)]);
|
|
24245
24516
|
return {
|
|
@@ -24257,11 +24528,11 @@ async function deleteIgnoreFile() {
|
|
|
24257
24528
|
}
|
|
24258
24529
|
}
|
|
24259
24530
|
var ignoreToolSchemas = {
|
|
24260
|
-
getIgnoreFile:
|
|
24261
|
-
putIgnoreFile:
|
|
24262
|
-
content:
|
|
24531
|
+
getIgnoreFile: import_mini78.z.object({}),
|
|
24532
|
+
putIgnoreFile: import_mini78.z.object({
|
|
24533
|
+
content: import_mini78.z.string()
|
|
24263
24534
|
}),
|
|
24264
|
-
deleteIgnoreFile:
|
|
24535
|
+
deleteIgnoreFile: import_mini78.z.object({})
|
|
24265
24536
|
};
|
|
24266
24537
|
var ignoreTools = {
|
|
24267
24538
|
getIgnoreFile: {
|
|
@@ -24294,11 +24565,11 @@ var ignoreTools = {
|
|
|
24294
24565
|
};
|
|
24295
24566
|
|
|
24296
24567
|
// src/mcp/import.ts
|
|
24297
|
-
var
|
|
24298
|
-
var importOptionsSchema =
|
|
24299
|
-
target:
|
|
24300
|
-
features:
|
|
24301
|
-
global:
|
|
24568
|
+
var import_mini79 = require("zod/mini");
|
|
24569
|
+
var importOptionsSchema = import_mini79.z.object({
|
|
24570
|
+
target: import_mini79.z.string(),
|
|
24571
|
+
features: import_mini79.z.optional(import_mini79.z.array(import_mini79.z.string())),
|
|
24572
|
+
global: import_mini79.z.optional(import_mini79.z.boolean())
|
|
24302
24573
|
});
|
|
24303
24574
|
async function executeImport(options) {
|
|
24304
24575
|
try {
|
|
@@ -24369,15 +24640,15 @@ var importTools = {
|
|
|
24369
24640
|
};
|
|
24370
24641
|
|
|
24371
24642
|
// src/mcp/mcp.ts
|
|
24372
|
-
var
|
|
24373
|
-
var
|
|
24643
|
+
var import_node_path149 = require("path");
|
|
24644
|
+
var import_mini80 = require("zod/mini");
|
|
24374
24645
|
var maxMcpSizeBytes = 1024 * 1024;
|
|
24375
24646
|
async function getMcpFile() {
|
|
24376
24647
|
try {
|
|
24377
24648
|
const rulesyncMcp = await RulesyncMcp.fromFile({
|
|
24378
24649
|
validate: true
|
|
24379
24650
|
});
|
|
24380
|
-
const relativePathFromCwd = (0,
|
|
24651
|
+
const relativePathFromCwd = (0, import_node_path149.join)(
|
|
24381
24652
|
rulesyncMcp.getRelativeDirPath(),
|
|
24382
24653
|
rulesyncMcp.getRelativeFilePath()
|
|
24383
24654
|
);
|
|
@@ -24415,7 +24686,7 @@ async function putMcpFile({ content }) {
|
|
|
24415
24686
|
const paths = RulesyncMcp.getSettablePaths();
|
|
24416
24687
|
const relativeDirPath = paths.recommended.relativeDirPath;
|
|
24417
24688
|
const relativeFilePath = paths.recommended.relativeFilePath;
|
|
24418
|
-
const fullPath = (0,
|
|
24689
|
+
const fullPath = (0, import_node_path149.join)(baseDir, relativeDirPath, relativeFilePath);
|
|
24419
24690
|
const rulesyncMcp = new RulesyncMcp({
|
|
24420
24691
|
baseDir,
|
|
24421
24692
|
relativeDirPath,
|
|
@@ -24423,9 +24694,9 @@ async function putMcpFile({ content }) {
|
|
|
24423
24694
|
fileContent: content,
|
|
24424
24695
|
validate: true
|
|
24425
24696
|
});
|
|
24426
|
-
await ensureDir((0,
|
|
24697
|
+
await ensureDir((0, import_node_path149.join)(baseDir, relativeDirPath));
|
|
24427
24698
|
await writeFileContent(fullPath, content);
|
|
24428
|
-
const relativePathFromCwd = (0,
|
|
24699
|
+
const relativePathFromCwd = (0, import_node_path149.join)(relativeDirPath, relativeFilePath);
|
|
24429
24700
|
return {
|
|
24430
24701
|
relativePathFromCwd,
|
|
24431
24702
|
content: rulesyncMcp.getFileContent()
|
|
@@ -24443,15 +24714,15 @@ async function deleteMcpFile() {
|
|
|
24443
24714
|
try {
|
|
24444
24715
|
const baseDir = process.cwd();
|
|
24445
24716
|
const paths = RulesyncMcp.getSettablePaths();
|
|
24446
|
-
const recommendedPath = (0,
|
|
24717
|
+
const recommendedPath = (0, import_node_path149.join)(
|
|
24447
24718
|
baseDir,
|
|
24448
24719
|
paths.recommended.relativeDirPath,
|
|
24449
24720
|
paths.recommended.relativeFilePath
|
|
24450
24721
|
);
|
|
24451
|
-
const legacyPath = (0,
|
|
24722
|
+
const legacyPath = (0, import_node_path149.join)(baseDir, paths.legacy.relativeDirPath, paths.legacy.relativeFilePath);
|
|
24452
24723
|
await removeFile(recommendedPath);
|
|
24453
24724
|
await removeFile(legacyPath);
|
|
24454
|
-
const relativePathFromCwd = (0,
|
|
24725
|
+
const relativePathFromCwd = (0, import_node_path149.join)(
|
|
24455
24726
|
paths.recommended.relativeDirPath,
|
|
24456
24727
|
paths.recommended.relativeFilePath
|
|
24457
24728
|
);
|
|
@@ -24468,11 +24739,11 @@ async function deleteMcpFile() {
|
|
|
24468
24739
|
}
|
|
24469
24740
|
}
|
|
24470
24741
|
var mcpToolSchemas = {
|
|
24471
|
-
getMcpFile:
|
|
24472
|
-
putMcpFile:
|
|
24473
|
-
content:
|
|
24742
|
+
getMcpFile: import_mini80.z.object({}),
|
|
24743
|
+
putMcpFile: import_mini80.z.object({
|
|
24744
|
+
content: import_mini80.z.string()
|
|
24474
24745
|
}),
|
|
24475
|
-
deleteMcpFile:
|
|
24746
|
+
deleteMcpFile: import_mini80.z.object({})
|
|
24476
24747
|
};
|
|
24477
24748
|
var mcpTools = {
|
|
24478
24749
|
getMcpFile: {
|
|
@@ -24505,13 +24776,13 @@ var mcpTools = {
|
|
|
24505
24776
|
};
|
|
24506
24777
|
|
|
24507
24778
|
// src/mcp/rules.ts
|
|
24508
|
-
var
|
|
24509
|
-
var
|
|
24779
|
+
var import_node_path150 = require("path");
|
|
24780
|
+
var import_mini81 = require("zod/mini");
|
|
24510
24781
|
var logger2 = new ConsoleLogger({ verbose: false, silent: true });
|
|
24511
24782
|
var maxRuleSizeBytes = 1024 * 1024;
|
|
24512
24783
|
var maxRulesCount = 1e3;
|
|
24513
24784
|
async function listRules() {
|
|
24514
|
-
const rulesDir = (0,
|
|
24785
|
+
const rulesDir = (0, import_node_path150.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
24515
24786
|
try {
|
|
24516
24787
|
const files = await listDirectoryFiles(rulesDir);
|
|
24517
24788
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -24524,7 +24795,7 @@ async function listRules() {
|
|
|
24524
24795
|
});
|
|
24525
24796
|
const frontmatter = rule.getFrontmatter();
|
|
24526
24797
|
return {
|
|
24527
|
-
relativePathFromCwd: (0,
|
|
24798
|
+
relativePathFromCwd: (0, import_node_path150.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, file),
|
|
24528
24799
|
frontmatter
|
|
24529
24800
|
};
|
|
24530
24801
|
} catch (error) {
|
|
@@ -24546,14 +24817,14 @@ async function getRule({ relativePathFromCwd }) {
|
|
|
24546
24817
|
relativePath: relativePathFromCwd,
|
|
24547
24818
|
intendedRootDir: process.cwd()
|
|
24548
24819
|
});
|
|
24549
|
-
const filename = (0,
|
|
24820
|
+
const filename = (0, import_node_path150.basename)(relativePathFromCwd);
|
|
24550
24821
|
try {
|
|
24551
24822
|
const rule = await RulesyncRule.fromFile({
|
|
24552
24823
|
relativeFilePath: filename,
|
|
24553
24824
|
validate: true
|
|
24554
24825
|
});
|
|
24555
24826
|
return {
|
|
24556
|
-
relativePathFromCwd: (0,
|
|
24827
|
+
relativePathFromCwd: (0, import_node_path150.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
24557
24828
|
frontmatter: rule.getFrontmatter(),
|
|
24558
24829
|
body: rule.getBody()
|
|
24559
24830
|
};
|
|
@@ -24572,7 +24843,7 @@ async function putRule({
|
|
|
24572
24843
|
relativePath: relativePathFromCwd,
|
|
24573
24844
|
intendedRootDir: process.cwd()
|
|
24574
24845
|
});
|
|
24575
|
-
const filename = (0,
|
|
24846
|
+
const filename = (0, import_node_path150.basename)(relativePathFromCwd);
|
|
24576
24847
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
24577
24848
|
if (estimatedSize > maxRuleSizeBytes) {
|
|
24578
24849
|
throw new Error(
|
|
@@ -24582,7 +24853,7 @@ async function putRule({
|
|
|
24582
24853
|
try {
|
|
24583
24854
|
const existingRules = await listRules();
|
|
24584
24855
|
const isUpdate = existingRules.some(
|
|
24585
|
-
(rule2) => rule2.relativePathFromCwd === (0,
|
|
24856
|
+
(rule2) => rule2.relativePathFromCwd === (0, import_node_path150.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
24586
24857
|
);
|
|
24587
24858
|
if (!isUpdate && existingRules.length >= maxRulesCount) {
|
|
24588
24859
|
throw new Error(
|
|
@@ -24597,11 +24868,11 @@ async function putRule({
|
|
|
24597
24868
|
body,
|
|
24598
24869
|
validate: true
|
|
24599
24870
|
});
|
|
24600
|
-
const rulesDir = (0,
|
|
24871
|
+
const rulesDir = (0, import_node_path150.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
24601
24872
|
await ensureDir(rulesDir);
|
|
24602
24873
|
await writeFileContent(rule.getFilePath(), rule.getFileContent());
|
|
24603
24874
|
return {
|
|
24604
|
-
relativePathFromCwd: (0,
|
|
24875
|
+
relativePathFromCwd: (0, import_node_path150.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
24605
24876
|
frontmatter: rule.getFrontmatter(),
|
|
24606
24877
|
body: rule.getBody()
|
|
24607
24878
|
};
|
|
@@ -24616,12 +24887,12 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
24616
24887
|
relativePath: relativePathFromCwd,
|
|
24617
24888
|
intendedRootDir: process.cwd()
|
|
24618
24889
|
});
|
|
24619
|
-
const filename = (0,
|
|
24620
|
-
const fullPath = (0,
|
|
24890
|
+
const filename = (0, import_node_path150.basename)(relativePathFromCwd);
|
|
24891
|
+
const fullPath = (0, import_node_path150.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH, filename);
|
|
24621
24892
|
try {
|
|
24622
24893
|
await removeFile(fullPath);
|
|
24623
24894
|
return {
|
|
24624
|
-
relativePathFromCwd: (0,
|
|
24895
|
+
relativePathFromCwd: (0, import_node_path150.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
24625
24896
|
};
|
|
24626
24897
|
} catch (error) {
|
|
24627
24898
|
throw new Error(`Failed to delete rule file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -24630,23 +24901,23 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
24630
24901
|
}
|
|
24631
24902
|
}
|
|
24632
24903
|
var ruleToolSchemas = {
|
|
24633
|
-
listRules:
|
|
24634
|
-
getRule:
|
|
24635
|
-
relativePathFromCwd:
|
|
24904
|
+
listRules: import_mini81.z.object({}),
|
|
24905
|
+
getRule: import_mini81.z.object({
|
|
24906
|
+
relativePathFromCwd: import_mini81.z.string()
|
|
24636
24907
|
}),
|
|
24637
|
-
putRule:
|
|
24638
|
-
relativePathFromCwd:
|
|
24908
|
+
putRule: import_mini81.z.object({
|
|
24909
|
+
relativePathFromCwd: import_mini81.z.string(),
|
|
24639
24910
|
frontmatter: RulesyncRuleFrontmatterSchema,
|
|
24640
|
-
body:
|
|
24911
|
+
body: import_mini81.z.string()
|
|
24641
24912
|
}),
|
|
24642
|
-
deleteRule:
|
|
24643
|
-
relativePathFromCwd:
|
|
24913
|
+
deleteRule: import_mini81.z.object({
|
|
24914
|
+
relativePathFromCwd: import_mini81.z.string()
|
|
24644
24915
|
})
|
|
24645
24916
|
};
|
|
24646
24917
|
var ruleTools = {
|
|
24647
24918
|
listRules: {
|
|
24648
24919
|
name: "listRules",
|
|
24649
|
-
description: `List all rules from ${(0,
|
|
24920
|
+
description: `List all rules from ${(0, import_node_path150.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
24650
24921
|
parameters: ruleToolSchemas.listRules,
|
|
24651
24922
|
execute: async () => {
|
|
24652
24923
|
const rules = await listRules();
|
|
@@ -24688,8 +24959,8 @@ var ruleTools = {
|
|
|
24688
24959
|
};
|
|
24689
24960
|
|
|
24690
24961
|
// src/mcp/skills.ts
|
|
24691
|
-
var
|
|
24692
|
-
var
|
|
24962
|
+
var import_node_path151 = require("path");
|
|
24963
|
+
var import_mini82 = require("zod/mini");
|
|
24693
24964
|
var logger3 = new ConsoleLogger({ verbose: false, silent: true });
|
|
24694
24965
|
var maxSkillSizeBytes = 1024 * 1024;
|
|
24695
24966
|
var maxSkillsCount = 1e3;
|
|
@@ -24706,19 +24977,19 @@ function mcpSkillFileToAiDirFile(file) {
|
|
|
24706
24977
|
};
|
|
24707
24978
|
}
|
|
24708
24979
|
function extractDirName(relativeDirPathFromCwd) {
|
|
24709
|
-
const dirName = (0,
|
|
24980
|
+
const dirName = (0, import_node_path151.basename)(relativeDirPathFromCwd);
|
|
24710
24981
|
if (!dirName) {
|
|
24711
24982
|
throw new Error(`Invalid path: ${relativeDirPathFromCwd}`);
|
|
24712
24983
|
}
|
|
24713
24984
|
return dirName;
|
|
24714
24985
|
}
|
|
24715
24986
|
async function listSkills() {
|
|
24716
|
-
const skillsDir = (0,
|
|
24987
|
+
const skillsDir = (0, import_node_path151.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH);
|
|
24717
24988
|
try {
|
|
24718
|
-
const skillDirPaths = await findFilesByGlobs((0,
|
|
24989
|
+
const skillDirPaths = await findFilesByGlobs((0, import_node_path151.join)(skillsDir, "*"), { type: "dir" });
|
|
24719
24990
|
const skills = await Promise.all(
|
|
24720
24991
|
skillDirPaths.map(async (dirPath) => {
|
|
24721
|
-
const dirName = (0,
|
|
24992
|
+
const dirName = (0, import_node_path151.basename)(dirPath);
|
|
24722
24993
|
if (!dirName) return null;
|
|
24723
24994
|
try {
|
|
24724
24995
|
const skill = await RulesyncSkill.fromDir({
|
|
@@ -24726,7 +24997,7 @@ async function listSkills() {
|
|
|
24726
24997
|
});
|
|
24727
24998
|
const frontmatter = skill.getFrontmatter();
|
|
24728
24999
|
return {
|
|
24729
|
-
relativeDirPathFromCwd: (0,
|
|
25000
|
+
relativeDirPathFromCwd: (0, import_node_path151.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
24730
25001
|
frontmatter
|
|
24731
25002
|
};
|
|
24732
25003
|
} catch (error) {
|
|
@@ -24754,7 +25025,7 @@ async function getSkill({ relativeDirPathFromCwd }) {
|
|
|
24754
25025
|
dirName
|
|
24755
25026
|
});
|
|
24756
25027
|
return {
|
|
24757
|
-
relativeDirPathFromCwd: (0,
|
|
25028
|
+
relativeDirPathFromCwd: (0, import_node_path151.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
24758
25029
|
frontmatter: skill.getFrontmatter(),
|
|
24759
25030
|
body: skill.getBody(),
|
|
24760
25031
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -24788,7 +25059,7 @@ async function putSkill({
|
|
|
24788
25059
|
try {
|
|
24789
25060
|
const existingSkills = await listSkills();
|
|
24790
25061
|
const isUpdate = existingSkills.some(
|
|
24791
|
-
(skill2) => skill2.relativeDirPathFromCwd === (0,
|
|
25062
|
+
(skill2) => skill2.relativeDirPathFromCwd === (0, import_node_path151.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
24792
25063
|
);
|
|
24793
25064
|
if (!isUpdate && existingSkills.length >= maxSkillsCount) {
|
|
24794
25065
|
throw new Error(
|
|
@@ -24805,9 +25076,9 @@ async function putSkill({
|
|
|
24805
25076
|
otherFiles: aiDirFiles,
|
|
24806
25077
|
validate: true
|
|
24807
25078
|
});
|
|
24808
|
-
const skillDirPath = (0,
|
|
25079
|
+
const skillDirPath = (0, import_node_path151.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
24809
25080
|
await ensureDir(skillDirPath);
|
|
24810
|
-
const skillFilePath = (0,
|
|
25081
|
+
const skillFilePath = (0, import_node_path151.join)(skillDirPath, SKILL_FILE_NAME);
|
|
24811
25082
|
const skillFileContent = stringifyFrontmatter(body, frontmatter);
|
|
24812
25083
|
await writeFileContent(skillFilePath, skillFileContent);
|
|
24813
25084
|
for (const file of otherFiles) {
|
|
@@ -24815,15 +25086,15 @@ async function putSkill({
|
|
|
24815
25086
|
relativePath: file.name,
|
|
24816
25087
|
intendedRootDir: skillDirPath
|
|
24817
25088
|
});
|
|
24818
|
-
const filePath = (0,
|
|
24819
|
-
const fileDir = (0,
|
|
25089
|
+
const filePath = (0, import_node_path151.join)(skillDirPath, file.name);
|
|
25090
|
+
const fileDir = (0, import_node_path151.join)(skillDirPath, (0, import_node_path151.dirname)(file.name));
|
|
24820
25091
|
if (fileDir !== skillDirPath) {
|
|
24821
25092
|
await ensureDir(fileDir);
|
|
24822
25093
|
}
|
|
24823
25094
|
await writeFileContent(filePath, file.body);
|
|
24824
25095
|
}
|
|
24825
25096
|
return {
|
|
24826
|
-
relativeDirPathFromCwd: (0,
|
|
25097
|
+
relativeDirPathFromCwd: (0, import_node_path151.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
24827
25098
|
frontmatter: skill.getFrontmatter(),
|
|
24828
25099
|
body: skill.getBody(),
|
|
24829
25100
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -24845,13 +25116,13 @@ async function deleteSkill({
|
|
|
24845
25116
|
intendedRootDir: process.cwd()
|
|
24846
25117
|
});
|
|
24847
25118
|
const dirName = extractDirName(relativeDirPathFromCwd);
|
|
24848
|
-
const skillDirPath = (0,
|
|
25119
|
+
const skillDirPath = (0, import_node_path151.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
24849
25120
|
try {
|
|
24850
25121
|
if (await directoryExists(skillDirPath)) {
|
|
24851
25122
|
await removeDirectory(skillDirPath);
|
|
24852
25123
|
}
|
|
24853
25124
|
return {
|
|
24854
|
-
relativeDirPathFromCwd: (0,
|
|
25125
|
+
relativeDirPathFromCwd: (0, import_node_path151.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
24855
25126
|
};
|
|
24856
25127
|
} catch (error) {
|
|
24857
25128
|
throw new Error(
|
|
@@ -24862,29 +25133,29 @@ async function deleteSkill({
|
|
|
24862
25133
|
);
|
|
24863
25134
|
}
|
|
24864
25135
|
}
|
|
24865
|
-
var McpSkillFileSchema =
|
|
24866
|
-
name:
|
|
24867
|
-
body:
|
|
25136
|
+
var McpSkillFileSchema = import_mini82.z.object({
|
|
25137
|
+
name: import_mini82.z.string(),
|
|
25138
|
+
body: import_mini82.z.string()
|
|
24868
25139
|
});
|
|
24869
25140
|
var skillToolSchemas = {
|
|
24870
|
-
listSkills:
|
|
24871
|
-
getSkill:
|
|
24872
|
-
relativeDirPathFromCwd:
|
|
25141
|
+
listSkills: import_mini82.z.object({}),
|
|
25142
|
+
getSkill: import_mini82.z.object({
|
|
25143
|
+
relativeDirPathFromCwd: import_mini82.z.string()
|
|
24873
25144
|
}),
|
|
24874
|
-
putSkill:
|
|
24875
|
-
relativeDirPathFromCwd:
|
|
25145
|
+
putSkill: import_mini82.z.object({
|
|
25146
|
+
relativeDirPathFromCwd: import_mini82.z.string(),
|
|
24876
25147
|
frontmatter: RulesyncSkillFrontmatterSchema,
|
|
24877
|
-
body:
|
|
24878
|
-
otherFiles:
|
|
25148
|
+
body: import_mini82.z.string(),
|
|
25149
|
+
otherFiles: import_mini82.z.optional(import_mini82.z.array(McpSkillFileSchema))
|
|
24879
25150
|
}),
|
|
24880
|
-
deleteSkill:
|
|
24881
|
-
relativeDirPathFromCwd:
|
|
25151
|
+
deleteSkill: import_mini82.z.object({
|
|
25152
|
+
relativeDirPathFromCwd: import_mini82.z.string()
|
|
24882
25153
|
})
|
|
24883
25154
|
};
|
|
24884
25155
|
var skillTools = {
|
|
24885
25156
|
listSkills: {
|
|
24886
25157
|
name: "listSkills",
|
|
24887
|
-
description: `List all skills from ${(0,
|
|
25158
|
+
description: `List all skills from ${(0, import_node_path151.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "*", SKILL_FILE_NAME)} with their frontmatter.`,
|
|
24888
25159
|
parameters: skillToolSchemas.listSkills,
|
|
24889
25160
|
execute: async () => {
|
|
24890
25161
|
const skills = await listSkills();
|
|
@@ -24927,13 +25198,13 @@ var skillTools = {
|
|
|
24927
25198
|
};
|
|
24928
25199
|
|
|
24929
25200
|
// src/mcp/subagents.ts
|
|
24930
|
-
var
|
|
24931
|
-
var
|
|
25201
|
+
var import_node_path152 = require("path");
|
|
25202
|
+
var import_mini83 = require("zod/mini");
|
|
24932
25203
|
var logger4 = new ConsoleLogger({ verbose: false, silent: true });
|
|
24933
25204
|
var maxSubagentSizeBytes = 1024 * 1024;
|
|
24934
25205
|
var maxSubagentsCount = 1e3;
|
|
24935
25206
|
async function listSubagents() {
|
|
24936
|
-
const subagentsDir = (0,
|
|
25207
|
+
const subagentsDir = (0, import_node_path152.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
24937
25208
|
try {
|
|
24938
25209
|
const files = await listDirectoryFiles(subagentsDir);
|
|
24939
25210
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -24946,7 +25217,7 @@ async function listSubagents() {
|
|
|
24946
25217
|
});
|
|
24947
25218
|
const frontmatter = subagent.getFrontmatter();
|
|
24948
25219
|
return {
|
|
24949
|
-
relativePathFromCwd: (0,
|
|
25220
|
+
relativePathFromCwd: (0, import_node_path152.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, file),
|
|
24950
25221
|
frontmatter
|
|
24951
25222
|
};
|
|
24952
25223
|
} catch (error) {
|
|
@@ -24970,14 +25241,14 @@ async function getSubagent({ relativePathFromCwd }) {
|
|
|
24970
25241
|
relativePath: relativePathFromCwd,
|
|
24971
25242
|
intendedRootDir: process.cwd()
|
|
24972
25243
|
});
|
|
24973
|
-
const filename = (0,
|
|
25244
|
+
const filename = (0, import_node_path152.basename)(relativePathFromCwd);
|
|
24974
25245
|
try {
|
|
24975
25246
|
const subagent = await RulesyncSubagent.fromFile({
|
|
24976
25247
|
relativeFilePath: filename,
|
|
24977
25248
|
validate: true
|
|
24978
25249
|
});
|
|
24979
25250
|
return {
|
|
24980
|
-
relativePathFromCwd: (0,
|
|
25251
|
+
relativePathFromCwd: (0, import_node_path152.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
24981
25252
|
frontmatter: subagent.getFrontmatter(),
|
|
24982
25253
|
body: subagent.getBody()
|
|
24983
25254
|
};
|
|
@@ -24996,7 +25267,7 @@ async function putSubagent({
|
|
|
24996
25267
|
relativePath: relativePathFromCwd,
|
|
24997
25268
|
intendedRootDir: process.cwd()
|
|
24998
25269
|
});
|
|
24999
|
-
const filename = (0,
|
|
25270
|
+
const filename = (0, import_node_path152.basename)(relativePathFromCwd);
|
|
25000
25271
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
25001
25272
|
if (estimatedSize > maxSubagentSizeBytes) {
|
|
25002
25273
|
throw new Error(
|
|
@@ -25006,7 +25277,7 @@ async function putSubagent({
|
|
|
25006
25277
|
try {
|
|
25007
25278
|
const existingSubagents = await listSubagents();
|
|
25008
25279
|
const isUpdate = existingSubagents.some(
|
|
25009
|
-
(subagent2) => subagent2.relativePathFromCwd === (0,
|
|
25280
|
+
(subagent2) => subagent2.relativePathFromCwd === (0, import_node_path152.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
25010
25281
|
);
|
|
25011
25282
|
if (!isUpdate && existingSubagents.length >= maxSubagentsCount) {
|
|
25012
25283
|
throw new Error(
|
|
@@ -25021,11 +25292,11 @@ async function putSubagent({
|
|
|
25021
25292
|
body,
|
|
25022
25293
|
validate: true
|
|
25023
25294
|
});
|
|
25024
|
-
const subagentsDir = (0,
|
|
25295
|
+
const subagentsDir = (0, import_node_path152.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
25025
25296
|
await ensureDir(subagentsDir);
|
|
25026
25297
|
await writeFileContent(subagent.getFilePath(), subagent.getFileContent());
|
|
25027
25298
|
return {
|
|
25028
|
-
relativePathFromCwd: (0,
|
|
25299
|
+
relativePathFromCwd: (0, import_node_path152.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
25029
25300
|
frontmatter: subagent.getFrontmatter(),
|
|
25030
25301
|
body: subagent.getBody()
|
|
25031
25302
|
};
|
|
@@ -25040,12 +25311,12 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
25040
25311
|
relativePath: relativePathFromCwd,
|
|
25041
25312
|
intendedRootDir: process.cwd()
|
|
25042
25313
|
});
|
|
25043
|
-
const filename = (0,
|
|
25044
|
-
const fullPath = (0,
|
|
25314
|
+
const filename = (0, import_node_path152.basename)(relativePathFromCwd);
|
|
25315
|
+
const fullPath = (0, import_node_path152.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename);
|
|
25045
25316
|
try {
|
|
25046
25317
|
await removeFile(fullPath);
|
|
25047
25318
|
return {
|
|
25048
|
-
relativePathFromCwd: (0,
|
|
25319
|
+
relativePathFromCwd: (0, import_node_path152.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
25049
25320
|
};
|
|
25050
25321
|
} catch (error) {
|
|
25051
25322
|
throw new Error(
|
|
@@ -25057,23 +25328,23 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
25057
25328
|
}
|
|
25058
25329
|
}
|
|
25059
25330
|
var subagentToolSchemas = {
|
|
25060
|
-
listSubagents:
|
|
25061
|
-
getSubagent:
|
|
25062
|
-
relativePathFromCwd:
|
|
25331
|
+
listSubagents: import_mini83.z.object({}),
|
|
25332
|
+
getSubagent: import_mini83.z.object({
|
|
25333
|
+
relativePathFromCwd: import_mini83.z.string()
|
|
25063
25334
|
}),
|
|
25064
|
-
putSubagent:
|
|
25065
|
-
relativePathFromCwd:
|
|
25335
|
+
putSubagent: import_mini83.z.object({
|
|
25336
|
+
relativePathFromCwd: import_mini83.z.string(),
|
|
25066
25337
|
frontmatter: RulesyncSubagentFrontmatterSchema,
|
|
25067
|
-
body:
|
|
25338
|
+
body: import_mini83.z.string()
|
|
25068
25339
|
}),
|
|
25069
|
-
deleteSubagent:
|
|
25070
|
-
relativePathFromCwd:
|
|
25340
|
+
deleteSubagent: import_mini83.z.object({
|
|
25341
|
+
relativePathFromCwd: import_mini83.z.string()
|
|
25071
25342
|
})
|
|
25072
25343
|
};
|
|
25073
25344
|
var subagentTools = {
|
|
25074
25345
|
listSubagents: {
|
|
25075
25346
|
name: "listSubagents",
|
|
25076
|
-
description: `List all subagents from ${(0,
|
|
25347
|
+
description: `List all subagents from ${(0, import_node_path152.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
25077
25348
|
parameters: subagentToolSchemas.listSubagents,
|
|
25078
25349
|
execute: async () => {
|
|
25079
25350
|
const subagents = await listSubagents();
|
|
@@ -25115,7 +25386,7 @@ var subagentTools = {
|
|
|
25115
25386
|
};
|
|
25116
25387
|
|
|
25117
25388
|
// src/mcp/tools.ts
|
|
25118
|
-
var rulesyncFeatureSchema =
|
|
25389
|
+
var rulesyncFeatureSchema = import_mini84.z.enum([
|
|
25119
25390
|
"rule",
|
|
25120
25391
|
"command",
|
|
25121
25392
|
"subagent",
|
|
@@ -25125,21 +25396,21 @@ var rulesyncFeatureSchema = import_mini83.z.enum([
|
|
|
25125
25396
|
"generate",
|
|
25126
25397
|
"import"
|
|
25127
25398
|
]);
|
|
25128
|
-
var rulesyncOperationSchema =
|
|
25129
|
-
var skillFileSchema =
|
|
25130
|
-
name:
|
|
25131
|
-
body:
|
|
25399
|
+
var rulesyncOperationSchema = import_mini84.z.enum(["list", "get", "put", "delete", "run"]);
|
|
25400
|
+
var skillFileSchema = import_mini84.z.object({
|
|
25401
|
+
name: import_mini84.z.string(),
|
|
25402
|
+
body: import_mini84.z.string()
|
|
25132
25403
|
});
|
|
25133
|
-
var rulesyncToolSchema =
|
|
25404
|
+
var rulesyncToolSchema = import_mini84.z.object({
|
|
25134
25405
|
feature: rulesyncFeatureSchema,
|
|
25135
25406
|
operation: rulesyncOperationSchema,
|
|
25136
|
-
targetPathFromCwd:
|
|
25137
|
-
frontmatter:
|
|
25138
|
-
body:
|
|
25139
|
-
otherFiles:
|
|
25140
|
-
content:
|
|
25141
|
-
generateOptions:
|
|
25142
|
-
importOptions:
|
|
25407
|
+
targetPathFromCwd: import_mini84.z.optional(import_mini84.z.string()),
|
|
25408
|
+
frontmatter: import_mini84.z.optional(import_mini84.z.unknown()),
|
|
25409
|
+
body: import_mini84.z.optional(import_mini84.z.string()),
|
|
25410
|
+
otherFiles: import_mini84.z.optional(import_mini84.z.array(skillFileSchema)),
|
|
25411
|
+
content: import_mini84.z.optional(import_mini84.z.string()),
|
|
25412
|
+
generateOptions: import_mini84.z.optional(generateOptionsSchema),
|
|
25413
|
+
importOptions: import_mini84.z.optional(importOptionsSchema)
|
|
25143
25414
|
});
|
|
25144
25415
|
var supportedOperationsByFeature = {
|
|
25145
25416
|
rule: ["list", "get", "put", "delete"],
|
|
@@ -25346,7 +25617,7 @@ async function mcpCommand(logger5, { version }) {
|
|
|
25346
25617
|
}
|
|
25347
25618
|
|
|
25348
25619
|
// src/cli/commands/resolve-gitignore-targets.ts
|
|
25349
|
-
var
|
|
25620
|
+
var import_node_path153 = require("path");
|
|
25350
25621
|
var resolveGitignoreTargets = async ({
|
|
25351
25622
|
cliTargets,
|
|
25352
25623
|
cwd = process.cwd()
|
|
@@ -25354,8 +25625,8 @@ var resolveGitignoreTargets = async ({
|
|
|
25354
25625
|
if (cliTargets !== void 0) {
|
|
25355
25626
|
return cliTargets;
|
|
25356
25627
|
}
|
|
25357
|
-
const baseConfigPath = (0,
|
|
25358
|
-
const localConfigPath = (0,
|
|
25628
|
+
const baseConfigPath = (0, import_node_path153.join)(cwd, RULESYNC_CONFIG_RELATIVE_FILE_PATH);
|
|
25629
|
+
const localConfigPath = (0, import_node_path153.join)(cwd, RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH);
|
|
25359
25630
|
const [hasBase, hasLocal] = await Promise.all([
|
|
25360
25631
|
fileExists(baseConfigPath),
|
|
25361
25632
|
fileExists(localConfigPath)
|
|
@@ -25776,7 +26047,7 @@ function wrapCommand({
|
|
|
25776
26047
|
}
|
|
25777
26048
|
|
|
25778
26049
|
// src/cli/index.ts
|
|
25779
|
-
var getVersion = () => "8.
|
|
26050
|
+
var getVersion = () => "8.4.0";
|
|
25780
26051
|
function wrapCommand2(name, errorCode, handler) {
|
|
25781
26052
|
return wrapCommand({ name, errorCode, handler, getVersion });
|
|
25782
26053
|
}
|