agentsmesh 0.9.0 → 0.10.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/targets.js CHANGED
@@ -1,6 +1,6 @@
1
1
  import { z } from 'zod';
2
2
  import { readFile, readdir, stat, mkdir, lstat, unlink, writeFile, rename, rm, realpath, access } from 'fs/promises';
3
- import { normalize, join, basename, relative, dirname, extname, win32, isAbsolute, posix } from 'path';
3
+ import { basename, join, win32, posix, relative, dirname, extname } from 'path';
4
4
  import { existsSync, realpathSync, constants, statSync } from 'fs';
5
5
  import { stringify, parse } from 'yaml';
6
6
  import { parse as parse$1 } from 'smol-toml';
@@ -11,35 +11,35 @@ var __getOwnPropNames = Object.getOwnPropertyNames;
11
11
  var __esm = (fn, res) => function __init() {
12
12
  return fn && (res = (0, fn[__getOwnPropNames(fn)[0]])(fn = 0)), res;
13
13
  };
14
- var __export = (target13, all) => {
14
+ var __export = (target14, all) => {
15
15
  for (var name in all)
16
- __defProp(target13, name, { get: all[name], enumerable: true });
16
+ __defProp(target14, name, { get: all[name], enumerable: true });
17
17
  };
18
18
 
19
19
  // src/config/core/conversions.ts
20
- function usesCommandSkillProjection(target13) {
21
- return Object.prototype.hasOwnProperty.call(DEFAULT_COMMANDS_TO_SKILLS, target13);
20
+ function usesCommandSkillProjection(target14) {
21
+ return Object.prototype.hasOwnProperty.call(DEFAULT_COMMANDS_TO_SKILLS, target14);
22
22
  }
23
- function usesAgentSkillProjection(target13) {
24
- return Object.prototype.hasOwnProperty.call(DEFAULT_AGENTS_TO_SKILLS, target13);
23
+ function usesAgentSkillProjection(target14) {
24
+ return Object.prototype.hasOwnProperty.call(DEFAULT_AGENTS_TO_SKILLS, target14);
25
25
  }
26
26
  function resolveConversionValue(value, scope) {
27
27
  if (value === void 0) return void 0;
28
28
  if (typeof value === "boolean") return value;
29
29
  return value[scope];
30
30
  }
31
- function shouldConvertCommandsToSkills(config, target13, defaultEnabled, scope = "project") {
32
- const raw = config.conversions?.commands_to_skills?.[target13];
31
+ function shouldConvertCommandsToSkills(config, target14, defaultEnabled, scope = "project") {
32
+ const raw = config.conversions?.commands_to_skills?.[target14];
33
33
  const configVal = resolveConversionValue(raw, scope);
34
34
  if (configVal !== void 0) return configVal;
35
- if (usesCommandSkillProjection(target13)) return DEFAULT_COMMANDS_TO_SKILLS[target13];
35
+ if (usesCommandSkillProjection(target14)) return DEFAULT_COMMANDS_TO_SKILLS[target14];
36
36
  return defaultEnabled ?? false;
37
37
  }
38
- function shouldConvertAgentsToSkills(config, target13, defaultEnabled, scope = "project") {
39
- const raw = config.conversions?.agents_to_skills?.[target13];
38
+ function shouldConvertAgentsToSkills(config, target14, defaultEnabled, scope = "project") {
39
+ const raw = config.conversions?.agents_to_skills?.[target14];
40
40
  const configVal = resolveConversionValue(raw, scope);
41
41
  if (configVal !== void 0) return configVal;
42
- if (usesAgentSkillProjection(target13)) return DEFAULT_AGENTS_TO_SKILLS[target13];
42
+ if (usesAgentSkillProjection(target14)) return DEFAULT_AGENTS_TO_SKILLS[target14];
43
43
  return defaultEnabled ?? false;
44
44
  }
45
45
  var DEFAULT_COMMANDS_TO_SKILLS, DEFAULT_AGENTS_TO_SKILLS;
@@ -92,12 +92,12 @@ function capabilityLevel(capability) {
92
92
  function canUseScopedSettings(feature) {
93
93
  return settingsBackedFeatures.includes(feature);
94
94
  }
95
- function validateCapabilityImplementations(descriptor13, capabilities, ctx, pathPrefix) {
95
+ function validateCapabilityImplementations(descriptor14, capabilities2, ctx, pathPrefix) {
96
96
  for (const requirement of generatorRequirements) {
97
- const level = capabilityLevel(capabilities[requirement.feature]);
97
+ const level = capabilityLevel(capabilities2[requirement.feature]);
98
98
  if (level === "none") continue;
99
- const hasGenerator = typeof descriptor13.generators[requirement.generator] === "function";
100
- const hasSettingsEmitter = canUseScopedSettings(requirement.feature) && typeof descriptor13.emitScopedSettings === "function";
99
+ const hasGenerator = typeof descriptor14.generators[requirement.generator] === "function";
100
+ const hasSettingsEmitter = canUseScopedSettings(requirement.feature) && typeof descriptor14.emitScopedSettings === "function";
101
101
  if (hasGenerator || hasSettingsEmitter) continue;
102
102
  ctx.addIssue({
103
103
  code: "custom",
@@ -212,8 +212,8 @@ function builtinDescriptors() {
212
212
  }
213
213
  return _builtinDescriptors;
214
214
  }
215
- function registerTargetDescriptor(descriptor13) {
216
- const validated = validateDescriptor(descriptor13);
215
+ function registerTargetDescriptor(descriptor14) {
216
+ const validated = validateDescriptor(descriptor14);
217
217
  descriptorRegistry.set(validated.id, validated);
218
218
  }
219
219
  function getDescriptor(name) {
@@ -234,11 +234,11 @@ var init_registry = __esm({
234
234
  // src/targets/catalog/shared-artifact-owner.ts
235
235
  function findSharedArtifactOwnershipConflicts(descriptors) {
236
236
  const owners = [];
237
- for (const descriptor13 of descriptors) {
238
- if (!descriptor13.sharedArtifacts) continue;
239
- for (const [prefix, role] of Object.entries(descriptor13.sharedArtifacts)) {
237
+ for (const descriptor14 of descriptors) {
238
+ if (!descriptor14.sharedArtifacts) continue;
239
+ for (const [prefix, role] of Object.entries(descriptor14.sharedArtifacts)) {
240
240
  if (role !== "owner") continue;
241
- owners.push({ targetId: descriptor13.id, prefix });
241
+ owners.push({ targetId: descriptor14.id, prefix });
242
242
  }
243
243
  }
244
244
  const conflicts = [];
@@ -289,6 +289,7 @@ var init_builtin_target_ids_generated = __esm({
289
289
  "cursor",
290
290
  "gemini-cli",
291
291
  "junie",
292
+ "kilo-code",
292
293
  "kiro",
293
294
  "roo-code",
294
295
  "windsurf"
@@ -993,21 +994,6 @@ var init_generator = __esm({
993
994
  init_constants();
994
995
  }
995
996
  });
996
-
997
- // src/core/reference/import-map.ts
998
- async function buildImportReferenceMap(target13, projectRoot, scope = "project") {
999
- const refs = /* @__PURE__ */ new Map();
1000
- const def = getDescriptor(target13);
1001
- if (def) {
1002
- await def.buildImportPaths(refs, projectRoot, scope);
1003
- }
1004
- return refs;
1005
- }
1006
- var init_import_map = __esm({
1007
- "src/core/reference/import-map.ts"() {
1008
- init_registry();
1009
- }
1010
- });
1011
997
  function pathApi(projectRoot) {
1012
998
  return projectRoot.includes("\\") || WINDOWS_ABSOLUTE_PATH.test(projectRoot) ? win32 : posix;
1013
999
  }
@@ -1046,13 +1032,28 @@ var init_path_helpers = __esm({
1046
1032
  }
1047
1033
  });
1048
1034
 
1035
+ // src/core/reference/import-map.ts
1036
+ async function buildImportReferenceMap(target14, projectRoot, scope = "project") {
1037
+ const refs = /* @__PURE__ */ new Map();
1038
+ const def = getDescriptor(target14);
1039
+ if (def) {
1040
+ await def.buildImportPaths(refs, projectRoot, scope);
1041
+ }
1042
+ return refs;
1043
+ }
1044
+ var init_import_map = __esm({
1045
+ "src/core/reference/import-map.ts"() {
1046
+ init_registry();
1047
+ }
1048
+ });
1049
+
1049
1050
  // src/core/reference/link-format-registry.ts
1050
- function topLevelDotfilePrefixes(descriptor13) {
1051
- const layouts = [descriptor13.project, descriptor13.globalSupport?.layout].filter(
1051
+ function topLevelDotfilePrefixes(descriptor14) {
1052
+ const layouts = [descriptor14.project, descriptor14.globalSupport?.layout].filter(
1052
1053
  (l) => l !== void 0
1053
1054
  );
1054
1055
  const candidates = [
1055
- ...descriptor13.detectionPaths,
1056
+ ...descriptor14.detectionPaths,
1056
1057
  ...layouts.flatMap((l) => l.managedOutputs?.dirs ?? []),
1057
1058
  ...layouts.flatMap((l) => l.managedOutputs?.files ?? [])
1058
1059
  ];
@@ -1065,8 +1066,8 @@ function topLevelDotfilePrefixes(descriptor13) {
1065
1066
  }
1066
1067
  function buildDefaultRootRelativePrefixes() {
1067
1068
  const set = /* @__PURE__ */ new Set([".agentsmesh/"]);
1068
- for (const descriptor13 of BUILTIN_TARGETS) {
1069
- for (const prefix of topLevelDotfilePrefixes(descriptor13)) set.add(prefix);
1069
+ for (const descriptor14 of BUILTIN_TARGETS) {
1070
+ for (const prefix of topLevelDotfilePrefixes(descriptor14)) set.add(prefix);
1070
1071
  }
1071
1072
  return Array.from(set);
1072
1073
  }
@@ -1137,7 +1138,7 @@ function resolveProjectPath(token, projectRoot, sourceFile) {
1137
1138
  }
1138
1139
  return [windowsToken];
1139
1140
  }
1140
- if (isAbsolute(token)) {
1141
+ if (api.isAbsolute(token)) {
1141
1142
  const absoluteToken = normalizeForProject(projectRoot, token);
1142
1143
  if (absoluteToken.startsWith(normalizedProjectRoot) || existsSync(token))
1143
1144
  return [absoluteToken];
@@ -1243,9 +1244,14 @@ var init_link_rebaser_helpers = __esm({
1243
1244
  LINE_NUMBER_SUFFIX = /(?::(\d+)){1,2}$/;
1244
1245
  }
1245
1246
  });
1247
+
1248
+ // src/core/reference/link-rebaser-formatting.ts
1246
1249
  function isReadingContext(context) {
1247
1250
  return context === void 0 || context.role === "inline-code" || context.role === "bracketed" || context.role === "quoted" || context.role === "at-prefix" || context.role === "bracket-label" || context.role === "bare-prose";
1248
1251
  }
1252
+ function isReadingContextOptions(options) {
1253
+ return isReadingContext(options.tokenContext);
1254
+ }
1249
1255
  function isUnderProjectRoot(projectRoot, absolutePath) {
1250
1256
  const api = pathApi(projectRoot);
1251
1257
  const root = normalizeForProject(projectRoot, projectRoot);
@@ -1285,11 +1291,6 @@ function toProjectRootRelative(projectRoot, absolutePath, keepSlash) {
1285
1291
  const rewritten = relPath.length > 0 ? relPath : ".";
1286
1292
  return keepSlash && !rewritten.endsWith("/") ? `${rewritten}/` : rewritten;
1287
1293
  }
1288
- function shouldPreserveAgentsMeshAnchor(_projectRoot, _destinationFile, options) {
1289
- if (!isReadingContext(options.tokenContext)) return false;
1290
- if (options.originalToken === void 0) return false;
1291
- return normalizeSeparators(options.originalToken).startsWith(".agentsmesh/");
1292
- }
1293
1294
  function toProjectRootReference(projectRoot, absolutePath, keepSlash) {
1294
1295
  const formatted = toProjectRootRelative(projectRoot, absolutePath, keepSlash);
1295
1296
  if (formatted === null) return null;
@@ -1299,21 +1300,21 @@ function formatLinkPathForDestinationLegacy(projectRoot, destinationFile, absolu
1299
1300
  const api = pathApi(projectRoot);
1300
1301
  const root = normalizeForProject(projectRoot, projectRoot);
1301
1302
  const destFile = normalizeForProject(projectRoot, destinationFile);
1302
- const target13 = normalizeForProject(projectRoot, absoluteTargetPath);
1303
- if (!isUnderProjectRoot(projectRoot, target13)) {
1304
- return toProjectRootReference(projectRoot, target13, keepSlash)?.text ?? null;
1303
+ const target14 = normalizeForProject(projectRoot, absoluteTargetPath);
1304
+ if (!isUnderProjectRoot(projectRoot, target14)) {
1305
+ return toProjectRootReference(projectRoot, target14, keepSlash)?.text ?? null;
1305
1306
  }
1306
- const destDir = normalizeForProject(projectRoot, dirname(destFile));
1307
+ const destDir = normalizeForProject(projectRoot, api.dirname(destFile));
1307
1308
  if (!isUnderProjectRoot(projectRoot, destDir) && destDir !== root) {
1308
- return toProjectRootReference(projectRoot, target13, keepSlash)?.text ?? null;
1309
+ return toProjectRootReference(projectRoot, target14, keepSlash)?.text ?? null;
1309
1310
  }
1310
- let rel2 = api.relative(destDir, target13).replace(/\\/g, "/");
1311
+ let rel2 = api.relative(destDir, target14).replace(/\\/g, "/");
1311
1312
  if (api.isAbsolute(rel2) || WINDOWS_ABSOLUTE_PATH.test(rel2)) {
1312
- return toProjectRootRelative(projectRoot, target13, keepSlash);
1313
+ return toProjectRootRelative(projectRoot, target14, keepSlash);
1313
1314
  }
1314
1315
  const joined = normalizeForProject(projectRoot, api.join(destDir, rel2));
1315
1316
  if (!isUnderProjectRoot(projectRoot, joined)) {
1316
- return toProjectRootRelative(projectRoot, target13, keepSlash);
1317
+ return toProjectRootRelative(projectRoot, target14, keepSlash);
1317
1318
  }
1318
1319
  if (rel2 === "" || rel2 === ".") {
1319
1320
  rel2 = ".";
@@ -1332,9 +1333,14 @@ var init_link_rebaser_formatting = __esm({
1332
1333
  // src/core/reference/link-rebaser-output.ts
1333
1334
  function formatLinkPathForDestination(projectRoot, destinationFile, absoluteTargetPath, keepSlash, options = {}) {
1334
1335
  const scope = options.scope ?? "project";
1335
- const target13 = normalizeForProject(projectRoot, absoluteTargetPath);
1336
- if (shouldPreserveAgentsMeshAnchor(projectRoot, destinationFile, options)) {
1337
- return normalizeSeparators(options.originalToken ?? "");
1336
+ const target14 = normalizeForProject(projectRoot, absoluteTargetPath);
1337
+ if (isReadingContextOptions(options) && isUnderAgentsMesh(projectRoot, destinationFile) && isUnderAgentsMesh(projectRoot, target14)) {
1338
+ const api = pathApi(projectRoot);
1339
+ const root = normalizeForProject(projectRoot, projectRoot);
1340
+ const rel2 = api.relative(root, target14).replace(/\\/g, "/");
1341
+ if (!rel2.startsWith("..") && rel2.length > 0) {
1342
+ return keepSlash && !rel2.endsWith("/") ? `${rel2}/` : rel2;
1343
+ }
1338
1344
  }
1339
1345
  if (options.forceRelative) {
1340
1346
  return formatLinkPathForDestinationLegacy(
@@ -1346,10 +1352,10 @@ function formatLinkPathForDestination(projectRoot, destinationFile, absoluteTarg
1346
1352
  );
1347
1353
  }
1348
1354
  if (scope === "global" && !isUnderAgentsMesh(projectRoot, destinationFile)) {
1349
- return toProjectRootReference(projectRoot, target13, keepSlash)?.text ?? null;
1355
+ return toProjectRootReference(projectRoot, target14, keepSlash)?.text ?? null;
1350
1356
  }
1351
1357
  const meshCanonicalForShape = (() => {
1352
- if (isUnderAgentsMesh(projectRoot, target13)) return target13;
1358
+ if (isUnderAgentsMesh(projectRoot, target14)) return target14;
1353
1359
  const logical = options.logicalMeshSourceAbsolute;
1354
1360
  if (logical && isUnderAgentsMesh(projectRoot, normalizeForProject(projectRoot, logical))) {
1355
1361
  return normalizeForProject(projectRoot, logical);
@@ -1357,9 +1363,9 @@ function formatLinkPathForDestination(projectRoot, destinationFile, absoluteTarg
1357
1363
  return null;
1358
1364
  })();
1359
1365
  if (!meshCanonicalForShape) {
1360
- return toProjectRootReference(projectRoot, target13, keepSlash)?.text ?? null;
1366
+ return toProjectRootReference(projectRoot, target14, keepSlash)?.text ?? null;
1361
1367
  }
1362
- const treatAsDirectory = keepSlash || (options.pathIsDirectory?.(target13) ?? false);
1368
+ const treatAsDirectory = keepSlash || (options.pathIsDirectory?.(target14) ?? false);
1363
1369
  if (treatAsDirectory) {
1364
1370
  const meshRelative = toAgentsMeshRootRelative(projectRoot, meshCanonicalForShape, keepSlash);
1365
1371
  if (meshRelative !== null) return meshRelative;
@@ -1383,7 +1389,7 @@ var init_link_rebaser_output = __esm({
1383
1389
  });
1384
1390
 
1385
1391
  // src/core/reference/link-rebaser-suffix-strip.ts
1386
- function resolveByDestinationSuffixStrip(token, projectRoot, destinationFile, pathExists) {
1392
+ function resolveByDestinationSuffixStrip(token, projectRoot, destinationFile, pathExists2) {
1387
1393
  const api = pathApi(projectRoot);
1388
1394
  const normalizedToken = normalizeSeparators(token);
1389
1395
  if (!isRootRelativePathToken(normalizedToken)) return null;
@@ -1395,7 +1401,7 @@ function resolveByDestinationSuffixStrip(token, projectRoot, destinationFile, pa
1395
1401
  const suffix = segments.slice(i).join("/");
1396
1402
  const candidate = normalizeForProject(projectRoot, api.join(destDir, suffix));
1397
1403
  if (candidate === destFilePath) continue;
1398
- if (pathExists(candidate)) return candidate;
1404
+ if (pathExists2(candidate)) return candidate;
1399
1405
  }
1400
1406
  return null;
1401
1407
  }
@@ -1712,22 +1718,23 @@ var init_link_rebaser = __esm({
1712
1718
  init_link_token_context();
1713
1719
  }
1714
1720
  });
1715
- function pathVariants(path) {
1716
- const variants = [normalize(path)];
1721
+ function pathVariants(api, path) {
1722
+ const variants = [api.normalize(path)];
1717
1723
  if (!existsSync(path)) return variants;
1718
1724
  try {
1719
1725
  const realPaths = [realpathSync(path), realpathSync.native(path)];
1720
1726
  for (const realPath of realPaths) {
1721
- const normalized = normalize(realPath);
1727
+ const normalized = api.normalize(realPath);
1722
1728
  if (!variants.includes(normalized)) variants.push(normalized);
1723
1729
  }
1724
1730
  } catch {
1725
1731
  }
1726
1732
  return variants;
1727
1733
  }
1728
- async function createImportReferenceNormalizer(target13, projectRoot, scope = "project") {
1734
+ async function createImportReferenceNormalizer(target14, projectRoot, scope = "project") {
1735
+ const api = pathApi(projectRoot);
1729
1736
  const refs = /* @__PURE__ */ new Map();
1730
- const targets = Array.from(/* @__PURE__ */ new Set([target13, ...TARGET_IDS]));
1737
+ const targets = Array.from(/* @__PURE__ */ new Set([target14, ...TARGET_IDS]));
1731
1738
  for (const candidate of targets) {
1732
1739
  const candidateRefs = await buildImportReferenceMap(candidate, projectRoot, scope);
1733
1740
  for (const [targetPath, canonicalPath] of candidateRefs.entries()) {
@@ -1736,17 +1743,17 @@ async function createImportReferenceNormalizer(target13, projectRoot, scope = "p
1736
1743
  }
1737
1744
  const artifactMap = /* @__PURE__ */ new Map();
1738
1745
  for (const [targetPath, canonicalPath] of refs.entries()) {
1739
- const canonicalAbsPath = normalize(join(projectRoot, canonicalPath));
1740
- for (const variant of pathVariants(join(projectRoot, targetPath))) {
1746
+ const canonicalAbsPath = api.normalize(api.join(projectRoot, canonicalPath));
1747
+ for (const variant of pathVariants(api, api.join(projectRoot, targetPath))) {
1741
1748
  artifactMap.set(variant, canonicalAbsPath);
1742
1749
  }
1743
1750
  }
1744
1751
  const canonicalDestAbs = /* @__PURE__ */ new Set();
1745
1752
  for (const canonicalPath of new Set(refs.values())) {
1746
- const abs = normalize(join(projectRoot, canonicalPath));
1753
+ const abs = api.normalize(api.join(projectRoot, canonicalPath));
1747
1754
  canonicalDestAbs.add(abs);
1748
- for (const variant of pathVariants(abs)) {
1749
- canonicalDestAbs.add(normalize(variant));
1755
+ for (const variant of pathVariants(api, abs)) {
1756
+ canonicalDestAbs.add(api.normalize(variant));
1750
1757
  }
1751
1758
  }
1752
1759
  return (content, sourceFile, destinationFile) => rewriteFileLinks({
@@ -1756,7 +1763,7 @@ async function createImportReferenceNormalizer(target13, projectRoot, scope = "p
1756
1763
  destinationFile,
1757
1764
  translatePath: (absolutePath) => artifactMap.get(absolutePath) ?? absolutePath,
1758
1765
  pathExists: (absolutePath) => {
1759
- const normalized = normalize(absolutePath);
1766
+ const normalized = api.normalize(absolutePath);
1760
1767
  return artifactMap.has(absolutePath) || artifactMap.has(normalized) || existsSync(absolutePath) || canonicalDestAbs.has(normalized);
1761
1768
  },
1762
1769
  explicitCurrentDirLinks: false,
@@ -1773,11 +1780,43 @@ async function createImportReferenceNormalizer(target13, projectRoot, scope = "p
1773
1780
  }
1774
1781
  var init_import_rewriter = __esm({
1775
1782
  "src/core/reference/import-rewriter.ts"() {
1783
+ init_path_helpers();
1776
1784
  init_import_map();
1777
1785
  init_link_rebaser();
1778
1786
  init_target_ids();
1779
1787
  }
1780
1788
  });
1789
+ async function writeMcpWithMerge(projectRoot, canonicalPath, imported) {
1790
+ const destPath = join(projectRoot, canonicalPath);
1791
+ const existing = await readExistingServers(destPath);
1792
+ const merged = { ...existing, ...imported };
1793
+ await mkdirp(dirname(destPath));
1794
+ await writeFileAtomic(destPath, JSON.stringify({ mcpServers: merged }, null, 2));
1795
+ }
1796
+ async function readExistingServers(path) {
1797
+ const content = await readFileSafe(path);
1798
+ if (content === null) return {};
1799
+ let parsed;
1800
+ try {
1801
+ parsed = JSON.parse(content);
1802
+ } catch {
1803
+ return {};
1804
+ }
1805
+ if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return {};
1806
+ const raw = parsed.mcpServers;
1807
+ if (!raw || typeof raw !== "object" || Array.isArray(raw)) return {};
1808
+ const out = {};
1809
+ for (const [name, value] of Object.entries(raw)) {
1810
+ if (!value || typeof value !== "object" || Array.isArray(value)) continue;
1811
+ out[name] = value;
1812
+ }
1813
+ return out;
1814
+ }
1815
+ var init_mcp_merge = __esm({
1816
+ "src/targets/import/mcp-merge.ts"() {
1817
+ init_fs();
1818
+ }
1819
+ });
1781
1820
 
1782
1821
  // src/targets/import/shared-import-helpers.ts
1783
1822
  function toGlobsArray(v) {
@@ -2090,11 +2129,9 @@ async function runMcpJson(spec, sources, projectRoot, fromTool) {
2090
2129
  const srcPath = join(projectRoot, rel2);
2091
2130
  const content = await readFileSafe(srcPath);
2092
2131
  if (content === null) continue;
2093
- const servers = parseMcpJson(content);
2094
- if (Object.keys(servers).length === 0) return [];
2095
- const destPath = join(projectRoot, canonicalPath);
2096
- await mkdirp(dirname(destPath));
2097
- await writeFileAtomic(destPath, JSON.stringify({ mcpServers: servers }, null, 2));
2132
+ const imported = parseMcpJson(content);
2133
+ if (Object.keys(imported).length === 0) return [];
2134
+ await writeMcpWithMerge(projectRoot, canonicalPath, imported);
2098
2135
  return [{ fromTool, fromPath: srcPath, toPath: canonicalPath, feature: spec.feature }];
2099
2136
  }
2100
2137
  return [];
@@ -2130,14 +2167,14 @@ function specsForFeature(importer, feature) {
2130
2167
  if (Array.isArray(value)) return value;
2131
2168
  return [value];
2132
2169
  }
2133
- async function runDescriptorImport(descriptor13, projectRoot, scope, options) {
2134
- const importer = descriptor13.importer;
2170
+ async function runDescriptorImport(descriptor14, projectRoot, scope, options) {
2171
+ const importer = descriptor14.importer;
2135
2172
  if (!importer) return [];
2136
- const normalize = options?.normalize ?? await createImportReferenceNormalizer(descriptor13.id, projectRoot, scope);
2173
+ const normalize = options?.normalize ?? await createImportReferenceNormalizer(descriptor14.id, projectRoot, scope);
2137
2174
  const results = [];
2138
2175
  for (const feature of IMPORT_FEATURE_ORDER) {
2139
2176
  for (const spec of specsForFeature(importer, feature)) {
2140
- results.push(...await runSpec(spec, scope, projectRoot, descriptor13.id, normalize));
2177
+ results.push(...await runSpec(spec, scope, projectRoot, descriptor14.id, normalize));
2141
2178
  }
2142
2179
  }
2143
2180
  return results;
@@ -2146,6 +2183,7 @@ var init_descriptor_import_runner = __esm({
2146
2183
  "src/targets/import/descriptor-import-runner.ts"() {
2147
2184
  init_import_rewriter();
2148
2185
  init_fs();
2186
+ init_mcp_merge();
2149
2187
  init_markdown();
2150
2188
  init_shared_import_helpers();
2151
2189
  init_import_metadata();
@@ -2601,22 +2639,22 @@ var init_projected_agent_skill = __esm({
2601
2639
  }
2602
2640
  });
2603
2641
  function rel(projectRoot, absPath) {
2604
- return relative(projectRoot, absPath).replace(/\\/g, "/");
2642
+ return pathApi(projectRoot).relative(projectRoot, absPath).replace(/\\/g, "/");
2605
2643
  }
2606
2644
  async function listFiles(projectRoot, dir) {
2607
- return readDirRecursive(join(projectRoot, dir)).catch(() => []);
2645
+ return readDirRecursive(pathApi(projectRoot).join(projectRoot, dir)).catch(() => []);
2608
2646
  }
2609
2647
  function addDirectoryMapping(refs, from, to) {
2610
2648
  refs.set(from, to);
2611
2649
  refs.set(`${from}/`, `${to}/`);
2612
2650
  }
2613
2651
  function addAncestorMappings(refs, fromPath, toPath, stopDir) {
2614
- let fromDir = dirname(fromPath);
2615
- let toDir = dirname(toPath);
2652
+ let fromDir = posix.dirname(fromPath);
2653
+ let toDir = posix.dirname(toPath);
2616
2654
  while (fromDir !== stopDir && fromDir !== ".") {
2617
2655
  addDirectoryMapping(refs, fromDir, toDir);
2618
- fromDir = dirname(fromDir);
2619
- toDir = dirname(toDir);
2656
+ fromDir = posix.dirname(fromDir);
2657
+ toDir = posix.dirname(toDir);
2620
2658
  }
2621
2659
  }
2622
2660
  function addSimpleFileMapping(refs, fromPath, canonicalDir, extension) {
@@ -2660,18 +2698,18 @@ async function targetRootSegments() {
2660
2698
  if (targetRootSegmentsCache !== void 0) return targetRootSegmentsCache;
2661
2699
  const { BUILTIN_TARGETS: BUILTIN_TARGETS2 } = await Promise.resolve().then(() => (init_builtin_targets(), builtin_targets_exports));
2662
2700
  const roots = /* @__PURE__ */ new Set();
2663
- for (const descriptor13 of BUILTIN_TARGETS2) {
2701
+ for (const descriptor14 of BUILTIN_TARGETS2) {
2664
2702
  for (const path of [
2665
- descriptor13.project.rootInstructionPath,
2666
- descriptor13.project.skillDir,
2667
- ...descriptor13.project.managedOutputs?.dirs ?? [],
2668
- ...descriptor13.project.managedOutputs?.files ?? [],
2669
- ...descriptor13.detectionPaths,
2670
- descriptor13.globalSupport?.layout.rootInstructionPath,
2671
- descriptor13.globalSupport?.layout.skillDir,
2672
- ...descriptor13.globalSupport?.layout.managedOutputs?.dirs ?? [],
2673
- ...descriptor13.globalSupport?.layout.managedOutputs?.files ?? [],
2674
- ...descriptor13.globalSupport?.detectionPaths ?? []
2703
+ descriptor14.project.rootInstructionPath,
2704
+ descriptor14.project.skillDir,
2705
+ ...descriptor14.project.managedOutputs?.dirs ?? [],
2706
+ ...descriptor14.project.managedOutputs?.files ?? [],
2707
+ ...descriptor14.detectionPaths,
2708
+ descriptor14.globalSupport?.layout.rootInstructionPath,
2709
+ descriptor14.globalSupport?.layout.skillDir,
2710
+ ...descriptor14.globalSupport?.layout.managedOutputs?.dirs ?? [],
2711
+ ...descriptor14.globalSupport?.layout.managedOutputs?.files ?? [],
2712
+ ...descriptor14.globalSupport?.detectionPaths ?? []
2675
2713
  ]) {
2676
2714
  if (path !== void 0) {
2677
2715
  const segment = firstPathSegment(path);
@@ -2688,8 +2726,9 @@ function hasHiddenSegment(relPath) {
2688
2726
  async function listScopedAgentsFiles(projectRoot) {
2689
2727
  const files = [];
2690
2728
  const targetRootSegmentsSet = await targetRootSegments();
2729
+ const api = pathApi(projectRoot);
2691
2730
  async function walk(relDir) {
2692
- const absDir = join(projectRoot, relDir);
2731
+ const absDir = api.join(projectRoot, relDir);
2693
2732
  const entries = await readdir(absDir, { withFileTypes: true }).catch(() => []);
2694
2733
  for (const entry of entries) {
2695
2734
  const relPath = relDir ? `${relDir}/${entry.name}` : entry.name;
@@ -2698,7 +2737,7 @@ async function listScopedAgentsFiles(projectRoot) {
2698
2737
  await walk(relPath);
2699
2738
  continue;
2700
2739
  }
2701
- if (entry.isSymbolicLink() && await stat(join(projectRoot, relPath)).then(
2740
+ if (entry.isSymbolicLink() && await stat(api.join(projectRoot, relPath)).then(
2702
2741
  (info) => info.isDirectory(),
2703
2742
  () => false
2704
2743
  )) {
@@ -2707,7 +2746,7 @@ async function listScopedAgentsFiles(projectRoot) {
2707
2746
  continue;
2708
2747
  }
2709
2748
  if (entry.name === "AGENTS.md" || entry.name === "AGENTS.override.md") {
2710
- files.push(join(projectRoot, relPath));
2749
+ files.push(api.join(projectRoot, relPath));
2711
2750
  }
2712
2751
  }
2713
2752
  }
@@ -2721,7 +2760,7 @@ async function addScopedAgentsMappings(refs, projectRoot) {
2721
2760
  const isNestedAgents = relPath.endsWith("/AGENTS.md") && relPath !== "AGENTS.md" && !relPath.endsWith("/AGENTS.override.md");
2722
2761
  const isNestedOverride = relPath.endsWith("/AGENTS.override.md") && relPath !== "AGENTS.override.md";
2723
2762
  if (!isNestedAgents && !isNestedOverride) continue;
2724
- const parentDir = dirname(relPath);
2763
+ const parentDir = posix.dirname(relPath);
2725
2764
  if (hasHiddenSegment(parentDir)) continue;
2726
2765
  const ruleName = parentDir.replace(/\//g, "-");
2727
2766
  refs.set(relPath, `${AB_RULES}/${ruleName}.md`);
@@ -2730,6 +2769,7 @@ async function addScopedAgentsMappings(refs, projectRoot) {
2730
2769
  var AB_RULES, AB_COMMANDS, AB_AGENTS, AB_SKILLS2, targetRootSegmentsCache;
2731
2770
  var init_import_map_shared = __esm({
2732
2771
  "src/core/reference/import-map-shared.ts"() {
2772
+ init_path_helpers();
2733
2773
  init_fs();
2734
2774
  init_command_skill();
2735
2775
  init_projected_agent_skill();
@@ -3184,9 +3224,100 @@ var init_junie = __esm({
3184
3224
  }
3185
3225
  });
3186
3226
 
3227
+ // src/targets/kilo-code/constants.ts
3228
+ var KILO_CODE_TARGET, KILO_CODE_DIR, KILO_CODE_ROOT_RULE, KILO_CODE_RULES_DIR, KILO_CODE_COMMANDS_DIR, KILO_CODE_AGENTS_DIR, KILO_CODE_SKILLS_DIR, KILO_CODE_MCP_FILE, KILO_CODE_IGNORE, KILO_CODE_LEGACY_DIR, KILO_CODE_LEGACY_RULES_DIR, KILO_CODE_LEGACY_WORKFLOWS_DIR, KILO_CODE_LEGACY_SKILLS_DIR, KILO_CODE_LEGACY_MCP_FILE, KILO_CODE_LEGACY_MODES_FILE, KILO_CODE_GLOBAL_DIR, KILO_CODE_GLOBAL_AGENTS_MD, KILO_CODE_GLOBAL_RULES_DIR, KILO_CODE_GLOBAL_COMMANDS_DIR, KILO_CODE_GLOBAL_AGENTS_DIR, KILO_CODE_GLOBAL_SKILLS_DIR, KILO_CODE_GLOBAL_MCP_FILE, KILO_CODE_GLOBAL_IGNORE, KILO_CODE_GLOBAL_AGENTS_SKILLS_DIR, KILO_CODE_CANONICAL_RULES_DIR, KILO_CODE_CANONICAL_COMMANDS_DIR, KILO_CODE_CANONICAL_AGENTS_DIR, KILO_CODE_CANONICAL_MCP, KILO_CODE_CANONICAL_IGNORE;
3229
+ var init_constants8 = __esm({
3230
+ "src/targets/kilo-code/constants.ts"() {
3231
+ KILO_CODE_TARGET = "kilo-code";
3232
+ KILO_CODE_DIR = ".kilo";
3233
+ KILO_CODE_ROOT_RULE = "AGENTS.md";
3234
+ KILO_CODE_RULES_DIR = `${KILO_CODE_DIR}/rules`;
3235
+ KILO_CODE_COMMANDS_DIR = `${KILO_CODE_DIR}/commands`;
3236
+ KILO_CODE_AGENTS_DIR = `${KILO_CODE_DIR}/agents`;
3237
+ KILO_CODE_SKILLS_DIR = `${KILO_CODE_DIR}/skills`;
3238
+ KILO_CODE_MCP_FILE = `${KILO_CODE_DIR}/mcp.json`;
3239
+ KILO_CODE_IGNORE = ".kilocodeignore";
3240
+ KILO_CODE_LEGACY_DIR = ".kilocode";
3241
+ KILO_CODE_LEGACY_RULES_DIR = `${KILO_CODE_LEGACY_DIR}/rules`;
3242
+ KILO_CODE_LEGACY_WORKFLOWS_DIR = `${KILO_CODE_LEGACY_DIR}/workflows`;
3243
+ KILO_CODE_LEGACY_SKILLS_DIR = `${KILO_CODE_LEGACY_DIR}/skills`;
3244
+ KILO_CODE_LEGACY_MCP_FILE = `${KILO_CODE_LEGACY_DIR}/mcp.json`;
3245
+ KILO_CODE_LEGACY_MODES_FILE = ".kilocodemodes";
3246
+ KILO_CODE_GLOBAL_DIR = ".kilo";
3247
+ KILO_CODE_GLOBAL_AGENTS_MD = `${KILO_CODE_GLOBAL_DIR}/AGENTS.md`;
3248
+ KILO_CODE_GLOBAL_RULES_DIR = `${KILO_CODE_GLOBAL_DIR}/rules`;
3249
+ KILO_CODE_GLOBAL_COMMANDS_DIR = `${KILO_CODE_GLOBAL_DIR}/commands`;
3250
+ KILO_CODE_GLOBAL_AGENTS_DIR = `${KILO_CODE_GLOBAL_DIR}/agents`;
3251
+ KILO_CODE_GLOBAL_SKILLS_DIR = `${KILO_CODE_GLOBAL_DIR}/skills`;
3252
+ KILO_CODE_GLOBAL_MCP_FILE = `${KILO_CODE_GLOBAL_DIR}/mcp.json`;
3253
+ KILO_CODE_GLOBAL_IGNORE = ".kilocodeignore";
3254
+ KILO_CODE_GLOBAL_AGENTS_SKILLS_DIR = ".agents/skills";
3255
+ KILO_CODE_CANONICAL_RULES_DIR = ".agentsmesh/rules";
3256
+ KILO_CODE_CANONICAL_COMMANDS_DIR = ".agentsmesh/commands";
3257
+ KILO_CODE_CANONICAL_AGENTS_DIR = ".agentsmesh/agents";
3258
+ KILO_CODE_CANONICAL_MCP = ".agentsmesh/mcp.json";
3259
+ KILO_CODE_CANONICAL_IGNORE = ".agentsmesh/ignore";
3260
+ }
3261
+ });
3262
+ async function buildKiloCodeImportPaths(refs, projectRoot, scope = "project") {
3263
+ if (scope === "global") {
3264
+ refs.set(KILO_CODE_GLOBAL_AGENTS_MD, `${AB_RULES2}/_root.md`);
3265
+ for (const absPath of await listFiles(projectRoot, KILO_CODE_GLOBAL_RULES_DIR)) {
3266
+ addSimpleFileMapping(refs, rel(projectRoot, absPath), AB_RULES2, ".md");
3267
+ }
3268
+ for (const absPath of await listFiles(projectRoot, KILO_CODE_GLOBAL_COMMANDS_DIR)) {
3269
+ addSimpleFileMapping(refs, rel(projectRoot, absPath), AB_COMMANDS2, ".md");
3270
+ }
3271
+ for (const absPath of await listFiles(projectRoot, KILO_CODE_GLOBAL_AGENTS_DIR)) {
3272
+ addSimpleFileMapping(refs, rel(projectRoot, absPath), AB_AGENTS2, ".md");
3273
+ }
3274
+ for (const absPath of await listFiles(projectRoot, KILO_CODE_GLOBAL_SKILLS_DIR)) {
3275
+ addSkillLikeMapping(refs, rel(projectRoot, absPath), KILO_CODE_GLOBAL_SKILLS_DIR);
3276
+ }
3277
+ refs.set(KILO_CODE_GLOBAL_MCP_FILE, ".agentsmesh/mcp.json");
3278
+ return;
3279
+ }
3280
+ refs.set(KILO_CODE_ROOT_RULE, `${AB_RULES2}/_root.md`);
3281
+ for (const absPath of await listFiles(projectRoot, KILO_CODE_RULES_DIR)) {
3282
+ addSimpleFileMapping(refs, rel(projectRoot, absPath), AB_RULES2, ".md");
3283
+ }
3284
+ for (const absPath of await listFiles(projectRoot, KILO_CODE_COMMANDS_DIR)) {
3285
+ addSimpleFileMapping(refs, rel(projectRoot, absPath), AB_COMMANDS2, ".md");
3286
+ }
3287
+ for (const absPath of await listFiles(projectRoot, KILO_CODE_AGENTS_DIR)) {
3288
+ addSimpleFileMapping(refs, rel(projectRoot, absPath), AB_AGENTS2, ".md");
3289
+ }
3290
+ for (const absPath of await listFiles(projectRoot, KILO_CODE_SKILLS_DIR)) {
3291
+ addSkillLikeMapping(refs, rel(projectRoot, absPath), KILO_CODE_SKILLS_DIR);
3292
+ }
3293
+ refs.set(KILO_CODE_MCP_FILE, ".agentsmesh/mcp.json");
3294
+ for (const absPath of await listFiles(projectRoot, KILO_CODE_LEGACY_RULES_DIR)) {
3295
+ const relPath = rel(projectRoot, absPath);
3296
+ if (basename(relPath) === "00-root.md") {
3297
+ refs.set(relPath, `${AB_RULES2}/_root.md`);
3298
+ continue;
3299
+ }
3300
+ addSimpleFileMapping(refs, relPath, AB_RULES2, ".md");
3301
+ }
3302
+ for (const absPath of await listFiles(projectRoot, KILO_CODE_LEGACY_WORKFLOWS_DIR)) {
3303
+ addSimpleFileMapping(refs, rel(projectRoot, absPath), AB_COMMANDS2, ".md");
3304
+ }
3305
+ for (const absPath of await listFiles(projectRoot, KILO_CODE_LEGACY_SKILLS_DIR)) {
3306
+ addSkillLikeMapping(refs, rel(projectRoot, absPath), KILO_CODE_LEGACY_SKILLS_DIR);
3307
+ }
3308
+ refs.set(KILO_CODE_LEGACY_MCP_FILE, ".agentsmesh/mcp.json");
3309
+ }
3310
+ var init_kilo_code = __esm({
3311
+ "src/core/reference/import-maps/kilo-code.ts"() {
3312
+ init_import_map_shared();
3313
+ init_constants8();
3314
+ init_constants2();
3315
+ }
3316
+ });
3317
+
3187
3318
  // src/targets/kiro/constants.ts
3188
3319
  var KIRO_TARGET, KIRO_AGENTS_MD, KIRO_DIR, KIRO_STEERING_DIR, KIRO_SKILLS_DIR, KIRO_AGENTS_DIR, KIRO_HOOKS_DIR, KIRO_SETTINGS_DIR, KIRO_MCP_FILE, KIRO_IGNORE, KIRO_GLOBAL_STEERING_DIR, KIRO_GLOBAL_STEERING_AGENTS_MD, KIRO_GLOBAL_SKILLS_DIR, KIRO_GLOBAL_AGENTS_DIR, KIRO_GLOBAL_MCP_FILE, KIRO_GLOBAL_IGNORE, KIRO_GLOBAL_AGENTS_SKILLS_DIR, KIRO_CANONICAL_ROOT_RULE, KIRO_CANONICAL_RULES_DIR, KIRO_CANONICAL_AGENTS_DIR, KIRO_CANONICAL_MCP, KIRO_CANONICAL_HOOKS, KIRO_CANONICAL_IGNORE;
3189
- var init_constants8 = __esm({
3320
+ var init_constants9 = __esm({
3190
3321
  "src/targets/kiro/constants.ts"() {
3191
3322
  KIRO_TARGET = "kiro";
3192
3323
  KIRO_AGENTS_MD = "AGENTS.md";
@@ -3245,14 +3376,14 @@ async function buildKiroImportPaths(refs, projectRoot, scope = "project") {
3245
3376
  var init_kiro = __esm({
3246
3377
  "src/core/reference/import-maps/kiro.ts"() {
3247
3378
  init_import_map_shared();
3248
- init_constants8();
3379
+ init_constants9();
3249
3380
  init_constants2();
3250
3381
  }
3251
3382
  });
3252
3383
 
3253
3384
  // src/targets/roo-code/constants.ts
3254
3385
  var ROO_CODE_TARGET, ROO_CODE_DIR, ROO_CODE_ROOT_RULE, ROO_CODE_ROOT_RULE_FALLBACK, ROO_CODE_RULES_DIR, ROO_CODE_COMMANDS_DIR, ROO_CODE_SKILLS_DIR, ROO_CODE_MCP_FILE, ROO_CODE_IGNORE, ROO_CODE_MODES_FILE, ROO_CODE_GLOBAL_MODES_FILE, ROO_CODE_GLOBAL_DIR, ROO_CODE_GLOBAL_RULES_DIR, ROO_CODE_GLOBAL_COMMANDS_DIR, ROO_CODE_GLOBAL_SKILLS_DIR, ROO_CODE_GLOBAL_MCP_FILE, ROO_CODE_GLOBAL_IGNORE, ROO_CODE_GLOBAL_AGENTS_MD, ROO_CODE_GLOBAL_AGENTS_SKILLS_DIR, ROO_CODE_CANONICAL_RULES_DIR, ROO_CODE_CANONICAL_COMMANDS_DIR, ROO_CODE_CANONICAL_MCP, ROO_CODE_CANONICAL_IGNORE;
3255
- var init_constants9 = __esm({
3386
+ var init_constants10 = __esm({
3256
3387
  "src/targets/roo-code/constants.ts"() {
3257
3388
  ROO_CODE_TARGET = "roo-code";
3258
3389
  ROO_CODE_DIR = ".roo";
@@ -3319,7 +3450,7 @@ async function buildRooCodeImportPaths(refs, projectRoot, scope = "project") {
3319
3450
  var init_roo_code = __esm({
3320
3451
  "src/core/reference/import-maps/roo-code.ts"() {
3321
3452
  init_import_map_shared();
3322
- init_constants9();
3453
+ init_constants10();
3323
3454
  init_constants2();
3324
3455
  }
3325
3456
  });
@@ -3358,6 +3489,7 @@ var init_import_maps = __esm({
3358
3489
  init_cursor();
3359
3490
  init_gemini_cli();
3360
3491
  init_junie();
3492
+ init_kilo_code();
3361
3493
  init_kiro();
3362
3494
  init_roo_code();
3363
3495
  init_windsurf();
@@ -3849,10 +3981,8 @@ async function importSettings(projectRoot, results) {
3849
3981
  }
3850
3982
  const alreadyImportedMcp = results.some((r) => r.feature === "mcp");
3851
3983
  if (!alreadyImportedMcp && settings.mcpServers && typeof settings.mcpServers === "object") {
3852
- const mcpContent = JSON.stringify({ mcpServers: settings.mcpServers }, null, 2);
3853
- const destPath = join(projectRoot, CLAUDE_CANONICAL_MCP);
3854
- await mkdirp(dirname(destPath));
3855
- await writeFileAtomic(destPath, mcpContent);
3984
+ const mcpServers = settings.mcpServers;
3985
+ await writeMcpWithMerge(projectRoot, CLAUDE_CANONICAL_MCP, mcpServers);
3856
3986
  results.push({
3857
3987
  fromTool: "claude-code",
3858
3988
  fromPath: settingsPath,
@@ -3900,6 +4030,7 @@ var init_settings_helpers = __esm({
3900
4030
  "src/targets/claude-code/settings-helpers.ts"() {
3901
4031
  init_hook_command();
3902
4032
  init_fs();
4033
+ init_mcp_merge();
3903
4034
  init_constants3();
3904
4035
  }
3905
4036
  });
@@ -4859,11 +4990,11 @@ var init_linter3 = __esm({
4859
4990
  });
4860
4991
 
4861
4992
  // src/core/lint/shared/helpers.ts
4862
- function createWarning(file, target13, message) {
4993
+ function createWarning(file, target14, message) {
4863
4994
  return {
4864
4995
  level: "warning",
4865
4996
  file,
4866
- target: target13,
4997
+ target: target14,
4867
4998
  message
4868
4999
  };
4869
5000
  }
@@ -4873,12 +5004,12 @@ function formatOxfordComma(items) {
4873
5004
  if (items.length === 2) return `${items[0]} and ${items[1]}`;
4874
5005
  return `${items.slice(0, -1).join(", ")}, and ${items[items.length - 1]}`;
4875
5006
  }
4876
- function createUnsupportedHookWarning(event, target13, supportedEvents, options) {
4877
- const by = options?.unsupportedBy ?? target13;
5007
+ function createUnsupportedHookWarning(event, target14, supportedEvents, options) {
5008
+ const by = options?.unsupportedBy ?? target14;
4878
5009
  const supported = formatOxfordComma(supportedEvents);
4879
5010
  return createWarning(
4880
5011
  ".agentsmesh/hooks.yaml",
4881
- target13,
5012
+ target14,
4882
5013
  `${event} is not supported by ${by}; only ${supported} are projected.`
4883
5014
  );
4884
5015
  }
@@ -5062,7 +5193,7 @@ var init_cline2 = __esm({
5062
5193
 
5063
5194
  // src/targets/codex-cli/constants.ts
5064
5195
  var CODEX_TARGET, CODEX_MD, AGENTS_MD, CODEX_GLOBAL_AGENTS_MD, CODEX_GLOBAL_AGENTS_OVERRIDE_MD, CODEX_SKILLS_DIR, CODEX_SKILLS_FALLBACK_DIR, CODEX_CONFIG_TOML, CODEX_INSTRUCTIONS_DIR, CODEX_RULES_DIR, CODEX_AGENTS_DIR, CODEX_CANONICAL_RULES_DIR, CODEX_CANONICAL_COMMANDS_DIR, CODEX_CANONICAL_AGENTS_DIR, CODEX_CANONICAL_SKILLS_DIR, CODEX_CANONICAL_MCP, CODEX_RULE_EMBED_MARKER, CODEX_RULE_EMBED_JSON_PREFIX, CODEX_RULE_EMBED_B64_BEGIN, CODEX_RULE_EMBED_B64_END, CODEX_RULE_EMBED_B64_LINE, CODEX_RULE_INDEX_START, CODEX_RULE_INDEX_END;
5065
- var init_constants10 = __esm({
5196
+ var init_constants11 = __esm({
5066
5197
  "src/targets/codex-cli/constants.ts"() {
5067
5198
  CODEX_TARGET = "codex-cli";
5068
5199
  CODEX_MD = "codex.md";
@@ -5125,7 +5256,7 @@ function summarizeRule(rule) {
5125
5256
  scopes.push(`Enforced in \`${CODEX_RULES_DIR}/${ruleSlug2(rule.source)}.rules\`.`);
5126
5257
  }
5127
5258
  if (rule.targets.length > 0) {
5128
- scopes.push(`Targeted to ${rule.targets.map((target13) => `\`${target13}\``).join(", ")}.`);
5259
+ scopes.push(`Targeted to ${rule.targets.map((target14) => `\`${target14}\``).join(", ")}.`);
5129
5260
  }
5130
5261
  return scopes.join(" ");
5131
5262
  }
@@ -5155,7 +5286,7 @@ function stripCodexRuleIndex(content) {
5155
5286
  var init_instruction_mirror = __esm({
5156
5287
  "src/targets/codex-cli/instruction-mirror.ts"() {
5157
5288
  init_markdown();
5158
- init_constants10();
5289
+ init_constants11();
5159
5290
  }
5160
5291
  });
5161
5292
  function looksLikeCodexRulesDsl(body) {
@@ -5221,7 +5352,7 @@ function renderCodexGlobalInstructions(canonical) {
5221
5352
  var init_rules = __esm({
5222
5353
  "src/targets/codex-cli/generator/rules.ts"() {
5223
5354
  init_managed_blocks();
5224
- init_constants10();
5355
+ init_constants11();
5225
5356
  init_instruction_mirror();
5226
5357
  }
5227
5358
  });
@@ -5262,7 +5393,7 @@ function generateCommands4(canonical) {
5262
5393
  var init_skills = __esm({
5263
5394
  "src/targets/codex-cli/generator/skills.ts"() {
5264
5395
  init_markdown();
5265
- init_constants10();
5396
+ init_constants11();
5266
5397
  init_command_skill();
5267
5398
  }
5268
5399
  });
@@ -5303,7 +5434,7 @@ ${body}
5303
5434
  }
5304
5435
  var init_agents = __esm({
5305
5436
  "src/targets/codex-cli/generator/agents.ts"() {
5306
- init_constants10();
5437
+ init_constants11();
5307
5438
  }
5308
5439
  });
5309
5440
 
@@ -5355,7 +5486,7 @@ function needsTomlQuoting(key) {
5355
5486
  var init_mcp = __esm({
5356
5487
  "src/targets/codex-cli/generator/mcp.ts"() {
5357
5488
  init_mcp_servers();
5358
- init_constants10();
5489
+ init_constants11();
5359
5490
  }
5360
5491
  });
5361
5492
 
@@ -5414,11 +5545,7 @@ async function importMcp(projectRoot, results) {
5414
5545
  if (server) mcpServers[name] = server;
5415
5546
  }
5416
5547
  if (Object.keys(mcpServers).length === 0) return;
5417
- await mkdirp(join(projectRoot, ".agentsmesh"));
5418
- await writeFileAtomic(
5419
- join(projectRoot, CODEX_CANONICAL_MCP),
5420
- JSON.stringify({ mcpServers }, null, 2)
5421
- );
5548
+ await writeMcpWithMerge(projectRoot, CODEX_CANONICAL_MCP, mcpServers);
5422
5549
  results.push({
5423
5550
  fromTool: CODEX_TARGET,
5424
5551
  fromPath: configPath,
@@ -5429,7 +5556,8 @@ async function importMcp(projectRoot, results) {
5429
5556
  var init_mcp_helpers = __esm({
5430
5557
  "src/targets/codex-cli/mcp-helpers.ts"() {
5431
5558
  init_fs();
5432
- init_constants10();
5559
+ init_mcp_merge();
5560
+ init_constants11();
5433
5561
  }
5434
5562
  });
5435
5563
  function shouldImportScopedAgentsRule(relDir) {
@@ -5523,7 +5651,7 @@ var init_skills_adapter2 = __esm({
5523
5651
  init_projected_agent_skill();
5524
5652
  init_scoped_agents_import();
5525
5653
  init_skill_import_pipeline();
5526
- init_constants10();
5654
+ init_constants11();
5527
5655
  }
5528
5656
  });
5529
5657
  async function importCodexAgentsFromToml(projectRoot, results, normalize) {
@@ -5576,7 +5704,7 @@ var init_importer_agents = __esm({
5576
5704
  "src/targets/codex-cli/importer-agents.ts"() {
5577
5705
  init_fs();
5578
5706
  init_projected_agent_skill();
5579
- init_constants10();
5707
+ init_constants11();
5580
5708
  }
5581
5709
  });
5582
5710
  function tryParseEmbeddedCanonicalFromCodexRules(content) {
@@ -5619,7 +5747,7 @@ function tryParseEmbeddedCanonicalFromCodexRules(content) {
5619
5747
  }
5620
5748
  var init_codex_rules_embed = __esm({
5621
5749
  "src/targets/codex-cli/codex-rules-embed.ts"() {
5622
- init_constants10();
5750
+ init_constants11();
5623
5751
  }
5624
5752
  });
5625
5753
  async function importCodexNonRootRuleFiles(projectRoot, destDir, normalize) {
@@ -5693,7 +5821,7 @@ var init_import_codex_non_root_rules = __esm({
5693
5821
  init_fs();
5694
5822
  init_markdown();
5695
5823
  init_import_metadata();
5696
- init_constants10();
5824
+ init_constants11();
5697
5825
  init_codex_rules_embed();
5698
5826
  }
5699
5827
  });
@@ -5815,7 +5943,7 @@ var init_importer_rules2 = __esm({
5815
5943
  init_embedded_rules();
5816
5944
  init_import_orchestrator();
5817
5945
  init_scoped_agents_import();
5818
- init_constants10();
5946
+ init_constants11();
5819
5947
  init_import_codex_non_root_rules();
5820
5948
  init_instruction_mirror();
5821
5949
  }
@@ -5840,7 +5968,7 @@ async function importFromCodex(projectRoot, options) {
5840
5968
  var init_importer4 = __esm({
5841
5969
  "src/targets/codex-cli/importer.ts"() {
5842
5970
  init_import_rewriter();
5843
- init_constants10();
5971
+ init_constants11();
5844
5972
  init_mcp_helpers();
5845
5973
  init_skills_adapter2();
5846
5974
  init_importer_agents();
@@ -5865,7 +5993,7 @@ function lintRules4(canonical, projectRoot, _projectFiles) {
5865
5993
  }
5866
5994
  var init_linter4 = __esm({
5867
5995
  "src/targets/codex-cli/linter.ts"() {
5868
- init_constants10();
5996
+ init_constants11();
5869
5997
  }
5870
5998
  });
5871
5999
 
@@ -5915,7 +6043,7 @@ var target4, project4, global3, globalCapabilities4, descriptor4;
5915
6043
  var init_codex_cli2 = __esm({
5916
6044
  "src/targets/codex-cli/index.ts"() {
5917
6045
  init_generator5();
5918
- init_constants10();
6046
+ init_constants11();
5919
6047
  init_importer4();
5920
6048
  init_linter4();
5921
6049
  init_lint2();
@@ -6179,10 +6307,7 @@ async function importMcp2(projectRoot, results) {
6179
6307
  importedFrom.push(srcPath);
6180
6308
  }
6181
6309
  if (Object.keys(merged).length === 0) return;
6182
- await writeFileAtomic(
6183
- join(projectRoot, CONTINUE_CANONICAL_MCP),
6184
- JSON.stringify({ mcpServers: merged }, null, 2)
6185
- );
6310
+ await writeMcpWithMerge(projectRoot, CONTINUE_CANONICAL_MCP, merged);
6186
6311
  for (const fromPath of importedFrom) {
6187
6312
  results.push({
6188
6313
  fromTool: CONTINUE_TARGET,
@@ -6206,6 +6331,7 @@ var init_importer5 = __esm({
6206
6331
  init_fs();
6207
6332
  init_embedded_skill();
6208
6333
  init_descriptor_import_runner();
6334
+ init_mcp_merge();
6209
6335
  init_shared_import_helpers();
6210
6336
  init_constants5();
6211
6337
  init_continue2();
@@ -6536,7 +6662,7 @@ var init_continue2 = __esm({
6536
6662
 
6537
6663
  // src/targets/copilot/constants.ts
6538
6664
  var COPILOT_TARGET, COPILOT_INSTRUCTIONS, COPILOT_CONTEXT_DIR, COPILOT_INSTRUCTIONS_DIR, COPILOT_PROMPTS_DIR, COPILOT_HOOKS_DIR, COPILOT_SKILLS_DIR, COPILOT_AGENTS_DIR, COPILOT_CANONICAL_RULES_DIR, COPILOT_CANONICAL_COMMANDS_DIR, COPILOT_CANONICAL_AGENTS_DIR, COPILOT_CANONICAL_SKILLS_DIR, COPILOT_CANONICAL_HOOKS, COPILOT_LEGACY_HOOKS_DIR, COPILOT_GLOBAL_INSTRUCTIONS, COPILOT_GLOBAL_AGENTS_DIR, COPILOT_GLOBAL_SKILLS_DIR, COPILOT_GLOBAL_PROMPTS_DIR, COPILOT_GLOBAL_AGENTS_MD, COPILOT_GLOBAL_CLAUDE_SKILLS_DIR, COPILOT_GLOBAL_AGENTS_SKILLS_DIR;
6539
- var init_constants11 = __esm({
6665
+ var init_constants12 = __esm({
6540
6666
  "src/targets/copilot/constants.ts"() {
6541
6667
  COPILOT_TARGET = "copilot";
6542
6668
  COPILOT_INSTRUCTIONS = ".github/copilot-instructions.md";
@@ -6601,7 +6727,7 @@ function parseCommandPromptFrontmatter(frontmatter, promptPath) {
6601
6727
  var init_command_prompt = __esm({
6602
6728
  "src/targets/copilot/command-prompt.ts"() {
6603
6729
  init_markdown();
6604
- init_constants11();
6730
+ init_constants12();
6605
6731
  }
6606
6732
  });
6607
6733
 
@@ -6753,7 +6879,7 @@ function generateHooks3(canonical) {
6753
6879
  var init_generator7 = __esm({
6754
6880
  "src/targets/copilot/generator.ts"() {
6755
6881
  init_markdown();
6756
- init_constants11();
6882
+ init_constants12();
6757
6883
  init_command_prompt();
6758
6884
  init_hook_entry();
6759
6885
  }
@@ -6847,7 +6973,7 @@ async function importHooks(projectRoot, results) {
6847
6973
  var init_hook_parser = __esm({
6848
6974
  "src/targets/copilot/hook-parser.ts"() {
6849
6975
  init_fs();
6850
- init_constants11();
6976
+ init_constants12();
6851
6977
  }
6852
6978
  });
6853
6979
  async function importSkills2(projectRoot, results, normalize, skillsDirRel = COPILOT_SKILLS_DIR) {
@@ -6868,7 +6994,7 @@ async function importSkills2(projectRoot, results, normalize, skillsDirRel = COP
6868
6994
  var init_skills_adapter3 = __esm({
6869
6995
  "src/targets/copilot/skills-adapter.ts"() {
6870
6996
  init_skill_import_pipeline();
6871
- init_constants11();
6997
+ init_constants12();
6872
6998
  }
6873
6999
  });
6874
7000
 
@@ -6891,7 +7017,7 @@ var init_importer6 = __esm({
6891
7017
  "src/targets/copilot/importer.ts"() {
6892
7018
  init_import_rewriter();
6893
7019
  init_descriptor_import_runner();
6894
- init_constants11();
7020
+ init_constants12();
6895
7021
  init_hook_parser();
6896
7022
  init_skills_adapter3();
6897
7023
  init_copilot2();
@@ -6910,7 +7036,7 @@ var init_import_mappers4 = __esm({
6910
7036
  init_import_metadata();
6911
7037
  init_shared_import_helpers();
6912
7038
  init_command_prompt();
6913
- init_constants11();
7039
+ init_constants12();
6914
7040
  copilotLegacyRuleMapper = async ({
6915
7041
  relativePath,
6916
7042
  normalizeTo,
@@ -7027,7 +7153,7 @@ function lintRules6(canonical, projectRoot, projectFiles, options) {
7027
7153
  var init_linter6 = __esm({
7028
7154
  "src/targets/copilot/linter.ts"() {
7029
7155
  init_validate_rules();
7030
- init_constants11();
7156
+ init_constants12();
7031
7157
  }
7032
7158
  });
7033
7159
 
@@ -7144,7 +7270,7 @@ var SCRIPT_PREFIX_RE;
7144
7270
  var init_hook_assets = __esm({
7145
7271
  "src/targets/copilot/hook-assets.ts"() {
7146
7272
  init_fs();
7147
- init_constants11();
7273
+ init_constants12();
7148
7274
  init_hook_entry();
7149
7275
  SCRIPT_PREFIX_RE = /^(?<prefix>\s*(?:(?:bash|sh|zsh)\s+)?)["']?(?<path>(?:\.\.\/|\.\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?<suffix>(?:\s.*)?)$/;
7150
7276
  }
@@ -7158,7 +7284,7 @@ var generateCopilotGlobalExtras;
7158
7284
  var init_scope_extras2 = __esm({
7159
7285
  "src/targets/copilot/scope-extras.ts"() {
7160
7286
  init_fs();
7161
- init_constants11();
7287
+ init_constants12();
7162
7288
  generateCopilotGlobalExtras = async (canonical, projectRoot, scope, enabledFeatures) => {
7163
7289
  if (scope !== "global" || !enabledFeatures.has("rules")) return [];
7164
7290
  const root = canonical.rules.find((r) => r.root);
@@ -7181,7 +7307,7 @@ var target6, project6, global4, globalCapabilities6, descriptor6;
7181
7307
  var init_copilot2 = __esm({
7182
7308
  "src/targets/copilot/index.ts"() {
7183
7309
  init_generator7();
7184
- init_constants11();
7310
+ init_constants12();
7185
7311
  init_importer6();
7186
7312
  init_import_mappers4();
7187
7313
  init_linter6();
@@ -7950,8 +8076,8 @@ async function hasGlobalCursorArtifacts(projectRoot) {
7950
8076
  join(projectRoot, CURSOR_COMMANDS_DIR)
7951
8077
  ];
7952
8078
  for (const p of candidates) {
7953
- const stat4 = await readFileSafe(p);
7954
- if (stat4 !== null && stat4.trim() !== "") return true;
8079
+ const stat5 = await readFileSafe(p);
8080
+ if (stat5 !== null && stat5.trim() !== "") return true;
7955
8081
  }
7956
8082
  const skillFiles = await readDirRecursive(join(projectRoot, CURSOR_GLOBAL_SKILLS_DIR));
7957
8083
  if (skillFiles.some((f) => f.endsWith(".md"))) return true;
@@ -8109,9 +8235,8 @@ async function importMcp3(projectRoot, results) {
8109
8235
  return;
8110
8236
  }
8111
8237
  if (!parsed || typeof parsed !== "object" || !("mcpServers" in parsed)) return;
8112
- const destPath = join(projectRoot, CURSOR_CANONICAL_MCP);
8113
- await mkdirp(dirname(destPath));
8114
- await writeFileAtomic(destPath, content);
8238
+ const servers = parsed.mcpServers;
8239
+ await writeMcpWithMerge(projectRoot, CURSOR_CANONICAL_MCP, servers);
8115
8240
  results.push({
8116
8241
  fromTool: "cursor",
8117
8242
  fromPath: mcpPath,
@@ -8138,6 +8263,7 @@ var init_importer7 = __esm({
8138
8263
  init_import_rewriter();
8139
8264
  init_fs();
8140
8265
  init_descriptor_import_runner();
8266
+ init_mcp_merge();
8141
8267
  init_importer_rules3();
8142
8268
  init_settings_helpers2();
8143
8269
  init_skills_adapter4();
@@ -8439,7 +8565,7 @@ var init_cursor2 = __esm({
8439
8565
 
8440
8566
  // src/targets/gemini-cli/constants.ts
8441
8567
  var GEMINI_TARGET, GEMINI_ROOT, GEMINI_COMPAT_AGENTS, GEMINI_RULES_DIR, GEMINI_COMPAT_INNER_ROOT, GEMINI_COMMANDS_DIR, GEMINI_POLICIES_DIR, GEMINI_SETTINGS, GEMINI_IGNORE, GEMINI_SKILLS_DIR, GEMINI_AGENTS_DIR, GEMINI_SYSTEM, GEMINI_DEFAULT_POLICIES_FILE, GEMINI_CANONICAL_RULES_DIR, GEMINI_CANONICAL_COMMANDS_DIR, GEMINI_CANONICAL_AGENTS_DIR, GEMINI_CANONICAL_SKILLS_DIR, GEMINI_CANONICAL_MCP, GEMINI_CANONICAL_HOOKS, GEMINI_CANONICAL_IGNORE, GEMINI_CANONICAL_PERMISSIONS, GEMINI_GLOBAL_ROOT, GEMINI_GLOBAL_COMPAT_AGENTS, GEMINI_GLOBAL_SETTINGS, GEMINI_GLOBAL_COMMANDS_DIR, GEMINI_GLOBAL_SKILLS_DIR, GEMINI_GLOBAL_AGENTS_DIR;
8442
- var init_constants12 = __esm({
8568
+ var init_constants13 = __esm({
8443
8569
  "src/targets/gemini-cli/constants.ts"() {
8444
8570
  GEMINI_TARGET = "gemini-cli";
8445
8571
  GEMINI_ROOT = "GEMINI.md";
@@ -8491,7 +8617,7 @@ function generateRules8(canonical) {
8491
8617
  var init_rules3 = __esm({
8492
8618
  "src/targets/gemini-cli/generator/rules.ts"() {
8493
8619
  init_managed_blocks();
8494
- init_constants12();
8620
+ init_constants13();
8495
8621
  }
8496
8622
  });
8497
8623
  function canonicalCommandNameToGeminiTomlPath(cmdName, commandsDir) {
@@ -8531,7 +8657,7 @@ function generateCommands8(canonical) {
8531
8657
  }
8532
8658
  var init_commands2 = __esm({
8533
8659
  "src/targets/gemini-cli/generator/commands.ts"() {
8534
- init_constants12();
8660
+ init_constants13();
8535
8661
  init_command_namespace();
8536
8662
  }
8537
8663
  });
@@ -8559,7 +8685,7 @@ function generateAgents6(canonical) {
8559
8685
  var init_agents3 = __esm({
8560
8686
  "src/targets/gemini-cli/generator/agents.ts"() {
8561
8687
  init_markdown();
8562
- init_constants12();
8688
+ init_constants13();
8563
8689
  }
8564
8690
  });
8565
8691
 
@@ -8590,7 +8716,7 @@ function generateSkills8(canonical) {
8590
8716
  var init_skills3 = __esm({
8591
8717
  "src/targets/gemini-cli/generator/skills.ts"() {
8592
8718
  init_markdown();
8593
- init_constants12();
8719
+ init_constants13();
8594
8720
  }
8595
8721
  });
8596
8722
 
@@ -8651,7 +8777,7 @@ function generateGeminiSettingsFiles(canonical) {
8651
8777
  var init_settings = __esm({
8652
8778
  "src/targets/gemini-cli/generator/settings.ts"() {
8653
8779
  init_hook_command();
8654
- init_constants12();
8780
+ init_constants13();
8655
8781
  }
8656
8782
  });
8657
8783
 
@@ -8662,7 +8788,7 @@ function generateIgnore4(canonical) {
8662
8788
  }
8663
8789
  var init_ignore2 = __esm({
8664
8790
  "src/targets/gemini-cli/generator/ignore.ts"() {
8665
- init_constants12();
8791
+ init_constants13();
8666
8792
  }
8667
8793
  });
8668
8794
 
@@ -8763,7 +8889,7 @@ function generateGeminiPermissionsPolicies(canonical) {
8763
8889
  }
8764
8890
  var init_policies_generator = __esm({
8765
8891
  "src/targets/gemini-cli/policies-generator.ts"() {
8766
- init_constants12();
8892
+ init_constants13();
8767
8893
  }
8768
8894
  });
8769
8895
  function mapGeminiHookEvent(event) {
@@ -8891,7 +9017,7 @@ var init_format_helpers_settings = __esm({
8891
9017
  "src/targets/gemini-cli/format-helpers-settings.ts"() {
8892
9018
  init_hook_command();
8893
9019
  init_fs();
8894
- init_constants12();
9020
+ init_constants13();
8895
9021
  init_format_helpers_shared();
8896
9022
  }
8897
9023
  });
@@ -8916,7 +9042,7 @@ async function importGeminiIgnore(projectRoot, results) {
8916
9042
  var init_format_helpers = __esm({
8917
9043
  "src/targets/gemini-cli/format-helpers.ts"() {
8918
9044
  init_fs();
8919
- init_constants12();
9045
+ init_constants13();
8920
9046
  init_format_helpers_shared();
8921
9047
  init_format_helpers_settings();
8922
9048
  }
@@ -9024,7 +9150,7 @@ async function importGeminiPolicies(projectRoot) {
9024
9150
  var init_policies_importer = __esm({
9025
9151
  "src/targets/gemini-cli/policies-importer.ts"() {
9026
9152
  init_fs();
9027
- init_constants12();
9153
+ init_constants13();
9028
9154
  }
9029
9155
  });
9030
9156
  function stripProjectRootCanonicalPrefix(content, projectRoot) {
@@ -9150,7 +9276,7 @@ var init_importer_skills_agents = __esm({
9150
9276
  init_markdown();
9151
9277
  init_import_metadata();
9152
9278
  init_projected_agent_skill();
9153
- init_constants12();
9279
+ init_constants13();
9154
9280
  }
9155
9281
  });
9156
9282
  async function importRootRule2(projectRoot, results, normalize) {
@@ -9226,7 +9352,7 @@ var init_importer8 = __esm({
9226
9352
  init_import_metadata();
9227
9353
  init_embedded_rules();
9228
9354
  init_descriptor_import_runner();
9229
- init_constants12();
9355
+ init_constants13();
9230
9356
  init_gemini_cli2();
9231
9357
  init_format_helpers();
9232
9358
  init_policies_importer();
@@ -9294,7 +9420,7 @@ var init_importer_mappers3 = __esm({
9294
9420
  init_import_metadata();
9295
9421
  init_shared_import_helpers();
9296
9422
  init_format_helpers();
9297
- init_constants12();
9423
+ init_constants13();
9298
9424
  }
9299
9425
  });
9300
9426
 
@@ -9318,7 +9444,7 @@ function lintRules8(canonical, projectRoot, projectFiles, options) {
9318
9444
  var init_linter8 = __esm({
9319
9445
  "src/targets/gemini-cli/linter.ts"() {
9320
9446
  init_validate_rules();
9321
- init_constants12();
9447
+ init_constants13();
9322
9448
  }
9323
9449
  });
9324
9450
 
@@ -9399,7 +9525,7 @@ var init_gemini_cli2 = __esm({
9399
9525
  init_generator11();
9400
9526
  init_capabilities();
9401
9527
  init_policies_generator();
9402
- init_constants12();
9528
+ init_constants13();
9403
9529
  init_importer8();
9404
9530
  init_import_mappers6();
9405
9531
  init_linter8();
@@ -9973,59 +10099,603 @@ var init_junie2 = __esm({
9973
10099
  };
9974
10100
  }
9975
10101
  });
9976
- function toKebab(value) {
9977
- return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
9978
- }
9979
- function hookText(entry) {
9980
- return entry.type === "prompt" ? entry.prompt : entry.command;
9981
- }
9982
- function toWhen(event, matcher) {
9983
- const type = CANONICAL_TO_KIRO[event];
9984
- if (event === "PreToolUse" || event === "PostToolUse") {
9985
- return { type, tools: [matcher || "*"] };
9986
- }
9987
- return { type };
9988
- }
9989
- function generateKiroHooks(hooks) {
10102
+ function generateRules10(canonical) {
9990
10103
  const outputs = [];
9991
- for (const [event, entries] of Object.entries(hooks)) {
9992
- const mappedEvent = event;
9993
- if (!(mappedEvent in CANONICAL_TO_KIRO) || !Array.isArray(entries)) continue;
9994
- let index = 1;
9995
- for (const entry of entries) {
9996
- const text = hookText(entry);
9997
- if (!text) continue;
9998
- const file = {
9999
- name: `${toKebab(event)} ${index}`,
10000
- version: "1",
10001
- when: toWhen(mappedEvent, entry.matcher),
10002
- then: entry.type === "prompt" ? { type: "askAgent", prompt: text } : { type: "shellCommand", command: text }
10003
- };
10004
- outputs.push({
10005
- name: `${toKebab(event)}-${index}.kiro.hook`,
10006
- content: JSON.stringify(file, null, 2)
10007
- });
10008
- index += 1;
10009
- }
10104
+ const root = canonical.rules.find((rule) => rule.root);
10105
+ if (root) {
10106
+ outputs.push({
10107
+ path: KILO_CODE_ROOT_RULE,
10108
+ content: root.body.trim() ? root.body : ""
10109
+ });
10110
+ }
10111
+ for (const rule of canonical.rules) {
10112
+ if (rule.root) continue;
10113
+ if (rule.targets.length > 0 && !rule.targets.includes(KILO_CODE_TARGET)) continue;
10114
+ const slug = basename(rule.source, ".md");
10115
+ const frontmatter = {};
10116
+ if (rule.description) frontmatter.description = rule.description;
10117
+ if (rule.globs.length > 0) frontmatter.globs = rule.globs;
10118
+ const content = Object.keys(frontmatter).length > 0 ? serializeFrontmatter(frontmatter, rule.body.trim() || "") : rule.body.trim() || "";
10119
+ outputs.push({
10120
+ path: `${KILO_CODE_RULES_DIR}/${slug}.md`,
10121
+ content
10122
+ });
10010
10123
  }
10011
10124
  return outputs;
10012
10125
  }
10013
- function toCanonicalEntry(file) {
10014
- const canonicalEvent = KIRO_TO_CANONICAL.get(file.when.type);
10015
- if (!canonicalEvent) return null;
10016
- const matcher = file.when.tools?.[0] ?? file.when.patterns?.[0] ?? "*";
10017
- if (file.then.type === "askAgent" && typeof file.then.prompt === "string") {
10126
+ function generateCommands10(canonical) {
10127
+ return canonical.commands.map((command) => {
10128
+ const frontmatter = {};
10129
+ if (command.description) frontmatter.description = command.description;
10018
10130
  return {
10019
- event: canonicalEvent,
10020
- entry: {
10021
- matcher,
10022
- command: file.then.prompt,
10023
- prompt: file.then.prompt,
10024
- type: "prompt"
10025
- }
10131
+ path: `${KILO_CODE_COMMANDS_DIR}/${command.name}.md`,
10132
+ content: serializeFrontmatter(frontmatter, command.body.trim() || "")
10026
10133
  };
10027
- }
10028
- if (file.then.type === "shellCommand" && typeof file.then.command === "string") {
10134
+ });
10135
+ }
10136
+ function generateAgents8(canonical) {
10137
+ return canonical.agents.map((agent) => {
10138
+ const slug = basename(agent.source, ".md");
10139
+ const frontmatter = { mode: "subagent" };
10140
+ if (agent.description) frontmatter.description = agent.description;
10141
+ if (agent.model) frontmatter.model = agent.model;
10142
+ if (agent.tools.length > 0) frontmatter.tools = agent.tools;
10143
+ if (agent.disallowedTools.length > 0) frontmatter.disallowedTools = agent.disallowedTools;
10144
+ return {
10145
+ path: `${KILO_CODE_AGENTS_DIR}/${slug}.md`,
10146
+ content: serializeFrontmatter(frontmatter, agent.body.trim() || "")
10147
+ };
10148
+ });
10149
+ }
10150
+ function generateMcp8(canonical) {
10151
+ if (!canonical.mcp || Object.keys(canonical.mcp.mcpServers).length === 0) return [];
10152
+ return [
10153
+ {
10154
+ path: KILO_CODE_MCP_FILE,
10155
+ content: JSON.stringify({ mcpServers: canonical.mcp.mcpServers }, null, 2)
10156
+ }
10157
+ ];
10158
+ }
10159
+ function generateIgnore6(canonical) {
10160
+ if (canonical.ignore.length === 0) return [];
10161
+ return [{ path: KILO_CODE_IGNORE, content: canonical.ignore.join("\n") }];
10162
+ }
10163
+ function generateSkills10(canonical) {
10164
+ return generateEmbeddedSkills(canonical, KILO_CODE_SKILLS_DIR);
10165
+ }
10166
+ var init_generator13 = __esm({
10167
+ "src/targets/kilo-code/generator.ts"() {
10168
+ init_embedded_skill();
10169
+ init_markdown();
10170
+ init_constants8();
10171
+ }
10172
+ });
10173
+ var kiloNonRootRuleMapper, kiloCommandMapper, kiloAgentMapper;
10174
+ var init_import_mappers7 = __esm({
10175
+ "src/targets/kilo-code/import-mappers.ts"() {
10176
+ init_markdown();
10177
+ init_import_metadata();
10178
+ init_constants8();
10179
+ kiloNonRootRuleMapper = async ({
10180
+ relativePath,
10181
+ normalizeTo,
10182
+ destDir
10183
+ }) => {
10184
+ const destPath = join(destDir, relativePath);
10185
+ const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
10186
+ return {
10187
+ destPath,
10188
+ toPath: `${KILO_CODE_CANONICAL_RULES_DIR}/${relativePath}`,
10189
+ content: await serializeImportedRuleWithFallback(
10190
+ destPath,
10191
+ {
10192
+ root: false,
10193
+ description: typeof frontmatter.description === "string" ? frontmatter.description : void 0,
10194
+ globs: Array.isArray(frontmatter.globs) ? frontmatter.globs : void 0
10195
+ },
10196
+ body
10197
+ )
10198
+ };
10199
+ };
10200
+ kiloCommandMapper = async ({
10201
+ relativePath,
10202
+ normalizeTo,
10203
+ destDir
10204
+ }) => {
10205
+ const destPath = join(destDir, relativePath);
10206
+ const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
10207
+ return {
10208
+ destPath,
10209
+ toPath: `${KILO_CODE_CANONICAL_COMMANDS_DIR}/${relativePath}`,
10210
+ content: await serializeImportedCommandWithFallback(
10211
+ destPath,
10212
+ {
10213
+ hasDescription: Object.prototype.hasOwnProperty.call(frontmatter, "description"),
10214
+ description: typeof frontmatter.description === "string" ? frontmatter.description : void 0,
10215
+ hasAllowedTools: false,
10216
+ allowedTools: []
10217
+ },
10218
+ body
10219
+ )
10220
+ };
10221
+ };
10222
+ kiloAgentMapper = async ({
10223
+ relativePath,
10224
+ normalizeTo,
10225
+ destDir
10226
+ }) => {
10227
+ const destPath = join(destDir, relativePath);
10228
+ const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
10229
+ return {
10230
+ destPath,
10231
+ toPath: `${KILO_CODE_CANONICAL_AGENTS_DIR}/${relativePath}`,
10232
+ content: await serializeImportedAgentWithFallback(destPath, frontmatter, body)
10233
+ };
10234
+ };
10235
+ }
10236
+ });
10237
+ async function pathExists(absolutePath) {
10238
+ try {
10239
+ await stat(absolutePath);
10240
+ return true;
10241
+ } catch {
10242
+ return false;
10243
+ }
10244
+ }
10245
+ async function importLegacyRules(projectRoot, results, normalize) {
10246
+ const srcDir = join(projectRoot, KILO_CODE_LEGACY_RULES_DIR);
10247
+ if (!await pathExists(srcDir)) return;
10248
+ const destDir = join(projectRoot, KILO_CODE_CANONICAL_RULES_DIR);
10249
+ const rootSourceFile = join(srcDir, LEGACY_ROOT_RULE_FILE);
10250
+ const hasCurrentRoot = results.some((result) => result.toPath === CANONICAL_ROOT_RULE_PATH);
10251
+ const rootContent = hasCurrentRoot ? null : await readFileSafe(rootSourceFile);
10252
+ if (rootContent !== null) {
10253
+ const destPath = join(projectRoot, CANONICAL_ROOT_RULE_PATH);
10254
+ const normalized = normalize(rootContent, rootSourceFile, destPath);
10255
+ const { body } = parseFrontmatter(normalized);
10256
+ const serialized = await serializeImportedRuleWithFallback(destPath, { root: true }, body);
10257
+ await writeFileAtomic(destPath, serialized);
10258
+ results.push({
10259
+ feature: "rules",
10260
+ fromTool: KILO_CODE_TARGET,
10261
+ fromPath: `${KILO_CODE_LEGACY_RULES_DIR}/${LEGACY_ROOT_RULE_FILE}`,
10262
+ toPath: CANONICAL_ROOT_RULE_PATH
10263
+ });
10264
+ }
10265
+ results.push(
10266
+ ...await importFileDirectory({
10267
+ srcDir,
10268
+ destDir,
10269
+ extensions: [".md"],
10270
+ fromTool: KILO_CODE_TARGET,
10271
+ normalize,
10272
+ mapEntry: async ({ srcPath, relativePath, content, normalizeTo }) => {
10273
+ const mapping = await kiloNonRootRuleMapper({
10274
+ absolutePath: srcPath,
10275
+ relativePath,
10276
+ content,
10277
+ destDir,
10278
+ normalizeTo
10279
+ });
10280
+ if (relativePath === LEGACY_ROOT_RULE_FILE) return null;
10281
+ if (!mapping) return null;
10282
+ return { ...mapping, feature: "rules" };
10283
+ }
10284
+ })
10285
+ );
10286
+ }
10287
+ async function importLegacyWorkflows(projectRoot, results, normalize) {
10288
+ const srcDir = join(projectRoot, KILO_CODE_LEGACY_WORKFLOWS_DIR);
10289
+ if (!await pathExists(srcDir)) return;
10290
+ const destDir = join(projectRoot, KILO_CODE_CANONICAL_COMMANDS_DIR);
10291
+ results.push(
10292
+ ...await importFileDirectory({
10293
+ srcDir,
10294
+ destDir,
10295
+ extensions: [".md"],
10296
+ fromTool: KILO_CODE_TARGET,
10297
+ normalize,
10298
+ mapEntry: async ({ srcPath, relativePath, content, normalizeTo }) => {
10299
+ const mapping = await kiloCommandMapper({
10300
+ absolutePath: srcPath,
10301
+ relativePath,
10302
+ content,
10303
+ destDir,
10304
+ normalizeTo
10305
+ });
10306
+ if (!mapping) return null;
10307
+ return { ...mapping, feature: "commands" };
10308
+ }
10309
+ })
10310
+ );
10311
+ }
10312
+ async function importLegacyModes(projectRoot, results, normalize) {
10313
+ const sourceFile = join(projectRoot, KILO_CODE_LEGACY_MODES_FILE);
10314
+ const content = await readFileSafe(sourceFile);
10315
+ if (content === null) return;
10316
+ let parsed;
10317
+ try {
10318
+ parsed = parse(content);
10319
+ } catch {
10320
+ return;
10321
+ }
10322
+ if (!parsed || !Array.isArray(parsed.customModes)) return;
10323
+ for (const raw of parsed.customModes) {
10324
+ if (!raw || typeof raw !== "object") continue;
10325
+ const mode = raw;
10326
+ if (typeof mode.slug !== "string" || mode.slug.length === 0) continue;
10327
+ const slug = mode.slug;
10328
+ const destPath = join(projectRoot, KILO_CODE_CANONICAL_AGENTS_DIR, `${slug}.md`);
10329
+ const description = typeof mode.description === "string" ? mode.description : "";
10330
+ const role = typeof mode.roleDefinition === "string" ? mode.roleDefinition.trim() : "";
10331
+ const whenToUse = typeof mode.whenToUse === "string" ? mode.whenToUse.trim() : "";
10332
+ const body = whenToUse ? `${role}
10333
+
10334
+ ## When to use
10335
+
10336
+ ${whenToUse}` : role;
10337
+ const frontmatter = {};
10338
+ if (description) frontmatter.description = description;
10339
+ if (typeof mode.name === "string" && mode.name.length > 0) frontmatter.name = mode.name;
10340
+ const serialized = await serializeImportedAgentWithFallback(destPath, frontmatter, body);
10341
+ const normalized = normalize(serialized, sourceFile, destPath);
10342
+ await writeFileAtomic(destPath, normalized);
10343
+ results.push({
10344
+ feature: "agents",
10345
+ fromTool: KILO_CODE_TARGET,
10346
+ fromPath: sourceFile,
10347
+ toPath: `${KILO_CODE_CANONICAL_AGENTS_DIR}/${slug}.md`
10348
+ });
10349
+ }
10350
+ }
10351
+ async function importFromKiloCode(projectRoot, options = {}) {
10352
+ const scope = options.scope ?? "project";
10353
+ const results = [];
10354
+ const normalize = await createImportReferenceNormalizer(KILO_CODE_TARGET, projectRoot, scope);
10355
+ results.push(...await runDescriptorImport(descriptor10, projectRoot, scope, { normalize }));
10356
+ await importEmbeddedSkills(
10357
+ projectRoot,
10358
+ KILO_CODE_SKILLS_DIR,
10359
+ KILO_CODE_TARGET,
10360
+ results,
10361
+ normalize
10362
+ );
10363
+ if (scope === "project") {
10364
+ await importLegacyRules(projectRoot, results, normalize);
10365
+ await importLegacyWorkflows(projectRoot, results, normalize);
10366
+ await importLegacyModes(projectRoot, results, normalize);
10367
+ await importEmbeddedSkills(
10368
+ projectRoot,
10369
+ KILO_CODE_LEGACY_SKILLS_DIR,
10370
+ KILO_CODE_TARGET,
10371
+ results,
10372
+ normalize
10373
+ );
10374
+ }
10375
+ return results;
10376
+ }
10377
+ var CANONICAL_ROOT_RULE_PATH, LEGACY_ROOT_RULE_FILE;
10378
+ var init_importer10 = __esm({
10379
+ "src/targets/kilo-code/importer.ts"() {
10380
+ init_import_rewriter();
10381
+ init_embedded_skill();
10382
+ init_import_orchestrator();
10383
+ init_descriptor_import_runner();
10384
+ init_fs();
10385
+ init_import_metadata();
10386
+ init_markdown();
10387
+ init_import_mappers7();
10388
+ init_constants8();
10389
+ init_kilo_code2();
10390
+ CANONICAL_ROOT_RULE_PATH = `${KILO_CODE_CANONICAL_RULES_DIR}/_root.md`;
10391
+ LEGACY_ROOT_RULE_FILE = "00-root.md";
10392
+ }
10393
+ });
10394
+
10395
+ // src/targets/kilo-code/linter.ts
10396
+ function lintRules10(canonical, projectRoot, projectFiles, options) {
10397
+ return validateRules(canonical, projectRoot, projectFiles, {
10398
+ checkGlobMatches: options?.scope !== "global"
10399
+ }).map((diagnostic) => ({
10400
+ ...diagnostic,
10401
+ target: KILO_CODE_TARGET
10402
+ }));
10403
+ }
10404
+ var init_linter10 = __esm({
10405
+ "src/targets/kilo-code/linter.ts"() {
10406
+ init_validate_rules();
10407
+ init_constants8();
10408
+ }
10409
+ });
10410
+
10411
+ // src/targets/kilo-code/lint.ts
10412
+ function lintHooks4(canonical) {
10413
+ if (!canonical.hooks) return [];
10414
+ const hasEntries = Object.values(canonical.hooks).some(
10415
+ (entries) => Array.isArray(entries) && entries.length > 0
10416
+ );
10417
+ if (!hasEntries) return [];
10418
+ return [
10419
+ createWarning(
10420
+ ".agentsmesh/hooks.yaml",
10421
+ "kilo-code",
10422
+ "kilo-code does not support user-defined lifecycle hooks; canonical hooks are not projected."
10423
+ )
10424
+ ];
10425
+ }
10426
+ function lintPermissions2(canonical) {
10427
+ if (!canonical.permissions) return [];
10428
+ const { allow, deny } = canonical.permissions;
10429
+ const ask = canonical.permissions.ask ?? [];
10430
+ if (allow.length === 0 && deny.length === 0 && ask.length === 0) return [];
10431
+ return [
10432
+ createWarning(
10433
+ ".agentsmesh/permissions.yaml",
10434
+ "kilo-code",
10435
+ "kilo-code permissions live in kilo.jsonc, which agentsmesh does not generate in v1; canonical permissions are not projected."
10436
+ )
10437
+ ];
10438
+ }
10439
+ var init_lint8 = __esm({
10440
+ "src/targets/kilo-code/lint.ts"() {
10441
+ init_helpers();
10442
+ }
10443
+ });
10444
+
10445
+ // src/targets/kilo-code/index.ts
10446
+ var target10, project10, globalLayout3, capabilities, descriptor10;
10447
+ var init_kilo_code2 = __esm({
10448
+ "src/targets/kilo-code/index.ts"() {
10449
+ init_generator13();
10450
+ init_constants8();
10451
+ init_skill_mirror();
10452
+ init_importer10();
10453
+ init_import_mappers7();
10454
+ init_linter10();
10455
+ init_lint8();
10456
+ init_import_map_builders();
10457
+ target10 = {
10458
+ name: KILO_CODE_TARGET,
10459
+ primaryRootInstructionPath: KILO_CODE_ROOT_RULE,
10460
+ generateRules: generateRules10,
10461
+ generateCommands: generateCommands10,
10462
+ generateAgents: generateAgents8,
10463
+ generateSkills: generateSkills10,
10464
+ generateMcp: generateMcp8,
10465
+ generateIgnore: generateIgnore6,
10466
+ importFrom: importFromKiloCode
10467
+ };
10468
+ project10 = {
10469
+ rootInstructionPath: KILO_CODE_ROOT_RULE,
10470
+ skillDir: KILO_CODE_SKILLS_DIR,
10471
+ managedOutputs: {
10472
+ dirs: [KILO_CODE_RULES_DIR, KILO_CODE_COMMANDS_DIR, KILO_CODE_AGENTS_DIR, KILO_CODE_SKILLS_DIR],
10473
+ files: [KILO_CODE_ROOT_RULE, KILO_CODE_MCP_FILE, KILO_CODE_IGNORE]
10474
+ },
10475
+ paths: {
10476
+ rulePath(slug, _rule) {
10477
+ return `${KILO_CODE_RULES_DIR}/${slug}.md`;
10478
+ },
10479
+ commandPath(name, _config) {
10480
+ return `${KILO_CODE_COMMANDS_DIR}/${name}.md`;
10481
+ },
10482
+ agentPath(name, _config) {
10483
+ return `${KILO_CODE_AGENTS_DIR}/${name}.md`;
10484
+ }
10485
+ }
10486
+ };
10487
+ globalLayout3 = {
10488
+ rootInstructionPath: KILO_CODE_GLOBAL_AGENTS_MD,
10489
+ skillDir: KILO_CODE_GLOBAL_SKILLS_DIR,
10490
+ managedOutputs: {
10491
+ dirs: [
10492
+ KILO_CODE_GLOBAL_RULES_DIR,
10493
+ KILO_CODE_GLOBAL_COMMANDS_DIR,
10494
+ KILO_CODE_GLOBAL_AGENTS_DIR,
10495
+ KILO_CODE_GLOBAL_SKILLS_DIR,
10496
+ KILO_CODE_GLOBAL_AGENTS_SKILLS_DIR
10497
+ ],
10498
+ files: [KILO_CODE_GLOBAL_AGENTS_MD, KILO_CODE_GLOBAL_MCP_FILE, KILO_CODE_GLOBAL_IGNORE]
10499
+ },
10500
+ rewriteGeneratedPath(path) {
10501
+ if (path === KILO_CODE_ROOT_RULE) return KILO_CODE_GLOBAL_AGENTS_MD;
10502
+ return path;
10503
+ },
10504
+ mirrorGlobalPath(path, activeTargets) {
10505
+ return mirrorSkillsToAgents(path, KILO_CODE_GLOBAL_SKILLS_DIR, activeTargets);
10506
+ },
10507
+ paths: {
10508
+ rulePath(slug, _rule) {
10509
+ return `${KILO_CODE_GLOBAL_RULES_DIR}/${slug}.md`;
10510
+ },
10511
+ commandPath(name, _config) {
10512
+ return `${KILO_CODE_GLOBAL_COMMANDS_DIR}/${name}.md`;
10513
+ },
10514
+ agentPath(name, _config) {
10515
+ return `${KILO_CODE_GLOBAL_AGENTS_DIR}/${name}.md`;
10516
+ }
10517
+ }
10518
+ };
10519
+ capabilities = {
10520
+ rules: "native",
10521
+ additionalRules: "native",
10522
+ commands: "native",
10523
+ agents: "native",
10524
+ skills: "native",
10525
+ mcp: "native",
10526
+ hooks: "none",
10527
+ ignore: "native",
10528
+ permissions: "none"
10529
+ };
10530
+ descriptor10 = {
10531
+ id: KILO_CODE_TARGET,
10532
+ generators: target10,
10533
+ capabilities,
10534
+ emptyImportMessage: "No Kilo Code config found (AGENTS.md, .kilo/rules, .kilo/commands, .kilo/agents, .kilo/skills, .kilo/mcp.json, .kilocodeignore, .kilocode/, or .kilocodemodes).",
10535
+ lintRules: lintRules10,
10536
+ lint: {
10537
+ hooks: lintHooks4,
10538
+ permissions: lintPermissions2
10539
+ },
10540
+ project: project10,
10541
+ globalSupport: {
10542
+ capabilities,
10543
+ detectionPaths: [
10544
+ KILO_CODE_GLOBAL_AGENTS_MD,
10545
+ KILO_CODE_GLOBAL_RULES_DIR,
10546
+ KILO_CODE_GLOBAL_COMMANDS_DIR,
10547
+ KILO_CODE_GLOBAL_AGENTS_DIR,
10548
+ KILO_CODE_GLOBAL_SKILLS_DIR,
10549
+ KILO_CODE_GLOBAL_MCP_FILE,
10550
+ KILO_CODE_GLOBAL_IGNORE
10551
+ ],
10552
+ layout: globalLayout3
10553
+ },
10554
+ importer: {
10555
+ rules: [
10556
+ {
10557
+ // Root rule: prefer AGENTS.md (new) → in legacy projects users
10558
+ // historically used .kilocode/rules/00-root.md, but those import
10559
+ // through the descriptor's directory mapper as a regular rule with
10560
+ // slug `00-root` (we don't promote them to root). The legacy global
10561
+ // rules dir falls back to AGENTS.md only.
10562
+ feature: "rules",
10563
+ mode: "singleFile",
10564
+ source: {
10565
+ project: [KILO_CODE_ROOT_RULE],
10566
+ global: [KILO_CODE_GLOBAL_AGENTS_MD]
10567
+ },
10568
+ canonicalDir: KILO_CODE_CANONICAL_RULES_DIR,
10569
+ canonicalRootFilename: "_root.md",
10570
+ markAsRoot: true
10571
+ },
10572
+ {
10573
+ feature: "rules",
10574
+ mode: "directory",
10575
+ source: {
10576
+ project: [KILO_CODE_RULES_DIR],
10577
+ global: [KILO_CODE_GLOBAL_RULES_DIR]
10578
+ },
10579
+ canonicalDir: KILO_CODE_CANONICAL_RULES_DIR,
10580
+ extensions: [".md"],
10581
+ map: kiloNonRootRuleMapper
10582
+ }
10583
+ ],
10584
+ commands: {
10585
+ feature: "commands",
10586
+ mode: "directory",
10587
+ source: {
10588
+ project: [KILO_CODE_COMMANDS_DIR],
10589
+ global: [KILO_CODE_GLOBAL_COMMANDS_DIR]
10590
+ },
10591
+ canonicalDir: KILO_CODE_CANONICAL_COMMANDS_DIR,
10592
+ extensions: [".md"],
10593
+ map: kiloCommandMapper
10594
+ },
10595
+ agents: {
10596
+ feature: "agents",
10597
+ mode: "directory",
10598
+ source: {
10599
+ project: [KILO_CODE_AGENTS_DIR],
10600
+ global: [KILO_CODE_GLOBAL_AGENTS_DIR]
10601
+ },
10602
+ canonicalDir: KILO_CODE_CANONICAL_AGENTS_DIR,
10603
+ extensions: [".md"],
10604
+ map: kiloAgentMapper
10605
+ },
10606
+ mcp: {
10607
+ feature: "mcp",
10608
+ mode: "mcpJson",
10609
+ source: {
10610
+ project: [KILO_CODE_MCP_FILE, KILO_CODE_LEGACY_MCP_FILE],
10611
+ global: [KILO_CODE_GLOBAL_MCP_FILE]
10612
+ },
10613
+ canonicalDir: ".agentsmesh",
10614
+ canonicalFilename: KILO_CODE_CANONICAL_MCP
10615
+ },
10616
+ ignore: {
10617
+ feature: "ignore",
10618
+ mode: "flatFile",
10619
+ source: {
10620
+ project: [KILO_CODE_IGNORE],
10621
+ global: [KILO_CODE_GLOBAL_IGNORE]
10622
+ },
10623
+ canonicalDir: ".agentsmesh",
10624
+ canonicalFilename: KILO_CODE_CANONICAL_IGNORE
10625
+ }
10626
+ },
10627
+ buildImportPaths: buildKiloCodeImportPaths,
10628
+ detectionPaths: [
10629
+ KILO_CODE_RULES_DIR,
10630
+ KILO_CODE_COMMANDS_DIR,
10631
+ KILO_CODE_AGENTS_DIR,
10632
+ KILO_CODE_SKILLS_DIR,
10633
+ KILO_CODE_MCP_FILE,
10634
+ KILO_CODE_LEGACY_RULES_DIR,
10635
+ KILO_CODE_LEGACY_WORKFLOWS_DIR,
10636
+ KILO_CODE_LEGACY_SKILLS_DIR,
10637
+ KILO_CODE_LEGACY_MCP_FILE,
10638
+ KILO_CODE_LEGACY_MODES_FILE,
10639
+ KILO_CODE_IGNORE,
10640
+ "kilo.jsonc",
10641
+ "kilo.json"
10642
+ ]
10643
+ };
10644
+ }
10645
+ });
10646
+ function toKebab(value) {
10647
+ return value.replace(/([a-z0-9])([A-Z])/g, "$1-$2").replace(/_/g, "-").toLowerCase();
10648
+ }
10649
+ function hookText(entry) {
10650
+ return entry.type === "prompt" ? entry.prompt : entry.command;
10651
+ }
10652
+ function toWhen(event, matcher) {
10653
+ const type = CANONICAL_TO_KIRO[event];
10654
+ if (event === "PreToolUse" || event === "PostToolUse") {
10655
+ return { type, tools: [matcher || "*"] };
10656
+ }
10657
+ return { type };
10658
+ }
10659
+ function generateKiroHooks(hooks) {
10660
+ const outputs = [];
10661
+ for (const [event, entries] of Object.entries(hooks)) {
10662
+ const mappedEvent = event;
10663
+ if (!(mappedEvent in CANONICAL_TO_KIRO) || !Array.isArray(entries)) continue;
10664
+ let index = 1;
10665
+ for (const entry of entries) {
10666
+ const text = hookText(entry);
10667
+ if (!text) continue;
10668
+ const file = {
10669
+ name: `${toKebab(event)} ${index}`,
10670
+ version: "1",
10671
+ when: toWhen(mappedEvent, entry.matcher),
10672
+ then: entry.type === "prompt" ? { type: "askAgent", prompt: text } : { type: "shellCommand", command: text }
10673
+ };
10674
+ outputs.push({
10675
+ name: `${toKebab(event)}-${index}.kiro.hook`,
10676
+ content: JSON.stringify(file, null, 2)
10677
+ });
10678
+ index += 1;
10679
+ }
10680
+ }
10681
+ return outputs;
10682
+ }
10683
+ function toCanonicalEntry(file) {
10684
+ const canonicalEvent = KIRO_TO_CANONICAL.get(file.when.type);
10685
+ if (!canonicalEvent) return null;
10686
+ const matcher = file.when.tools?.[0] ?? file.when.patterns?.[0] ?? "*";
10687
+ if (file.then.type === "askAgent" && typeof file.then.prompt === "string") {
10688
+ return {
10689
+ event: canonicalEvent,
10690
+ entry: {
10691
+ matcher,
10692
+ command: file.then.prompt,
10693
+ prompt: file.then.prompt,
10694
+ type: "prompt"
10695
+ }
10696
+ };
10697
+ }
10698
+ if (file.then.type === "shellCommand" && typeof file.then.command === "string") {
10029
10699
  return {
10030
10700
  event: canonicalEvent,
10031
10701
  entry: { matcher, command: file.then.command, type: "command" }
@@ -10080,7 +10750,7 @@ function steeringFrontmatter(rule) {
10080
10750
  if (rule.description) frontmatter.description = rule.description;
10081
10751
  return frontmatter;
10082
10752
  }
10083
- function generateRules10(canonical) {
10753
+ function generateRules11(canonical) {
10084
10754
  const outputs = [];
10085
10755
  const root = canonical.rules.find((rule) => rule.root);
10086
10756
  if (root) {
@@ -10097,10 +10767,10 @@ function generateRules10(canonical) {
10097
10767
  }
10098
10768
  return outputs;
10099
10769
  }
10100
- function generateSkills10(canonical) {
10770
+ function generateSkills11(canonical) {
10101
10771
  return generateEmbeddedSkills(canonical, KIRO_SKILLS_DIR);
10102
10772
  }
10103
- function generateMcp8(canonical) {
10773
+ function generateMcp9(canonical) {
10104
10774
  if (!canonical.mcp || Object.keys(canonical.mcp.mcpServers).length === 0) return [];
10105
10775
  return [
10106
10776
  {
@@ -10116,7 +10786,7 @@ function generateHooks5(canonical) {
10116
10786
  content: hook.content
10117
10787
  }));
10118
10788
  }
10119
- function generateAgents8(canonical) {
10789
+ function generateAgents9(canonical) {
10120
10790
  return canonical.agents.map((agent) => {
10121
10791
  const frontmatter = {
10122
10792
  name: agent.name,
@@ -10131,16 +10801,16 @@ function generateAgents8(canonical) {
10131
10801
  return { path: `${KIRO_AGENTS_DIR}/${agent.name}.md`, content };
10132
10802
  });
10133
10803
  }
10134
- function generateIgnore6(canonical) {
10804
+ function generateIgnore7(canonical) {
10135
10805
  if (canonical.ignore.length === 0) return [];
10136
10806
  return [{ path: KIRO_IGNORE, content: canonical.ignore.join("\n") }];
10137
10807
  }
10138
- var init_generator13 = __esm({
10808
+ var init_generator14 = __esm({
10139
10809
  "src/targets/kiro/generator.ts"() {
10140
10810
  init_embedded_skill();
10141
10811
  init_markdown();
10142
10812
  init_hook_format();
10143
- init_constants8();
10813
+ init_constants9();
10144
10814
  }
10145
10815
  });
10146
10816
  function canonicalRuleMeta(frontmatter) {
@@ -10229,12 +10899,12 @@ async function importFromKiro(projectRoot, options = {}) {
10229
10899
  const normalize = await createImportReferenceNormalizer(KIRO_TARGET, projectRoot, scope);
10230
10900
  await importRoot(projectRoot, results, normalize, scope);
10231
10901
  await importNonRootRules(projectRoot, results, normalize);
10232
- results.push(...await runDescriptorImport(descriptor10, projectRoot, scope, { normalize }));
10902
+ results.push(...await runDescriptorImport(descriptor11, projectRoot, scope, { normalize }));
10233
10903
  await importEmbeddedSkills(projectRoot, KIRO_SKILLS_DIR, KIRO_TARGET, results, normalize);
10234
10904
  if (scope === "project") await importHooks2(projectRoot, results);
10235
10905
  return results;
10236
10906
  }
10237
- var init_importer10 = __esm({
10907
+ var init_importer11 = __esm({
10238
10908
  "src/targets/kiro/importer.ts"() {
10239
10909
  init_import_rewriter();
10240
10910
  init_embedded_skill();
@@ -10245,13 +10915,13 @@ var init_importer10 = __esm({
10245
10915
  init_fs();
10246
10916
  init_markdown();
10247
10917
  init_hook_format();
10248
- init_constants8();
10918
+ init_constants9();
10249
10919
  init_kiro2();
10250
10920
  }
10251
10921
  });
10252
10922
 
10253
10923
  // src/targets/kiro/linter.ts
10254
- function lintRules10(canonical, projectRoot, projectFiles, options) {
10924
+ function lintRules11(canonical, projectRoot, projectFiles, options) {
10255
10925
  return validateRules(canonical, projectRoot, projectFiles, {
10256
10926
  checkGlobMatches: options?.scope !== "global"
10257
10927
  }).map((diagnostic) => ({
@@ -10259,15 +10929,15 @@ function lintRules10(canonical, projectRoot, projectFiles, options) {
10259
10929
  target: KIRO_TARGET
10260
10930
  }));
10261
10931
  }
10262
- var init_linter10 = __esm({
10932
+ var init_linter11 = __esm({
10263
10933
  "src/targets/kiro/linter.ts"() {
10264
10934
  init_validate_rules();
10265
- init_constants8();
10935
+ init_constants9();
10266
10936
  }
10267
10937
  });
10268
10938
 
10269
10939
  // src/targets/kiro/lint.ts
10270
- function lintHooks4(canonical) {
10940
+ function lintHooks5(canonical) {
10271
10941
  if (!canonical.hooks || Object.keys(canonical.hooks).length === 0) return [];
10272
10942
  const supported = ["PreToolUse", "PostToolUse", "UserPromptSubmit", "SubagentStop"];
10273
10943
  const supportedSet = new Set(supported);
@@ -10275,35 +10945,35 @@ function lintHooks4(canonical) {
10275
10945
  (event) => createUnsupportedHookWarning(event, "kiro", supported, { unsupportedBy: "Kiro hooks" })
10276
10946
  );
10277
10947
  }
10278
- var init_lint8 = __esm({
10948
+ var init_lint9 = __esm({
10279
10949
  "src/targets/kiro/lint.ts"() {
10280
10950
  init_helpers();
10281
10951
  }
10282
10952
  });
10283
10953
 
10284
10954
  // src/targets/kiro/index.ts
10285
- var target10, project10, global8, globalCapabilities10, descriptor10;
10955
+ var target11, project11, global8, globalCapabilities10, descriptor11;
10286
10956
  var init_kiro2 = __esm({
10287
10957
  "src/targets/kiro/index.ts"() {
10288
- init_generator13();
10958
+ init_generator14();
10289
10959
  init_skill_mirror();
10290
- init_importer10();
10291
- init_linter10();
10292
- init_lint8();
10960
+ init_importer11();
10961
+ init_linter11();
10962
+ init_lint9();
10293
10963
  init_import_map_builders();
10294
- init_constants8();
10295
- target10 = {
10964
+ init_constants9();
10965
+ target11 = {
10296
10966
  name: KIRO_TARGET,
10297
10967
  primaryRootInstructionPath: KIRO_AGENTS_MD,
10298
- generateRules: generateRules10,
10299
- generateAgents: generateAgents8,
10300
- generateSkills: generateSkills10,
10301
- generateMcp: generateMcp8,
10968
+ generateRules: generateRules11,
10969
+ generateAgents: generateAgents9,
10970
+ generateSkills: generateSkills11,
10971
+ generateMcp: generateMcp9,
10302
10972
  generateHooks: generateHooks5,
10303
- generateIgnore: generateIgnore6,
10973
+ generateIgnore: generateIgnore7,
10304
10974
  importFrom: importFromKiro
10305
10975
  };
10306
- project10 = {
10976
+ project11 = {
10307
10977
  rootInstructionPath: KIRO_AGENTS_MD,
10308
10978
  skillDir: KIRO_SKILLS_DIR,
10309
10979
  managedOutputs: {
@@ -10384,9 +11054,9 @@ var init_kiro2 = __esm({
10384
11054
  ignore: "native",
10385
11055
  permissions: "none"
10386
11056
  };
10387
- descriptor10 = {
11057
+ descriptor11 = {
10388
11058
  id: KIRO_TARGET,
10389
- generators: target10,
11059
+ generators: target11,
10390
11060
  capabilities: {
10391
11061
  rules: "native",
10392
11062
  additionalRules: "native",
@@ -10399,11 +11069,11 @@ var init_kiro2 = __esm({
10399
11069
  permissions: "none"
10400
11070
  },
10401
11071
  emptyImportMessage: "No Kiro config found (AGENTS.md, .kiro/steering, .kiro/skills, .kiro/agents, .kiro/hooks, .kiro/settings/mcp.json, or .kiroignore).",
10402
- lintRules: lintRules10,
11072
+ lintRules: lintRules11,
10403
11073
  lint: {
10404
- hooks: lintHooks4
11074
+ hooks: lintHooks5
10405
11075
  },
10406
- project: project10,
11076
+ project: project11,
10407
11077
  globalSupport: {
10408
11078
  capabilities: globalCapabilities10,
10409
11079
  detectionPaths: [
@@ -10452,7 +11122,7 @@ var init_kiro2 = __esm({
10452
11122
  };
10453
11123
  }
10454
11124
  });
10455
- function generateRules11(canonical) {
11125
+ function generateRules12(canonical) {
10456
11126
  const outputs = [];
10457
11127
  const root = canonical.rules.find((rule) => rule.root);
10458
11128
  if (root) {
@@ -10472,7 +11142,7 @@ function generateRules11(canonical) {
10472
11142
  }
10473
11143
  return outputs;
10474
11144
  }
10475
- function generateCommands10(canonical) {
11145
+ function generateCommands11(canonical) {
10476
11146
  return canonical.commands.map((command) => {
10477
11147
  const frontmatter = {};
10478
11148
  if (command.description) frontmatter.description = command.description;
@@ -10482,7 +11152,7 @@ function generateCommands10(canonical) {
10482
11152
  };
10483
11153
  });
10484
11154
  }
10485
- function generateMcp9(canonical) {
11155
+ function generateMcp10(canonical) {
10486
11156
  if (!canonical.mcp || Object.keys(canonical.mcp.mcpServers).length === 0) return [];
10487
11157
  return [
10488
11158
  {
@@ -10491,14 +11161,14 @@ function generateMcp9(canonical) {
10491
11161
  }
10492
11162
  ];
10493
11163
  }
10494
- function generateIgnore7(canonical) {
11164
+ function generateIgnore8(canonical) {
10495
11165
  if (canonical.ignore.length === 0) return [];
10496
11166
  return [{ path: ROO_CODE_IGNORE, content: canonical.ignore.join("\n") }];
10497
11167
  }
10498
- function generateSkills11(canonical) {
11168
+ function generateSkills12(canonical) {
10499
11169
  return generateEmbeddedSkills(canonical, ROO_CODE_SKILLS_DIR);
10500
11170
  }
10501
- function generateAgents9(canonical) {
11171
+ function generateAgents10(canonical) {
10502
11172
  if (canonical.agents.length === 0) return [];
10503
11173
  const customModes = canonical.agents.map((agent) => {
10504
11174
  const slug = basename(agent.source, ".md");
@@ -10509,19 +11179,19 @@ function generateAgents9(canonical) {
10509
11179
  });
10510
11180
  return [{ path: ROO_CODE_MODES_FILE, content: stringify({ customModes }) }];
10511
11181
  }
10512
- var init_generator14 = __esm({
11182
+ var init_generator15 = __esm({
10513
11183
  "src/targets/roo-code/generator.ts"() {
10514
11184
  init_embedded_skill();
10515
11185
  init_markdown();
10516
- init_constants9();
11186
+ init_constants10();
10517
11187
  }
10518
11188
  });
10519
11189
  var rooNonRootRuleMapper, rooCommandMapper;
10520
- var init_import_mappers7 = __esm({
11190
+ var init_import_mappers8 = __esm({
10521
11191
  "src/targets/roo-code/import-mappers.ts"() {
10522
11192
  init_markdown();
10523
11193
  init_import_metadata();
10524
- init_constants9();
11194
+ init_constants10();
10525
11195
  rooNonRootRuleMapper = async ({
10526
11196
  relativePath,
10527
11197
  normalizeTo,
@@ -10605,25 +11275,25 @@ async function importFromRooCode(projectRoot, options = {}) {
10605
11275
  const scope = options.scope ?? "project";
10606
11276
  const results = [];
10607
11277
  const normalize = await createImportReferenceNormalizer(ROO_CODE_TARGET, projectRoot, scope);
10608
- results.push(...await runDescriptorImport(descriptor11, projectRoot, scope, { normalize }));
11278
+ results.push(...await runDescriptorImport(descriptor12, projectRoot, scope, { normalize }));
10609
11279
  await importPerModeRules(projectRoot, results, normalize);
10610
11280
  await importEmbeddedSkills(projectRoot, ROO_CODE_SKILLS_DIR, ROO_CODE_TARGET, results, normalize);
10611
11281
  return results;
10612
11282
  }
10613
- var init_importer11 = __esm({
11283
+ var init_importer12 = __esm({
10614
11284
  "src/targets/roo-code/importer.ts"() {
10615
11285
  init_import_rewriter();
10616
11286
  init_embedded_skill();
10617
11287
  init_import_orchestrator();
10618
11288
  init_descriptor_import_runner();
10619
- init_import_mappers7();
10620
- init_constants9();
11289
+ init_import_mappers8();
11290
+ init_constants10();
10621
11291
  init_roo_code2();
10622
11292
  }
10623
11293
  });
10624
11294
 
10625
11295
  // src/targets/roo-code/linter.ts
10626
- function lintRules11(canonical, projectRoot, projectFiles, options) {
11296
+ function lintRules12(canonical, projectRoot, projectFiles, options) {
10627
11297
  return validateRules(canonical, projectRoot, projectFiles, {
10628
11298
  checkGlobMatches: options?.scope !== "global"
10629
11299
  }).map((diagnostic) => ({
@@ -10631,10 +11301,10 @@ function lintRules11(canonical, projectRoot, projectFiles, options) {
10631
11301
  target: ROO_CODE_TARGET
10632
11302
  }));
10633
11303
  }
10634
- var init_linter11 = __esm({
11304
+ var init_linter12 = __esm({
10635
11305
  "src/targets/roo-code/linter.ts"() {
10636
11306
  init_validate_rules();
10637
- init_constants9();
11307
+ init_constants10();
10638
11308
  }
10639
11309
  });
10640
11310
  function computeStatus5(existing, content) {
@@ -10642,29 +11312,29 @@ function computeStatus5(existing, content) {
10642
11312
  if (existing !== content) return "updated";
10643
11313
  return "unchanged";
10644
11314
  }
10645
- var target11, project11, generateRooGlobalExtras, global9, globalCapabilities11, descriptor11;
11315
+ var target12, project12, generateRooGlobalExtras, global9, globalCapabilities11, descriptor12;
10646
11316
  var init_roo_code2 = __esm({
10647
11317
  "src/targets/roo-code/index.ts"() {
10648
11318
  init_fs();
10649
- init_generator14();
10650
- init_constants9();
11319
+ init_generator15();
11320
+ init_constants10();
10651
11321
  init_skill_mirror();
10652
- init_importer11();
10653
- init_import_mappers7();
10654
- init_linter11();
11322
+ init_importer12();
11323
+ init_import_mappers8();
11324
+ init_linter12();
10655
11325
  init_import_map_builders();
10656
- target11 = {
11326
+ target12 = {
10657
11327
  name: "roo-code",
10658
11328
  primaryRootInstructionPath: ROO_CODE_ROOT_RULE,
10659
- generateRules: generateRules11,
10660
- generateCommands: generateCommands10,
10661
- generateSkills: generateSkills11,
10662
- generateMcp: generateMcp9,
10663
- generateIgnore: generateIgnore7,
10664
- generateAgents: generateAgents9,
11329
+ generateRules: generateRules12,
11330
+ generateCommands: generateCommands11,
11331
+ generateSkills: generateSkills12,
11332
+ generateMcp: generateMcp10,
11333
+ generateIgnore: generateIgnore8,
11334
+ generateAgents: generateAgents10,
10665
11335
  importFrom: importFromRooCode
10666
11336
  };
10667
- project11 = {
11337
+ project12 = {
10668
11338
  rootInstructionPath: ROO_CODE_ROOT_RULE,
10669
11339
  skillDir: ".roo/skills",
10670
11340
  managedOutputs: {
@@ -10772,9 +11442,9 @@ var init_roo_code2 = __esm({
10772
11442
  ignore: "native",
10773
11443
  permissions: "none"
10774
11444
  };
10775
- descriptor11 = {
11445
+ descriptor12 = {
10776
11446
  id: "roo-code",
10777
- generators: target11,
11447
+ generators: target12,
10778
11448
  capabilities: {
10779
11449
  rules: "native",
10780
11450
  additionalRules: "native",
@@ -10787,8 +11457,8 @@ var init_roo_code2 = __esm({
10787
11457
  permissions: "none"
10788
11458
  },
10789
11459
  emptyImportMessage: "No Roo Code config found (.roo/rules, .roo/commands, .roo/skills, .roo/mcp.json, .rooignore, or .roorules).",
10790
- lintRules: lintRules11,
10791
- project: project11,
11460
+ lintRules: lintRules12,
11461
+ project: project12,
10792
11462
  globalSupport: {
10793
11463
  capabilities: globalCapabilities11,
10794
11464
  detectionPaths: [
@@ -10871,7 +11541,7 @@ var init_roo_code2 = __esm({
10871
11541
 
10872
11542
  // src/targets/windsurf/constants.ts
10873
11543
  var WINDSURF_TARGET, WINDSURF_RULES_ROOT, WINDSURF_RULES_DIR, WINDSURF_IGNORE, CODEIUM_IGNORE, WINDSURF_AGENTS_MD, WINDSURF_HOOKS_FILE, WINDSURF_MCP_EXAMPLE_FILE, WINDSURF_MCP_CONFIG_FILE, WINDSURF_WORKFLOWS_DIR, WINDSURF_SKILLS_DIR, WINDSURF_CANONICAL_RULES_DIR, WINDSURF_CANONICAL_COMMANDS_DIR, WINDSURF_CANONICAL_AGENTS_DIR, WINDSURF_CANONICAL_SKILLS_DIR, WINDSURF_CANONICAL_IGNORE, WINDSURF_CANONICAL_HOOKS, WINDSURF_CANONICAL_MCP, WINDSURF_GLOBAL_RULES, WINDSURF_GLOBAL_SKILLS_DIR, WINDSURF_GLOBAL_WORKFLOWS_DIR, WINDSURF_GLOBAL_HOOKS_FILE, WINDSURF_GLOBAL_MCP_FILE, WINDSURF_GLOBAL_IGNORE, WINDSURF_GLOBAL_AGENTS_SKILLS_DIR;
10874
- var init_constants13 = __esm({
11544
+ var init_constants14 = __esm({
10875
11545
  "src/targets/windsurf/constants.ts"() {
10876
11546
  WINDSURF_TARGET = "windsurf";
10877
11547
  WINDSURF_RULES_ROOT = ".windsurfrules";
@@ -10910,7 +11580,7 @@ function directoryScopedRuleDir(globs) {
10910
11580
  if (dirs.length !== globs.length) return null;
10911
11581
  return dirs.every((dir) => dir === dirs[0]) ? dirs[0] : null;
10912
11582
  }
10913
- function generateRules12(canonical) {
11583
+ function generateRules13(canonical) {
10914
11584
  const outputs = [];
10915
11585
  const root = canonical.rules.find((r) => r.root);
10916
11586
  if (!root) return [];
@@ -10947,23 +11617,23 @@ function generateRules12(canonical) {
10947
11617
  var init_rules4 = __esm({
10948
11618
  "src/targets/windsurf/generator/rules.ts"() {
10949
11619
  init_markdown();
10950
- init_constants13();
11620
+ init_constants14();
10951
11621
  }
10952
11622
  });
10953
11623
 
10954
11624
  // src/targets/windsurf/generator/ignore.ts
10955
- function generateIgnore8(canonical) {
11625
+ function generateIgnore9(canonical) {
10956
11626
  if (!canonical.ignore || canonical.ignore.length === 0) return [];
10957
11627
  return [{ path: CODEIUM_IGNORE, content: canonical.ignore.join("\n") }];
10958
11628
  }
10959
11629
  var init_ignore3 = __esm({
10960
11630
  "src/targets/windsurf/generator/ignore.ts"() {
10961
- init_constants13();
11631
+ init_constants14();
10962
11632
  }
10963
11633
  });
10964
11634
 
10965
11635
  // src/targets/windsurf/generator/workflows.ts
10966
- function generateCommands11(canonical) {
11636
+ function generateCommands12(canonical) {
10967
11637
  return canonical.commands.map((cmd) => {
10968
11638
  const frontmatter = {
10969
11639
  description: cmd.description.trim() || void 0,
@@ -10982,12 +11652,12 @@ function generateCommands11(canonical) {
10982
11652
  var init_workflows = __esm({
10983
11653
  "src/targets/windsurf/generator/workflows.ts"() {
10984
11654
  init_markdown();
10985
- init_constants13();
11655
+ init_constants14();
10986
11656
  }
10987
11657
  });
10988
11658
 
10989
11659
  // src/targets/windsurf/generator/agents.ts
10990
- function generateAgents10(canonical) {
11660
+ function generateAgents11(canonical) {
10991
11661
  return canonical.agents.map((agent) => ({
10992
11662
  path: `${WINDSURF_SKILLS_DIR}/${projectedAgentSkillDirName(agent.name)}/SKILL.md`,
10993
11663
  content: serializeProjectedAgentSkill(agent)
@@ -10996,12 +11666,12 @@ function generateAgents10(canonical) {
10996
11666
  var init_agents4 = __esm({
10997
11667
  "src/targets/windsurf/generator/agents.ts"() {
10998
11668
  init_projected_agent_skill();
10999
- init_constants13();
11669
+ init_constants14();
11000
11670
  }
11001
11671
  });
11002
11672
 
11003
11673
  // src/targets/windsurf/generator/mcp.ts
11004
- function generateMcp10(canonical) {
11674
+ function generateMcp11(canonical) {
11005
11675
  if (!canonical.mcp || Object.keys(canonical.mcp.mcpServers).length === 0) return [];
11006
11676
  return [
11007
11677
  {
@@ -11012,7 +11682,7 @@ function generateMcp10(canonical) {
11012
11682
  }
11013
11683
  var init_mcp3 = __esm({
11014
11684
  "src/targets/windsurf/generator/mcp.ts"() {
11015
- init_constants13();
11685
+ init_constants14();
11016
11686
  }
11017
11687
  });
11018
11688
 
@@ -11055,12 +11725,12 @@ function generateHooks6(canonical) {
11055
11725
  var init_hooks2 = __esm({
11056
11726
  "src/targets/windsurf/generator/hooks.ts"() {
11057
11727
  init_hook_command();
11058
- init_constants13();
11728
+ init_constants14();
11059
11729
  }
11060
11730
  });
11061
11731
 
11062
11732
  // src/targets/windsurf/generator/skills.ts
11063
- function generateSkills12(canonical) {
11733
+ function generateSkills13(canonical) {
11064
11734
  const outputs = [];
11065
11735
  for (const skill of canonical.skills) {
11066
11736
  const frontmatter = {
@@ -11082,12 +11752,12 @@ function generateSkills12(canonical) {
11082
11752
  var init_skills4 = __esm({
11083
11753
  "src/targets/windsurf/generator/skills.ts"() {
11084
11754
  init_markdown();
11085
- init_constants13();
11755
+ init_constants14();
11086
11756
  }
11087
11757
  });
11088
11758
 
11089
11759
  // src/targets/windsurf/generator/index.ts
11090
- var init_generator15 = __esm({
11760
+ var init_generator16 = __esm({
11091
11761
  "src/targets/windsurf/generator/index.ts"() {
11092
11762
  init_rules4();
11093
11763
  init_ignore3();
@@ -11100,9 +11770,9 @@ var init_generator15 = __esm({
11100
11770
  });
11101
11771
 
11102
11772
  // src/targets/windsurf/generator.ts
11103
- var init_generator16 = __esm({
11773
+ var init_generator17 = __esm({
11104
11774
  "src/targets/windsurf/generator.ts"() {
11105
- init_generator15();
11775
+ init_generator16();
11106
11776
  }
11107
11777
  });
11108
11778
  function toStringArray8(value) {
@@ -11154,7 +11824,7 @@ var init_importer_workflows = __esm({
11154
11824
  init_fs();
11155
11825
  init_markdown();
11156
11826
  init_import_metadata();
11157
- init_constants13();
11827
+ init_constants14();
11158
11828
  }
11159
11829
  });
11160
11830
  async function importSkills4(projectRoot, results, normalize, skillsRelDir = WINDSURF_SKILLS_DIR) {
@@ -11201,7 +11871,7 @@ var init_skills_adapter5 = __esm({
11201
11871
  init_projected_agent_skill();
11202
11872
  init_scoped_agents_import();
11203
11873
  init_skill_import_pipeline();
11204
- init_constants13();
11874
+ init_constants14();
11205
11875
  }
11206
11876
  });
11207
11877
  async function importWindsurfHooks(projectRoot, results) {
@@ -11299,7 +11969,7 @@ async function importWindsurfMcp(projectRoot, results) {
11299
11969
  var init_importer_hooks_mcp = __esm({
11300
11970
  "src/targets/windsurf/importer-hooks-mcp.ts"() {
11301
11971
  init_fs();
11302
- init_constants13();
11972
+ init_constants14();
11303
11973
  }
11304
11974
  });
11305
11975
  async function importFromWindsurf(projectRoot, options) {
@@ -11436,7 +12106,7 @@ async function importFromWindsurf(projectRoot, options) {
11436
12106
  await importWindsurfMcp(projectRoot, results);
11437
12107
  return results;
11438
12108
  }
11439
- var init_importer12 = __esm({
12109
+ var init_importer13 = __esm({
11440
12110
  "src/targets/windsurf/importer.ts"() {
11441
12111
  init_import_rewriter();
11442
12112
  init_fs();
@@ -11444,13 +12114,13 @@ var init_importer12 = __esm({
11444
12114
  init_import_metadata();
11445
12115
  init_import_orchestrator();
11446
12116
  init_scoped_agents_import();
11447
- init_constants13();
12117
+ init_constants14();
11448
12118
  init_importer_workflows();
11449
12119
  init_skills_adapter5();
11450
12120
  init_importer_hooks_mcp();
11451
12121
  }
11452
12122
  });
11453
- function lintRules12(canonical, projectRoot, _projectFiles) {
12123
+ function lintRules13(canonical, projectRoot, _projectFiles) {
11454
12124
  const diags = [];
11455
12125
  const { rules } = canonical;
11456
12126
  if (rules.length > 0) {
@@ -11477,9 +12147,9 @@ function lintRules12(canonical, projectRoot, _projectFiles) {
11477
12147
  }
11478
12148
  return diags;
11479
12149
  }
11480
- var init_linter12 = __esm({
12150
+ var init_linter13 = __esm({
11481
12151
  "src/targets/windsurf/linter.ts"() {
11482
- init_constants13();
12152
+ init_constants14();
11483
12153
  }
11484
12154
  });
11485
12155
 
@@ -11503,7 +12173,7 @@ function lintMcp4(canonical) {
11503
12173
  )
11504
12174
  ];
11505
12175
  }
11506
- var init_lint9 = __esm({
12176
+ var init_lint10 = __esm({
11507
12177
  "src/targets/windsurf/lint.ts"() {
11508
12178
  init_helpers();
11509
12179
  }
@@ -11516,32 +12186,32 @@ function directoryScopedRuleDir2(globs) {
11516
12186
  if (dirs.length !== globs.length) return null;
11517
12187
  return dirs.every((dir) => dir === dirs[0]) ? dirs[0] : null;
11518
12188
  }
11519
- var target12, project12, global10, globalCapabilities12, descriptor12;
12189
+ var target13, project13, global10, globalCapabilities12, descriptor13;
11520
12190
  var init_windsurf2 = __esm({
11521
12191
  "src/targets/windsurf/index.ts"() {
11522
- init_generator16();
12192
+ init_generator17();
11523
12193
  init_capabilities();
11524
- init_constants13();
12194
+ init_constants14();
11525
12195
  init_skill_mirror();
11526
- init_importer12();
11527
- init_linter12();
11528
- init_lint9();
12196
+ init_importer13();
12197
+ init_linter13();
12198
+ init_lint10();
11529
12199
  init_import_map_builders();
11530
12200
  init_conversions();
11531
12201
  init_projected_agent_skill();
11532
- target12 = {
12202
+ target13 = {
11533
12203
  name: "windsurf",
11534
12204
  primaryRootInstructionPath: WINDSURF_AGENTS_MD,
11535
- generateRules: generateRules12,
11536
- generateCommands: generateCommands11,
11537
- generateAgents: generateAgents10,
11538
- generateSkills: generateSkills12,
11539
- generateMcp: generateMcp10,
12205
+ generateRules: generateRules13,
12206
+ generateCommands: generateCommands12,
12207
+ generateAgents: generateAgents11,
12208
+ generateSkills: generateSkills13,
12209
+ generateMcp: generateMcp11,
11540
12210
  generateHooks: generateHooks6,
11541
- generateIgnore: generateIgnore8,
12211
+ generateIgnore: generateIgnore9,
11542
12212
  importFrom: importFromWindsurf
11543
12213
  };
11544
- project12 = {
12214
+ project13 = {
11545
12215
  rootInstructionPath: WINDSURF_AGENTS_MD,
11546
12216
  extraRuleOutputPaths(rule) {
11547
12217
  if (rule.root) return [WINDSURF_AGENTS_MD];
@@ -11636,9 +12306,9 @@ var init_windsurf2 = __esm({
11636
12306
  ignore: "native",
11637
12307
  permissions: "none"
11638
12308
  };
11639
- descriptor12 = {
12309
+ descriptor13 = {
11640
12310
  id: "windsurf",
11641
- generators: target12,
12311
+ generators: target13,
11642
12312
  capabilities: {
11643
12313
  rules: "native",
11644
12314
  additionalRules: "native",
@@ -11652,12 +12322,12 @@ var init_windsurf2 = __esm({
11652
12322
  },
11653
12323
  emptyImportMessage: "No Windsurf config found (.windsurfrules, .windsurf/rules, .windsurfignore, or .codeiumignore).",
11654
12324
  supportsConversion: { agents: true },
11655
- lintRules: lintRules12,
12325
+ lintRules: lintRules13,
11656
12326
  lint: {
11657
12327
  commands: lintCommands6,
11658
12328
  mcp: lintMcp4
11659
12329
  },
11660
- project: project12,
12330
+ project: project13,
11661
12331
  globalSupport: {
11662
12332
  capabilities: globalCapabilities12,
11663
12333
  detectionPaths: [
@@ -11700,67 +12370,67 @@ function builtinTargetsMap() {
11700
12370
  }
11701
12371
  return _builtinTargetsMap;
11702
12372
  }
11703
- function getBuiltinTargetDefinition(target13) {
11704
- return builtinTargetsMap().get(target13);
12373
+ function getBuiltinTargetDefinition(target14) {
12374
+ return builtinTargetsMap().get(target14);
11705
12375
  }
11706
- function getTargetCapabilities(target13, scope = "project") {
11707
- const descriptor13 = getBuiltinTargetDefinition(target13) ?? getDescriptor(target13);
11708
- if (!descriptor13) return void 0;
11709
- const raw = scope === "global" ? descriptor13.globalSupport?.capabilities ?? descriptor13.capabilities : descriptor13.capabilities;
12376
+ function getTargetCapabilities(target14, scope = "project") {
12377
+ const descriptor14 = getBuiltinTargetDefinition(target14) ?? getDescriptor(target14);
12378
+ if (!descriptor14) return void 0;
12379
+ const raw = scope === "global" ? descriptor14.globalSupport?.capabilities ?? descriptor14.capabilities : descriptor14.capabilities;
11710
12380
  return normalizeTargetCapabilities(raw);
11711
12381
  }
11712
- function getTargetDetectionPaths(target13, scope = "project") {
11713
- const descriptor13 = getBuiltinTargetDefinition(target13) ?? getDescriptor(target13);
11714
- if (!descriptor13) return [];
12382
+ function getTargetDetectionPaths(target14, scope = "project") {
12383
+ const descriptor14 = getBuiltinTargetDefinition(target14) ?? getDescriptor(target14);
12384
+ if (!descriptor14) return [];
11715
12385
  if (scope === "global") {
11716
- return descriptor13.globalSupport?.detectionPaths ?? [];
12386
+ return descriptor14.globalSupport?.detectionPaths ?? [];
11717
12387
  }
11718
- return descriptor13.detectionPaths;
12388
+ return descriptor14.detectionPaths;
11719
12389
  }
11720
- function getTargetLayout(target13, scope = "project") {
11721
- const descriptor13 = getBuiltinTargetDefinition(target13) ?? getDescriptor(target13);
11722
- if (!descriptor13) return void 0;
12390
+ function getTargetLayout(target14, scope = "project") {
12391
+ const descriptor14 = getBuiltinTargetDefinition(target14) ?? getDescriptor(target14);
12392
+ if (!descriptor14) return void 0;
11723
12393
  if (scope === "global") {
11724
- return descriptor13.globalSupport?.layout;
12394
+ return descriptor14.globalSupport?.layout;
11725
12395
  }
11726
- return descriptor13.project;
12396
+ return descriptor14.project;
11727
12397
  }
11728
- function getTargetPrimaryRootInstructionPath(target13, scope = "project") {
11729
- return getTargetLayout(target13, scope)?.rootInstructionPath;
12398
+ function getTargetPrimaryRootInstructionPath(target14, scope = "project") {
12399
+ return getTargetLayout(target14, scope)?.rootInstructionPath;
11730
12400
  }
11731
- function getTargetSkillDir(target13, scope = "project") {
11732
- return getTargetLayout(target13, scope)?.skillDir;
12401
+ function getTargetSkillDir(target14, scope = "project") {
12402
+ return getTargetLayout(target14, scope)?.skillDir;
11733
12403
  }
11734
- function getTargetManagedOutputs(target13, scope = "project") {
11735
- return getTargetLayout(target13, scope)?.managedOutputs;
12404
+ function getTargetManagedOutputs(target14, scope = "project") {
12405
+ return getTargetLayout(target14, scope)?.managedOutputs;
11736
12406
  }
11737
- function rewriteGeneratedOutputPath(target13, path, scope = "project") {
11738
- const layout = getTargetLayout(target13, scope);
12407
+ function rewriteGeneratedOutputPath(target14, path, scope = "project") {
12408
+ const layout = getTargetLayout(target14, scope);
11739
12409
  if (!layout) return null;
11740
12410
  return layout.rewriteGeneratedPath ? layout.rewriteGeneratedPath(path) : path;
11741
12411
  }
11742
- function isFeatureSuppressedByConversion(descriptor13, feature, config, scope) {
11743
- if (!descriptor13 || !config) return false;
11744
- if (feature === "commands" && descriptor13.supportsConversion?.commands) {
11745
- return !shouldConvertCommandsToSkills(config, descriptor13.id, true, scope);
12412
+ function isFeatureSuppressedByConversion(descriptor14, feature, config, scope) {
12413
+ if (!descriptor14 || !config) return false;
12414
+ if (feature === "commands" && descriptor14.supportsConversion?.commands) {
12415
+ return !shouldConvertCommandsToSkills(config, descriptor14.id, true, scope);
11746
12416
  }
11747
- if (feature === "agents" && descriptor13.supportsConversion?.agents) {
11748
- return !shouldConvertAgentsToSkills(config, descriptor13.id, true, scope);
12417
+ if (feature === "agents" && descriptor14.supportsConversion?.agents) {
12418
+ return !shouldConvertAgentsToSkills(config, descriptor14.id, true, scope);
11749
12419
  }
11750
12420
  return false;
11751
12421
  }
11752
- function getEffectiveTargetSupportLevel(target13, feature, config, scope = "project") {
11753
- const baseLevel = getTargetCapabilities(target13, scope)?.[feature]?.level ?? "none";
12422
+ function getEffectiveTargetSupportLevel(target14, feature, config, scope = "project") {
12423
+ const baseLevel = getTargetCapabilities(target14, scope)?.[feature]?.level ?? "none";
11754
12424
  if (baseLevel !== "embedded") return baseLevel;
11755
- const descriptor13 = getBuiltinTargetDefinition(target13) ?? getDescriptor(target13);
11756
- return isFeatureSuppressedByConversion(descriptor13, feature, config, scope) ? "none" : baseLevel;
12425
+ const descriptor14 = getBuiltinTargetDefinition(target14) ?? getDescriptor(target14);
12426
+ return isFeatureSuppressedByConversion(descriptor14, feature, config, scope) ? "none" : baseLevel;
11757
12427
  }
11758
- function resolveTargetFeatureGenerator(target13, feature, config, scope = "project") {
11759
- const descriptor13 = getBuiltinTargetDefinition(target13) ?? getDescriptor(target13);
11760
- if (!descriptor13?.generators) return void 0;
11761
- if (isFeatureSuppressedByConversion(descriptor13, feature, config, scope)) return void 0;
12428
+ function resolveTargetFeatureGenerator(target14, feature, config, scope = "project") {
12429
+ const descriptor14 = getBuiltinTargetDefinition(target14) ?? getDescriptor(target14);
12430
+ if (!descriptor14?.generators) return void 0;
12431
+ if (isFeatureSuppressedByConversion(descriptor14, feature, config, scope)) return void 0;
11762
12432
  const pick = PICK_FEATURE_GENERATOR[feature];
11763
- return pick === null ? void 0 : pick(descriptor13.generators);
12433
+ return pick === null ? void 0 : pick(descriptor14.generators);
11764
12434
  }
11765
12435
  var BUILTIN_TARGETS, _builtinTargetsMap, PICK_FEATURE_GENERATOR;
11766
12436
  var init_builtin_targets = __esm({
@@ -11779,6 +12449,7 @@ var init_builtin_targets = __esm({
11779
12449
  init_cursor2();
11780
12450
  init_gemini_cli2();
11781
12451
  init_junie2();
12452
+ init_kilo_code2();
11782
12453
  init_kiro2();
11783
12454
  init_roo_code2();
11784
12455
  init_windsurf2();
@@ -11794,7 +12465,8 @@ var init_builtin_targets = __esm({
11794
12465
  descriptor9,
11795
12466
  descriptor10,
11796
12467
  descriptor11,
11797
- descriptor12
12468
+ descriptor12,
12469
+ descriptor13
11798
12470
  ];
11799
12471
  PICK_FEATURE_GENERATOR = {
11800
12472
  rules: (g) => g.generateRules,
@@ -11814,8 +12486,8 @@ var init_builtin_targets = __esm({
11814
12486
  init_builtin_targets();
11815
12487
  init_registry();
11816
12488
  init_descriptor_import_runner();
11817
- function copyCapabilities(capabilities) {
11818
- return Object.freeze({ ...capabilities });
12489
+ function copyCapabilities(capabilities2) {
12490
+ return Object.freeze({ ...capabilities2 });
11819
12491
  }
11820
12492
  function copyGenerators(generators) {
11821
12493
  return Object.freeze({ ...generators });
@@ -11848,17 +12520,17 @@ function copyGlobalSupport(globalSupport) {
11848
12520
  layout: copyLayout(globalSupport.layout)
11849
12521
  });
11850
12522
  }
11851
- function copyTargetDescriptor(descriptor13) {
12523
+ function copyTargetDescriptor(descriptor14) {
11852
12524
  return Object.freeze({
11853
- ...descriptor13,
11854
- generators: copyGenerators(descriptor13.generators),
11855
- capabilities: copyCapabilities(descriptor13.capabilities),
11856
- globalSupport: descriptor13.globalSupport === void 0 ? void 0 : copyGlobalSupport(descriptor13.globalSupport),
11857
- lint: descriptor13.lint === void 0 ? void 0 : Object.freeze({ ...descriptor13.lint }),
11858
- project: copyLayout(descriptor13.project),
11859
- supportsConversion: descriptor13.supportsConversion === void 0 ? void 0 : Object.freeze({ ...descriptor13.supportsConversion }),
11860
- detectionPaths: Object.freeze([...descriptor13.detectionPaths]),
11861
- sharedArtifacts: descriptor13.sharedArtifacts === void 0 ? void 0 : Object.freeze({ ...descriptor13.sharedArtifacts })
12525
+ ...descriptor14,
12526
+ generators: copyGenerators(descriptor14.generators),
12527
+ capabilities: copyCapabilities(descriptor14.capabilities),
12528
+ globalSupport: descriptor14.globalSupport === void 0 ? void 0 : copyGlobalSupport(descriptor14.globalSupport),
12529
+ lint: descriptor14.lint === void 0 ? void 0 : Object.freeze({ ...descriptor14.lint }),
12530
+ project: copyLayout(descriptor14.project),
12531
+ supportsConversion: descriptor14.supportsConversion === void 0 ? void 0 : Object.freeze({ ...descriptor14.supportsConversion }),
12532
+ detectionPaths: Object.freeze([...descriptor14.detectionPaths]),
12533
+ sharedArtifacts: descriptor14.sharedArtifacts === void 0 ? void 0 : Object.freeze({ ...descriptor14.sharedArtifacts })
11862
12534
  });
11863
12535
  }
11864
12536
  function getTargetCatalog() {