rulesync 7.28.0 → 8.0.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 +29 -27
- package/dist/{chunk-AKHOQKVV.js → chunk-GB6XLCGB.js} +1951 -761
- package/dist/cli/index.cjs +1956 -747
- package/dist/cli/index.js +29 -10
- package/dist/index.cjs +1981 -791
- package/dist/index.d.cts +3 -0
- package/dist/index.d.ts +3 -0
- package/dist/index.js +1 -1
- package/package.json +1 -1
package/dist/cli/index.cjs
CHANGED
|
@@ -41,10 +41,21 @@ var ALL_FEATURES = [
|
|
|
41
41
|
var ALL_FEATURES_WITH_WILDCARD = [...ALL_FEATURES, "*"];
|
|
42
42
|
var FeatureSchema = import_mini.z.enum(ALL_FEATURES);
|
|
43
43
|
var FeaturesSchema = import_mini.z.array(FeatureSchema);
|
|
44
|
+
var FeatureOptionsSchema = import_mini.z.record(import_mini.z.string(), import_mini.z.unknown());
|
|
45
|
+
var FeatureValueSchema = import_mini.z.union([import_mini.z.boolean(), FeatureOptionsSchema]);
|
|
46
|
+
var PerFeatureConfigSchema = import_mini.z.record(import_mini.z.string(), FeatureValueSchema);
|
|
44
47
|
var RulesyncFeaturesSchema = import_mini.z.union([
|
|
45
48
|
import_mini.z.array(import_mini.z.enum(ALL_FEATURES_WITH_WILDCARD)),
|
|
46
|
-
import_mini.z.record(
|
|
49
|
+
import_mini.z.record(
|
|
50
|
+
import_mini.z.string(),
|
|
51
|
+
import_mini.z.union([import_mini.z.array(import_mini.z.enum(ALL_FEATURES_WITH_WILDCARD)), PerFeatureConfigSchema])
|
|
52
|
+
)
|
|
47
53
|
]);
|
|
54
|
+
var isFeatureValueEnabled = (value) => {
|
|
55
|
+
if (value === true) return true;
|
|
56
|
+
if (typeof value === "object" && value !== null && !Array.isArray(value)) return true;
|
|
57
|
+
return false;
|
|
58
|
+
};
|
|
48
59
|
|
|
49
60
|
// src/utils/error.ts
|
|
50
61
|
var import_zod = require("zod");
|
|
@@ -5064,7 +5075,7 @@ var HooksProcessor = class extends FeatureProcessor {
|
|
|
5064
5075
|
};
|
|
5065
5076
|
|
|
5066
5077
|
// src/features/ignore/ignore-processor.ts
|
|
5067
|
-
var
|
|
5078
|
+
var import_mini21 = require("zod/mini");
|
|
5068
5079
|
|
|
5069
5080
|
// src/features/ignore/augmentcode-ignore.ts
|
|
5070
5081
|
var import_node_path33 = require("path");
|
|
@@ -5140,7 +5151,7 @@ var ToolIgnore = class extends ToolFile {
|
|
|
5140
5151
|
}
|
|
5141
5152
|
}
|
|
5142
5153
|
}
|
|
5143
|
-
static getSettablePaths() {
|
|
5154
|
+
static getSettablePaths(_params) {
|
|
5144
5155
|
throw new Error("Please implement this method in the subclass.");
|
|
5145
5156
|
}
|
|
5146
5157
|
getPatterns() {
|
|
@@ -5243,21 +5254,47 @@ var AugmentcodeIgnore = class _AugmentcodeIgnore extends ToolIgnore {
|
|
|
5243
5254
|
// src/features/ignore/claudecode-ignore.ts
|
|
5244
5255
|
var import_node_path34 = require("path");
|
|
5245
5256
|
var import_es_toolkit2 = require("es-toolkit");
|
|
5257
|
+
var import_mini20 = require("zod/mini");
|
|
5258
|
+
var SHARED_SETTINGS_FILE = "settings.json";
|
|
5259
|
+
var LOCAL_SETTINGS_FILE = "settings.local.json";
|
|
5260
|
+
var DEFAULT_FILE_MODE = "shared";
|
|
5261
|
+
var ClaudecodeIgnoreOptionsSchema = import_mini20.z.looseObject({
|
|
5262
|
+
fileMode: import_mini20.z.optional(import_mini20.z.enum(["shared", "local"]))
|
|
5263
|
+
});
|
|
5264
|
+
var resolveFileMode = (options) => {
|
|
5265
|
+
if (!options) return DEFAULT_FILE_MODE;
|
|
5266
|
+
const parsed = ClaudecodeIgnoreOptionsSchema.safeParse(options);
|
|
5267
|
+
if (!parsed.success) {
|
|
5268
|
+
throw new Error(
|
|
5269
|
+
`Invalid options for claudecode ignore feature: ${parsed.error.message}. \`fileMode\` must be either "shared" or "local".`
|
|
5270
|
+
);
|
|
5271
|
+
}
|
|
5272
|
+
return parsed.data.fileMode ?? DEFAULT_FILE_MODE;
|
|
5273
|
+
};
|
|
5274
|
+
var fileNameForMode = (fileMode) => {
|
|
5275
|
+
return fileMode === "local" ? LOCAL_SETTINGS_FILE : SHARED_SETTINGS_FILE;
|
|
5276
|
+
};
|
|
5246
5277
|
var ClaudecodeIgnore = class _ClaudecodeIgnore extends ToolIgnore {
|
|
5247
5278
|
constructor(params) {
|
|
5248
5279
|
super(params);
|
|
5249
5280
|
const jsonValue = JSON.parse(this.fileContent);
|
|
5250
5281
|
this.patterns = jsonValue.permissions?.deny ?? [];
|
|
5251
5282
|
}
|
|
5252
|
-
static getSettablePaths() {
|
|
5283
|
+
static getSettablePaths(params) {
|
|
5284
|
+
const fileMode = resolveFileMode(params?.options);
|
|
5253
5285
|
return {
|
|
5254
5286
|
relativeDirPath: ".claude",
|
|
5255
|
-
relativeFilePath:
|
|
5287
|
+
relativeFilePath: fileNameForMode(fileMode)
|
|
5256
5288
|
};
|
|
5257
5289
|
}
|
|
5258
5290
|
/**
|
|
5259
|
-
* ClaudecodeIgnore uses settings.json, which can
|
|
5260
|
-
* It should not be deleted by rulesync.
|
|
5291
|
+
* ClaudecodeIgnore uses settings.json (or settings.local.json), which can
|
|
5292
|
+
* include non-ignore settings. It should not be deleted by rulesync.
|
|
5293
|
+
*
|
|
5294
|
+
* NOTE: Because this returns `false`, switching `fileMode` (e.g. from
|
|
5295
|
+
* `"local"` to `"shared"`) will not automatically clean up deny patterns
|
|
5296
|
+
* in the previously-used file. Users must manually remove stale deny
|
|
5297
|
+
* entries from the old file when changing `fileMode`.
|
|
5261
5298
|
*/
|
|
5262
5299
|
isDeletable() {
|
|
5263
5300
|
return false;
|
|
@@ -5279,16 +5316,14 @@ var ClaudecodeIgnore = class _ClaudecodeIgnore extends ToolIgnore {
|
|
|
5279
5316
|
}
|
|
5280
5317
|
static async fromRulesyncIgnore({
|
|
5281
5318
|
baseDir = process.cwd(),
|
|
5282
|
-
rulesyncIgnore
|
|
5319
|
+
rulesyncIgnore,
|
|
5320
|
+
options
|
|
5283
5321
|
}) {
|
|
5284
5322
|
const fileContent = rulesyncIgnore.getFileContent();
|
|
5285
5323
|
const patterns = fileContent.split(/\r?\n|\r/).map((line) => line.trim()).filter((line) => line.length > 0 && !line.startsWith("#"));
|
|
5286
5324
|
const deniedValues = patterns.map((pattern) => `Read(${pattern})`);
|
|
5287
|
-
const
|
|
5288
|
-
|
|
5289
|
-
this.getSettablePaths().relativeDirPath,
|
|
5290
|
-
this.getSettablePaths().relativeFilePath
|
|
5291
|
-
);
|
|
5325
|
+
const paths = this.getSettablePaths({ options });
|
|
5326
|
+
const filePath = (0, import_node_path34.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
5292
5327
|
const exists = await fileExists(filePath);
|
|
5293
5328
|
const existingFileContent = exists ? await readFileContent(filePath) : "{}";
|
|
5294
5329
|
const existingJsonValue = JSON.parse(existingFileContent);
|
|
@@ -5309,27 +5344,29 @@ var ClaudecodeIgnore = class _ClaudecodeIgnore extends ToolIgnore {
|
|
|
5309
5344
|
};
|
|
5310
5345
|
return new _ClaudecodeIgnore({
|
|
5311
5346
|
baseDir,
|
|
5312
|
-
relativeDirPath:
|
|
5313
|
-
relativeFilePath:
|
|
5347
|
+
relativeDirPath: paths.relativeDirPath,
|
|
5348
|
+
relativeFilePath: paths.relativeFilePath,
|
|
5314
5349
|
fileContent: JSON.stringify(jsonValue, null, 2),
|
|
5315
5350
|
validate: true
|
|
5316
5351
|
});
|
|
5317
5352
|
}
|
|
5318
5353
|
static async fromFile({
|
|
5319
5354
|
baseDir = process.cwd(),
|
|
5320
|
-
validate = true
|
|
5355
|
+
validate = true,
|
|
5356
|
+
options
|
|
5321
5357
|
}) {
|
|
5322
|
-
const
|
|
5323
|
-
|
|
5324
|
-
|
|
5325
|
-
|
|
5326
|
-
|
|
5327
|
-
)
|
|
5328
|
-
|
|
5358
|
+
const fileMode = resolveFileMode(options);
|
|
5359
|
+
const paths = this.getSettablePaths({ options });
|
|
5360
|
+
const filePath = (0, import_node_path34.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
5361
|
+
const exists = await fileExists(filePath);
|
|
5362
|
+
if (!exists && fileMode === "shared") {
|
|
5363
|
+
throw new Error(`File not found: ${filePath}`);
|
|
5364
|
+
}
|
|
5365
|
+
const fileContent = exists ? await readFileContent(filePath) : "{}";
|
|
5329
5366
|
return new _ClaudecodeIgnore({
|
|
5330
5367
|
baseDir,
|
|
5331
|
-
relativeDirPath:
|
|
5332
|
-
relativeFilePath:
|
|
5368
|
+
relativeDirPath: paths.relativeDirPath,
|
|
5369
|
+
relativeFilePath: paths.relativeFilePath,
|
|
5333
5370
|
fileContent,
|
|
5334
5371
|
validate
|
|
5335
5372
|
});
|
|
@@ -6066,7 +6103,7 @@ var ignoreProcessorToolTargets = [
|
|
|
6066
6103
|
"windsurf",
|
|
6067
6104
|
"zed"
|
|
6068
6105
|
];
|
|
6069
|
-
var IgnoreProcessorToolTargetSchema =
|
|
6106
|
+
var IgnoreProcessorToolTargetSchema = import_mini21.z.enum(ignoreProcessorToolTargets);
|
|
6070
6107
|
var toolIgnoreFactories = /* @__PURE__ */ new Map([
|
|
6071
6108
|
["augmentcode", { class: AugmentcodeIgnore }],
|
|
6072
6109
|
["claudecode", { class: ClaudecodeIgnore }],
|
|
@@ -6093,12 +6130,14 @@ var defaultGetFactory2 = (target) => {
|
|
|
6093
6130
|
var IgnoreProcessor = class extends FeatureProcessor {
|
|
6094
6131
|
toolTarget;
|
|
6095
6132
|
getFactory;
|
|
6133
|
+
featureOptions;
|
|
6096
6134
|
constructor({
|
|
6097
6135
|
baseDir = process.cwd(),
|
|
6098
6136
|
toolTarget,
|
|
6099
6137
|
getFactory = defaultGetFactory2,
|
|
6100
6138
|
dryRun = false,
|
|
6101
|
-
logger: logger5
|
|
6139
|
+
logger: logger5,
|
|
6140
|
+
featureOptions
|
|
6102
6141
|
}) {
|
|
6103
6142
|
super({ baseDir, dryRun, logger: logger5 });
|
|
6104
6143
|
const result = IgnoreProcessorToolTargetSchema.safeParse(toolTarget);
|
|
@@ -6109,6 +6148,7 @@ var IgnoreProcessor = class extends FeatureProcessor {
|
|
|
6109
6148
|
}
|
|
6110
6149
|
this.toolTarget = result.data;
|
|
6111
6150
|
this.getFactory = getFactory;
|
|
6151
|
+
this.featureOptions = featureOptions;
|
|
6112
6152
|
}
|
|
6113
6153
|
async writeToolIgnoresFromRulesyncIgnores(rulesyncIgnores) {
|
|
6114
6154
|
const toolIgnores = await this.convertRulesyncFilesToToolFiles(rulesyncIgnores);
|
|
@@ -6137,7 +6177,7 @@ var IgnoreProcessor = class extends FeatureProcessor {
|
|
|
6137
6177
|
} = {}) {
|
|
6138
6178
|
try {
|
|
6139
6179
|
const factory = this.getFactory(this.toolTarget);
|
|
6140
|
-
const paths = factory.class.getSettablePaths();
|
|
6180
|
+
const paths = factory.class.getSettablePaths({ options: this.featureOptions });
|
|
6141
6181
|
if (forDeletion) {
|
|
6142
6182
|
const toolIgnore = factory.class.forDeletion({
|
|
6143
6183
|
baseDir: this.baseDir,
|
|
@@ -6161,7 +6201,7 @@ var IgnoreProcessor = class extends FeatureProcessor {
|
|
|
6161
6201
|
}
|
|
6162
6202
|
async loadToolIgnores() {
|
|
6163
6203
|
const factory = this.getFactory(this.toolTarget);
|
|
6164
|
-
return [await factory.class.fromFile({ baseDir: this.baseDir })];
|
|
6204
|
+
return [await factory.class.fromFile({ baseDir: this.baseDir, options: this.featureOptions })];
|
|
6165
6205
|
}
|
|
6166
6206
|
/**
|
|
6167
6207
|
* Implementation of abstract method from FeatureProcessor
|
|
@@ -6177,7 +6217,8 @@ var IgnoreProcessor = class extends FeatureProcessor {
|
|
|
6177
6217
|
const factory = this.getFactory(this.toolTarget);
|
|
6178
6218
|
const toolIgnore = await factory.class.fromRulesyncIgnore({
|
|
6179
6219
|
baseDir: this.baseDir,
|
|
6180
|
-
rulesyncIgnore
|
|
6220
|
+
rulesyncIgnore,
|
|
6221
|
+
options: this.featureOptions
|
|
6181
6222
|
});
|
|
6182
6223
|
return [toolIgnore];
|
|
6183
6224
|
}
|
|
@@ -6205,7 +6246,7 @@ var IgnoreProcessor = class extends FeatureProcessor {
|
|
|
6205
6246
|
};
|
|
6206
6247
|
|
|
6207
6248
|
// src/features/mcp/mcp-processor.ts
|
|
6208
|
-
var
|
|
6249
|
+
var import_mini26 = require("zod/mini");
|
|
6209
6250
|
|
|
6210
6251
|
// src/features/mcp/claudecode-mcp.ts
|
|
6211
6252
|
var import_node_path47 = require("path");
|
|
@@ -6213,47 +6254,47 @@ var import_node_path47 = require("path");
|
|
|
6213
6254
|
// src/features/mcp/rulesync-mcp.ts
|
|
6214
6255
|
var import_node_path46 = require("path");
|
|
6215
6256
|
var import_object = require("es-toolkit/object");
|
|
6216
|
-
var
|
|
6257
|
+
var import_mini23 = require("zod/mini");
|
|
6217
6258
|
|
|
6218
6259
|
// src/types/mcp.ts
|
|
6219
|
-
var
|
|
6220
|
-
var McpServerSchema =
|
|
6221
|
-
type:
|
|
6222
|
-
command:
|
|
6223
|
-
args:
|
|
6224
|
-
url:
|
|
6225
|
-
httpUrl:
|
|
6226
|
-
env:
|
|
6227
|
-
disabled:
|
|
6228
|
-
networkTimeout:
|
|
6229
|
-
timeout:
|
|
6230
|
-
trust:
|
|
6231
|
-
cwd:
|
|
6232
|
-
transport:
|
|
6233
|
-
alwaysAllow:
|
|
6234
|
-
tools:
|
|
6235
|
-
kiroAutoApprove:
|
|
6236
|
-
kiroAutoBlock:
|
|
6237
|
-
headers:
|
|
6238
|
-
enabledTools:
|
|
6239
|
-
disabledTools:
|
|
6260
|
+
var import_mini22 = require("zod/mini");
|
|
6261
|
+
var McpServerSchema = import_mini22.z.looseObject({
|
|
6262
|
+
type: import_mini22.z.optional(import_mini22.z.enum(["local", "stdio", "sse", "http"])),
|
|
6263
|
+
command: import_mini22.z.optional(import_mini22.z.union([import_mini22.z.string(), import_mini22.z.array(import_mini22.z.string())])),
|
|
6264
|
+
args: import_mini22.z.optional(import_mini22.z.array(import_mini22.z.string())),
|
|
6265
|
+
url: import_mini22.z.optional(import_mini22.z.string()),
|
|
6266
|
+
httpUrl: import_mini22.z.optional(import_mini22.z.string()),
|
|
6267
|
+
env: import_mini22.z.optional(import_mini22.z.record(import_mini22.z.string(), import_mini22.z.string())),
|
|
6268
|
+
disabled: import_mini22.z.optional(import_mini22.z.boolean()),
|
|
6269
|
+
networkTimeout: import_mini22.z.optional(import_mini22.z.number()),
|
|
6270
|
+
timeout: import_mini22.z.optional(import_mini22.z.number()),
|
|
6271
|
+
trust: import_mini22.z.optional(import_mini22.z.boolean()),
|
|
6272
|
+
cwd: import_mini22.z.optional(import_mini22.z.string()),
|
|
6273
|
+
transport: import_mini22.z.optional(import_mini22.z.enum(["local", "stdio", "sse", "http"])),
|
|
6274
|
+
alwaysAllow: import_mini22.z.optional(import_mini22.z.array(import_mini22.z.string())),
|
|
6275
|
+
tools: import_mini22.z.optional(import_mini22.z.array(import_mini22.z.string())),
|
|
6276
|
+
kiroAutoApprove: import_mini22.z.optional(import_mini22.z.array(import_mini22.z.string())),
|
|
6277
|
+
kiroAutoBlock: import_mini22.z.optional(import_mini22.z.array(import_mini22.z.string())),
|
|
6278
|
+
headers: import_mini22.z.optional(import_mini22.z.record(import_mini22.z.string(), import_mini22.z.string())),
|
|
6279
|
+
enabledTools: import_mini22.z.optional(import_mini22.z.array(import_mini22.z.string())),
|
|
6280
|
+
disabledTools: import_mini22.z.optional(import_mini22.z.array(import_mini22.z.string()))
|
|
6240
6281
|
});
|
|
6241
|
-
var McpServersSchema =
|
|
6282
|
+
var McpServersSchema = import_mini22.z.record(import_mini22.z.string(), McpServerSchema);
|
|
6242
6283
|
function isMcpServers(value) {
|
|
6243
6284
|
return value !== void 0 && value !== null && typeof value === "object" && !Array.isArray(value);
|
|
6244
6285
|
}
|
|
6245
6286
|
|
|
6246
6287
|
// src/features/mcp/rulesync-mcp.ts
|
|
6247
|
-
var RulesyncMcpServerSchema =
|
|
6248
|
-
targets:
|
|
6249
|
-
description:
|
|
6250
|
-
exposed:
|
|
6288
|
+
var RulesyncMcpServerSchema = import_mini23.z.extend(McpServerSchema, {
|
|
6289
|
+
targets: import_mini23.z.optional(RulesyncTargetsSchema),
|
|
6290
|
+
description: import_mini23.z.optional(import_mini23.z.string()),
|
|
6291
|
+
exposed: import_mini23.z.optional(import_mini23.z.boolean())
|
|
6251
6292
|
});
|
|
6252
|
-
var RulesyncMcpConfigSchema =
|
|
6253
|
-
mcpServers:
|
|
6293
|
+
var RulesyncMcpConfigSchema = import_mini23.z.object({
|
|
6294
|
+
mcpServers: import_mini23.z.record(import_mini23.z.string(), RulesyncMcpServerSchema)
|
|
6254
6295
|
});
|
|
6255
|
-
var RulesyncMcpFileSchema =
|
|
6256
|
-
$schema:
|
|
6296
|
+
var RulesyncMcpFileSchema = import_mini23.z.looseObject({
|
|
6297
|
+
$schema: import_mini23.z.optional(import_mini23.z.string()),
|
|
6257
6298
|
...RulesyncMcpConfigSchema.shape
|
|
6258
6299
|
});
|
|
6259
6300
|
var RulesyncMcp = class _RulesyncMcp extends RulesyncFile {
|
|
@@ -6460,7 +6501,8 @@ var ClaudecodeMcp = class _ClaudecodeMcp extends ToolMcp {
|
|
|
6460
6501
|
relativeDirPath: paths.relativeDirPath,
|
|
6461
6502
|
relativeFilePath: paths.relativeFilePath,
|
|
6462
6503
|
fileContent: JSON.stringify(newJson, null, 2),
|
|
6463
|
-
validate
|
|
6504
|
+
validate,
|
|
6505
|
+
global
|
|
6464
6506
|
});
|
|
6465
6507
|
}
|
|
6466
6508
|
static async fromRulesyncMcp({
|
|
@@ -6481,7 +6523,8 @@ var ClaudecodeMcp = class _ClaudecodeMcp extends ToolMcp {
|
|
|
6481
6523
|
relativeDirPath: paths.relativeDirPath,
|
|
6482
6524
|
relativeFilePath: paths.relativeFilePath,
|
|
6483
6525
|
fileContent: JSON.stringify(mcpJson, null, 2),
|
|
6484
|
-
validate
|
|
6526
|
+
validate,
|
|
6527
|
+
global
|
|
6485
6528
|
});
|
|
6486
6529
|
}
|
|
6487
6530
|
toRulesyncMcp() {
|
|
@@ -7454,25 +7497,25 @@ var JunieMcp = class _JunieMcp extends ToolMcp {
|
|
|
7454
7497
|
// src/features/mcp/kilo-mcp.ts
|
|
7455
7498
|
var import_node_path57 = require("path");
|
|
7456
7499
|
var import_jsonc_parser2 = require("jsonc-parser");
|
|
7457
|
-
var
|
|
7458
|
-
var KiloMcpLocalServerSchema =
|
|
7459
|
-
type:
|
|
7460
|
-
command:
|
|
7461
|
-
environment:
|
|
7462
|
-
enabled:
|
|
7463
|
-
cwd:
|
|
7500
|
+
var import_mini24 = require("zod/mini");
|
|
7501
|
+
var KiloMcpLocalServerSchema = import_mini24.z.object({
|
|
7502
|
+
type: import_mini24.z.literal("local"),
|
|
7503
|
+
command: import_mini24.z.array(import_mini24.z.string()),
|
|
7504
|
+
environment: import_mini24.z.optional(import_mini24.z.record(import_mini24.z.string(), import_mini24.z.string())),
|
|
7505
|
+
enabled: import_mini24.z._default(import_mini24.z.boolean(), true),
|
|
7506
|
+
cwd: import_mini24.z.optional(import_mini24.z.string())
|
|
7464
7507
|
});
|
|
7465
|
-
var KiloMcpRemoteServerSchema =
|
|
7466
|
-
type:
|
|
7467
|
-
url:
|
|
7468
|
-
headers:
|
|
7469
|
-
enabled:
|
|
7508
|
+
var KiloMcpRemoteServerSchema = import_mini24.z.object({
|
|
7509
|
+
type: import_mini24.z.literal("remote"),
|
|
7510
|
+
url: import_mini24.z.string(),
|
|
7511
|
+
headers: import_mini24.z.optional(import_mini24.z.record(import_mini24.z.string(), import_mini24.z.string())),
|
|
7512
|
+
enabled: import_mini24.z._default(import_mini24.z.boolean(), true)
|
|
7470
7513
|
});
|
|
7471
|
-
var KiloMcpServerSchema =
|
|
7472
|
-
var KiloConfigSchema =
|
|
7473
|
-
$schema:
|
|
7474
|
-
mcp:
|
|
7475
|
-
tools:
|
|
7514
|
+
var KiloMcpServerSchema = import_mini24.z.union([KiloMcpLocalServerSchema, KiloMcpRemoteServerSchema]);
|
|
7515
|
+
var KiloConfigSchema = import_mini24.z.looseObject({
|
|
7516
|
+
$schema: import_mini24.z.optional(import_mini24.z.string()),
|
|
7517
|
+
mcp: import_mini24.z.optional(import_mini24.z.record(import_mini24.z.string(), KiloMcpServerSchema)),
|
|
7518
|
+
tools: import_mini24.z.optional(import_mini24.z.record(import_mini24.z.string(), import_mini24.z.boolean()))
|
|
7476
7519
|
});
|
|
7477
7520
|
function convertFromKiloFormat(kiloMcp, tools) {
|
|
7478
7521
|
return Object.fromEntries(
|
|
@@ -7769,28 +7812,28 @@ var KiroMcp = class _KiroMcp extends ToolMcp {
|
|
|
7769
7812
|
// src/features/mcp/opencode-mcp.ts
|
|
7770
7813
|
var import_node_path59 = require("path");
|
|
7771
7814
|
var import_jsonc_parser3 = require("jsonc-parser");
|
|
7772
|
-
var
|
|
7773
|
-
var OpencodeMcpLocalServerSchema =
|
|
7774
|
-
type:
|
|
7775
|
-
command:
|
|
7776
|
-
environment:
|
|
7777
|
-
enabled:
|
|
7778
|
-
cwd:
|
|
7815
|
+
var import_mini25 = require("zod/mini");
|
|
7816
|
+
var OpencodeMcpLocalServerSchema = import_mini25.z.object({
|
|
7817
|
+
type: import_mini25.z.literal("local"),
|
|
7818
|
+
command: import_mini25.z.array(import_mini25.z.string()),
|
|
7819
|
+
environment: import_mini25.z.optional(import_mini25.z.record(import_mini25.z.string(), import_mini25.z.string())),
|
|
7820
|
+
enabled: import_mini25.z._default(import_mini25.z.boolean(), true),
|
|
7821
|
+
cwd: import_mini25.z.optional(import_mini25.z.string())
|
|
7779
7822
|
});
|
|
7780
|
-
var OpencodeMcpRemoteServerSchema =
|
|
7781
|
-
type:
|
|
7782
|
-
url:
|
|
7783
|
-
headers:
|
|
7784
|
-
enabled:
|
|
7823
|
+
var OpencodeMcpRemoteServerSchema = import_mini25.z.object({
|
|
7824
|
+
type: import_mini25.z.literal("remote"),
|
|
7825
|
+
url: import_mini25.z.string(),
|
|
7826
|
+
headers: import_mini25.z.optional(import_mini25.z.record(import_mini25.z.string(), import_mini25.z.string())),
|
|
7827
|
+
enabled: import_mini25.z._default(import_mini25.z.boolean(), true)
|
|
7785
7828
|
});
|
|
7786
|
-
var OpencodeMcpServerSchema =
|
|
7829
|
+
var OpencodeMcpServerSchema = import_mini25.z.union([
|
|
7787
7830
|
OpencodeMcpLocalServerSchema,
|
|
7788
7831
|
OpencodeMcpRemoteServerSchema
|
|
7789
7832
|
]);
|
|
7790
|
-
var OpencodeConfigSchema =
|
|
7791
|
-
$schema:
|
|
7792
|
-
mcp:
|
|
7793
|
-
tools:
|
|
7833
|
+
var OpencodeConfigSchema = import_mini25.z.looseObject({
|
|
7834
|
+
$schema: import_mini25.z.optional(import_mini25.z.string()),
|
|
7835
|
+
mcp: import_mini25.z.optional(import_mini25.z.record(import_mini25.z.string(), OpencodeMcpServerSchema)),
|
|
7836
|
+
tools: import_mini25.z.optional(import_mini25.z.record(import_mini25.z.string(), import_mini25.z.boolean()))
|
|
7794
7837
|
});
|
|
7795
7838
|
function convertFromOpencodeFormat(opencodeMcp, tools) {
|
|
7796
7839
|
return Object.fromEntries(
|
|
@@ -8261,7 +8304,7 @@ var mcpProcessorToolTargetTuple = [
|
|
|
8261
8304
|
"roo",
|
|
8262
8305
|
"rovodev"
|
|
8263
8306
|
];
|
|
8264
|
-
var McpProcessorToolTargetSchema =
|
|
8307
|
+
var McpProcessorToolTargetSchema = import_mini26.z.enum(mcpProcessorToolTargetTuple);
|
|
8265
8308
|
var toolMcpFactories = /* @__PURE__ */ new Map([
|
|
8266
8309
|
[
|
|
8267
8310
|
"claudecode",
|
|
@@ -8602,7 +8645,7 @@ var McpProcessor = class extends FeatureProcessor {
|
|
|
8602
8645
|
// src/features/rules/rules-processor.ts
|
|
8603
8646
|
var import_node_path131 = require("path");
|
|
8604
8647
|
var import_toon = require("@toon-format/toon");
|
|
8605
|
-
var
|
|
8648
|
+
var import_mini65 = require("zod/mini");
|
|
8606
8649
|
|
|
8607
8650
|
// src/constants/general.ts
|
|
8608
8651
|
var SKILL_FILE_NAME = "SKILL.md";
|
|
@@ -8612,7 +8655,7 @@ var import_node_path65 = require("path");
|
|
|
8612
8655
|
|
|
8613
8656
|
// src/features/skills/simulated-skill.ts
|
|
8614
8657
|
var import_node_path64 = require("path");
|
|
8615
|
-
var
|
|
8658
|
+
var import_mini27 = require("zod/mini");
|
|
8616
8659
|
|
|
8617
8660
|
// src/features/skills/tool-skill.ts
|
|
8618
8661
|
var import_node_path63 = require("path");
|
|
@@ -8849,9 +8892,9 @@ var ToolSkill = class extends AiDir {
|
|
|
8849
8892
|
};
|
|
8850
8893
|
|
|
8851
8894
|
// src/features/skills/simulated-skill.ts
|
|
8852
|
-
var SimulatedSkillFrontmatterSchema =
|
|
8853
|
-
name:
|
|
8854
|
-
description:
|
|
8895
|
+
var SimulatedSkillFrontmatterSchema = import_mini27.z.looseObject({
|
|
8896
|
+
name: import_mini27.z.string(),
|
|
8897
|
+
description: import_mini27.z.string()
|
|
8855
8898
|
});
|
|
8856
8899
|
var SimulatedSkill = class extends ToolSkill {
|
|
8857
8900
|
frontmatter;
|
|
@@ -9078,49 +9121,49 @@ var FactorydroidSkill = class _FactorydroidSkill extends SimulatedSkill {
|
|
|
9078
9121
|
|
|
9079
9122
|
// src/features/skills/rovodev-skill.ts
|
|
9080
9123
|
var import_node_path68 = require("path");
|
|
9081
|
-
var
|
|
9124
|
+
var import_mini29 = require("zod/mini");
|
|
9082
9125
|
|
|
9083
9126
|
// src/features/skills/rulesync-skill.ts
|
|
9084
9127
|
var import_node_path67 = require("path");
|
|
9085
|
-
var
|
|
9086
|
-
var RulesyncSkillFrontmatterSchemaInternal =
|
|
9087
|
-
name:
|
|
9088
|
-
description:
|
|
9089
|
-
targets:
|
|
9090
|
-
claudecode:
|
|
9091
|
-
|
|
9092
|
-
"allowed-tools":
|
|
9093
|
-
model:
|
|
9094
|
-
"disable-model-invocation":
|
|
9128
|
+
var import_mini28 = require("zod/mini");
|
|
9129
|
+
var RulesyncSkillFrontmatterSchemaInternal = import_mini28.z.looseObject({
|
|
9130
|
+
name: import_mini28.z.string(),
|
|
9131
|
+
description: import_mini28.z.string(),
|
|
9132
|
+
targets: import_mini28.z._default(RulesyncTargetsSchema, ["*"]),
|
|
9133
|
+
claudecode: import_mini28.z.optional(
|
|
9134
|
+
import_mini28.z.looseObject({
|
|
9135
|
+
"allowed-tools": import_mini28.z.optional(import_mini28.z.array(import_mini28.z.string())),
|
|
9136
|
+
model: import_mini28.z.optional(import_mini28.z.string()),
|
|
9137
|
+
"disable-model-invocation": import_mini28.z.optional(import_mini28.z.boolean())
|
|
9095
9138
|
})
|
|
9096
9139
|
),
|
|
9097
|
-
codexcli:
|
|
9098
|
-
|
|
9099
|
-
"short-description":
|
|
9140
|
+
codexcli: import_mini28.z.optional(
|
|
9141
|
+
import_mini28.z.looseObject({
|
|
9142
|
+
"short-description": import_mini28.z.optional(import_mini28.z.string())
|
|
9100
9143
|
})
|
|
9101
9144
|
),
|
|
9102
|
-
opencode:
|
|
9103
|
-
|
|
9104
|
-
"allowed-tools":
|
|
9145
|
+
opencode: import_mini28.z.optional(
|
|
9146
|
+
import_mini28.z.looseObject({
|
|
9147
|
+
"allowed-tools": import_mini28.z.optional(import_mini28.z.array(import_mini28.z.string()))
|
|
9105
9148
|
})
|
|
9106
9149
|
),
|
|
9107
|
-
kilo:
|
|
9108
|
-
|
|
9109
|
-
"allowed-tools":
|
|
9150
|
+
kilo: import_mini28.z.optional(
|
|
9151
|
+
import_mini28.z.looseObject({
|
|
9152
|
+
"allowed-tools": import_mini28.z.optional(import_mini28.z.array(import_mini28.z.string()))
|
|
9110
9153
|
})
|
|
9111
9154
|
),
|
|
9112
|
-
deepagents:
|
|
9113
|
-
|
|
9114
|
-
"allowed-tools":
|
|
9155
|
+
deepagents: import_mini28.z.optional(
|
|
9156
|
+
import_mini28.z.looseObject({
|
|
9157
|
+
"allowed-tools": import_mini28.z.optional(import_mini28.z.array(import_mini28.z.string()))
|
|
9115
9158
|
})
|
|
9116
9159
|
),
|
|
9117
|
-
copilot:
|
|
9118
|
-
|
|
9119
|
-
license:
|
|
9160
|
+
copilot: import_mini28.z.optional(
|
|
9161
|
+
import_mini28.z.looseObject({
|
|
9162
|
+
license: import_mini28.z.optional(import_mini28.z.string())
|
|
9120
9163
|
})
|
|
9121
9164
|
),
|
|
9122
|
-
cline:
|
|
9123
|
-
roo:
|
|
9165
|
+
cline: import_mini28.z.optional(import_mini28.z.looseObject({})),
|
|
9166
|
+
roo: import_mini28.z.optional(import_mini28.z.looseObject({}))
|
|
9124
9167
|
});
|
|
9125
9168
|
var RulesyncSkillFrontmatterSchema = RulesyncSkillFrontmatterSchemaInternal;
|
|
9126
9169
|
var RulesyncSkill = class _RulesyncSkill extends AiDir {
|
|
@@ -9217,9 +9260,9 @@ var RulesyncSkill = class _RulesyncSkill extends AiDir {
|
|
|
9217
9260
|
};
|
|
9218
9261
|
|
|
9219
9262
|
// src/features/skills/rovodev-skill.ts
|
|
9220
|
-
var RovodevSkillFrontmatterSchema =
|
|
9221
|
-
name:
|
|
9222
|
-
description:
|
|
9263
|
+
var RovodevSkillFrontmatterSchema = import_mini29.z.looseObject({
|
|
9264
|
+
name: import_mini29.z.string(),
|
|
9265
|
+
description: import_mini29.z.string()
|
|
9223
9266
|
});
|
|
9224
9267
|
var RovodevSkill = class _RovodevSkill extends ToolSkill {
|
|
9225
9268
|
constructor({
|
|
@@ -9391,7 +9434,7 @@ var RovodevSkill = class _RovodevSkill extends ToolSkill {
|
|
|
9391
9434
|
|
|
9392
9435
|
// src/features/skills/skills-processor.ts
|
|
9393
9436
|
var import_node_path86 = require("path");
|
|
9394
|
-
var
|
|
9437
|
+
var import_mini45 = require("zod/mini");
|
|
9395
9438
|
|
|
9396
9439
|
// src/types/dir-feature-processor.ts
|
|
9397
9440
|
var import_node_path69 = require("path");
|
|
@@ -9530,10 +9573,10 @@ var DirFeatureProcessor = class {
|
|
|
9530
9573
|
|
|
9531
9574
|
// src/features/skills/agentsskills-skill.ts
|
|
9532
9575
|
var import_node_path70 = require("path");
|
|
9533
|
-
var
|
|
9534
|
-
var AgentsSkillsSkillFrontmatterSchema =
|
|
9535
|
-
name:
|
|
9536
|
-
description:
|
|
9576
|
+
var import_mini30 = require("zod/mini");
|
|
9577
|
+
var AgentsSkillsSkillFrontmatterSchema = import_mini30.z.looseObject({
|
|
9578
|
+
name: import_mini30.z.string(),
|
|
9579
|
+
description: import_mini30.z.string()
|
|
9537
9580
|
});
|
|
9538
9581
|
var AgentsSkillsSkill = class _AgentsSkillsSkill extends ToolSkill {
|
|
9539
9582
|
constructor({
|
|
@@ -9688,10 +9731,10 @@ var AgentsSkillsSkill = class _AgentsSkillsSkill extends ToolSkill {
|
|
|
9688
9731
|
|
|
9689
9732
|
// src/features/skills/antigravity-skill.ts
|
|
9690
9733
|
var import_node_path71 = require("path");
|
|
9691
|
-
var
|
|
9692
|
-
var AntigravitySkillFrontmatterSchema =
|
|
9693
|
-
name:
|
|
9694
|
-
description:
|
|
9734
|
+
var import_mini31 = require("zod/mini");
|
|
9735
|
+
var AntigravitySkillFrontmatterSchema = import_mini31.z.looseObject({
|
|
9736
|
+
name: import_mini31.z.string(),
|
|
9737
|
+
description: import_mini31.z.string()
|
|
9695
9738
|
});
|
|
9696
9739
|
var AntigravitySkill = class _AntigravitySkill extends ToolSkill {
|
|
9697
9740
|
constructor({
|
|
@@ -9849,13 +9892,13 @@ var AntigravitySkill = class _AntigravitySkill extends ToolSkill {
|
|
|
9849
9892
|
|
|
9850
9893
|
// src/features/skills/claudecode-skill.ts
|
|
9851
9894
|
var import_node_path72 = require("path");
|
|
9852
|
-
var
|
|
9853
|
-
var ClaudecodeSkillFrontmatterSchema =
|
|
9854
|
-
name:
|
|
9855
|
-
description:
|
|
9856
|
-
"allowed-tools":
|
|
9857
|
-
model:
|
|
9858
|
-
"disable-model-invocation":
|
|
9895
|
+
var import_mini32 = require("zod/mini");
|
|
9896
|
+
var ClaudecodeSkillFrontmatterSchema = import_mini32.z.looseObject({
|
|
9897
|
+
name: import_mini32.z.string(),
|
|
9898
|
+
description: import_mini32.z.string(),
|
|
9899
|
+
"allowed-tools": import_mini32.z.optional(import_mini32.z.array(import_mini32.z.string())),
|
|
9900
|
+
model: import_mini32.z.optional(import_mini32.z.string()),
|
|
9901
|
+
"disable-model-invocation": import_mini32.z.optional(import_mini32.z.boolean())
|
|
9859
9902
|
});
|
|
9860
9903
|
var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
|
|
9861
9904
|
constructor({
|
|
@@ -10025,10 +10068,10 @@ var ClaudecodeSkill = class _ClaudecodeSkill extends ToolSkill {
|
|
|
10025
10068
|
|
|
10026
10069
|
// src/features/skills/cline-skill.ts
|
|
10027
10070
|
var import_node_path73 = require("path");
|
|
10028
|
-
var
|
|
10029
|
-
var ClineSkillFrontmatterSchema =
|
|
10030
|
-
name:
|
|
10031
|
-
description:
|
|
10071
|
+
var import_mini33 = require("zod/mini");
|
|
10072
|
+
var ClineSkillFrontmatterSchema = import_mini33.z.looseObject({
|
|
10073
|
+
name: import_mini33.z.string(),
|
|
10074
|
+
description: import_mini33.z.string()
|
|
10032
10075
|
});
|
|
10033
10076
|
var ClineSkill = class _ClineSkill extends ToolSkill {
|
|
10034
10077
|
constructor({
|
|
@@ -10198,13 +10241,13 @@ var ClineSkill = class _ClineSkill extends ToolSkill {
|
|
|
10198
10241
|
|
|
10199
10242
|
// src/features/skills/codexcli-skill.ts
|
|
10200
10243
|
var import_node_path74 = require("path");
|
|
10201
|
-
var
|
|
10202
|
-
var CodexCliSkillFrontmatterSchema =
|
|
10203
|
-
name:
|
|
10204
|
-
description:
|
|
10205
|
-
metadata:
|
|
10206
|
-
|
|
10207
|
-
"short-description":
|
|
10244
|
+
var import_mini34 = require("zod/mini");
|
|
10245
|
+
var CodexCliSkillFrontmatterSchema = import_mini34.z.looseObject({
|
|
10246
|
+
name: import_mini34.z.string(),
|
|
10247
|
+
description: import_mini34.z.string(),
|
|
10248
|
+
metadata: import_mini34.z.optional(
|
|
10249
|
+
import_mini34.z.looseObject({
|
|
10250
|
+
"short-description": import_mini34.z.optional(import_mini34.z.string())
|
|
10208
10251
|
})
|
|
10209
10252
|
)
|
|
10210
10253
|
});
|
|
@@ -10369,11 +10412,11 @@ var CodexCliSkill = class _CodexCliSkill extends ToolSkill {
|
|
|
10369
10412
|
|
|
10370
10413
|
// src/features/skills/copilot-skill.ts
|
|
10371
10414
|
var import_node_path75 = require("path");
|
|
10372
|
-
var
|
|
10373
|
-
var CopilotSkillFrontmatterSchema =
|
|
10374
|
-
name:
|
|
10375
|
-
description:
|
|
10376
|
-
license:
|
|
10415
|
+
var import_mini35 = require("zod/mini");
|
|
10416
|
+
var CopilotSkillFrontmatterSchema = import_mini35.z.looseObject({
|
|
10417
|
+
name: import_mini35.z.string(),
|
|
10418
|
+
description: import_mini35.z.string(),
|
|
10419
|
+
license: import_mini35.z.optional(import_mini35.z.string())
|
|
10377
10420
|
});
|
|
10378
10421
|
var CopilotSkill = class _CopilotSkill extends ToolSkill {
|
|
10379
10422
|
constructor({
|
|
@@ -10534,10 +10577,10 @@ var CopilotSkill = class _CopilotSkill extends ToolSkill {
|
|
|
10534
10577
|
|
|
10535
10578
|
// src/features/skills/cursor-skill.ts
|
|
10536
10579
|
var import_node_path76 = require("path");
|
|
10537
|
-
var
|
|
10538
|
-
var CursorSkillFrontmatterSchema =
|
|
10539
|
-
name:
|
|
10540
|
-
description:
|
|
10580
|
+
var import_mini36 = require("zod/mini");
|
|
10581
|
+
var CursorSkillFrontmatterSchema = import_mini36.z.looseObject({
|
|
10582
|
+
name: import_mini36.z.string(),
|
|
10583
|
+
description: import_mini36.z.string()
|
|
10541
10584
|
});
|
|
10542
10585
|
var CursorSkill = class _CursorSkill extends ToolSkill {
|
|
10543
10586
|
constructor({
|
|
@@ -10689,11 +10732,11 @@ var CursorSkill = class _CursorSkill extends ToolSkill {
|
|
|
10689
10732
|
|
|
10690
10733
|
// src/features/skills/deepagents-skill.ts
|
|
10691
10734
|
var import_node_path77 = require("path");
|
|
10692
|
-
var
|
|
10693
|
-
var DeepagentsSkillFrontmatterSchema =
|
|
10694
|
-
name:
|
|
10695
|
-
description:
|
|
10696
|
-
"allowed-tools":
|
|
10735
|
+
var import_mini37 = require("zod/mini");
|
|
10736
|
+
var DeepagentsSkillFrontmatterSchema = import_mini37.z.looseObject({
|
|
10737
|
+
name: import_mini37.z.string(),
|
|
10738
|
+
description: import_mini37.z.string(),
|
|
10739
|
+
"allowed-tools": import_mini37.z.optional(import_mini37.z.array(import_mini37.z.string()))
|
|
10697
10740
|
});
|
|
10698
10741
|
var DeepagentsSkill = class _DeepagentsSkill extends ToolSkill {
|
|
10699
10742
|
constructor({
|
|
@@ -10851,10 +10894,10 @@ var DeepagentsSkill = class _DeepagentsSkill extends ToolSkill {
|
|
|
10851
10894
|
|
|
10852
10895
|
// src/features/skills/geminicli-skill.ts
|
|
10853
10896
|
var import_node_path78 = require("path");
|
|
10854
|
-
var
|
|
10855
|
-
var GeminiCliSkillFrontmatterSchema =
|
|
10856
|
-
name:
|
|
10857
|
-
description:
|
|
10897
|
+
var import_mini38 = require("zod/mini");
|
|
10898
|
+
var GeminiCliSkillFrontmatterSchema = import_mini38.z.looseObject({
|
|
10899
|
+
name: import_mini38.z.string(),
|
|
10900
|
+
description: import_mini38.z.string()
|
|
10858
10901
|
});
|
|
10859
10902
|
var GeminiCliSkill = class _GeminiCliSkill extends ToolSkill {
|
|
10860
10903
|
constructor({
|
|
@@ -11008,10 +11051,10 @@ var GeminiCliSkill = class _GeminiCliSkill extends ToolSkill {
|
|
|
11008
11051
|
|
|
11009
11052
|
// src/features/skills/junie-skill.ts
|
|
11010
11053
|
var import_node_path79 = require("path");
|
|
11011
|
-
var
|
|
11012
|
-
var JunieSkillFrontmatterSchema =
|
|
11013
|
-
name:
|
|
11014
|
-
description:
|
|
11054
|
+
var import_mini39 = require("zod/mini");
|
|
11055
|
+
var JunieSkillFrontmatterSchema = import_mini39.z.looseObject({
|
|
11056
|
+
name: import_mini39.z.string(),
|
|
11057
|
+
description: import_mini39.z.string()
|
|
11015
11058
|
});
|
|
11016
11059
|
var JunieSkill = class _JunieSkill extends ToolSkill {
|
|
11017
11060
|
constructor({
|
|
@@ -11184,11 +11227,11 @@ var JunieSkill = class _JunieSkill extends ToolSkill {
|
|
|
11184
11227
|
|
|
11185
11228
|
// src/features/skills/kilo-skill.ts
|
|
11186
11229
|
var import_node_path80 = require("path");
|
|
11187
|
-
var
|
|
11188
|
-
var KiloSkillFrontmatterSchema =
|
|
11189
|
-
name:
|
|
11190
|
-
description:
|
|
11191
|
-
"allowed-tools":
|
|
11230
|
+
var import_mini40 = require("zod/mini");
|
|
11231
|
+
var KiloSkillFrontmatterSchema = import_mini40.z.looseObject({
|
|
11232
|
+
name: import_mini40.z.string(),
|
|
11233
|
+
description: import_mini40.z.string(),
|
|
11234
|
+
"allowed-tools": import_mini40.z.optional(import_mini40.z.array(import_mini40.z.string()))
|
|
11192
11235
|
});
|
|
11193
11236
|
var KiloSkill = class _KiloSkill extends ToolSkill {
|
|
11194
11237
|
constructor({
|
|
@@ -11345,10 +11388,10 @@ var KiloSkill = class _KiloSkill extends ToolSkill {
|
|
|
11345
11388
|
|
|
11346
11389
|
// src/features/skills/kiro-skill.ts
|
|
11347
11390
|
var import_node_path81 = require("path");
|
|
11348
|
-
var
|
|
11349
|
-
var KiroSkillFrontmatterSchema =
|
|
11350
|
-
name:
|
|
11351
|
-
description:
|
|
11391
|
+
var import_mini41 = require("zod/mini");
|
|
11392
|
+
var KiroSkillFrontmatterSchema = import_mini41.z.looseObject({
|
|
11393
|
+
name: import_mini41.z.string(),
|
|
11394
|
+
description: import_mini41.z.string()
|
|
11352
11395
|
});
|
|
11353
11396
|
var KiroSkill = class _KiroSkill extends ToolSkill {
|
|
11354
11397
|
constructor({
|
|
@@ -11522,11 +11565,11 @@ var KiroSkill = class _KiroSkill extends ToolSkill {
|
|
|
11522
11565
|
|
|
11523
11566
|
// src/features/skills/opencode-skill.ts
|
|
11524
11567
|
var import_node_path82 = require("path");
|
|
11525
|
-
var
|
|
11526
|
-
var OpenCodeSkillFrontmatterSchema =
|
|
11527
|
-
name:
|
|
11528
|
-
description:
|
|
11529
|
-
"allowed-tools":
|
|
11568
|
+
var import_mini42 = require("zod/mini");
|
|
11569
|
+
var OpenCodeSkillFrontmatterSchema = import_mini42.z.looseObject({
|
|
11570
|
+
name: import_mini42.z.string(),
|
|
11571
|
+
description: import_mini42.z.string(),
|
|
11572
|
+
"allowed-tools": import_mini42.z.optional(import_mini42.z.array(import_mini42.z.string()))
|
|
11530
11573
|
});
|
|
11531
11574
|
var OpenCodeSkill = class _OpenCodeSkill extends ToolSkill {
|
|
11532
11575
|
constructor({
|
|
@@ -11683,10 +11726,10 @@ var OpenCodeSkill = class _OpenCodeSkill extends ToolSkill {
|
|
|
11683
11726
|
|
|
11684
11727
|
// src/features/skills/replit-skill.ts
|
|
11685
11728
|
var import_node_path83 = require("path");
|
|
11686
|
-
var
|
|
11687
|
-
var ReplitSkillFrontmatterSchema =
|
|
11688
|
-
name:
|
|
11689
|
-
description:
|
|
11729
|
+
var import_mini43 = require("zod/mini");
|
|
11730
|
+
var ReplitSkillFrontmatterSchema = import_mini43.z.looseObject({
|
|
11731
|
+
name: import_mini43.z.string(),
|
|
11732
|
+
description: import_mini43.z.string()
|
|
11690
11733
|
});
|
|
11691
11734
|
var ReplitSkill = class _ReplitSkill extends ToolSkill {
|
|
11692
11735
|
constructor({
|
|
@@ -11841,10 +11884,10 @@ var ReplitSkill = class _ReplitSkill extends ToolSkill {
|
|
|
11841
11884
|
|
|
11842
11885
|
// src/features/skills/roo-skill.ts
|
|
11843
11886
|
var import_node_path84 = require("path");
|
|
11844
|
-
var
|
|
11845
|
-
var RooSkillFrontmatterSchema =
|
|
11846
|
-
name:
|
|
11847
|
-
description:
|
|
11887
|
+
var import_mini44 = require("zod/mini");
|
|
11888
|
+
var RooSkillFrontmatterSchema = import_mini44.z.looseObject({
|
|
11889
|
+
name: import_mini44.z.string(),
|
|
11890
|
+
description: import_mini44.z.string()
|
|
11848
11891
|
});
|
|
11849
11892
|
var RooSkill = class _RooSkill extends ToolSkill {
|
|
11850
11893
|
constructor({
|
|
@@ -12053,7 +12096,7 @@ var skillsProcessorToolTargetTuple = [
|
|
|
12053
12096
|
"roo",
|
|
12054
12097
|
"rovodev"
|
|
12055
12098
|
];
|
|
12056
|
-
var SkillsProcessorToolTargetSchema =
|
|
12099
|
+
var SkillsProcessorToolTargetSchema = import_mini45.z.enum(skillsProcessorToolTargetTuple);
|
|
12057
12100
|
var toolSkillFactories = /* @__PURE__ */ new Map([
|
|
12058
12101
|
[
|
|
12059
12102
|
"agentsmd",
|
|
@@ -12425,7 +12468,7 @@ var import_node_path88 = require("path");
|
|
|
12425
12468
|
|
|
12426
12469
|
// src/features/subagents/simulated-subagent.ts
|
|
12427
12470
|
var import_node_path87 = require("path");
|
|
12428
|
-
var
|
|
12471
|
+
var import_mini46 = require("zod/mini");
|
|
12429
12472
|
|
|
12430
12473
|
// src/features/subagents/tool-subagent.ts
|
|
12431
12474
|
var ToolSubagent = class extends ToolFile {
|
|
@@ -12477,9 +12520,9 @@ var ToolSubagent = class extends ToolFile {
|
|
|
12477
12520
|
};
|
|
12478
12521
|
|
|
12479
12522
|
// src/features/subagents/simulated-subagent.ts
|
|
12480
|
-
var SimulatedSubagentFrontmatterSchema =
|
|
12481
|
-
name:
|
|
12482
|
-
description:
|
|
12523
|
+
var SimulatedSubagentFrontmatterSchema = import_mini46.z.object({
|
|
12524
|
+
name: import_mini46.z.string(),
|
|
12525
|
+
description: import_mini46.z.optional(import_mini46.z.string())
|
|
12483
12526
|
});
|
|
12484
12527
|
var SimulatedSubagent = class extends ToolSubagent {
|
|
12485
12528
|
frontmatter;
|
|
@@ -12637,15 +12680,15 @@ var FactorydroidSubagent = class _FactorydroidSubagent extends SimulatedSubagent
|
|
|
12637
12680
|
|
|
12638
12681
|
// src/features/subagents/geminicli-subagent.ts
|
|
12639
12682
|
var import_node_path91 = require("path");
|
|
12640
|
-
var
|
|
12683
|
+
var import_mini48 = require("zod/mini");
|
|
12641
12684
|
|
|
12642
12685
|
// src/features/subagents/rulesync-subagent.ts
|
|
12643
12686
|
var import_node_path90 = require("path");
|
|
12644
|
-
var
|
|
12645
|
-
var RulesyncSubagentFrontmatterSchema =
|
|
12646
|
-
targets:
|
|
12647
|
-
name:
|
|
12648
|
-
description:
|
|
12687
|
+
var import_mini47 = require("zod/mini");
|
|
12688
|
+
var RulesyncSubagentFrontmatterSchema = import_mini47.z.looseObject({
|
|
12689
|
+
targets: import_mini47.z._default(RulesyncTargetsSchema, ["*"]),
|
|
12690
|
+
name: import_mini47.z.string(),
|
|
12691
|
+
description: import_mini47.z.optional(import_mini47.z.string())
|
|
12649
12692
|
});
|
|
12650
12693
|
var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
12651
12694
|
frontmatter;
|
|
@@ -12714,9 +12757,9 @@ var RulesyncSubagent = class _RulesyncSubagent extends RulesyncFile {
|
|
|
12714
12757
|
};
|
|
12715
12758
|
|
|
12716
12759
|
// src/features/subagents/geminicli-subagent.ts
|
|
12717
|
-
var GeminiCliSubagentFrontmatterSchema =
|
|
12718
|
-
name:
|
|
12719
|
-
description:
|
|
12760
|
+
var GeminiCliSubagentFrontmatterSchema = import_mini48.z.looseObject({
|
|
12761
|
+
name: import_mini48.z.string(),
|
|
12762
|
+
description: import_mini48.z.optional(import_mini48.z.string())
|
|
12720
12763
|
});
|
|
12721
12764
|
var GeminiCliSubagent = class _GeminiCliSubagent extends ToolSubagent {
|
|
12722
12765
|
frontmatter;
|
|
@@ -12889,10 +12932,10 @@ var RooSubagent = class _RooSubagent extends SimulatedSubagent {
|
|
|
12889
12932
|
|
|
12890
12933
|
// src/features/subagents/rovodev-subagent.ts
|
|
12891
12934
|
var import_node_path93 = require("path");
|
|
12892
|
-
var
|
|
12893
|
-
var RovodevSubagentFrontmatterSchema =
|
|
12894
|
-
name:
|
|
12895
|
-
description:
|
|
12935
|
+
var import_mini49 = require("zod/mini");
|
|
12936
|
+
var RovodevSubagentFrontmatterSchema = import_mini49.z.looseObject({
|
|
12937
|
+
name: import_mini49.z.string(),
|
|
12938
|
+
description: import_mini49.z.optional(import_mini49.z.string())
|
|
12896
12939
|
});
|
|
12897
12940
|
var RovodevSubagent = class _RovodevSubagent extends ToolSubagent {
|
|
12898
12941
|
frontmatter;
|
|
@@ -13034,18 +13077,18 @@ var RovodevSubagent = class _RovodevSubagent extends ToolSubagent {
|
|
|
13034
13077
|
|
|
13035
13078
|
// src/features/subagents/subagents-processor.ts
|
|
13036
13079
|
var import_node_path104 = require("path");
|
|
13037
|
-
var
|
|
13080
|
+
var import_mini58 = require("zod/mini");
|
|
13038
13081
|
|
|
13039
13082
|
// src/features/subagents/claudecode-subagent.ts
|
|
13040
13083
|
var import_node_path94 = require("path");
|
|
13041
|
-
var
|
|
13042
|
-
var ClaudecodeSubagentFrontmatterSchema =
|
|
13043
|
-
name:
|
|
13044
|
-
description:
|
|
13045
|
-
model:
|
|
13046
|
-
tools:
|
|
13047
|
-
permissionMode:
|
|
13048
|
-
skills:
|
|
13084
|
+
var import_mini50 = require("zod/mini");
|
|
13085
|
+
var ClaudecodeSubagentFrontmatterSchema = import_mini50.z.looseObject({
|
|
13086
|
+
name: import_mini50.z.string(),
|
|
13087
|
+
description: import_mini50.z.optional(import_mini50.z.string()),
|
|
13088
|
+
model: import_mini50.z.optional(import_mini50.z.string()),
|
|
13089
|
+
tools: import_mini50.z.optional(import_mini50.z.union([import_mini50.z.string(), import_mini50.z.array(import_mini50.z.string())])),
|
|
13090
|
+
permissionMode: import_mini50.z.optional(import_mini50.z.string()),
|
|
13091
|
+
skills: import_mini50.z.optional(import_mini50.z.union([import_mini50.z.string(), import_mini50.z.array(import_mini50.z.string())]))
|
|
13049
13092
|
});
|
|
13050
13093
|
var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
13051
13094
|
frontmatter;
|
|
@@ -13201,14 +13244,14 @@ var ClaudecodeSubagent = class _ClaudecodeSubagent extends ToolSubagent {
|
|
|
13201
13244
|
// src/features/subagents/codexcli-subagent.ts
|
|
13202
13245
|
var import_node_path95 = require("path");
|
|
13203
13246
|
var smolToml4 = __toESM(require("smol-toml"), 1);
|
|
13204
|
-
var
|
|
13205
|
-
var CodexCliSubagentTomlSchema =
|
|
13206
|
-
name:
|
|
13207
|
-
description:
|
|
13208
|
-
developer_instructions:
|
|
13209
|
-
model:
|
|
13210
|
-
model_reasoning_effort:
|
|
13211
|
-
sandbox_mode:
|
|
13247
|
+
var import_mini51 = require("zod/mini");
|
|
13248
|
+
var CodexCliSubagentTomlSchema = import_mini51.z.looseObject({
|
|
13249
|
+
name: import_mini51.z.string(),
|
|
13250
|
+
description: import_mini51.z.optional(import_mini51.z.string()),
|
|
13251
|
+
developer_instructions: import_mini51.z.optional(import_mini51.z.string()),
|
|
13252
|
+
model: import_mini51.z.optional(import_mini51.z.string()),
|
|
13253
|
+
model_reasoning_effort: import_mini51.z.optional(import_mini51.z.string()),
|
|
13254
|
+
sandbox_mode: import_mini51.z.optional(import_mini51.z.string())
|
|
13212
13255
|
});
|
|
13213
13256
|
var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
|
|
13214
13257
|
body;
|
|
@@ -13363,12 +13406,12 @@ var CodexCliSubagent = class _CodexCliSubagent extends ToolSubagent {
|
|
|
13363
13406
|
|
|
13364
13407
|
// src/features/subagents/copilot-subagent.ts
|
|
13365
13408
|
var import_node_path96 = require("path");
|
|
13366
|
-
var
|
|
13409
|
+
var import_mini52 = require("zod/mini");
|
|
13367
13410
|
var REQUIRED_TOOL = "agent/runSubagent";
|
|
13368
|
-
var CopilotSubagentFrontmatterSchema =
|
|
13369
|
-
name:
|
|
13370
|
-
description:
|
|
13371
|
-
tools:
|
|
13411
|
+
var CopilotSubagentFrontmatterSchema = import_mini52.z.looseObject({
|
|
13412
|
+
name: import_mini52.z.string(),
|
|
13413
|
+
description: import_mini52.z.optional(import_mini52.z.string()),
|
|
13414
|
+
tools: import_mini52.z.optional(import_mini52.z.union([import_mini52.z.string(), import_mini52.z.array(import_mini52.z.string())]))
|
|
13372
13415
|
});
|
|
13373
13416
|
var normalizeTools = (tools) => {
|
|
13374
13417
|
if (!tools) {
|
|
@@ -13529,10 +13572,10 @@ var CopilotSubagent = class _CopilotSubagent extends ToolSubagent {
|
|
|
13529
13572
|
|
|
13530
13573
|
// src/features/subagents/cursor-subagent.ts
|
|
13531
13574
|
var import_node_path97 = require("path");
|
|
13532
|
-
var
|
|
13533
|
-
var CursorSubagentFrontmatterSchema =
|
|
13534
|
-
name:
|
|
13535
|
-
description:
|
|
13575
|
+
var import_mini53 = require("zod/mini");
|
|
13576
|
+
var CursorSubagentFrontmatterSchema = import_mini53.z.looseObject({
|
|
13577
|
+
name: import_mini53.z.string(),
|
|
13578
|
+
description: import_mini53.z.optional(import_mini53.z.string())
|
|
13536
13579
|
});
|
|
13537
13580
|
var CursorSubagent = class _CursorSubagent extends ToolSubagent {
|
|
13538
13581
|
frontmatter;
|
|
@@ -13676,11 +13719,11 @@ var CursorSubagent = class _CursorSubagent extends ToolSubagent {
|
|
|
13676
13719
|
|
|
13677
13720
|
// src/features/subagents/deepagents-subagent.ts
|
|
13678
13721
|
var import_node_path98 = require("path");
|
|
13679
|
-
var
|
|
13680
|
-
var DeepagentsSubagentFrontmatterSchema =
|
|
13681
|
-
name:
|
|
13682
|
-
description:
|
|
13683
|
-
model:
|
|
13722
|
+
var import_mini54 = require("zod/mini");
|
|
13723
|
+
var DeepagentsSubagentFrontmatterSchema = import_mini54.z.looseObject({
|
|
13724
|
+
name: import_mini54.z.string(),
|
|
13725
|
+
description: import_mini54.z.optional(import_mini54.z.string()),
|
|
13726
|
+
model: import_mini54.z.optional(import_mini54.z.string())
|
|
13684
13727
|
});
|
|
13685
13728
|
var DeepagentsSubagent = class _DeepagentsSubagent extends ToolSubagent {
|
|
13686
13729
|
frontmatter;
|
|
@@ -13829,10 +13872,10 @@ var DeepagentsSubagent = class _DeepagentsSubagent extends ToolSubagent {
|
|
|
13829
13872
|
|
|
13830
13873
|
// src/features/subagents/junie-subagent.ts
|
|
13831
13874
|
var import_node_path99 = require("path");
|
|
13832
|
-
var
|
|
13833
|
-
var JunieSubagentFrontmatterSchema =
|
|
13834
|
-
name:
|
|
13835
|
-
description:
|
|
13875
|
+
var import_mini55 = require("zod/mini");
|
|
13876
|
+
var JunieSubagentFrontmatterSchema = import_mini55.z.looseObject({
|
|
13877
|
+
name: import_mini55.z.optional(import_mini55.z.string()),
|
|
13878
|
+
description: import_mini55.z.string()
|
|
13836
13879
|
});
|
|
13837
13880
|
var JunieSubagent = class _JunieSubagent extends ToolSubagent {
|
|
13838
13881
|
frontmatter;
|
|
@@ -13990,11 +14033,11 @@ var import_node_path101 = require("path");
|
|
|
13990
14033
|
|
|
13991
14034
|
// src/features/subagents/opencode-style-subagent.ts
|
|
13992
14035
|
var import_node_path100 = require("path");
|
|
13993
|
-
var
|
|
13994
|
-
var OpenCodeStyleSubagentFrontmatterSchema =
|
|
13995
|
-
description:
|
|
13996
|
-
mode:
|
|
13997
|
-
name:
|
|
14036
|
+
var import_mini56 = require("zod/mini");
|
|
14037
|
+
var OpenCodeStyleSubagentFrontmatterSchema = import_mini56.z.looseObject({
|
|
14038
|
+
description: import_mini56.z.optional(import_mini56.z.string()),
|
|
14039
|
+
mode: import_mini56.z._default(import_mini56.z.string(), "subagent"),
|
|
14040
|
+
name: import_mini56.z.optional(import_mini56.z.string())
|
|
13998
14041
|
});
|
|
13999
14042
|
var OpenCodeStyleSubagent = class extends ToolSubagent {
|
|
14000
14043
|
frontmatter;
|
|
@@ -14143,22 +14186,22 @@ var KiloSubagent = class _KiloSubagent extends OpenCodeStyleSubagent {
|
|
|
14143
14186
|
|
|
14144
14187
|
// src/features/subagents/kiro-subagent.ts
|
|
14145
14188
|
var import_node_path102 = require("path");
|
|
14146
|
-
var
|
|
14147
|
-
var KiroCliSubagentJsonSchema =
|
|
14148
|
-
name:
|
|
14149
|
-
description:
|
|
14150
|
-
prompt:
|
|
14151
|
-
tools:
|
|
14152
|
-
toolAliases:
|
|
14153
|
-
toolSettings:
|
|
14154
|
-
toolSchema:
|
|
14155
|
-
hooks:
|
|
14156
|
-
model:
|
|
14157
|
-
mcpServers:
|
|
14158
|
-
useLegacyMcpJson:
|
|
14159
|
-
resources:
|
|
14160
|
-
allowedTools:
|
|
14161
|
-
includeMcpJson:
|
|
14189
|
+
var import_mini57 = require("zod/mini");
|
|
14190
|
+
var KiroCliSubagentJsonSchema = import_mini57.z.looseObject({
|
|
14191
|
+
name: import_mini57.z.string(),
|
|
14192
|
+
description: import_mini57.z.optional(import_mini57.z.nullable(import_mini57.z.string())),
|
|
14193
|
+
prompt: import_mini57.z.optional(import_mini57.z.nullable(import_mini57.z.string())),
|
|
14194
|
+
tools: import_mini57.z.optional(import_mini57.z.nullable(import_mini57.z.array(import_mini57.z.string()))),
|
|
14195
|
+
toolAliases: import_mini57.z.optional(import_mini57.z.nullable(import_mini57.z.record(import_mini57.z.string(), import_mini57.z.string()))),
|
|
14196
|
+
toolSettings: import_mini57.z.optional(import_mini57.z.nullable(import_mini57.z.unknown())),
|
|
14197
|
+
toolSchema: import_mini57.z.optional(import_mini57.z.nullable(import_mini57.z.unknown())),
|
|
14198
|
+
hooks: import_mini57.z.optional(import_mini57.z.nullable(import_mini57.z.record(import_mini57.z.string(), import_mini57.z.array(import_mini57.z.unknown())))),
|
|
14199
|
+
model: import_mini57.z.optional(import_mini57.z.nullable(import_mini57.z.string())),
|
|
14200
|
+
mcpServers: import_mini57.z.optional(import_mini57.z.nullable(import_mini57.z.record(import_mini57.z.string(), import_mini57.z.unknown()))),
|
|
14201
|
+
useLegacyMcpJson: import_mini57.z.optional(import_mini57.z.nullable(import_mini57.z.boolean())),
|
|
14202
|
+
resources: import_mini57.z.optional(import_mini57.z.nullable(import_mini57.z.array(import_mini57.z.string()))),
|
|
14203
|
+
allowedTools: import_mini57.z.optional(import_mini57.z.nullable(import_mini57.z.array(import_mini57.z.string()))),
|
|
14204
|
+
includeMcpJson: import_mini57.z.optional(import_mini57.z.nullable(import_mini57.z.boolean()))
|
|
14162
14205
|
});
|
|
14163
14206
|
var KiroSubagent = class _KiroSubagent extends ToolSubagent {
|
|
14164
14207
|
body;
|
|
@@ -14419,7 +14462,7 @@ var subagentsProcessorToolTargetTuple = [
|
|
|
14419
14462
|
"roo",
|
|
14420
14463
|
"rovodev"
|
|
14421
14464
|
];
|
|
14422
|
-
var SubagentsProcessorToolTargetSchema =
|
|
14465
|
+
var SubagentsProcessorToolTargetSchema = import_mini58.z.enum(subagentsProcessorToolTargetTuple);
|
|
14423
14466
|
var toolSubagentFactories = /* @__PURE__ */ new Map([
|
|
14424
14467
|
[
|
|
14425
14468
|
"agentsmd",
|
|
@@ -14729,42 +14772,42 @@ var import_node_path106 = require("path");
|
|
|
14729
14772
|
|
|
14730
14773
|
// src/features/rules/rulesync-rule.ts
|
|
14731
14774
|
var import_node_path105 = require("path");
|
|
14732
|
-
var
|
|
14733
|
-
var RulesyncRuleFrontmatterSchema =
|
|
14734
|
-
root:
|
|
14735
|
-
localRoot:
|
|
14736
|
-
targets:
|
|
14737
|
-
description:
|
|
14738
|
-
globs:
|
|
14739
|
-
agentsmd:
|
|
14740
|
-
|
|
14775
|
+
var import_mini59 = require("zod/mini");
|
|
14776
|
+
var RulesyncRuleFrontmatterSchema = import_mini59.z.object({
|
|
14777
|
+
root: import_mini59.z.optional(import_mini59.z.boolean()),
|
|
14778
|
+
localRoot: import_mini59.z.optional(import_mini59.z.boolean()),
|
|
14779
|
+
targets: import_mini59.z._default(RulesyncTargetsSchema, ["*"]),
|
|
14780
|
+
description: import_mini59.z.optional(import_mini59.z.string()),
|
|
14781
|
+
globs: import_mini59.z.optional(import_mini59.z.array(import_mini59.z.string())),
|
|
14782
|
+
agentsmd: import_mini59.z.optional(
|
|
14783
|
+
import_mini59.z.looseObject({
|
|
14741
14784
|
// @example "path/to/subproject"
|
|
14742
|
-
subprojectPath:
|
|
14785
|
+
subprojectPath: import_mini59.z.optional(import_mini59.z.string())
|
|
14743
14786
|
})
|
|
14744
14787
|
),
|
|
14745
|
-
claudecode:
|
|
14746
|
-
|
|
14788
|
+
claudecode: import_mini59.z.optional(
|
|
14789
|
+
import_mini59.z.looseObject({
|
|
14747
14790
|
// Glob patterns for conditional rules (takes precedence over globs)
|
|
14748
14791
|
// @example ["src/**/*.ts", "tests/**/*.test.ts"]
|
|
14749
|
-
paths:
|
|
14792
|
+
paths: import_mini59.z.optional(import_mini59.z.array(import_mini59.z.string()))
|
|
14750
14793
|
})
|
|
14751
14794
|
),
|
|
14752
|
-
cursor:
|
|
14753
|
-
|
|
14754
|
-
alwaysApply:
|
|
14755
|
-
description:
|
|
14756
|
-
globs:
|
|
14795
|
+
cursor: import_mini59.z.optional(
|
|
14796
|
+
import_mini59.z.looseObject({
|
|
14797
|
+
alwaysApply: import_mini59.z.optional(import_mini59.z.boolean()),
|
|
14798
|
+
description: import_mini59.z.optional(import_mini59.z.string()),
|
|
14799
|
+
globs: import_mini59.z.optional(import_mini59.z.array(import_mini59.z.string()))
|
|
14757
14800
|
})
|
|
14758
14801
|
),
|
|
14759
|
-
copilot:
|
|
14760
|
-
|
|
14761
|
-
excludeAgent:
|
|
14802
|
+
copilot: import_mini59.z.optional(
|
|
14803
|
+
import_mini59.z.looseObject({
|
|
14804
|
+
excludeAgent: import_mini59.z.optional(import_mini59.z.union([import_mini59.z.literal("code-review"), import_mini59.z.literal("coding-agent")]))
|
|
14762
14805
|
})
|
|
14763
14806
|
),
|
|
14764
|
-
antigravity:
|
|
14765
|
-
|
|
14766
|
-
trigger:
|
|
14767
|
-
globs:
|
|
14807
|
+
antigravity: import_mini59.z.optional(
|
|
14808
|
+
import_mini59.z.looseObject({
|
|
14809
|
+
trigger: import_mini59.z.optional(import_mini59.z.string()),
|
|
14810
|
+
globs: import_mini59.z.optional(import_mini59.z.array(import_mini59.z.string()))
|
|
14768
14811
|
})
|
|
14769
14812
|
)
|
|
14770
14813
|
});
|
|
@@ -15064,20 +15107,20 @@ var AgentsMdRule = class _AgentsMdRule extends ToolRule {
|
|
|
15064
15107
|
|
|
15065
15108
|
// src/features/rules/antigravity-rule.ts
|
|
15066
15109
|
var import_node_path108 = require("path");
|
|
15067
|
-
var
|
|
15068
|
-
var AntigravityRuleFrontmatterSchema =
|
|
15069
|
-
trigger:
|
|
15070
|
-
|
|
15071
|
-
|
|
15072
|
-
|
|
15073
|
-
|
|
15074
|
-
|
|
15075
|
-
|
|
15110
|
+
var import_mini60 = require("zod/mini");
|
|
15111
|
+
var AntigravityRuleFrontmatterSchema = import_mini60.z.looseObject({
|
|
15112
|
+
trigger: import_mini60.z.optional(
|
|
15113
|
+
import_mini60.z.union([
|
|
15114
|
+
import_mini60.z.literal("always_on"),
|
|
15115
|
+
import_mini60.z.literal("glob"),
|
|
15116
|
+
import_mini60.z.literal("manual"),
|
|
15117
|
+
import_mini60.z.literal("model_decision"),
|
|
15118
|
+
import_mini60.z.string()
|
|
15076
15119
|
// accepts any string for forward compatibility
|
|
15077
15120
|
])
|
|
15078
15121
|
),
|
|
15079
|
-
globs:
|
|
15080
|
-
description:
|
|
15122
|
+
globs: import_mini60.z.optional(import_mini60.z.string()),
|
|
15123
|
+
description: import_mini60.z.optional(import_mini60.z.string())
|
|
15081
15124
|
});
|
|
15082
15125
|
function parseGlobsString(globs) {
|
|
15083
15126
|
if (!globs) {
|
|
@@ -15664,9 +15707,9 @@ var ClaudecodeLegacyRule = class _ClaudecodeLegacyRule extends ToolRule {
|
|
|
15664
15707
|
|
|
15665
15708
|
// src/features/rules/claudecode-rule.ts
|
|
15666
15709
|
var import_node_path112 = require("path");
|
|
15667
|
-
var
|
|
15668
|
-
var ClaudecodeRuleFrontmatterSchema =
|
|
15669
|
-
paths:
|
|
15710
|
+
var import_mini61 = require("zod/mini");
|
|
15711
|
+
var ClaudecodeRuleFrontmatterSchema = import_mini61.z.object({
|
|
15712
|
+
paths: import_mini61.z.optional(import_mini61.z.array(import_mini61.z.string()))
|
|
15670
15713
|
});
|
|
15671
15714
|
var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
15672
15715
|
frontmatter;
|
|
@@ -15882,9 +15925,9 @@ var ClaudecodeRule = class _ClaudecodeRule extends ToolRule {
|
|
|
15882
15925
|
|
|
15883
15926
|
// src/features/rules/cline-rule.ts
|
|
15884
15927
|
var import_node_path113 = require("path");
|
|
15885
|
-
var
|
|
15886
|
-
var ClineRuleFrontmatterSchema =
|
|
15887
|
-
description:
|
|
15928
|
+
var import_mini62 = require("zod/mini");
|
|
15929
|
+
var ClineRuleFrontmatterSchema = import_mini62.z.object({
|
|
15930
|
+
description: import_mini62.z.string()
|
|
15888
15931
|
});
|
|
15889
15932
|
var ClineRule = class _ClineRule extends ToolRule {
|
|
15890
15933
|
static getSettablePaths(_options = {}) {
|
|
@@ -16063,11 +16106,11 @@ var CodexcliRule = class _CodexcliRule extends ToolRule {
|
|
|
16063
16106
|
|
|
16064
16107
|
// src/features/rules/copilot-rule.ts
|
|
16065
16108
|
var import_node_path115 = require("path");
|
|
16066
|
-
var
|
|
16067
|
-
var CopilotRuleFrontmatterSchema =
|
|
16068
|
-
description:
|
|
16069
|
-
applyTo:
|
|
16070
|
-
excludeAgent:
|
|
16109
|
+
var import_mini63 = require("zod/mini");
|
|
16110
|
+
var CopilotRuleFrontmatterSchema = import_mini63.z.object({
|
|
16111
|
+
description: import_mini63.z.optional(import_mini63.z.string()),
|
|
16112
|
+
applyTo: import_mini63.z.optional(import_mini63.z.string()),
|
|
16113
|
+
excludeAgent: import_mini63.z.optional(import_mini63.z.union([import_mini63.z.literal("code-review"), import_mini63.z.literal("coding-agent")]))
|
|
16071
16114
|
});
|
|
16072
16115
|
var CopilotRule = class _CopilotRule extends ToolRule {
|
|
16073
16116
|
frontmatter;
|
|
@@ -16309,11 +16352,11 @@ var CopilotcliRule = class _CopilotcliRule extends CopilotRule {
|
|
|
16309
16352
|
|
|
16310
16353
|
// src/features/rules/cursor-rule.ts
|
|
16311
16354
|
var import_node_path116 = require("path");
|
|
16312
|
-
var
|
|
16313
|
-
var CursorRuleFrontmatterSchema =
|
|
16314
|
-
description:
|
|
16315
|
-
globs:
|
|
16316
|
-
alwaysApply:
|
|
16355
|
+
var import_mini64 = require("zod/mini");
|
|
16356
|
+
var CursorRuleFrontmatterSchema = import_mini64.z.object({
|
|
16357
|
+
description: import_mini64.z.optional(import_mini64.z.string()),
|
|
16358
|
+
globs: import_mini64.z.optional(import_mini64.z.string()),
|
|
16359
|
+
alwaysApply: import_mini64.z.optional(import_mini64.z.boolean())
|
|
16317
16360
|
});
|
|
16318
16361
|
var CursorRule = class _CursorRule extends ToolRule {
|
|
16319
16362
|
frontmatter;
|
|
@@ -17890,14 +17933,21 @@ var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
|
17890
17933
|
rulesyncRule,
|
|
17891
17934
|
validate = true
|
|
17892
17935
|
}) {
|
|
17893
|
-
|
|
17894
|
-
|
|
17895
|
-
|
|
17896
|
-
|
|
17897
|
-
|
|
17898
|
-
|
|
17899
|
-
|
|
17900
|
-
|
|
17936
|
+
const toolRuleParams = this.buildToolRuleParamsDefault({
|
|
17937
|
+
baseDir,
|
|
17938
|
+
rulesyncRule,
|
|
17939
|
+
validate,
|
|
17940
|
+
nonRootPath: this.getSettablePaths().nonRoot
|
|
17941
|
+
});
|
|
17942
|
+
const windsurfFrontmatter = this.buildWindsurfFrontmatter({
|
|
17943
|
+
relativeFilePath: rulesyncRule.getRelativeFilePath(),
|
|
17944
|
+
description: rulesyncRule.getFrontmatter().description,
|
|
17945
|
+
globs: rulesyncRule.getFrontmatter().globs
|
|
17946
|
+
});
|
|
17947
|
+
return new _WindsurfRule({
|
|
17948
|
+
...toolRuleParams,
|
|
17949
|
+
fileContent: stringifyFrontmatter(rulesyncRule.getBody(), windsurfFrontmatter)
|
|
17950
|
+
});
|
|
17901
17951
|
}
|
|
17902
17952
|
toRulesyncRule() {
|
|
17903
17953
|
return this.toRulesyncRuleDefault();
|
|
@@ -17924,6 +17974,18 @@ var WindsurfRule = class _WindsurfRule extends ToolRule {
|
|
|
17924
17974
|
toolTarget: "windsurf"
|
|
17925
17975
|
});
|
|
17926
17976
|
}
|
|
17977
|
+
static buildWindsurfFrontmatter({
|
|
17978
|
+
relativeFilePath,
|
|
17979
|
+
description,
|
|
17980
|
+
globs
|
|
17981
|
+
}) {
|
|
17982
|
+
const hasSpecificGlobs = Boolean(globs && globs.length > 0 && !globs.includes("**/*"));
|
|
17983
|
+
return {
|
|
17984
|
+
title: description ?? relativeFilePath.replace(/\.md$/, ""),
|
|
17985
|
+
trigger: hasSpecificGlobs ? "glob" : "always_on",
|
|
17986
|
+
...hasSpecificGlobs && { globs }
|
|
17987
|
+
};
|
|
17988
|
+
}
|
|
17927
17989
|
};
|
|
17928
17990
|
|
|
17929
17991
|
// src/features/rules/rules-processor.ts
|
|
@@ -17954,8 +18016,30 @@ var rulesProcessorToolTargets = [
|
|
|
17954
18016
|
"warp",
|
|
17955
18017
|
"windsurf"
|
|
17956
18018
|
];
|
|
17957
|
-
var RulesProcessorToolTargetSchema =
|
|
18019
|
+
var RulesProcessorToolTargetSchema = import_mini65.z.enum(rulesProcessorToolTargets);
|
|
17958
18020
|
var formatRulePaths = (rules) => rules.map((r) => (0, import_node_path131.join)(r.getRelativeDirPath(), r.getRelativeFilePath())).join(", ");
|
|
18021
|
+
var RulesFeatureOptionsSchema = import_mini65.z.looseObject({
|
|
18022
|
+
ruleDiscoveryMode: import_mini65.z.optional(import_mini65.z.enum(["none", "explicit"]))
|
|
18023
|
+
});
|
|
18024
|
+
var resolveRuleDiscoveryMode = ({
|
|
18025
|
+
defaultMode,
|
|
18026
|
+
options
|
|
18027
|
+
}) => {
|
|
18028
|
+
if (defaultMode === "claudecode-legacy") {
|
|
18029
|
+
return defaultMode;
|
|
18030
|
+
}
|
|
18031
|
+
if (!options) return defaultMode;
|
|
18032
|
+
const parsed = RulesFeatureOptionsSchema.safeParse(options);
|
|
18033
|
+
if (!parsed.success) {
|
|
18034
|
+
throw new Error(
|
|
18035
|
+
`Invalid options for rules feature: ${parsed.error.message}. \`ruleDiscoveryMode\` must be either "none" or "explicit".`
|
|
18036
|
+
);
|
|
18037
|
+
}
|
|
18038
|
+
if (!parsed.data.ruleDiscoveryMode) {
|
|
18039
|
+
return defaultMode;
|
|
18040
|
+
}
|
|
18041
|
+
return parsed.data.ruleDiscoveryMode === "none" ? "auto" : "toon";
|
|
18042
|
+
};
|
|
17959
18043
|
var toolRuleFactories = /* @__PURE__ */ new Map([
|
|
17960
18044
|
[
|
|
17961
18045
|
"agentsmd",
|
|
@@ -18270,6 +18354,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18270
18354
|
global;
|
|
18271
18355
|
getFactory;
|
|
18272
18356
|
skills;
|
|
18357
|
+
featureOptions;
|
|
18273
18358
|
constructor({
|
|
18274
18359
|
baseDir = process.cwd(),
|
|
18275
18360
|
toolTarget,
|
|
@@ -18279,6 +18364,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18279
18364
|
global = false,
|
|
18280
18365
|
getFactory = defaultGetFactory6,
|
|
18281
18366
|
skills,
|
|
18367
|
+
featureOptions,
|
|
18282
18368
|
dryRun = false,
|
|
18283
18369
|
logger: logger5
|
|
18284
18370
|
}) {
|
|
@@ -18296,6 +18382,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18296
18382
|
this.simulateSkills = simulateSkills;
|
|
18297
18383
|
this.getFactory = getFactory;
|
|
18298
18384
|
this.skills = skills;
|
|
18385
|
+
this.featureOptions = featureOptions;
|
|
18299
18386
|
}
|
|
18300
18387
|
async convertRulesyncFilesToToolFiles(rulesyncFiles) {
|
|
18301
18388
|
const rulesyncRules = rulesyncFiles.filter(
|
|
@@ -18453,7 +18540,11 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
18453
18540
|
* Generate reference section based on meta configuration.
|
|
18454
18541
|
*/
|
|
18455
18542
|
generateReferenceSectionFromMeta(meta, toolRules) {
|
|
18456
|
-
|
|
18543
|
+
const mode = resolveRuleDiscoveryMode({
|
|
18544
|
+
defaultMode: meta.ruleDiscoveryMode,
|
|
18545
|
+
options: this.featureOptions
|
|
18546
|
+
});
|
|
18547
|
+
switch (mode) {
|
|
18457
18548
|
case "toon":
|
|
18458
18549
|
return this.generateToonReferencesSection(toolRules);
|
|
18459
18550
|
case "claudecode-legacy":
|
|
@@ -18877,51 +18968,51 @@ var import_request_error = require("@octokit/request-error");
|
|
|
18877
18968
|
var import_rest = require("@octokit/rest");
|
|
18878
18969
|
|
|
18879
18970
|
// src/types/fetch.ts
|
|
18880
|
-
var
|
|
18971
|
+
var import_mini67 = require("zod/mini");
|
|
18881
18972
|
|
|
18882
18973
|
// src/types/fetch-targets.ts
|
|
18883
|
-
var
|
|
18974
|
+
var import_mini66 = require("zod/mini");
|
|
18884
18975
|
var ALL_FETCH_TARGETS = ["rulesync", ...ALL_TOOL_TARGETS];
|
|
18885
|
-
var FetchTargetSchema =
|
|
18976
|
+
var FetchTargetSchema = import_mini66.z.enum(ALL_FETCH_TARGETS);
|
|
18886
18977
|
|
|
18887
18978
|
// src/types/fetch.ts
|
|
18888
|
-
var ConflictStrategySchema =
|
|
18889
|
-
var GitHubFileTypeSchema =
|
|
18890
|
-
var GitHubFileEntrySchema =
|
|
18891
|
-
name:
|
|
18892
|
-
path:
|
|
18893
|
-
sha:
|
|
18894
|
-
size:
|
|
18979
|
+
var ConflictStrategySchema = import_mini67.z.enum(["skip", "overwrite"]);
|
|
18980
|
+
var GitHubFileTypeSchema = import_mini67.z.enum(["file", "dir", "symlink", "submodule"]);
|
|
18981
|
+
var GitHubFileEntrySchema = import_mini67.z.looseObject({
|
|
18982
|
+
name: import_mini67.z.string(),
|
|
18983
|
+
path: import_mini67.z.string(),
|
|
18984
|
+
sha: import_mini67.z.string(),
|
|
18985
|
+
size: import_mini67.z.number(),
|
|
18895
18986
|
type: GitHubFileTypeSchema,
|
|
18896
|
-
download_url:
|
|
18987
|
+
download_url: import_mini67.z.nullable(import_mini67.z.string())
|
|
18897
18988
|
});
|
|
18898
|
-
var FetchOptionsSchema =
|
|
18899
|
-
target:
|
|
18900
|
-
features:
|
|
18901
|
-
ref:
|
|
18902
|
-
path:
|
|
18903
|
-
output:
|
|
18904
|
-
conflict:
|
|
18905
|
-
token:
|
|
18906
|
-
verbose:
|
|
18907
|
-
silent:
|
|
18989
|
+
var FetchOptionsSchema = import_mini67.z.looseObject({
|
|
18990
|
+
target: import_mini67.z.optional(FetchTargetSchema),
|
|
18991
|
+
features: import_mini67.z.optional(import_mini67.z.array(import_mini67.z.enum(ALL_FEATURES_WITH_WILDCARD))),
|
|
18992
|
+
ref: import_mini67.z.optional(import_mini67.z.string()),
|
|
18993
|
+
path: import_mini67.z.optional(import_mini67.z.string()),
|
|
18994
|
+
output: import_mini67.z.optional(import_mini67.z.string()),
|
|
18995
|
+
conflict: import_mini67.z.optional(ConflictStrategySchema),
|
|
18996
|
+
token: import_mini67.z.optional(import_mini67.z.string()),
|
|
18997
|
+
verbose: import_mini67.z.optional(import_mini67.z.boolean()),
|
|
18998
|
+
silent: import_mini67.z.optional(import_mini67.z.boolean())
|
|
18908
18999
|
});
|
|
18909
|
-
var FetchFileStatusSchema =
|
|
18910
|
-
var GitHubRepoInfoSchema =
|
|
18911
|
-
default_branch:
|
|
18912
|
-
private:
|
|
19000
|
+
var FetchFileStatusSchema = import_mini67.z.enum(["created", "overwritten", "skipped"]);
|
|
19001
|
+
var GitHubRepoInfoSchema = import_mini67.z.looseObject({
|
|
19002
|
+
default_branch: import_mini67.z.string(),
|
|
19003
|
+
private: import_mini67.z.boolean()
|
|
18913
19004
|
});
|
|
18914
|
-
var GitHubReleaseAssetSchema =
|
|
18915
|
-
name:
|
|
18916
|
-
browser_download_url:
|
|
18917
|
-
size:
|
|
19005
|
+
var GitHubReleaseAssetSchema = import_mini67.z.looseObject({
|
|
19006
|
+
name: import_mini67.z.string(),
|
|
19007
|
+
browser_download_url: import_mini67.z.string(),
|
|
19008
|
+
size: import_mini67.z.number()
|
|
18918
19009
|
});
|
|
18919
|
-
var GitHubReleaseSchema =
|
|
18920
|
-
tag_name:
|
|
18921
|
-
name:
|
|
18922
|
-
prerelease:
|
|
18923
|
-
draft:
|
|
18924
|
-
assets:
|
|
19010
|
+
var GitHubReleaseSchema = import_mini67.z.looseObject({
|
|
19011
|
+
tag_name: import_mini67.z.string(),
|
|
19012
|
+
name: import_mini67.z.nullable(import_mini67.z.string()),
|
|
19013
|
+
prerelease: import_mini67.z.boolean(),
|
|
19014
|
+
draft: import_mini67.z.boolean(),
|
|
19015
|
+
assets: import_mini67.z.array(GitHubReleaseAssetSchema)
|
|
18925
19016
|
});
|
|
18926
19017
|
|
|
18927
19018
|
// src/lib/github-client.ts
|
|
@@ -19222,9 +19313,9 @@ async function listDirectoryRecursive(params) {
|
|
|
19222
19313
|
}
|
|
19223
19314
|
|
|
19224
19315
|
// src/types/git-provider.ts
|
|
19225
|
-
var
|
|
19316
|
+
var import_mini68 = require("zod/mini");
|
|
19226
19317
|
var ALL_GIT_PROVIDERS = ["github", "gitlab"];
|
|
19227
|
-
var GitProviderSchema =
|
|
19318
|
+
var GitProviderSchema = import_mini68.z.enum(ALL_GIT_PROVIDERS);
|
|
19228
19319
|
|
|
19229
19320
|
// src/lib/source-parser.ts
|
|
19230
19321
|
var GITHUB_HOSTS = /* @__PURE__ */ new Set(["github.com", "www.github.com"]);
|
|
@@ -19847,7 +19938,7 @@ var import_jsonc_parser4 = require("jsonc-parser");
|
|
|
19847
19938
|
|
|
19848
19939
|
// src/config/config.ts
|
|
19849
19940
|
var import_node_path133 = require("path");
|
|
19850
|
-
var
|
|
19941
|
+
var import_mini69 = require("zod/mini");
|
|
19851
19942
|
|
|
19852
19943
|
// src/utils/validation.ts
|
|
19853
19944
|
function findControlCharacter(value) {
|
|
@@ -19864,53 +19955,53 @@ function hasControlCharacters(value) {
|
|
|
19864
19955
|
}
|
|
19865
19956
|
|
|
19866
19957
|
// src/config/config.ts
|
|
19867
|
-
var SourceEntrySchema =
|
|
19868
|
-
source:
|
|
19869
|
-
skills: (0,
|
|
19870
|
-
transport: (0,
|
|
19871
|
-
ref: (0,
|
|
19872
|
-
|
|
19873
|
-
(0,
|
|
19874
|
-
(0,
|
|
19958
|
+
var SourceEntrySchema = import_mini69.z.object({
|
|
19959
|
+
source: import_mini69.z.string().check((0, import_mini69.minLength)(1, "source must be a non-empty string")),
|
|
19960
|
+
skills: (0, import_mini69.optional)(import_mini69.z.array(import_mini69.z.string())),
|
|
19961
|
+
transport: (0, import_mini69.optional)(import_mini69.z.enum(["github", "git"])),
|
|
19962
|
+
ref: (0, import_mini69.optional)(
|
|
19963
|
+
import_mini69.z.string().check(
|
|
19964
|
+
(0, import_mini69.refine)((v) => !v.startsWith("-"), 'ref must not start with "-"'),
|
|
19965
|
+
(0, import_mini69.refine)((v) => !hasControlCharacters(v), "ref must not contain control characters")
|
|
19875
19966
|
)
|
|
19876
19967
|
),
|
|
19877
|
-
path: (0,
|
|
19878
|
-
|
|
19879
|
-
(0,
|
|
19880
|
-
(0,
|
|
19881
|
-
(0,
|
|
19968
|
+
path: (0, import_mini69.optional)(
|
|
19969
|
+
import_mini69.z.string().check(
|
|
19970
|
+
(0, import_mini69.refine)((v) => !v.includes(".."), 'path must not contain ".."'),
|
|
19971
|
+
(0, import_mini69.refine)((v) => !(0, import_node_path133.isAbsolute)(v), "path must not be absolute"),
|
|
19972
|
+
(0, import_mini69.refine)((v) => !hasControlCharacters(v), "path must not contain control characters")
|
|
19882
19973
|
)
|
|
19883
19974
|
)
|
|
19884
19975
|
});
|
|
19885
|
-
var ConfigParamsSchema =
|
|
19886
|
-
baseDirs:
|
|
19976
|
+
var ConfigParamsSchema = import_mini69.z.object({
|
|
19977
|
+
baseDirs: import_mini69.z.array(import_mini69.z.string()),
|
|
19887
19978
|
targets: RulesyncTargetsSchema,
|
|
19888
19979
|
features: RulesyncFeaturesSchema,
|
|
19889
|
-
verbose:
|
|
19890
|
-
delete:
|
|
19980
|
+
verbose: import_mini69.z.boolean(),
|
|
19981
|
+
delete: import_mini69.z.boolean(),
|
|
19891
19982
|
// New non-experimental options
|
|
19892
|
-
global: (0,
|
|
19893
|
-
silent: (0,
|
|
19894
|
-
simulateCommands: (0,
|
|
19895
|
-
simulateSubagents: (0,
|
|
19896
|
-
simulateSkills: (0,
|
|
19897
|
-
dryRun: (0,
|
|
19898
|
-
check: (0,
|
|
19983
|
+
global: (0, import_mini69.optional)(import_mini69.z.boolean()),
|
|
19984
|
+
silent: (0, import_mini69.optional)(import_mini69.z.boolean()),
|
|
19985
|
+
simulateCommands: (0, import_mini69.optional)(import_mini69.z.boolean()),
|
|
19986
|
+
simulateSubagents: (0, import_mini69.optional)(import_mini69.z.boolean()),
|
|
19987
|
+
simulateSkills: (0, import_mini69.optional)(import_mini69.z.boolean()),
|
|
19988
|
+
dryRun: (0, import_mini69.optional)(import_mini69.z.boolean()),
|
|
19989
|
+
check: (0, import_mini69.optional)(import_mini69.z.boolean()),
|
|
19899
19990
|
// Declarative skill sources
|
|
19900
|
-
sources: (0,
|
|
19991
|
+
sources: (0, import_mini69.optional)(import_mini69.z.array(SourceEntrySchema))
|
|
19901
19992
|
});
|
|
19902
|
-
var PartialConfigParamsSchema =
|
|
19903
|
-
var ConfigFileSchema =
|
|
19904
|
-
$schema: (0,
|
|
19905
|
-
...
|
|
19993
|
+
var PartialConfigParamsSchema = import_mini69.z.partial(ConfigParamsSchema);
|
|
19994
|
+
var ConfigFileSchema = import_mini69.z.object({
|
|
19995
|
+
$schema: (0, import_mini69.optional)(import_mini69.z.string()),
|
|
19996
|
+
...import_mini69.z.partial(ConfigParamsSchema).shape
|
|
19906
19997
|
});
|
|
19907
|
-
var RequiredConfigParamsSchema =
|
|
19998
|
+
var RequiredConfigParamsSchema = import_mini69.z.required(ConfigParamsSchema);
|
|
19908
19999
|
var CONFLICTING_TARGET_PAIRS = [
|
|
19909
20000
|
["augmentcode", "augmentcode-legacy"],
|
|
19910
20001
|
["claudecode", "claudecode-legacy"]
|
|
19911
20002
|
];
|
|
19912
20003
|
var LEGACY_TARGETS = ["augmentcode-legacy", "claudecode-legacy"];
|
|
19913
|
-
var Config = class {
|
|
20004
|
+
var Config = class _Config {
|
|
19914
20005
|
baseDirs;
|
|
19915
20006
|
targets;
|
|
19916
20007
|
features;
|
|
@@ -19985,26 +20076,23 @@ var Config = class {
|
|
|
19985
20076
|
const perTargetFeatures = this.features;
|
|
19986
20077
|
if (target) {
|
|
19987
20078
|
const targetFeatures = perTargetFeatures[target];
|
|
19988
|
-
if (!targetFeatures
|
|
20079
|
+
if (!targetFeatures) {
|
|
19989
20080
|
return [];
|
|
19990
20081
|
}
|
|
19991
|
-
|
|
19992
|
-
return [...ALL_FEATURES];
|
|
19993
|
-
}
|
|
19994
|
-
return targetFeatures.filter((feature) => feature !== "*");
|
|
20082
|
+
return _Config.normalizeTargetFeatures(targetFeatures);
|
|
19995
20083
|
}
|
|
19996
20084
|
const allFeatures = [];
|
|
19997
20085
|
for (const features of Object.values(perTargetFeatures)) {
|
|
19998
|
-
if (features
|
|
19999
|
-
|
|
20000
|
-
|
|
20001
|
-
|
|
20002
|
-
|
|
20003
|
-
if (feature !== "*" && !allFeatures.includes(feature)) {
|
|
20004
|
-
allFeatures.push(feature);
|
|
20005
|
-
}
|
|
20086
|
+
if (!features) continue;
|
|
20087
|
+
const normalized = _Config.normalizeTargetFeatures(features);
|
|
20088
|
+
for (const feature of normalized) {
|
|
20089
|
+
if (!allFeatures.includes(feature)) {
|
|
20090
|
+
allFeatures.push(feature);
|
|
20006
20091
|
}
|
|
20007
20092
|
}
|
|
20093
|
+
if (allFeatures.length === ALL_FEATURES.length) {
|
|
20094
|
+
return allFeatures;
|
|
20095
|
+
}
|
|
20008
20096
|
}
|
|
20009
20097
|
return allFeatures;
|
|
20010
20098
|
}
|
|
@@ -20013,6 +20101,47 @@ var Config = class {
|
|
|
20013
20101
|
}
|
|
20014
20102
|
return this.features.filter((feature) => feature !== "*");
|
|
20015
20103
|
}
|
|
20104
|
+
/**
|
|
20105
|
+
* Normalize a per-target features value (array or per-feature object) into
|
|
20106
|
+
* the flat list of enabled features.
|
|
20107
|
+
*/
|
|
20108
|
+
static normalizeTargetFeatures(value) {
|
|
20109
|
+
if (Array.isArray(value)) {
|
|
20110
|
+
if (value.length === 0) return [];
|
|
20111
|
+
if (value.includes("*")) return [...ALL_FEATURES];
|
|
20112
|
+
return value.filter((feature) => feature !== "*");
|
|
20113
|
+
}
|
|
20114
|
+
if (isFeatureValueEnabled(value["*"])) {
|
|
20115
|
+
return [...ALL_FEATURES];
|
|
20116
|
+
}
|
|
20117
|
+
const enabled = [];
|
|
20118
|
+
for (const [key, val] of Object.entries(value)) {
|
|
20119
|
+
if (key === "*") continue;
|
|
20120
|
+
if (!isFeatureValueEnabled(val)) continue;
|
|
20121
|
+
enabled.push(key);
|
|
20122
|
+
}
|
|
20123
|
+
return enabled;
|
|
20124
|
+
}
|
|
20125
|
+
/**
|
|
20126
|
+
* Returns the per-feature options object for a given target/feature, if any.
|
|
20127
|
+
* Returns `undefined` when no per-feature options were provided or when the
|
|
20128
|
+
* feature is not enabled for the given target.
|
|
20129
|
+
*/
|
|
20130
|
+
getFeatureOptions(target, feature) {
|
|
20131
|
+
if (Array.isArray(this.features)) {
|
|
20132
|
+
return void 0;
|
|
20133
|
+
}
|
|
20134
|
+
const targetFeatures = this.features[target];
|
|
20135
|
+
if (!targetFeatures || Array.isArray(targetFeatures)) {
|
|
20136
|
+
return void 0;
|
|
20137
|
+
}
|
|
20138
|
+
const perFeature = targetFeatures;
|
|
20139
|
+
const value = perFeature[feature];
|
|
20140
|
+
if (value && typeof value === "object" && isFeatureValueEnabled(value)) {
|
|
20141
|
+
return value;
|
|
20142
|
+
}
|
|
20143
|
+
return void 0;
|
|
20144
|
+
}
|
|
20016
20145
|
/**
|
|
20017
20146
|
* Check if per-target features configuration is being used.
|
|
20018
20147
|
*/
|
|
@@ -20049,123 +20178,1100 @@ var Config = class {
|
|
|
20049
20178
|
getSources() {
|
|
20050
20179
|
return this.sources;
|
|
20051
20180
|
}
|
|
20052
|
-
/**
|
|
20053
|
-
* Returns true if either dry-run or check mode is enabled.
|
|
20054
|
-
* In both modes, no files should be written.
|
|
20055
|
-
*/
|
|
20056
|
-
isPreviewMode() {
|
|
20057
|
-
return this.dryRun || this.check;
|
|
20181
|
+
/**
|
|
20182
|
+
* Returns true if either dry-run or check mode is enabled.
|
|
20183
|
+
* In both modes, no files should be written.
|
|
20184
|
+
*/
|
|
20185
|
+
isPreviewMode() {
|
|
20186
|
+
return this.dryRun || this.check;
|
|
20187
|
+
}
|
|
20188
|
+
};
|
|
20189
|
+
|
|
20190
|
+
// src/config/config-resolver.ts
|
|
20191
|
+
var getDefaults = () => ({
|
|
20192
|
+
targets: ["agentsmd"],
|
|
20193
|
+
features: ["rules"],
|
|
20194
|
+
verbose: false,
|
|
20195
|
+
delete: false,
|
|
20196
|
+
baseDirs: [process.cwd()],
|
|
20197
|
+
configPath: RULESYNC_CONFIG_RELATIVE_FILE_PATH,
|
|
20198
|
+
global: false,
|
|
20199
|
+
silent: false,
|
|
20200
|
+
simulateCommands: false,
|
|
20201
|
+
simulateSubagents: false,
|
|
20202
|
+
simulateSkills: false,
|
|
20203
|
+
dryRun: false,
|
|
20204
|
+
check: false,
|
|
20205
|
+
sources: []
|
|
20206
|
+
});
|
|
20207
|
+
var loadConfigFromFile = async (filePath) => {
|
|
20208
|
+
if (!await fileExists(filePath)) {
|
|
20209
|
+
return {};
|
|
20210
|
+
}
|
|
20211
|
+
const fileContent = await readFileContent(filePath);
|
|
20212
|
+
const jsonData = (0, import_jsonc_parser4.parse)(fileContent);
|
|
20213
|
+
const parsed = ConfigFileSchema.parse(jsonData);
|
|
20214
|
+
const { $schema: _schema, ...configParams } = parsed;
|
|
20215
|
+
return configParams;
|
|
20216
|
+
};
|
|
20217
|
+
var mergeConfigs = (baseConfig, localConfig) => {
|
|
20218
|
+
return {
|
|
20219
|
+
targets: localConfig.targets ?? baseConfig.targets,
|
|
20220
|
+
features: localConfig.features ?? baseConfig.features,
|
|
20221
|
+
verbose: localConfig.verbose ?? baseConfig.verbose,
|
|
20222
|
+
delete: localConfig.delete ?? baseConfig.delete,
|
|
20223
|
+
baseDirs: localConfig.baseDirs ?? baseConfig.baseDirs,
|
|
20224
|
+
global: localConfig.global ?? baseConfig.global,
|
|
20225
|
+
silent: localConfig.silent ?? baseConfig.silent,
|
|
20226
|
+
simulateCommands: localConfig.simulateCommands ?? baseConfig.simulateCommands,
|
|
20227
|
+
simulateSubagents: localConfig.simulateSubagents ?? baseConfig.simulateSubagents,
|
|
20228
|
+
simulateSkills: localConfig.simulateSkills ?? baseConfig.simulateSkills,
|
|
20229
|
+
dryRun: localConfig.dryRun ?? baseConfig.dryRun,
|
|
20230
|
+
check: localConfig.check ?? baseConfig.check,
|
|
20231
|
+
sources: localConfig.sources ?? baseConfig.sources
|
|
20232
|
+
};
|
|
20233
|
+
};
|
|
20234
|
+
var ConfigResolver = class {
|
|
20235
|
+
static async resolve({
|
|
20236
|
+
targets,
|
|
20237
|
+
features,
|
|
20238
|
+
verbose,
|
|
20239
|
+
delete: isDelete,
|
|
20240
|
+
baseDirs,
|
|
20241
|
+
configPath = getDefaults().configPath,
|
|
20242
|
+
global,
|
|
20243
|
+
silent,
|
|
20244
|
+
simulateCommands,
|
|
20245
|
+
simulateSubagents,
|
|
20246
|
+
simulateSkills,
|
|
20247
|
+
dryRun,
|
|
20248
|
+
check
|
|
20249
|
+
}) {
|
|
20250
|
+
const validatedConfigPath = resolvePath(configPath, process.cwd());
|
|
20251
|
+
const baseConfig = await loadConfigFromFile(validatedConfigPath);
|
|
20252
|
+
const configDir = (0, import_node_path134.dirname)(validatedConfigPath);
|
|
20253
|
+
const localConfigPath = (0, import_node_path134.join)(configDir, RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH);
|
|
20254
|
+
const localConfig = await loadConfigFromFile(localConfigPath);
|
|
20255
|
+
const configByFile = mergeConfigs(baseConfig, localConfig);
|
|
20256
|
+
const resolvedGlobal = global ?? configByFile.global ?? getDefaults().global;
|
|
20257
|
+
const resolvedSimulateCommands = simulateCommands ?? configByFile.simulateCommands ?? getDefaults().simulateCommands;
|
|
20258
|
+
const resolvedSimulateSubagents = simulateSubagents ?? configByFile.simulateSubagents ?? getDefaults().simulateSubagents;
|
|
20259
|
+
const resolvedSimulateSkills = simulateSkills ?? configByFile.simulateSkills ?? getDefaults().simulateSkills;
|
|
20260
|
+
const configParams = {
|
|
20261
|
+
targets: targets ?? configByFile.targets ?? getDefaults().targets,
|
|
20262
|
+
features: features ?? configByFile.features ?? getDefaults().features,
|
|
20263
|
+
verbose: verbose ?? configByFile.verbose ?? getDefaults().verbose,
|
|
20264
|
+
delete: isDelete ?? configByFile.delete ?? getDefaults().delete,
|
|
20265
|
+
baseDirs: getBaseDirsInLightOfGlobal({
|
|
20266
|
+
baseDirs: baseDirs ?? configByFile.baseDirs ?? getDefaults().baseDirs,
|
|
20267
|
+
global: resolvedGlobal
|
|
20268
|
+
}),
|
|
20269
|
+
global: resolvedGlobal,
|
|
20270
|
+
silent: silent ?? configByFile.silent ?? getDefaults().silent,
|
|
20271
|
+
simulateCommands: resolvedSimulateCommands,
|
|
20272
|
+
simulateSubagents: resolvedSimulateSubagents,
|
|
20273
|
+
simulateSkills: resolvedSimulateSkills,
|
|
20274
|
+
dryRun: dryRun ?? configByFile.dryRun ?? getDefaults().dryRun,
|
|
20275
|
+
check: check ?? configByFile.check ?? getDefaults().check,
|
|
20276
|
+
sources: configByFile.sources ?? getDefaults().sources
|
|
20277
|
+
};
|
|
20278
|
+
return new Config(configParams);
|
|
20279
|
+
}
|
|
20280
|
+
};
|
|
20281
|
+
function getBaseDirsInLightOfGlobal({
|
|
20282
|
+
baseDirs,
|
|
20283
|
+
global
|
|
20284
|
+
}) {
|
|
20285
|
+
if (global) {
|
|
20286
|
+
return [getHomeDirectory()];
|
|
20287
|
+
}
|
|
20288
|
+
const resolvedBaseDirs = baseDirs.map((baseDir) => (0, import_node_path134.resolve)(baseDir));
|
|
20289
|
+
resolvedBaseDirs.forEach((baseDir) => {
|
|
20290
|
+
validateBaseDir(baseDir);
|
|
20291
|
+
});
|
|
20292
|
+
return resolvedBaseDirs;
|
|
20293
|
+
}
|
|
20294
|
+
|
|
20295
|
+
// src/lib/generate.ts
|
|
20296
|
+
var import_node_path140 = require("path");
|
|
20297
|
+
var import_es_toolkit5 = require("es-toolkit");
|
|
20298
|
+
|
|
20299
|
+
// src/features/permissions/permissions-processor.ts
|
|
20300
|
+
var import_mini73 = require("zod/mini");
|
|
20301
|
+
|
|
20302
|
+
// src/features/permissions/claudecode-permissions.ts
|
|
20303
|
+
var import_node_path136 = require("path");
|
|
20304
|
+
var import_es_toolkit4 = require("es-toolkit");
|
|
20305
|
+
|
|
20306
|
+
// src/features/permissions/rulesync-permissions.ts
|
|
20307
|
+
var import_node_path135 = require("path");
|
|
20308
|
+
|
|
20309
|
+
// src/types/permissions.ts
|
|
20310
|
+
var import_mini70 = require("zod/mini");
|
|
20311
|
+
var PermissionActionSchema = import_mini70.z.enum(["allow", "ask", "deny"]);
|
|
20312
|
+
var PermissionRulesSchema = import_mini70.z.record(import_mini70.z.string(), PermissionActionSchema);
|
|
20313
|
+
var PermissionsConfigSchema = import_mini70.z.looseObject({
|
|
20314
|
+
permission: import_mini70.z.record(import_mini70.z.string(), PermissionRulesSchema)
|
|
20315
|
+
});
|
|
20316
|
+
var RulesyncPermissionsFileSchema = import_mini70.z.looseObject({
|
|
20317
|
+
$schema: import_mini70.z.optional(import_mini70.z.string()),
|
|
20318
|
+
...PermissionsConfigSchema.shape
|
|
20319
|
+
});
|
|
20320
|
+
|
|
20321
|
+
// src/features/permissions/rulesync-permissions.ts
|
|
20322
|
+
var RulesyncPermissions = class _RulesyncPermissions extends RulesyncFile {
|
|
20323
|
+
json;
|
|
20324
|
+
constructor(params) {
|
|
20325
|
+
super({ ...params });
|
|
20326
|
+
this.json = JSON.parse(this.fileContent);
|
|
20327
|
+
if (params.validate) {
|
|
20328
|
+
const result = this.validate();
|
|
20329
|
+
if (!result.success) {
|
|
20330
|
+
throw result.error;
|
|
20331
|
+
}
|
|
20332
|
+
}
|
|
20333
|
+
}
|
|
20334
|
+
static getSettablePaths() {
|
|
20335
|
+
return {
|
|
20336
|
+
relativeDirPath: RULESYNC_RELATIVE_DIR_PATH,
|
|
20337
|
+
relativeFilePath: RULESYNC_PERMISSIONS_FILE_NAME
|
|
20338
|
+
};
|
|
20339
|
+
}
|
|
20340
|
+
validate() {
|
|
20341
|
+
const result = RulesyncPermissionsFileSchema.safeParse(this.json);
|
|
20342
|
+
if (!result.success) {
|
|
20343
|
+
return { success: false, error: result.error };
|
|
20344
|
+
}
|
|
20345
|
+
return { success: true, error: null };
|
|
20346
|
+
}
|
|
20347
|
+
static async fromFile({
|
|
20348
|
+
baseDir = process.cwd(),
|
|
20349
|
+
validate = true
|
|
20350
|
+
}) {
|
|
20351
|
+
const paths = _RulesyncPermissions.getSettablePaths();
|
|
20352
|
+
const filePath = (0, import_node_path135.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
20353
|
+
if (!await fileExists(filePath)) {
|
|
20354
|
+
throw new Error(`No ${RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH} found.`);
|
|
20355
|
+
}
|
|
20356
|
+
const fileContent = await readFileContent(filePath);
|
|
20357
|
+
return new _RulesyncPermissions({
|
|
20358
|
+
baseDir,
|
|
20359
|
+
relativeDirPath: paths.relativeDirPath,
|
|
20360
|
+
relativeFilePath: paths.relativeFilePath,
|
|
20361
|
+
fileContent,
|
|
20362
|
+
validate
|
|
20363
|
+
});
|
|
20364
|
+
}
|
|
20365
|
+
getJson() {
|
|
20366
|
+
return this.json;
|
|
20367
|
+
}
|
|
20368
|
+
};
|
|
20369
|
+
|
|
20370
|
+
// src/features/permissions/tool-permissions.ts
|
|
20371
|
+
var ToolPermissions = class extends ToolFile {
|
|
20372
|
+
static getSettablePaths(_options) {
|
|
20373
|
+
throw new Error("Please implement this method in the subclass.");
|
|
20374
|
+
}
|
|
20375
|
+
validate() {
|
|
20376
|
+
return { success: true, error: null };
|
|
20377
|
+
}
|
|
20378
|
+
static fromRulesyncPermissions(_params) {
|
|
20379
|
+
throw new Error("Please implement this method in the subclass.");
|
|
20380
|
+
}
|
|
20381
|
+
toRulesyncPermissionsDefault({
|
|
20382
|
+
fileContent
|
|
20383
|
+
}) {
|
|
20384
|
+
return new RulesyncPermissions({
|
|
20385
|
+
baseDir: this.baseDir,
|
|
20386
|
+
relativeDirPath: RULESYNC_RELATIVE_DIR_PATH,
|
|
20387
|
+
relativeFilePath: RULESYNC_PERMISSIONS_FILE_NAME,
|
|
20388
|
+
fileContent
|
|
20389
|
+
});
|
|
20390
|
+
}
|
|
20391
|
+
static async fromFile(_params) {
|
|
20392
|
+
throw new Error("Please implement this method in the subclass.");
|
|
20393
|
+
}
|
|
20394
|
+
static forDeletion(_params) {
|
|
20395
|
+
throw new Error("Please implement this method in the subclass.");
|
|
20396
|
+
}
|
|
20397
|
+
};
|
|
20398
|
+
|
|
20399
|
+
// src/features/permissions/claudecode-permissions.ts
|
|
20400
|
+
var CANONICAL_TO_CLAUDE_TOOL_NAMES = {
|
|
20401
|
+
bash: "Bash",
|
|
20402
|
+
read: "Read",
|
|
20403
|
+
edit: "Edit",
|
|
20404
|
+
write: "Write",
|
|
20405
|
+
webfetch: "WebFetch",
|
|
20406
|
+
websearch: "WebSearch",
|
|
20407
|
+
grep: "Grep",
|
|
20408
|
+
glob: "Glob",
|
|
20409
|
+
notebookedit: "NotebookEdit",
|
|
20410
|
+
agent: "Agent"
|
|
20411
|
+
};
|
|
20412
|
+
var CLAUDE_TO_CANONICAL_TOOL_NAMES = Object.fromEntries(
|
|
20413
|
+
Object.entries(CANONICAL_TO_CLAUDE_TOOL_NAMES).map(([k, v]) => [v, k])
|
|
20414
|
+
);
|
|
20415
|
+
function toClaudeToolName(canonical) {
|
|
20416
|
+
return CANONICAL_TO_CLAUDE_TOOL_NAMES[canonical] ?? canonical;
|
|
20417
|
+
}
|
|
20418
|
+
function toCanonicalToolName(claudeName) {
|
|
20419
|
+
return CLAUDE_TO_CANONICAL_TOOL_NAMES[claudeName] ?? claudeName;
|
|
20420
|
+
}
|
|
20421
|
+
function parseClaudePermissionEntry(entry) {
|
|
20422
|
+
const parenIndex = entry.indexOf("(");
|
|
20423
|
+
if (parenIndex === -1) {
|
|
20424
|
+
return { toolName: entry, pattern: "*" };
|
|
20425
|
+
}
|
|
20426
|
+
const toolName = entry.slice(0, parenIndex);
|
|
20427
|
+
if (!entry.endsWith(")")) {
|
|
20428
|
+
return { toolName, pattern: "*" };
|
|
20429
|
+
}
|
|
20430
|
+
const pattern = entry.slice(parenIndex + 1, -1);
|
|
20431
|
+
return { toolName, pattern: pattern || "*" };
|
|
20432
|
+
}
|
|
20433
|
+
function buildClaudePermissionEntry(toolName, pattern) {
|
|
20434
|
+
if (pattern === "*") {
|
|
20435
|
+
return toolName;
|
|
20436
|
+
}
|
|
20437
|
+
return `${toolName}(${pattern})`;
|
|
20438
|
+
}
|
|
20439
|
+
var ClaudecodePermissions = class _ClaudecodePermissions extends ToolPermissions {
|
|
20440
|
+
constructor(params) {
|
|
20441
|
+
super({
|
|
20442
|
+
...params,
|
|
20443
|
+
fileContent: params.fileContent ?? "{}"
|
|
20444
|
+
});
|
|
20445
|
+
}
|
|
20446
|
+
isDeletable() {
|
|
20447
|
+
return false;
|
|
20448
|
+
}
|
|
20449
|
+
static getSettablePaths() {
|
|
20450
|
+
return {
|
|
20451
|
+
relativeDirPath: ".claude",
|
|
20452
|
+
relativeFilePath: "settings.json"
|
|
20453
|
+
};
|
|
20454
|
+
}
|
|
20455
|
+
static async fromFile({
|
|
20456
|
+
baseDir = process.cwd(),
|
|
20457
|
+
validate = true
|
|
20458
|
+
}) {
|
|
20459
|
+
const paths = _ClaudecodePermissions.getSettablePaths();
|
|
20460
|
+
const filePath = (0, import_node_path136.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
20461
|
+
const fileContent = await readFileContentOrNull(filePath) ?? '{"permissions":{}}';
|
|
20462
|
+
return new _ClaudecodePermissions({
|
|
20463
|
+
baseDir,
|
|
20464
|
+
relativeDirPath: paths.relativeDirPath,
|
|
20465
|
+
relativeFilePath: paths.relativeFilePath,
|
|
20466
|
+
fileContent,
|
|
20467
|
+
validate
|
|
20468
|
+
});
|
|
20469
|
+
}
|
|
20470
|
+
static async fromRulesyncPermissions({
|
|
20471
|
+
baseDir = process.cwd(),
|
|
20472
|
+
rulesyncPermissions,
|
|
20473
|
+
logger: logger5
|
|
20474
|
+
}) {
|
|
20475
|
+
const paths = _ClaudecodePermissions.getSettablePaths();
|
|
20476
|
+
const filePath = (0, import_node_path136.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
20477
|
+
const existingContent = await readOrInitializeFileContent(
|
|
20478
|
+
filePath,
|
|
20479
|
+
JSON.stringify({}, null, 2)
|
|
20480
|
+
);
|
|
20481
|
+
let settings;
|
|
20482
|
+
try {
|
|
20483
|
+
settings = JSON.parse(existingContent);
|
|
20484
|
+
} catch (error) {
|
|
20485
|
+
throw new Error(
|
|
20486
|
+
`Failed to parse existing Claude settings at ${filePath}: ${formatError(error)}`,
|
|
20487
|
+
{ cause: error }
|
|
20488
|
+
);
|
|
20489
|
+
}
|
|
20490
|
+
const config = rulesyncPermissions.getJson();
|
|
20491
|
+
const { allow, ask, deny } = convertRulesyncToClaudePermissions(config);
|
|
20492
|
+
const managedToolNames = new Set(
|
|
20493
|
+
Object.keys(config.permission).map((category) => toClaudeToolName(category))
|
|
20494
|
+
);
|
|
20495
|
+
const existingPermissions = settings.permissions ?? {};
|
|
20496
|
+
const preservedAllow = (existingPermissions.allow ?? []).filter(
|
|
20497
|
+
(entry) => !managedToolNames.has(parseClaudePermissionEntry(entry).toolName)
|
|
20498
|
+
);
|
|
20499
|
+
const preservedAsk = (existingPermissions.ask ?? []).filter(
|
|
20500
|
+
(entry) => !managedToolNames.has(parseClaudePermissionEntry(entry).toolName)
|
|
20501
|
+
);
|
|
20502
|
+
const preservedDeny = (existingPermissions.deny ?? []).filter(
|
|
20503
|
+
(entry) => !managedToolNames.has(parseClaudePermissionEntry(entry).toolName)
|
|
20504
|
+
);
|
|
20505
|
+
if (logger5 && managedToolNames.has("Read")) {
|
|
20506
|
+
const droppedReadDenyEntries = (existingPermissions.deny ?? []).filter((entry) => {
|
|
20507
|
+
const { toolName } = parseClaudePermissionEntry(entry);
|
|
20508
|
+
return toolName === "Read";
|
|
20509
|
+
});
|
|
20510
|
+
if (droppedReadDenyEntries.length > 0) {
|
|
20511
|
+
logger5.warn(
|
|
20512
|
+
`Permissions feature manages 'Read' tool and will overwrite ${droppedReadDenyEntries.length} existing Read deny entries (possibly from ignore feature). Permissions take precedence.`
|
|
20513
|
+
);
|
|
20514
|
+
}
|
|
20515
|
+
}
|
|
20516
|
+
const mergedPermissions = {
|
|
20517
|
+
...existingPermissions
|
|
20518
|
+
};
|
|
20519
|
+
const mergedAllow = (0, import_es_toolkit4.uniq)([...preservedAllow, ...allow].toSorted());
|
|
20520
|
+
const mergedAsk = (0, import_es_toolkit4.uniq)([...preservedAsk, ...ask].toSorted());
|
|
20521
|
+
const mergedDeny = (0, import_es_toolkit4.uniq)([...preservedDeny, ...deny].toSorted());
|
|
20522
|
+
if (mergedAllow.length > 0) {
|
|
20523
|
+
mergedPermissions.allow = mergedAllow;
|
|
20524
|
+
} else {
|
|
20525
|
+
delete mergedPermissions.allow;
|
|
20526
|
+
}
|
|
20527
|
+
if (mergedAsk.length > 0) {
|
|
20528
|
+
mergedPermissions.ask = mergedAsk;
|
|
20529
|
+
} else {
|
|
20530
|
+
delete mergedPermissions.ask;
|
|
20531
|
+
}
|
|
20532
|
+
if (mergedDeny.length > 0) {
|
|
20533
|
+
mergedPermissions.deny = mergedDeny;
|
|
20534
|
+
} else {
|
|
20535
|
+
delete mergedPermissions.deny;
|
|
20536
|
+
}
|
|
20537
|
+
const merged = { ...settings, permissions: mergedPermissions };
|
|
20538
|
+
const fileContent = JSON.stringify(merged, null, 2);
|
|
20539
|
+
return new _ClaudecodePermissions({
|
|
20540
|
+
baseDir,
|
|
20541
|
+
relativeDirPath: paths.relativeDirPath,
|
|
20542
|
+
relativeFilePath: paths.relativeFilePath,
|
|
20543
|
+
fileContent,
|
|
20544
|
+
validate: true
|
|
20545
|
+
});
|
|
20546
|
+
}
|
|
20547
|
+
toRulesyncPermissions() {
|
|
20548
|
+
let settings;
|
|
20549
|
+
try {
|
|
20550
|
+
settings = JSON.parse(this.getFileContent());
|
|
20551
|
+
} catch (error) {
|
|
20552
|
+
throw new Error(
|
|
20553
|
+
`Failed to parse Claude permissions content in ${(0, import_node_path136.join)(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${formatError(error)}`,
|
|
20554
|
+
{ cause: error }
|
|
20555
|
+
);
|
|
20556
|
+
}
|
|
20557
|
+
const permissions = settings.permissions ?? {};
|
|
20558
|
+
const config = convertClaudeToRulesyncPermissions({
|
|
20559
|
+
allow: permissions.allow ?? [],
|
|
20560
|
+
ask: permissions.ask ?? [],
|
|
20561
|
+
deny: permissions.deny ?? []
|
|
20562
|
+
});
|
|
20563
|
+
return this.toRulesyncPermissionsDefault({
|
|
20564
|
+
fileContent: JSON.stringify(config, null, 2)
|
|
20565
|
+
});
|
|
20566
|
+
}
|
|
20567
|
+
validate() {
|
|
20568
|
+
return { success: true, error: null };
|
|
20569
|
+
}
|
|
20570
|
+
static forDeletion({
|
|
20571
|
+
baseDir = process.cwd(),
|
|
20572
|
+
relativeDirPath,
|
|
20573
|
+
relativeFilePath
|
|
20574
|
+
}) {
|
|
20575
|
+
return new _ClaudecodePermissions({
|
|
20576
|
+
baseDir,
|
|
20577
|
+
relativeDirPath,
|
|
20578
|
+
relativeFilePath,
|
|
20579
|
+
fileContent: JSON.stringify({ permissions: {} }, null, 2),
|
|
20580
|
+
validate: false
|
|
20581
|
+
});
|
|
20582
|
+
}
|
|
20583
|
+
};
|
|
20584
|
+
function convertRulesyncToClaudePermissions(config) {
|
|
20585
|
+
const allow = [];
|
|
20586
|
+
const ask = [];
|
|
20587
|
+
const deny = [];
|
|
20588
|
+
for (const [category, rules] of Object.entries(config.permission)) {
|
|
20589
|
+
const claudeToolName = toClaudeToolName(category);
|
|
20590
|
+
for (const [pattern, action] of Object.entries(rules)) {
|
|
20591
|
+
const entry = buildClaudePermissionEntry(claudeToolName, pattern);
|
|
20592
|
+
switch (action) {
|
|
20593
|
+
case "allow":
|
|
20594
|
+
allow.push(entry);
|
|
20595
|
+
break;
|
|
20596
|
+
case "ask":
|
|
20597
|
+
ask.push(entry);
|
|
20598
|
+
break;
|
|
20599
|
+
case "deny":
|
|
20600
|
+
deny.push(entry);
|
|
20601
|
+
break;
|
|
20602
|
+
}
|
|
20603
|
+
}
|
|
20604
|
+
}
|
|
20605
|
+
return { allow, ask, deny };
|
|
20606
|
+
}
|
|
20607
|
+
function convertClaudeToRulesyncPermissions(params) {
|
|
20608
|
+
const permission = {};
|
|
20609
|
+
const processEntries = (entries, action) => {
|
|
20610
|
+
for (const entry of entries) {
|
|
20611
|
+
const { toolName, pattern } = parseClaudePermissionEntry(entry);
|
|
20612
|
+
const canonical = toCanonicalToolName(toolName);
|
|
20613
|
+
if (!permission[canonical]) {
|
|
20614
|
+
permission[canonical] = {};
|
|
20615
|
+
}
|
|
20616
|
+
permission[canonical][pattern] = action;
|
|
20617
|
+
}
|
|
20618
|
+
};
|
|
20619
|
+
processEntries(params.allow, "allow");
|
|
20620
|
+
processEntries(params.ask, "ask");
|
|
20621
|
+
processEntries(params.deny, "deny");
|
|
20622
|
+
return { permission };
|
|
20623
|
+
}
|
|
20624
|
+
|
|
20625
|
+
// src/features/permissions/codexcli-permissions.ts
|
|
20626
|
+
var import_node_path137 = require("path");
|
|
20627
|
+
var smolToml5 = __toESM(require("smol-toml"), 1);
|
|
20628
|
+
var RULESYNC_PROFILE_NAME = "rulesync";
|
|
20629
|
+
var CodexcliPermissions = class _CodexcliPermissions extends ToolPermissions {
|
|
20630
|
+
static getSettablePaths(_options = {}) {
|
|
20631
|
+
return {
|
|
20632
|
+
relativeDirPath: ".codex",
|
|
20633
|
+
relativeFilePath: "config.toml"
|
|
20634
|
+
};
|
|
20635
|
+
}
|
|
20636
|
+
isDeletable() {
|
|
20637
|
+
return false;
|
|
20638
|
+
}
|
|
20639
|
+
static async fromFile({
|
|
20640
|
+
baseDir = process.cwd(),
|
|
20641
|
+
validate = true,
|
|
20642
|
+
global = false
|
|
20643
|
+
}) {
|
|
20644
|
+
const paths = this.getSettablePaths({ global });
|
|
20645
|
+
const filePath = (0, import_node_path137.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
20646
|
+
const fileContent = await readFileContentOrNull(filePath) ?? smolToml5.stringify({});
|
|
20647
|
+
return new _CodexcliPermissions({
|
|
20648
|
+
baseDir,
|
|
20649
|
+
relativeDirPath: paths.relativeDirPath,
|
|
20650
|
+
relativeFilePath: paths.relativeFilePath,
|
|
20651
|
+
fileContent,
|
|
20652
|
+
validate
|
|
20653
|
+
});
|
|
20654
|
+
}
|
|
20655
|
+
static async fromRulesyncPermissions({
|
|
20656
|
+
baseDir = process.cwd(),
|
|
20657
|
+
rulesyncPermissions,
|
|
20658
|
+
validate = true,
|
|
20659
|
+
logger: logger5,
|
|
20660
|
+
global = false
|
|
20661
|
+
}) {
|
|
20662
|
+
const paths = this.getSettablePaths({ global });
|
|
20663
|
+
const filePath = (0, import_node_path137.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
20664
|
+
const existingContent = await readFileContentOrNull(filePath) ?? smolToml5.stringify({});
|
|
20665
|
+
const parsed = toMutableTable(smolToml5.parse(existingContent));
|
|
20666
|
+
const profile = convertRulesyncToCodexProfile({
|
|
20667
|
+
config: rulesyncPermissions.getJson(),
|
|
20668
|
+
logger: logger5
|
|
20669
|
+
});
|
|
20670
|
+
const permissionsTable = toMutableTable(parsed.permissions);
|
|
20671
|
+
permissionsTable[RULESYNC_PROFILE_NAME] = profile;
|
|
20672
|
+
parsed.permissions = permissionsTable;
|
|
20673
|
+
parsed.default_permissions = RULESYNC_PROFILE_NAME;
|
|
20674
|
+
return new _CodexcliPermissions({
|
|
20675
|
+
baseDir,
|
|
20676
|
+
relativeDirPath: paths.relativeDirPath,
|
|
20677
|
+
relativeFilePath: paths.relativeFilePath,
|
|
20678
|
+
fileContent: smolToml5.stringify(parsed),
|
|
20679
|
+
validate
|
|
20680
|
+
});
|
|
20681
|
+
}
|
|
20682
|
+
toRulesyncPermissions() {
|
|
20683
|
+
let parsed;
|
|
20684
|
+
try {
|
|
20685
|
+
parsed = smolToml5.parse(this.getFileContent());
|
|
20686
|
+
} catch (error) {
|
|
20687
|
+
throw new Error(
|
|
20688
|
+
`Failed to parse Codex CLI permissions content in ${(0, import_node_path137.join)(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${formatError(error)}`,
|
|
20689
|
+
{ cause: error }
|
|
20690
|
+
);
|
|
20691
|
+
}
|
|
20692
|
+
const table = toMutableTable(parsed);
|
|
20693
|
+
const defaultProfile = typeof table.default_permissions === "string" ? table.default_permissions : void 0;
|
|
20694
|
+
const permissionsTable = toMutableTable(table.permissions);
|
|
20695
|
+
const profile = toCodexProfile(permissionsTable[defaultProfile ?? RULESYNC_PROFILE_NAME]) ?? toCodexProfile(permissionsTable[RULESYNC_PROFILE_NAME]);
|
|
20696
|
+
const config = convertCodexProfileToRulesync(profile);
|
|
20697
|
+
return this.toRulesyncPermissionsDefault({
|
|
20698
|
+
fileContent: JSON.stringify(config, null, 2)
|
|
20699
|
+
});
|
|
20700
|
+
}
|
|
20701
|
+
validate() {
|
|
20702
|
+
return { success: true, error: null };
|
|
20703
|
+
}
|
|
20704
|
+
static forDeletion({
|
|
20705
|
+
baseDir = process.cwd(),
|
|
20706
|
+
relativeDirPath,
|
|
20707
|
+
relativeFilePath
|
|
20708
|
+
}) {
|
|
20709
|
+
return new _CodexcliPermissions({
|
|
20710
|
+
baseDir,
|
|
20711
|
+
relativeDirPath,
|
|
20712
|
+
relativeFilePath,
|
|
20713
|
+
fileContent: smolToml5.stringify({}),
|
|
20714
|
+
validate: false
|
|
20715
|
+
});
|
|
20716
|
+
}
|
|
20717
|
+
};
|
|
20718
|
+
function convertRulesyncToCodexProfile({
|
|
20719
|
+
config,
|
|
20720
|
+
logger: logger5
|
|
20721
|
+
}) {
|
|
20722
|
+
const filesystem = {};
|
|
20723
|
+
const domains = {};
|
|
20724
|
+
for (const [toolName, rules] of Object.entries(config.permission)) {
|
|
20725
|
+
if (toolName === "read") {
|
|
20726
|
+
for (const [pattern, action] of Object.entries(rules)) {
|
|
20727
|
+
filesystem[pattern] = mapReadAction(action);
|
|
20728
|
+
}
|
|
20729
|
+
continue;
|
|
20730
|
+
}
|
|
20731
|
+
if (toolName === "edit" || toolName === "write") {
|
|
20732
|
+
for (const [pattern, action] of Object.entries(rules)) {
|
|
20733
|
+
filesystem[pattern] = mapWriteAction(action);
|
|
20734
|
+
}
|
|
20735
|
+
continue;
|
|
20736
|
+
}
|
|
20737
|
+
if (toolName === "webfetch") {
|
|
20738
|
+
for (const [pattern, action] of Object.entries(rules)) {
|
|
20739
|
+
if (action === "ask") {
|
|
20740
|
+
logger5?.warn(
|
|
20741
|
+
`Codex CLI does not support "ask" for network domain permissions. Skipping webfetch rule: ${pattern}`
|
|
20742
|
+
);
|
|
20743
|
+
continue;
|
|
20744
|
+
}
|
|
20745
|
+
domains[pattern] = action;
|
|
20746
|
+
}
|
|
20747
|
+
continue;
|
|
20748
|
+
}
|
|
20749
|
+
logger5?.warn(
|
|
20750
|
+
`Codex CLI permissions support only read/edit/write/webfetch categories. Skipping: ${toolName}`
|
|
20751
|
+
);
|
|
20752
|
+
}
|
|
20753
|
+
return {
|
|
20754
|
+
...Object.keys(filesystem).length > 0 ? { filesystem } : {},
|
|
20755
|
+
...Object.keys(domains).length > 0 ? { network: { domains } } : {}
|
|
20756
|
+
};
|
|
20757
|
+
}
|
|
20758
|
+
function convertCodexProfileToRulesync(profile) {
|
|
20759
|
+
const permission = {};
|
|
20760
|
+
if (profile?.filesystem) {
|
|
20761
|
+
permission.read = {};
|
|
20762
|
+
permission.edit = {};
|
|
20763
|
+
for (const [pattern, access] of Object.entries(profile.filesystem)) {
|
|
20764
|
+
if (access === "none") {
|
|
20765
|
+
permission.read[pattern] = "deny";
|
|
20766
|
+
permission.edit[pattern] = "deny";
|
|
20767
|
+
} else if (access === "read") {
|
|
20768
|
+
permission.read[pattern] = "allow";
|
|
20769
|
+
} else {
|
|
20770
|
+
permission.edit[pattern] = "allow";
|
|
20771
|
+
}
|
|
20772
|
+
}
|
|
20773
|
+
}
|
|
20774
|
+
if (profile?.network?.domains) {
|
|
20775
|
+
permission.webfetch = {};
|
|
20776
|
+
for (const [domain, value] of Object.entries(profile.network.domains)) {
|
|
20777
|
+
permission.webfetch[domain] = value;
|
|
20778
|
+
}
|
|
20779
|
+
}
|
|
20780
|
+
return { permission };
|
|
20781
|
+
}
|
|
20782
|
+
function toCodexProfile(value) {
|
|
20783
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
20784
|
+
const table = toMutableTable(value);
|
|
20785
|
+
const filesystem = toFilesystemRecord(table.filesystem);
|
|
20786
|
+
const networkRaw = toMutableTable(table.network);
|
|
20787
|
+
const domains = toDomainRecord(networkRaw.domains);
|
|
20788
|
+
return {
|
|
20789
|
+
...filesystem ? { filesystem } : {},
|
|
20790
|
+
...domains ? { network: { domains } } : {}
|
|
20791
|
+
};
|
|
20792
|
+
}
|
|
20793
|
+
function toMutableTable(value) {
|
|
20794
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) {
|
|
20795
|
+
return {};
|
|
20796
|
+
}
|
|
20797
|
+
return { ...value };
|
|
20798
|
+
}
|
|
20799
|
+
function toFilesystemRecord(value) {
|
|
20800
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
20801
|
+
const result = {};
|
|
20802
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
20803
|
+
if (typeof raw !== "string") continue;
|
|
20804
|
+
if (raw === "read" || raw === "write" || raw === "none") {
|
|
20805
|
+
result[key] = raw;
|
|
20806
|
+
}
|
|
20807
|
+
}
|
|
20808
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
20809
|
+
}
|
|
20810
|
+
function toDomainRecord(value) {
|
|
20811
|
+
if (!value || typeof value !== "object" || Array.isArray(value)) return void 0;
|
|
20812
|
+
const result = {};
|
|
20813
|
+
for (const [key, raw] of Object.entries(value)) {
|
|
20814
|
+
if (raw === "allow" || raw === "deny") {
|
|
20815
|
+
result[key] = raw;
|
|
20816
|
+
}
|
|
20817
|
+
}
|
|
20818
|
+
return Object.keys(result).length > 0 ? result : void 0;
|
|
20819
|
+
}
|
|
20820
|
+
function mapReadAction(action) {
|
|
20821
|
+
return action === "allow" ? "read" : "none";
|
|
20822
|
+
}
|
|
20823
|
+
function mapWriteAction(action) {
|
|
20824
|
+
return action === "allow" ? "write" : "none";
|
|
20825
|
+
}
|
|
20826
|
+
|
|
20827
|
+
// src/features/permissions/geminicli-permissions.ts
|
|
20828
|
+
var import_node_path138 = require("path");
|
|
20829
|
+
var import_mini71 = require("zod/mini");
|
|
20830
|
+
var GeminiCliSettingsSchema = import_mini71.z.looseObject({
|
|
20831
|
+
tools: import_mini71.z.optional(
|
|
20832
|
+
import_mini71.z.looseObject({
|
|
20833
|
+
allowed: import_mini71.z.optional(import_mini71.z.array(import_mini71.z.string())),
|
|
20834
|
+
exclude: import_mini71.z.optional(import_mini71.z.array(import_mini71.z.string()))
|
|
20835
|
+
})
|
|
20836
|
+
)
|
|
20837
|
+
});
|
|
20838
|
+
var RULESYNC_TO_GEMINICLI_TOOL_NAME = {
|
|
20839
|
+
bash: "run_shell_command",
|
|
20840
|
+
read: "read_file",
|
|
20841
|
+
edit: "replace",
|
|
20842
|
+
write: "write_file",
|
|
20843
|
+
webfetch: "web_fetch"
|
|
20844
|
+
};
|
|
20845
|
+
var GeminicliPermissions = class _GeminicliPermissions extends ToolPermissions {
|
|
20846
|
+
static getSettablePaths(_options = {}) {
|
|
20847
|
+
return {
|
|
20848
|
+
relativeDirPath: ".gemini",
|
|
20849
|
+
relativeFilePath: "settings.json"
|
|
20850
|
+
};
|
|
20851
|
+
}
|
|
20852
|
+
isDeletable() {
|
|
20853
|
+
return false;
|
|
20854
|
+
}
|
|
20855
|
+
static async fromFile({
|
|
20856
|
+
baseDir = process.cwd(),
|
|
20857
|
+
validate = true,
|
|
20858
|
+
global = false
|
|
20859
|
+
}) {
|
|
20860
|
+
const paths = this.getSettablePaths({ global });
|
|
20861
|
+
const filePath = (0, import_node_path138.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
20862
|
+
const fileContent = await readFileContentOrNull(filePath) ?? JSON.stringify({}, null, 2);
|
|
20863
|
+
return new _GeminicliPermissions({
|
|
20864
|
+
baseDir,
|
|
20865
|
+
relativeDirPath: paths.relativeDirPath,
|
|
20866
|
+
relativeFilePath: paths.relativeFilePath,
|
|
20867
|
+
fileContent,
|
|
20868
|
+
validate
|
|
20869
|
+
});
|
|
20870
|
+
}
|
|
20871
|
+
static async fromRulesyncPermissions({
|
|
20872
|
+
baseDir = process.cwd(),
|
|
20873
|
+
rulesyncPermissions,
|
|
20874
|
+
validate = true,
|
|
20875
|
+
logger: logger5,
|
|
20876
|
+
global = false
|
|
20877
|
+
}) {
|
|
20878
|
+
const paths = this.getSettablePaths({ global });
|
|
20879
|
+
const filePath = (0, import_node_path138.join)(baseDir, paths.relativeDirPath, paths.relativeFilePath);
|
|
20880
|
+
const existingContent = await readFileContentOrNull(filePath) ?? JSON.stringify({}, null, 2);
|
|
20881
|
+
const settingsResult = GeminiCliSettingsSchema.safeParse(JSON.parse(existingContent));
|
|
20882
|
+
if (!settingsResult.success) {
|
|
20883
|
+
throw new Error(
|
|
20884
|
+
`Failed to parse existing Gemini CLI settings at ${filePath}: ${formatError(settingsResult.error)}`
|
|
20885
|
+
);
|
|
20886
|
+
}
|
|
20887
|
+
const { allowed, exclude } = convertRulesyncToGeminicliTools({
|
|
20888
|
+
config: rulesyncPermissions.getJson(),
|
|
20889
|
+
logger: logger5
|
|
20890
|
+
});
|
|
20891
|
+
const merged = {
|
|
20892
|
+
...settingsResult.data,
|
|
20893
|
+
tools: {
|
|
20894
|
+
...settingsResult.data.tools,
|
|
20895
|
+
...allowed.length > 0 ? { allowed } : {},
|
|
20896
|
+
...exclude.length > 0 ? { exclude } : {}
|
|
20897
|
+
}
|
|
20898
|
+
};
|
|
20899
|
+
return new _GeminicliPermissions({
|
|
20900
|
+
baseDir,
|
|
20901
|
+
relativeDirPath: paths.relativeDirPath,
|
|
20902
|
+
relativeFilePath: paths.relativeFilePath,
|
|
20903
|
+
fileContent: JSON.stringify(merged, null, 2),
|
|
20904
|
+
validate
|
|
20905
|
+
});
|
|
20906
|
+
}
|
|
20907
|
+
toRulesyncPermissions() {
|
|
20908
|
+
let settings;
|
|
20909
|
+
try {
|
|
20910
|
+
const parsed = JSON.parse(this.getFileContent());
|
|
20911
|
+
settings = GeminiCliSettingsSchema.parse(parsed);
|
|
20912
|
+
} catch (error) {
|
|
20913
|
+
throw new Error(
|
|
20914
|
+
`Failed to parse Gemini CLI permissions content in ${(0, import_node_path138.join)(this.getRelativeDirPath(), this.getRelativeFilePath())}: ${formatError(error)}`,
|
|
20915
|
+
{ cause: error }
|
|
20916
|
+
);
|
|
20917
|
+
}
|
|
20918
|
+
const permission = {};
|
|
20919
|
+
for (const toolEntry of settings.tools?.allowed ?? []) {
|
|
20920
|
+
const mapped = parseGeminicliToolEntry({ entry: toolEntry });
|
|
20921
|
+
const rules = permission[mapped.category] ??= {};
|
|
20922
|
+
rules[mapped.pattern] = "allow";
|
|
20923
|
+
}
|
|
20924
|
+
for (const toolEntry of settings.tools?.exclude ?? []) {
|
|
20925
|
+
const mapped = parseGeminicliToolEntry({ entry: toolEntry });
|
|
20926
|
+
const rules = permission[mapped.category] ??= {};
|
|
20927
|
+
rules[mapped.pattern] = "deny";
|
|
20928
|
+
}
|
|
20929
|
+
return this.toRulesyncPermissionsDefault({
|
|
20930
|
+
fileContent: JSON.stringify({ permission }, null, 2)
|
|
20931
|
+
});
|
|
20932
|
+
}
|
|
20933
|
+
validate() {
|
|
20934
|
+
return { success: true, error: null };
|
|
20935
|
+
}
|
|
20936
|
+
static forDeletion({
|
|
20937
|
+
baseDir = process.cwd(),
|
|
20938
|
+
relativeDirPath,
|
|
20939
|
+
relativeFilePath
|
|
20940
|
+
}) {
|
|
20941
|
+
return new _GeminicliPermissions({
|
|
20942
|
+
baseDir,
|
|
20943
|
+
relativeDirPath,
|
|
20944
|
+
relativeFilePath,
|
|
20945
|
+
fileContent: JSON.stringify({}, null, 2),
|
|
20946
|
+
validate: false
|
|
20947
|
+
});
|
|
20948
|
+
}
|
|
20949
|
+
};
|
|
20950
|
+
function convertRulesyncToGeminicliTools({
|
|
20951
|
+
config,
|
|
20952
|
+
logger: logger5
|
|
20953
|
+
}) {
|
|
20954
|
+
const allowed = [];
|
|
20955
|
+
const exclude = [];
|
|
20956
|
+
for (const [toolName, rules] of Object.entries(config.permission)) {
|
|
20957
|
+
const mappedToolName = RULESYNC_TO_GEMINICLI_TOOL_NAME[toolName] ?? toolName;
|
|
20958
|
+
if (!RULESYNC_TO_GEMINICLI_TOOL_NAME[toolName]) {
|
|
20959
|
+
logger5?.warn(`Gemini CLI permissions use direct tool names. Mapping as-is: ${toolName}`);
|
|
20960
|
+
}
|
|
20961
|
+
for (const [pattern, action] of Object.entries(rules)) {
|
|
20962
|
+
if (action === "ask") {
|
|
20963
|
+
logger5?.warn(
|
|
20964
|
+
`Gemini CLI does not support explicit "ask" rules in settings. Skipping ${toolName}:${pattern}`
|
|
20965
|
+
);
|
|
20966
|
+
continue;
|
|
20967
|
+
}
|
|
20968
|
+
const geminiEntry = pattern === "*" ? mappedToolName : `${mappedToolName}(${pattern})`;
|
|
20969
|
+
if (action === "allow") {
|
|
20970
|
+
allowed.push(geminiEntry);
|
|
20971
|
+
} else {
|
|
20972
|
+
exclude.push(geminiEntry);
|
|
20973
|
+
}
|
|
20974
|
+
}
|
|
20975
|
+
}
|
|
20976
|
+
return { allowed, exclude };
|
|
20977
|
+
}
|
|
20978
|
+
function parseGeminicliToolEntry({ entry }) {
|
|
20979
|
+
const match = /^([^()]+?)(?:\((.*)\))?$/.exec(entry);
|
|
20980
|
+
if (!match) return { category: entry, pattern: "*" };
|
|
20981
|
+
const rawToolName = match[1]?.trim() ?? entry;
|
|
20982
|
+
const mappedCategory = Object.entries(RULESYNC_TO_GEMINICLI_TOOL_NAME).find(
|
|
20983
|
+
([, value]) => value === rawToolName
|
|
20984
|
+
)?.[0];
|
|
20985
|
+
return {
|
|
20986
|
+
category: mappedCategory ?? rawToolName,
|
|
20987
|
+
pattern: (match[2] ?? "*").trim()
|
|
20988
|
+
};
|
|
20989
|
+
}
|
|
20990
|
+
|
|
20991
|
+
// src/features/permissions/opencode-permissions.ts
|
|
20992
|
+
var import_node_path139 = require("path");
|
|
20993
|
+
var import_jsonc_parser5 = require("jsonc-parser");
|
|
20994
|
+
var import_mini72 = require("zod/mini");
|
|
20995
|
+
var OpencodePermissionSchema = import_mini72.z.union([
|
|
20996
|
+
import_mini72.z.enum(["allow", "ask", "deny"]),
|
|
20997
|
+
import_mini72.z.record(import_mini72.z.string(), import_mini72.z.enum(["allow", "ask", "deny"]))
|
|
20998
|
+
]);
|
|
20999
|
+
var OpencodePermissionsConfigSchema = import_mini72.z.looseObject({
|
|
21000
|
+
permission: import_mini72.z.optional(import_mini72.z.record(import_mini72.z.string(), OpencodePermissionSchema))
|
|
21001
|
+
});
|
|
21002
|
+
var OpencodePermissions = class _OpencodePermissions extends ToolPermissions {
|
|
21003
|
+
json;
|
|
21004
|
+
constructor(params) {
|
|
21005
|
+
super(params);
|
|
21006
|
+
this.json = OpencodePermissionsConfigSchema.parse((0, import_jsonc_parser5.parse)(this.fileContent || "{}"));
|
|
21007
|
+
}
|
|
21008
|
+
getJson() {
|
|
21009
|
+
return this.json;
|
|
21010
|
+
}
|
|
21011
|
+
isDeletable() {
|
|
21012
|
+
return false;
|
|
21013
|
+
}
|
|
21014
|
+
static getSettablePaths({
|
|
21015
|
+
global = false
|
|
21016
|
+
} = {}) {
|
|
21017
|
+
return global ? { relativeDirPath: (0, import_node_path139.join)(".config", "opencode"), relativeFilePath: "opencode.json" } : { relativeDirPath: ".", relativeFilePath: "opencode.json" };
|
|
21018
|
+
}
|
|
21019
|
+
static async fromFile({
|
|
21020
|
+
baseDir = process.cwd(),
|
|
21021
|
+
validate = true,
|
|
21022
|
+
global = false
|
|
21023
|
+
}) {
|
|
21024
|
+
const basePaths = _OpencodePermissions.getSettablePaths({ global });
|
|
21025
|
+
const jsonDir = (0, import_node_path139.join)(baseDir, basePaths.relativeDirPath);
|
|
21026
|
+
const jsoncPath = (0, import_node_path139.join)(jsonDir, "opencode.jsonc");
|
|
21027
|
+
const jsonPath = (0, import_node_path139.join)(jsonDir, "opencode.json");
|
|
21028
|
+
let fileContent = await readFileContentOrNull(jsoncPath);
|
|
21029
|
+
let relativeFilePath = "opencode.jsonc";
|
|
21030
|
+
if (!fileContent) {
|
|
21031
|
+
fileContent = await readFileContentOrNull(jsonPath);
|
|
21032
|
+
if (fileContent) {
|
|
21033
|
+
relativeFilePath = "opencode.json";
|
|
21034
|
+
}
|
|
21035
|
+
}
|
|
21036
|
+
const parsed = (0, import_jsonc_parser5.parse)(fileContent ?? "{}");
|
|
21037
|
+
const nextJson = { ...parsed, permission: parsed.permission ?? {} };
|
|
21038
|
+
return new _OpencodePermissions({
|
|
21039
|
+
baseDir,
|
|
21040
|
+
relativeDirPath: basePaths.relativeDirPath,
|
|
21041
|
+
relativeFilePath,
|
|
21042
|
+
fileContent: JSON.stringify(nextJson, null, 2),
|
|
21043
|
+
validate
|
|
21044
|
+
});
|
|
21045
|
+
}
|
|
21046
|
+
static async fromRulesyncPermissions({
|
|
21047
|
+
baseDir = process.cwd(),
|
|
21048
|
+
rulesyncPermissions,
|
|
21049
|
+
global = false
|
|
21050
|
+
}) {
|
|
21051
|
+
const basePaths = _OpencodePermissions.getSettablePaths({ global });
|
|
21052
|
+
const jsonDir = (0, import_node_path139.join)(baseDir, basePaths.relativeDirPath);
|
|
21053
|
+
const jsoncPath = (0, import_node_path139.join)(jsonDir, "opencode.jsonc");
|
|
21054
|
+
const jsonPath = (0, import_node_path139.join)(jsonDir, "opencode.json");
|
|
21055
|
+
let fileContent = await readFileContentOrNull(jsoncPath);
|
|
21056
|
+
let relativeFilePath = "opencode.jsonc";
|
|
21057
|
+
if (!fileContent) {
|
|
21058
|
+
fileContent = await readFileContentOrNull(jsonPath);
|
|
21059
|
+
if (fileContent) {
|
|
21060
|
+
relativeFilePath = "opencode.json";
|
|
21061
|
+
}
|
|
21062
|
+
}
|
|
21063
|
+
const parsed = (0, import_jsonc_parser5.parse)(fileContent ?? "{}");
|
|
21064
|
+
const nextJson = {
|
|
21065
|
+
...parsed,
|
|
21066
|
+
permission: rulesyncPermissions.getJson().permission
|
|
21067
|
+
};
|
|
21068
|
+
return new _OpencodePermissions({
|
|
21069
|
+
baseDir,
|
|
21070
|
+
relativeDirPath: basePaths.relativeDirPath,
|
|
21071
|
+
relativeFilePath,
|
|
21072
|
+
fileContent: JSON.stringify(nextJson, null, 2),
|
|
21073
|
+
validate: true
|
|
21074
|
+
});
|
|
21075
|
+
}
|
|
21076
|
+
toRulesyncPermissions() {
|
|
21077
|
+
const permission = this.normalizePermission(this.json.permission);
|
|
21078
|
+
return this.toRulesyncPermissionsDefault({
|
|
21079
|
+
fileContent: JSON.stringify({ permission }, null, 2)
|
|
21080
|
+
});
|
|
21081
|
+
}
|
|
21082
|
+
validate() {
|
|
21083
|
+
try {
|
|
21084
|
+
const json = JSON.parse(this.fileContent || "{}");
|
|
21085
|
+
const result = OpencodePermissionsConfigSchema.safeParse(json);
|
|
21086
|
+
if (!result.success) {
|
|
21087
|
+
return { success: false, error: result.error };
|
|
21088
|
+
}
|
|
21089
|
+
return { success: true, error: null };
|
|
21090
|
+
} catch (error) {
|
|
21091
|
+
return {
|
|
21092
|
+
success: false,
|
|
21093
|
+
error: new Error(`Failed to parse OpenCode permissions JSON: ${formatError(error)}`)
|
|
21094
|
+
};
|
|
21095
|
+
}
|
|
21096
|
+
}
|
|
21097
|
+
static forDeletion({
|
|
21098
|
+
baseDir = process.cwd(),
|
|
21099
|
+
relativeDirPath,
|
|
21100
|
+
relativeFilePath
|
|
21101
|
+
}) {
|
|
21102
|
+
return new _OpencodePermissions({
|
|
21103
|
+
baseDir,
|
|
21104
|
+
relativeDirPath,
|
|
21105
|
+
relativeFilePath,
|
|
21106
|
+
fileContent: JSON.stringify({ permission: {} }, null, 2),
|
|
21107
|
+
validate: false
|
|
21108
|
+
});
|
|
21109
|
+
}
|
|
21110
|
+
normalizePermission(permission) {
|
|
21111
|
+
if (!permission) {
|
|
21112
|
+
return {};
|
|
21113
|
+
}
|
|
21114
|
+
return Object.fromEntries(
|
|
21115
|
+
Object.entries(permission).map(([tool, value]) => [
|
|
21116
|
+
tool,
|
|
21117
|
+
typeof value === "string" ? { "*": value } : value
|
|
21118
|
+
])
|
|
21119
|
+
);
|
|
21120
|
+
}
|
|
21121
|
+
};
|
|
21122
|
+
|
|
21123
|
+
// src/features/permissions/permissions-processor.ts
|
|
21124
|
+
var permissionsProcessorToolTargetTuple = [
|
|
21125
|
+
"claudecode",
|
|
21126
|
+
"codexcli",
|
|
21127
|
+
"geminicli",
|
|
21128
|
+
"opencode"
|
|
21129
|
+
];
|
|
21130
|
+
var PermissionsProcessorToolTargetSchema = import_mini73.z.enum(permissionsProcessorToolTargetTuple);
|
|
21131
|
+
var toolPermissionsFactories = /* @__PURE__ */ new Map([
|
|
21132
|
+
[
|
|
21133
|
+
"claudecode",
|
|
21134
|
+
{
|
|
21135
|
+
class: ClaudecodePermissions,
|
|
21136
|
+
meta: {
|
|
21137
|
+
supportsProject: true,
|
|
21138
|
+
supportsGlobal: false,
|
|
21139
|
+
supportsImport: true
|
|
21140
|
+
}
|
|
21141
|
+
}
|
|
21142
|
+
],
|
|
21143
|
+
[
|
|
21144
|
+
"codexcli",
|
|
21145
|
+
{
|
|
21146
|
+
class: CodexcliPermissions,
|
|
21147
|
+
meta: {
|
|
21148
|
+
supportsProject: true,
|
|
21149
|
+
supportsGlobal: true,
|
|
21150
|
+
supportsImport: true
|
|
21151
|
+
}
|
|
21152
|
+
}
|
|
21153
|
+
],
|
|
21154
|
+
[
|
|
21155
|
+
"geminicli",
|
|
21156
|
+
{
|
|
21157
|
+
class: GeminicliPermissions,
|
|
21158
|
+
meta: {
|
|
21159
|
+
supportsProject: true,
|
|
21160
|
+
supportsGlobal: true,
|
|
21161
|
+
supportsImport: true
|
|
21162
|
+
}
|
|
21163
|
+
}
|
|
21164
|
+
],
|
|
21165
|
+
[
|
|
21166
|
+
"opencode",
|
|
21167
|
+
{
|
|
21168
|
+
class: OpencodePermissions,
|
|
21169
|
+
meta: {
|
|
21170
|
+
supportsProject: true,
|
|
21171
|
+
supportsGlobal: true,
|
|
21172
|
+
supportsImport: true
|
|
21173
|
+
}
|
|
21174
|
+
}
|
|
21175
|
+
]
|
|
21176
|
+
]);
|
|
21177
|
+
var PermissionsProcessor = class extends FeatureProcessor {
|
|
21178
|
+
toolTarget;
|
|
21179
|
+
global;
|
|
21180
|
+
constructor({
|
|
21181
|
+
baseDir = process.cwd(),
|
|
21182
|
+
toolTarget,
|
|
21183
|
+
global = false,
|
|
21184
|
+
dryRun = false,
|
|
21185
|
+
logger: logger5
|
|
21186
|
+
}) {
|
|
21187
|
+
super({ baseDir, dryRun, logger: logger5 });
|
|
21188
|
+
const result = PermissionsProcessorToolTargetSchema.safeParse(toolTarget);
|
|
21189
|
+
if (!result.success) {
|
|
21190
|
+
throw new Error(
|
|
21191
|
+
`Invalid tool target for PermissionsProcessor: ${toolTarget}. ${formatError(result.error)}`
|
|
21192
|
+
);
|
|
21193
|
+
}
|
|
21194
|
+
this.toolTarget = result.data;
|
|
21195
|
+
this.global = global;
|
|
21196
|
+
}
|
|
21197
|
+
async loadRulesyncFiles() {
|
|
21198
|
+
try {
|
|
21199
|
+
return [
|
|
21200
|
+
await RulesyncPermissions.fromFile({
|
|
21201
|
+
baseDir: process.cwd(),
|
|
21202
|
+
validate: true
|
|
21203
|
+
})
|
|
21204
|
+
];
|
|
21205
|
+
} catch (error) {
|
|
21206
|
+
this.logger.error(
|
|
21207
|
+
`Failed to load Rulesync permissions file (${RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH}): ${formatError(error)}`
|
|
21208
|
+
);
|
|
21209
|
+
return [];
|
|
21210
|
+
}
|
|
21211
|
+
}
|
|
21212
|
+
async loadToolFiles({
|
|
21213
|
+
forDeletion = false
|
|
21214
|
+
} = {}) {
|
|
21215
|
+
try {
|
|
21216
|
+
const factory = toolPermissionsFactories.get(this.toolTarget);
|
|
21217
|
+
if (!factory) throw new Error(`Unsupported tool target: ${this.toolTarget}`);
|
|
21218
|
+
const paths = factory.class.getSettablePaths({ global: this.global });
|
|
21219
|
+
if (forDeletion) {
|
|
21220
|
+
const toolPermissions2 = factory.class.forDeletion({
|
|
21221
|
+
baseDir: this.baseDir,
|
|
21222
|
+
relativeDirPath: paths.relativeDirPath,
|
|
21223
|
+
relativeFilePath: paths.relativeFilePath,
|
|
21224
|
+
global: this.global
|
|
21225
|
+
});
|
|
21226
|
+
const list = toolPermissions2.isDeletable?.() !== false ? [toolPermissions2] : [];
|
|
21227
|
+
return list;
|
|
21228
|
+
}
|
|
21229
|
+
const toolPermissions = await factory.class.fromFile({
|
|
21230
|
+
baseDir: this.baseDir,
|
|
21231
|
+
validate: true,
|
|
21232
|
+
global: this.global
|
|
21233
|
+
});
|
|
21234
|
+
return [toolPermissions];
|
|
21235
|
+
} catch (error) {
|
|
21236
|
+
const msg = `Failed to load permissions files for tool target: ${this.toolTarget}: ${formatError(error)}`;
|
|
21237
|
+
if (error instanceof Error && error.message.includes("no such file or directory")) {
|
|
21238
|
+
this.logger.debug(msg);
|
|
21239
|
+
} else {
|
|
21240
|
+
this.logger.error(msg);
|
|
21241
|
+
}
|
|
21242
|
+
return [];
|
|
21243
|
+
}
|
|
21244
|
+
}
|
|
21245
|
+
async convertRulesyncFilesToToolFiles(rulesyncFiles) {
|
|
21246
|
+
const rulesyncPermissions = rulesyncFiles.find(
|
|
21247
|
+
(f) => f instanceof RulesyncPermissions
|
|
21248
|
+
);
|
|
21249
|
+
if (!rulesyncPermissions) {
|
|
21250
|
+
throw new Error(`No ${RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH} found.`);
|
|
21251
|
+
}
|
|
21252
|
+
const factory = toolPermissionsFactories.get(this.toolTarget);
|
|
21253
|
+
if (!factory) throw new Error(`Unsupported tool target: ${this.toolTarget}`);
|
|
21254
|
+
const toolPermissions = await factory.class.fromRulesyncPermissions({
|
|
21255
|
+
baseDir: this.baseDir,
|
|
21256
|
+
rulesyncPermissions,
|
|
21257
|
+
logger: this.logger,
|
|
21258
|
+
global: this.global
|
|
21259
|
+
});
|
|
21260
|
+
return [toolPermissions];
|
|
20058
21261
|
}
|
|
20059
|
-
|
|
20060
|
-
|
|
20061
|
-
|
|
20062
|
-
var getDefaults = () => ({
|
|
20063
|
-
targets: ["agentsmd"],
|
|
20064
|
-
features: ["rules"],
|
|
20065
|
-
verbose: false,
|
|
20066
|
-
delete: false,
|
|
20067
|
-
baseDirs: [process.cwd()],
|
|
20068
|
-
configPath: RULESYNC_CONFIG_RELATIVE_FILE_PATH,
|
|
20069
|
-
global: false,
|
|
20070
|
-
silent: false,
|
|
20071
|
-
simulateCommands: false,
|
|
20072
|
-
simulateSubagents: false,
|
|
20073
|
-
simulateSkills: false,
|
|
20074
|
-
dryRun: false,
|
|
20075
|
-
check: false,
|
|
20076
|
-
sources: []
|
|
20077
|
-
});
|
|
20078
|
-
var loadConfigFromFile = async (filePath) => {
|
|
20079
|
-
if (!await fileExists(filePath)) {
|
|
20080
|
-
return {};
|
|
21262
|
+
async convertToolFilesToRulesyncFiles(toolFiles) {
|
|
21263
|
+
const permissions = toolFiles.filter((f) => f instanceof ToolPermissions);
|
|
21264
|
+
return permissions.map((p) => p.toRulesyncPermissions());
|
|
20081
21265
|
}
|
|
20082
|
-
|
|
20083
|
-
|
|
20084
|
-
|
|
20085
|
-
|
|
20086
|
-
|
|
20087
|
-
};
|
|
20088
|
-
var mergeConfigs = (baseConfig, localConfig) => {
|
|
20089
|
-
return {
|
|
20090
|
-
targets: localConfig.targets ?? baseConfig.targets,
|
|
20091
|
-
features: localConfig.features ?? baseConfig.features,
|
|
20092
|
-
verbose: localConfig.verbose ?? baseConfig.verbose,
|
|
20093
|
-
delete: localConfig.delete ?? baseConfig.delete,
|
|
20094
|
-
baseDirs: localConfig.baseDirs ?? baseConfig.baseDirs,
|
|
20095
|
-
global: localConfig.global ?? baseConfig.global,
|
|
20096
|
-
silent: localConfig.silent ?? baseConfig.silent,
|
|
20097
|
-
simulateCommands: localConfig.simulateCommands ?? baseConfig.simulateCommands,
|
|
20098
|
-
simulateSubagents: localConfig.simulateSubagents ?? baseConfig.simulateSubagents,
|
|
20099
|
-
simulateSkills: localConfig.simulateSkills ?? baseConfig.simulateSkills,
|
|
20100
|
-
dryRun: localConfig.dryRun ?? baseConfig.dryRun,
|
|
20101
|
-
check: localConfig.check ?? baseConfig.check,
|
|
20102
|
-
sources: localConfig.sources ?? baseConfig.sources
|
|
20103
|
-
};
|
|
20104
|
-
};
|
|
20105
|
-
var ConfigResolver = class {
|
|
20106
|
-
static async resolve({
|
|
20107
|
-
targets,
|
|
20108
|
-
features,
|
|
20109
|
-
verbose,
|
|
20110
|
-
delete: isDelete,
|
|
20111
|
-
baseDirs,
|
|
20112
|
-
configPath = getDefaults().configPath,
|
|
20113
|
-
global,
|
|
20114
|
-
silent,
|
|
20115
|
-
simulateCommands,
|
|
20116
|
-
simulateSubagents,
|
|
20117
|
-
simulateSkills,
|
|
20118
|
-
dryRun,
|
|
20119
|
-
check
|
|
20120
|
-
}) {
|
|
20121
|
-
const validatedConfigPath = resolvePath(configPath, process.cwd());
|
|
20122
|
-
const baseConfig = await loadConfigFromFile(validatedConfigPath);
|
|
20123
|
-
const configDir = (0, import_node_path134.dirname)(validatedConfigPath);
|
|
20124
|
-
const localConfigPath = (0, import_node_path134.join)(configDir, RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH);
|
|
20125
|
-
const localConfig = await loadConfigFromFile(localConfigPath);
|
|
20126
|
-
const configByFile = mergeConfigs(baseConfig, localConfig);
|
|
20127
|
-
const resolvedGlobal = global ?? configByFile.global ?? getDefaults().global;
|
|
20128
|
-
const resolvedSimulateCommands = simulateCommands ?? configByFile.simulateCommands ?? getDefaults().simulateCommands;
|
|
20129
|
-
const resolvedSimulateSubagents = simulateSubagents ?? configByFile.simulateSubagents ?? getDefaults().simulateSubagents;
|
|
20130
|
-
const resolvedSimulateSkills = simulateSkills ?? configByFile.simulateSkills ?? getDefaults().simulateSkills;
|
|
20131
|
-
const configParams = {
|
|
20132
|
-
targets: targets ?? configByFile.targets ?? getDefaults().targets,
|
|
20133
|
-
features: features ?? configByFile.features ?? getDefaults().features,
|
|
20134
|
-
verbose: verbose ?? configByFile.verbose ?? getDefaults().verbose,
|
|
20135
|
-
delete: isDelete ?? configByFile.delete ?? getDefaults().delete,
|
|
20136
|
-
baseDirs: getBaseDirsInLightOfGlobal({
|
|
20137
|
-
baseDirs: baseDirs ?? configByFile.baseDirs ?? getDefaults().baseDirs,
|
|
20138
|
-
global: resolvedGlobal
|
|
20139
|
-
}),
|
|
20140
|
-
global: resolvedGlobal,
|
|
20141
|
-
silent: silent ?? configByFile.silent ?? getDefaults().silent,
|
|
20142
|
-
simulateCommands: resolvedSimulateCommands,
|
|
20143
|
-
simulateSubagents: resolvedSimulateSubagents,
|
|
20144
|
-
simulateSkills: resolvedSimulateSkills,
|
|
20145
|
-
dryRun: dryRun ?? configByFile.dryRun ?? getDefaults().dryRun,
|
|
20146
|
-
check: check ?? configByFile.check ?? getDefaults().check,
|
|
20147
|
-
sources: configByFile.sources ?? getDefaults().sources
|
|
20148
|
-
};
|
|
20149
|
-
return new Config(configParams);
|
|
21266
|
+
static getToolTargets({
|
|
21267
|
+
global = false,
|
|
21268
|
+
importOnly = false
|
|
21269
|
+
} = {}) {
|
|
21270
|
+
return [...toolPermissionsFactories.entries()].filter(([, f]) => global ? f.meta.supportsGlobal : f.meta.supportsProject).filter(([, f]) => importOnly ? f.meta.supportsImport : true).map(([target]) => target);
|
|
20150
21271
|
}
|
|
20151
21272
|
};
|
|
20152
|
-
function getBaseDirsInLightOfGlobal({
|
|
20153
|
-
baseDirs,
|
|
20154
|
-
global
|
|
20155
|
-
}) {
|
|
20156
|
-
if (global) {
|
|
20157
|
-
return [getHomeDirectory()];
|
|
20158
|
-
}
|
|
20159
|
-
const resolvedBaseDirs = baseDirs.map((baseDir) => (0, import_node_path134.resolve)(baseDir));
|
|
20160
|
-
resolvedBaseDirs.forEach((baseDir) => {
|
|
20161
|
-
validateBaseDir(baseDir);
|
|
20162
|
-
});
|
|
20163
|
-
return resolvedBaseDirs;
|
|
20164
|
-
}
|
|
20165
21273
|
|
|
20166
21274
|
// src/lib/generate.ts
|
|
20167
|
-
var import_node_path135 = require("path");
|
|
20168
|
-
var import_es_toolkit4 = require("es-toolkit");
|
|
20169
21275
|
async function processFeatureGeneration(params) {
|
|
20170
21276
|
const { config, processor, toolFiles } = params;
|
|
20171
21277
|
let totalCount = 0;
|
|
@@ -20238,7 +21344,7 @@ function warnUnsupportedTargets(params) {
|
|
|
20238
21344
|
}
|
|
20239
21345
|
}
|
|
20240
21346
|
async function checkRulesyncDirExists(params) {
|
|
20241
|
-
return fileExists((0,
|
|
21347
|
+
return fileExists((0, import_node_path140.join)(params.baseDir, RULESYNC_RELATIVE_DIR_PATH));
|
|
20242
21348
|
}
|
|
20243
21349
|
async function generate(params) {
|
|
20244
21350
|
const { config, logger: logger5 } = params;
|
|
@@ -20248,8 +21354,9 @@ async function generate(params) {
|
|
|
20248
21354
|
const subagentsResult = await generateSubagentsCore({ config, logger: logger5 });
|
|
20249
21355
|
const skillsResult = await generateSkillsCore({ config, logger: logger5 });
|
|
20250
21356
|
const hooksResult = await generateHooksCore({ config, logger: logger5 });
|
|
21357
|
+
const permissionsResult = await generatePermissionsCore({ config, logger: logger5 });
|
|
20251
21358
|
const rulesResult = await generateRulesCore({ config, logger: logger5, skills: skillsResult.skills });
|
|
20252
|
-
const hasDiff = ignoreResult.hasDiff || mcpResult.hasDiff || commandsResult.hasDiff || subagentsResult.hasDiff || skillsResult.hasDiff || hooksResult.hasDiff || rulesResult.hasDiff;
|
|
21359
|
+
const hasDiff = ignoreResult.hasDiff || mcpResult.hasDiff || commandsResult.hasDiff || subagentsResult.hasDiff || skillsResult.hasDiff || hooksResult.hasDiff || permissionsResult.hasDiff || rulesResult.hasDiff;
|
|
20253
21360
|
return {
|
|
20254
21361
|
rulesCount: rulesResult.count,
|
|
20255
21362
|
rulesPaths: rulesResult.paths,
|
|
@@ -20265,6 +21372,8 @@ async function generate(params) {
|
|
|
20265
21372
|
skillsPaths: skillsResult.paths,
|
|
20266
21373
|
hooksCount: hooksResult.count,
|
|
20267
21374
|
hooksPaths: hooksResult.paths,
|
|
21375
|
+
permissionsCount: permissionsResult.count,
|
|
21376
|
+
permissionsPaths: permissionsResult.paths,
|
|
20268
21377
|
skills: skillsResult.skills,
|
|
20269
21378
|
hasDiff
|
|
20270
21379
|
};
|
|
@@ -20275,7 +21384,7 @@ async function generateRulesCore(params) {
|
|
|
20275
21384
|
const allPaths = [];
|
|
20276
21385
|
let hasDiff = false;
|
|
20277
21386
|
const supportedTargets = RulesProcessor.getToolTargets({ global: config.getGlobal() });
|
|
20278
|
-
const toolTargets = (0,
|
|
21387
|
+
const toolTargets = (0, import_es_toolkit5.intersection)(config.getTargets(), supportedTargets);
|
|
20279
21388
|
warnUnsupportedTargets({ config, supportedTargets, featureName: "rules", logger: logger5 });
|
|
20280
21389
|
for (const baseDir of config.getBaseDirs()) {
|
|
20281
21390
|
for (const toolTarget of toolTargets) {
|
|
@@ -20290,6 +21399,7 @@ async function generateRulesCore(params) {
|
|
|
20290
21399
|
simulateSubagents: config.getSimulateSubagents(),
|
|
20291
21400
|
simulateSkills: config.getSimulateSkills(),
|
|
20292
21401
|
skills,
|
|
21402
|
+
featureOptions: config.getFeatureOptions(toolTarget, "rules"),
|
|
20293
21403
|
dryRun: config.isPreviewMode(),
|
|
20294
21404
|
logger: logger5
|
|
20295
21405
|
});
|
|
@@ -20317,7 +21427,7 @@ async function generateIgnoreCore(params) {
|
|
|
20317
21427
|
let totalCount = 0;
|
|
20318
21428
|
const allPaths = [];
|
|
20319
21429
|
let hasDiff = false;
|
|
20320
|
-
for (const toolTarget of (0,
|
|
21430
|
+
for (const toolTarget of (0, import_es_toolkit5.intersection)(config.getTargets(), supportedIgnoreTargets)) {
|
|
20321
21431
|
if (!config.getFeatures(toolTarget).includes("ignore")) {
|
|
20322
21432
|
continue;
|
|
20323
21433
|
}
|
|
@@ -20327,7 +21437,8 @@ async function generateIgnoreCore(params) {
|
|
|
20327
21437
|
baseDir: baseDir === process.cwd() ? "." : baseDir,
|
|
20328
21438
|
toolTarget,
|
|
20329
21439
|
dryRun: config.isPreviewMode(),
|
|
20330
|
-
logger: logger5
|
|
21440
|
+
logger: logger5,
|
|
21441
|
+
featureOptions: config.getFeatureOptions(toolTarget, "ignore")
|
|
20331
21442
|
});
|
|
20332
21443
|
const rulesyncFiles = await processor.loadRulesyncFiles();
|
|
20333
21444
|
const result = await processFeatureWithRulesyncFiles({ config, processor, rulesyncFiles });
|
|
@@ -20350,7 +21461,7 @@ async function generateMcpCore(params) {
|
|
|
20350
21461
|
const allPaths = [];
|
|
20351
21462
|
let hasDiff = false;
|
|
20352
21463
|
const supportedMcpTargets = McpProcessor.getToolTargets({ global: config.getGlobal() });
|
|
20353
|
-
const toolTargets = (0,
|
|
21464
|
+
const toolTargets = (0, import_es_toolkit5.intersection)(config.getTargets(), supportedMcpTargets);
|
|
20354
21465
|
warnUnsupportedTargets({
|
|
20355
21466
|
config,
|
|
20356
21467
|
supportedTargets: supportedMcpTargets,
|
|
@@ -20387,7 +21498,7 @@ async function generateCommandsCore(params) {
|
|
|
20387
21498
|
global: config.getGlobal(),
|
|
20388
21499
|
includeSimulated: config.getSimulateCommands()
|
|
20389
21500
|
});
|
|
20390
|
-
const toolTargets = (0,
|
|
21501
|
+
const toolTargets = (0, import_es_toolkit5.intersection)(config.getTargets(), supportedCommandsTargets);
|
|
20391
21502
|
warnUnsupportedTargets({
|
|
20392
21503
|
config,
|
|
20393
21504
|
supportedTargets: supportedCommandsTargets,
|
|
@@ -20425,7 +21536,7 @@ async function generateSubagentsCore(params) {
|
|
|
20425
21536
|
global: config.getGlobal(),
|
|
20426
21537
|
includeSimulated: config.getSimulateSubagents()
|
|
20427
21538
|
});
|
|
20428
|
-
const toolTargets = (0,
|
|
21539
|
+
const toolTargets = (0, import_es_toolkit5.intersection)(config.getTargets(), supportedSubagentsTargets);
|
|
20429
21540
|
warnUnsupportedTargets({
|
|
20430
21541
|
config,
|
|
20431
21542
|
supportedTargets: supportedSubagentsTargets,
|
|
@@ -20464,7 +21575,7 @@ async function generateSkillsCore(params) {
|
|
|
20464
21575
|
global: config.getGlobal(),
|
|
20465
21576
|
includeSimulated: config.getSimulateSkills()
|
|
20466
21577
|
});
|
|
20467
|
-
const toolTargets = (0,
|
|
21578
|
+
const toolTargets = (0, import_es_toolkit5.intersection)(config.getTargets(), supportedSkillsTargets);
|
|
20468
21579
|
warnUnsupportedTargets({
|
|
20469
21580
|
config,
|
|
20470
21581
|
supportedTargets: supportedSkillsTargets,
|
|
@@ -20509,7 +21620,7 @@ async function generateHooksCore(params) {
|
|
|
20509
21620
|
const allPaths = [];
|
|
20510
21621
|
let hasDiff = false;
|
|
20511
21622
|
const supportedHooksTargets = HooksProcessor.getToolTargets({ global: config.getGlobal() });
|
|
20512
|
-
const toolTargets = (0,
|
|
21623
|
+
const toolTargets = (0, import_es_toolkit5.intersection)(config.getTargets(), supportedHooksTargets);
|
|
20513
21624
|
warnUnsupportedTargets({
|
|
20514
21625
|
config,
|
|
20515
21626
|
supportedTargets: supportedHooksTargets,
|
|
@@ -20537,10 +21648,52 @@ async function generateHooksCore(params) {
|
|
|
20537
21648
|
}
|
|
20538
21649
|
return { count: totalCount, paths: allPaths, hasDiff };
|
|
20539
21650
|
}
|
|
21651
|
+
async function generatePermissionsCore(params) {
|
|
21652
|
+
const { config, logger: logger5 } = params;
|
|
21653
|
+
const supportedPermissionsTargets = PermissionsProcessor.getToolTargets({
|
|
21654
|
+
global: config.getGlobal()
|
|
21655
|
+
});
|
|
21656
|
+
warnUnsupportedTargets({
|
|
21657
|
+
config,
|
|
21658
|
+
supportedTargets: supportedPermissionsTargets,
|
|
21659
|
+
featureName: "permissions",
|
|
21660
|
+
logger: logger5
|
|
21661
|
+
});
|
|
21662
|
+
let totalCount = 0;
|
|
21663
|
+
const allPaths = [];
|
|
21664
|
+
let hasDiff = false;
|
|
21665
|
+
for (const baseDir of config.getBaseDirs()) {
|
|
21666
|
+
for (const toolTarget of (0, import_es_toolkit5.intersection)(config.getTargets(), supportedPermissionsTargets)) {
|
|
21667
|
+
if (!config.getFeatures(toolTarget).includes("permissions")) {
|
|
21668
|
+
continue;
|
|
21669
|
+
}
|
|
21670
|
+
try {
|
|
21671
|
+
const processor = new PermissionsProcessor({
|
|
21672
|
+
baseDir,
|
|
21673
|
+
toolTarget,
|
|
21674
|
+
global: config.getGlobal(),
|
|
21675
|
+
dryRun: config.isPreviewMode(),
|
|
21676
|
+
logger: logger5
|
|
21677
|
+
});
|
|
21678
|
+
const rulesyncFiles = await processor.loadRulesyncFiles();
|
|
21679
|
+
const result = await processFeatureWithRulesyncFiles({ config, processor, rulesyncFiles });
|
|
21680
|
+
totalCount += result.count;
|
|
21681
|
+
allPaths.push(...result.paths);
|
|
21682
|
+
if (result.hasDiff) hasDiff = true;
|
|
21683
|
+
} catch (error) {
|
|
21684
|
+
logger5.warn(
|
|
21685
|
+
`Failed to generate ${toolTarget} permissions files for ${baseDir}: ${formatError(error)}`
|
|
21686
|
+
);
|
|
21687
|
+
continue;
|
|
21688
|
+
}
|
|
21689
|
+
}
|
|
21690
|
+
}
|
|
21691
|
+
return { count: totalCount, paths: allPaths, hasDiff };
|
|
21692
|
+
}
|
|
20540
21693
|
|
|
20541
21694
|
// src/utils/result.ts
|
|
20542
21695
|
function calculateTotalCount(result) {
|
|
20543
|
-
return result.rulesCount + result.ignoreCount + result.mcpCount + result.commandsCount + result.subagentsCount + result.skillsCount + result.hooksCount;
|
|
21696
|
+
return result.rulesCount + result.ignoreCount + result.mcpCount + result.commandsCount + result.subagentsCount + result.skillsCount + result.hooksCount + result.permissionsCount;
|
|
20544
21697
|
}
|
|
20545
21698
|
|
|
20546
21699
|
// src/cli/commands/generate.ts
|
|
@@ -20601,6 +21754,7 @@ async function generateCommand(logger5, options) {
|
|
|
20601
21754
|
subagents: { count: result.subagentsCount, paths: result.subagentsPaths },
|
|
20602
21755
|
skills: { count: result.skillsCount, paths: result.skillsPaths },
|
|
20603
21756
|
hooks: { count: result.hooksCount, paths: result.hooksPaths },
|
|
21757
|
+
permissions: { count: result.permissionsCount, paths: result.permissionsPaths },
|
|
20604
21758
|
rules: { count: result.rulesCount, paths: result.rulesPaths }
|
|
20605
21759
|
};
|
|
20606
21760
|
const featureLabels = {
|
|
@@ -20610,7 +21764,8 @@ async function generateCommand(logger5, options) {
|
|
|
20610
21764
|
commands: (count) => `${count === 1 ? "command" : "commands"}`,
|
|
20611
21765
|
subagents: (count) => `${count === 1 ? "subagent" : "subagents"}`,
|
|
20612
21766
|
skills: (count) => `${count === 1 ? "skill" : "skills"}`,
|
|
20613
|
-
hooks: (count) => `${count === 1 ? "hooks file" : "hooks files"}
|
|
21767
|
+
hooks: (count) => `${count === 1 ? "hooks file" : "hooks files"}`,
|
|
21768
|
+
permissions: (count) => `${count === 1 ? "permissions file" : "permissions files"}`
|
|
20614
21769
|
};
|
|
20615
21770
|
for (const [feature, data] of Object.entries(featureResults)) {
|
|
20616
21771
|
logFeatureResult(logger5, {
|
|
@@ -20650,6 +21805,7 @@ async function generateCommand(logger5, options) {
|
|
|
20650
21805
|
if (result.subagentsCount > 0) parts.push(`${result.subagentsCount} subagents`);
|
|
20651
21806
|
if (result.skillsCount > 0) parts.push(`${result.skillsCount} skills`);
|
|
20652
21807
|
if (result.hooksCount > 0) parts.push(`${result.hooksCount} hooks`);
|
|
21808
|
+
if (result.permissionsCount > 0) parts.push(`${result.permissionsCount} permissions`);
|
|
20653
21809
|
if (isPreview) {
|
|
20654
21810
|
logger5.info(`${modePrefix} Would write ${totalGenerated} file(s) total (${parts.join(" + ")})`);
|
|
20655
21811
|
} else {
|
|
@@ -20658,7 +21814,7 @@ async function generateCommand(logger5, options) {
|
|
|
20658
21814
|
}
|
|
20659
21815
|
|
|
20660
21816
|
// src/cli/commands/gitignore.ts
|
|
20661
|
-
var
|
|
21817
|
+
var import_node_path141 = require("path");
|
|
20662
21818
|
|
|
20663
21819
|
// src/cli/commands/gitignore-entries.ts
|
|
20664
21820
|
var normalizeGitignoreEntryTargets = (target) => {
|
|
@@ -20673,7 +21829,6 @@ var GITIGNORE_ENTRY_REGISTRY = [
|
|
|
20673
21829
|
},
|
|
20674
21830
|
{ target: "common", feature: "general", entry: ".rulesync/rules/*.local.md" },
|
|
20675
21831
|
{ target: "common", feature: "general", entry: "rulesync.local.jsonc" },
|
|
20676
|
-
{ target: "common", feature: "general", entry: "!.rulesync/.aiignore" },
|
|
20677
21832
|
// AGENTS.local.md is placed in common scope (not rovodev-only) so that
|
|
20678
21833
|
// local rule files are always gitignored regardless of which targets are enabled.
|
|
20679
21834
|
// This prevents accidental commits when a user disables the rovodev target.
|
|
@@ -20805,6 +21960,8 @@ var GITIGNORE_ENTRY_REGISTRY = [
|
|
|
20805
21960
|
{ target: "kiro", feature: "subagents", entry: "**/.kiro/agents/" },
|
|
20806
21961
|
{ target: "kiro", feature: "mcp", entry: "**/.kiro/settings/mcp.json" },
|
|
20807
21962
|
{ target: "kiro", feature: "ignore", entry: "**/.aiignore" },
|
|
21963
|
+
// Keep this after ignore entries like "**/.aiignore" so the exception remains effective.
|
|
21964
|
+
{ target: "common", feature: "general", entry: "!.rulesync/.aiignore" },
|
|
20808
21965
|
// OpenCode
|
|
20809
21966
|
{ target: "opencode", feature: "commands", entry: "**/.opencode/command/" },
|
|
20810
21967
|
{ target: "opencode", feature: "subagents", entry: "**/.opencode/agent/" },
|
|
@@ -20869,8 +22026,12 @@ var isFeatureSelectedForTarget = (feature, target, features) => {
|
|
|
20869
22026
|
if (target === "common") return true;
|
|
20870
22027
|
const targetFeatures = features[target];
|
|
20871
22028
|
if (!targetFeatures) return true;
|
|
20872
|
-
if (
|
|
20873
|
-
|
|
22029
|
+
if (Array.isArray(targetFeatures)) {
|
|
22030
|
+
if (targetFeatures.includes("*")) return true;
|
|
22031
|
+
return targetFeatures.includes(feature);
|
|
22032
|
+
}
|
|
22033
|
+
if (isFeatureValueEnabled(targetFeatures["*"])) return true;
|
|
22034
|
+
return isFeatureValueEnabled(targetFeatures[feature]);
|
|
20874
22035
|
};
|
|
20875
22036
|
var isFeatureSelected = (feature, target, features) => {
|
|
20876
22037
|
return normalizeGitignoreEntryTargets(target).some(
|
|
@@ -20905,8 +22066,14 @@ var warnInvalidFeatures = (features, logger5) => {
|
|
|
20905
22066
|
} else {
|
|
20906
22067
|
for (const targetFeatures of Object.values(features)) {
|
|
20907
22068
|
if (!targetFeatures) continue;
|
|
20908
|
-
|
|
20909
|
-
|
|
22069
|
+
if (Array.isArray(targetFeatures)) {
|
|
22070
|
+
for (const feature of targetFeatures) {
|
|
22071
|
+
warnOnce(feature);
|
|
22072
|
+
}
|
|
22073
|
+
} else {
|
|
22074
|
+
for (const feature of Object.keys(targetFeatures)) {
|
|
22075
|
+
warnOnce(feature);
|
|
22076
|
+
}
|
|
20910
22077
|
}
|
|
20911
22078
|
}
|
|
20912
22079
|
}
|
|
@@ -20985,7 +22152,7 @@ var removeExistingRulesyncEntries = (content) => {
|
|
|
20985
22152
|
return result;
|
|
20986
22153
|
};
|
|
20987
22154
|
var gitignoreCommand = async (logger5, options) => {
|
|
20988
|
-
const gitignorePath = (0,
|
|
22155
|
+
const gitignorePath = (0, import_node_path141.join)(process.cwd(), ".gitignore");
|
|
20989
22156
|
let gitignoreContent = "";
|
|
20990
22157
|
if (await fileExists(gitignorePath)) {
|
|
20991
22158
|
gitignoreContent = await readFileContent(gitignorePath);
|
|
@@ -21047,6 +22214,7 @@ async function importFromTool(params) {
|
|
|
21047
22214
|
const subagentsCount = await importSubagentsCore({ config, tool, logger: logger5 });
|
|
21048
22215
|
const skillsCount = await importSkillsCore({ config, tool, logger: logger5 });
|
|
21049
22216
|
const hooksCount = await importHooksCore({ config, tool, logger: logger5 });
|
|
22217
|
+
const permissionsCount = await importPermissionsCore({ config, tool, logger: logger5 });
|
|
21050
22218
|
return {
|
|
21051
22219
|
rulesCount,
|
|
21052
22220
|
ignoreCount,
|
|
@@ -21054,7 +22222,8 @@ async function importFromTool(params) {
|
|
|
21054
22222
|
commandsCount,
|
|
21055
22223
|
subagentsCount,
|
|
21056
22224
|
skillsCount,
|
|
21057
|
-
hooksCount
|
|
22225
|
+
hooksCount,
|
|
22226
|
+
permissionsCount
|
|
21058
22227
|
};
|
|
21059
22228
|
}
|
|
21060
22229
|
async function importRulesCore(params) {
|
|
@@ -21100,7 +22269,8 @@ async function importIgnoreCore(params) {
|
|
|
21100
22269
|
const ignoreProcessor = new IgnoreProcessor({
|
|
21101
22270
|
baseDir: config.getBaseDirs()[0] ?? ".",
|
|
21102
22271
|
toolTarget: tool,
|
|
21103
|
-
logger: logger5
|
|
22272
|
+
logger: logger5,
|
|
22273
|
+
featureOptions: config.getFeatureOptions(tool, "ignore")
|
|
21104
22274
|
});
|
|
21105
22275
|
const toolFiles = await ignoreProcessor.loadToolFiles();
|
|
21106
22276
|
if (toolFiles.length === 0) {
|
|
@@ -21262,6 +22432,41 @@ async function importHooksCore(params) {
|
|
|
21262
22432
|
}
|
|
21263
22433
|
return writtenCount;
|
|
21264
22434
|
}
|
|
22435
|
+
async function importPermissionsCore(params) {
|
|
22436
|
+
const { config, tool, logger: logger5 } = params;
|
|
22437
|
+
if (!config.getFeatures(tool).includes("permissions")) {
|
|
22438
|
+
return 0;
|
|
22439
|
+
}
|
|
22440
|
+
const allTargets = PermissionsProcessor.getToolTargets({ global: config.getGlobal() });
|
|
22441
|
+
const importableTargets = PermissionsProcessor.getToolTargets({
|
|
22442
|
+
global: config.getGlobal(),
|
|
22443
|
+
importOnly: true
|
|
22444
|
+
});
|
|
22445
|
+
if (!allTargets.includes(tool)) {
|
|
22446
|
+
return 0;
|
|
22447
|
+
}
|
|
22448
|
+
if (!importableTargets.includes(tool)) {
|
|
22449
|
+
logger5.warn(`Import is not supported for ${tool} permissions. Skipping.`);
|
|
22450
|
+
return 0;
|
|
22451
|
+
}
|
|
22452
|
+
const permissionsProcessor = new PermissionsProcessor({
|
|
22453
|
+
baseDir: config.getBaseDirs()[0] ?? ".",
|
|
22454
|
+
toolTarget: tool,
|
|
22455
|
+
global: config.getGlobal(),
|
|
22456
|
+
logger: logger5
|
|
22457
|
+
});
|
|
22458
|
+
const toolFiles = await permissionsProcessor.loadToolFiles();
|
|
22459
|
+
if (toolFiles.length === 0) {
|
|
22460
|
+
logger5.warn(`No permissions files found for ${tool}. Skipping import.`);
|
|
22461
|
+
return 0;
|
|
22462
|
+
}
|
|
22463
|
+
const rulesyncFiles = await permissionsProcessor.convertToolFilesToRulesyncFiles(toolFiles);
|
|
22464
|
+
const { count: writtenCount } = await permissionsProcessor.writeAiFiles(rulesyncFiles);
|
|
22465
|
+
if (config.getVerbose() && writtenCount > 0) {
|
|
22466
|
+
logger5.success(`Created ${writtenCount} permissions file(s)`);
|
|
22467
|
+
}
|
|
22468
|
+
return writtenCount;
|
|
22469
|
+
}
|
|
21265
22470
|
|
|
21266
22471
|
// src/cli/commands/import.ts
|
|
21267
22472
|
async function importCommand(logger5, options) {
|
|
@@ -21290,7 +22495,8 @@ async function importCommand(logger5, options) {
|
|
|
21290
22495
|
commands: { count: result.commandsCount },
|
|
21291
22496
|
subagents: { count: result.subagentsCount },
|
|
21292
22497
|
skills: { count: result.skillsCount },
|
|
21293
|
-
hooks: { count: result.hooksCount }
|
|
22498
|
+
hooks: { count: result.hooksCount },
|
|
22499
|
+
permissions: { count: result.permissionsCount }
|
|
21294
22500
|
});
|
|
21295
22501
|
logger5.captureData("totalFiles", totalImported);
|
|
21296
22502
|
}
|
|
@@ -21302,11 +22508,12 @@ async function importCommand(logger5, options) {
|
|
|
21302
22508
|
if (result.subagentsCount > 0) parts.push(`${result.subagentsCount} subagents`);
|
|
21303
22509
|
if (result.skillsCount > 0) parts.push(`${result.skillsCount} skills`);
|
|
21304
22510
|
if (result.hooksCount > 0) parts.push(`${result.hooksCount} hooks`);
|
|
22511
|
+
if (result.permissionsCount > 0) parts.push(`${result.permissionsCount} permissions`);
|
|
21305
22512
|
logger5.success(`Imported ${totalImported} file(s) total (${parts.join(" + ")})`);
|
|
21306
22513
|
}
|
|
21307
22514
|
|
|
21308
22515
|
// src/lib/init.ts
|
|
21309
|
-
var
|
|
22516
|
+
var import_node_path142 = require("path");
|
|
21310
22517
|
async function init() {
|
|
21311
22518
|
const sampleFiles = await createSampleFiles();
|
|
21312
22519
|
const configFile = await createConfigFile();
|
|
@@ -21498,27 +22705,27 @@ Keep the summary concise and ready to reuse in future tasks.`
|
|
|
21498
22705
|
await ensureDir(subagentPaths.relativeDirPath);
|
|
21499
22706
|
await ensureDir(skillPaths.relativeDirPath);
|
|
21500
22707
|
await ensureDir(ignorePaths.recommended.relativeDirPath);
|
|
21501
|
-
const ruleFilepath = (0,
|
|
22708
|
+
const ruleFilepath = (0, import_node_path142.join)(rulePaths.recommended.relativeDirPath, sampleRuleFile.filename);
|
|
21502
22709
|
results.push(await writeIfNotExists(ruleFilepath, sampleRuleFile.content));
|
|
21503
|
-
const mcpFilepath = (0,
|
|
22710
|
+
const mcpFilepath = (0, import_node_path142.join)(
|
|
21504
22711
|
mcpPaths.recommended.relativeDirPath,
|
|
21505
22712
|
mcpPaths.recommended.relativeFilePath
|
|
21506
22713
|
);
|
|
21507
22714
|
results.push(await writeIfNotExists(mcpFilepath, sampleMcpFile.content));
|
|
21508
|
-
const commandFilepath = (0,
|
|
22715
|
+
const commandFilepath = (0, import_node_path142.join)(commandPaths.relativeDirPath, sampleCommandFile.filename);
|
|
21509
22716
|
results.push(await writeIfNotExists(commandFilepath, sampleCommandFile.content));
|
|
21510
|
-
const subagentFilepath = (0,
|
|
22717
|
+
const subagentFilepath = (0, import_node_path142.join)(subagentPaths.relativeDirPath, sampleSubagentFile.filename);
|
|
21511
22718
|
results.push(await writeIfNotExists(subagentFilepath, sampleSubagentFile.content));
|
|
21512
|
-
const skillDirPath = (0,
|
|
22719
|
+
const skillDirPath = (0, import_node_path142.join)(skillPaths.relativeDirPath, sampleSkillFile.dirName);
|
|
21513
22720
|
await ensureDir(skillDirPath);
|
|
21514
|
-
const skillFilepath = (0,
|
|
22721
|
+
const skillFilepath = (0, import_node_path142.join)(skillDirPath, SKILL_FILE_NAME);
|
|
21515
22722
|
results.push(await writeIfNotExists(skillFilepath, sampleSkillFile.content));
|
|
21516
|
-
const ignoreFilepath = (0,
|
|
22723
|
+
const ignoreFilepath = (0, import_node_path142.join)(
|
|
21517
22724
|
ignorePaths.recommended.relativeDirPath,
|
|
21518
22725
|
ignorePaths.recommended.relativeFilePath
|
|
21519
22726
|
);
|
|
21520
22727
|
results.push(await writeIfNotExists(ignoreFilepath, sampleIgnoreFile.content));
|
|
21521
|
-
const hooksFilepath = (0,
|
|
22728
|
+
const hooksFilepath = (0, import_node_path142.join)(hooksPaths.relativeDirPath, hooksPaths.relativeFilePath);
|
|
21522
22729
|
results.push(await writeIfNotExists(hooksFilepath, sampleHooksFile.content));
|
|
21523
22730
|
return results;
|
|
21524
22731
|
}
|
|
@@ -21566,12 +22773,12 @@ async function initCommand(logger5) {
|
|
|
21566
22773
|
}
|
|
21567
22774
|
|
|
21568
22775
|
// src/lib/sources.ts
|
|
21569
|
-
var
|
|
22776
|
+
var import_node_path145 = require("path");
|
|
21570
22777
|
var import_promise2 = require("es-toolkit/promise");
|
|
21571
22778
|
|
|
21572
22779
|
// src/lib/git-client.ts
|
|
21573
22780
|
var import_node_child_process = require("child_process");
|
|
21574
|
-
var
|
|
22781
|
+
var import_node_path143 = require("path");
|
|
21575
22782
|
var import_node_util2 = require("util");
|
|
21576
22783
|
var execFileAsync = (0, import_node_util2.promisify)(import_node_child_process.execFile);
|
|
21577
22784
|
var GIT_TIMEOUT_MS = 6e4;
|
|
@@ -21659,7 +22866,7 @@ async function fetchSkillFiles(params) {
|
|
|
21659
22866
|
const { url, ref, skillsPath, logger: logger5 } = params;
|
|
21660
22867
|
validateGitUrl(url, { logger: logger5 });
|
|
21661
22868
|
validateRef(ref);
|
|
21662
|
-
if (skillsPath.split(/[/\\]/).includes("..") || (0,
|
|
22869
|
+
if (skillsPath.split(/[/\\]/).includes("..") || (0, import_node_path143.isAbsolute)(skillsPath)) {
|
|
21663
22870
|
throw new GitClientError(
|
|
21664
22871
|
`Invalid skillsPath "${skillsPath}": must be a relative path without ".."`
|
|
21665
22872
|
);
|
|
@@ -21693,7 +22900,7 @@ async function fetchSkillFiles(params) {
|
|
|
21693
22900
|
timeout: GIT_TIMEOUT_MS
|
|
21694
22901
|
});
|
|
21695
22902
|
await execFileAsync("git", ["-C", tmpDir, "checkout"], { timeout: GIT_TIMEOUT_MS });
|
|
21696
|
-
const skillsDir = (0,
|
|
22903
|
+
const skillsDir = (0, import_node_path143.join)(tmpDir, skillsPath);
|
|
21697
22904
|
if (!await directoryExists(skillsDir)) return [];
|
|
21698
22905
|
return await walkDirectory(skillsDir, skillsDir, 0, { totalFiles: 0, totalSize: 0 }, logger5);
|
|
21699
22906
|
} catch (error) {
|
|
@@ -21715,7 +22922,7 @@ async function walkDirectory(dir, baseDir, depth = 0, ctx = { totalFiles: 0, tot
|
|
|
21715
22922
|
const results = [];
|
|
21716
22923
|
for (const name of await listDirectoryFiles(dir)) {
|
|
21717
22924
|
if (name === ".git") continue;
|
|
21718
|
-
const fullPath = (0,
|
|
22925
|
+
const fullPath = (0, import_node_path143.join)(dir, name);
|
|
21719
22926
|
if (await isSymlink(fullPath)) {
|
|
21720
22927
|
logger5?.warn(`Skipping symlink "${fullPath}".`);
|
|
21721
22928
|
continue;
|
|
@@ -21743,7 +22950,7 @@ async function walkDirectory(dir, baseDir, depth = 0, ctx = { totalFiles: 0, tot
|
|
|
21743
22950
|
);
|
|
21744
22951
|
}
|
|
21745
22952
|
const content = await readFileContent(fullPath);
|
|
21746
|
-
results.push({ relativePath: (0,
|
|
22953
|
+
results.push({ relativePath: (0, import_node_path143.relative)(baseDir, fullPath), content, size });
|
|
21747
22954
|
}
|
|
21748
22955
|
}
|
|
21749
22956
|
return results;
|
|
@@ -21751,28 +22958,28 @@ async function walkDirectory(dir, baseDir, depth = 0, ctx = { totalFiles: 0, tot
|
|
|
21751
22958
|
|
|
21752
22959
|
// src/lib/sources-lock.ts
|
|
21753
22960
|
var import_node_crypto = require("crypto");
|
|
21754
|
-
var
|
|
21755
|
-
var
|
|
22961
|
+
var import_node_path144 = require("path");
|
|
22962
|
+
var import_mini74 = require("zod/mini");
|
|
21756
22963
|
var LOCKFILE_VERSION = 1;
|
|
21757
|
-
var LockedSkillSchema =
|
|
21758
|
-
integrity:
|
|
22964
|
+
var LockedSkillSchema = import_mini74.z.object({
|
|
22965
|
+
integrity: import_mini74.z.string()
|
|
21759
22966
|
});
|
|
21760
|
-
var LockedSourceSchema =
|
|
21761
|
-
requestedRef: (0,
|
|
21762
|
-
resolvedRef:
|
|
21763
|
-
resolvedAt: (0,
|
|
21764
|
-
skills:
|
|
22967
|
+
var LockedSourceSchema = import_mini74.z.object({
|
|
22968
|
+
requestedRef: (0, import_mini74.optional)(import_mini74.z.string()),
|
|
22969
|
+
resolvedRef: import_mini74.z.string().check((0, import_mini74.refine)((v) => /^[0-9a-f]{40}$/.test(v), "resolvedRef must be a 40-character hex SHA")),
|
|
22970
|
+
resolvedAt: (0, import_mini74.optional)(import_mini74.z.string()),
|
|
22971
|
+
skills: import_mini74.z.record(import_mini74.z.string(), LockedSkillSchema)
|
|
21765
22972
|
});
|
|
21766
|
-
var SourcesLockSchema =
|
|
21767
|
-
lockfileVersion:
|
|
21768
|
-
sources:
|
|
22973
|
+
var SourcesLockSchema = import_mini74.z.object({
|
|
22974
|
+
lockfileVersion: import_mini74.z.number(),
|
|
22975
|
+
sources: import_mini74.z.record(import_mini74.z.string(), LockedSourceSchema)
|
|
21769
22976
|
});
|
|
21770
|
-
var LegacyLockedSourceSchema =
|
|
21771
|
-
resolvedRef:
|
|
21772
|
-
skills:
|
|
22977
|
+
var LegacyLockedSourceSchema = import_mini74.z.object({
|
|
22978
|
+
resolvedRef: import_mini74.z.string(),
|
|
22979
|
+
skills: import_mini74.z.array(import_mini74.z.string())
|
|
21773
22980
|
});
|
|
21774
|
-
var LegacySourcesLockSchema =
|
|
21775
|
-
sources:
|
|
22981
|
+
var LegacySourcesLockSchema = import_mini74.z.object({
|
|
22982
|
+
sources: import_mini74.z.record(import_mini74.z.string(), LegacyLockedSourceSchema)
|
|
21776
22983
|
});
|
|
21777
22984
|
function migrateLegacyLock(params) {
|
|
21778
22985
|
const { legacy, logger: logger5 } = params;
|
|
@@ -21797,7 +23004,7 @@ function createEmptyLock() {
|
|
|
21797
23004
|
}
|
|
21798
23005
|
async function readLockFile(params) {
|
|
21799
23006
|
const { logger: logger5 } = params;
|
|
21800
|
-
const lockPath = (0,
|
|
23007
|
+
const lockPath = (0, import_node_path144.join)(params.baseDir, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH);
|
|
21801
23008
|
if (!await fileExists(lockPath)) {
|
|
21802
23009
|
logger5.debug("No sources lockfile found, starting fresh.");
|
|
21803
23010
|
return createEmptyLock();
|
|
@@ -21826,7 +23033,7 @@ async function readLockFile(params) {
|
|
|
21826
23033
|
}
|
|
21827
23034
|
async function writeLockFile(params) {
|
|
21828
23035
|
const { logger: logger5 } = params;
|
|
21829
|
-
const lockPath = (0,
|
|
23036
|
+
const lockPath = (0, import_node_path144.join)(params.baseDir, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH);
|
|
21830
23037
|
const content = JSON.stringify(params.lock, null, 2) + "\n";
|
|
21831
23038
|
await writeFileContent(lockPath, content);
|
|
21832
23039
|
logger5.debug(`Wrote sources lockfile to ${lockPath}`);
|
|
@@ -22000,7 +23207,7 @@ function logGitClientHints(params) {
|
|
|
22000
23207
|
async function checkLockedSkillsExist(curatedDir, skillNames) {
|
|
22001
23208
|
if (skillNames.length === 0) return true;
|
|
22002
23209
|
for (const name of skillNames) {
|
|
22003
|
-
if (!await directoryExists((0,
|
|
23210
|
+
if (!await directoryExists((0, import_node_path145.join)(curatedDir, name))) {
|
|
22004
23211
|
return false;
|
|
22005
23212
|
}
|
|
22006
23213
|
}
|
|
@@ -22008,10 +23215,10 @@ async function checkLockedSkillsExist(curatedDir, skillNames) {
|
|
|
22008
23215
|
}
|
|
22009
23216
|
async function cleanPreviousCuratedSkills(params) {
|
|
22010
23217
|
const { curatedDir, lockedSkillNames, logger: logger5 } = params;
|
|
22011
|
-
const resolvedCuratedDir = (0,
|
|
23218
|
+
const resolvedCuratedDir = (0, import_node_path145.resolve)(curatedDir);
|
|
22012
23219
|
for (const prevSkill of lockedSkillNames) {
|
|
22013
|
-
const prevDir = (0,
|
|
22014
|
-
if (!(0,
|
|
23220
|
+
const prevDir = (0, import_node_path145.join)(curatedDir, prevSkill);
|
|
23221
|
+
if (!(0, import_node_path145.resolve)(prevDir).startsWith(resolvedCuratedDir + import_node_path145.sep)) {
|
|
22015
23222
|
logger5.warn(
|
|
22016
23223
|
`Skipping removal of "${prevSkill}": resolved path is outside the curated directory.`
|
|
22017
23224
|
);
|
|
@@ -22050,9 +23257,9 @@ async function writeSkillAndComputeIntegrity(params) {
|
|
|
22050
23257
|
for (const file of files) {
|
|
22051
23258
|
checkPathTraversal({
|
|
22052
23259
|
relativePath: file.relativePath,
|
|
22053
|
-
intendedRootDir: (0,
|
|
23260
|
+
intendedRootDir: (0, import_node_path145.join)(curatedDir, skillName)
|
|
22054
23261
|
});
|
|
22055
|
-
await writeFileContent((0,
|
|
23262
|
+
await writeFileContent((0, import_node_path145.join)(curatedDir, skillName, file.relativePath), file.content);
|
|
22056
23263
|
written.push({ path: file.relativePath, content: file.content });
|
|
22057
23264
|
}
|
|
22058
23265
|
const integrity = computeSkillIntegrity(written);
|
|
@@ -22129,7 +23336,7 @@ async function fetchSource(params) {
|
|
|
22129
23336
|
ref = resolvedSha;
|
|
22130
23337
|
logger5.debug(`Resolved ${sourceKey} ref "${requestedRef}" to SHA: ${resolvedSha}`);
|
|
22131
23338
|
}
|
|
22132
|
-
const curatedDir = (0,
|
|
23339
|
+
const curatedDir = (0, import_node_path145.join)(baseDir, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH);
|
|
22133
23340
|
if (locked && resolvedSha === locked.resolvedRef && !updateSources) {
|
|
22134
23341
|
const allExist = await checkLockedSkillsExist(curatedDir, lockedSkillNames);
|
|
22135
23342
|
if (allExist) {
|
|
@@ -22254,7 +23461,7 @@ async function fetchSourceViaGit(params) {
|
|
|
22254
23461
|
requestedRef = def.ref;
|
|
22255
23462
|
resolvedSha = def.sha;
|
|
22256
23463
|
}
|
|
22257
|
-
const curatedDir = (0,
|
|
23464
|
+
const curatedDir = (0, import_node_path145.join)(baseDir, RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH);
|
|
22258
23465
|
if (locked && resolvedSha === locked.resolvedRef && !updateSources) {
|
|
22259
23466
|
if (await checkLockedSkillsExist(curatedDir, lockedSkillNames)) {
|
|
22260
23467
|
return { skillCount: 0, fetchedSkillNames: lockedSkillNames, updatedLock: lock };
|
|
@@ -22370,11 +23577,11 @@ async function installCommand(logger5, options) {
|
|
|
22370
23577
|
var import_fastmcp = require("fastmcp");
|
|
22371
23578
|
|
|
22372
23579
|
// src/mcp/tools.ts
|
|
22373
|
-
var
|
|
23580
|
+
var import_mini83 = require("zod/mini");
|
|
22374
23581
|
|
|
22375
23582
|
// src/mcp/commands.ts
|
|
22376
|
-
var
|
|
22377
|
-
var
|
|
23583
|
+
var import_node_path146 = require("path");
|
|
23584
|
+
var import_mini75 = require("zod/mini");
|
|
22378
23585
|
|
|
22379
23586
|
// src/utils/logger.ts
|
|
22380
23587
|
var BaseLogger = class {
|
|
@@ -22525,7 +23732,7 @@ var logger = new ConsoleLogger({ verbose: false, silent: true });
|
|
|
22525
23732
|
var maxCommandSizeBytes = 1024 * 1024;
|
|
22526
23733
|
var maxCommandsCount = 1e3;
|
|
22527
23734
|
async function listCommands() {
|
|
22528
|
-
const commandsDir = (0,
|
|
23735
|
+
const commandsDir = (0, import_node_path146.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
22529
23736
|
try {
|
|
22530
23737
|
const files = await listDirectoryFiles(commandsDir);
|
|
22531
23738
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -22541,7 +23748,7 @@ async function listCommands() {
|
|
|
22541
23748
|
});
|
|
22542
23749
|
const frontmatter = command.getFrontmatter();
|
|
22543
23750
|
return {
|
|
22544
|
-
relativePathFromCwd: (0,
|
|
23751
|
+
relativePathFromCwd: (0, import_node_path146.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, file),
|
|
22545
23752
|
frontmatter
|
|
22546
23753
|
};
|
|
22547
23754
|
} catch (error) {
|
|
@@ -22563,13 +23770,13 @@ async function getCommand({ relativePathFromCwd }) {
|
|
|
22563
23770
|
relativePath: relativePathFromCwd,
|
|
22564
23771
|
intendedRootDir: process.cwd()
|
|
22565
23772
|
});
|
|
22566
|
-
const filename = (0,
|
|
23773
|
+
const filename = (0, import_node_path146.basename)(relativePathFromCwd);
|
|
22567
23774
|
try {
|
|
22568
23775
|
const command = await RulesyncCommand.fromFile({
|
|
22569
23776
|
relativeFilePath: filename
|
|
22570
23777
|
});
|
|
22571
23778
|
return {
|
|
22572
|
-
relativePathFromCwd: (0,
|
|
23779
|
+
relativePathFromCwd: (0, import_node_path146.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
22573
23780
|
frontmatter: command.getFrontmatter(),
|
|
22574
23781
|
body: command.getBody()
|
|
22575
23782
|
};
|
|
@@ -22588,7 +23795,7 @@ async function putCommand({
|
|
|
22588
23795
|
relativePath: relativePathFromCwd,
|
|
22589
23796
|
intendedRootDir: process.cwd()
|
|
22590
23797
|
});
|
|
22591
|
-
const filename = (0,
|
|
23798
|
+
const filename = (0, import_node_path146.basename)(relativePathFromCwd);
|
|
22592
23799
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
22593
23800
|
if (estimatedSize > maxCommandSizeBytes) {
|
|
22594
23801
|
throw new Error(
|
|
@@ -22598,7 +23805,7 @@ async function putCommand({
|
|
|
22598
23805
|
try {
|
|
22599
23806
|
const existingCommands = await listCommands();
|
|
22600
23807
|
const isUpdate = existingCommands.some(
|
|
22601
|
-
(command2) => command2.relativePathFromCwd === (0,
|
|
23808
|
+
(command2) => command2.relativePathFromCwd === (0, import_node_path146.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
22602
23809
|
);
|
|
22603
23810
|
if (!isUpdate && existingCommands.length >= maxCommandsCount) {
|
|
22604
23811
|
throw new Error(
|
|
@@ -22615,11 +23822,11 @@ async function putCommand({
|
|
|
22615
23822
|
fileContent,
|
|
22616
23823
|
validate: true
|
|
22617
23824
|
});
|
|
22618
|
-
const commandsDir = (0,
|
|
23825
|
+
const commandsDir = (0, import_node_path146.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH);
|
|
22619
23826
|
await ensureDir(commandsDir);
|
|
22620
23827
|
await writeFileContent(command.getFilePath(), command.getFileContent());
|
|
22621
23828
|
return {
|
|
22622
|
-
relativePathFromCwd: (0,
|
|
23829
|
+
relativePathFromCwd: (0, import_node_path146.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename),
|
|
22623
23830
|
frontmatter: command.getFrontmatter(),
|
|
22624
23831
|
body: command.getBody()
|
|
22625
23832
|
};
|
|
@@ -22634,12 +23841,12 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
22634
23841
|
relativePath: relativePathFromCwd,
|
|
22635
23842
|
intendedRootDir: process.cwd()
|
|
22636
23843
|
});
|
|
22637
|
-
const filename = (0,
|
|
22638
|
-
const fullPath = (0,
|
|
23844
|
+
const filename = (0, import_node_path146.basename)(relativePathFromCwd);
|
|
23845
|
+
const fullPath = (0, import_node_path146.join)(process.cwd(), RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename);
|
|
22639
23846
|
try {
|
|
22640
23847
|
await removeFile(fullPath);
|
|
22641
23848
|
return {
|
|
22642
|
-
relativePathFromCwd: (0,
|
|
23849
|
+
relativePathFromCwd: (0, import_node_path146.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, filename)
|
|
22643
23850
|
};
|
|
22644
23851
|
} catch (error) {
|
|
22645
23852
|
throw new Error(`Failed to delete command file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -22648,23 +23855,23 @@ async function deleteCommand({ relativePathFromCwd }) {
|
|
|
22648
23855
|
}
|
|
22649
23856
|
}
|
|
22650
23857
|
var commandToolSchemas = {
|
|
22651
|
-
listCommands:
|
|
22652
|
-
getCommand:
|
|
22653
|
-
relativePathFromCwd:
|
|
23858
|
+
listCommands: import_mini75.z.object({}),
|
|
23859
|
+
getCommand: import_mini75.z.object({
|
|
23860
|
+
relativePathFromCwd: import_mini75.z.string()
|
|
22654
23861
|
}),
|
|
22655
|
-
putCommand:
|
|
22656
|
-
relativePathFromCwd:
|
|
23862
|
+
putCommand: import_mini75.z.object({
|
|
23863
|
+
relativePathFromCwd: import_mini75.z.string(),
|
|
22657
23864
|
frontmatter: RulesyncCommandFrontmatterSchema,
|
|
22658
|
-
body:
|
|
23865
|
+
body: import_mini75.z.string()
|
|
22659
23866
|
}),
|
|
22660
|
-
deleteCommand:
|
|
22661
|
-
relativePathFromCwd:
|
|
23867
|
+
deleteCommand: import_mini75.z.object({
|
|
23868
|
+
relativePathFromCwd: import_mini75.z.string()
|
|
22662
23869
|
})
|
|
22663
23870
|
};
|
|
22664
23871
|
var commandTools = {
|
|
22665
23872
|
listCommands: {
|
|
22666
23873
|
name: "listCommands",
|
|
22667
|
-
description: `List all commands from ${(0,
|
|
23874
|
+
description: `List all commands from ${(0, import_node_path146.join)(RULESYNC_COMMANDS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
22668
23875
|
parameters: commandToolSchemas.listCommands,
|
|
22669
23876
|
execute: async () => {
|
|
22670
23877
|
const commands = await listCommands();
|
|
@@ -22706,15 +23913,15 @@ var commandTools = {
|
|
|
22706
23913
|
};
|
|
22707
23914
|
|
|
22708
23915
|
// src/mcp/generate.ts
|
|
22709
|
-
var
|
|
22710
|
-
var generateOptionsSchema =
|
|
22711
|
-
targets:
|
|
22712
|
-
features:
|
|
22713
|
-
delete:
|
|
22714
|
-
global:
|
|
22715
|
-
simulateCommands:
|
|
22716
|
-
simulateSubagents:
|
|
22717
|
-
simulateSkills:
|
|
23916
|
+
var import_mini76 = require("zod/mini");
|
|
23917
|
+
var generateOptionsSchema = import_mini76.z.object({
|
|
23918
|
+
targets: import_mini76.z.optional(import_mini76.z.array(import_mini76.z.string())),
|
|
23919
|
+
features: import_mini76.z.optional(import_mini76.z.array(import_mini76.z.string())),
|
|
23920
|
+
delete: import_mini76.z.optional(import_mini76.z.boolean()),
|
|
23921
|
+
global: import_mini76.z.optional(import_mini76.z.boolean()),
|
|
23922
|
+
simulateCommands: import_mini76.z.optional(import_mini76.z.boolean()),
|
|
23923
|
+
simulateSubagents: import_mini76.z.optional(import_mini76.z.boolean()),
|
|
23924
|
+
simulateSkills: import_mini76.z.optional(import_mini76.z.boolean())
|
|
22718
23925
|
});
|
|
22719
23926
|
async function executeGenerate(options = {}) {
|
|
22720
23927
|
try {
|
|
@@ -22763,6 +23970,7 @@ function buildSuccessResponse(params) {
|
|
|
22763
23970
|
subagentsCount: generateResult.subagentsCount,
|
|
22764
23971
|
skillsCount: generateResult.skillsCount,
|
|
22765
23972
|
hooksCount: generateResult.hooksCount,
|
|
23973
|
+
permissionsCount: generateResult.permissionsCount,
|
|
22766
23974
|
totalCount
|
|
22767
23975
|
},
|
|
22768
23976
|
config: {
|
|
@@ -22792,11 +24000,11 @@ var generateTools = {
|
|
|
22792
24000
|
};
|
|
22793
24001
|
|
|
22794
24002
|
// src/mcp/ignore.ts
|
|
22795
|
-
var
|
|
22796
|
-
var
|
|
24003
|
+
var import_node_path147 = require("path");
|
|
24004
|
+
var import_mini77 = require("zod/mini");
|
|
22797
24005
|
var maxIgnoreFileSizeBytes = 100 * 1024;
|
|
22798
24006
|
async function getIgnoreFile() {
|
|
22799
|
-
const ignoreFilePath = (0,
|
|
24007
|
+
const ignoreFilePath = (0, import_node_path147.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
22800
24008
|
try {
|
|
22801
24009
|
const content = await readFileContent(ignoreFilePath);
|
|
22802
24010
|
return {
|
|
@@ -22813,7 +24021,7 @@ async function getIgnoreFile() {
|
|
|
22813
24021
|
}
|
|
22814
24022
|
}
|
|
22815
24023
|
async function putIgnoreFile({ content }) {
|
|
22816
|
-
const ignoreFilePath = (0,
|
|
24024
|
+
const ignoreFilePath = (0, import_node_path147.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
22817
24025
|
const contentSizeBytes = Buffer.byteLength(content, "utf8");
|
|
22818
24026
|
if (contentSizeBytes > maxIgnoreFileSizeBytes) {
|
|
22819
24027
|
throw new Error(
|
|
@@ -22837,8 +24045,8 @@ async function putIgnoreFile({ content }) {
|
|
|
22837
24045
|
}
|
|
22838
24046
|
}
|
|
22839
24047
|
async function deleteIgnoreFile() {
|
|
22840
|
-
const aiignorePath = (0,
|
|
22841
|
-
const legacyIgnorePath = (0,
|
|
24048
|
+
const aiignorePath = (0, import_node_path147.join)(process.cwd(), RULESYNC_AIIGNORE_RELATIVE_FILE_PATH);
|
|
24049
|
+
const legacyIgnorePath = (0, import_node_path147.join)(process.cwd(), RULESYNC_IGNORE_RELATIVE_FILE_PATH);
|
|
22842
24050
|
try {
|
|
22843
24051
|
await Promise.all([removeFile(aiignorePath), removeFile(legacyIgnorePath)]);
|
|
22844
24052
|
return {
|
|
@@ -22856,11 +24064,11 @@ async function deleteIgnoreFile() {
|
|
|
22856
24064
|
}
|
|
22857
24065
|
}
|
|
22858
24066
|
var ignoreToolSchemas = {
|
|
22859
|
-
getIgnoreFile:
|
|
22860
|
-
putIgnoreFile:
|
|
22861
|
-
content:
|
|
24067
|
+
getIgnoreFile: import_mini77.z.object({}),
|
|
24068
|
+
putIgnoreFile: import_mini77.z.object({
|
|
24069
|
+
content: import_mini77.z.string()
|
|
22862
24070
|
}),
|
|
22863
|
-
deleteIgnoreFile:
|
|
24071
|
+
deleteIgnoreFile: import_mini77.z.object({})
|
|
22864
24072
|
};
|
|
22865
24073
|
var ignoreTools = {
|
|
22866
24074
|
getIgnoreFile: {
|
|
@@ -22893,11 +24101,11 @@ var ignoreTools = {
|
|
|
22893
24101
|
};
|
|
22894
24102
|
|
|
22895
24103
|
// src/mcp/import.ts
|
|
22896
|
-
var
|
|
22897
|
-
var importOptionsSchema =
|
|
22898
|
-
target:
|
|
22899
|
-
features:
|
|
22900
|
-
global:
|
|
24104
|
+
var import_mini78 = require("zod/mini");
|
|
24105
|
+
var importOptionsSchema = import_mini78.z.object({
|
|
24106
|
+
target: import_mini78.z.string(),
|
|
24107
|
+
features: import_mini78.z.optional(import_mini78.z.array(import_mini78.z.string())),
|
|
24108
|
+
global: import_mini78.z.optional(import_mini78.z.boolean())
|
|
22901
24109
|
});
|
|
22902
24110
|
async function executeImport(options) {
|
|
22903
24111
|
try {
|
|
@@ -22942,6 +24150,7 @@ function buildSuccessResponse2(params) {
|
|
|
22942
24150
|
subagentsCount: importResult.subagentsCount,
|
|
22943
24151
|
skillsCount: importResult.skillsCount,
|
|
22944
24152
|
hooksCount: importResult.hooksCount,
|
|
24153
|
+
permissionsCount: importResult.permissionsCount,
|
|
22945
24154
|
totalCount
|
|
22946
24155
|
},
|
|
22947
24156
|
config: {
|
|
@@ -22967,15 +24176,15 @@ var importTools = {
|
|
|
22967
24176
|
};
|
|
22968
24177
|
|
|
22969
24178
|
// src/mcp/mcp.ts
|
|
22970
|
-
var
|
|
22971
|
-
var
|
|
24179
|
+
var import_node_path148 = require("path");
|
|
24180
|
+
var import_mini79 = require("zod/mini");
|
|
22972
24181
|
var maxMcpSizeBytes = 1024 * 1024;
|
|
22973
24182
|
async function getMcpFile() {
|
|
22974
24183
|
try {
|
|
22975
24184
|
const rulesyncMcp = await RulesyncMcp.fromFile({
|
|
22976
24185
|
validate: true
|
|
22977
24186
|
});
|
|
22978
|
-
const relativePathFromCwd = (0,
|
|
24187
|
+
const relativePathFromCwd = (0, import_node_path148.join)(
|
|
22979
24188
|
rulesyncMcp.getRelativeDirPath(),
|
|
22980
24189
|
rulesyncMcp.getRelativeFilePath()
|
|
22981
24190
|
);
|
|
@@ -23013,7 +24222,7 @@ async function putMcpFile({ content }) {
|
|
|
23013
24222
|
const paths = RulesyncMcp.getSettablePaths();
|
|
23014
24223
|
const relativeDirPath = paths.recommended.relativeDirPath;
|
|
23015
24224
|
const relativeFilePath = paths.recommended.relativeFilePath;
|
|
23016
|
-
const fullPath = (0,
|
|
24225
|
+
const fullPath = (0, import_node_path148.join)(baseDir, relativeDirPath, relativeFilePath);
|
|
23017
24226
|
const rulesyncMcp = new RulesyncMcp({
|
|
23018
24227
|
baseDir,
|
|
23019
24228
|
relativeDirPath,
|
|
@@ -23021,9 +24230,9 @@ async function putMcpFile({ content }) {
|
|
|
23021
24230
|
fileContent: content,
|
|
23022
24231
|
validate: true
|
|
23023
24232
|
});
|
|
23024
|
-
await ensureDir((0,
|
|
24233
|
+
await ensureDir((0, import_node_path148.join)(baseDir, relativeDirPath));
|
|
23025
24234
|
await writeFileContent(fullPath, content);
|
|
23026
|
-
const relativePathFromCwd = (0,
|
|
24235
|
+
const relativePathFromCwd = (0, import_node_path148.join)(relativeDirPath, relativeFilePath);
|
|
23027
24236
|
return {
|
|
23028
24237
|
relativePathFromCwd,
|
|
23029
24238
|
content: rulesyncMcp.getFileContent()
|
|
@@ -23041,15 +24250,15 @@ async function deleteMcpFile() {
|
|
|
23041
24250
|
try {
|
|
23042
24251
|
const baseDir = process.cwd();
|
|
23043
24252
|
const paths = RulesyncMcp.getSettablePaths();
|
|
23044
|
-
const recommendedPath = (0,
|
|
24253
|
+
const recommendedPath = (0, import_node_path148.join)(
|
|
23045
24254
|
baseDir,
|
|
23046
24255
|
paths.recommended.relativeDirPath,
|
|
23047
24256
|
paths.recommended.relativeFilePath
|
|
23048
24257
|
);
|
|
23049
|
-
const legacyPath = (0,
|
|
24258
|
+
const legacyPath = (0, import_node_path148.join)(baseDir, paths.legacy.relativeDirPath, paths.legacy.relativeFilePath);
|
|
23050
24259
|
await removeFile(recommendedPath);
|
|
23051
24260
|
await removeFile(legacyPath);
|
|
23052
|
-
const relativePathFromCwd = (0,
|
|
24261
|
+
const relativePathFromCwd = (0, import_node_path148.join)(
|
|
23053
24262
|
paths.recommended.relativeDirPath,
|
|
23054
24263
|
paths.recommended.relativeFilePath
|
|
23055
24264
|
);
|
|
@@ -23066,11 +24275,11 @@ async function deleteMcpFile() {
|
|
|
23066
24275
|
}
|
|
23067
24276
|
}
|
|
23068
24277
|
var mcpToolSchemas = {
|
|
23069
|
-
getMcpFile:
|
|
23070
|
-
putMcpFile:
|
|
23071
|
-
content:
|
|
24278
|
+
getMcpFile: import_mini79.z.object({}),
|
|
24279
|
+
putMcpFile: import_mini79.z.object({
|
|
24280
|
+
content: import_mini79.z.string()
|
|
23072
24281
|
}),
|
|
23073
|
-
deleteMcpFile:
|
|
24282
|
+
deleteMcpFile: import_mini79.z.object({})
|
|
23074
24283
|
};
|
|
23075
24284
|
var mcpTools = {
|
|
23076
24285
|
getMcpFile: {
|
|
@@ -23103,13 +24312,13 @@ var mcpTools = {
|
|
|
23103
24312
|
};
|
|
23104
24313
|
|
|
23105
24314
|
// src/mcp/rules.ts
|
|
23106
|
-
var
|
|
23107
|
-
var
|
|
24315
|
+
var import_node_path149 = require("path");
|
|
24316
|
+
var import_mini80 = require("zod/mini");
|
|
23108
24317
|
var logger2 = new ConsoleLogger({ verbose: false, silent: true });
|
|
23109
24318
|
var maxRuleSizeBytes = 1024 * 1024;
|
|
23110
24319
|
var maxRulesCount = 1e3;
|
|
23111
24320
|
async function listRules() {
|
|
23112
|
-
const rulesDir = (0,
|
|
24321
|
+
const rulesDir = (0, import_node_path149.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
23113
24322
|
try {
|
|
23114
24323
|
const files = await listDirectoryFiles(rulesDir);
|
|
23115
24324
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -23122,7 +24331,7 @@ async function listRules() {
|
|
|
23122
24331
|
});
|
|
23123
24332
|
const frontmatter = rule.getFrontmatter();
|
|
23124
24333
|
return {
|
|
23125
|
-
relativePathFromCwd: (0,
|
|
24334
|
+
relativePathFromCwd: (0, import_node_path149.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, file),
|
|
23126
24335
|
frontmatter
|
|
23127
24336
|
};
|
|
23128
24337
|
} catch (error) {
|
|
@@ -23144,14 +24353,14 @@ async function getRule({ relativePathFromCwd }) {
|
|
|
23144
24353
|
relativePath: relativePathFromCwd,
|
|
23145
24354
|
intendedRootDir: process.cwd()
|
|
23146
24355
|
});
|
|
23147
|
-
const filename = (0,
|
|
24356
|
+
const filename = (0, import_node_path149.basename)(relativePathFromCwd);
|
|
23148
24357
|
try {
|
|
23149
24358
|
const rule = await RulesyncRule.fromFile({
|
|
23150
24359
|
relativeFilePath: filename,
|
|
23151
24360
|
validate: true
|
|
23152
24361
|
});
|
|
23153
24362
|
return {
|
|
23154
|
-
relativePathFromCwd: (0,
|
|
24363
|
+
relativePathFromCwd: (0, import_node_path149.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
23155
24364
|
frontmatter: rule.getFrontmatter(),
|
|
23156
24365
|
body: rule.getBody()
|
|
23157
24366
|
};
|
|
@@ -23170,7 +24379,7 @@ async function putRule({
|
|
|
23170
24379
|
relativePath: relativePathFromCwd,
|
|
23171
24380
|
intendedRootDir: process.cwd()
|
|
23172
24381
|
});
|
|
23173
|
-
const filename = (0,
|
|
24382
|
+
const filename = (0, import_node_path149.basename)(relativePathFromCwd);
|
|
23174
24383
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
23175
24384
|
if (estimatedSize > maxRuleSizeBytes) {
|
|
23176
24385
|
throw new Error(
|
|
@@ -23180,7 +24389,7 @@ async function putRule({
|
|
|
23180
24389
|
try {
|
|
23181
24390
|
const existingRules = await listRules();
|
|
23182
24391
|
const isUpdate = existingRules.some(
|
|
23183
|
-
(rule2) => rule2.relativePathFromCwd === (0,
|
|
24392
|
+
(rule2) => rule2.relativePathFromCwd === (0, import_node_path149.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
23184
24393
|
);
|
|
23185
24394
|
if (!isUpdate && existingRules.length >= maxRulesCount) {
|
|
23186
24395
|
throw new Error(
|
|
@@ -23195,11 +24404,11 @@ async function putRule({
|
|
|
23195
24404
|
body,
|
|
23196
24405
|
validate: true
|
|
23197
24406
|
});
|
|
23198
|
-
const rulesDir = (0,
|
|
24407
|
+
const rulesDir = (0, import_node_path149.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH);
|
|
23199
24408
|
await ensureDir(rulesDir);
|
|
23200
24409
|
await writeFileContent(rule.getFilePath(), rule.getFileContent());
|
|
23201
24410
|
return {
|
|
23202
|
-
relativePathFromCwd: (0,
|
|
24411
|
+
relativePathFromCwd: (0, import_node_path149.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename),
|
|
23203
24412
|
frontmatter: rule.getFrontmatter(),
|
|
23204
24413
|
body: rule.getBody()
|
|
23205
24414
|
};
|
|
@@ -23214,12 +24423,12 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
23214
24423
|
relativePath: relativePathFromCwd,
|
|
23215
24424
|
intendedRootDir: process.cwd()
|
|
23216
24425
|
});
|
|
23217
|
-
const filename = (0,
|
|
23218
|
-
const fullPath = (0,
|
|
24426
|
+
const filename = (0, import_node_path149.basename)(relativePathFromCwd);
|
|
24427
|
+
const fullPath = (0, import_node_path149.join)(process.cwd(), RULESYNC_RULES_RELATIVE_DIR_PATH, filename);
|
|
23219
24428
|
try {
|
|
23220
24429
|
await removeFile(fullPath);
|
|
23221
24430
|
return {
|
|
23222
|
-
relativePathFromCwd: (0,
|
|
24431
|
+
relativePathFromCwd: (0, import_node_path149.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, filename)
|
|
23223
24432
|
};
|
|
23224
24433
|
} catch (error) {
|
|
23225
24434
|
throw new Error(`Failed to delete rule file ${relativePathFromCwd}: ${formatError(error)}`, {
|
|
@@ -23228,23 +24437,23 @@ async function deleteRule({ relativePathFromCwd }) {
|
|
|
23228
24437
|
}
|
|
23229
24438
|
}
|
|
23230
24439
|
var ruleToolSchemas = {
|
|
23231
|
-
listRules:
|
|
23232
|
-
getRule:
|
|
23233
|
-
relativePathFromCwd:
|
|
24440
|
+
listRules: import_mini80.z.object({}),
|
|
24441
|
+
getRule: import_mini80.z.object({
|
|
24442
|
+
relativePathFromCwd: import_mini80.z.string()
|
|
23234
24443
|
}),
|
|
23235
|
-
putRule:
|
|
23236
|
-
relativePathFromCwd:
|
|
24444
|
+
putRule: import_mini80.z.object({
|
|
24445
|
+
relativePathFromCwd: import_mini80.z.string(),
|
|
23237
24446
|
frontmatter: RulesyncRuleFrontmatterSchema,
|
|
23238
|
-
body:
|
|
24447
|
+
body: import_mini80.z.string()
|
|
23239
24448
|
}),
|
|
23240
|
-
deleteRule:
|
|
23241
|
-
relativePathFromCwd:
|
|
24449
|
+
deleteRule: import_mini80.z.object({
|
|
24450
|
+
relativePathFromCwd: import_mini80.z.string()
|
|
23242
24451
|
})
|
|
23243
24452
|
};
|
|
23244
24453
|
var ruleTools = {
|
|
23245
24454
|
listRules: {
|
|
23246
24455
|
name: "listRules",
|
|
23247
|
-
description: `List all rules from ${(0,
|
|
24456
|
+
description: `List all rules from ${(0, import_node_path149.join)(RULESYNC_RULES_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
23248
24457
|
parameters: ruleToolSchemas.listRules,
|
|
23249
24458
|
execute: async () => {
|
|
23250
24459
|
const rules = await listRules();
|
|
@@ -23286,8 +24495,8 @@ var ruleTools = {
|
|
|
23286
24495
|
};
|
|
23287
24496
|
|
|
23288
24497
|
// src/mcp/skills.ts
|
|
23289
|
-
var
|
|
23290
|
-
var
|
|
24498
|
+
var import_node_path150 = require("path");
|
|
24499
|
+
var import_mini81 = require("zod/mini");
|
|
23291
24500
|
var logger3 = new ConsoleLogger({ verbose: false, silent: true });
|
|
23292
24501
|
var maxSkillSizeBytes = 1024 * 1024;
|
|
23293
24502
|
var maxSkillsCount = 1e3;
|
|
@@ -23304,19 +24513,19 @@ function mcpSkillFileToAiDirFile(file) {
|
|
|
23304
24513
|
};
|
|
23305
24514
|
}
|
|
23306
24515
|
function extractDirName(relativeDirPathFromCwd) {
|
|
23307
|
-
const dirName = (0,
|
|
24516
|
+
const dirName = (0, import_node_path150.basename)(relativeDirPathFromCwd);
|
|
23308
24517
|
if (!dirName) {
|
|
23309
24518
|
throw new Error(`Invalid path: ${relativeDirPathFromCwd}`);
|
|
23310
24519
|
}
|
|
23311
24520
|
return dirName;
|
|
23312
24521
|
}
|
|
23313
24522
|
async function listSkills() {
|
|
23314
|
-
const skillsDir = (0,
|
|
24523
|
+
const skillsDir = (0, import_node_path150.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH);
|
|
23315
24524
|
try {
|
|
23316
|
-
const skillDirPaths = await findFilesByGlobs((0,
|
|
24525
|
+
const skillDirPaths = await findFilesByGlobs((0, import_node_path150.join)(skillsDir, "*"), { type: "dir" });
|
|
23317
24526
|
const skills = await Promise.all(
|
|
23318
24527
|
skillDirPaths.map(async (dirPath) => {
|
|
23319
|
-
const dirName = (0,
|
|
24528
|
+
const dirName = (0, import_node_path150.basename)(dirPath);
|
|
23320
24529
|
if (!dirName) return null;
|
|
23321
24530
|
try {
|
|
23322
24531
|
const skill = await RulesyncSkill.fromDir({
|
|
@@ -23324,7 +24533,7 @@ async function listSkills() {
|
|
|
23324
24533
|
});
|
|
23325
24534
|
const frontmatter = skill.getFrontmatter();
|
|
23326
24535
|
return {
|
|
23327
|
-
relativeDirPathFromCwd: (0,
|
|
24536
|
+
relativeDirPathFromCwd: (0, import_node_path150.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
23328
24537
|
frontmatter
|
|
23329
24538
|
};
|
|
23330
24539
|
} catch (error) {
|
|
@@ -23352,7 +24561,7 @@ async function getSkill({ relativeDirPathFromCwd }) {
|
|
|
23352
24561
|
dirName
|
|
23353
24562
|
});
|
|
23354
24563
|
return {
|
|
23355
|
-
relativeDirPathFromCwd: (0,
|
|
24564
|
+
relativeDirPathFromCwd: (0, import_node_path150.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
23356
24565
|
frontmatter: skill.getFrontmatter(),
|
|
23357
24566
|
body: skill.getBody(),
|
|
23358
24567
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -23386,7 +24595,7 @@ async function putSkill({
|
|
|
23386
24595
|
try {
|
|
23387
24596
|
const existingSkills = await listSkills();
|
|
23388
24597
|
const isUpdate = existingSkills.some(
|
|
23389
|
-
(skill2) => skill2.relativeDirPathFromCwd === (0,
|
|
24598
|
+
(skill2) => skill2.relativeDirPathFromCwd === (0, import_node_path150.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
23390
24599
|
);
|
|
23391
24600
|
if (!isUpdate && existingSkills.length >= maxSkillsCount) {
|
|
23392
24601
|
throw new Error(
|
|
@@ -23403,9 +24612,9 @@ async function putSkill({
|
|
|
23403
24612
|
otherFiles: aiDirFiles,
|
|
23404
24613
|
validate: true
|
|
23405
24614
|
});
|
|
23406
|
-
const skillDirPath = (0,
|
|
24615
|
+
const skillDirPath = (0, import_node_path150.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
23407
24616
|
await ensureDir(skillDirPath);
|
|
23408
|
-
const skillFilePath = (0,
|
|
24617
|
+
const skillFilePath = (0, import_node_path150.join)(skillDirPath, SKILL_FILE_NAME);
|
|
23409
24618
|
const skillFileContent = stringifyFrontmatter(body, frontmatter);
|
|
23410
24619
|
await writeFileContent(skillFilePath, skillFileContent);
|
|
23411
24620
|
for (const file of otherFiles) {
|
|
@@ -23413,15 +24622,15 @@ async function putSkill({
|
|
|
23413
24622
|
relativePath: file.name,
|
|
23414
24623
|
intendedRootDir: skillDirPath
|
|
23415
24624
|
});
|
|
23416
|
-
const filePath = (0,
|
|
23417
|
-
const fileDir = (0,
|
|
24625
|
+
const filePath = (0, import_node_path150.join)(skillDirPath, file.name);
|
|
24626
|
+
const fileDir = (0, import_node_path150.join)(skillDirPath, (0, import_node_path150.dirname)(file.name));
|
|
23418
24627
|
if (fileDir !== skillDirPath) {
|
|
23419
24628
|
await ensureDir(fileDir);
|
|
23420
24629
|
}
|
|
23421
24630
|
await writeFileContent(filePath, file.body);
|
|
23422
24631
|
}
|
|
23423
24632
|
return {
|
|
23424
|
-
relativeDirPathFromCwd: (0,
|
|
24633
|
+
relativeDirPathFromCwd: (0, import_node_path150.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName),
|
|
23425
24634
|
frontmatter: skill.getFrontmatter(),
|
|
23426
24635
|
body: skill.getBody(),
|
|
23427
24636
|
otherFiles: skill.getOtherFiles().map(aiDirFileToMcpSkillFile)
|
|
@@ -23443,13 +24652,13 @@ async function deleteSkill({
|
|
|
23443
24652
|
intendedRootDir: process.cwd()
|
|
23444
24653
|
});
|
|
23445
24654
|
const dirName = extractDirName(relativeDirPathFromCwd);
|
|
23446
|
-
const skillDirPath = (0,
|
|
24655
|
+
const skillDirPath = (0, import_node_path150.join)(process.cwd(), RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName);
|
|
23447
24656
|
try {
|
|
23448
24657
|
if (await directoryExists(skillDirPath)) {
|
|
23449
24658
|
await removeDirectory(skillDirPath);
|
|
23450
24659
|
}
|
|
23451
24660
|
return {
|
|
23452
|
-
relativeDirPathFromCwd: (0,
|
|
24661
|
+
relativeDirPathFromCwd: (0, import_node_path150.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, dirName)
|
|
23453
24662
|
};
|
|
23454
24663
|
} catch (error) {
|
|
23455
24664
|
throw new Error(
|
|
@@ -23460,29 +24669,29 @@ async function deleteSkill({
|
|
|
23460
24669
|
);
|
|
23461
24670
|
}
|
|
23462
24671
|
}
|
|
23463
|
-
var McpSkillFileSchema =
|
|
23464
|
-
name:
|
|
23465
|
-
body:
|
|
24672
|
+
var McpSkillFileSchema = import_mini81.z.object({
|
|
24673
|
+
name: import_mini81.z.string(),
|
|
24674
|
+
body: import_mini81.z.string()
|
|
23466
24675
|
});
|
|
23467
24676
|
var skillToolSchemas = {
|
|
23468
|
-
listSkills:
|
|
23469
|
-
getSkill:
|
|
23470
|
-
relativeDirPathFromCwd:
|
|
24677
|
+
listSkills: import_mini81.z.object({}),
|
|
24678
|
+
getSkill: import_mini81.z.object({
|
|
24679
|
+
relativeDirPathFromCwd: import_mini81.z.string()
|
|
23471
24680
|
}),
|
|
23472
|
-
putSkill:
|
|
23473
|
-
relativeDirPathFromCwd:
|
|
24681
|
+
putSkill: import_mini81.z.object({
|
|
24682
|
+
relativeDirPathFromCwd: import_mini81.z.string(),
|
|
23474
24683
|
frontmatter: RulesyncSkillFrontmatterSchema,
|
|
23475
|
-
body:
|
|
23476
|
-
otherFiles:
|
|
24684
|
+
body: import_mini81.z.string(),
|
|
24685
|
+
otherFiles: import_mini81.z.optional(import_mini81.z.array(McpSkillFileSchema))
|
|
23477
24686
|
}),
|
|
23478
|
-
deleteSkill:
|
|
23479
|
-
relativeDirPathFromCwd:
|
|
24687
|
+
deleteSkill: import_mini81.z.object({
|
|
24688
|
+
relativeDirPathFromCwd: import_mini81.z.string()
|
|
23480
24689
|
})
|
|
23481
24690
|
};
|
|
23482
24691
|
var skillTools = {
|
|
23483
24692
|
listSkills: {
|
|
23484
24693
|
name: "listSkills",
|
|
23485
|
-
description: `List all skills from ${(0,
|
|
24694
|
+
description: `List all skills from ${(0, import_node_path150.join)(RULESYNC_SKILLS_RELATIVE_DIR_PATH, "*", SKILL_FILE_NAME)} with their frontmatter.`,
|
|
23486
24695
|
parameters: skillToolSchemas.listSkills,
|
|
23487
24696
|
execute: async () => {
|
|
23488
24697
|
const skills = await listSkills();
|
|
@@ -23525,13 +24734,13 @@ var skillTools = {
|
|
|
23525
24734
|
};
|
|
23526
24735
|
|
|
23527
24736
|
// src/mcp/subagents.ts
|
|
23528
|
-
var
|
|
23529
|
-
var
|
|
24737
|
+
var import_node_path151 = require("path");
|
|
24738
|
+
var import_mini82 = require("zod/mini");
|
|
23530
24739
|
var logger4 = new ConsoleLogger({ verbose: false, silent: true });
|
|
23531
24740
|
var maxSubagentSizeBytes = 1024 * 1024;
|
|
23532
24741
|
var maxSubagentsCount = 1e3;
|
|
23533
24742
|
async function listSubagents() {
|
|
23534
|
-
const subagentsDir = (0,
|
|
24743
|
+
const subagentsDir = (0, import_node_path151.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
23535
24744
|
try {
|
|
23536
24745
|
const files = await listDirectoryFiles(subagentsDir);
|
|
23537
24746
|
const mdFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -23544,7 +24753,7 @@ async function listSubagents() {
|
|
|
23544
24753
|
});
|
|
23545
24754
|
const frontmatter = subagent.getFrontmatter();
|
|
23546
24755
|
return {
|
|
23547
|
-
relativePathFromCwd: (0,
|
|
24756
|
+
relativePathFromCwd: (0, import_node_path151.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, file),
|
|
23548
24757
|
frontmatter
|
|
23549
24758
|
};
|
|
23550
24759
|
} catch (error) {
|
|
@@ -23568,14 +24777,14 @@ async function getSubagent({ relativePathFromCwd }) {
|
|
|
23568
24777
|
relativePath: relativePathFromCwd,
|
|
23569
24778
|
intendedRootDir: process.cwd()
|
|
23570
24779
|
});
|
|
23571
|
-
const filename = (0,
|
|
24780
|
+
const filename = (0, import_node_path151.basename)(relativePathFromCwd);
|
|
23572
24781
|
try {
|
|
23573
24782
|
const subagent = await RulesyncSubagent.fromFile({
|
|
23574
24783
|
relativeFilePath: filename,
|
|
23575
24784
|
validate: true
|
|
23576
24785
|
});
|
|
23577
24786
|
return {
|
|
23578
|
-
relativePathFromCwd: (0,
|
|
24787
|
+
relativePathFromCwd: (0, import_node_path151.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
23579
24788
|
frontmatter: subagent.getFrontmatter(),
|
|
23580
24789
|
body: subagent.getBody()
|
|
23581
24790
|
};
|
|
@@ -23594,7 +24803,7 @@ async function putSubagent({
|
|
|
23594
24803
|
relativePath: relativePathFromCwd,
|
|
23595
24804
|
intendedRootDir: process.cwd()
|
|
23596
24805
|
});
|
|
23597
|
-
const filename = (0,
|
|
24806
|
+
const filename = (0, import_node_path151.basename)(relativePathFromCwd);
|
|
23598
24807
|
const estimatedSize = JSON.stringify(frontmatter).length + body.length;
|
|
23599
24808
|
if (estimatedSize > maxSubagentSizeBytes) {
|
|
23600
24809
|
throw new Error(
|
|
@@ -23604,7 +24813,7 @@ async function putSubagent({
|
|
|
23604
24813
|
try {
|
|
23605
24814
|
const existingSubagents = await listSubagents();
|
|
23606
24815
|
const isUpdate = existingSubagents.some(
|
|
23607
|
-
(subagent2) => subagent2.relativePathFromCwd === (0,
|
|
24816
|
+
(subagent2) => subagent2.relativePathFromCwd === (0, import_node_path151.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
23608
24817
|
);
|
|
23609
24818
|
if (!isUpdate && existingSubagents.length >= maxSubagentsCount) {
|
|
23610
24819
|
throw new Error(
|
|
@@ -23619,11 +24828,11 @@ async function putSubagent({
|
|
|
23619
24828
|
body,
|
|
23620
24829
|
validate: true
|
|
23621
24830
|
});
|
|
23622
|
-
const subagentsDir = (0,
|
|
24831
|
+
const subagentsDir = (0, import_node_path151.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH);
|
|
23623
24832
|
await ensureDir(subagentsDir);
|
|
23624
24833
|
await writeFileContent(subagent.getFilePath(), subagent.getFileContent());
|
|
23625
24834
|
return {
|
|
23626
|
-
relativePathFromCwd: (0,
|
|
24835
|
+
relativePathFromCwd: (0, import_node_path151.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename),
|
|
23627
24836
|
frontmatter: subagent.getFrontmatter(),
|
|
23628
24837
|
body: subagent.getBody()
|
|
23629
24838
|
};
|
|
@@ -23638,12 +24847,12 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
23638
24847
|
relativePath: relativePathFromCwd,
|
|
23639
24848
|
intendedRootDir: process.cwd()
|
|
23640
24849
|
});
|
|
23641
|
-
const filename = (0,
|
|
23642
|
-
const fullPath = (0,
|
|
24850
|
+
const filename = (0, import_node_path151.basename)(relativePathFromCwd);
|
|
24851
|
+
const fullPath = (0, import_node_path151.join)(process.cwd(), RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename);
|
|
23643
24852
|
try {
|
|
23644
24853
|
await removeFile(fullPath);
|
|
23645
24854
|
return {
|
|
23646
|
-
relativePathFromCwd: (0,
|
|
24855
|
+
relativePathFromCwd: (0, import_node_path151.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, filename)
|
|
23647
24856
|
};
|
|
23648
24857
|
} catch (error) {
|
|
23649
24858
|
throw new Error(
|
|
@@ -23655,23 +24864,23 @@ async function deleteSubagent({ relativePathFromCwd }) {
|
|
|
23655
24864
|
}
|
|
23656
24865
|
}
|
|
23657
24866
|
var subagentToolSchemas = {
|
|
23658
|
-
listSubagents:
|
|
23659
|
-
getSubagent:
|
|
23660
|
-
relativePathFromCwd:
|
|
24867
|
+
listSubagents: import_mini82.z.object({}),
|
|
24868
|
+
getSubagent: import_mini82.z.object({
|
|
24869
|
+
relativePathFromCwd: import_mini82.z.string()
|
|
23661
24870
|
}),
|
|
23662
|
-
putSubagent:
|
|
23663
|
-
relativePathFromCwd:
|
|
24871
|
+
putSubagent: import_mini82.z.object({
|
|
24872
|
+
relativePathFromCwd: import_mini82.z.string(),
|
|
23664
24873
|
frontmatter: RulesyncSubagentFrontmatterSchema,
|
|
23665
|
-
body:
|
|
24874
|
+
body: import_mini82.z.string()
|
|
23666
24875
|
}),
|
|
23667
|
-
deleteSubagent:
|
|
23668
|
-
relativePathFromCwd:
|
|
24876
|
+
deleteSubagent: import_mini82.z.object({
|
|
24877
|
+
relativePathFromCwd: import_mini82.z.string()
|
|
23669
24878
|
})
|
|
23670
24879
|
};
|
|
23671
24880
|
var subagentTools = {
|
|
23672
24881
|
listSubagents: {
|
|
23673
24882
|
name: "listSubagents",
|
|
23674
|
-
description: `List all subagents from ${(0,
|
|
24883
|
+
description: `List all subagents from ${(0, import_node_path151.join)(RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH, "*.md")} with their frontmatter.`,
|
|
23675
24884
|
parameters: subagentToolSchemas.listSubagents,
|
|
23676
24885
|
execute: async () => {
|
|
23677
24886
|
const subagents = await listSubagents();
|
|
@@ -23713,7 +24922,7 @@ var subagentTools = {
|
|
|
23713
24922
|
};
|
|
23714
24923
|
|
|
23715
24924
|
// src/mcp/tools.ts
|
|
23716
|
-
var rulesyncFeatureSchema =
|
|
24925
|
+
var rulesyncFeatureSchema = import_mini83.z.enum([
|
|
23717
24926
|
"rule",
|
|
23718
24927
|
"command",
|
|
23719
24928
|
"subagent",
|
|
@@ -23723,21 +24932,21 @@ var rulesyncFeatureSchema = import_mini78.z.enum([
|
|
|
23723
24932
|
"generate",
|
|
23724
24933
|
"import"
|
|
23725
24934
|
]);
|
|
23726
|
-
var rulesyncOperationSchema =
|
|
23727
|
-
var skillFileSchema =
|
|
23728
|
-
name:
|
|
23729
|
-
body:
|
|
24935
|
+
var rulesyncOperationSchema = import_mini83.z.enum(["list", "get", "put", "delete", "run"]);
|
|
24936
|
+
var skillFileSchema = import_mini83.z.object({
|
|
24937
|
+
name: import_mini83.z.string(),
|
|
24938
|
+
body: import_mini83.z.string()
|
|
23730
24939
|
});
|
|
23731
|
-
var rulesyncToolSchema =
|
|
24940
|
+
var rulesyncToolSchema = import_mini83.z.object({
|
|
23732
24941
|
feature: rulesyncFeatureSchema,
|
|
23733
24942
|
operation: rulesyncOperationSchema,
|
|
23734
|
-
targetPathFromCwd:
|
|
23735
|
-
frontmatter:
|
|
23736
|
-
body:
|
|
23737
|
-
otherFiles:
|
|
23738
|
-
content:
|
|
23739
|
-
generateOptions:
|
|
23740
|
-
importOptions:
|
|
24943
|
+
targetPathFromCwd: import_mini83.z.optional(import_mini83.z.string()),
|
|
24944
|
+
frontmatter: import_mini83.z.optional(import_mini83.z.unknown()),
|
|
24945
|
+
body: import_mini83.z.optional(import_mini83.z.string()),
|
|
24946
|
+
otherFiles: import_mini83.z.optional(import_mini83.z.array(skillFileSchema)),
|
|
24947
|
+
content: import_mini83.z.optional(import_mini83.z.string()),
|
|
24948
|
+
generateOptions: import_mini83.z.optional(generateOptionsSchema),
|
|
24949
|
+
importOptions: import_mini83.z.optional(importOptionsSchema)
|
|
23741
24950
|
});
|
|
23742
24951
|
var supportedOperationsByFeature = {
|
|
23743
24952
|
rule: ["list", "get", "put", "delete"],
|
|
@@ -24345,7 +25554,7 @@ function wrapCommand({
|
|
|
24345
25554
|
}
|
|
24346
25555
|
|
|
24347
25556
|
// src/cli/index.ts
|
|
24348
|
-
var getVersion = () => "
|
|
25557
|
+
var getVersion = () => "8.0.0";
|
|
24349
25558
|
function wrapCommand2(name, errorCode, handler) {
|
|
24350
25559
|
return wrapCommand({ name, errorCode, handler, getVersion });
|
|
24351
25560
|
}
|