rulesync 43.16.0 → 43.17.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/dist/cli/index.cjs +246 -1359
- package/dist/cli/index.js +63 -1176
- package/dist/cli/index.js.map +1 -1
- package/dist/{import-BZAYr7ab.js → import-C_TEclz6.js} +1654 -66
- package/dist/{import-BZAYr7ab.js.map → import-C_TEclz6.js.map} +1 -1
- package/dist/{import-B2rJ3SBE.cjs → import-DzRS2z_a.cjs} +1983 -95
- package/dist/index.cjs +1 -1
- package/dist/index.d.cts.map +1 -1
- package/dist/index.d.ts.map +1 -1
- package/dist/index.js +1 -1
- package/package.json +14 -14
|
@@ -381,40 +381,40 @@ function formatError(error) {
|
|
|
381
381
|
return boundErrorMessage(String(error));
|
|
382
382
|
}
|
|
383
383
|
// src/constants/rulesync-paths.ts
|
|
384
|
-
const { join: join$
|
|
384
|
+
const { join: join$386 } = node_path.posix;
|
|
385
385
|
const RULESYNC_CONFIG_RELATIVE_FILE_PATH = "rulesync.jsonc";
|
|
386
386
|
const RULESYNC_LOCAL_CONFIG_RELATIVE_FILE_PATH = "rulesync.local.jsonc";
|
|
387
387
|
const RULESYNC_USER_CONFIG_DIR_NAME = "rulesync";
|
|
388
388
|
const RULESYNC_XDG_CONFIG_HOME_DEFAULT_DIR_NAME = ".config";
|
|
389
389
|
const RULESYNC_RELATIVE_DIR_PATH = ".rulesync";
|
|
390
390
|
const RULES_FEATURE_SUBDIR = "rules";
|
|
391
|
-
const CURATED_RULES_FEATURE_SUBDIR = join$
|
|
391
|
+
const CURATED_RULES_FEATURE_SUBDIR = join$386(RULES_FEATURE_SUBDIR, ".curated");
|
|
392
392
|
const COMMANDS_FEATURE_SUBDIR = "commands";
|
|
393
|
-
const CURATED_COMMANDS_FEATURE_SUBDIR = join$
|
|
393
|
+
const CURATED_COMMANDS_FEATURE_SUBDIR = join$386(COMMANDS_FEATURE_SUBDIR, ".curated");
|
|
394
394
|
const SUBAGENTS_FEATURE_SUBDIR = "subagents";
|
|
395
|
-
const CURATED_SUBAGENTS_FEATURE_SUBDIR = join$
|
|
395
|
+
const CURATED_SUBAGENTS_FEATURE_SUBDIR = join$386(SUBAGENTS_FEATURE_SUBDIR, ".curated");
|
|
396
396
|
const CHECKS_FEATURE_SUBDIR = "checks";
|
|
397
397
|
const SKILLS_FEATURE_SUBDIR = "skills";
|
|
398
|
-
const CURATED_SKILLS_FEATURE_SUBDIR = join$
|
|
399
|
-
const RULESYNC_RULES_RELATIVE_DIR_PATH = join$
|
|
400
|
-
const RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH = join$
|
|
401
|
-
const RULESYNC_COMMANDS_RELATIVE_DIR_PATH = join$
|
|
402
|
-
const RULESYNC_CURATED_COMMANDS_RELATIVE_DIR_PATH = join$
|
|
403
|
-
const RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH = join$
|
|
404
|
-
const RULESYNC_CURATED_SUBAGENTS_RELATIVE_DIR_PATH = join$
|
|
405
|
-
const RULESYNC_CHECKS_RELATIVE_DIR_PATH = join$
|
|
406
|
-
const RULESYNC_MCP_RELATIVE_FILE_PATH = join$
|
|
407
|
-
const RULESYNC_HOOKS_RELATIVE_FILE_PATH = join$
|
|
408
|
-
const RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH = join$
|
|
409
|
-
join$
|
|
410
|
-
const RULESYNC_HOOKS_LEGACY_RELATIVE_FILE_PATH = join$
|
|
411
|
-
const RULESYNC_PERMISSIONS_LEGACY_RELATIVE_FILE_PATH = join$
|
|
398
|
+
const CURATED_SKILLS_FEATURE_SUBDIR = join$386(SKILLS_FEATURE_SUBDIR, ".curated");
|
|
399
|
+
const RULESYNC_RULES_RELATIVE_DIR_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, RULES_FEATURE_SUBDIR);
|
|
400
|
+
const RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, CURATED_RULES_FEATURE_SUBDIR);
|
|
401
|
+
const RULESYNC_COMMANDS_RELATIVE_DIR_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, COMMANDS_FEATURE_SUBDIR);
|
|
402
|
+
const RULESYNC_CURATED_COMMANDS_RELATIVE_DIR_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, CURATED_COMMANDS_FEATURE_SUBDIR);
|
|
403
|
+
const RULESYNC_SUBAGENTS_RELATIVE_DIR_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, SUBAGENTS_FEATURE_SUBDIR);
|
|
404
|
+
const RULESYNC_CURATED_SUBAGENTS_RELATIVE_DIR_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, CURATED_SUBAGENTS_FEATURE_SUBDIR);
|
|
405
|
+
const RULESYNC_CHECKS_RELATIVE_DIR_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, CHECKS_FEATURE_SUBDIR);
|
|
406
|
+
const RULESYNC_MCP_RELATIVE_FILE_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, "mcp.jsonc");
|
|
407
|
+
const RULESYNC_HOOKS_RELATIVE_FILE_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, "hooks.jsonc");
|
|
408
|
+
const RULESYNC_PERMISSIONS_RELATIVE_FILE_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, "permissions.jsonc");
|
|
409
|
+
join$386(RULESYNC_RELATIVE_DIR_PATH, "mcp.json");
|
|
410
|
+
const RULESYNC_HOOKS_LEGACY_RELATIVE_FILE_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, "hooks.json");
|
|
411
|
+
const RULESYNC_PERMISSIONS_LEGACY_RELATIVE_FILE_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, "permissions.json");
|
|
412
412
|
const RULESYNC_AIIGNORE_FILE_NAME = ".aiignore";
|
|
413
|
-
const RULESYNC_AIIGNORE_RELATIVE_FILE_PATH = join$
|
|
413
|
+
const RULESYNC_AIIGNORE_RELATIVE_FILE_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, ".aiignore");
|
|
414
414
|
const RULESYNC_IGNORE_RELATIVE_FILE_PATH = ".rulesyncignore";
|
|
415
415
|
const RULESYNC_OVERVIEW_FILE_NAME = "overview.md";
|
|
416
|
-
const RULESYNC_SKILLS_RELATIVE_DIR_PATH = join$
|
|
417
|
-
const RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH = join$
|
|
416
|
+
const RULESYNC_SKILLS_RELATIVE_DIR_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, SKILLS_FEATURE_SUBDIR);
|
|
417
|
+
const RULESYNC_CURATED_SKILLS_RELATIVE_DIR_PATH = join$386(RULESYNC_RELATIVE_DIR_PATH, CURATED_SKILLS_FEATURE_SUBDIR);
|
|
418
418
|
const RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH = "rulesync.lock";
|
|
419
419
|
const RULESYNC_NPM_SOURCES_LOCK_RELATIVE_FILE_PATH = "rulesync-npm.lock.json";
|
|
420
420
|
const RULESYNC_MCP_FILE_NAME = "mcp.jsonc";
|
|
@@ -3291,6 +3291,8 @@ const ConfigParamsSchema = zod_mini.z.object({
|
|
|
3291
3291
|
simulateSubagents: (0, zod_mini.optional)(zod_mini.z.boolean()),
|
|
3292
3292
|
simulateSkills: (0, zod_mini.optional)(zod_mini.z.boolean()),
|
|
3293
3293
|
preserveUnownedHooks: (0, zod_mini.optional)(zod_mini.z.boolean()),
|
|
3294
|
+
preserveUnmanagedRuleContent: (0, zod_mini.optional)(zod_mini.z.boolean()),
|
|
3295
|
+
preserveUnownedSkills: (0, zod_mini.optional)(zod_mini.z.boolean()),
|
|
3294
3296
|
deriveSubprojectPathFromGlobs: (0, zod_mini.optional)(zod_mini.z.boolean()),
|
|
3295
3297
|
flattenedCommandNaming: (0, zod_mini.optional)(FlattenedCommandNamingSchema),
|
|
3296
3298
|
/**
|
|
@@ -3473,6 +3475,8 @@ var Config = class Config {
|
|
|
3473
3475
|
simulateSubagents;
|
|
3474
3476
|
simulateSkills;
|
|
3475
3477
|
preserveUnownedHooks;
|
|
3478
|
+
preserveUnmanagedRuleContent;
|
|
3479
|
+
preserveUnownedSkills;
|
|
3476
3480
|
deriveSubprojectPathFromGlobs;
|
|
3477
3481
|
flattenedCommandNaming;
|
|
3478
3482
|
language;
|
|
@@ -3501,7 +3505,7 @@ var Config = class Config {
|
|
|
3501
3505
|
inputRoots;
|
|
3502
3506
|
configFilePath;
|
|
3503
3507
|
sources;
|
|
3504
|
-
constructor({ outputRoots, targets, features, verbose, delete: isDelete, global, silent, simulateCommands, simulateSubagents, simulateSkills, preserveUnownedHooks, deriveSubprojectPathFromGlobs, flattenedCommandNaming, language, gitignoreTargetsOnly, gitignoreDestination, dryRun, check, retireTargets, retireFeatures, inputRoot, inputRoots, configFilePath, sources, configFileTargets, configFileSelection }) {
|
|
3508
|
+
constructor({ outputRoots, targets, features, verbose, delete: isDelete, global, silent, simulateCommands, simulateSubagents, simulateSkills, preserveUnownedHooks, preserveUnmanagedRuleContent, preserveUnownedSkills, deriveSubprojectPathFromGlobs, flattenedCommandNaming, language, gitignoreTargetsOnly, gitignoreDestination, dryRun, check, retireTargets, retireFeatures, inputRoot, inputRoots, configFilePath, sources, configFileTargets, configFileSelection }) {
|
|
3505
3509
|
assertTargetsFeaturesExclusive({
|
|
3506
3510
|
targets,
|
|
3507
3511
|
features
|
|
@@ -3535,6 +3539,8 @@ var Config = class Config {
|
|
|
3535
3539
|
this.simulateSubagents = simulateSubagents ?? false;
|
|
3536
3540
|
this.simulateSkills = simulateSkills ?? false;
|
|
3537
3541
|
this.preserveUnownedHooks = preserveUnownedHooks ?? false;
|
|
3542
|
+
this.preserveUnmanagedRuleContent = preserveUnmanagedRuleContent === true;
|
|
3543
|
+
this.preserveUnownedSkills = preserveUnownedSkills === true;
|
|
3538
3544
|
this.deriveSubprojectPathFromGlobs = deriveSubprojectPathFromGlobs ?? false;
|
|
3539
3545
|
this.flattenedCommandNaming = flattenedCommandNaming ?? "basename";
|
|
3540
3546
|
this.language = language;
|
|
@@ -3795,6 +3801,12 @@ var Config = class Config {
|
|
|
3795
3801
|
getPreserveUnownedHooks() {
|
|
3796
3802
|
return this.preserveUnownedHooks;
|
|
3797
3803
|
}
|
|
3804
|
+
getPreserveUnmanagedRuleContent() {
|
|
3805
|
+
return this.preserveUnmanagedRuleContent;
|
|
3806
|
+
}
|
|
3807
|
+
getPreserveUnownedSkills() {
|
|
3808
|
+
return this.preserveUnownedSkills;
|
|
3809
|
+
}
|
|
3798
3810
|
getFlattenedCommandNaming() {
|
|
3799
3811
|
return this.flattenedCommandNaming;
|
|
3800
3812
|
}
|
|
@@ -3860,6 +3872,24 @@ var Config = class Config {
|
|
|
3860
3872
|
return this.dryRun || this.check;
|
|
3861
3873
|
}
|
|
3862
3874
|
};
|
|
3875
|
+
/**
|
|
3876
|
+
* The `rules` options for `target` in a run, with the `include` rule selection
|
|
3877
|
+
* always read from the configuration file. `--targets` replaces the object
|
|
3878
|
+
* form of `targets`, and with it every per-target option, but a target that
|
|
3879
|
+
* selects its rules there must not receive every rule just because it was
|
|
3880
|
+
* picked with `--targets`: that would write the rules the user deliberately
|
|
3881
|
+
* kept away from it.
|
|
3882
|
+
*/
|
|
3883
|
+
function getRulesFeatureOptions(config, target) {
|
|
3884
|
+
const options = config.getFeatureOptions(target, "rules");
|
|
3885
|
+
if (options !== void 0 && "include" in options) return options;
|
|
3886
|
+
const configFileOptions = config.getConfigFileFeatureOptions(target, "rules");
|
|
3887
|
+
if (configFileOptions === void 0 || !("include" in configFileOptions)) return options;
|
|
3888
|
+
return {
|
|
3889
|
+
...options,
|
|
3890
|
+
include: configFileOptions.include
|
|
3891
|
+
};
|
|
3892
|
+
}
|
|
3863
3893
|
// src/config/config-resolver.ts
|
|
3864
3894
|
const getDefaults = () => ({
|
|
3865
3895
|
targets: ["agentsmd"],
|
|
@@ -3874,6 +3904,8 @@ const getDefaults = () => ({
|
|
|
3874
3904
|
simulateSubagents: false,
|
|
3875
3905
|
simulateSkills: false,
|
|
3876
3906
|
preserveUnownedHooks: false,
|
|
3907
|
+
preserveUnmanagedRuleContent: false,
|
|
3908
|
+
preserveUnownedSkills: false,
|
|
3877
3909
|
deriveSubprojectPathFromGlobs: false,
|
|
3878
3910
|
flattenedCommandNaming: "basename",
|
|
3879
3911
|
gitignoreTargetsOnly: true,
|
|
@@ -4212,6 +4244,16 @@ var ConfigResolver = class {
|
|
|
4212
4244
|
file: configByFile.preserveUnownedHooks,
|
|
4213
4245
|
fallback: getDefaults().preserveUnownedHooks
|
|
4214
4246
|
}),
|
|
4247
|
+
preserveUnmanagedRuleContent: pick({
|
|
4248
|
+
cli: void 0,
|
|
4249
|
+
file: configByFile.preserveUnmanagedRuleContent,
|
|
4250
|
+
fallback: getDefaults().preserveUnmanagedRuleContent
|
|
4251
|
+
}),
|
|
4252
|
+
preserveUnownedSkills: pick({
|
|
4253
|
+
cli: void 0,
|
|
4254
|
+
file: configByFile.preserveUnownedSkills,
|
|
4255
|
+
fallback: getDefaults().preserveUnownedSkills
|
|
4256
|
+
}),
|
|
4215
4257
|
deriveSubprojectPathFromGlobs: pick({
|
|
4216
4258
|
cli: deriveSubprojectPathFromGlobs,
|
|
4217
4259
|
file: configByFile.deriveSubprojectPathFromGlobs,
|
|
@@ -4453,6 +4495,33 @@ var AiFile = class {
|
|
|
4453
4495
|
return false;
|
|
4454
4496
|
}
|
|
4455
4497
|
/**
|
|
4498
|
+
* The content the write phase puts on disk, given what the file holds now
|
|
4499
|
+
* (`null` when it does not exist) and the generated content (already ending
|
|
4500
|
+
* in a newline). Defaults to the generated content; override for a file
|
|
4501
|
+
* that keeps part of the existing content, such as a root rule file under
|
|
4502
|
+
* `preserveUnmanagedRuleContent`. `generate --check` compares the same
|
|
4503
|
+
* composed content, so content kept this way is never reported as drift.
|
|
4504
|
+
*/
|
|
4505
|
+
composeWrittenContent({ generatedContent }) {
|
|
4506
|
+
return generatedContent;
|
|
4507
|
+
}
|
|
4508
|
+
/**
|
|
4509
|
+
* Whether removing this file (the `--delete` sweep, `retireTargets`) has to
|
|
4510
|
+
* look at what it holds first, through {@link composeContentAfterRemoval}.
|
|
4511
|
+
*/
|
|
4512
|
+
keepsContentOnRemoval() {
|
|
4513
|
+
return false;
|
|
4514
|
+
}
|
|
4515
|
+
/**
|
|
4516
|
+
* How removing this file treats what it holds: `delete` it as a whole (the
|
|
4517
|
+
* default), `rewrite` it with rulesync's own content taken out, or `keep` it
|
|
4518
|
+
* untouched because none of it is rulesync's any more. Only consulted when
|
|
4519
|
+
* {@link keepsContentOnRemoval} is true.
|
|
4520
|
+
*/
|
|
4521
|
+
composeContentAfterRemoval(_params) {
|
|
4522
|
+
return { action: "delete" };
|
|
4523
|
+
}
|
|
4524
|
+
/**
|
|
4456
4525
|
* POSIX mode to apply after writing, or `undefined` to leave the default
|
|
4457
4526
|
* alone. Override in subclasses whose output the tool executes directly
|
|
4458
4527
|
* (e.g. Cline's hook scripts, which are spawned by path and therefore need
|
|
@@ -12361,6 +12430,1125 @@ function classifyRemoteName(name) {
|
|
|
12361
12430
|
};
|
|
12362
12431
|
return { kind: "safe" };
|
|
12363
12432
|
}
|
|
12433
|
+
// src/types/git-provider.ts
|
|
12434
|
+
/**
|
|
12435
|
+
* Supported Git providers for fetch command
|
|
12436
|
+
*/
|
|
12437
|
+
const ALL_GIT_PROVIDERS = ["github", "gitlab"];
|
|
12438
|
+
zod_mini.z.enum(ALL_GIT_PROVIDERS);
|
|
12439
|
+
// src/lib/source-parser.ts
|
|
12440
|
+
const GITHUB_HOSTS = /* @__PURE__ */ new Set(["github.com", "www.github.com"]);
|
|
12441
|
+
const GITLAB_HOSTS = /* @__PURE__ */ new Set(["gitlab.com", "www.gitlab.com"]);
|
|
12442
|
+
/**
|
|
12443
|
+
* Parse source specification into components
|
|
12444
|
+
* Supports:
|
|
12445
|
+
* - URL format: https://github.com/owner/repo, https://gitlab.com/owner/repo
|
|
12446
|
+
* - Prefix format: github:owner/repo, gitlab:owner/repo
|
|
12447
|
+
* - Shorthand format: owner/repo (defaults to GitHub)
|
|
12448
|
+
* - With ref: owner/repo@ref
|
|
12449
|
+
* - With path: owner/repo:path
|
|
12450
|
+
* - Combined: owner/repo@ref:path
|
|
12451
|
+
*/
|
|
12452
|
+
function parseSource(source) {
|
|
12453
|
+
if (source.startsWith("http://") || source.startsWith("https://")) return parseUrl(source);
|
|
12454
|
+
if (source.includes(":") && !source.includes("://")) {
|
|
12455
|
+
const colonIndex = source.indexOf(":");
|
|
12456
|
+
const prefix = source.substring(0, colonIndex);
|
|
12457
|
+
const rest = source.substring(colonIndex + 1);
|
|
12458
|
+
const provider = ALL_GIT_PROVIDERS.find((p) => p === prefix);
|
|
12459
|
+
if (provider) return {
|
|
12460
|
+
provider,
|
|
12461
|
+
...parseShorthand(rest)
|
|
12462
|
+
};
|
|
12463
|
+
return {
|
|
12464
|
+
provider: "github",
|
|
12465
|
+
...parseShorthand(source)
|
|
12466
|
+
};
|
|
12467
|
+
}
|
|
12468
|
+
return {
|
|
12469
|
+
provider: "github",
|
|
12470
|
+
...parseShorthand(source)
|
|
12471
|
+
};
|
|
12472
|
+
}
|
|
12473
|
+
/**
|
|
12474
|
+
* Parse URL format into components
|
|
12475
|
+
*/
|
|
12476
|
+
function parseUrl(url) {
|
|
12477
|
+
const urlObj = new URL(url);
|
|
12478
|
+
const host = urlObj.hostname.toLowerCase();
|
|
12479
|
+
let provider;
|
|
12480
|
+
if (GITHUB_HOSTS.has(host)) provider = "github";
|
|
12481
|
+
else if (GITLAB_HOSTS.has(host)) provider = "gitlab";
|
|
12482
|
+
else throw new Error(`Unknown Git provider for host: ${host}. Supported providers: ${ALL_GIT_PROVIDERS.join(", ")}`);
|
|
12483
|
+
const segments = urlObj.pathname.split("/").filter(Boolean);
|
|
12484
|
+
if (segments.length < 2) throw new Error(`Invalid ${provider} URL: ${url}. Expected format: https://${host}/owner/repo`);
|
|
12485
|
+
const owner = segments[0];
|
|
12486
|
+
const repo = segments[1]?.replace(/\.git$/, "");
|
|
12487
|
+
if (segments.length > 2 && (segments[2] === "tree" || segments[2] === "blob")) {
|
|
12488
|
+
const decode = (segment) => decodeUrlSegment({
|
|
12489
|
+
segment,
|
|
12490
|
+
provider,
|
|
12491
|
+
url
|
|
12492
|
+
});
|
|
12493
|
+
const ref = segments[3] === void 0 ? void 0 : decode(segments[3]);
|
|
12494
|
+
const path = segments.length > 4 ? decode(segments.slice(4).join("/")) : void 0;
|
|
12495
|
+
if (path !== void 0 && path.split(/[\\/]/).includes("..")) throw new Error(`Invalid ${provider} URL: ${url}. Path must not contain ".." segments.`);
|
|
12496
|
+
return {
|
|
12497
|
+
provider,
|
|
12498
|
+
owner: owner ?? "",
|
|
12499
|
+
repo: repo ?? "",
|
|
12500
|
+
ref,
|
|
12501
|
+
path
|
|
12502
|
+
};
|
|
12503
|
+
}
|
|
12504
|
+
return {
|
|
12505
|
+
provider,
|
|
12506
|
+
owner: owner ?? "",
|
|
12507
|
+
repo: repo ?? ""
|
|
12508
|
+
};
|
|
12509
|
+
}
|
|
12510
|
+
/**
|
|
12511
|
+
* Percent-decode a URL path segment, turning a malformed escape (e.g. a lone
|
|
12512
|
+
* `%`) into an error that names the offending source.
|
|
12513
|
+
*/
|
|
12514
|
+
function decodeUrlSegment({ segment, provider, url }) {
|
|
12515
|
+
try {
|
|
12516
|
+
return decodeURIComponent(segment);
|
|
12517
|
+
} catch (error) {
|
|
12518
|
+
if (error instanceof URIError) throw new Error(`Invalid ${provider} URL: ${url}. Malformed percent-encoding in ref or path.`, { cause: error });
|
|
12519
|
+
throw error;
|
|
12520
|
+
}
|
|
12521
|
+
}
|
|
12522
|
+
/**
|
|
12523
|
+
* Parse shorthand format (without provider prefix)
|
|
12524
|
+
*/
|
|
12525
|
+
function parseShorthand(source) {
|
|
12526
|
+
let remaining = source;
|
|
12527
|
+
let path;
|
|
12528
|
+
let ref;
|
|
12529
|
+
const colonIndex = remaining.indexOf(":");
|
|
12530
|
+
if (colonIndex !== -1) {
|
|
12531
|
+
path = remaining.substring(colonIndex + 1);
|
|
12532
|
+
if (!path) throw new Error(`Invalid source: ${source}. Path cannot be empty after ":".`);
|
|
12533
|
+
remaining = remaining.substring(0, colonIndex);
|
|
12534
|
+
}
|
|
12535
|
+
const atIndex = remaining.indexOf("@");
|
|
12536
|
+
if (atIndex !== -1) {
|
|
12537
|
+
ref = remaining.substring(atIndex + 1);
|
|
12538
|
+
if (!ref) throw new Error(`Invalid source: ${source}. Ref cannot be empty after "@".`);
|
|
12539
|
+
remaining = remaining.substring(0, atIndex);
|
|
12540
|
+
}
|
|
12541
|
+
const slashIndex = remaining.indexOf("/");
|
|
12542
|
+
if (slashIndex === -1) throw new Error(`Invalid source: ${source}. Expected format: owner/repo, owner/repo@ref, or owner/repo:path`);
|
|
12543
|
+
const owner = remaining.substring(0, slashIndex);
|
|
12544
|
+
const repo = remaining.substring(slashIndex + 1);
|
|
12545
|
+
if (!owner || !repo) throw new Error(`Invalid source: ${source}. Both owner and repo are required.`);
|
|
12546
|
+
return {
|
|
12547
|
+
owner,
|
|
12548
|
+
repo,
|
|
12549
|
+
ref,
|
|
12550
|
+
path
|
|
12551
|
+
};
|
|
12552
|
+
}
|
|
12553
|
+
/**
|
|
12554
|
+
* Schema for a single locked skill entry with content integrity.
|
|
12555
|
+
*/
|
|
12556
|
+
const LockedSkillSchema = zod_mini.z.object({ integrity: zod_mini.z.string() });
|
|
12557
|
+
/** Schema for a single locked rule entry with content integrity. */
|
|
12558
|
+
const LockedRuleSchema = zod_mini.z.object({ integrity: zod_mini.z.string() });
|
|
12559
|
+
/**
|
|
12560
|
+
* Schema for a single locked source entry.
|
|
12561
|
+
*/
|
|
12562
|
+
const LockedSourceSchema = zod_mini.z.object({
|
|
12563
|
+
requestedRef: (0, zod_mini.optional)(zod_mini.z.string()),
|
|
12564
|
+
resolvedRef: zod_mini.z.string().check((0, zod_mini.refine)((v) => /^[0-9a-f]{40}$/.test(v), "resolvedRef must be a 40-character hex SHA")),
|
|
12565
|
+
resolvedAt: (0, zod_mini.optional)(zod_mini.z.string()),
|
|
12566
|
+
skills: zod_mini.z.record(zod_mini.z.string(), LockedSkillSchema),
|
|
12567
|
+
/**
|
|
12568
|
+
* The normalized `skills` selection the entry was written for. Absent from
|
|
12569
|
+
* lockfiles written before the selection was recorded.
|
|
12570
|
+
*/
|
|
12571
|
+
skillSelection: (0, zod_mini.optional)(zod_mini.z.array(zod_mini.z.string())),
|
|
12572
|
+
/**
|
|
12573
|
+
* The normalized path the skills were read from in the source. Absent from
|
|
12574
|
+
* lockfiles written before the path was recorded.
|
|
12575
|
+
*/
|
|
12576
|
+
skillsPath: (0, zod_mini.optional)(zod_mini.z.string()),
|
|
12577
|
+
rules: (0, zod_mini.optional)(zod_mini.z.record(zod_mini.z.string(), LockedRuleSchema)),
|
|
12578
|
+
ruleSelection: (0, zod_mini.optional)(zod_mini.z.array(zod_mini.z.string())),
|
|
12579
|
+
rulesPath: (0, zod_mini.optional)(zod_mini.z.string()),
|
|
12580
|
+
resolvedRuleNames: (0, zod_mini.optional)(zod_mini.z.array(zod_mini.z.string())),
|
|
12581
|
+
commands: (0, zod_mini.optional)(zod_mini.z.record(zod_mini.z.string(), LockedRuleSchema)),
|
|
12582
|
+
commandSelection: (0, zod_mini.optional)(zod_mini.z.array(zod_mini.z.string())),
|
|
12583
|
+
commandsPath: (0, zod_mini.optional)(zod_mini.z.string()),
|
|
12584
|
+
resolvedCommandNames: (0, zod_mini.optional)(zod_mini.z.array(zod_mini.z.string())),
|
|
12585
|
+
subagents: (0, zod_mini.optional)(zod_mini.z.record(zod_mini.z.string(), LockedRuleSchema)),
|
|
12586
|
+
subagentSelection: (0, zod_mini.optional)(zod_mini.z.array(zod_mini.z.string())),
|
|
12587
|
+
subagentsPath: (0, zod_mini.optional)(zod_mini.z.string()),
|
|
12588
|
+
resolvedSubagentNames: (0, zod_mini.optional)(zod_mini.z.array(zod_mini.z.string()))
|
|
12589
|
+
});
|
|
12590
|
+
/**
|
|
12591
|
+
* Schema for the full lockfile (current version).
|
|
12592
|
+
*/
|
|
12593
|
+
const SourcesLockSchema = zod_mini.z.object({
|
|
12594
|
+
lockfileVersion: zod_mini.z.number(),
|
|
12595
|
+
sources: zod_mini.z.record(zod_mini.z.string(), LockedSourceSchema)
|
|
12596
|
+
});
|
|
12597
|
+
/**
|
|
12598
|
+
* Schema for the legacy v0 lockfile format (skills as string array, no version field).
|
|
12599
|
+
*/
|
|
12600
|
+
const LegacyLockedSourceSchema = zod_mini.z.object({
|
|
12601
|
+
resolvedRef: zod_mini.z.string(),
|
|
12602
|
+
skills: zod_mini.z.array(zod_mini.z.string())
|
|
12603
|
+
});
|
|
12604
|
+
const LegacySourcesLockSchema = zod_mini.z.object({ sources: zod_mini.z.record(zod_mini.z.string(), LegacyLockedSourceSchema) });
|
|
12605
|
+
/**
|
|
12606
|
+
* Migrate a legacy lockfile (string[] skills, no version) to the current format.
|
|
12607
|
+
* Skills get empty integrity since we can't compute it retroactively.
|
|
12608
|
+
*/
|
|
12609
|
+
function migrateLegacyLock(params) {
|
|
12610
|
+
const { legacy, logger } = params;
|
|
12611
|
+
const sources = {};
|
|
12612
|
+
for (const [key, entry] of Object.entries(legacy.sources)) {
|
|
12613
|
+
const skills = {};
|
|
12614
|
+
for (const name of entry.skills) skills[name] = { integrity: "" };
|
|
12615
|
+
sources[key] = {
|
|
12616
|
+
resolvedRef: entry.resolvedRef,
|
|
12617
|
+
skills
|
|
12618
|
+
};
|
|
12619
|
+
}
|
|
12620
|
+
logger.info("Migrated legacy sources lockfile to version 1. Run 'rulesync install --update' to populate integrity hashes.");
|
|
12621
|
+
return {
|
|
12622
|
+
lockfileVersion: 1,
|
|
12623
|
+
sources
|
|
12624
|
+
};
|
|
12625
|
+
}
|
|
12626
|
+
/**
|
|
12627
|
+
* Create an empty lockfile structure.
|
|
12628
|
+
*/
|
|
12629
|
+
function createEmptyLock() {
|
|
12630
|
+
return {
|
|
12631
|
+
lockfileVersion: 1,
|
|
12632
|
+
sources: {}
|
|
12633
|
+
};
|
|
12634
|
+
}
|
|
12635
|
+
/**
|
|
12636
|
+
* Read the lockfile from disk.
|
|
12637
|
+
* @returns The parsed lockfile, or an empty lockfile if it doesn't exist or is invalid.
|
|
12638
|
+
*/
|
|
12639
|
+
async function readLockFile(params) {
|
|
12640
|
+
const { logger } = params;
|
|
12641
|
+
const lockPath = (0, node_path.join)(params.projectRoot, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH);
|
|
12642
|
+
if (!await fileExists(lockPath)) {
|
|
12643
|
+
logger.debug("No sources lockfile found, starting fresh.");
|
|
12644
|
+
return createEmptyLock();
|
|
12645
|
+
}
|
|
12646
|
+
try {
|
|
12647
|
+
const content = await readFileContent(lockPath);
|
|
12648
|
+
const data = JSON.parse(content);
|
|
12649
|
+
const result = SourcesLockSchema.safeParse(data);
|
|
12650
|
+
if (result.success) return result.data;
|
|
12651
|
+
const legacyResult = LegacySourcesLockSchema.safeParse(data);
|
|
12652
|
+
if (legacyResult.success) return migrateLegacyLock({
|
|
12653
|
+
legacy: legacyResult.data,
|
|
12654
|
+
logger
|
|
12655
|
+
});
|
|
12656
|
+
logger.warn(`Invalid sources lockfile format (${RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH}). Starting fresh.`);
|
|
12657
|
+
return createEmptyLock();
|
|
12658
|
+
} catch {
|
|
12659
|
+
logger.warn(`Failed to read sources lockfile (${RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH}). Starting fresh.`);
|
|
12660
|
+
return createEmptyLock();
|
|
12661
|
+
}
|
|
12662
|
+
}
|
|
12663
|
+
/**
|
|
12664
|
+
* Write the lockfile to disk.
|
|
12665
|
+
*/
|
|
12666
|
+
async function writeLockFile(params) {
|
|
12667
|
+
const { logger } = params;
|
|
12668
|
+
const lockPath = (0, node_path.join)(params.projectRoot, RULESYNC_SOURCES_LOCK_RELATIVE_FILE_PATH);
|
|
12669
|
+
await writeFileContent(lockPath, JSON.stringify(params.lock, null, 2) + "\n");
|
|
12670
|
+
logger.debug(`Wrote sources lockfile to ${lockPath}`);
|
|
12671
|
+
}
|
|
12672
|
+
/**
|
|
12673
|
+
* Compute a SHA-256 integrity hash for a skill's contents.
|
|
12674
|
+
* Takes a sorted list of [relativePath, content] pairs to produce a deterministic hash.
|
|
12675
|
+
*/
|
|
12676
|
+
function computeSkillIntegrity(files) {
|
|
12677
|
+
const hash = (0, node_crypto.createHash)("sha256");
|
|
12678
|
+
const sorted = files.toSorted((a, b) => a.path.localeCompare(b.path));
|
|
12679
|
+
for (const file of sorted) {
|
|
12680
|
+
hash.update(file.path);
|
|
12681
|
+
hash.update("\0");
|
|
12682
|
+
hash.update(file.content);
|
|
12683
|
+
hash.update("\0");
|
|
12684
|
+
}
|
|
12685
|
+
return `sha256-${hash.digest("hex")}`;
|
|
12686
|
+
}
|
|
12687
|
+
/** Compute a SHA-256 integrity hash for one rule file. */
|
|
12688
|
+
function computeRuleIntegrity(content) {
|
|
12689
|
+
const hash = (0, node_crypto.createHash)("sha256");
|
|
12690
|
+
hash.update(content);
|
|
12691
|
+
return `sha256-${hash.digest("hex")}`;
|
|
12692
|
+
}
|
|
12693
|
+
/**
|
|
12694
|
+
* Normalize a source key for consistent lockfile lookups.
|
|
12695
|
+
* Strips URL prefixes, provider prefixes, trailing slashes, .git suffix, and lowercases.
|
|
12696
|
+
*/
|
|
12697
|
+
function normalizeSourceKey(source) {
|
|
12698
|
+
let key = source;
|
|
12699
|
+
for (const prefix of [
|
|
12700
|
+
"https://www.github.com/",
|
|
12701
|
+
"https://github.com/",
|
|
12702
|
+
"http://www.github.com/",
|
|
12703
|
+
"http://github.com/",
|
|
12704
|
+
"https://www.gitlab.com/",
|
|
12705
|
+
"https://gitlab.com/",
|
|
12706
|
+
"http://www.gitlab.com/",
|
|
12707
|
+
"http://gitlab.com/"
|
|
12708
|
+
]) if (key.toLowerCase().startsWith(prefix)) {
|
|
12709
|
+
key = key.substring(prefix.length);
|
|
12710
|
+
break;
|
|
12711
|
+
}
|
|
12712
|
+
for (const provider of ["github:", "gitlab:"]) if (key.startsWith(provider)) {
|
|
12713
|
+
key = key.substring(provider.length);
|
|
12714
|
+
break;
|
|
12715
|
+
}
|
|
12716
|
+
key = key.replace(/\/+$/, "");
|
|
12717
|
+
key = key.replace(/\.git$/, "");
|
|
12718
|
+
key = key.toLowerCase();
|
|
12719
|
+
return key;
|
|
12720
|
+
}
|
|
12721
|
+
/**
|
|
12722
|
+
* Separates the repository part of a lock key from the qualifier that tells
|
|
12723
|
+
* apart several declared entries of the same repository.
|
|
12724
|
+
*/
|
|
12725
|
+
const LOCK_KEY_QUALIFIER_SEPARATOR = "#";
|
|
12726
|
+
/**
|
|
12727
|
+
* Normalize a lock key for comparison. The repository part is normalized with
|
|
12728
|
+
* {@link normalizeSourceKey}; a qualifier (see {@link resolveSourceLockKeys})
|
|
12729
|
+
* is kept verbatim, since paths and refs are case-sensitive. A key without a
|
|
12730
|
+
* qualifier normalizes exactly as before qualifiers existed.
|
|
12731
|
+
*/
|
|
12732
|
+
function normalizeLockKey(key) {
|
|
12733
|
+
const separatorIndex = key.indexOf(LOCK_KEY_QUALIFIER_SEPARATOR);
|
|
12734
|
+
if (separatorIndex === -1) return normalizeSourceKey(key);
|
|
12735
|
+
return normalizeSourceKey(key.slice(0, separatorIndex)) + key.slice(separatorIndex);
|
|
12736
|
+
}
|
|
12737
|
+
/** The normalized repository part of a lock key, without its qualifier. */
|
|
12738
|
+
function getLockKeyRepository(key) {
|
|
12739
|
+
const separatorIndex = key.indexOf(LOCK_KEY_QUALIFIER_SEPARATOR);
|
|
12740
|
+
return normalizeSourceKey(separatorIndex === -1 ? key : key.slice(0, separatorIndex));
|
|
12741
|
+
}
|
|
12742
|
+
function encodeLockKeyQualifierValue(value) {
|
|
12743
|
+
return encodeURIComponent(value).replace(/%2F/gi, "/");
|
|
12744
|
+
}
|
|
12745
|
+
function normalizeLockKeyDirPath(dirPath) {
|
|
12746
|
+
return normalizePosixDirPath(dirPath);
|
|
12747
|
+
}
|
|
12748
|
+
/**
|
|
12749
|
+
* The location fields of a declared entry that tell it apart from other
|
|
12750
|
+
* entries of the same repository, as a lock key qualifier (empty when the
|
|
12751
|
+
* entry declares none of them).
|
|
12752
|
+
*/
|
|
12753
|
+
function buildLockKeyQualifier(sourceEntry) {
|
|
12754
|
+
const parts = [];
|
|
12755
|
+
if (sourceEntry.path !== void 0) parts.push(`path=${encodeLockKeyQualifierValue(normalizeLockKeyDirPath(sourceEntry.path))}`);
|
|
12756
|
+
for (const field of [
|
|
12757
|
+
"rulesPath",
|
|
12758
|
+
"commandsPath",
|
|
12759
|
+
"subagentsPath"
|
|
12760
|
+
]) {
|
|
12761
|
+
const dirPath = sourceEntry[field];
|
|
12762
|
+
if (dirPath !== void 0) parts.push(`${field}=${encodeLockKeyQualifierValue(normalizeLockKeyDirPath(dirPath))}`);
|
|
12763
|
+
}
|
|
12764
|
+
if (sourceEntry.ref !== void 0) parts.push(`ref=${encodeLockKeyQualifierValue(sourceEntry.ref)}`);
|
|
12765
|
+
return parts.join("&");
|
|
12766
|
+
}
|
|
12767
|
+
/**
|
|
12768
|
+
* The key each declared source's lock entry is stored under, index-aligned
|
|
12769
|
+
* with `sources`.
|
|
12770
|
+
*
|
|
12771
|
+
* A repository declared once keeps the bare {@link normalizeSourceKey} key,
|
|
12772
|
+
* so lockfiles written before multiple entries per repository were supported
|
|
12773
|
+
* stay valid unchanged. Only when several git/GitHub entries normalize to the
|
|
12774
|
+
* same repository does each of them get a qualified key
|
|
12775
|
+
* (`owner/repo#path=plugins/team-a/skills&ref=main`) built from its `path`,
|
|
12776
|
+
* `rulesPath`, `commandsPath`, `subagentsPath` and `ref`, so each entry keeps its own lock entry, its own
|
|
12777
|
+
* curated-artifact cleanup and its own `--frozen` check. An entry declaring
|
|
12778
|
+
* none of those fields keeps the bare key, and entries declaring the same
|
|
12779
|
+
* location are told apart by their order (`entry=2`, `entry=3`, ...).
|
|
12780
|
+
*
|
|
12781
|
+
* npm-transport sources are locked in a separate lockfile by package name;
|
|
12782
|
+
* their key here is unused and left bare.
|
|
12783
|
+
*/
|
|
12784
|
+
function resolveSourceLockKeys(sources) {
|
|
12785
|
+
const bareKeys = sources.map((sourceEntry) => normalizeSourceKey(sourceEntry.source));
|
|
12786
|
+
const repositoryCounts = /* @__PURE__ */ new Map();
|
|
12787
|
+
sources.forEach((sourceEntry, index) => {
|
|
12788
|
+
if (getSourceTransport(sourceEntry) === "npm") return;
|
|
12789
|
+
const bareKey = bareKeys[index] ?? "";
|
|
12790
|
+
repositoryCounts.set(bareKey, (repositoryCounts.get(bareKey) ?? 0) + 1);
|
|
12791
|
+
});
|
|
12792
|
+
const qualifierCounts = /* @__PURE__ */ new Map();
|
|
12793
|
+
return sources.map((sourceEntry, index) => {
|
|
12794
|
+
const bareKey = bareKeys[index] ?? "";
|
|
12795
|
+
if (getSourceTransport(sourceEntry) === "npm" || (repositoryCounts.get(bareKey) ?? 0) < 2) return bareKey;
|
|
12796
|
+
const qualifier = buildLockKeyQualifier(sourceEntry);
|
|
12797
|
+
const base = qualifier === "" ? bareKey : `${bareKey}${LOCK_KEY_QUALIFIER_SEPARATOR}${qualifier}`;
|
|
12798
|
+
const occurrence = (qualifierCounts.get(base) ?? 0) + 1;
|
|
12799
|
+
qualifierCounts.set(base, occurrence);
|
|
12800
|
+
if (occurrence === 1) return base;
|
|
12801
|
+
return `${base}${qualifier === "" ? LOCK_KEY_QUALIFIER_SEPARATOR : "&"}entry=${occurrence}`;
|
|
12802
|
+
});
|
|
12803
|
+
}
|
|
12804
|
+
/**
|
|
12805
|
+
* Move a lock entry to another key, keeping its position-independent content
|
|
12806
|
+
* unchanged (immutable — returns a fresh lock object).
|
|
12807
|
+
*/
|
|
12808
|
+
function renameLockedSource(params) {
|
|
12809
|
+
const { lock, fromKey, toKey } = params;
|
|
12810
|
+
const entry = getLockedSource(lock, fromKey);
|
|
12811
|
+
if (entry === void 0) return lock;
|
|
12812
|
+
const normalizedFrom = normalizeLockKey(fromKey);
|
|
12813
|
+
const remaining = {};
|
|
12814
|
+
for (const [key, value] of Object.entries(lock.sources)) if (normalizeLockKey(key) !== normalizedFrom) remaining[key] = value;
|
|
12815
|
+
return setLockedSource({
|
|
12816
|
+
lockfileVersion: lock.lockfileVersion,
|
|
12817
|
+
sources: remaining
|
|
12818
|
+
}, toKey, entry);
|
|
12819
|
+
}
|
|
12820
|
+
/**
|
|
12821
|
+
* Get the locked entry for a lock key (see {@link resolveSourceLockKeys}),
|
|
12822
|
+
* if it exists.
|
|
12823
|
+
*/
|
|
12824
|
+
function getLockedSource(lock, lockKey) {
|
|
12825
|
+
const normalized = normalizeLockKey(lockKey);
|
|
12826
|
+
for (const [key, value] of Object.entries(lock.sources)) if (normalizeLockKey(key) === normalized) return value;
|
|
12827
|
+
}
|
|
12828
|
+
/**
|
|
12829
|
+
* Set (or update) a locked entry for a lock key.
|
|
12830
|
+
*/
|
|
12831
|
+
function setLockedSource(lock, lockKey, entry) {
|
|
12832
|
+
const normalized = normalizeLockKey(lockKey);
|
|
12833
|
+
const filteredSources = {};
|
|
12834
|
+
for (const [key, value] of Object.entries(lock.sources)) if (normalizeLockKey(key) !== normalized) filteredSources[key] = value;
|
|
12835
|
+
return {
|
|
12836
|
+
lockfileVersion: lock.lockfileVersion,
|
|
12837
|
+
sources: {
|
|
12838
|
+
...filteredSources,
|
|
12839
|
+
[normalized]: entry
|
|
12840
|
+
}
|
|
12841
|
+
};
|
|
12842
|
+
}
|
|
12843
|
+
/**
|
|
12844
|
+
* Get the skill names from a locked source entry.
|
|
12845
|
+
*/
|
|
12846
|
+
function getLockedSkillNames(entry) {
|
|
12847
|
+
return Object.keys(entry.skills);
|
|
12848
|
+
}
|
|
12849
|
+
/**
|
|
12850
|
+
* The features a source installs as one Markdown file per item, each locked
|
|
12851
|
+
* with the same four fields (`rules` / `ruleSelection` / `rulesPath` /
|
|
12852
|
+
* `resolvedRuleNames`, and the command and subagent counterparts).
|
|
12853
|
+
*/
|
|
12854
|
+
const SOURCE_FILE_FEATURES = [
|
|
12855
|
+
"rules",
|
|
12856
|
+
"commands",
|
|
12857
|
+
"subagents"
|
|
12858
|
+
];
|
|
12859
|
+
/** Build a value for each per-file feature. */
|
|
12860
|
+
function mapFileFeatures(map) {
|
|
12861
|
+
return {
|
|
12862
|
+
rules: map("rules"),
|
|
12863
|
+
commands: map("commands"),
|
|
12864
|
+
subagents: map("subagents")
|
|
12865
|
+
};
|
|
12866
|
+
}
|
|
12867
|
+
/** Read one per-file feature's lock fields from a lock entry. */
|
|
12868
|
+
function getLockedFileFeatureState(entry, feature) {
|
|
12869
|
+
switch (feature) {
|
|
12870
|
+
case "rules": return {
|
|
12871
|
+
items: entry.rules,
|
|
12872
|
+
selection: entry.ruleSelection,
|
|
12873
|
+
path: entry.rulesPath,
|
|
12874
|
+
resolvedNames: entry.resolvedRuleNames
|
|
12875
|
+
};
|
|
12876
|
+
case "commands": return {
|
|
12877
|
+
items: entry.commands,
|
|
12878
|
+
selection: entry.commandSelection,
|
|
12879
|
+
path: entry.commandsPath,
|
|
12880
|
+
resolvedNames: entry.resolvedCommandNames
|
|
12881
|
+
};
|
|
12882
|
+
case "subagents": return {
|
|
12883
|
+
items: entry.subagents,
|
|
12884
|
+
selection: entry.subagentSelection,
|
|
12885
|
+
path: entry.subagentsPath,
|
|
12886
|
+
resolvedNames: entry.resolvedSubagentNames
|
|
12887
|
+
};
|
|
12888
|
+
}
|
|
12889
|
+
}
|
|
12890
|
+
/** The lock fields that record one per-file feature's state. */
|
|
12891
|
+
function toFileFeatureLockFields(feature, state) {
|
|
12892
|
+
switch (feature) {
|
|
12893
|
+
case "rules": return {
|
|
12894
|
+
rules: state.items,
|
|
12895
|
+
ruleSelection: state.selection,
|
|
12896
|
+
rulesPath: state.path,
|
|
12897
|
+
resolvedRuleNames: state.resolvedNames
|
|
12898
|
+
};
|
|
12899
|
+
case "commands": return {
|
|
12900
|
+
commands: state.items,
|
|
12901
|
+
commandSelection: state.selection,
|
|
12902
|
+
commandsPath: state.path,
|
|
12903
|
+
resolvedCommandNames: state.resolvedNames
|
|
12904
|
+
};
|
|
12905
|
+
case "subagents": return {
|
|
12906
|
+
subagents: state.items,
|
|
12907
|
+
subagentSelection: state.selection,
|
|
12908
|
+
subagentsPath: state.path,
|
|
12909
|
+
resolvedSubagentNames: state.resolvedNames
|
|
12910
|
+
};
|
|
12911
|
+
}
|
|
12912
|
+
}
|
|
12913
|
+
/** The item names one per-file feature of a lock entry locks. */
|
|
12914
|
+
function getLockedFileNames(entry, feature) {
|
|
12915
|
+
return Object.keys(getLockedFileFeatureState(entry, feature).items ?? {});
|
|
12916
|
+
}
|
|
12917
|
+
// src/lib/sources-artifacts.ts
|
|
12918
|
+
const FILE_FEATURE_SPECS = {
|
|
12919
|
+
rules: {
|
|
12920
|
+
noun: "rule",
|
|
12921
|
+
pathField: "rulesPath",
|
|
12922
|
+
defaultPath: "rules",
|
|
12923
|
+
curatedRelativeDirPath: RULESYNC_CURATED_RULES_RELATIVE_DIR_PATH
|
|
12924
|
+
},
|
|
12925
|
+
commands: {
|
|
12926
|
+
noun: "command",
|
|
12927
|
+
pathField: "commandsPath",
|
|
12928
|
+
defaultPath: "commands",
|
|
12929
|
+
curatedRelativeDirPath: RULESYNC_CURATED_COMMANDS_RELATIVE_DIR_PATH
|
|
12930
|
+
},
|
|
12931
|
+
subagents: {
|
|
12932
|
+
noun: "subagent",
|
|
12933
|
+
pathField: "subagentsPath",
|
|
12934
|
+
defaultPath: "subagents",
|
|
12935
|
+
curatedRelativeDirPath: RULESYNC_CURATED_SUBAGENTS_RELATIVE_DIR_PATH
|
|
12936
|
+
}
|
|
12937
|
+
};
|
|
12938
|
+
/** The singular noun of a per-file feature, for messages (`rule`, `command`, `subagent`). */
|
|
12939
|
+
function getFileFeatureNoun(feature) {
|
|
12940
|
+
return FILE_FEATURE_SPECS[feature].noun;
|
|
12941
|
+
}
|
|
12942
|
+
/** Where a per-file feature's fetched copies live, relative to the project root. */
|
|
12943
|
+
function getCuratedFileFeatureRelativeDirPath(feature) {
|
|
12944
|
+
return FILE_FEATURE_SPECS[feature].curatedRelativeDirPath;
|
|
12945
|
+
}
|
|
12946
|
+
/** Every selection field a source entry may declare. */
|
|
12947
|
+
const SOURCE_SELECTION_FIELDS = ["skills", ...SOURCE_FILE_FEATURES];
|
|
12948
|
+
function getSourceFilters(sourceEntry) {
|
|
12949
|
+
const hasExplicitFeature = SOURCE_SELECTION_FIELDS.some((field) => sourceEntry[field] !== void 0);
|
|
12950
|
+
return {
|
|
12951
|
+
skills: sourceEntry.skills ?? (hasExplicitFeature ? void 0 : ["*"]),
|
|
12952
|
+
rules: sourceEntry.rules,
|
|
12953
|
+
commands: sourceEntry.commands,
|
|
12954
|
+
subagents: sourceEntry.subagents
|
|
12955
|
+
};
|
|
12956
|
+
}
|
|
12957
|
+
/** The selection fields a source entry declares as an empty list. */
|
|
12958
|
+
function getEmptySelectionFields(sourceEntry) {
|
|
12959
|
+
return SOURCE_SELECTION_FIELDS.filter((field) => sourceEntry[field]?.length === 0);
|
|
12960
|
+
}
|
|
12961
|
+
function hasEmptySelection(sourceEntry) {
|
|
12962
|
+
return getEmptySelectionFields(sourceEntry).length > 0;
|
|
12963
|
+
}
|
|
12964
|
+
/**
|
|
12965
|
+
* Whether a lock entry was written for the ref the manifest declares now. A
|
|
12966
|
+
* declared ref that differs from the locked `requestedRef` is resolved afresh
|
|
12967
|
+
* (and fails `--frozen`), so editing the ref in the manifest cannot keep
|
|
12968
|
+
* installing the commit resolved for the old one.
|
|
12969
|
+
*
|
|
12970
|
+
* An entry that records no `requestedRef` (a migrated legacy lock, or a
|
|
12971
|
+
* hand-written one) still matches: it says nothing that contradicts the
|
|
12972
|
+
* declared ref, and refusing it would gain nothing, since whoever can edit the
|
|
12973
|
+
* lock can also write any `requestedRef`. The declared ref is recorded on it
|
|
12974
|
+
* the next time the entry is written.
|
|
12975
|
+
*
|
|
12976
|
+
* A source that declares no ref also matches: its locked `requestedRef` is the
|
|
12977
|
+
* default branch it resolved to, which cannot be told apart from a ref that
|
|
12978
|
+
* was dropped from the manifest without asking the remote.
|
|
12979
|
+
*/
|
|
12980
|
+
function lockedRefMatchesDeclared(params) {
|
|
12981
|
+
const { locked, declaredRef } = params;
|
|
12982
|
+
return declaredRef === void 0 || locked.requestedRef === void 0 || locked.requestedRef === declaredRef;
|
|
12983
|
+
}
|
|
12984
|
+
/**
|
|
12985
|
+
* Check that every locked skill is on disk in the curated directory with the
|
|
12986
|
+
* content the lockfile records: its files hash to the locked integrity, so a
|
|
12987
|
+
* skill edited, extended or trimmed in place is fetched again, as a rule is.
|
|
12988
|
+
*
|
|
12989
|
+
* The locked hash keys each file by the path the transport reported. The
|
|
12990
|
+
* GitHub API and npm report POSIX paths, while the git transport reports
|
|
12991
|
+
* platform paths, so on Windows both spellings are accepted.
|
|
12992
|
+
*
|
|
12993
|
+
* Only presence is checked for a skill whose content this entry cannot vouch
|
|
12994
|
+
* for: one an earlier source already installed under the same name (the
|
|
12995
|
+
* curated directory then holds that source's copy, which wins), and one locked
|
|
12996
|
+
* with an empty integrity by the migration from the legacy lockfile format.
|
|
12997
|
+
*/
|
|
12998
|
+
async function checkLockedSkillsAreValid(params) {
|
|
12999
|
+
const { curatedDir, skills, presenceOnlySkillNames = /* @__PURE__ */ new Set() } = params;
|
|
13000
|
+
for (const [name, entry] of Object.entries(skills)) {
|
|
13001
|
+
const skillDir = (0, node_path.join)(curatedDir, name);
|
|
13002
|
+
if (!await directoryExists(skillDir)) return false;
|
|
13003
|
+
if (entry.integrity === "" || presenceOnlySkillNames.has(name)) continue;
|
|
13004
|
+
const files = await Promise.all((await listFilePathsRecursively(skillDir, { includeHidden: true })).map(async (relativePath) => ({
|
|
13005
|
+
relativePath,
|
|
13006
|
+
content: await readFileContent((0, node_path.join)(skillDir, relativePath))
|
|
13007
|
+
})));
|
|
13008
|
+
if (!(node_path.sep === "/" ? [(relativePath) => relativePath] : [toPosixPath, (relativePath) => relativePath]).some((spell) => computeSkillIntegrity(files.map((file) => ({
|
|
13009
|
+
path: spell(file.relativePath),
|
|
13010
|
+
content: file.content
|
|
13011
|
+
}))) === entry.integrity)) return false;
|
|
13012
|
+
}
|
|
13013
|
+
return true;
|
|
13014
|
+
}
|
|
13015
|
+
/**
|
|
13016
|
+
* Check that every item one per-file feature of a lock entry locks is on disk
|
|
13017
|
+
* in its curated directory with the locked content. A locked name that is not
|
|
13018
|
+
* a valid file name (a hand-edited lockfile) never counts as installed, so it
|
|
13019
|
+
* is fetched again rather than read from outside the curated directory.
|
|
13020
|
+
*/
|
|
13021
|
+
async function checkLockedFilesAreValid(params) {
|
|
13022
|
+
const { items } = getLockedFileFeatureState(params.locked, params.feature);
|
|
13023
|
+
for (const [name, entry] of Object.entries(items ?? {})) {
|
|
13024
|
+
if (!isValidRuleName(name)) return false;
|
|
13025
|
+
const filePath = (0, node_path.join)(params.curatedDir, `${name}.md`);
|
|
13026
|
+
if (!await fileExists(filePath)) return false;
|
|
13027
|
+
if (computeRuleIntegrity(await readFileContent(filePath)) !== entry.integrity) return false;
|
|
13028
|
+
}
|
|
13029
|
+
return true;
|
|
13030
|
+
}
|
|
13031
|
+
async function canReuseLockedFiles(params) {
|
|
13032
|
+
const { feature, locked, sourceEntry, lockedNames, localNames, alreadyFetchedNames, curatedDir } = params;
|
|
13033
|
+
if (!lockedFileConfigMatches({
|
|
13034
|
+
feature,
|
|
13035
|
+
locked,
|
|
13036
|
+
sourceEntry
|
|
13037
|
+
})) return false;
|
|
13038
|
+
const { resolvedNames } = getLockedFileFeatureState(locked, feature);
|
|
13039
|
+
if (resolvedNames === void 0) return false;
|
|
13040
|
+
const availableNames = /* @__PURE__ */ new Set([
|
|
13041
|
+
...lockedNames,
|
|
13042
|
+
...localNames,
|
|
13043
|
+
...alreadyFetchedNames
|
|
13044
|
+
]);
|
|
13045
|
+
if (resolvedNames.some((name) => !availableNames.has(name))) return false;
|
|
13046
|
+
if (lockedNames.some((name) => localNames.has(name) || alreadyFetchedNames.has(name))) return false;
|
|
13047
|
+
return checkLockedFilesAreValid({
|
|
13048
|
+
feature,
|
|
13049
|
+
curatedDir,
|
|
13050
|
+
locked
|
|
13051
|
+
});
|
|
13052
|
+
}
|
|
13053
|
+
/**
|
|
13054
|
+
* Remove previously curated skill directories for a source before re-fetching.
|
|
13055
|
+
* Validates that each path resolves within the curated directory to prevent traversal.
|
|
13056
|
+
*/
|
|
13057
|
+
async function cleanPreviousCuratedSkills(params) {
|
|
13058
|
+
const { curatedDir, lockedSkillNames, protectedSkillNames = /* @__PURE__ */ new Set(), logger } = params;
|
|
13059
|
+
const resolvedCuratedDir = (0, node_path.resolve)(curatedDir);
|
|
13060
|
+
for (const prevSkill of lockedSkillNames) {
|
|
13061
|
+
if (protectedSkillNames.has(prevSkill)) continue;
|
|
13062
|
+
const prevDir = (0, node_path.join)(curatedDir, prevSkill);
|
|
13063
|
+
if (!(0, node_path.resolve)(prevDir).startsWith(resolvedCuratedDir + node_path.sep)) {
|
|
13064
|
+
logger.warn(`Skipping removal of ${quoteForLog(prevSkill)}: resolved path is outside the curated directory.`);
|
|
13065
|
+
continue;
|
|
13066
|
+
}
|
|
13067
|
+
if (await directoryExists(prevDir)) await removeDirectoryStrict(prevDir);
|
|
13068
|
+
}
|
|
13069
|
+
}
|
|
13070
|
+
/**
|
|
13071
|
+
* Whether `<name>.md` resolves to a file directly inside `curatedDir`. Locked
|
|
13072
|
+
* names come from the lockfile, which can be edited by hand, so they are
|
|
13073
|
+
* checked before anything is read, removed or written under them.
|
|
13074
|
+
*/
|
|
13075
|
+
function isCuratedFileInside(params) {
|
|
13076
|
+
const resolvedCuratedDir = (0, node_path.resolve)(params.curatedDir);
|
|
13077
|
+
return (0, node_path.resolve)((0, node_path.join)(params.curatedDir, `${params.name}.md`)).startsWith(resolvedCuratedDir + node_path.sep);
|
|
13078
|
+
}
|
|
13079
|
+
/**
|
|
13080
|
+
* Remove a source's previously curated files (rules, commands or subagents)
|
|
13081
|
+
* before re-fetching. Validates that each path resolves within the curated
|
|
13082
|
+
* directory to prevent traversal.
|
|
13083
|
+
*/
|
|
13084
|
+
async function cleanPreviousCuratedFiles(params) {
|
|
13085
|
+
const { curatedDir, lockedNames, protectedNames, logger } = params;
|
|
13086
|
+
for (const prevName of lockedNames) {
|
|
13087
|
+
if (protectedNames.has(prevName)) continue;
|
|
13088
|
+
if (!isCuratedFileInside({
|
|
13089
|
+
curatedDir,
|
|
13090
|
+
name: prevName
|
|
13091
|
+
})) {
|
|
13092
|
+
logger.warn(`Skipping removal of ${quoteForLog(prevName)}: resolved path is outside the curated directory.`);
|
|
13093
|
+
continue;
|
|
13094
|
+
}
|
|
13095
|
+
const prevFile = (0, node_path.join)(curatedDir, `${prevName}.md`);
|
|
13096
|
+
if (await fileExists(prevFile)) await removeFileStrict(prevFile);
|
|
13097
|
+
}
|
|
13098
|
+
}
|
|
13099
|
+
async function replaceCuratedFiles(params) {
|
|
13100
|
+
const { feature, files, curatedDir, locked, lockedNames, resolvedRef, sourceKey, localNames, alreadyFetchedNames, compareLockedIntegrity, frozen, logger } = params;
|
|
13101
|
+
const protectedNames = alreadyFetchedNames;
|
|
13102
|
+
const installableFiles = files.filter((file) => !shouldSkipFile({
|
|
13103
|
+
feature,
|
|
13104
|
+
name: file.name,
|
|
13105
|
+
sourceKey,
|
|
13106
|
+
localNames,
|
|
13107
|
+
alreadyFetchedNames,
|
|
13108
|
+
logger
|
|
13109
|
+
}));
|
|
13110
|
+
const previousContents = /* @__PURE__ */ new Map();
|
|
13111
|
+
for (const name of lockedNames) {
|
|
13112
|
+
if (protectedNames.has(name) || !isCuratedFileInside({
|
|
13113
|
+
curatedDir,
|
|
13114
|
+
name
|
|
13115
|
+
})) continue;
|
|
13116
|
+
const path = (0, node_path.join)(curatedDir, `${name}.md`);
|
|
13117
|
+
if (await fileExists(path)) previousContents.set(name, await readFileContent(path));
|
|
13118
|
+
}
|
|
13119
|
+
try {
|
|
13120
|
+
await cleanPreviousCuratedFiles({
|
|
13121
|
+
curatedDir,
|
|
13122
|
+
lockedNames,
|
|
13123
|
+
protectedNames,
|
|
13124
|
+
logger
|
|
13125
|
+
});
|
|
13126
|
+
const fetchedFiles = {};
|
|
13127
|
+
for (const file of installableFiles) fetchedFiles[file.name] = await writeFeatureFileAndComputeIntegrity({
|
|
13128
|
+
feature,
|
|
13129
|
+
file,
|
|
13130
|
+
curatedDir,
|
|
13131
|
+
locked,
|
|
13132
|
+
resolvedRef,
|
|
13133
|
+
sourceKey,
|
|
13134
|
+
compareLockedIntegrity,
|
|
13135
|
+
frozen,
|
|
13136
|
+
logger
|
|
13137
|
+
});
|
|
13138
|
+
return fetchedFiles;
|
|
13139
|
+
} catch (error) {
|
|
13140
|
+
for (const file of installableFiles) await removeFileStrict((0, node_path.join)(curatedDir, `${file.name}.md`));
|
|
13141
|
+
for (const [name, content] of previousContents) await writeFileContent((0, node_path.join)(curatedDir, `${name}.md`), content);
|
|
13142
|
+
throw error;
|
|
13143
|
+
}
|
|
13144
|
+
}
|
|
13145
|
+
/**
|
|
13146
|
+
* Check whether a skill should be skipped during fetching.
|
|
13147
|
+
* Returns true (with appropriate logging) if the skill should be skipped.
|
|
13148
|
+
*/
|
|
13149
|
+
function shouldSkipSkill(params) {
|
|
13150
|
+
const { skillName, sourceKey, localSkillNames, alreadyFetchedSkillNames, logger } = params;
|
|
13151
|
+
if (skillName.includes("..") || skillName.includes("/") || skillName.includes("\\")) {
|
|
13152
|
+
logger.warn(`Skipping skill with invalid name ${quoteForLog(skillName)} from ${sourceKey}: contains path traversal characters.`);
|
|
13153
|
+
return true;
|
|
13154
|
+
}
|
|
13155
|
+
const unsafe = describeUnsafeRemoteName(skillName);
|
|
13156
|
+
if (unsafe !== void 0) {
|
|
13157
|
+
logger.warn(`Skipping skill with unsafe name ${unsafe} from ${sourceKey}.`);
|
|
13158
|
+
return true;
|
|
13159
|
+
}
|
|
13160
|
+
if (localSkillNames.has(skillName)) {
|
|
13161
|
+
logger.debug(`Skipping remote skill ${quoteForLog(skillName)} from ${sourceKey}: local skill takes precedence.`);
|
|
13162
|
+
return true;
|
|
13163
|
+
}
|
|
13164
|
+
if (alreadyFetchedSkillNames.has(skillName)) {
|
|
13165
|
+
logger.warn(`Skipping duplicate skill ${quoteForLog(skillName)} from ${sourceKey}: already fetched from another source.`);
|
|
13166
|
+
return true;
|
|
13167
|
+
}
|
|
13168
|
+
return false;
|
|
13169
|
+
}
|
|
13170
|
+
/**
|
|
13171
|
+
* Check whether a remote rule, command or subagent should be skipped: its
|
|
13172
|
+
* name could escape the curated directory or is unsafe to print, a local file
|
|
13173
|
+
* of the same name takes precedence, or an earlier source already took it.
|
|
13174
|
+
*/
|
|
13175
|
+
function shouldSkipFile(params) {
|
|
13176
|
+
const { feature, name, sourceKey, localNames, alreadyFetchedNames, logger } = params;
|
|
13177
|
+
const noun = getFileFeatureNoun(feature);
|
|
13178
|
+
if (!isValidRuleName(name)) {
|
|
13179
|
+
logger.warn(`Skipping ${noun} with invalid name ${quoteForLog(name)} from ${sourceKey}.`);
|
|
13180
|
+
return true;
|
|
13181
|
+
}
|
|
13182
|
+
const unsafe = describeUnsafeRemoteName(name);
|
|
13183
|
+
if (unsafe !== void 0) {
|
|
13184
|
+
logger.warn(`Skipping ${noun} with unsafe name ${unsafe} from ${sourceKey}.`);
|
|
13185
|
+
return true;
|
|
13186
|
+
}
|
|
13187
|
+
if (localNames.has(name)) {
|
|
13188
|
+
logger.debug(`Skipping remote ${noun} ${quoteForLog(name)} from ${sourceKey}: local ${noun} takes precedence.`);
|
|
13189
|
+
return true;
|
|
13190
|
+
}
|
|
13191
|
+
if (alreadyFetchedNames.has(name)) {
|
|
13192
|
+
logger.warn(`Skipping duplicate ${noun} ${quoteForLog(name)} from ${sourceKey}: already fetched from another source.`);
|
|
13193
|
+
return true;
|
|
13194
|
+
}
|
|
13195
|
+
return false;
|
|
13196
|
+
}
|
|
13197
|
+
/**
|
|
13198
|
+
* Why a remote skill or rule name must not be installed, already quoted for a
|
|
13199
|
+
* log line, or `undefined` when it is safe. It applies the same gate as
|
|
13200
|
+
* `rulesync fetch`: a name hiding control or deceptive zero-width characters
|
|
13201
|
+
* could rewrite the terminal when printed, or pass for another name, and a
|
|
13202
|
+
* name Windows folds lands on a different entry than it reads as.
|
|
13203
|
+
*/
|
|
13204
|
+
function describeUnsafeRemoteName(name) {
|
|
13205
|
+
const verdict = classifyRemoteName(name);
|
|
13206
|
+
if (verdict.kind === "safe") return;
|
|
13207
|
+
return verdict.reason === "hidden" ? `${quoteForLog(verdict.display)} (it contains hidden or control characters)` : `${quoteForLog(name)} (Windows resolves it to a different name)`;
|
|
13208
|
+
}
|
|
13209
|
+
function isValidRuleName(ruleName) {
|
|
13210
|
+
return !(ruleName.includes("..") || ruleName.includes("/") || ruleName.includes("\\") || ruleName.length === 0 || [
|
|
13211
|
+
"__proto__",
|
|
13212
|
+
"constructor",
|
|
13213
|
+
"prototype"
|
|
13214
|
+
].includes(ruleName));
|
|
13215
|
+
}
|
|
13216
|
+
/**
|
|
13217
|
+
* A fetched artifact whose content no longer matches the integrity recorded
|
|
13218
|
+
* for the same resolved ref. Under `--frozen` that is fatal — the lockfile is
|
|
13219
|
+
* the contract, and the gh transport refuses the same case — otherwise it is
|
|
13220
|
+
* reported and the new content is taken.
|
|
13221
|
+
*/
|
|
13222
|
+
function reportIntegrityMismatch(params) {
|
|
13223
|
+
const { message, frozen, logger } = params;
|
|
13224
|
+
if (frozen) throw new Error(`${message} Refusing to install it under --frozen.`);
|
|
13225
|
+
logger.warn(message);
|
|
13226
|
+
}
|
|
13227
|
+
async function writeFeatureFileAndComputeIntegrity(params) {
|
|
13228
|
+
const { feature, file, curatedDir, locked, resolvedRef, sourceKey, compareLockedIntegrity = true, frozen, logger } = params;
|
|
13229
|
+
const relativePath = `${file.name}.md`;
|
|
13230
|
+
checkPathTraversal({
|
|
13231
|
+
relativePath,
|
|
13232
|
+
intendedRootDir: curatedDir
|
|
13233
|
+
});
|
|
13234
|
+
const integrity = computeRuleIntegrity(file.content);
|
|
13235
|
+
const lockedEntry = locked ? getLockedFileFeatureState(locked, feature).items?.[file.name] : void 0;
|
|
13236
|
+
if (compareLockedIntegrity && lockedEntry?.integrity && lockedEntry.integrity !== integrity && resolvedRef === locked?.resolvedRef) reportIntegrityMismatch({
|
|
13237
|
+
message: `Integrity mismatch for ${getFileFeatureNoun(feature)} ${quoteForLog(file.name)} from ${sourceKey}: expected "${lockedEntry.integrity}", got "${integrity}". Content may have been tampered with.`,
|
|
13238
|
+
frozen,
|
|
13239
|
+
logger
|
|
13240
|
+
});
|
|
13241
|
+
await writeFileContent((0, node_path.join)(curatedDir, relativePath), file.content);
|
|
13242
|
+
return { integrity };
|
|
13243
|
+
}
|
|
13244
|
+
/**
|
|
13245
|
+
* Write skill files to disk, compute integrity, and check against the lockfile.
|
|
13246
|
+
* Returns the computed LockedSkill entry.
|
|
13247
|
+
*/
|
|
13248
|
+
async function writeSkillAndComputeIntegrity(params) {
|
|
13249
|
+
const { skillName, files, curatedDir, locked, resolvedSha, sourceKey, frozen, logger } = params;
|
|
13250
|
+
for (const file of files) checkPathTraversal({
|
|
13251
|
+
relativePath: file.relativePath,
|
|
13252
|
+
intendedRootDir: (0, node_path.join)(curatedDir, skillName)
|
|
13253
|
+
});
|
|
13254
|
+
const integrity = computeSkillIntegrity(files.map((file) => ({
|
|
13255
|
+
path: file.relativePath,
|
|
13256
|
+
content: file.content
|
|
13257
|
+
})));
|
|
13258
|
+
const lockedSkillEntry = locked?.skills[skillName];
|
|
13259
|
+
if (lockedSkillEntry?.integrity && lockedSkillEntry.integrity !== integrity && resolvedSha === locked?.resolvedRef) reportIntegrityMismatch({
|
|
13260
|
+
message: `Integrity mismatch for skill ${quoteForLog(skillName)} from ${sourceKey}: expected "${lockedSkillEntry.integrity}", got "${integrity}". Content may have been tampered with.`,
|
|
13261
|
+
frozen,
|
|
13262
|
+
logger
|
|
13263
|
+
});
|
|
13264
|
+
for (const file of files) {
|
|
13265
|
+
const filePath = (0, node_path.join)(curatedDir, skillName, file.relativePath);
|
|
13266
|
+
await writeFileContent(filePath, file.content);
|
|
13267
|
+
if (file.executable === true) await applyFileMode(filePath, 493);
|
|
13268
|
+
}
|
|
13269
|
+
return { integrity };
|
|
13270
|
+
}
|
|
13271
|
+
/**
|
|
13272
|
+
* Merge back locked skills that still exist in the remote but were skipped
|
|
13273
|
+
* during fetching (due to local precedence, already-fetched, etc.). Skills no
|
|
13274
|
+
* longer present in the remote (e.g. renamed or deleted upstream) are
|
|
13275
|
+
* intentionally dropped. Shared by the git/github and npm lock updates.
|
|
13276
|
+
*/
|
|
13277
|
+
function mergeFetchedWithLockedSkills(params) {
|
|
13278
|
+
const { fetchedSkills, lockedSkills, remoteSkillNames } = params;
|
|
13279
|
+
const remoteSet = new Set(remoteSkillNames);
|
|
13280
|
+
const mergedSkills = { ...fetchedSkills };
|
|
13281
|
+
if (lockedSkills) {
|
|
13282
|
+
for (const [skillName, skillEntry] of Object.entries(lockedSkills)) if (!(skillName in mergedSkills) && remoteSet.has(skillName)) mergedSkills[skillName] = skillEntry;
|
|
13283
|
+
}
|
|
13284
|
+
return mergedSkills;
|
|
13285
|
+
}
|
|
13286
|
+
function assertMatchingSkillsFound({ skillNames, source }) {
|
|
13287
|
+
if (skillNames.length === 0) throw new Error(`No matching skills found in ${source}.`);
|
|
13288
|
+
}
|
|
13289
|
+
/**
|
|
13290
|
+
* Merge newly fetched skills with existing locked skills and update the lockfile.
|
|
13291
|
+
*/
|
|
13292
|
+
function buildLockUpdate(params) {
|
|
13293
|
+
const { lock, lockKey, sourceKey, fetchedSkills, locked, requestedRef, resolvedSha, skillSelection, skillsPath, remoteSkillNames, logger } = params;
|
|
13294
|
+
const fetchedNames = Object.keys(fetchedSkills);
|
|
13295
|
+
const mergedSkills = mergeFetchedWithLockedSkills({
|
|
13296
|
+
fetchedSkills,
|
|
13297
|
+
lockedSkills: locked?.skills,
|
|
13298
|
+
remoteSkillNames
|
|
13299
|
+
});
|
|
13300
|
+
const updatedLock = setLockedSource(lock, lockKey, {
|
|
13301
|
+
requestedRef,
|
|
13302
|
+
resolvedRef: resolvedSha,
|
|
13303
|
+
resolvedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13304
|
+
skills: mergedSkills,
|
|
13305
|
+
skillSelection,
|
|
13306
|
+
skillsPath,
|
|
13307
|
+
rules: locked?.rules ?? {},
|
|
13308
|
+
ruleSelection: locked?.ruleSelection,
|
|
13309
|
+
rulesPath: locked?.rulesPath,
|
|
13310
|
+
resolvedRuleNames: locked?.resolvedRuleNames,
|
|
13311
|
+
...pickFileFeatureLockFields({
|
|
13312
|
+
locked,
|
|
13313
|
+
features: ["commands", "subagents"]
|
|
13314
|
+
})
|
|
13315
|
+
});
|
|
13316
|
+
logger.info(`Fetched ${fetchedNames.length} skill(s) from ${sourceKey}: ${fetchedNames.map(stripControlCharacters).join(", ") || "(none)"}`);
|
|
13317
|
+
return {
|
|
13318
|
+
updatedLock,
|
|
13319
|
+
fetchedNames
|
|
13320
|
+
};
|
|
13321
|
+
}
|
|
13322
|
+
/**
|
|
13323
|
+
* The lock fields of the given per-file features, copied from a lock entry
|
|
13324
|
+
* (empty when there is none), so that writing one feature's fields keeps the
|
|
13325
|
+
* others as they were.
|
|
13326
|
+
*/
|
|
13327
|
+
function pickFileFeatureLockFields(params) {
|
|
13328
|
+
const { locked, features } = params;
|
|
13329
|
+
if (locked === void 0) return {};
|
|
13330
|
+
return Object.assign({}, ...features.map((feature) => toFileFeatureLockFields(feature, getLockedFileFeatureState(locked, feature))));
|
|
13331
|
+
}
|
|
13332
|
+
function buildFileLockUpdate(params) {
|
|
13333
|
+
const { feature, lock, lockKey, sourceKey, fetchedFiles, locked, requestedRef, resolvedRef, selection, path, resolvedNames, logger } = params;
|
|
13334
|
+
const fetchedNames = Object.keys(fetchedFiles);
|
|
13335
|
+
const updatedLock = setLockedSource(lock, lockKey, {
|
|
13336
|
+
requestedRef,
|
|
13337
|
+
resolvedRef,
|
|
13338
|
+
resolvedAt: (/* @__PURE__ */ new Date()).toISOString(),
|
|
13339
|
+
skills: locked?.skills ?? {},
|
|
13340
|
+
skillSelection: locked?.skillSelection,
|
|
13341
|
+
skillsPath: locked?.skillsPath,
|
|
13342
|
+
...pickFileFeatureLockFields({
|
|
13343
|
+
locked,
|
|
13344
|
+
features: SOURCE_FILE_FEATURES
|
|
13345
|
+
}),
|
|
13346
|
+
...toFileFeatureLockFields(feature, {
|
|
13347
|
+
items: fetchedFiles,
|
|
13348
|
+
selection,
|
|
13349
|
+
path,
|
|
13350
|
+
resolvedNames
|
|
13351
|
+
})
|
|
13352
|
+
});
|
|
13353
|
+
logger.info(`Fetched ${fetchedNames.length} ${getFileFeatureNoun(feature)}(s) from ${sourceKey}: ${fetchedNames.map(stripControlCharacters).join(", ") || "(none)"}`);
|
|
13354
|
+
return {
|
|
13355
|
+
updatedLock,
|
|
13356
|
+
fetchedNames
|
|
13357
|
+
};
|
|
13358
|
+
}
|
|
13359
|
+
function getFirstPathSeparatorIndex(path) {
|
|
13360
|
+
const slashIndex = path.indexOf("/");
|
|
13361
|
+
const backslashIndex = path.indexOf("\\");
|
|
13362
|
+
if (slashIndex === -1) return backslashIndex;
|
|
13363
|
+
if (backslashIndex === -1) return slashIndex;
|
|
13364
|
+
return Math.min(slashIndex, backslashIndex);
|
|
13365
|
+
}
|
|
13366
|
+
/**
|
|
13367
|
+
* Decide whether a repository's root-level files should be installed as the
|
|
13368
|
+
* single requested skill (the "root fallback").
|
|
13369
|
+
*
|
|
13370
|
+
* A root fallback fires only when a single, non-wildcard skill was requested,
|
|
13371
|
+
* that skill's own directory is absent, and the repository root actually carries
|
|
13372
|
+
* a `SKILL.md`. Both the git transport (`groupRemoteFilesBySkillRoot`) and the
|
|
13373
|
+
* GitHub transport (`discoverGithubSkillDirs`) gate on these same conditions, so
|
|
13374
|
+
* the decision lives here to keep the two paths from drifting.
|
|
13375
|
+
*/
|
|
13376
|
+
function shouldUseRootFallback(params) {
|
|
13377
|
+
const { skillFilter, isWildcard, hasRootSkillFile, hasRequestedSkillDir } = params;
|
|
13378
|
+
const [singleSkillName] = skillFilter;
|
|
13379
|
+
return !isWildcard && skillFilter.length === 1 && singleSkillName !== void 0 && hasRootSkillFile && !hasRequestedSkillDir;
|
|
13380
|
+
}
|
|
13381
|
+
function groupRemoteFilesBySkillRoot(params) {
|
|
13382
|
+
const { remoteFiles, skillFilter, isWildcard } = params;
|
|
13383
|
+
const grouped = /* @__PURE__ */ new Map();
|
|
13384
|
+
const rootLevelFiles = [];
|
|
13385
|
+
for (const file of remoteFiles) {
|
|
13386
|
+
const separatorIndex = getFirstPathSeparatorIndex(file.relativePath);
|
|
13387
|
+
if (separatorIndex === -1) {
|
|
13388
|
+
rootLevelFiles.push(file);
|
|
13389
|
+
continue;
|
|
13390
|
+
}
|
|
13391
|
+
const skillName = file.relativePath.substring(0, separatorIndex);
|
|
13392
|
+
if (skillName.length === 0) continue;
|
|
13393
|
+
const innerPath = file.relativePath.substring(separatorIndex + 1);
|
|
13394
|
+
const groupedFiles = grouped.get(skillName) ?? [];
|
|
13395
|
+
groupedFiles.push({
|
|
13396
|
+
...file,
|
|
13397
|
+
relativePath: innerPath
|
|
13398
|
+
});
|
|
13399
|
+
grouped.set(skillName, groupedFiles);
|
|
13400
|
+
}
|
|
13401
|
+
const [singleSkillName] = skillFilter;
|
|
13402
|
+
const hasRootSkillFile = rootLevelFiles.some((file) => file.relativePath === SKILL_FILE_NAME);
|
|
13403
|
+
if (singleSkillName !== void 0 && shouldUseRootFallback({
|
|
13404
|
+
skillFilter,
|
|
13405
|
+
isWildcard,
|
|
13406
|
+
hasRootSkillFile,
|
|
13407
|
+
hasRequestedSkillDir: grouped.has(singleSkillName)
|
|
13408
|
+
})) grouped.set(singleSkillName, rootLevelFiles);
|
|
13409
|
+
return grouped;
|
|
13410
|
+
}
|
|
13411
|
+
function normalizeRuleFilterName(name) {
|
|
13412
|
+
return name.replace(/\.md$/i, "");
|
|
13413
|
+
}
|
|
13414
|
+
/** Whether a declared skill or rule selection is the `["*"]` wildcard. */
|
|
13415
|
+
function isWildcardSelection(selection) {
|
|
13416
|
+
return selection.length === 1 && selection[0] === "*";
|
|
13417
|
+
}
|
|
13418
|
+
/**
|
|
13419
|
+
* Pick the remote files a source entry declares for one per-file feature:
|
|
13420
|
+
* Markdown files whose normalized name is selected by the feature's field
|
|
13421
|
+
* (`sourceEntry.rules`, `.commands` or `.subagents`, or the wildcard) and is a
|
|
13422
|
+
* valid file name. Candidate order is preserved.
|
|
13423
|
+
*/
|
|
13424
|
+
function selectDeclaredFiles(params) {
|
|
13425
|
+
const { feature, sourceEntry, candidates, getFileName } = params;
|
|
13426
|
+
const ruleFilter = (sourceEntry[feature] ?? []).map(normalizeRuleFilterName);
|
|
13427
|
+
const isWildcard = isWildcardSelection(ruleFilter);
|
|
13428
|
+
return candidates.filter((candidate) => getFileName(candidate).toLowerCase().endsWith(".md")).map((candidate) => ({
|
|
13429
|
+
candidate,
|
|
13430
|
+
name: normalizeRuleFilterName(getFileName(candidate))
|
|
13431
|
+
})).filter(({ name }) => (isWildcard || ruleFilter.includes(name)) && isValidRuleName(name));
|
|
13432
|
+
}
|
|
13433
|
+
function normalizeRuleSelection(rules) {
|
|
13434
|
+
return [...new Set(rules.map(normalizeRuleFilterName))].toSorted();
|
|
13435
|
+
}
|
|
13436
|
+
function normalizeSkillSelection(skills) {
|
|
13437
|
+
return [...new Set(skills)].toSorted();
|
|
13438
|
+
}
|
|
13439
|
+
/**
|
|
13440
|
+
* Whether the locked entry was written for the `skills` selection and skills
|
|
13441
|
+
* path the manifest declares now. Without it, widening the selection or moving
|
|
13442
|
+
* the path after an install is a silent no-op: the ref is unchanged and every
|
|
13443
|
+
* locked skill is on disk, so nothing is fetched and `--frozen` never notices.
|
|
13444
|
+
*
|
|
13445
|
+
* Lockfiles written before the path was recorded carry no `skillsPath`. Such
|
|
13446
|
+
* an entry is handled like one without `skillSelection`: fetched again at its
|
|
13447
|
+
* locked ref to record the path, and accepted as-is under `acceptLegacy`.
|
|
13448
|
+
*
|
|
13449
|
+
* Lockfiles written before the selection was recorded carry no
|
|
13450
|
+
* `skillSelection`. An install that may write the lockfile fetches such an
|
|
13451
|
+
* entry again at its locked ref so the selection gets recorded once; the checks that
|
|
13452
|
+
* cannot write it (`--frozen`, adding a source) pass `acceptLegacy` and fall
|
|
13453
|
+
* back to the locked skill names instead, so a wildcard is taken at face value
|
|
13454
|
+
* and an explicit list is covered only when every name it selects is locked.
|
|
13455
|
+
* An entry that locks no skills at all (a rules-only install) covers nothing:
|
|
13456
|
+
* it was never written for a skill selection.
|
|
13457
|
+
*/
|
|
13458
|
+
function lockedSkillConfigMatches(params) {
|
|
13459
|
+
const skills = getSourceFilters(params.sourceEntry).skills;
|
|
13460
|
+
if (skills === void 0) return false;
|
|
13461
|
+
const lockedPath = params.locked.skillsPath;
|
|
13462
|
+
if (lockedPath === void 0 ? !params.acceptLegacy : lockedPath !== resolveSkillsPath(params.sourceEntry)) return false;
|
|
13463
|
+
const selection = normalizeSkillSelection(skills);
|
|
13464
|
+
const lockedSelection = params.locked.skillSelection;
|
|
13465
|
+
if (lockedSelection === void 0) {
|
|
13466
|
+
const lockedSkillNames = new Set(Object.keys(params.locked.skills));
|
|
13467
|
+
if (!params.acceptLegacy || lockedSkillNames.size === 0) return false;
|
|
13468
|
+
if (isWildcardSelection(selection)) return true;
|
|
13469
|
+
return selection.every((skillName) => lockedSkillNames.has(skillName));
|
|
13470
|
+
}
|
|
13471
|
+
return selection.length === lockedSelection.length && selection.every((skillName, index) => skillName === lockedSelection[index]);
|
|
13472
|
+
}
|
|
13473
|
+
/**
|
|
13474
|
+
* Skip the re-fetch when the SHA and the skill selection match the lockfile and
|
|
13475
|
+
* every curated skill the entry locks is still on disk, unmodified.
|
|
13476
|
+
*/
|
|
13477
|
+
async function canReuseLockedSkills(params) {
|
|
13478
|
+
const { locked, resolvedSha, updateSources, frozen, sourceEntry, curatedDir, getAlreadyFetchedSkillNames } = params;
|
|
13479
|
+
return locked !== void 0 && resolvedSha === locked.resolvedRef && !updateSources && lockedSkillConfigMatches({
|
|
13480
|
+
locked,
|
|
13481
|
+
sourceEntry,
|
|
13482
|
+
acceptLegacy: frozen
|
|
13483
|
+
}) && await checkLockedSkillsAreValid({
|
|
13484
|
+
curatedDir,
|
|
13485
|
+
skills: locked.skills,
|
|
13486
|
+
presenceOnlySkillNames: await getAlreadyFetchedSkillNames()
|
|
13487
|
+
});
|
|
13488
|
+
}
|
|
13489
|
+
/**
|
|
13490
|
+
* The path the skills of a source are read from, as declared: the source's
|
|
13491
|
+
* `path`, else (for the github transport) the path embedded in the source
|
|
13492
|
+
* spec, else `skills`. Every transport fetches from this path, and the
|
|
13493
|
+
* lockfile records its normalized form ({@link resolveSkillsPath}), so the
|
|
13494
|
+
* fetch and the lock comparison cannot pick different paths.
|
|
13495
|
+
*/
|
|
13496
|
+
function resolveSkillsSourcePath(sourceEntry) {
|
|
13497
|
+
const embeddedPath = getSourceTransport(sourceEntry) === "github" ? parseSource(sourceEntry.source).path : void 0;
|
|
13498
|
+
return sourceEntry.path ?? embeddedPath ?? "skills";
|
|
13499
|
+
}
|
|
13500
|
+
/** The skills path of a source in the form the lockfile records and compares. */
|
|
13501
|
+
function resolveSkillsPath(sourceEntry) {
|
|
13502
|
+
return normalizeSourceDirPath(resolveSkillsSourcePath(sourceEntry));
|
|
13503
|
+
}
|
|
13504
|
+
/**
|
|
13505
|
+
* The path one per-file feature of a source is read from, as declared: the
|
|
13506
|
+
* source's `rulesPath` / `commandsPath` / `subagentsPath`, else `rules` /
|
|
13507
|
+
* `commands` / `subagents`. The counterpart of {@link resolveSkillsSourcePath}.
|
|
13508
|
+
*/
|
|
13509
|
+
function resolveFileFeatureSourcePath(sourceEntry, feature) {
|
|
13510
|
+
const spec = FILE_FEATURE_SPECS[feature];
|
|
13511
|
+
return sourceEntry[spec.pathField] ?? spec.defaultPath;
|
|
13512
|
+
}
|
|
13513
|
+
/** A per-file feature's path in the form the lockfile records and compares. */
|
|
13514
|
+
function resolveFileFeaturePath(sourceEntry, feature) {
|
|
13515
|
+
return normalizeSourceDirPath(resolveFileFeatureSourcePath(sourceEntry, feature));
|
|
13516
|
+
}
|
|
13517
|
+
/**
|
|
13518
|
+
* The form a source directory path is recorded in the lockfile and compared
|
|
13519
|
+
* in: posix separators, normalized, with no trailing slash.
|
|
13520
|
+
*/
|
|
13521
|
+
function normalizeSourceDirPath(dirPath) {
|
|
13522
|
+
return normalizePosixDirPath(dirPath);
|
|
13523
|
+
}
|
|
13524
|
+
/**
|
|
13525
|
+
* Whether a lock entry was written for the selection and path one per-file
|
|
13526
|
+
* feature of the source declares now.
|
|
13527
|
+
*/
|
|
13528
|
+
function lockedFileConfigMatches(params) {
|
|
13529
|
+
const { feature, locked, sourceEntry } = params;
|
|
13530
|
+
const declared = getSourceFilters(sourceEntry)[feature];
|
|
13531
|
+
const { selection: lockedSelection, path: lockedPath } = getLockedFileFeatureState(locked, feature);
|
|
13532
|
+
if (declared === void 0 || lockedSelection === void 0) return false;
|
|
13533
|
+
const selection = normalizeRuleSelection(declared);
|
|
13534
|
+
return selection.length === lockedSelection.length && selection.every((name, index) => name === lockedSelection[index]) && resolveFileFeaturePath(sourceEntry, feature) === lockedPath;
|
|
13535
|
+
}
|
|
13536
|
+
function assertMatchingFilesFound(params) {
|
|
13537
|
+
if (params.names.length === 0) throw new Error(`No matching ${params.feature} found in ${params.source}.`);
|
|
13538
|
+
}
|
|
13539
|
+
/**
|
|
13540
|
+
* "N skill(s) and M rule(s)", followed by the command and subagent counts when
|
|
13541
|
+
* any were installed, for the summary lines of `add` and `install`.
|
|
13542
|
+
*/
|
|
13543
|
+
function formatInstalledCounts(result) {
|
|
13544
|
+
const extras = [result.fetchedCommandCount > 0 ? `${result.fetchedCommandCount} command(s)` : void 0, result.fetchedSubagentCount > 0 ? `${result.fetchedSubagentCount} subagent(s)` : void 0].filter((part) => part !== void 0);
|
|
13545
|
+
const parts = [
|
|
13546
|
+
`${result.fetchedSkillCount} skill(s)`,
|
|
13547
|
+
`${result.fetchedRuleCount} rule(s)`,
|
|
13548
|
+
...extras
|
|
13549
|
+
];
|
|
13550
|
+
return `${parts.slice(0, -1).join(", ")} and ${parts.at(-1)}`;
|
|
13551
|
+
}
|
|
12364
13552
|
const SKILL_DESCRIPTION_MAX_LENGTH = 1024;
|
|
12365
13553
|
const SKILL_NAME_PATTERN = /^[a-z0-9]+(?:-[a-z0-9]+)*$/;
|
|
12366
13554
|
/**
|
|
@@ -15483,8 +16671,11 @@ var FeatureProcessor = class extends RulesyncSourceConsumer {
|
|
|
15483
16671
|
})) continue;
|
|
15484
16672
|
const existingFileContent = await readFileContentOrNull(filePath);
|
|
15485
16673
|
if (existingFileContent !== null && aiFile.shouldMergeExistingFileContent()) aiFile.setFileContent(existingFileContent);
|
|
15486
|
-
const contentWithNewline = addTrailingNewline(aiFile.getFileContent());
|
|
15487
16674
|
const existingContent = existingFileContent;
|
|
16675
|
+
const contentWithNewline = aiFile.composeWrittenContent({
|
|
16676
|
+
existingContent,
|
|
16677
|
+
generatedContent: addTrailingNewline(aiFile.getFileContent())
|
|
16678
|
+
});
|
|
15488
16679
|
if (existingContent === null && aiFile.shouldSkipCreationWhenPayloadEmpty() && fileContentIsEmptyPayload({
|
|
15489
16680
|
filePath,
|
|
15490
16681
|
content: contentWithNewline
|
|
@@ -15603,6 +16794,21 @@ var FeatureProcessor = class extends RulesyncSourceConsumer {
|
|
|
15603
16794
|
}
|
|
15604
16795
|
if (refused) continue;
|
|
15605
16796
|
const loggedPath = stripControlCharacters(filePath);
|
|
16797
|
+
if (aiFile.keepsContentOnRemoval()) {
|
|
16798
|
+
const existingContent = await readFileContentOrNull(filePath);
|
|
16799
|
+
const outcome = existingContent === null ? { action: "delete" } : aiFile.composeContentAfterRemoval({ existingContent });
|
|
16800
|
+
if (outcome.action === "keep") continue;
|
|
16801
|
+
if (outcome.action === "rewrite") {
|
|
16802
|
+
if (this.dryRun) this.logger.info(`[DRY RUN] Would rewrite: ${loggedPath}`);
|
|
16803
|
+
else {
|
|
16804
|
+
await writeFileContent(filePath, outcome.content);
|
|
16805
|
+
this.logger.info(`Removed the generated block from: ${loggedPath}`);
|
|
16806
|
+
}
|
|
16807
|
+
this.sweepWrites.paths.push(aiFile.getRelativePathFromCwd());
|
|
16808
|
+
removedCount++;
|
|
16809
|
+
continue;
|
|
16810
|
+
}
|
|
16811
|
+
}
|
|
15606
16812
|
if (this.dryRun) this.logger.info(`[DRY RUN] Would delete: ${loggedPath}`);
|
|
15607
16813
|
else {
|
|
15608
16814
|
await removeFile(filePath);
|
|
@@ -15987,8 +17193,8 @@ var ClaimedIdentities = class {
|
|
|
15987
17193
|
};
|
|
15988
17194
|
// src/utils/curated-frontmatter.ts
|
|
15989
17195
|
/**
|
|
15990
|
-
* The frontmatter fields a command or
|
|
15991
|
-
* keeps. Only the canonical, tool-neutral fields of the rulesync schema are
|
|
17196
|
+
* The frontmatter fields a command, subagent or skill fetched from a declared
|
|
17197
|
+
* source keeps. Only the canonical, tool-neutral fields of the rulesync schema are
|
|
15992
17198
|
* listed: none of them grants tools, permissions, hooks or MCP servers.
|
|
15993
17199
|
*
|
|
15994
17200
|
* Every tool section (`claudecode`, `codexcli`, `kiro`, `opencode`, ...) is
|
|
@@ -16005,6 +17211,30 @@ const CURATED_SUBAGENT_FRONTMATTER_KEYS = [
|
|
|
16005
17211
|
"description"
|
|
16006
17212
|
];
|
|
16007
17213
|
/**
|
|
17214
|
+
* A skill also keeps the root invocation flags (`disable-model-invocation`,
|
|
17215
|
+
* `user-invocable`), which only narrow when the skill is loaded, and the Agent
|
|
17216
|
+
* Skills packaging fields (`license`, `compatibility`, `metadata`). Inside
|
|
17217
|
+
* `metadata`, the tool blocks listed in `CURATED_SKILL_DROPPED_METADATA_KEYS`
|
|
17218
|
+
* are dropped, since they gate or install things rather than describe the
|
|
17219
|
+
* skill.
|
|
17220
|
+
*/
|
|
17221
|
+
const CURATED_SKILL_FRONTMATTER_KEYS = [
|
|
17222
|
+
"targets",
|
|
17223
|
+
"name",
|
|
17224
|
+
"description",
|
|
17225
|
+
"disable-model-invocation",
|
|
17226
|
+
"user-invocable",
|
|
17227
|
+
"license",
|
|
17228
|
+
"compatibility",
|
|
17229
|
+
"metadata"
|
|
17230
|
+
];
|
|
17231
|
+
/**
|
|
17232
|
+
* `metadata` keys a tool reads as configuration: OpenClaw's `metadata.openclaw`
|
|
17233
|
+
* (`install`, `always`, `requires`, ...) and Hermes Agent's `metadata.hermes`
|
|
17234
|
+
* (`requires_toolsets`, ...). A skill fetched from a source loses them.
|
|
17235
|
+
*/
|
|
17236
|
+
const CURATED_SKILL_DROPPED_METADATA_KEYS = ["openclaw", "hermes"];
|
|
17237
|
+
/**
|
|
16008
17238
|
* Keep only `allowedKeys` of a frontmatter object. Returns a new frontmatter
|
|
16009
17239
|
* and the names of the dropped top-level keys, in input order.
|
|
16010
17240
|
*/
|
|
@@ -31721,6 +32951,15 @@ const defaultGetFactory$5 = (target) => {
|
|
|
31721
32951
|
const skillsProcessorToolTargetsProject = [...toolSkillFactories].filter(([, factory]) => factory.meta.supportsProject).map(([target]) => target);
|
|
31722
32952
|
const skillsProcessorToolTargetsSimulated = [...toolSkillFactories].filter(([, factory]) => factory.meta.supportsSimulated).map(([target]) => target);
|
|
31723
32953
|
const skillsProcessorToolTargetsGlobal = [...toolSkillFactories].filter(([, factory]) => factory.meta.supportsGlobal).map(([target]) => target);
|
|
32954
|
+
/**
|
|
32955
|
+
* Whether a skill companion path is the Codex `agents/openai.yaml` sidecar,
|
|
32956
|
+
* compared case-insensitively and with either separator, since a
|
|
32957
|
+
* case-insensitive filesystem or Windows resolves those spellings to it.
|
|
32958
|
+
*/
|
|
32959
|
+
function isCodexOpenaiYaml(relativeFilePath) {
|
|
32960
|
+
const normalize = (path) => path.replaceAll("\\", "/").toLowerCase();
|
|
32961
|
+
return normalize(relativeFilePath) === normalize(CODEXCLI_OPENAI_YAML_RELATIVE_PATH);
|
|
32962
|
+
}
|
|
31724
32963
|
var SkillsProcessor = class extends DirFeatureProcessor {
|
|
31725
32964
|
toolTarget;
|
|
31726
32965
|
global;
|
|
@@ -31834,16 +33073,59 @@ var SkillsProcessor = class extends DirFeatureProcessor {
|
|
|
31834
33073
|
}));
|
|
31835
33074
|
return false;
|
|
31836
33075
|
});
|
|
31837
|
-
curatedSkills = await Promise.all(nonConflicting.map((dirName) => RulesyncSkill.fromDir({
|
|
33076
|
+
curatedSkills = await Promise.all(nonConflicting.map(async (dirName) => this.withCanonicalFrontmatterOnly(await RulesyncSkill.fromDir({
|
|
31838
33077
|
outputRoot: treeParent,
|
|
31839
33078
|
relativeDirPath: treeCuratedSkillsDirPath,
|
|
31840
33079
|
dirName,
|
|
31841
33080
|
global: this.global
|
|
31842
|
-
})));
|
|
33081
|
+
}))));
|
|
31843
33082
|
}
|
|
31844
33083
|
return [...localSkills, ...curatedSkills];
|
|
31845
33084
|
}
|
|
31846
33085
|
/**
|
|
33086
|
+
* A skill fetched from a declared source, keeping only the canonical,
|
|
33087
|
+
* tool-neutral frontmatter fields and dropping every tool section, since
|
|
33088
|
+
* those are copied into the generated files and can grant tools or hooks
|
|
33089
|
+
* (Claude Code `allowed-tools` and `hooks`, for example). The tool blocks
|
|
33090
|
+
* inside `metadata` (OpenClaw's `metadata.openclaw`, Hermes Agent's
|
|
33091
|
+
* `metadata.hermes`) and a Codex `agents/openai.yaml` companion file (its
|
|
33092
|
+
* invocation policy and MCP dependencies) go too. The body and the other
|
|
33093
|
+
* companion files are kept. A local skill of the same name keeps its
|
|
33094
|
+
* tool-specific settings.
|
|
33095
|
+
*/
|
|
33096
|
+
withCanonicalFrontmatterOnly(skill) {
|
|
33097
|
+
const kept = keepCuratedFrontmatterKeys({
|
|
33098
|
+
frontmatter: skill.getFrontmatter(),
|
|
33099
|
+
allowedKeys: CURATED_SKILL_FRONTMATTER_KEYS
|
|
33100
|
+
});
|
|
33101
|
+
const frontmatter = kept.frontmatter;
|
|
33102
|
+
const droppedKeys = [...kept.droppedKeys];
|
|
33103
|
+
if (frontmatter.metadata !== void 0) {
|
|
33104
|
+
const metadata = { ...frontmatter.metadata };
|
|
33105
|
+
for (const key of CURATED_SKILL_DROPPED_METADATA_KEYS) if (Object.hasOwn(metadata, key)) {
|
|
33106
|
+
delete metadata[key];
|
|
33107
|
+
droppedKeys.push(`metadata.${key}`);
|
|
33108
|
+
}
|
|
33109
|
+
frontmatter.metadata = metadata;
|
|
33110
|
+
}
|
|
33111
|
+
const otherFiles = skill.getOtherFiles();
|
|
33112
|
+
const keptFiles = otherFiles.filter((file) => !isCodexOpenaiYaml(file.relativeFilePathToDirPath));
|
|
33113
|
+
const droppedFiles = otherFiles.length - keptFiles.length;
|
|
33114
|
+
if (droppedKeys.length === 0 && droppedFiles === 0) return skill;
|
|
33115
|
+
const skillPath = quoteForLog((0, node_path.join)(skill.getRelativeDirPath(), skill.getDirName()));
|
|
33116
|
+
if (droppedKeys.length > 0) this.logger.warn(`Dropped frontmatter from source-installed skill ${skillPath}: ${droppedKeys.map(stripControlCharacters).join(", ")}. A skill installed from a source keeps only these frontmatter fields: ${CURATED_SKILL_FRONTMATTER_KEYS.join(", ")} (without ${CURATED_SKILL_DROPPED_METADATA_KEYS.map((key) => `metadata.${key}`).join(" or ")}). It cannot grant tools or hooks; copy it into .rulesync/skills/ locally to keep tool-specific settings.`);
|
|
33117
|
+
if (droppedFiles > 0) this.logger.warn(`Dropped ${CODEXCLI_OPENAI_YAML_RELATIVE_PATH} from source-installed skill ${skillPath}: a skill installed from a source cannot set a Codex CLI invocation policy or MCP dependencies; copy it into .rulesync/skills/ locally to keep them.`);
|
|
33118
|
+
return new RulesyncSkill({
|
|
33119
|
+
outputRoot: skill.getOutputRoot(),
|
|
33120
|
+
relativeDirPath: skill.getRelativeDirPath(),
|
|
33121
|
+
dirName: skill.getDirName(),
|
|
33122
|
+
frontmatter,
|
|
33123
|
+
body: skill.getBody(),
|
|
33124
|
+
otherFiles: keptFiles,
|
|
33125
|
+
global: skill.getGlobal()
|
|
33126
|
+
});
|
|
33127
|
+
}
|
|
33128
|
+
/**
|
|
31847
33129
|
* Implementation of abstract method from DirFeatureProcessor.
|
|
31848
33130
|
*
|
|
31849
33131
|
* Load and parse rulesync skill directories from every configured input
|
|
@@ -41455,6 +42737,116 @@ var ClaudecodeLanguageSettings = class ClaudecodeLanguageSettings extends ToolFi
|
|
|
41455
42737
|
}
|
|
41456
42738
|
}
|
|
41457
42739
|
};
|
|
42740
|
+
// src/features/rules/rule-managed-block.ts
|
|
42741
|
+
/**
|
|
42742
|
+
* The fence `preserveUnmanagedRuleContent` wraps around the generated body of
|
|
42743
|
+
* a root rule file, so content a person writes outside it survives the next
|
|
42744
|
+
* `generate`. The wording follows the block `rulesync gitignore` writes
|
|
42745
|
+
* (`# Generated by Rulesync` / `# End of Rulesync`), as Markdown comments so
|
|
42746
|
+
* the tools reading the file do not show it.
|
|
42747
|
+
*/
|
|
42748
|
+
const RULE_MANAGED_BLOCK_START = "<!-- Generated by Rulesync -->";
|
|
42749
|
+
const RULE_MANAGED_BLOCK_END = "<!-- End of Rulesync -->";
|
|
42750
|
+
const LEADING_FRONTMATTER_PATTERN = /^---\r?\n[\s\S]*?\r?\n---[ \t]*(?:\r?\n|$)/;
|
|
42751
|
+
const splitLeadingFrontmatter = (content) => {
|
|
42752
|
+
const match = LEADING_FRONTMATTER_PATTERN.exec(content);
|
|
42753
|
+
if (!match) return {
|
|
42754
|
+
frontmatter: "",
|
|
42755
|
+
rest: content
|
|
42756
|
+
};
|
|
42757
|
+
return {
|
|
42758
|
+
frontmatter: match[0].endsWith("\n") ? match[0] : `${match[0]}\n`,
|
|
42759
|
+
rest: content.slice(match[0].length)
|
|
42760
|
+
};
|
|
42761
|
+
};
|
|
42762
|
+
const CODE_FENCE_PATTERN = /^ {0,3}(`{3,}|~{3,})/;
|
|
42763
|
+
/**
|
|
42764
|
+
* Locate the first complete fence: a line that is exactly the start marker
|
|
42765
|
+
* (surrounding whitespace aside) followed later by a line that is exactly the
|
|
42766
|
+
* end marker. A start marker without an end marker is not a fence. Marker
|
|
42767
|
+
* lines inside a Markdown code block (```` ``` ```` or `~~~`) do not count, so
|
|
42768
|
+
* a rule that quotes the markers in an example is not mistaken for a fence.
|
|
42769
|
+
*/
|
|
42770
|
+
const findFence = (content) => {
|
|
42771
|
+
let startLineBegin;
|
|
42772
|
+
let startLineEnd = 0;
|
|
42773
|
+
let openCodeFence;
|
|
42774
|
+
let offset = 0;
|
|
42775
|
+
while (offset <= content.length) {
|
|
42776
|
+
const newline = content.indexOf("\n", offset);
|
|
42777
|
+
const lineEnd = newline === -1 ? content.length : newline + 1;
|
|
42778
|
+
const rawLine = content.slice(offset, newline === -1 ? content.length : newline);
|
|
42779
|
+
const codeFence = CODE_FENCE_PATTERN.exec(rawLine)?.[1];
|
|
42780
|
+
if (openCodeFence !== void 0) {
|
|
42781
|
+
if (codeFence !== void 0 && codeFence[0] === openCodeFence[0] && codeFence.length >= openCodeFence.length && rawLine.trim() === codeFence) openCodeFence = void 0;
|
|
42782
|
+
} else if (codeFence !== void 0) openCodeFence = codeFence;
|
|
42783
|
+
else {
|
|
42784
|
+
const line = rawLine.trim();
|
|
42785
|
+
if (startLineBegin === void 0) {
|
|
42786
|
+
if (line === "<!-- Generated by Rulesync -->") {
|
|
42787
|
+
startLineBegin = offset;
|
|
42788
|
+
startLineEnd = lineEnd;
|
|
42789
|
+
}
|
|
42790
|
+
} else if (line === "<!-- End of Rulesync -->") return {
|
|
42791
|
+
startLineBegin,
|
|
42792
|
+
startLineEnd,
|
|
42793
|
+
endLineBegin: offset,
|
|
42794
|
+
endLineEnd: lineEnd
|
|
42795
|
+
};
|
|
42796
|
+
}
|
|
42797
|
+
if (newline === -1) break;
|
|
42798
|
+
offset = lineEnd;
|
|
42799
|
+
}
|
|
42800
|
+
};
|
|
42801
|
+
/**
|
|
42802
|
+
* Compose the content to write for a root rule file under
|
|
42803
|
+
* `preserveUnmanagedRuleContent`: the generated frontmatter (if any) first,
|
|
42804
|
+
* then whatever the existing file holds before its fence, the fenced
|
|
42805
|
+
* generated body, and whatever it holds after the fence.
|
|
42806
|
+
*
|
|
42807
|
+
* An existing file without a complete fence is treated as entirely
|
|
42808
|
+
* rulesync's — it is what rulesync wrote before the option was turned on, and
|
|
42809
|
+
* keeping it would duplicate that content outside the fence — so only the
|
|
42810
|
+
* fenced body is written. Hand edits belong outside the fence from then on.
|
|
42811
|
+
*
|
|
42812
|
+
* When the generated content starts with frontmatter, the existing file's
|
|
42813
|
+
* leading frontmatter is rulesync's too and is replaced rather than kept.
|
|
42814
|
+
*/
|
|
42815
|
+
const spliceRuleManagedBlock = ({ existingContent, generatedContent }) => {
|
|
42816
|
+
const generated = splitLeadingFrontmatter(generatedContent);
|
|
42817
|
+
const body = generated.rest.replace(/^\n+/, "");
|
|
42818
|
+
const block = `${RULE_MANAGED_BLOCK_START}\n${body}${body === "" || body.endsWith("\n") ? "" : "\n"}${RULE_MANAGED_BLOCK_END}\n`;
|
|
42819
|
+
if (existingContent === null) return generated.frontmatter + block;
|
|
42820
|
+
const eol = (text) => existingContent.includes("\r\n") ? text.replaceAll("\n", "\r\n") : text;
|
|
42821
|
+
const existing = generated.frontmatter === "" ? existingContent : splitLeadingFrontmatter(existingContent).rest;
|
|
42822
|
+
const fence = findFence(existing);
|
|
42823
|
+
if (fence === void 0) return eol(generated.frontmatter + block);
|
|
42824
|
+
const before = existing.slice(0, fence.startLineBegin);
|
|
42825
|
+
let after = existing.slice(fence.endLineEnd);
|
|
42826
|
+
if (fence.endLineEnd === existing.length && !existing.endsWith("\n")) after = "";
|
|
42827
|
+
return eol(generated.frontmatter) + before + eol(block) + after;
|
|
42828
|
+
};
|
|
42829
|
+
/**
|
|
42830
|
+
* `content` with its first complete fence (marker lines included) taken out,
|
|
42831
|
+
* or `undefined` when it has none. Used when a root rule file stops being
|
|
42832
|
+
* generated: the fenced block is rulesync's to remove, the rest is not.
|
|
42833
|
+
*/
|
|
42834
|
+
const removeRuleManagedBlock = (content) => {
|
|
42835
|
+
const fence = findFence(content);
|
|
42836
|
+
if (fence === void 0) return;
|
|
42837
|
+
return content.slice(0, fence.startLineBegin) + content.slice(fence.endLineEnd);
|
|
42838
|
+
};
|
|
42839
|
+
/**
|
|
42840
|
+
* The text inside the first complete fence (without the marker lines), or
|
|
42841
|
+
* `undefined` when `content` has none. `import` keeps only this part so
|
|
42842
|
+
* hand-written content outside the fence is not copied into the rulesync
|
|
42843
|
+
* source, where the next `generate` would write it a second time.
|
|
42844
|
+
*/
|
|
42845
|
+
const extractRuleManagedBlock = (content) => {
|
|
42846
|
+
const fence = findFence(content);
|
|
42847
|
+
if (fence === void 0) return;
|
|
42848
|
+
return content.slice(fence.startLineEnd, fence.endLineBegin);
|
|
42849
|
+
};
|
|
41458
42850
|
// src/features/shared/opencode-family-mcp-tool-keys.ts
|
|
41459
42851
|
/**
|
|
41460
42852
|
* MCP tool naming shared by OpenCode and its forks (Kilo, MiMo Code):
|
|
@@ -43129,6 +44521,46 @@ var ToolRule = class extends ToolFile {
|
|
|
43129
44521
|
this.description = description;
|
|
43130
44522
|
this.globs = globs;
|
|
43131
44523
|
}
|
|
44524
|
+
/**
|
|
44525
|
+
* Whether the write phase fences the generated content and keeps what the
|
|
44526
|
+
* existing file holds outside the fence (`preserveUnmanagedRuleContent`).
|
|
44527
|
+
* Set by the rules processor on the root rule files it emits.
|
|
44528
|
+
*/
|
|
44529
|
+
preservesUnmanagedContent = false;
|
|
44530
|
+
/** See {@link ToolRule.preservesUnmanagedContent}. */
|
|
44531
|
+
enableUnmanagedContentPreservation() {
|
|
44532
|
+
this.preservesUnmanagedContent = true;
|
|
44533
|
+
}
|
|
44534
|
+
isPreservingUnmanagedContent() {
|
|
44535
|
+
return this.preservesUnmanagedContent;
|
|
44536
|
+
}
|
|
44537
|
+
composeWrittenContent({ existingContent, generatedContent }) {
|
|
44538
|
+
if (!this.preservesUnmanagedContent) return generatedContent;
|
|
44539
|
+
return spliceRuleManagedBlock({
|
|
44540
|
+
existingContent,
|
|
44541
|
+
generatedContent
|
|
44542
|
+
});
|
|
44543
|
+
}
|
|
44544
|
+
keepsContentOnRemoval() {
|
|
44545
|
+
return this.preservesUnmanagedContent;
|
|
44546
|
+
}
|
|
44547
|
+
/**
|
|
44548
|
+
* Under `preserveUnmanagedRuleContent`, removing a root rule file takes out
|
|
44549
|
+
* only the fenced block and keeps the hand-written rest; a file with nothing
|
|
44550
|
+
* else left is deleted. A file without a fence is not rulesync's any more —
|
|
44551
|
+
* the hand-written rest of an earlier removal, or a file written before the
|
|
44552
|
+
* option was on — so it is left in place.
|
|
44553
|
+
*/
|
|
44554
|
+
composeContentAfterRemoval({ existingContent }) {
|
|
44555
|
+
if (!this.preservesUnmanagedContent) return { action: "delete" };
|
|
44556
|
+
const rest = removeRuleManagedBlock(existingContent);
|
|
44557
|
+
if (rest === void 0) return { action: "keep" };
|
|
44558
|
+
if (rest.trim() === "") return { action: "delete" };
|
|
44559
|
+
return {
|
|
44560
|
+
action: "rewrite",
|
|
44561
|
+
content: rest
|
|
44562
|
+
};
|
|
44563
|
+
}
|
|
43132
44564
|
static getSettablePaths(_options = {}) {
|
|
43133
44565
|
throw new Error("Please implement this method in the subclass.");
|
|
43134
44566
|
}
|
|
@@ -53213,6 +54645,23 @@ const resolveBooleanRulesOption = ({ options, key }) => {
|
|
|
53213
54645
|
if (!parsed.success) throw new Error(`Invalid options for rules feature: ${parsed.error.message}. \`${key}\` must be a boolean.`);
|
|
53214
54646
|
return parsed.data[key] ?? true;
|
|
53215
54647
|
};
|
|
54648
|
+
/**
|
|
54649
|
+
* Resolve the `include` rules option: the names of the rules this target
|
|
54650
|
+
* receives, or `undefined` when the option is unset (every rule is eligible).
|
|
54651
|
+
*/
|
|
54652
|
+
const resolveRuleIncludeOption = (options) => {
|
|
54653
|
+
if (!options) return void 0;
|
|
54654
|
+
const parsed = zod_mini.z.looseObject({ include: zod_mini.z.optional(zod_mini.z.array(zod_mini.z.string())) }).safeParse(options);
|
|
54655
|
+
if (!parsed.success) throw new Error(`Invalid options for rules feature: ${parsed.error.message}. \`include\` must be an array of rule names.`);
|
|
54656
|
+
return parsed.data.include;
|
|
54657
|
+
};
|
|
54658
|
+
/**
|
|
54659
|
+
* The name the `include` rules option selects a rule by: its path under
|
|
54660
|
+
* `rules/` (or `rules/.curated/`) without the `.md` extension, normalized the
|
|
54661
|
+
* same way as `sources[].rules`. A rule at the top of the directory is matched
|
|
54662
|
+
* by its file name alone, e.g. `git-safety` for `git-safety.md`.
|
|
54663
|
+
*/
|
|
54664
|
+
const getRuleSelectionName = (rule) => normalizeRuleFilterName(toPosixPath(rule.getRelativeFilePath()));
|
|
53216
54665
|
const allToolTargetKeys$1 = [...toolRuleFactories.keys()];
|
|
53217
54666
|
const rulesProcessorToolTargets = allToolTargetKeys$1.filter((target) => {
|
|
53218
54667
|
return toolRuleFactories.get(target)?.meta.supportsProject !== false;
|
|
@@ -53255,6 +54704,24 @@ const findFilesWithFallback = async (primaryFilePaths, alternativeRoots, buildAl
|
|
|
53255
54704
|
* delete generated files it can no longer regenerate and report success.
|
|
53256
54705
|
*/
|
|
53257
54706
|
const rootRelativeGlob = (...segments) => node_path.posix.join(...segments.filter((segment) => segment !== void 0).map(toPosixPath));
|
|
54707
|
+
/**
|
|
54708
|
+
* Keep only the fenced part of a rule a `preserveUnmanagedRuleContent` run
|
|
54709
|
+
* wrote, so `import` does not copy hand-written content outside the fence into
|
|
54710
|
+
* the rulesync source, where the next `generate` would write it a second time
|
|
54711
|
+
* inside the fence. A rule without a complete fence is returned unchanged.
|
|
54712
|
+
*/
|
|
54713
|
+
const extractFencedRule = (rulesyncRule) => {
|
|
54714
|
+
const fenced = extractRuleManagedBlock(rulesyncRule.getBody());
|
|
54715
|
+
if (fenced === void 0) return rulesyncRule;
|
|
54716
|
+
return new RulesyncRule({
|
|
54717
|
+
outputRoot: rulesyncRule.getOutputRoot(),
|
|
54718
|
+
relativeDirPath: rulesyncRule.getRelativeDirPath(),
|
|
54719
|
+
relativeFilePath: rulesyncRule.getRelativeFilePath(),
|
|
54720
|
+
frontmatter: rulesyncRule.getFrontmatter(),
|
|
54721
|
+
body: fenced.trim(),
|
|
54722
|
+
validate: false
|
|
54723
|
+
});
|
|
54724
|
+
};
|
|
53258
54725
|
const isRootRule = (rule) => Boolean(rule.getFrontmatter().root || rule.getFrontmatter().localRoot);
|
|
53259
54726
|
var RulesProcessor = class extends FeatureProcessor {
|
|
53260
54727
|
toolTarget;
|
|
@@ -53271,7 +54738,8 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
53271
54738
|
skills;
|
|
53272
54739
|
featureOptions;
|
|
53273
54740
|
deleteOrphans;
|
|
53274
|
-
|
|
54741
|
+
preserveUnmanagedContent;
|
|
54742
|
+
constructor({ outputRoot = process.cwd(), inputRoots, toolTarget, simulateCommands = false, simulateSubagents = false, simulateSkills = false, language, deriveSubprojectPathFromGlobs = false, global = false, getFactory = defaultGetFactory$3, skills, featureOptions, delete: deleteOrphans = false, preserveUnmanagedContent = false, dryRun = false, logger }) {
|
|
53275
54743
|
super({
|
|
53276
54744
|
outputRoot,
|
|
53277
54745
|
inputRoots,
|
|
@@ -53291,6 +54759,7 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
53291
54759
|
this.skills = skills;
|
|
53292
54760
|
this.featureOptions = featureOptions;
|
|
53293
54761
|
this.deleteOrphans = deleteOrphans;
|
|
54762
|
+
this.preserveUnmanagedContent = preserveUnmanagedContent;
|
|
53294
54763
|
}
|
|
53295
54764
|
async convertRulesyncFilesToToolFiles(rulesyncFiles) {
|
|
53296
54765
|
const rulesyncRules = rulesyncFiles.filter((file) => file instanceof RulesyncRule);
|
|
@@ -53334,6 +54803,9 @@ var RulesProcessor = class extends FeatureProcessor {
|
|
|
53334
54803
|
});
|
|
53335
54804
|
extraFiles.push(...await this.buildLanguageSettingsFiles());
|
|
53336
54805
|
const outputFiles = [...toolRules, ...extraFiles];
|
|
54806
|
+
if (this.preserveUnmanagedContent) {
|
|
54807
|
+
for (const file of outputFiles) if (file instanceof ToolRule && file.isRoot()) file.enableUnmanagedContentPreservation();
|
|
54808
|
+
}
|
|
53337
54809
|
this.warnForOutputPathCollisions({
|
|
53338
54810
|
outputFiles,
|
|
53339
54811
|
convertedRules
|
|
@@ -53768,10 +55240,10 @@ As this project's AI coding tool, you must follow the additional conventions bel
|
|
|
53768
55240
|
async convertToolFilesToRulesyncFiles(toolFiles) {
|
|
53769
55241
|
const toolRules = toolFiles.filter((file) => file instanceof ToolRule);
|
|
53770
55242
|
const rulesyncRules = toolRules.map((toolRule) => {
|
|
53771
|
-
if (toolRule.isLocalRoot()) return toolRule.toLocalRootRulesyncRule({ targets: [this.toolTarget] });
|
|
55243
|
+
if (toolRule.isLocalRoot()) return this.withoutUnmanagedContent(toolRule.toLocalRootRulesyncRule({ targets: [this.toolTarget] }));
|
|
53772
55244
|
return this.withoutLanguageBlock({
|
|
53773
55245
|
toolRule,
|
|
53774
|
-
rulesyncRule: toolRule.toRulesyncRule()
|
|
55246
|
+
rulesyncRule: this.withoutUnmanagedContent(toolRule.toRulesyncRule())
|
|
53775
55247
|
});
|
|
53776
55248
|
});
|
|
53777
55249
|
const claimedBy = /* @__PURE__ */ new Map();
|
|
@@ -53788,6 +55260,13 @@ As this project's AI coding tool, you must follow the additional conventions bel
|
|
|
53788
55260
|
return rulesyncRules;
|
|
53789
55261
|
}
|
|
53790
55262
|
/**
|
|
55263
|
+
* See {@link extractFencedRule}. Only under `preserveUnmanagedRuleContent`:
|
|
55264
|
+
* without it a file that merely quotes the markers is imported whole.
|
|
55265
|
+
*/
|
|
55266
|
+
withoutUnmanagedContent(rulesyncRule) {
|
|
55267
|
+
return this.preserveUnmanagedContent ? extractFencedRule(rulesyncRule) : rulesyncRule;
|
|
55268
|
+
}
|
|
55269
|
+
/**
|
|
53791
55270
|
* Drop the language block a previous `generate` appended, so that importing
|
|
53792
55271
|
* a generated root file and generating again yields one block, not two.
|
|
53793
55272
|
* Every imported rule is checked, not just root ones: Cursor and the
|
|
@@ -53909,10 +55388,15 @@ As this project's AI coding tool, you must follow the additional conventions bel
|
|
|
53909
55388
|
* copy (case-insensitive, matching the intra-root collision handling).
|
|
53910
55389
|
*/
|
|
53911
55390
|
async loadRulesyncFiles() {
|
|
53912
|
-
const rulesyncRules = await this.loadMergedRulesyncRules();
|
|
53913
55391
|
const factory = this.getFactory(this.toolTarget);
|
|
55392
|
+
const mergedRules = await this.loadMergedRulesyncRules();
|
|
55393
|
+
const rulesyncRules = this.selectIncludedRules({
|
|
55394
|
+
rules: mergedRules,
|
|
55395
|
+
factory
|
|
55396
|
+
});
|
|
53914
55397
|
const targetedRootRules = rulesyncRules.filter((rule) => rule.getFrontmatter().root).filter((rule) => factory.class.isTargetedByRulesyncRule(rule));
|
|
53915
|
-
|
|
55398
|
+
const rootRuleLeftOutByInclude = mergedRules.some((rule) => rule.getFrontmatter().root && factory.class.isTargetedByRulesyncRule(rule) && !rulesyncRules.includes(rule));
|
|
55399
|
+
if (targetedRootRules.length === 0 && rulesyncRules.length > 0 && !rootRuleLeftOutByInclude) this.logger.warn(`No root rulesync rule file found for target '${this.toolTarget}'. Consider adding 'root: true' to one of your rule files in ${RULESYNC_RULES_RELATIVE_DIR_PATH}.`);
|
|
53916
55400
|
const targetedLocalRootRules = rulesyncRules.filter((rule) => rule.getFrontmatter().localRoot).filter((rule) => factory.class.isTargetedByRulesyncRule(rule));
|
|
53917
55401
|
if (targetedLocalRootRules.length > 1) throw new Error(`Multiple localRoot rules found for target '${this.toolTarget}': ${formatRulePaths(targetedLocalRootRules)}. Only one rule can have localRoot: true`);
|
|
53918
55402
|
if (targetedLocalRootRules.length > 0 && targetedRootRules.length === 0) throw new Error(`localRoot: true requires a root: true rule to exist for target '${this.toolTarget}' (found in ${formatRulePaths(targetedLocalRootRules)})`);
|
|
@@ -53930,6 +55414,28 @@ As this project's AI coding tool, you must follow the additional conventions bel
|
|
|
53930
55414
|
return [...targetedRootRules, ...nonRootRules];
|
|
53931
55415
|
}
|
|
53932
55416
|
/**
|
|
55417
|
+
* Narrow the rules to the ones the target's `include` rules option names.
|
|
55418
|
+
* The option is a pure narrowing filter: a named rule still has to target
|
|
55419
|
+
* this tool through its `targets` frontmatter, which is checked afterwards
|
|
55420
|
+
* as for any other rule. A name that matches no rule (local or curated) is
|
|
55421
|
+
* an error, so a renamed or removed rule does not silently disappear from
|
|
55422
|
+
* the target. `["*"]` selects every rule, as in `sources[].rules`.
|
|
55423
|
+
*/
|
|
55424
|
+
selectIncludedRules({ rules, factory, warn = true }) {
|
|
55425
|
+
const include = resolveRuleIncludeOption(this.featureOptions);
|
|
55426
|
+
if (include === void 0) return rules;
|
|
55427
|
+
const names = [...new Set(include.map(normalizeRuleFilterName))];
|
|
55428
|
+
if (isWildcardSelection(names)) return rules;
|
|
55429
|
+
const availableNames = new Set(rules.map(getRuleSelectionName));
|
|
55430
|
+
const unknownNames = names.filter((name) => !availableNames.has(name));
|
|
55431
|
+
if (unknownNames.length > 0) throw new Error(`Unknown rule name${unknownNames.length > 1 ? "s" : ""} in the \`include\` rules option of target '${this.toolTarget}': ${unknownNames.map(quoteForLog).join(", ")}. Each name must match a rule file under ${RULESYNC_RULES_RELATIVE_DIR_PATH} (including fetched rules in .curated/), without the .md extension, e.g. "git-safety" for git-safety.md.`);
|
|
55432
|
+
const selectedNames = new Set(names);
|
|
55433
|
+
const selectedRules = rules.filter((rule) => selectedNames.has(getRuleSelectionName(rule)));
|
|
55434
|
+
const excludedByFrontmatter = selectedRules.filter((rule) => !factory.class.isTargetedByRulesyncRule(rule));
|
|
55435
|
+
if (warn && excludedByFrontmatter.length > 0) this.logger.warn(`The \`include\` rules option of target '${this.toolTarget}' names rules whose \`targets\` frontmatter excludes it, so they are not generated: ${formatRulePaths(excludedByFrontmatter)}`);
|
|
55436
|
+
return selectedRules;
|
|
55437
|
+
}
|
|
55438
|
+
/**
|
|
53933
55439
|
* Align the rules with each other through the tool's `alignRulesyncRules`
|
|
53934
55440
|
* hook, printing its warnings unless `warn` is off.
|
|
53935
55441
|
*/
|
|
@@ -53980,7 +55486,16 @@ As this project's AI coding tool, you must follow the additional conventions bel
|
|
|
53980
55486
|
async warnForFoldImportDuplicationRisk() {
|
|
53981
55487
|
const factory = this.getFactory(this.toolTarget);
|
|
53982
55488
|
if (factory.meta.collisionPolicy !== "fold") return;
|
|
53983
|
-
const
|
|
55489
|
+
const loadedRules = await this.loadMergedRulesyncRules();
|
|
55490
|
+
let includedRules = loadedRules;
|
|
55491
|
+
try {
|
|
55492
|
+
includedRules = this.selectIncludedRules({
|
|
55493
|
+
rules: loadedRules,
|
|
55494
|
+
factory,
|
|
55495
|
+
warn: false
|
|
55496
|
+
});
|
|
55497
|
+
} catch {}
|
|
55498
|
+
const targetedRules = this.alignRulesyncRules(includedRules, { warn: false }).filter((rule) => factory.class.isTargetedByRulesyncRule(rule));
|
|
53984
55499
|
let includeLocalRoot = !this.global;
|
|
53985
55500
|
try {
|
|
53986
55501
|
includeLocalRoot &&= resolveBooleanRulesOption({
|
|
@@ -54045,6 +55560,14 @@ As this project's AI coding tool, you must follow the additional conventions bel
|
|
|
54045
55560
|
* Load tool-specific rule configurations and parse them into ToolRule instances
|
|
54046
55561
|
*/
|
|
54047
55562
|
async loadToolFiles({ forDeletion = false } = {}) {
|
|
55563
|
+
const toolFiles = await this.loadToolFilesUnmarked({ forDeletion });
|
|
55564
|
+
if (forDeletion && this.preserveUnmanagedContent) {
|
|
55565
|
+
const { localRootFileName } = this.getFactory(this.toolTarget).meta;
|
|
55566
|
+
for (const file of toolFiles) if (file instanceof ToolRule && (file.isRoot() || file.isLocalRoot() || localRootFileName !== void 0 && file.getRelativeFilePath() === localRootFileName)) file.enableUnmanagedContentPreservation();
|
|
55567
|
+
}
|
|
55568
|
+
return toolFiles;
|
|
55569
|
+
}
|
|
55570
|
+
async loadToolFilesUnmarked({ forDeletion }) {
|
|
54048
55571
|
try {
|
|
54049
55572
|
const factory = this.getFactory(this.toolTarget);
|
|
54050
55573
|
const settablePaths = factory.class.getSettablePaths({ global: this.global });
|
|
@@ -57644,7 +59167,10 @@ function anchorDotPaths({ command, projectDirVar }) {
|
|
|
57644
59167
|
* first word, so interpreter-prefixed commands (`python3 "$VAR/x.py"`,
|
|
57645
59168
|
* `node $VAR/x.js`) do not leak a tool-specific variable into targets that do
|
|
57646
59169
|
* not define it. The recognized forms, each followed by `/`, are `"$VAR"`,
|
|
57647
|
-
* `"${VAR}"`, `$VAR` and `${VAR}
|
|
59170
|
+
* `"${VAR}"`, `$VAR` and `${VAR}`, plus the fail-closed `${VAR:?}` in either
|
|
59171
|
+
* spelling when `acceptsFailClosedForm` is set (for a tool that writes that
|
|
59172
|
+
* form itself; elsewhere a hand-written `${VAR:?}` is left as written, so it
|
|
59173
|
+
* keeps failing closed):
|
|
57648
59174
|
*
|
|
57649
59175
|
* - a quote around the whole path is kept, so a path containing spaces stays
|
|
57650
59176
|
* one word (`"$VAR/my hook.sh"` becomes `"./my hook.sh"`);
|
|
@@ -57669,9 +59195,9 @@ function anchorDotPaths({ command, projectDirVar }) {
|
|
|
57669
59195
|
* later words are not converted (see `convertsLaterWords`) or that starts
|
|
57670
59196
|
* with another variable — every occurrence after the first word.
|
|
57671
59197
|
*/
|
|
57672
|
-
function importProjectDirVariable({ command, projectDirVar, firstWordOnly = false }) {
|
|
59198
|
+
function importProjectDirVariable({ command, projectDirVar, firstWordOnly = false, acceptsFailClosedForm = false }) {
|
|
57673
59199
|
const escapedName = escapeRegExp(projectDirVar.replace(/^\$/, ""));
|
|
57674
|
-
const variable = `\\$(?:${escapedName}|\\{${escapedName}\\})`;
|
|
59200
|
+
const variable = `\\$(?:${escapedName}|\\{${escapedName}${acceptsFailClosedForm ? "(?::\\?)?" : ""}\\})`;
|
|
57675
59201
|
const pattern = new RegExp(`(?:"${variable}"/(["']?)|${variable}/)`, "g");
|
|
57676
59202
|
const leading = command.length - command.trimStart().length;
|
|
57677
59203
|
const inFirstWord = (offset) => offset === leading || offset === leading + 1 && command.charAt(leading) === "\"";
|
|
@@ -57782,6 +59308,15 @@ function groupDefinitionsByMatcher({ definitions, eventName, converterConfig, wa
|
|
|
57782
59308
|
}
|
|
57783
59309
|
return byMatcher;
|
|
57784
59310
|
}
|
|
59311
|
+
/**
|
|
59312
|
+
* The project directory variable as generate writes it into a shell command:
|
|
59313
|
+
* `$DEVIN_PLUGIN_ROOT` -> `${DEVIN_PLUGIN_ROOT:?}` for a tool that opts into
|
|
59314
|
+
* {@link ToolHooksConverterConfig.failsClosedOnEmptyProjectDirVar}.
|
|
59315
|
+
*/
|
|
59316
|
+
function emittedProjectDirVar(converterConfig) {
|
|
59317
|
+
const { projectDirVar } = converterConfig;
|
|
59318
|
+
return converterConfig.failsClosedOnEmptyProjectDirVar ? `\${${projectDirVar.replace(/^\$/, "")}:?}` : projectDirVar;
|
|
59319
|
+
}
|
|
57785
59320
|
/** `$CLAUDE_PROJECT_DIR` -> `${CLAUDE_PROJECT_DIR}`, the form the tool substitutes. */
|
|
57786
59321
|
function bracePlaceholder(projectDirVar) {
|
|
57787
59322
|
return `\${${projectDirVar.replace(/^\$/, "")}}`;
|
|
@@ -57829,12 +59364,12 @@ function applyCommandPrefix({ def, converterConfig }) {
|
|
|
57829
59364
|
converterConfig
|
|
57830
59365
|
}) ? command : anchorDotPaths({
|
|
57831
59366
|
command,
|
|
57832
|
-
projectDirVar: converterConfig
|
|
59367
|
+
projectDirVar: emittedProjectDirVar(converterConfig)
|
|
57833
59368
|
});
|
|
57834
59369
|
if (!shouldPrefix || typeof trimmedCommand !== "string") return typeof def.command === "string" ? anchorInline(def.command) : def.command;
|
|
57835
59370
|
const relativeCommand = trimmedCommand.replace(/^(["'])\.\//, "$1").replace(/^\.\//, "");
|
|
57836
59371
|
if (isExecForm) return `${bracePlaceholder(converterConfig.projectDirVar)}/${stripSurroundingQuotes(relativeCommand)}`;
|
|
57837
|
-
return anchorInline(`"${converterConfig
|
|
59372
|
+
return anchorInline(`"${emittedProjectDirVar(converterConfig)}"/${relativeCommand}`);
|
|
57838
59373
|
}
|
|
57839
59374
|
/** Whether a field restricted to some events applies on this one. */
|
|
57840
59375
|
function isEventApplicable({ events, eventName }) {
|
|
@@ -58484,7 +60019,8 @@ function stripCommandPrefix({ command, args, shell, converterConfig, warn }) {
|
|
|
58484
60019
|
}) || !runsInPosixShell({
|
|
58485
60020
|
shell,
|
|
58486
60021
|
converterConfig
|
|
58487
|
-
})
|
|
60022
|
+
}),
|
|
60023
|
+
acceptsFailClosedForm: converterConfig.failsClosedOnEmptyProjectDirVar ?? false
|
|
58488
60024
|
});
|
|
58489
60025
|
stripped = result.command;
|
|
58490
60026
|
if (warn && result.unrestored && !converterConfig.stripsProjectDirVarOnImportOnly) warn(`Hook command ${quoteValueForWarning(cmd)} was imported as ${quoteValueForWarning(stripped)}: a ${variable} path that is not a script the command runs becomes relative to the hook's working directory and is not restored on generate. Put the exact command in a tool-specific hooks override (such as "claudecode.hooks") to keep the variable.`);
|
|
@@ -63125,7 +64661,9 @@ var DevinHooks = class extends ToolHooks {
|
|
|
63125
64661
|
* anchored to the plugin install directory rather than run against the
|
|
63126
64662
|
* consumer's workspace. Devin CLI v3000.5.20+ sets `DEVIN_PLUGIN_ROOT` in the
|
|
63127
64663
|
* environment of hooks contributed by a plugin, and runs `command` as a shell
|
|
63128
|
-
* command, so the quoted `"$DEVIN_PLUGIN_ROOT"/...` form expands there.
|
|
64664
|
+
* command, so the quoted `"${DEVIN_PLUGIN_ROOT:?}"/...` form expands there.
|
|
64665
|
+
* The `:?` makes an older CLI, which leaves the variable empty, stop the hook
|
|
64666
|
+
* with an error rather than run `/scripts/...` from the filesystem root. Bare
|
|
63129
64667
|
* commands such as `npx prettier --write` are left intact.
|
|
63130
64668
|
*
|
|
63131
64669
|
* `DEVIN_PLUGIN_ROOT` is chosen over the shorter `PLUGIN_ROOT` (v3000.11.92+)
|
|
@@ -63139,6 +64677,7 @@ var DevinHooks = class extends ToolHooks {
|
|
|
63139
64677
|
const DEVIN_PLUGIN_CONVERTER_CONFIG = {
|
|
63140
64678
|
...DEVIN_CONVERTER_CONFIG,
|
|
63141
64679
|
projectDirVar: "$DEVIN_PLUGIN_ROOT",
|
|
64680
|
+
failsClosedOnEmptyProjectDirVar: true,
|
|
63142
64681
|
prefixDotRelativeCommandsOnly: true,
|
|
63143
64682
|
importedProjectDirVarAliases: ["$PLUGIN_ROOT", "$CLAUDE_PLUGIN_ROOT"]
|
|
63144
64683
|
};
|
|
@@ -63146,7 +64685,7 @@ const DEVIN_PLUGIN_CONVERTER_CONFIG = {
|
|
|
63146
64685
|
* Hooks inside a Devin plugin bundle (`<plugin>/hooks.json`). The file is the
|
|
63147
64686
|
* same bare event map as `.devin/hooks.v1.json` (no `hooks` wrapper key), as
|
|
63148
64687
|
* in Cognition's plugin templates. Unlike the `devin` target, `./`-relative
|
|
63149
|
-
* commands are anchored to `$DEVIN_PLUGIN_ROOT` (see
|
|
64688
|
+
* commands are anchored to `${DEVIN_PLUGIN_ROOT:?}` (see
|
|
63150
64689
|
* `DEVIN_PLUGIN_CONVERTER_CONFIG`).
|
|
63151
64690
|
*
|
|
63152
64691
|
* @see https://docs.devin.ai/cli/extensibility/plugins/overview
|
|
@@ -75152,7 +76691,8 @@ var CodewhaleMcp = class CodewhaleMcp extends ToolMcp {
|
|
|
75152
76691
|
}
|
|
75153
76692
|
static async fromRulesyncMcp({ outputRoot = process.cwd(), rulesyncMcp, validate = true, global = false, logger }) {
|
|
75154
76693
|
const paths = this.getSettablePaths({ global });
|
|
75155
|
-
const
|
|
76694
|
+
const filePath = (0, node_path.join)(outputRoot, paths.relativeDirPath, paths.relativeFilePath);
|
|
76695
|
+
const existingContent = await readFileContentOrNull(filePath);
|
|
75156
76696
|
const json = existingContent === null ? {} : parseCodewhaleMcpConfig({
|
|
75157
76697
|
fileContent: existingContent,
|
|
75158
76698
|
relativePath: (0, node_path.join)(paths.relativeDirPath, paths.relativeFilePath)
|
|
@@ -75165,7 +76705,11 @@ var CodewhaleMcp = class CodewhaleMcp extends ToolMcp {
|
|
|
75165
76705
|
[serversKey]: mcpServers
|
|
75166
76706
|
};
|
|
75167
76707
|
const fileContent = JSON.stringify(codewhaleConfig, null, 2);
|
|
75168
|
-
if (!global &&
|
|
76708
|
+
if (!global && !fileContentsEquivalent({
|
|
76709
|
+
filePath,
|
|
76710
|
+
expected: fileContent,
|
|
76711
|
+
existing: existingContent
|
|
76712
|
+
})) logger?.info(`Codewhale MCP: ${(0, node_path.join)(paths.relativeDirPath, paths.relativeFilePath)} changed, so Codewhale loads none of its servers until you run /mcp review and /mcp approve <digest> again.`);
|
|
75169
76713
|
return new CodewhaleMcp({
|
|
75170
76714
|
outputRoot,
|
|
75171
76715
|
relativeDirPath: paths.relativeDirPath,
|
|
@@ -96076,20 +97620,32 @@ function restrictedByAllToolsCategory(config) {
|
|
|
96076
97620
|
record: config.permission,
|
|
96077
97621
|
key: "*"
|
|
96078
97622
|
}) ?? {}).filter(([pattern, action]) => !/\s/.test(pattern) && (action === "deny" || action === "ask" && pattern !== "*")).map(([pattern]) => pattern).find((pattern) => {
|
|
96079
|
-
|
|
96080
|
-
|
|
96081
|
-
|
|
96082
|
-
|
|
96083
|
-
|
|
96084
|
-
|
|
96085
|
-
|
|
97623
|
+
return carveOutCheckSpellings(pattern.toLowerCase()).some((spelling) => {
|
|
97624
|
+
if (namesGitDirectory(spelling)) return true;
|
|
97625
|
+
const matches = createShadowingRestrictionsTest([{
|
|
97626
|
+
pattern: spelling.replace(/^\.?\//, ""),
|
|
97627
|
+
fromAllToolsCategory: true
|
|
97628
|
+
}]);
|
|
97629
|
+
return GIT_WRITTEN_PATHS.some((path) => matches(path).length > 0);
|
|
97630
|
+
});
|
|
96086
97631
|
});
|
|
96087
97632
|
}
|
|
97633
|
+
function carveOutCheckSpellings(pattern) {
|
|
97634
|
+
const slashed = pattern.replaceAll("\\", "/");
|
|
97635
|
+
return slashed === pattern ? [pattern] : [pattern, slashed];
|
|
97636
|
+
}
|
|
96088
97637
|
function isRestrictedInWorkspaceRootTable({ pattern, table }) {
|
|
96089
97638
|
const readRules = {};
|
|
96090
97639
|
for (const [tablePattern, access] of Object.entries(table)) {
|
|
96091
97640
|
if (tablePattern === pattern) continue;
|
|
96092
|
-
|
|
97641
|
+
if (access === "write") {
|
|
97642
|
+
readRules[tablePattern] = "allow";
|
|
97643
|
+
continue;
|
|
97644
|
+
}
|
|
97645
|
+
for (const spelling of carveOutCheckSpellings(tablePattern)) {
|
|
97646
|
+
if (spelling === pattern) return true;
|
|
97647
|
+
readRules[spelling] = "deny";
|
|
97648
|
+
}
|
|
96093
97649
|
}
|
|
96094
97650
|
return isCoveredByReadRestriction({
|
|
96095
97651
|
pattern,
|
|
@@ -114970,7 +116526,8 @@ function buildRulesStrategy(ctx) {
|
|
|
114970
116526
|
global,
|
|
114971
116527
|
dryRun,
|
|
114972
116528
|
logger,
|
|
114973
|
-
language: config.getLanguage()
|
|
116529
|
+
language: config.getLanguage(),
|
|
116530
|
+
preserveUnmanagedContent: config.getPreserveUnmanagedRuleContent()
|
|
114974
116531
|
}),
|
|
114975
116532
|
loadSource: (p) => p.loadToolFiles(),
|
|
114976
116533
|
toRulesync: (p, files) => p.convertToolFilesToRulesyncFiles(files),
|
|
@@ -115607,7 +117164,8 @@ const RETIREMENT_SPECS = {
|
|
|
115607
117164
|
...params,
|
|
115608
117165
|
simulateCommands: config.getSimulateCommands(),
|
|
115609
117166
|
simulateSubagents: config.getSimulateSubagents(),
|
|
115610
|
-
simulateSkills: config.getSimulateSkills()
|
|
117167
|
+
simulateSkills: config.getSimulateSkills(),
|
|
117168
|
+
preserveUnmanagedContent: config.getPreserveUnmanagedRuleContent()
|
|
115611
117169
|
}),
|
|
115612
117170
|
unownedPaths: ({ toolTarget, outputRoot }) => (toolRuleFactories.get(toolTarget)?.class.getSettablePaths().alternativeRoots ?? []).map((alt) => (0, node_path.resolve)(outputRoot, alt.relativeDirPath, alt.relativeFilePath))
|
|
115613
117171
|
},
|
|
@@ -115731,14 +117289,23 @@ function scheduleRetiredTargetSweeps({ config, logger, sweepPlan, sourceLoadFail
|
|
|
115731
117289
|
sweepPlan,
|
|
115732
117290
|
unownedPaths
|
|
115733
117291
|
}),
|
|
115734
|
-
reportDeleted: () => processor.getRemovedPaths()
|
|
117292
|
+
reportDeleted: () => processor.getRemovedPaths(),
|
|
117293
|
+
reportWritten: () => processor.getSweepWrites()
|
|
115735
117294
|
});
|
|
115736
117295
|
} else {
|
|
115737
117296
|
const processor = spec.create(params, config);
|
|
117297
|
+
const ownershipProcessor = config.getPreserveUnownedSkills() ? spec.create({
|
|
117298
|
+
...params,
|
|
117299
|
+
logger: new ConsoleLogger({
|
|
117300
|
+
verbose: false,
|
|
117301
|
+
silent: true
|
|
117302
|
+
})
|
|
117303
|
+
}, config) : void 0;
|
|
115738
117304
|
featurePlan.defer({
|
|
115739
117305
|
sweep: () => sweepDirs({
|
|
115740
117306
|
processor,
|
|
115741
|
-
sweepPlan
|
|
117307
|
+
sweepPlan,
|
|
117308
|
+
ownershipProcessor
|
|
115742
117309
|
}),
|
|
115743
117310
|
reportDeleted: () => processor.getRemovedPaths()
|
|
115744
117311
|
});
|
|
@@ -115755,18 +117322,36 @@ async function sweepFiles({ processor, sweepPlan, unownedPaths }) {
|
|
|
115755
117322
|
const present = await Promise.all(candidates.map((f) => fileExists(f.getFilePath())));
|
|
115756
117323
|
return await processor.removeOrphanAiFiles(candidates.filter((_, index) => present[index]), []) > 0;
|
|
115757
117324
|
}
|
|
115758
|
-
async function sweepDirs({ processor, sweepPlan }) {
|
|
115759
|
-
|
|
117325
|
+
async function sweepDirs({ processor, sweepPlan, ownershipProcessor }) {
|
|
117326
|
+
const isOwned = ownershipProcessor ? await loadSourceOwnedPaths(ownershipProcessor) : void 0;
|
|
117327
|
+
return await processor.removeOrphanAiDirs((await sweepPlan.rejectClaimed({
|
|
115760
117328
|
items: await processor.loadToolDirsToDelete(),
|
|
115761
117329
|
getPath: (d) => d.getDirPath()
|
|
115762
|
-
}), []) + await processor.removeOrphanFlatFiles({
|
|
115763
|
-
existingFlatFiles: await sweepPlan.rejectClaimed({
|
|
117330
|
+
})).filter((d) => isOwned?.(d.getDirPath()) ?? true), []) + await processor.removeOrphanFlatFiles({
|
|
117331
|
+
existingFlatFiles: (await sweepPlan.rejectClaimed({
|
|
115764
117332
|
items: await processor.loadToolFlatFilesToDelete(),
|
|
115765
117333
|
getPath: (d) => d.getFlatFilePath() ?? d.getDirPath()
|
|
117334
|
+
})).filter((d) => {
|
|
117335
|
+
if (isOwned === void 0) return true;
|
|
117336
|
+
const flatFilePath = d.getFlatFilePath();
|
|
117337
|
+
return flatFilePath !== void 0 && isOwned(flatFilePath);
|
|
115766
117338
|
}),
|
|
115767
117339
|
generatedDirs: []
|
|
115768
117340
|
}) > 0;
|
|
115769
117341
|
}
|
|
117342
|
+
/**
|
|
117343
|
+
* The paths the current sources would write for the processor's target — each
|
|
117344
|
+
* directory, and the file a flattening tool writes in its place — as a
|
|
117345
|
+
* case-folded membership test, matching how the sweeps compare paths.
|
|
117346
|
+
*/
|
|
117347
|
+
async function loadSourceOwnedPaths(processor) {
|
|
117348
|
+
const sourceDirs = await processor.convertRulesyncDirsToToolDirs(await processor.loadRulesyncDirs());
|
|
117349
|
+
const owned = new Set(sourceDirs.flatMap((d) => {
|
|
117350
|
+
const flatFilePath = d.getFlatFilePath();
|
|
117351
|
+
return [d.getDirPath(), ...flatFilePath === void 0 ? [] : [flatFilePath]].map((path) => caseFoldIdentity((0, node_path.resolve)(path)));
|
|
117352
|
+
}));
|
|
117353
|
+
return (path) => owned.has(caseFoldIdentity((0, node_path.resolve)(path)));
|
|
117354
|
+
}
|
|
115770
117355
|
// src/lib/shared-file-derive.ts
|
|
115771
117356
|
/**
|
|
115772
117357
|
* The single declaration of the cross-feature write order for shared
|
|
@@ -116012,29 +117597,30 @@ async function processDirFeatureGeneration(params) {
|
|
|
116012
117597
|
...d.getOtherFiles().map((f) => (0, node_path.join)(dirPath, f.relativeFilePathToDirPath))
|
|
116013
117598
|
];
|
|
116014
117599
|
}) });
|
|
116015
|
-
if (config.getDelete() && !processor.hasRulesyncSourceLoadFailure())
|
|
116016
|
-
|
|
116017
|
-
|
|
116018
|
-
|
|
116019
|
-
|
|
116020
|
-
|
|
116021
|
-
|
|
116022
|
-
|
|
116023
|
-
|
|
116024
|
-
|
|
116025
|
-
|
|
116026
|
-
|
|
116027
|
-
|
|
116028
|
-
|
|
116029
|
-
|
|
116030
|
-
|
|
116031
|
-
|
|
116032
|
-
|
|
116033
|
-
|
|
116034
|
-
|
|
116035
|
-
|
|
116036
|
-
|
|
116037
|
-
|
|
117600
|
+
if (config.getDelete() && !processor.hasRulesyncSourceLoadFailure()) {
|
|
117601
|
+
const preserveUnownedSkills = config.getPreserveUnownedSkills();
|
|
117602
|
+
sweepPlan.defer({
|
|
117603
|
+
sweep: async () => {
|
|
117604
|
+
const orphanDirCount = preserveUnownedSkills ? 0 : await processor.removeOrphanAiDirs(await sweepPlan.rejectClaimed({
|
|
117605
|
+
items: await processor.loadToolDirsToDelete(),
|
|
117606
|
+
getPath: (d) => d.getDirPath()
|
|
117607
|
+
}), toolDirs);
|
|
117608
|
+
const orphanFileCount = preserveUnownedSkills ? 0 : await processor.removeOrphanFlatFiles({
|
|
117609
|
+
existingFlatFiles: await sweepPlan.rejectClaimed({
|
|
117610
|
+
items: await processor.loadToolFlatFilesToDelete(),
|
|
117611
|
+
getPath: (d) => d.getFlatFilePath() ?? d.getDirPath()
|
|
117612
|
+
}),
|
|
117613
|
+
generatedDirs: toolDirs
|
|
117614
|
+
});
|
|
117615
|
+
const orphanInDirCount = await processor.removeOrphanFilesInAiDirs({
|
|
117616
|
+
generatedDirs: toolDirs,
|
|
117617
|
+
isClaimed: (path) => sweepPlan.isGeneratedExactly({ path })
|
|
117618
|
+
});
|
|
117619
|
+
return orphanDirCount + orphanFileCount + orphanInDirCount > 0;
|
|
117620
|
+
},
|
|
117621
|
+
reportDeleted: () => processor.getRemovedPaths()
|
|
117622
|
+
});
|
|
117623
|
+
}
|
|
116038
117624
|
return {
|
|
116039
117625
|
count: totalCount,
|
|
116040
117626
|
paths: allPaths,
|
|
@@ -116673,6 +118259,7 @@ async function generateRulesCore(params) {
|
|
|
116673
118259
|
skills: processorSkills,
|
|
116674
118260
|
featureOptions,
|
|
116675
118261
|
delete: config.getDelete(),
|
|
118262
|
+
preserveUnmanagedContent: config.getPreserveUnmanagedRuleContent(),
|
|
116676
118263
|
dryRun: config.isPreviewMode(),
|
|
116677
118264
|
logger
|
|
116678
118265
|
});
|
|
@@ -116687,7 +118274,7 @@ async function generateRulesCore(params) {
|
|
|
116687
118274
|
const processor = createProcessor({
|
|
116688
118275
|
toolTarget,
|
|
116689
118276
|
outputRoot,
|
|
116690
|
-
featureOptions: config
|
|
118277
|
+
featureOptions: getRulesFeatureOptions(config, toolTarget),
|
|
116691
118278
|
skills
|
|
116692
118279
|
});
|
|
116693
118280
|
const rulesyncFiles = await processor.loadRulesyncFiles();
|
|
@@ -117129,7 +118716,8 @@ async function importRulesCore(params) {
|
|
|
117129
118716
|
}),
|
|
117130
118717
|
toolTarget: tool,
|
|
117131
118718
|
global,
|
|
117132
|
-
logger
|
|
118719
|
+
logger,
|
|
118720
|
+
preserveUnmanagedContent: config.getPreserveUnmanagedRuleContent()
|
|
117133
118721
|
};
|
|
117134
118722
|
const rulesProcessor = new RulesProcessor(baseParams);
|
|
117135
118723
|
const toolFiles = await rulesProcessor.loadToolFiles();
|
|
@@ -117142,7 +118730,7 @@ async function importRulesCore(params) {
|
|
|
117142
118730
|
...baseParams,
|
|
117143
118731
|
inputRoots: config.getInputRoots(),
|
|
117144
118732
|
deriveSubprojectPathFromGlobs: config.getDeriveSubprojectPathFromGlobs(),
|
|
117145
|
-
featureOptions: config
|
|
118733
|
+
featureOptions: getRulesFeatureOptions(config, tool)
|
|
117146
118734
|
}).warnForFoldImportDuplicationRisk();
|
|
117147
118735
|
} catch (error) {
|
|
117148
118736
|
logger.warn(`Skipped the ${tool} import duplication check: ${formatError(error)}`);
|
|
@@ -117923,6 +119511,12 @@ Object.defineProperty(exports, "SKILL_FILE_NAME", {
|
|
|
117923
119511
|
return SKILL_FILE_NAME;
|
|
117924
119512
|
}
|
|
117925
119513
|
});
|
|
119514
|
+
Object.defineProperty(exports, "SOURCE_FILE_FEATURES", {
|
|
119515
|
+
enumerable: true,
|
|
119516
|
+
get: function() {
|
|
119517
|
+
return SOURCE_FILE_FEATURES;
|
|
119518
|
+
}
|
|
119519
|
+
});
|
|
117926
119520
|
Object.defineProperty(exports, "SkillsProcessor", {
|
|
117927
119521
|
enumerable: true,
|
|
117928
119522
|
get: function() {
|
|
@@ -117977,6 +119571,18 @@ Object.defineProperty(exports, "assertLandingOutsideVcsMetadata", {
|
|
|
117977
119571
|
return assertLandingOutsideVcsMetadata;
|
|
117978
119572
|
}
|
|
117979
119573
|
});
|
|
119574
|
+
Object.defineProperty(exports, "assertMatchingFilesFound", {
|
|
119575
|
+
enumerable: true,
|
|
119576
|
+
get: function() {
|
|
119577
|
+
return assertMatchingFilesFound;
|
|
119578
|
+
}
|
|
119579
|
+
});
|
|
119580
|
+
Object.defineProperty(exports, "assertMatchingSkillsFound", {
|
|
119581
|
+
enumerable: true,
|
|
119582
|
+
get: function() {
|
|
119583
|
+
return assertMatchingSkillsFound;
|
|
119584
|
+
}
|
|
119585
|
+
});
|
|
117980
119586
|
Object.defineProperty(exports, "assertNoSymlinkBelowRoot", {
|
|
117981
119587
|
enumerable: true,
|
|
117982
119588
|
get: function() {
|
|
@@ -118007,12 +119613,48 @@ Object.defineProperty(exports, "assertWritablePathInsideRoot", {
|
|
|
118007
119613
|
return assertWritablePathInsideRoot;
|
|
118008
119614
|
}
|
|
118009
119615
|
});
|
|
119616
|
+
Object.defineProperty(exports, "buildFileLockUpdate", {
|
|
119617
|
+
enumerable: true,
|
|
119618
|
+
get: function() {
|
|
119619
|
+
return buildFileLockUpdate;
|
|
119620
|
+
}
|
|
119621
|
+
});
|
|
119622
|
+
Object.defineProperty(exports, "buildLockUpdate", {
|
|
119623
|
+
enumerable: true,
|
|
119624
|
+
get: function() {
|
|
119625
|
+
return buildLockUpdate;
|
|
119626
|
+
}
|
|
119627
|
+
});
|
|
119628
|
+
Object.defineProperty(exports, "canReuseLockedFiles", {
|
|
119629
|
+
enumerable: true,
|
|
119630
|
+
get: function() {
|
|
119631
|
+
return canReuseLockedFiles;
|
|
119632
|
+
}
|
|
119633
|
+
});
|
|
119634
|
+
Object.defineProperty(exports, "canReuseLockedSkills", {
|
|
119635
|
+
enumerable: true,
|
|
119636
|
+
get: function() {
|
|
119637
|
+
return canReuseLockedSkills;
|
|
119638
|
+
}
|
|
119639
|
+
});
|
|
118010
119640
|
Object.defineProperty(exports, "caseFoldIdentity", {
|
|
118011
119641
|
enumerable: true,
|
|
118012
119642
|
get: function() {
|
|
118013
119643
|
return caseFoldIdentity;
|
|
118014
119644
|
}
|
|
118015
119645
|
});
|
|
119646
|
+
Object.defineProperty(exports, "checkLockedFilesAreValid", {
|
|
119647
|
+
enumerable: true,
|
|
119648
|
+
get: function() {
|
|
119649
|
+
return checkLockedFilesAreValid;
|
|
119650
|
+
}
|
|
119651
|
+
});
|
|
119652
|
+
Object.defineProperty(exports, "checkLockedSkillsAreValid", {
|
|
119653
|
+
enumerable: true,
|
|
119654
|
+
get: function() {
|
|
119655
|
+
return checkLockedSkillsAreValid;
|
|
119656
|
+
}
|
|
119657
|
+
});
|
|
118016
119658
|
Object.defineProperty(exports, "checkPathTraversal", {
|
|
118017
119659
|
enumerable: true,
|
|
118018
119660
|
get: function() {
|
|
@@ -118025,6 +119667,18 @@ Object.defineProperty(exports, "classifyRemoteName", {
|
|
|
118025
119667
|
return classifyRemoteName;
|
|
118026
119668
|
}
|
|
118027
119669
|
});
|
|
119670
|
+
Object.defineProperty(exports, "cleanPreviousCuratedFiles", {
|
|
119671
|
+
enumerable: true,
|
|
119672
|
+
get: function() {
|
|
119673
|
+
return cleanPreviousCuratedFiles;
|
|
119674
|
+
}
|
|
119675
|
+
});
|
|
119676
|
+
Object.defineProperty(exports, "cleanPreviousCuratedSkills", {
|
|
119677
|
+
enumerable: true,
|
|
119678
|
+
get: function() {
|
|
119679
|
+
return cleanPreviousCuratedSkills;
|
|
119680
|
+
}
|
|
119681
|
+
});
|
|
118028
119682
|
Object.defineProperty(exports, "convertFromTool", {
|
|
118029
119683
|
enumerable: true,
|
|
118030
119684
|
get: function() {
|
|
@@ -118097,6 +119751,12 @@ Object.defineProperty(exports, "formatError", {
|
|
|
118097
119751
|
return formatError;
|
|
118098
119752
|
}
|
|
118099
119753
|
});
|
|
119754
|
+
Object.defineProperty(exports, "formatInstalledCounts", {
|
|
119755
|
+
enumerable: true,
|
|
119756
|
+
get: function() {
|
|
119757
|
+
return formatInstalledCounts;
|
|
119758
|
+
}
|
|
119759
|
+
});
|
|
118100
119760
|
Object.defineProperty(exports, "formatMegabytes", {
|
|
118101
119761
|
enumerable: true,
|
|
118102
119762
|
get: function() {
|
|
@@ -118115,12 +119775,36 @@ Object.defineProperty(exports, "generate", {
|
|
|
118115
119775
|
return generate;
|
|
118116
119776
|
}
|
|
118117
119777
|
});
|
|
119778
|
+
Object.defineProperty(exports, "getCuratedFileFeatureRelativeDirPath", {
|
|
119779
|
+
enumerable: true,
|
|
119780
|
+
get: function() {
|
|
119781
|
+
return getCuratedFileFeatureRelativeDirPath;
|
|
119782
|
+
}
|
|
119783
|
+
});
|
|
119784
|
+
Object.defineProperty(exports, "getEmptySelectionFields", {
|
|
119785
|
+
enumerable: true,
|
|
119786
|
+
get: function() {
|
|
119787
|
+
return getEmptySelectionFields;
|
|
119788
|
+
}
|
|
119789
|
+
});
|
|
119790
|
+
Object.defineProperty(exports, "getFileFeatureNoun", {
|
|
119791
|
+
enumerable: true,
|
|
119792
|
+
get: function() {
|
|
119793
|
+
return getFileFeatureNoun;
|
|
119794
|
+
}
|
|
119795
|
+
});
|
|
118118
119796
|
Object.defineProperty(exports, "getFileSizeAndExecutableBit", {
|
|
118119
119797
|
enumerable: true,
|
|
118120
119798
|
get: function() {
|
|
118121
119799
|
return getFileSizeAndExecutableBit;
|
|
118122
119800
|
}
|
|
118123
119801
|
});
|
|
119802
|
+
Object.defineProperty(exports, "getFirstPathSeparatorIndex", {
|
|
119803
|
+
enumerable: true,
|
|
119804
|
+
get: function() {
|
|
119805
|
+
return getFirstPathSeparatorIndex;
|
|
119806
|
+
}
|
|
119807
|
+
});
|
|
118124
119808
|
Object.defineProperty(exports, "getHomeDirectory", {
|
|
118125
119809
|
enumerable: true,
|
|
118126
119810
|
get: function() {
|
|
@@ -118133,6 +119817,36 @@ Object.defineProperty(exports, "getLocalSkillDirNames", {
|
|
|
118133
119817
|
return getLocalSkillDirNames;
|
|
118134
119818
|
}
|
|
118135
119819
|
});
|
|
119820
|
+
Object.defineProperty(exports, "getLockKeyRepository", {
|
|
119821
|
+
enumerable: true,
|
|
119822
|
+
get: function() {
|
|
119823
|
+
return getLockKeyRepository;
|
|
119824
|
+
}
|
|
119825
|
+
});
|
|
119826
|
+
Object.defineProperty(exports, "getLockedFileFeatureState", {
|
|
119827
|
+
enumerable: true,
|
|
119828
|
+
get: function() {
|
|
119829
|
+
return getLockedFileFeatureState;
|
|
119830
|
+
}
|
|
119831
|
+
});
|
|
119832
|
+
Object.defineProperty(exports, "getLockedFileNames", {
|
|
119833
|
+
enumerable: true,
|
|
119834
|
+
get: function() {
|
|
119835
|
+
return getLockedFileNames;
|
|
119836
|
+
}
|
|
119837
|
+
});
|
|
119838
|
+
Object.defineProperty(exports, "getLockedSkillNames", {
|
|
119839
|
+
enumerable: true,
|
|
119840
|
+
get: function() {
|
|
119841
|
+
return getLockedSkillNames;
|
|
119842
|
+
}
|
|
119843
|
+
});
|
|
119844
|
+
Object.defineProperty(exports, "getLockedSource", {
|
|
119845
|
+
enumerable: true,
|
|
119846
|
+
get: function() {
|
|
119847
|
+
return getLockedSource;
|
|
119848
|
+
}
|
|
119849
|
+
});
|
|
118136
119850
|
Object.defineProperty(exports, "getProcessorRegistryEntry", {
|
|
118137
119851
|
enumerable: true,
|
|
118138
119852
|
get: function() {
|
|
@@ -118145,18 +119859,36 @@ Object.defineProperty(exports, "getRulesyncSourceCandidates", {
|
|
|
118145
119859
|
return getRulesyncSourceCandidates;
|
|
118146
119860
|
}
|
|
118147
119861
|
});
|
|
119862
|
+
Object.defineProperty(exports, "getSourceFilters", {
|
|
119863
|
+
enumerable: true,
|
|
119864
|
+
get: function() {
|
|
119865
|
+
return getSourceFilters;
|
|
119866
|
+
}
|
|
119867
|
+
});
|
|
118148
119868
|
Object.defineProperty(exports, "getSourceTransport", {
|
|
118149
119869
|
enumerable: true,
|
|
118150
119870
|
get: function() {
|
|
118151
119871
|
return getSourceTransport;
|
|
118152
119872
|
}
|
|
118153
119873
|
});
|
|
119874
|
+
Object.defineProperty(exports, "groupRemoteFilesBySkillRoot", {
|
|
119875
|
+
enumerable: true,
|
|
119876
|
+
get: function() {
|
|
119877
|
+
return groupRemoteFilesBySkillRoot;
|
|
119878
|
+
}
|
|
119879
|
+
});
|
|
118154
119880
|
Object.defineProperty(exports, "groupSpellingsByCaseFoldedIdentity", {
|
|
118155
119881
|
enumerable: true,
|
|
118156
119882
|
get: function() {
|
|
118157
119883
|
return groupSpellingsByCaseFoldedIdentity;
|
|
118158
119884
|
}
|
|
118159
119885
|
});
|
|
119886
|
+
Object.defineProperty(exports, "hasEmptySelection", {
|
|
119887
|
+
enumerable: true,
|
|
119888
|
+
get: function() {
|
|
119889
|
+
return hasEmptySelection;
|
|
119890
|
+
}
|
|
119891
|
+
});
|
|
118160
119892
|
Object.defineProperty(exports, "hasEnclosingMarkOutsideKeycap", {
|
|
118161
119893
|
enumerable: true,
|
|
118162
119894
|
get: function() {
|
|
@@ -118211,6 +119943,12 @@ Object.defineProperty(exports, "isSymlink", {
|
|
|
118211
119943
|
return isSymlink;
|
|
118212
119944
|
}
|
|
118213
119945
|
});
|
|
119946
|
+
Object.defineProperty(exports, "isWildcardSelection", {
|
|
119947
|
+
enumerable: true,
|
|
119948
|
+
get: function() {
|
|
119949
|
+
return isWildcardSelection;
|
|
119950
|
+
}
|
|
119951
|
+
});
|
|
118214
119952
|
Object.defineProperty(exports, "listDirectoryEntryNames", {
|
|
118215
119953
|
enumerable: true,
|
|
118216
119954
|
get: function() {
|
|
@@ -118235,24 +119973,84 @@ Object.defineProperty(exports, "loadYaml", {
|
|
|
118235
119973
|
return loadYaml;
|
|
118236
119974
|
}
|
|
118237
119975
|
});
|
|
119976
|
+
Object.defineProperty(exports, "lockedFileConfigMatches", {
|
|
119977
|
+
enumerable: true,
|
|
119978
|
+
get: function() {
|
|
119979
|
+
return lockedFileConfigMatches;
|
|
119980
|
+
}
|
|
119981
|
+
});
|
|
119982
|
+
Object.defineProperty(exports, "lockedRefMatchesDeclared", {
|
|
119983
|
+
enumerable: true,
|
|
119984
|
+
get: function() {
|
|
119985
|
+
return lockedRefMatchesDeclared;
|
|
119986
|
+
}
|
|
119987
|
+
});
|
|
119988
|
+
Object.defineProperty(exports, "lockedSkillConfigMatches", {
|
|
119989
|
+
enumerable: true,
|
|
119990
|
+
get: function() {
|
|
119991
|
+
return lockedSkillConfigMatches;
|
|
119992
|
+
}
|
|
119993
|
+
});
|
|
119994
|
+
Object.defineProperty(exports, "mapFileFeatures", {
|
|
119995
|
+
enumerable: true,
|
|
119996
|
+
get: function() {
|
|
119997
|
+
return mapFileFeatures;
|
|
119998
|
+
}
|
|
119999
|
+
});
|
|
118238
120000
|
Object.defineProperty(exports, "mapWithConcurrency", {
|
|
118239
120001
|
enumerable: true,
|
|
118240
120002
|
get: function() {
|
|
118241
120003
|
return mapWithConcurrency;
|
|
118242
120004
|
}
|
|
118243
120005
|
});
|
|
120006
|
+
Object.defineProperty(exports, "mergeFetchedWithLockedSkills", {
|
|
120007
|
+
enumerable: true,
|
|
120008
|
+
get: function() {
|
|
120009
|
+
return mergeFetchedWithLockedSkills;
|
|
120010
|
+
}
|
|
120011
|
+
});
|
|
118244
120012
|
Object.defineProperty(exports, "mergeInputRootConfigs", {
|
|
118245
120013
|
enumerable: true,
|
|
118246
120014
|
get: function() {
|
|
118247
120015
|
return mergeInputRootConfigs;
|
|
118248
120016
|
}
|
|
118249
120017
|
});
|
|
120018
|
+
Object.defineProperty(exports, "normalizeLockKey", {
|
|
120019
|
+
enumerable: true,
|
|
120020
|
+
get: function() {
|
|
120021
|
+
return normalizeLockKey;
|
|
120022
|
+
}
|
|
120023
|
+
});
|
|
118250
120024
|
Object.defineProperty(exports, "normalizePosixDirPath", {
|
|
118251
120025
|
enumerable: true,
|
|
118252
120026
|
get: function() {
|
|
118253
120027
|
return normalizePosixDirPath;
|
|
118254
120028
|
}
|
|
118255
120029
|
});
|
|
120030
|
+
Object.defineProperty(exports, "normalizeRuleFilterName", {
|
|
120031
|
+
enumerable: true,
|
|
120032
|
+
get: function() {
|
|
120033
|
+
return normalizeRuleFilterName;
|
|
120034
|
+
}
|
|
120035
|
+
});
|
|
120036
|
+
Object.defineProperty(exports, "normalizeRuleSelection", {
|
|
120037
|
+
enumerable: true,
|
|
120038
|
+
get: function() {
|
|
120039
|
+
return normalizeRuleSelection;
|
|
120040
|
+
}
|
|
120041
|
+
});
|
|
120042
|
+
Object.defineProperty(exports, "normalizeSkillSelection", {
|
|
120043
|
+
enumerable: true,
|
|
120044
|
+
get: function() {
|
|
120045
|
+
return normalizeSkillSelection;
|
|
120046
|
+
}
|
|
120047
|
+
});
|
|
120048
|
+
Object.defineProperty(exports, "normalizeSourceKey", {
|
|
120049
|
+
enumerable: true,
|
|
120050
|
+
get: function() {
|
|
120051
|
+
return normalizeSourceKey;
|
|
120052
|
+
}
|
|
120053
|
+
});
|
|
118256
120054
|
Object.defineProperty(exports, "parseCommaSeparatedList", {
|
|
118257
120055
|
enumerable: true,
|
|
118258
120056
|
get: function() {
|
|
@@ -118271,6 +120069,12 @@ Object.defineProperty(exports, "parseJsonc", {
|
|
|
118271
120069
|
return parseJsonc$6;
|
|
118272
120070
|
}
|
|
118273
120071
|
});
|
|
120072
|
+
Object.defineProperty(exports, "parseSource", {
|
|
120073
|
+
enumerable: true,
|
|
120074
|
+
get: function() {
|
|
120075
|
+
return parseSource;
|
|
120076
|
+
}
|
|
120077
|
+
});
|
|
118274
120078
|
Object.defineProperty(exports, "pathEscapesRoot", {
|
|
118275
120079
|
enumerable: true,
|
|
118276
120080
|
get: function() {
|
|
@@ -118301,16 +120105,16 @@ Object.defineProperty(exports, "readFileContentOrNull", {
|
|
|
118301
120105
|
return readFileContentOrNull;
|
|
118302
120106
|
}
|
|
118303
120107
|
});
|
|
118304
|
-
Object.defineProperty(exports, "
|
|
120108
|
+
Object.defineProperty(exports, "readLockFile", {
|
|
118305
120109
|
enumerable: true,
|
|
118306
120110
|
get: function() {
|
|
118307
|
-
return
|
|
120111
|
+
return readLockFile;
|
|
118308
120112
|
}
|
|
118309
120113
|
});
|
|
118310
|
-
Object.defineProperty(exports, "
|
|
120114
|
+
Object.defineProperty(exports, "removeDirectory", {
|
|
118311
120115
|
enumerable: true,
|
|
118312
120116
|
get: function() {
|
|
118313
|
-
return
|
|
120117
|
+
return removeDirectory;
|
|
118314
120118
|
}
|
|
118315
120119
|
});
|
|
118316
120120
|
Object.defineProperty(exports, "removeFile", {
|
|
@@ -118319,12 +120123,6 @@ Object.defineProperty(exports, "removeFile", {
|
|
|
118319
120123
|
return removeFile;
|
|
118320
120124
|
}
|
|
118321
120125
|
});
|
|
118322
|
-
Object.defineProperty(exports, "removeFileStrict", {
|
|
118323
|
-
enumerable: true,
|
|
118324
|
-
get: function() {
|
|
118325
|
-
return removeFileStrict;
|
|
118326
|
-
}
|
|
118327
|
-
});
|
|
118328
120126
|
Object.defineProperty(exports, "removeFileWithoutFollowingSymlinks", {
|
|
118329
120127
|
enumerable: true,
|
|
118330
120128
|
get: function() {
|
|
@@ -118337,6 +120135,18 @@ Object.defineProperty(exports, "removeTempDirectory", {
|
|
|
118337
120135
|
return removeTempDirectory;
|
|
118338
120136
|
}
|
|
118339
120137
|
});
|
|
120138
|
+
Object.defineProperty(exports, "renameLockedSource", {
|
|
120139
|
+
enumerable: true,
|
|
120140
|
+
get: function() {
|
|
120141
|
+
return renameLockedSource;
|
|
120142
|
+
}
|
|
120143
|
+
});
|
|
120144
|
+
Object.defineProperty(exports, "replaceCuratedFiles", {
|
|
120145
|
+
enumerable: true,
|
|
120146
|
+
get: function() {
|
|
120147
|
+
return replaceCuratedFiles;
|
|
120148
|
+
}
|
|
120149
|
+
});
|
|
118340
120150
|
Object.defineProperty(exports, "resetRunWarningState", {
|
|
118341
120151
|
enumerable: true,
|
|
118342
120152
|
get: function() {
|
|
@@ -118349,6 +120159,18 @@ Object.defineProperty(exports, "resolveEffectiveInputRoots", {
|
|
|
118349
120159
|
return resolveEffectiveInputRoots;
|
|
118350
120160
|
}
|
|
118351
120161
|
});
|
|
120162
|
+
Object.defineProperty(exports, "resolveFileFeaturePath", {
|
|
120163
|
+
enumerable: true,
|
|
120164
|
+
get: function() {
|
|
120165
|
+
return resolveFileFeaturePath;
|
|
120166
|
+
}
|
|
120167
|
+
});
|
|
120168
|
+
Object.defineProperty(exports, "resolveFileFeatureSourcePath", {
|
|
120169
|
+
enumerable: true,
|
|
120170
|
+
get: function() {
|
|
120171
|
+
return resolveFileFeatureSourcePath;
|
|
120172
|
+
}
|
|
120173
|
+
});
|
|
118352
120174
|
Object.defineProperty(exports, "resolvePath", {
|
|
118353
120175
|
enumerable: true,
|
|
118354
120176
|
get: function() {
|
|
@@ -118361,6 +120183,24 @@ Object.defineProperty(exports, "resolveRulesyncSourceWritePath", {
|
|
|
118361
120183
|
return resolveRulesyncSourceWritePath;
|
|
118362
120184
|
}
|
|
118363
120185
|
});
|
|
120186
|
+
Object.defineProperty(exports, "resolveSkillsPath", {
|
|
120187
|
+
enumerable: true,
|
|
120188
|
+
get: function() {
|
|
120189
|
+
return resolveSkillsPath;
|
|
120190
|
+
}
|
|
120191
|
+
});
|
|
120192
|
+
Object.defineProperty(exports, "resolveSkillsSourcePath", {
|
|
120193
|
+
enumerable: true,
|
|
120194
|
+
get: function() {
|
|
120195
|
+
return resolveSkillsSourcePath;
|
|
120196
|
+
}
|
|
120197
|
+
});
|
|
120198
|
+
Object.defineProperty(exports, "resolveSourceLockKeys", {
|
|
120199
|
+
enumerable: true,
|
|
120200
|
+
get: function() {
|
|
120201
|
+
return resolveSourceLockKeys;
|
|
120202
|
+
}
|
|
120203
|
+
});
|
|
118364
120204
|
Object.defineProperty(exports, "resolvedRelativePath", {
|
|
118365
120205
|
enumerable: true,
|
|
118366
120206
|
get: function() {
|
|
@@ -118373,12 +120213,42 @@ Object.defineProperty(exports, "runWithDirectoryRollback", {
|
|
|
118373
120213
|
return runWithDirectoryRollback;
|
|
118374
120214
|
}
|
|
118375
120215
|
});
|
|
120216
|
+
Object.defineProperty(exports, "selectDeclaredFiles", {
|
|
120217
|
+
enumerable: true,
|
|
120218
|
+
get: function() {
|
|
120219
|
+
return selectDeclaredFiles;
|
|
120220
|
+
}
|
|
120221
|
+
});
|
|
120222
|
+
Object.defineProperty(exports, "setLockedSource", {
|
|
120223
|
+
enumerable: true,
|
|
120224
|
+
get: function() {
|
|
120225
|
+
return setLockedSource;
|
|
120226
|
+
}
|
|
120227
|
+
});
|
|
118376
120228
|
Object.defineProperty(exports, "shortenToWidth", {
|
|
118377
120229
|
enumerable: true,
|
|
118378
120230
|
get: function() {
|
|
118379
120231
|
return shortenToWidth;
|
|
118380
120232
|
}
|
|
118381
120233
|
});
|
|
120234
|
+
Object.defineProperty(exports, "shouldSkipFile", {
|
|
120235
|
+
enumerable: true,
|
|
120236
|
+
get: function() {
|
|
120237
|
+
return shouldSkipFile;
|
|
120238
|
+
}
|
|
120239
|
+
});
|
|
120240
|
+
Object.defineProperty(exports, "shouldSkipSkill", {
|
|
120241
|
+
enumerable: true,
|
|
120242
|
+
get: function() {
|
|
120243
|
+
return shouldSkipSkill;
|
|
120244
|
+
}
|
|
120245
|
+
});
|
|
120246
|
+
Object.defineProperty(exports, "shouldUseRootFallback", {
|
|
120247
|
+
enumerable: true,
|
|
120248
|
+
get: function() {
|
|
120249
|
+
return shouldUseRootFallback;
|
|
120250
|
+
}
|
|
120251
|
+
});
|
|
118382
120252
|
Object.defineProperty(exports, "splitPathSegments", {
|
|
118383
120253
|
enumerable: true,
|
|
118384
120254
|
get: function() {
|
|
@@ -118421,6 +120291,12 @@ Object.defineProperty(exports, "sweepRefusalReason", {
|
|
|
118421
120291
|
return sweepRefusalReason;
|
|
118422
120292
|
}
|
|
118423
120293
|
});
|
|
120294
|
+
Object.defineProperty(exports, "toFileFeatureLockFields", {
|
|
120295
|
+
enumerable: true,
|
|
120296
|
+
get: function() {
|
|
120297
|
+
return toFileFeatureLockFields;
|
|
120298
|
+
}
|
|
120299
|
+
});
|
|
118424
120300
|
Object.defineProperty(exports, "toInstructionBudgetFile", {
|
|
118425
120301
|
enumerable: true,
|
|
118426
120302
|
get: function() {
|
|
@@ -118469,3 +120345,15 @@ Object.defineProperty(exports, "writeFileContent", {
|
|
|
118469
120345
|
return writeFileContent;
|
|
118470
120346
|
}
|
|
118471
120347
|
});
|
|
120348
|
+
Object.defineProperty(exports, "writeLockFile", {
|
|
120349
|
+
enumerable: true,
|
|
120350
|
+
get: function() {
|
|
120351
|
+
return writeLockFile;
|
|
120352
|
+
}
|
|
120353
|
+
});
|
|
120354
|
+
Object.defineProperty(exports, "writeSkillAndComputeIntegrity", {
|
|
120355
|
+
enumerable: true,
|
|
120356
|
+
get: function() {
|
|
120357
|
+
return writeSkillAndComputeIntegrity;
|
|
120358
|
+
}
|
|
120359
|
+
});
|