agentsmesh 0.5.0 → 0.6.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/CHANGELOG.md +65 -6
- package/README.md +167 -78
- package/dist/{canonical-types-gdrUi3bD.d.ts → canonical-types-CZwrJoBX.d.ts} +1 -1
- package/dist/canonical.d.ts +3 -2
- package/dist/canonical.js +59 -70
- package/dist/canonical.js.map +1 -1
- package/dist/cli.js +453 -17020
- package/dist/engine.d.ts +186 -5
- package/dist/engine.js +1673 -882
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +6 -0
- package/dist/index.js +12312 -0
- package/dist/index.js.map +1 -0
- package/dist/{target-descriptor-D64xD0C2.d.ts → target-descriptor-DjHhww11.d.ts} +30 -9
- package/dist/targets.d.ts +4 -3
- package/dist/targets.js +572 -775
- package/dist/targets.js.map +1 -1
- package/package.json +17 -3
- package/schemas/agentsmesh.json +122 -8
- package/dist/cli.js.map +0 -1
package/dist/targets.js
CHANGED
|
@@ -1,3 +1,10 @@
|
|
|
1
|
+
import { stringify, parse } from 'yaml';
|
|
2
|
+
import { join, basename, relative, normalize, dirname, extname, win32, isAbsolute, posix } from 'path';
|
|
3
|
+
import { readFile, mkdir, lstat, writeFile, rename, rm, readdir, stat, realpath, access } from 'fs/promises';
|
|
4
|
+
import { realpathSync, existsSync, constants, statSync } from 'fs';
|
|
5
|
+
import { parse as parse$1 } from 'smol-toml';
|
|
6
|
+
import { Buffer } from 'buffer';
|
|
7
|
+
|
|
1
8
|
// src/config/core/conversions.ts
|
|
2
9
|
var DEFAULT_COMMANDS_TO_SKILLS = {
|
|
3
10
|
"codex-cli": true
|
|
@@ -10,22 +17,30 @@ var DEFAULT_AGENTS_TO_SKILLS = {
|
|
|
10
17
|
// native .codex/agents/*.toml per agent-structures
|
|
11
18
|
windsurf: true
|
|
12
19
|
};
|
|
13
|
-
function hasOwnTarget(map, target13) {
|
|
14
|
-
return Object.prototype.hasOwnProperty.call(map, target13);
|
|
15
|
-
}
|
|
16
20
|
function usesCommandSkillProjection(target13) {
|
|
17
|
-
return
|
|
21
|
+
return Object.prototype.hasOwnProperty.call(DEFAULT_COMMANDS_TO_SKILLS, target13);
|
|
18
22
|
}
|
|
19
23
|
function usesAgentSkillProjection(target13) {
|
|
20
|
-
return
|
|
24
|
+
return Object.prototype.hasOwnProperty.call(DEFAULT_AGENTS_TO_SKILLS, target13);
|
|
25
|
+
}
|
|
26
|
+
function resolveConversionValue(value, scope) {
|
|
27
|
+
if (value === void 0) return void 0;
|
|
28
|
+
if (typeof value === "boolean") return value;
|
|
29
|
+
return value[scope];
|
|
21
30
|
}
|
|
22
|
-
function shouldConvertCommandsToSkills(config, target13) {
|
|
23
|
-
|
|
24
|
-
|
|
31
|
+
function shouldConvertCommandsToSkills(config, target13, defaultEnabled, scope = "project") {
|
|
32
|
+
const raw = config.conversions?.commands_to_skills?.[target13];
|
|
33
|
+
const configVal = resolveConversionValue(raw, scope);
|
|
34
|
+
if (configVal !== void 0) return configVal;
|
|
35
|
+
if (usesCommandSkillProjection(target13)) return DEFAULT_COMMANDS_TO_SKILLS[target13];
|
|
36
|
+
return defaultEnabled ?? false;
|
|
25
37
|
}
|
|
26
|
-
function shouldConvertAgentsToSkills(config, target13) {
|
|
27
|
-
|
|
28
|
-
|
|
38
|
+
function shouldConvertAgentsToSkills(config, target13, defaultEnabled, scope = "project") {
|
|
39
|
+
const raw = config.conversions?.agents_to_skills?.[target13];
|
|
40
|
+
const configVal = resolveConversionValue(raw, scope);
|
|
41
|
+
if (configVal !== void 0) return configVal;
|
|
42
|
+
if (usesAgentSkillProjection(target13)) return DEFAULT_AGENTS_TO_SKILLS[target13];
|
|
43
|
+
return defaultEnabled ?? false;
|
|
29
44
|
}
|
|
30
45
|
|
|
31
46
|
// src/targets/catalog/capabilities.ts
|
|
@@ -52,6 +67,61 @@ function normalizeTargetCapabilities(caps) {
|
|
|
52
67
|
};
|
|
53
68
|
}
|
|
54
69
|
|
|
70
|
+
// src/targets/catalog/registry.ts
|
|
71
|
+
var descriptorRegistry = /* @__PURE__ */ new Map();
|
|
72
|
+
var _builtinDescriptors;
|
|
73
|
+
function builtinDescriptors() {
|
|
74
|
+
if (!_builtinDescriptors) {
|
|
75
|
+
_builtinDescriptors = new Map(BUILTIN_TARGETS.map((d) => [d.id, d]));
|
|
76
|
+
}
|
|
77
|
+
return _builtinDescriptors;
|
|
78
|
+
}
|
|
79
|
+
function registerTargetDescriptor(descriptor13) {
|
|
80
|
+
descriptorRegistry.set(descriptor13.id, descriptor13);
|
|
81
|
+
}
|
|
82
|
+
function getDescriptor(name) {
|
|
83
|
+
return descriptorRegistry.get(name) ?? builtinDescriptors().get(name);
|
|
84
|
+
}
|
|
85
|
+
function getAllDescriptors() {
|
|
86
|
+
return [...descriptorRegistry.values()];
|
|
87
|
+
}
|
|
88
|
+
|
|
89
|
+
// src/targets/catalog/shared-artifact-owner.ts
|
|
90
|
+
function findSharedArtifactOwnershipConflicts(descriptors) {
|
|
91
|
+
const owners = [];
|
|
92
|
+
for (const descriptor13 of descriptors) {
|
|
93
|
+
if (!descriptor13.sharedArtifacts) continue;
|
|
94
|
+
for (const [prefix, role] of Object.entries(descriptor13.sharedArtifacts)) {
|
|
95
|
+
if (role !== "owner") continue;
|
|
96
|
+
owners.push({ targetId: descriptor13.id, prefix });
|
|
97
|
+
}
|
|
98
|
+
}
|
|
99
|
+
const conflicts = [];
|
|
100
|
+
for (let i = 0; i < owners.length; i++) {
|
|
101
|
+
for (let j = i + 1; j < owners.length; j++) {
|
|
102
|
+
const a = owners[i];
|
|
103
|
+
const b = owners[j];
|
|
104
|
+
if (a === void 0 || b === void 0) continue;
|
|
105
|
+
if (a.prefix === b.prefix || a.prefix.startsWith(b.prefix) || b.prefix.startsWith(a.prefix)) {
|
|
106
|
+
conflicts.push({ a, b });
|
|
107
|
+
}
|
|
108
|
+
}
|
|
109
|
+
}
|
|
110
|
+
return conflicts;
|
|
111
|
+
}
|
|
112
|
+
function assertSharedArtifactOwnersUnique(descriptors) {
|
|
113
|
+
const conflicts = findSharedArtifactOwnershipConflicts(descriptors);
|
|
114
|
+
if (conflicts.length === 0) return;
|
|
115
|
+
const lines = conflicts.map(
|
|
116
|
+
({ a, b }) => ` - "${a.targetId}" owns "${a.prefix}" and "${b.targetId}" owns "${b.prefix}"`
|
|
117
|
+
);
|
|
118
|
+
throw new Error(
|
|
119
|
+
`Shared-artifact ownership conflict: two targets claim the same or overlapping prefix.
|
|
120
|
+
` + lines.join("\n") + `
|
|
121
|
+
Resolve by changing one target's role to 'consumer' or by namespacing its prefix.`
|
|
122
|
+
);
|
|
123
|
+
}
|
|
124
|
+
|
|
55
125
|
// src/targets/catalog/target-ids.ts
|
|
56
126
|
var TARGET_IDS = [
|
|
57
127
|
"claude-code",
|
|
@@ -67,9 +137,6 @@ var TARGET_IDS = [
|
|
|
67
137
|
"antigravity",
|
|
68
138
|
"roo-code"
|
|
69
139
|
];
|
|
70
|
-
|
|
71
|
-
// src/utils/text/markdown.ts
|
|
72
|
-
import { parse as yamlParse, stringify as yamlStringify } from "yaml";
|
|
73
140
|
function parseFrontmatter(content) {
|
|
74
141
|
const open = content.indexOf("---");
|
|
75
142
|
if (open !== 0) {
|
|
@@ -81,13 +148,13 @@ function parseFrontmatter(content) {
|
|
|
81
148
|
}
|
|
82
149
|
const yamlStr = content.slice(3, close).trim();
|
|
83
150
|
const body = content.slice(close + 3).trim();
|
|
84
|
-
const frontmatter = yamlStr === "" ? {} :
|
|
151
|
+
const frontmatter = yamlStr === "" ? {} : parse(yamlStr) ?? {};
|
|
85
152
|
return { frontmatter, body };
|
|
86
153
|
}
|
|
87
154
|
function serializeFrontmatter(frontmatter, body) {
|
|
88
155
|
const keys = Object.keys(frontmatter);
|
|
89
156
|
if (keys.length === 0) return body;
|
|
90
|
-
const yamlStr =
|
|
157
|
+
const yamlStr = stringify(frontmatter, { lineWidth: 0 }).trimEnd();
|
|
91
158
|
return `---
|
|
92
159
|
${yamlStr}
|
|
93
160
|
---
|
|
@@ -308,27 +375,27 @@ ${body}
|
|
|
308
375
|
`;
|
|
309
376
|
}
|
|
310
377
|
|
|
311
|
-
// src/
|
|
312
|
-
|
|
378
|
+
// src/core/errors.ts
|
|
379
|
+
var AgentsMeshError = class extends Error {
|
|
380
|
+
code;
|
|
381
|
+
constructor(code, message, options) {
|
|
382
|
+
super(message, options);
|
|
383
|
+
this.name = "AgentsMeshError";
|
|
384
|
+
this.code = code;
|
|
385
|
+
}
|
|
386
|
+
};
|
|
387
|
+
var FileSystemError = class extends AgentsMeshError {
|
|
388
|
+
path;
|
|
389
|
+
errnoCode;
|
|
390
|
+
constructor(path, message, options) {
|
|
391
|
+
super("AM_FILESYSTEM", message, options);
|
|
392
|
+
this.name = "FileSystemError";
|
|
393
|
+
this.path = path;
|
|
394
|
+
this.errnoCode = options?.errnoCode;
|
|
395
|
+
}
|
|
396
|
+
};
|
|
313
397
|
|
|
314
398
|
// src/utils/filesystem/fs.ts
|
|
315
|
-
import {
|
|
316
|
-
readFile,
|
|
317
|
-
writeFile,
|
|
318
|
-
access,
|
|
319
|
-
mkdir,
|
|
320
|
-
rename,
|
|
321
|
-
readdir,
|
|
322
|
-
copyFile,
|
|
323
|
-
stat,
|
|
324
|
-
symlink,
|
|
325
|
-
unlink,
|
|
326
|
-
lstat,
|
|
327
|
-
readlink,
|
|
328
|
-
realpath
|
|
329
|
-
} from "fs/promises";
|
|
330
|
-
import { dirname, join, resolve } from "path";
|
|
331
|
-
import { constants } from "fs";
|
|
332
399
|
var UTF8_BOM = "\uFEFF";
|
|
333
400
|
async function readFileSafe(path) {
|
|
334
401
|
try {
|
|
@@ -337,24 +404,43 @@ async function readFileSafe(path) {
|
|
|
337
404
|
} catch (err) {
|
|
338
405
|
const e = err;
|
|
339
406
|
if (e.code === "ENOENT") return null;
|
|
340
|
-
throw new
|
|
407
|
+
throw new FileSystemError(
|
|
408
|
+
path,
|
|
341
409
|
`Failed to read ${path}: ${e.message}. Ensure the file exists and is readable.`,
|
|
342
|
-
{ cause: err }
|
|
410
|
+
{ cause: err, errnoCode: e.code }
|
|
343
411
|
);
|
|
344
412
|
}
|
|
345
413
|
}
|
|
346
414
|
async function writeFileAtomic(path, content) {
|
|
347
415
|
const dir = dirname(path);
|
|
348
416
|
await mkdir(dir, { recursive: true });
|
|
417
|
+
try {
|
|
418
|
+
const info = await lstat(path);
|
|
419
|
+
if (info.isDirectory()) {
|
|
420
|
+
throw new FileSystemError(
|
|
421
|
+
path,
|
|
422
|
+
`Failed to write ${path}: target exists and is a directory. Remove it or choose a different path.`,
|
|
423
|
+
{ errnoCode: "EISDIR" }
|
|
424
|
+
);
|
|
425
|
+
}
|
|
426
|
+
} catch (err) {
|
|
427
|
+
if (err instanceof FileSystemError) throw err;
|
|
428
|
+
const e = err;
|
|
429
|
+
if (e.code !== "ENOENT") throw err;
|
|
430
|
+
}
|
|
349
431
|
const tmpPath = `${path}.tmp`;
|
|
350
432
|
try {
|
|
351
433
|
await writeFile(tmpPath, content, "utf-8");
|
|
352
434
|
await rename(tmpPath, path);
|
|
353
435
|
} catch (err) {
|
|
354
|
-
|
|
355
|
-
throw new Error(`Failed to write ${path}: ${e.message}. Check permissions and disk space.`, {
|
|
356
|
-
cause: err
|
|
436
|
+
await rm(tmpPath, { force: true }).catch(() => {
|
|
357
437
|
});
|
|
438
|
+
const e = err;
|
|
439
|
+
throw new FileSystemError(
|
|
440
|
+
path,
|
|
441
|
+
`Failed to write ${path}: ${e.message}. Check permissions and disk space.`,
|
|
442
|
+
{ cause: err, errnoCode: e.code }
|
|
443
|
+
);
|
|
358
444
|
}
|
|
359
445
|
}
|
|
360
446
|
async function exists(path) {
|
|
@@ -375,9 +461,11 @@ async function readDirRecursive(dir, visited) {
|
|
|
375
461
|
} catch (err) {
|
|
376
462
|
const e = err;
|
|
377
463
|
if (e.code === "ENOENT" || e.code === "ENOTDIR" || e.code === "ELOOP") return [];
|
|
378
|
-
throw new
|
|
379
|
-
|
|
380
|
-
|
|
464
|
+
throw new FileSystemError(
|
|
465
|
+
dir,
|
|
466
|
+
`Failed to read directory ${dir}: ${e.message}. Check permissions.`,
|
|
467
|
+
{ cause: err, errnoCode: e.code }
|
|
468
|
+
);
|
|
381
469
|
}
|
|
382
470
|
const seen = visited ?? /* @__PURE__ */ new Set();
|
|
383
471
|
if (seen.has(canonicalDir)) return [];
|
|
@@ -401,9 +489,11 @@ async function readDirRecursive(dir, visited) {
|
|
|
401
489
|
} catch (err) {
|
|
402
490
|
const e = err;
|
|
403
491
|
if (e.code === "ENOENT" || e.code === "ENOTDIR" || e.code === "EACCES") return [];
|
|
404
|
-
throw new
|
|
405
|
-
|
|
406
|
-
|
|
492
|
+
throw new FileSystemError(
|
|
493
|
+
dir,
|
|
494
|
+
`Failed to read directory ${dir}: ${e.message}. Check permissions.`,
|
|
495
|
+
{ cause: err, errnoCode: e.code }
|
|
496
|
+
);
|
|
407
497
|
}
|
|
408
498
|
}
|
|
409
499
|
|
|
@@ -425,7 +515,7 @@ async function generateClaudeGlobalExtras(canonical, projectRoot, scope, enabled
|
|
|
425
515
|
const fm = { name: agent.name, description: agent.description || void 0 };
|
|
426
516
|
const content = serializeFrontmatter(fm, agent.body.trim());
|
|
427
517
|
const path = `${CLAUDE_OUTPUT_STYLES_DIR}/${agent.name}.md`;
|
|
428
|
-
const existing = await readFileSafe(
|
|
518
|
+
const existing = await readFileSafe(join(projectRoot, path));
|
|
429
519
|
results.push({
|
|
430
520
|
target: "claude-code",
|
|
431
521
|
path,
|
|
@@ -441,7 +531,7 @@ async function generateClaudeGlobalExtras(canonical, projectRoot, scope, enabled
|
|
|
441
531
|
const fm = { name: cmd.name, description: cmd.description || void 0 };
|
|
442
532
|
const content = serializeFrontmatter(fm, cmd.body.trim());
|
|
443
533
|
const path = `${CLAUDE_OUTPUT_STYLES_DIR}/${cmd.name}.md`;
|
|
444
|
-
const existing = await readFileSafe(
|
|
534
|
+
const existing = await readFileSafe(join(projectRoot, path));
|
|
445
535
|
results.push({
|
|
446
536
|
target: "claude-code",
|
|
447
537
|
path,
|
|
@@ -454,14 +544,6 @@ async function generateClaudeGlobalExtras(canonical, projectRoot, scope, enabled
|
|
|
454
544
|
return results;
|
|
455
545
|
}
|
|
456
546
|
|
|
457
|
-
// src/targets/claude-code/importer.ts
|
|
458
|
-
import { dirname as dirname7, join as join8 } from "path";
|
|
459
|
-
|
|
460
|
-
// src/core/reference/import-rewriter.ts
|
|
461
|
-
import { existsSync as existsSync2, realpathSync as realpathSync2, statSync } from "fs";
|
|
462
|
-
import { join as join3 } from "path";
|
|
463
|
-
import { normalize as normalizePath } from "path";
|
|
464
|
-
|
|
465
547
|
// src/core/reference/import-map.ts
|
|
466
548
|
async function buildImportReferenceMap(target13, projectRoot, scope = "project") {
|
|
467
549
|
const refs = /* @__PURE__ */ new Map();
|
|
@@ -471,9 +553,6 @@ async function buildImportReferenceMap(target13, projectRoot, scope = "project")
|
|
|
471
553
|
}
|
|
472
554
|
return refs;
|
|
473
555
|
}
|
|
474
|
-
|
|
475
|
-
// src/core/path-helpers.ts
|
|
476
|
-
import { posix, win32 } from "path";
|
|
477
556
|
var WINDOWS_ABSOLUTE_PATH = /^[A-Za-z]:[\\/]/;
|
|
478
557
|
var TRAILING_PUNCTUATION = /[.!?:;]+$/;
|
|
479
558
|
function pathApi(projectRoot) {
|
|
@@ -506,10 +585,6 @@ function rootFallbackPath(token, projectRoot) {
|
|
|
506
585
|
const stripped = token.replace(/^(\.\.\/)+/, "").replace(/^\.\//, "");
|
|
507
586
|
return stripped && stripped !== token ? normalizeForProject(projectRoot, api.join(projectRoot, stripped)) : null;
|
|
508
587
|
}
|
|
509
|
-
|
|
510
|
-
// src/core/reference/link-rebaser-helpers.ts
|
|
511
|
-
import { existsSync, realpathSync } from "fs";
|
|
512
|
-
import { isAbsolute, win32 as win322 } from "path";
|
|
513
588
|
var ROOT_RELATIVE_PREFIXES = [
|
|
514
589
|
".agentsmesh/",
|
|
515
590
|
".claude/",
|
|
@@ -572,7 +647,7 @@ function resolveProjectPath(token, projectRoot, sourceFile) {
|
|
|
572
647
|
const normalizedToken = normalizeSeparators(token);
|
|
573
648
|
if (WINDOWS_ABSOLUTE_PATH.test(token)) {
|
|
574
649
|
const windowsToken = normalizeForProject(projectRoot, token);
|
|
575
|
-
if (api ===
|
|
650
|
+
if (api === win32 || windowsToken.startsWith(`${normalizedProjectRoot}${api.sep}`)) {
|
|
576
651
|
return [windowsToken];
|
|
577
652
|
}
|
|
578
653
|
return [windowsToken];
|
|
@@ -662,9 +737,6 @@ function protectedRanges(content) {
|
|
|
662
737
|
}
|
|
663
738
|
return ranges;
|
|
664
739
|
}
|
|
665
|
-
|
|
666
|
-
// src/core/reference/link-rebaser-formatting.ts
|
|
667
|
-
import { dirname as dirname2 } from "path";
|
|
668
740
|
function isReadingContext(context) {
|
|
669
741
|
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";
|
|
670
742
|
}
|
|
@@ -725,7 +797,7 @@ function formatLinkPathForDestinationLegacy(projectRoot, destinationFile, absolu
|
|
|
725
797
|
if (!isUnderProjectRoot(projectRoot, target13)) {
|
|
726
798
|
return toProjectRootReference(projectRoot, target13, keepSlash)?.text ?? null;
|
|
727
799
|
}
|
|
728
|
-
const destDir = normalizeForProject(projectRoot,
|
|
800
|
+
const destDir = normalizeForProject(projectRoot, dirname(destFile));
|
|
729
801
|
if (!isUnderProjectRoot(projectRoot, destDir) && destDir !== root) {
|
|
730
802
|
return toProjectRootReference(projectRoot, target13, keepSlash)?.text ?? null;
|
|
731
803
|
}
|
|
@@ -1089,12 +1161,12 @@ function rewriteFileLinks(input) {
|
|
|
1089
1161
|
|
|
1090
1162
|
// src/core/reference/import-rewriter.ts
|
|
1091
1163
|
function pathVariants(path) {
|
|
1092
|
-
const variants = [
|
|
1093
|
-
if (!
|
|
1164
|
+
const variants = [normalize(path)];
|
|
1165
|
+
if (!existsSync(path)) return variants;
|
|
1094
1166
|
try {
|
|
1095
|
-
const realPaths = [
|
|
1167
|
+
const realPaths = [realpathSync(path), realpathSync.native(path)];
|
|
1096
1168
|
for (const realPath of realPaths) {
|
|
1097
|
-
const normalized =
|
|
1169
|
+
const normalized = normalize(realPath);
|
|
1098
1170
|
if (!variants.includes(normalized)) variants.push(normalized);
|
|
1099
1171
|
}
|
|
1100
1172
|
} catch {
|
|
@@ -1112,17 +1184,17 @@ async function createImportReferenceNormalizer(target13, projectRoot, scope = "p
|
|
|
1112
1184
|
}
|
|
1113
1185
|
const artifactMap = /* @__PURE__ */ new Map();
|
|
1114
1186
|
for (const [targetPath, canonicalPath] of refs.entries()) {
|
|
1115
|
-
const canonicalAbsPath =
|
|
1116
|
-
for (const variant of pathVariants(
|
|
1187
|
+
const canonicalAbsPath = normalize(join(projectRoot, canonicalPath));
|
|
1188
|
+
for (const variant of pathVariants(join(projectRoot, targetPath))) {
|
|
1117
1189
|
artifactMap.set(variant, canonicalAbsPath);
|
|
1118
1190
|
}
|
|
1119
1191
|
}
|
|
1120
1192
|
const canonicalDestAbs = /* @__PURE__ */ new Set();
|
|
1121
1193
|
for (const canonicalPath of new Set(refs.values())) {
|
|
1122
|
-
const abs =
|
|
1194
|
+
const abs = normalize(join(projectRoot, canonicalPath));
|
|
1123
1195
|
canonicalDestAbs.add(abs);
|
|
1124
1196
|
for (const variant of pathVariants(abs)) {
|
|
1125
|
-
canonicalDestAbs.add(
|
|
1197
|
+
canonicalDestAbs.add(normalize(variant));
|
|
1126
1198
|
}
|
|
1127
1199
|
}
|
|
1128
1200
|
return (content, sourceFile, destinationFile) => rewriteFileLinks({
|
|
@@ -1132,8 +1204,8 @@ async function createImportReferenceNormalizer(target13, projectRoot, scope = "p
|
|
|
1132
1204
|
destinationFile,
|
|
1133
1205
|
translatePath: (absolutePath) => artifactMap.get(absolutePath) ?? absolutePath,
|
|
1134
1206
|
pathExists: (absolutePath) => {
|
|
1135
|
-
const normalized =
|
|
1136
|
-
return artifactMap.has(absolutePath) || artifactMap.has(normalized) ||
|
|
1207
|
+
const normalized = normalize(absolutePath);
|
|
1208
|
+
return artifactMap.has(absolutePath) || artifactMap.has(normalized) || existsSync(absolutePath) || canonicalDestAbs.has(normalized);
|
|
1137
1209
|
},
|
|
1138
1210
|
explicitCurrentDirLinks: false,
|
|
1139
1211
|
rewriteBarePathTokens: true,
|
|
@@ -1147,12 +1219,6 @@ async function createImportReferenceNormalizer(target13, projectRoot, scope = "p
|
|
|
1147
1219
|
}
|
|
1148
1220
|
}).content;
|
|
1149
1221
|
}
|
|
1150
|
-
|
|
1151
|
-
// src/targets/import/import-metadata-core.ts
|
|
1152
|
-
import { basename as basename2 } from "path";
|
|
1153
|
-
|
|
1154
|
-
// src/targets/projection/managed-blocks.ts
|
|
1155
|
-
import { basename, join as join4 } from "path";
|
|
1156
1222
|
var ROOT_CONTRACT_START = "<!-- agentsmesh:root-generation-contract:start -->";
|
|
1157
1223
|
var ROOT_CONTRACT_END = "<!-- agentsmesh:root-generation-contract:end -->";
|
|
1158
1224
|
var EMBEDDED_RULES_START = "<!-- agentsmesh:embedded-rules:start -->";
|
|
@@ -1174,7 +1240,7 @@ function ruleSource(source) {
|
|
|
1174
1240
|
const meshIndex = normalized.lastIndexOf(".agentsmesh/");
|
|
1175
1241
|
if (meshIndex >= 0) return normalized.slice(meshIndex + ".agentsmesh/".length);
|
|
1176
1242
|
if (normalized.startsWith("rules/")) return normalized;
|
|
1177
|
-
return
|
|
1243
|
+
return join("rules", basename(normalized)).replace(/\\/g, "/");
|
|
1178
1244
|
}
|
|
1179
1245
|
function markerForRule(rule) {
|
|
1180
1246
|
return {
|
|
@@ -1346,7 +1412,7 @@ function pruneUndefined(frontmatter) {
|
|
|
1346
1412
|
return Object.fromEntries(Object.entries(frontmatter).filter(([, value]) => value !== void 0));
|
|
1347
1413
|
}
|
|
1348
1414
|
function serializeCanonicalRuleFrontmatter(destinationPath, frontmatter) {
|
|
1349
|
-
const isRootRule =
|
|
1415
|
+
const isRootRule = basename(destinationPath, ".md") === "_root";
|
|
1350
1416
|
const rest = { ...frontmatter };
|
|
1351
1417
|
delete rest.root;
|
|
1352
1418
|
return {
|
|
@@ -1356,7 +1422,7 @@ function serializeCanonicalRuleFrontmatter(destinationPath, frontmatter) {
|
|
|
1356
1422
|
}
|
|
1357
1423
|
async function serializeImportedRuleWithFallback(destinationPath, importedFrontmatter, body) {
|
|
1358
1424
|
const existingFrontmatter = await readExistingFrontmatter(destinationPath);
|
|
1359
|
-
const normalizedBody =
|
|
1425
|
+
const normalizedBody = basename(destinationPath, ".md") === "_root" ? stripAgentsmeshRootInstructionParagraph(body) : body.trim();
|
|
1360
1426
|
const mergedFrontmatter = serializeCanonicalRuleFrontmatter(
|
|
1361
1427
|
destinationPath,
|
|
1362
1428
|
pruneUndefined({ ...existingFrontmatter, ...importedFrontmatter })
|
|
@@ -1374,9 +1440,6 @@ async function serializeImportedRuleWithFallback(destinationPath, importedFrontm
|
|
|
1374
1440
|
}
|
|
1375
1441
|
return serializeFrontmatter(canonicalFrontmatter, normalizedBody || "");
|
|
1376
1442
|
}
|
|
1377
|
-
|
|
1378
|
-
// src/targets/import/import-metadata-serialize.ts
|
|
1379
|
-
import { basename as basename3, dirname as dirname3 } from "path";
|
|
1380
1443
|
async function serializeImportedCommandWithFallback(destinationPath, imported, body) {
|
|
1381
1444
|
const existingFrontmatter = await readExistingFrontmatter(destinationPath);
|
|
1382
1445
|
const existingAllowedTools = (() => {
|
|
@@ -1395,7 +1458,7 @@ async function serializeImportedCommandWithFallback(destinationPath, imported, b
|
|
|
1395
1458
|
}
|
|
1396
1459
|
async function serializeImportedSkillWithFallback(destinationPath, importedFrontmatter, body) {
|
|
1397
1460
|
const existingFrontmatter = await readExistingFrontmatter(destinationPath);
|
|
1398
|
-
const derivedName =
|
|
1461
|
+
const derivedName = basename(dirname(destinationPath));
|
|
1399
1462
|
const name = readString(importedFrontmatter, "name") ?? readString(existingFrontmatter, "name") ?? derivedName;
|
|
1400
1463
|
const description = readString(importedFrontmatter, "description") ?? readString(existingFrontmatter, "description") ?? "";
|
|
1401
1464
|
return serializeFrontmatter({ name, description }, body.trim() || "");
|
|
@@ -1416,7 +1479,7 @@ async function serializeImportedAgentWithFallback(destinationPath, importedFront
|
|
|
1416
1479
|
const maxTurns = typeof maxTurnsRaw === "number" ? maxTurnsRaw : Number(maxTurnsRaw ?? 0);
|
|
1417
1480
|
const hooks = readHooks(importedFrontmatter) ?? readHooks(existingFrontmatter);
|
|
1418
1481
|
const frontmatter = {
|
|
1419
|
-
name: readString(importedFrontmatter, "name") ?? readString(existingFrontmatter, "name") ??
|
|
1482
|
+
name: readString(importedFrontmatter, "name") ?? readString(existingFrontmatter, "name") ?? basename(destinationPath, ".md"),
|
|
1420
1483
|
description: readString(importedFrontmatter, "description") ?? readString(existingFrontmatter, "description") ?? "",
|
|
1421
1484
|
tools
|
|
1422
1485
|
};
|
|
@@ -1433,9 +1496,6 @@ async function serializeImportedAgentWithFallback(destinationPath, importedFront
|
|
|
1433
1496
|
if (memory) frontmatter.memory = memory;
|
|
1434
1497
|
return serializeFrontmatter(frontmatter, body.trim() || "");
|
|
1435
1498
|
}
|
|
1436
|
-
|
|
1437
|
-
// src/targets/import/import-orchestrator.ts
|
|
1438
|
-
import { dirname as dirname4, relative } from "path";
|
|
1439
1499
|
function matchesExtension(path, extensions) {
|
|
1440
1500
|
return extensions.some((extension) => path.endsWith(extension));
|
|
1441
1501
|
}
|
|
@@ -1454,7 +1514,7 @@ async function importFileDirectory(opts) {
|
|
|
1454
1514
|
normalizeTo: (destinationFile, sourceContent = content) => opts.normalize(sourceContent, srcPath, destinationFile)
|
|
1455
1515
|
});
|
|
1456
1516
|
if (!mapping) continue;
|
|
1457
|
-
await mkdirp(
|
|
1517
|
+
await mkdirp(dirname(mapping.destPath));
|
|
1458
1518
|
await writeFileAtomic(mapping.destPath, mapping.content);
|
|
1459
1519
|
results.push({
|
|
1460
1520
|
fromTool: opts.fromTool,
|
|
@@ -1466,9 +1526,6 @@ async function importFileDirectory(opts) {
|
|
|
1466
1526
|
return results;
|
|
1467
1527
|
}
|
|
1468
1528
|
|
|
1469
|
-
// src/targets/claude-code/importer-mappers.ts
|
|
1470
|
-
import { join as join5 } from "path";
|
|
1471
|
-
|
|
1472
1529
|
// src/targets/import/shared-import-helpers.ts
|
|
1473
1530
|
function toGlobsArray(v) {
|
|
1474
1531
|
if (Array.isArray(v)) return v.filter((x) => typeof x === "string");
|
|
@@ -1498,7 +1555,7 @@ function toStringRecord(value) {
|
|
|
1498
1555
|
|
|
1499
1556
|
// src/targets/claude-code/importer-mappers.ts
|
|
1500
1557
|
async function mapClaudeRuleFile(relativePath, destDir, normalizeTo) {
|
|
1501
|
-
const destPath =
|
|
1558
|
+
const destPath = join(destDir, relativePath);
|
|
1502
1559
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
1503
1560
|
return {
|
|
1504
1561
|
destPath,
|
|
@@ -1512,7 +1569,7 @@ async function mapClaudeRuleFile(relativePath, destDir, normalizeTo) {
|
|
|
1512
1569
|
};
|
|
1513
1570
|
}
|
|
1514
1571
|
async function mapClaudeMarkdownFile(relativePath, destDir, feature, normalizeTo) {
|
|
1515
|
-
const destPath =
|
|
1572
|
+
const destPath = join(destDir, relativePath);
|
|
1516
1573
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
1517
1574
|
const basePath = feature === "commands" ? CLAUDE_CANONICAL_COMMANDS_DIR : CLAUDE_CANONICAL_AGENTS_DIR;
|
|
1518
1575
|
return {
|
|
@@ -1534,10 +1591,6 @@ async function mapClaudeMarkdownFile(relativePath, destDir, feature, normalizeTo
|
|
|
1534
1591
|
) : await serializeImportedAgentWithFallback(destPath, frontmatter, body)
|
|
1535
1592
|
};
|
|
1536
1593
|
}
|
|
1537
|
-
|
|
1538
|
-
// src/targets/claude-code/settings-helpers.ts
|
|
1539
|
-
import { join as join6, dirname as dirname5 } from "path";
|
|
1540
|
-
import { stringify as yamlStringify2 } from "yaml";
|
|
1541
1594
|
function claudeHooksToCanonical(hooks) {
|
|
1542
1595
|
const result = {};
|
|
1543
1596
|
for (const [event, entries] of Object.entries(hooks)) {
|
|
@@ -1563,7 +1616,7 @@ function claudeHooksToCanonical(hooks) {
|
|
|
1563
1616
|
return result;
|
|
1564
1617
|
}
|
|
1565
1618
|
async function importClaudeHooksJson(projectRoot, results) {
|
|
1566
|
-
const hooksPath =
|
|
1619
|
+
const hooksPath = join(projectRoot, CLAUDE_HOOKS_JSON);
|
|
1567
1620
|
const content = await readFileSafe(hooksPath);
|
|
1568
1621
|
if (content === null) return false;
|
|
1569
1622
|
let parsed;
|
|
@@ -1575,9 +1628,9 @@ async function importClaudeHooksJson(projectRoot, results) {
|
|
|
1575
1628
|
if (!parsed || typeof parsed !== "object" || Array.isArray(parsed)) return false;
|
|
1576
1629
|
const canonicalHooks = claudeHooksToCanonical(parsed);
|
|
1577
1630
|
if (Object.keys(canonicalHooks).length === 0) return false;
|
|
1578
|
-
const hooksContent =
|
|
1579
|
-
const destPath =
|
|
1580
|
-
await mkdirp(
|
|
1631
|
+
const hooksContent = stringify(canonicalHooks);
|
|
1632
|
+
const destPath = join(projectRoot, CLAUDE_CANONICAL_HOOKS);
|
|
1633
|
+
await mkdirp(dirname(destPath));
|
|
1581
1634
|
await writeFileAtomic(destPath, hooksContent);
|
|
1582
1635
|
results.push({
|
|
1583
1636
|
fromTool: "claude-code",
|
|
@@ -1588,7 +1641,7 @@ async function importClaudeHooksJson(projectRoot, results) {
|
|
|
1588
1641
|
return true;
|
|
1589
1642
|
}
|
|
1590
1643
|
async function importMcpJson(projectRoot, results, scope = "project") {
|
|
1591
|
-
const mcpPath =
|
|
1644
|
+
const mcpPath = join(projectRoot, scope === "global" ? CLAUDE_GLOBAL_MCP_JSON : CLAUDE_MCP_JSON);
|
|
1592
1645
|
const content = await readFileSafe(mcpPath);
|
|
1593
1646
|
if (content === null) return;
|
|
1594
1647
|
let parsed;
|
|
@@ -1599,8 +1652,8 @@ async function importMcpJson(projectRoot, results, scope = "project") {
|
|
|
1599
1652
|
}
|
|
1600
1653
|
if (parsed.mcpServers && typeof parsed.mcpServers === "object") {
|
|
1601
1654
|
const mcpContent = JSON.stringify({ mcpServers: parsed.mcpServers }, null, 2);
|
|
1602
|
-
const destPath =
|
|
1603
|
-
await mkdirp(
|
|
1655
|
+
const destPath = join(projectRoot, CLAUDE_CANONICAL_MCP);
|
|
1656
|
+
await mkdirp(dirname(destPath));
|
|
1604
1657
|
await writeFileAtomic(destPath, mcpContent);
|
|
1605
1658
|
results.push({
|
|
1606
1659
|
fromTool: "claude-code",
|
|
@@ -1614,7 +1667,7 @@ async function importSettings(projectRoot, results) {
|
|
|
1614
1667
|
const hooksFromStandaloneFile = results.some(
|
|
1615
1668
|
(r) => r.feature === "hooks" && r.fromPath.replace(/\\/g, "/").endsWith(CLAUDE_HOOKS_JSON)
|
|
1616
1669
|
);
|
|
1617
|
-
const settingsPath =
|
|
1670
|
+
const settingsPath = join(projectRoot, CLAUDE_SETTINGS);
|
|
1618
1671
|
const content = await readFileSafe(settingsPath);
|
|
1619
1672
|
if (!content) return;
|
|
1620
1673
|
let settings;
|
|
@@ -1626,8 +1679,8 @@ async function importSettings(projectRoot, results) {
|
|
|
1626
1679
|
const alreadyImportedMcp = results.some((r) => r.feature === "mcp");
|
|
1627
1680
|
if (!alreadyImportedMcp && settings.mcpServers && typeof settings.mcpServers === "object") {
|
|
1628
1681
|
const mcpContent = JSON.stringify({ mcpServers: settings.mcpServers }, null, 2);
|
|
1629
|
-
const destPath =
|
|
1630
|
-
await mkdirp(
|
|
1682
|
+
const destPath = join(projectRoot, CLAUDE_CANONICAL_MCP);
|
|
1683
|
+
await mkdirp(dirname(destPath));
|
|
1631
1684
|
await writeFileAtomic(destPath, mcpContent);
|
|
1632
1685
|
results.push({
|
|
1633
1686
|
fromTool: "claude-code",
|
|
@@ -1643,9 +1696,9 @@ async function importSettings(projectRoot, results) {
|
|
|
1643
1696
|
const deny = Array.isArray(perms.deny) ? perms.deny.filter((s) => typeof s === "string") : [];
|
|
1644
1697
|
const ask = Array.isArray(perms.ask) ? perms.ask.filter((s) => typeof s === "string") : [];
|
|
1645
1698
|
if (allow.length > 0 || deny.length > 0 || ask.length > 0) {
|
|
1646
|
-
const permContent =
|
|
1647
|
-
const destPath =
|
|
1648
|
-
await mkdirp(
|
|
1699
|
+
const permContent = stringify({ allow, deny, ask });
|
|
1700
|
+
const destPath = join(projectRoot, CLAUDE_CANONICAL_PERMISSIONS);
|
|
1701
|
+
await mkdirp(dirname(destPath));
|
|
1649
1702
|
await writeFileAtomic(destPath, permContent);
|
|
1650
1703
|
results.push({
|
|
1651
1704
|
fromTool: "claude-code",
|
|
@@ -1659,9 +1712,9 @@ async function importSettings(projectRoot, results) {
|
|
|
1659
1712
|
if (!hooksFromStandaloneFile && rawHooks && typeof rawHooks === "object" && !Array.isArray(rawHooks)) {
|
|
1660
1713
|
const canonicalHooks = claudeHooksToCanonical(rawHooks);
|
|
1661
1714
|
if (Object.keys(canonicalHooks).length > 0) {
|
|
1662
|
-
const hooksContent =
|
|
1663
|
-
const destPath =
|
|
1664
|
-
await mkdirp(
|
|
1715
|
+
const hooksContent = stringify(canonicalHooks);
|
|
1716
|
+
const destPath = join(projectRoot, CLAUDE_CANONICAL_HOOKS);
|
|
1717
|
+
await mkdirp(dirname(destPath));
|
|
1665
1718
|
await writeFileAtomic(destPath, hooksContent);
|
|
1666
1719
|
results.push({
|
|
1667
1720
|
fromTool: "claude-code",
|
|
@@ -1672,25 +1725,22 @@ async function importSettings(projectRoot, results) {
|
|
|
1672
1725
|
}
|
|
1673
1726
|
}
|
|
1674
1727
|
}
|
|
1675
|
-
|
|
1676
|
-
// src/targets/claude-code/importer-skills.ts
|
|
1677
|
-
import { basename as basename4, dirname as dirname6, join as join7, relative as relative2 } from "path";
|
|
1678
1728
|
async function importClaudeSkills(projectRoot, results, normalize) {
|
|
1679
|
-
const skillsBaseDir =
|
|
1680
|
-
const destBase =
|
|
1729
|
+
const skillsBaseDir = join(projectRoot, CLAUDE_SKILLS_DIR);
|
|
1730
|
+
const destBase = join(projectRoot, CLAUDE_CANONICAL_SKILLS_DIR);
|
|
1681
1731
|
const allFiles = await readDirRecursive(skillsBaseDir);
|
|
1682
1732
|
const skillMdFiles = allFiles.filter((f) => f.endsWith("SKILL.md"));
|
|
1683
1733
|
for (const skillMdPath of skillMdFiles) {
|
|
1684
|
-
const skillDir =
|
|
1685
|
-
const skillName =
|
|
1686
|
-
const destSkillDir =
|
|
1734
|
+
const skillDir = dirname(skillMdPath);
|
|
1735
|
+
const skillName = basename(skillDir);
|
|
1736
|
+
const destSkillDir = join(destBase, skillName);
|
|
1687
1737
|
const skillFiles = await readDirRecursive(skillDir);
|
|
1688
1738
|
for (const filePath of skillFiles) {
|
|
1689
1739
|
const fileContent = await readFileSafe(filePath);
|
|
1690
1740
|
if (fileContent === null) continue;
|
|
1691
|
-
const relPath =
|
|
1692
|
-
const destPath =
|
|
1693
|
-
await mkdirp(
|
|
1741
|
+
const relPath = relative(skillDir, filePath);
|
|
1742
|
+
const destPath = join(destSkillDir, relPath);
|
|
1743
|
+
await mkdirp(dirname(destPath));
|
|
1694
1744
|
const normalized = normalize(fileContent, filePath, destPath);
|
|
1695
1745
|
const parsed = relPath === "SKILL.md" ? parseFrontmatter(normalized) : null;
|
|
1696
1746
|
await writeFileAtomic(
|
|
@@ -1728,16 +1778,16 @@ async function importFromClaudeCode(projectRoot, options = {}) {
|
|
|
1728
1778
|
return results;
|
|
1729
1779
|
}
|
|
1730
1780
|
async function importRules(projectRoot, results, normalize, scope) {
|
|
1731
|
-
const destDir =
|
|
1732
|
-
const primaryClaudePath =
|
|
1781
|
+
const destDir = join(projectRoot, CLAUDE_CANONICAL_RULES_DIR);
|
|
1782
|
+
const primaryClaudePath = join(projectRoot, CLAUDE_ROOT);
|
|
1733
1783
|
const primaryContent = await readFileSafe(primaryClaudePath);
|
|
1734
|
-
const legacyClaudePath =
|
|
1784
|
+
const legacyClaudePath = join(projectRoot, CLAUDE_LEGACY_ROOT);
|
|
1735
1785
|
const legacyContent = scope === "project" && primaryContent === null ? await readFileSafe(legacyClaudePath) : null;
|
|
1736
1786
|
const claudeContent = primaryContent ?? legacyContent;
|
|
1737
1787
|
const claudePath = primaryContent !== null ? primaryClaudePath : legacyClaudePath;
|
|
1738
1788
|
if (claudeContent !== null) {
|
|
1739
1789
|
await mkdirp(destDir);
|
|
1740
|
-
const destPath =
|
|
1790
|
+
const destPath = join(destDir, "_root.md");
|
|
1741
1791
|
const { frontmatter, body } = parseFrontmatter(normalize(claudeContent, claudePath, destPath));
|
|
1742
1792
|
const hasRoot = frontmatter.root === true;
|
|
1743
1793
|
const outFm = hasRoot ? frontmatter : { ...frontmatter, root: true };
|
|
@@ -1750,7 +1800,7 @@ async function importRules(projectRoot, results, normalize, scope) {
|
|
|
1750
1800
|
feature: "rules"
|
|
1751
1801
|
});
|
|
1752
1802
|
}
|
|
1753
|
-
const rulesDir =
|
|
1803
|
+
const rulesDir = join(projectRoot, CLAUDE_RULES_DIR);
|
|
1754
1804
|
results.push(
|
|
1755
1805
|
...await importFileDirectory({
|
|
1756
1806
|
srcDir: rulesDir,
|
|
@@ -1763,8 +1813,8 @@ async function importRules(projectRoot, results, normalize, scope) {
|
|
|
1763
1813
|
);
|
|
1764
1814
|
}
|
|
1765
1815
|
async function importCommands(projectRoot, results, normalize) {
|
|
1766
|
-
const destDir =
|
|
1767
|
-
const commandsDir =
|
|
1816
|
+
const destDir = join(projectRoot, CLAUDE_CANONICAL_COMMANDS_DIR);
|
|
1817
|
+
const commandsDir = join(projectRoot, CLAUDE_COMMANDS_DIR);
|
|
1768
1818
|
results.push(
|
|
1769
1819
|
...await importFileDirectory({
|
|
1770
1820
|
srcDir: commandsDir,
|
|
@@ -1777,8 +1827,8 @@ async function importCommands(projectRoot, results, normalize) {
|
|
|
1777
1827
|
);
|
|
1778
1828
|
}
|
|
1779
1829
|
async function importAgents(projectRoot, results, normalize) {
|
|
1780
|
-
const destDir =
|
|
1781
|
-
const agentsDir =
|
|
1830
|
+
const destDir = join(projectRoot, CLAUDE_CANONICAL_AGENTS_DIR);
|
|
1831
|
+
const agentsDir = join(projectRoot, CLAUDE_AGENTS_DIR);
|
|
1782
1832
|
results.push(
|
|
1783
1833
|
...await importFileDirectory({
|
|
1784
1834
|
srcDir: agentsDir,
|
|
@@ -1791,11 +1841,11 @@ async function importAgents(projectRoot, results, normalize) {
|
|
|
1791
1841
|
);
|
|
1792
1842
|
}
|
|
1793
1843
|
async function importIgnore(projectRoot, results) {
|
|
1794
|
-
const ignorePath =
|
|
1844
|
+
const ignorePath = join(projectRoot, CLAUDE_IGNORE);
|
|
1795
1845
|
const content = await readFileSafe(ignorePath);
|
|
1796
1846
|
if (content === null) return;
|
|
1797
|
-
const destPath =
|
|
1798
|
-
await mkdirp(
|
|
1847
|
+
const destPath = join(projectRoot, CLAUDE_CANONICAL_IGNORE);
|
|
1848
|
+
await mkdirp(dirname(destPath));
|
|
1799
1849
|
await writeFileAtomic(destPath, content);
|
|
1800
1850
|
results.push({
|
|
1801
1851
|
fromTool: "claude-code",
|
|
@@ -1805,9 +1855,6 @@ async function importIgnore(projectRoot, results) {
|
|
|
1805
1855
|
});
|
|
1806
1856
|
}
|
|
1807
1857
|
|
|
1808
|
-
// src/core/lint/validate-rules.ts
|
|
1809
|
-
import { relative as relative3 } from "path";
|
|
1810
|
-
|
|
1811
1858
|
// src/utils/text/glob.ts
|
|
1812
1859
|
function globMatch(filepath, pattern) {
|
|
1813
1860
|
const alternatives = expandBraces(pattern);
|
|
@@ -1899,7 +1946,7 @@ function validateRules(canonical, projectRoot, projectFiles, options = {}) {
|
|
|
1899
1946
|
if (!hasRoot) {
|
|
1900
1947
|
diags.push({
|
|
1901
1948
|
level: "error",
|
|
1902
|
-
file:
|
|
1949
|
+
file: relative(projectRoot, rules[0].source),
|
|
1903
1950
|
message: "Rules exist but no root rule (_root.md or root: true). Add a root rule."
|
|
1904
1951
|
});
|
|
1905
1952
|
}
|
|
@@ -1919,7 +1966,7 @@ function validateRules(canonical, projectRoot, projectFiles, options = {}) {
|
|
|
1919
1966
|
if (!anyMatch) {
|
|
1920
1967
|
diags.push({
|
|
1921
1968
|
level: "warning",
|
|
1922
|
-
file:
|
|
1969
|
+
file: relative(projectRoot, rule.source),
|
|
1923
1970
|
message: `globs "${rule.globs.join(", ")}" match 0 files in project`
|
|
1924
1971
|
});
|
|
1925
1972
|
}
|
|
@@ -1935,9 +1982,6 @@ function lintRules(canonical, _projectRoot, projectFiles, options) {
|
|
|
1935
1982
|
return diags.map((d) => ({ ...d, target: CLAUDE_CODE_TARGET }));
|
|
1936
1983
|
}
|
|
1937
1984
|
|
|
1938
|
-
// src/core/reference/import-map-shared.ts
|
|
1939
|
-
import { basename as basename5, dirname as dirname8, join as join9, relative as relative4 } from "path";
|
|
1940
|
-
|
|
1941
1985
|
// src/targets/codex-cli/command-skill.ts
|
|
1942
1986
|
var CODEX_COMMAND_SKILL_PREFIX = "am-command-";
|
|
1943
1987
|
var LEGACY_CODEX_COMMAND_SKILL_PREFIX = "ab-command-";
|
|
@@ -2082,34 +2126,34 @@ var AB_COMMANDS = ".agentsmesh/commands";
|
|
|
2082
2126
|
var AB_AGENTS = ".agentsmesh/agents";
|
|
2083
2127
|
var AB_SKILLS = ".agentsmesh/skills";
|
|
2084
2128
|
function rel(projectRoot, absPath) {
|
|
2085
|
-
return
|
|
2129
|
+
return relative(projectRoot, absPath).replace(/\\/g, "/");
|
|
2086
2130
|
}
|
|
2087
2131
|
async function listFiles(projectRoot, dir) {
|
|
2088
|
-
return readDirRecursive(
|
|
2132
|
+
return readDirRecursive(join(projectRoot, dir)).catch(() => []);
|
|
2089
2133
|
}
|
|
2090
2134
|
function addDirectoryMapping(refs, from, to) {
|
|
2091
2135
|
refs.set(from, to);
|
|
2092
2136
|
refs.set(`${from}/`, `${to}/`);
|
|
2093
2137
|
}
|
|
2094
2138
|
function addAncestorMappings(refs, fromPath, toPath, stopDir) {
|
|
2095
|
-
let fromDir =
|
|
2096
|
-
let toDir =
|
|
2139
|
+
let fromDir = dirname(fromPath);
|
|
2140
|
+
let toDir = dirname(toPath);
|
|
2097
2141
|
while (fromDir !== stopDir && fromDir !== ".") {
|
|
2098
2142
|
addDirectoryMapping(refs, fromDir, toDir);
|
|
2099
|
-
fromDir =
|
|
2100
|
-
toDir =
|
|
2143
|
+
fromDir = dirname(fromDir);
|
|
2144
|
+
toDir = dirname(toDir);
|
|
2101
2145
|
}
|
|
2102
2146
|
}
|
|
2103
2147
|
function addSimpleFileMapping(refs, fromPath, canonicalDir, extension) {
|
|
2104
|
-
refs.set(fromPath, `${canonicalDir}/${
|
|
2148
|
+
refs.set(fromPath, `${canonicalDir}/${basename(fromPath, extension)}.md`);
|
|
2105
2149
|
}
|
|
2106
2150
|
function addSkillLikeMapping(refs, relPath, skillsDir) {
|
|
2107
2151
|
if (!relPath.startsWith(`${skillsDir}/`)) return;
|
|
2108
2152
|
const rest = relPath.slice(skillsDir.length + 1);
|
|
2109
2153
|
if (!rest) return;
|
|
2110
2154
|
if (!rest.includes("/")) {
|
|
2111
|
-
if (!rest.endsWith(".md") ||
|
|
2112
|
-
const name =
|
|
2155
|
+
if (!rest.endsWith(".md") || basename(rest) === "SKILL.md") return;
|
|
2156
|
+
const name = basename(rest, ".md");
|
|
2113
2157
|
refs.set(relPath, `${AB_SKILLS}/${name}/SKILL.md`);
|
|
2114
2158
|
return;
|
|
2115
2159
|
}
|
|
@@ -2155,7 +2199,7 @@ async function addScopedAgentsMappings(refs, projectRoot) {
|
|
|
2155
2199
|
const isNestedAgents = relPath.endsWith("/AGENTS.md") && relPath !== "AGENTS.md" && !relPath.endsWith("/AGENTS.override.md");
|
|
2156
2200
|
const isNestedOverride = relPath.endsWith("/AGENTS.override.md") && relPath !== "AGENTS.override.md";
|
|
2157
2201
|
if (!isNestedAgents && !isNestedOverride) continue;
|
|
2158
|
-
const parentDir =
|
|
2202
|
+
const parentDir = dirname(relPath);
|
|
2159
2203
|
if (SCOPED_AGENTS_SKIP_DIRS.has(parentDir)) continue;
|
|
2160
2204
|
const ruleName = parentDir.replace(/\//g, "-");
|
|
2161
2205
|
refs.set(relPath, `${AB_RULES}/${ruleName}.md`);
|
|
@@ -2236,9 +2280,6 @@ async function buildClaudeCodeImportPaths(refs, projectRoot, scope = "project")
|
|
|
2236
2280
|
}
|
|
2237
2281
|
}
|
|
2238
2282
|
|
|
2239
|
-
// src/core/reference/import-maps/cline.ts
|
|
2240
|
-
import { basename as basename6 } from "path";
|
|
2241
|
-
|
|
2242
2283
|
// src/targets/cline/constants.ts
|
|
2243
2284
|
var CLINE_TARGET = "cline";
|
|
2244
2285
|
var CLINE_RULES_DIR = ".clinerules";
|
|
@@ -2278,7 +2319,7 @@ async function buildClineImportPaths(refs, projectRoot, scope = "project") {
|
|
|
2278
2319
|
refs.set(".clinerules/_root.md", `${AB_RULES2}/_root.md`);
|
|
2279
2320
|
for (const absPath of await listFiles(projectRoot, ".clinerules")) {
|
|
2280
2321
|
const relPath = rel(projectRoot, absPath);
|
|
2281
|
-
if (!relPath.endsWith(".md") || relPath.includes("/workflows/") ||
|
|
2322
|
+
if (!relPath.endsWith(".md") || relPath.includes("/workflows/") || basename(relPath) === "_root.md") {
|
|
2282
2323
|
continue;
|
|
2283
2324
|
}
|
|
2284
2325
|
addSimpleFileMapping(refs, relPath, AB_RULES2, ".md");
|
|
@@ -2321,12 +2362,9 @@ async function buildCodexCliImportPaths(refs, projectRoot, scope = "project") {
|
|
|
2321
2362
|
addSkillLikeMapping(refs, rel(projectRoot, absPath), ".agents/skills");
|
|
2322
2363
|
}
|
|
2323
2364
|
}
|
|
2324
|
-
|
|
2325
|
-
// src/core/reference/import-maps/copilot.ts
|
|
2326
|
-
import { basename as basename7 } from "path";
|
|
2327
2365
|
function addCopilotInstructionMapping(refs, fromPath) {
|
|
2328
2366
|
if (fromPath.endsWith(".instructions.md")) {
|
|
2329
|
-
refs.set(fromPath, `${AB_RULES2}/${
|
|
2367
|
+
refs.set(fromPath, `${AB_RULES2}/${basename(fromPath, ".instructions.md")}.md`);
|
|
2330
2368
|
return;
|
|
2331
2369
|
}
|
|
2332
2370
|
addSimpleFileMapping(refs, fromPath, AB_RULES2, ".md");
|
|
@@ -2334,25 +2372,22 @@ function addCopilotInstructionMapping(refs, fromPath) {
|
|
|
2334
2372
|
async function buildCopilotImportPaths(refs, projectRoot) {
|
|
2335
2373
|
refs.set(".github/copilot-instructions.md", `${AB_RULES2}/_root.md`);
|
|
2336
2374
|
for (const absPath of await listFiles(projectRoot, ".github/copilot")) {
|
|
2337
|
-
refs.set(rel(projectRoot, absPath), `${AB_RULES2}/${
|
|
2375
|
+
refs.set(rel(projectRoot, absPath), `${AB_RULES2}/${basename(absPath, ".instructions.md")}.md`);
|
|
2338
2376
|
}
|
|
2339
2377
|
for (const absPath of await listFiles(projectRoot, ".github/instructions")) {
|
|
2340
2378
|
addCopilotInstructionMapping(refs, rel(projectRoot, absPath));
|
|
2341
2379
|
}
|
|
2342
2380
|
for (const absPath of await listFiles(projectRoot, ".github/prompts")) {
|
|
2343
|
-
refs.set(rel(projectRoot, absPath), `${AB_COMMANDS2}/${
|
|
2381
|
+
refs.set(rel(projectRoot, absPath), `${AB_COMMANDS2}/${basename(absPath, ".prompt.md")}.md`);
|
|
2344
2382
|
}
|
|
2345
2383
|
for (const absPath of await listFiles(projectRoot, ".github/agents")) {
|
|
2346
|
-
refs.set(rel(projectRoot, absPath), `${AB_AGENTS2}/${
|
|
2384
|
+
refs.set(rel(projectRoot, absPath), `${AB_AGENTS2}/${basename(absPath, ".agent.md")}.md`);
|
|
2347
2385
|
}
|
|
2348
2386
|
for (const absPath of await listFiles(projectRoot, ".github/skills")) {
|
|
2349
2387
|
addSkillLikeMapping(refs, rel(projectRoot, absPath), ".github/skills");
|
|
2350
2388
|
}
|
|
2351
2389
|
}
|
|
2352
2390
|
|
|
2353
|
-
// src/core/reference/import-maps/continue.ts
|
|
2354
|
-
import { basename as basename8 } from "path";
|
|
2355
|
-
|
|
2356
2391
|
// src/targets/continue/constants.ts
|
|
2357
2392
|
var CONTINUE_TARGET = "continue";
|
|
2358
2393
|
var CONTINUE_RULES_DIR = ".continue/rules";
|
|
@@ -2378,7 +2413,7 @@ async function buildContinueImportPaths(refs, projectRoot, scope = "project") {
|
|
|
2378
2413
|
addSimpleFileMapping(refs, relPath, AB_RULES2, ".md");
|
|
2379
2414
|
}
|
|
2380
2415
|
for (const absPath of await listFiles(projectRoot, ".continue/prompts")) {
|
|
2381
|
-
refs.set(rel(projectRoot, absPath), `${AB_COMMANDS2}/${
|
|
2416
|
+
refs.set(rel(projectRoot, absPath), `${AB_COMMANDS2}/${basename(absPath, ".md")}.md`);
|
|
2382
2417
|
}
|
|
2383
2418
|
for (const absPath of await listFiles(projectRoot, ".continue/skills")) {
|
|
2384
2419
|
addSkillLikeMapping(refs, rel(projectRoot, absPath), ".continue/skills");
|
|
@@ -2534,7 +2569,6 @@ var KIRO_AGENTS_DIR = `${KIRO_DIR}/agents`;
|
|
|
2534
2569
|
var KIRO_HOOKS_DIR = `${KIRO_DIR}/hooks`;
|
|
2535
2570
|
var KIRO_SETTINGS_DIR = `${KIRO_DIR}/settings`;
|
|
2536
2571
|
var KIRO_MCP_FILE = `${KIRO_SETTINGS_DIR}/mcp.json`;
|
|
2537
|
-
var KIRO_CLI_FILE = `${KIRO_SETTINGS_DIR}/cli.json`;
|
|
2538
2572
|
var KIRO_IGNORE = ".kiroignore";
|
|
2539
2573
|
var KIRO_GLOBAL_STEERING_DIR = ".kiro/steering";
|
|
2540
2574
|
var KIRO_GLOBAL_STEERING_AGENTS_MD = ".kiro/steering/AGENTS.md";
|
|
@@ -2919,18 +2953,12 @@ function generateIgnore2(canonical) {
|
|
|
2919
2953
|
const content = canonical.ignore.join("\n");
|
|
2920
2954
|
return [{ path: CURSOR_IGNORE, content }];
|
|
2921
2955
|
}
|
|
2922
|
-
|
|
2923
|
-
// src/targets/cursor/importer.ts
|
|
2924
|
-
import { join as join18, dirname as dirname12 } from "path";
|
|
2925
|
-
|
|
2926
|
-
// src/targets/cursor/importer-mappers.ts
|
|
2927
|
-
import { join as join10 } from "path";
|
|
2928
2956
|
async function mapCursorRuleFile(relativePath, destDir, normalizeTo, onRootRule) {
|
|
2929
2957
|
const rawRelativePath = relativePath.replace(/\.mdc$/i, ".md");
|
|
2930
|
-
const rawDestPath =
|
|
2958
|
+
const rawDestPath = join(destDir, rawRelativePath);
|
|
2931
2959
|
const initial = parseFrontmatter(normalizeTo(rawDestPath));
|
|
2932
2960
|
const isRoot = initial.frontmatter.alwaysApply === true;
|
|
2933
|
-
const destPath = isRoot ?
|
|
2961
|
+
const destPath = isRoot ? join(destDir, "_root.md") : rawDestPath;
|
|
2934
2962
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
2935
2963
|
if (isRoot) onRootRule();
|
|
2936
2964
|
const canonicalFm = { ...frontmatter, root: isRoot };
|
|
@@ -2943,7 +2971,7 @@ async function mapCursorRuleFile(relativePath, destDir, normalizeTo, onRootRule)
|
|
|
2943
2971
|
};
|
|
2944
2972
|
}
|
|
2945
2973
|
async function mapCursorCommandFile(relativePath, destDir, normalizeTo) {
|
|
2946
|
-
const destPath =
|
|
2974
|
+
const destPath = join(destDir, relativePath);
|
|
2947
2975
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
2948
2976
|
const fromCamel = toToolsArray(frontmatter.allowedTools);
|
|
2949
2977
|
const allowedTools = fromCamel.length > 0 ? fromCamel : toToolsArray(frontmatter["allowed-tools"]);
|
|
@@ -2964,7 +2992,7 @@ async function mapCursorCommandFile(relativePath, destDir, normalizeTo) {
|
|
|
2964
2992
|
};
|
|
2965
2993
|
}
|
|
2966
2994
|
async function mapCursorAgentFile(relativePath, destDir, normalizeTo) {
|
|
2967
|
-
const destPath =
|
|
2995
|
+
const destPath = join(destDir, relativePath);
|
|
2968
2996
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
2969
2997
|
return {
|
|
2970
2998
|
destPath,
|
|
@@ -2973,15 +3001,6 @@ async function mapCursorAgentFile(relativePath, destDir, normalizeTo) {
|
|
|
2973
3001
|
content: await serializeImportedAgentWithFallback(destPath, frontmatter, body)
|
|
2974
3002
|
};
|
|
2975
3003
|
}
|
|
2976
|
-
|
|
2977
|
-
// src/targets/cursor/importer-rules.ts
|
|
2978
|
-
import { join as join13 } from "path";
|
|
2979
|
-
|
|
2980
|
-
// src/targets/cursor/import-root-helpers.ts
|
|
2981
|
-
import { join as join12 } from "path";
|
|
2982
|
-
|
|
2983
|
-
// src/targets/import/embedded-rules.ts
|
|
2984
|
-
import { join as join11 } from "path";
|
|
2985
3004
|
function canonicalRulePath(source) {
|
|
2986
3005
|
const normalized = source.replace(/\\/g, "/");
|
|
2987
3006
|
if (!normalized.startsWith("rules/") || normalized.endsWith("/")) return null;
|
|
@@ -2994,11 +3013,11 @@ async function splitEmbeddedRulesToCanonical(input) {
|
|
|
2994
3013
|
if (extracted.rules.length === 0) {
|
|
2995
3014
|
return { rootContent: extracted.rootContent, results };
|
|
2996
3015
|
}
|
|
2997
|
-
await mkdirp(
|
|
3016
|
+
await mkdirp(join(input.projectRoot, input.rulesDir));
|
|
2998
3017
|
for (const rule of extracted.rules) {
|
|
2999
3018
|
const canonicalSource = canonicalRulePath(rule.source);
|
|
3000
3019
|
if (canonicalSource === null || canonicalSource === "rules/_root.md") continue;
|
|
3001
|
-
const destPath =
|
|
3020
|
+
const destPath = join(input.projectRoot, ".agentsmesh", canonicalSource);
|
|
3002
3021
|
const normalized = input.normalize(rule.body, input.sourcePath, destPath);
|
|
3003
3022
|
const { frontmatter, body } = parseFrontmatter(normalized);
|
|
3004
3023
|
const content = await serializeImportedRuleWithFallback(
|
|
@@ -3025,9 +3044,9 @@ async function splitEmbeddedRulesToCanonical(input) {
|
|
|
3025
3044
|
|
|
3026
3045
|
// src/targets/cursor/import-root-helpers.ts
|
|
3027
3046
|
async function importCursorRootFile(input) {
|
|
3028
|
-
const destDir =
|
|
3047
|
+
const destDir = join(input.projectRoot, CURSOR_CANONICAL_RULES_DIR);
|
|
3029
3048
|
await mkdirp(destDir);
|
|
3030
|
-
const destPath =
|
|
3049
|
+
const destPath = join(destDir, "_root.md");
|
|
3031
3050
|
const split = await splitEmbeddedRulesToCanonical({
|
|
3032
3051
|
content: input.content,
|
|
3033
3052
|
projectRoot: input.projectRoot,
|
|
@@ -3054,9 +3073,9 @@ async function importCursorRootFile(input) {
|
|
|
3054
3073
|
|
|
3055
3074
|
// src/targets/cursor/importer-rules.ts
|
|
3056
3075
|
async function importCursorRules(projectRoot, results, normalize) {
|
|
3057
|
-
const destDir =
|
|
3076
|
+
const destDir = join(projectRoot, CURSOR_CANONICAL_RULES_DIR);
|
|
3058
3077
|
let rootWritten = false;
|
|
3059
|
-
const rulesDir =
|
|
3078
|
+
const rulesDir = join(projectRoot, CURSOR_RULES_DIR);
|
|
3060
3079
|
results.push(
|
|
3061
3080
|
...await importFileDirectory({
|
|
3062
3081
|
srcDir: rulesDir,
|
|
@@ -3079,7 +3098,7 @@ async function importCursorRules(projectRoot, results, normalize) {
|
|
|
3079
3098
|
})
|
|
3080
3099
|
);
|
|
3081
3100
|
if (!rootWritten) {
|
|
3082
|
-
const agentsPath =
|
|
3101
|
+
const agentsPath = join(projectRoot, CURSOR_COMPAT_AGENTS);
|
|
3083
3102
|
const agentsContent = await readFileSafe(agentsPath);
|
|
3084
3103
|
if (agentsContent !== null) {
|
|
3085
3104
|
rootWritten = await importCursorRootFile({
|
|
@@ -3092,7 +3111,7 @@ async function importCursorRules(projectRoot, results, normalize) {
|
|
|
3092
3111
|
}
|
|
3093
3112
|
}
|
|
3094
3113
|
if (!rootWritten) {
|
|
3095
|
-
const cursorRulesPath =
|
|
3114
|
+
const cursorRulesPath = join(projectRoot, CURSOR_LEGACY_RULES);
|
|
3096
3115
|
const cursorRulesContent = await readFileSafe(cursorRulesPath);
|
|
3097
3116
|
if (cursorRulesContent !== null) {
|
|
3098
3117
|
await importCursorRootFile({
|
|
@@ -3105,10 +3124,6 @@ async function importCursorRules(projectRoot, results, normalize) {
|
|
|
3105
3124
|
}
|
|
3106
3125
|
}
|
|
3107
3126
|
}
|
|
3108
|
-
|
|
3109
|
-
// src/targets/cursor/settings-helpers.ts
|
|
3110
|
-
import { join as join14, dirname as dirname9 } from "path";
|
|
3111
|
-
import { stringify as yamlStringify3 } from "yaml";
|
|
3112
3127
|
function cursorHooksToCanonical(hooks) {
|
|
3113
3128
|
const result = {};
|
|
3114
3129
|
for (const [event, entries] of Object.entries(hooks)) {
|
|
@@ -3135,7 +3150,7 @@ function cursorHooksToCanonical(hooks) {
|
|
|
3135
3150
|
}
|
|
3136
3151
|
async function importSettings2(projectRoot, results) {
|
|
3137
3152
|
let hooksImportedFromHooksJson = false;
|
|
3138
|
-
const hooksJsonPath =
|
|
3153
|
+
const hooksJsonPath = join(projectRoot, CURSOR_HOOKS);
|
|
3139
3154
|
const hooksJsonContent = await readFileSafe(hooksJsonPath);
|
|
3140
3155
|
if (hooksJsonContent) {
|
|
3141
3156
|
try {
|
|
@@ -3143,9 +3158,9 @@ async function importSettings2(projectRoot, results) {
|
|
|
3143
3158
|
if (hooksFile.hooks && typeof hooksFile.hooks === "object") {
|
|
3144
3159
|
const canonical = cursorHooksToCanonical(hooksFile.hooks);
|
|
3145
3160
|
if (Object.keys(canonical).length > 0) {
|
|
3146
|
-
const hooksContent =
|
|
3147
|
-
const destPath =
|
|
3148
|
-
await mkdirp(
|
|
3161
|
+
const hooksContent = stringify(canonical);
|
|
3162
|
+
const destPath = join(projectRoot, CURSOR_CANONICAL_HOOKS);
|
|
3163
|
+
await mkdirp(dirname(destPath));
|
|
3149
3164
|
await writeFileAtomic(destPath, hooksContent);
|
|
3150
3165
|
results.push({
|
|
3151
3166
|
fromTool: "cursor",
|
|
@@ -3159,7 +3174,7 @@ async function importSettings2(projectRoot, results) {
|
|
|
3159
3174
|
} catch {
|
|
3160
3175
|
}
|
|
3161
3176
|
}
|
|
3162
|
-
const settingsPath =
|
|
3177
|
+
const settingsPath = join(projectRoot, CURSOR_SETTINGS);
|
|
3163
3178
|
const content = await readFileSafe(settingsPath);
|
|
3164
3179
|
if (!content) return;
|
|
3165
3180
|
let settings;
|
|
@@ -3174,9 +3189,9 @@ async function importSettings2(projectRoot, results) {
|
|
|
3174
3189
|
const allow = Array.isArray(perms.allow) ? perms.allow.filter((s) => typeof s === "string") : [];
|
|
3175
3190
|
const deny = Array.isArray(perms.deny) ? perms.deny.filter((s) => typeof s === "string") : [];
|
|
3176
3191
|
if (allow.length > 0 || deny.length > 0) {
|
|
3177
|
-
const permContent =
|
|
3178
|
-
const destPath =
|
|
3179
|
-
await mkdirp(
|
|
3192
|
+
const permContent = stringify({ allow, deny });
|
|
3193
|
+
const destPath = join(projectRoot, CURSOR_CANONICAL_PERMISSIONS);
|
|
3194
|
+
await mkdirp(dirname(destPath));
|
|
3180
3195
|
await writeFileAtomic(destPath, permContent);
|
|
3181
3196
|
results.push({
|
|
3182
3197
|
fromTool: "cursor",
|
|
@@ -3190,9 +3205,9 @@ async function importSettings2(projectRoot, results) {
|
|
|
3190
3205
|
if (rawHooks && typeof rawHooks === "object" && !Array.isArray(rawHooks)) {
|
|
3191
3206
|
const canonicalHooks = cursorHooksToCanonical(rawHooks);
|
|
3192
3207
|
if (Object.keys(canonicalHooks).length > 0) {
|
|
3193
|
-
const hooksContent =
|
|
3194
|
-
const destPath =
|
|
3195
|
-
await mkdirp(
|
|
3208
|
+
const hooksContent = stringify(canonicalHooks);
|
|
3209
|
+
const destPath = join(projectRoot, CURSOR_CANONICAL_HOOKS);
|
|
3210
|
+
await mkdirp(dirname(destPath));
|
|
3196
3211
|
await writeFileAtomic(destPath, hooksContent);
|
|
3197
3212
|
results.push({
|
|
3198
3213
|
fromTool: "cursor",
|
|
@@ -3205,8 +3220,8 @@ async function importSettings2(projectRoot, results) {
|
|
|
3205
3220
|
}
|
|
3206
3221
|
async function importIgnore2(projectRoot, results) {
|
|
3207
3222
|
const sources = [
|
|
3208
|
-
{ path:
|
|
3209
|
-
{ path:
|
|
3223
|
+
{ path: join(projectRoot, CURSOR_IGNORE), label: CURSOR_IGNORE },
|
|
3224
|
+
{ path: join(projectRoot, CURSOR_INDEXING_IGNORE), label: CURSOR_INDEXING_IGNORE }
|
|
3210
3225
|
];
|
|
3211
3226
|
const patterns = [];
|
|
3212
3227
|
const importedFrom = [];
|
|
@@ -3222,23 +3237,17 @@ async function importIgnore2(projectRoot, results) {
|
|
|
3222
3237
|
}
|
|
3223
3238
|
}
|
|
3224
3239
|
if (patterns.length === 0) return;
|
|
3225
|
-
const destPath =
|
|
3226
|
-
await mkdirp(
|
|
3240
|
+
const destPath = join(projectRoot, CURSOR_CANONICAL_IGNORE);
|
|
3241
|
+
await mkdirp(dirname(destPath));
|
|
3227
3242
|
await writeFileAtomic(destPath, patterns.join("\n") + "\n");
|
|
3228
3243
|
results.push({
|
|
3229
3244
|
fromTool: "cursor",
|
|
3230
|
-
fromPath:
|
|
3245
|
+
fromPath: join(projectRoot, importedFrom[0]),
|
|
3231
3246
|
toPath: CURSOR_CANONICAL_IGNORE,
|
|
3232
3247
|
feature: "ignore"
|
|
3233
3248
|
});
|
|
3234
3249
|
}
|
|
3235
3250
|
|
|
3236
|
-
// src/targets/cursor/skills-adapter.ts
|
|
3237
|
-
import { join as join16, basename as basename10 } from "path";
|
|
3238
|
-
|
|
3239
|
-
// src/targets/import/shared/skill-import-pipeline.ts
|
|
3240
|
-
import { join as join15, basename as basename9, dirname as dirname10, relative as relative5 } from "path";
|
|
3241
|
-
|
|
3242
3251
|
// src/targets/import/shared/reserved.ts
|
|
3243
3252
|
var RESERVED_SKILL_PATTERNS = [
|
|
3244
3253
|
/^\./,
|
|
@@ -3261,8 +3270,8 @@ async function readNativeSkill(skillDir) {
|
|
|
3261
3270
|
const allFiles = await readDirRecursive(skillDir).catch(() => []);
|
|
3262
3271
|
const entries = [];
|
|
3263
3272
|
for (const absPath of allFiles) {
|
|
3264
|
-
const relPath =
|
|
3265
|
-
const filename =
|
|
3273
|
+
const relPath = relative(skillDir, absPath).replace(/\\/g, "/");
|
|
3274
|
+
const filename = basename(relPath);
|
|
3266
3275
|
if (isReservedArtifactName(filename)) {
|
|
3267
3276
|
continue;
|
|
3268
3277
|
}
|
|
@@ -3278,10 +3287,10 @@ async function readNativeSkill(skillDir) {
|
|
|
3278
3287
|
}
|
|
3279
3288
|
async function importDirectorySkill(skillName, skillDir, options) {
|
|
3280
3289
|
const entries = await readNativeSkill(skillDir);
|
|
3281
|
-
const destSkillDir =
|
|
3290
|
+
const destSkillDir = join(options.projectRoot, options.destCanonicalSkillsDir, skillName);
|
|
3282
3291
|
for (const entry of entries) {
|
|
3283
|
-
const destPath =
|
|
3284
|
-
await mkdirp(
|
|
3292
|
+
const destPath = join(destSkillDir, entry.relativePath);
|
|
3293
|
+
await mkdirp(dirname(destPath));
|
|
3285
3294
|
const normalized = options.normalize(entry.content, entry.absolutePath, destPath);
|
|
3286
3295
|
if (entry.relativePath === "SKILL.md") {
|
|
3287
3296
|
const { frontmatter, body } = parseFrontmatter(normalized);
|
|
@@ -3303,9 +3312,9 @@ async function importDirectorySkill(skillName, skillDir, options) {
|
|
|
3303
3312
|
}
|
|
3304
3313
|
}
|
|
3305
3314
|
async function importFlatSkill(skillName, srcPath, content, options) {
|
|
3306
|
-
const destSkillDir =
|
|
3315
|
+
const destSkillDir = join(options.projectRoot, options.destCanonicalSkillsDir, skillName);
|
|
3307
3316
|
await mkdirp(destSkillDir);
|
|
3308
|
-
const destPath =
|
|
3317
|
+
const destPath = join(destSkillDir, "SKILL.md");
|
|
3309
3318
|
const normalized = options.normalize(content, srcPath, destPath);
|
|
3310
3319
|
const { frontmatter, body } = parseFrontmatter(normalized);
|
|
3311
3320
|
const outContent = await serializeImportedSkillWithFallback(
|
|
@@ -3325,10 +3334,10 @@ async function findDirectorySkills(skillsDir) {
|
|
|
3325
3334
|
const skills = /* @__PURE__ */ new Map();
|
|
3326
3335
|
try {
|
|
3327
3336
|
const allFiles = await readDirRecursive(skillsDir);
|
|
3328
|
-
const skillMdFiles = allFiles.filter((f) =>
|
|
3337
|
+
const skillMdFiles = allFiles.filter((f) => basename(f) === "SKILL.md");
|
|
3329
3338
|
for (const skillMdPath of skillMdFiles) {
|
|
3330
|
-
const skillDir =
|
|
3331
|
-
const skillName =
|
|
3339
|
+
const skillDir = dirname(skillMdPath);
|
|
3340
|
+
const skillName = basename(skillDir);
|
|
3332
3341
|
skills.set(skillName, skillDir);
|
|
3333
3342
|
}
|
|
3334
3343
|
} catch {
|
|
@@ -3338,7 +3347,7 @@ async function findDirectorySkills(skillsDir) {
|
|
|
3338
3347
|
|
|
3339
3348
|
// src/targets/cursor/skills-adapter.ts
|
|
3340
3349
|
async function importSkills(projectRoot, results, normalize, skillsRelDir = CURSOR_SKILLS_DIR) {
|
|
3341
|
-
const skillsDir =
|
|
3350
|
+
const skillsDir = join(projectRoot, skillsRelDir);
|
|
3342
3351
|
const directorySkills = await findDirectorySkills(skillsDir);
|
|
3343
3352
|
const options = {
|
|
3344
3353
|
projectRoot,
|
|
@@ -3362,42 +3371,39 @@ async function importSkills(projectRoot, results, normalize, skillsRelDir = CURS
|
|
|
3362
3371
|
if (handledPaths.has(srcPath)) continue;
|
|
3363
3372
|
const content = await readFileSafe(srcPath);
|
|
3364
3373
|
if (!content) continue;
|
|
3365
|
-
const name =
|
|
3374
|
+
const name = basename(srcPath, ".md");
|
|
3366
3375
|
await importFlatSkill(name, srcPath, content, options);
|
|
3367
3376
|
}
|
|
3368
3377
|
}
|
|
3369
|
-
|
|
3370
|
-
// src/targets/cursor/import-global-exports-helpers.ts
|
|
3371
|
-
import { join as join17, dirname as dirname11 } from "path";
|
|
3372
3378
|
var CURSOR_TARGET2 = "cursor";
|
|
3373
3379
|
async function hasGlobalCursorArtifacts(projectRoot) {
|
|
3374
|
-
if (await exists(
|
|
3380
|
+
if (await exists(join(projectRoot, CURSOR_RULES_DIR))) return true;
|
|
3375
3381
|
const candidates = [
|
|
3376
|
-
|
|
3377
|
-
|
|
3378
|
-
|
|
3379
|
-
|
|
3380
|
-
|
|
3381
|
-
|
|
3382
|
-
|
|
3383
|
-
|
|
3382
|
+
join(projectRoot, CURSOR_DOT_CURSOR_AGENTS),
|
|
3383
|
+
join(projectRoot, CURSOR_GLOBAL_USER_RULES),
|
|
3384
|
+
join(projectRoot, CURSOR_GLOBAL_MCP_EXPORT),
|
|
3385
|
+
join(projectRoot, CURSOR_HOOKS),
|
|
3386
|
+
join(projectRoot, CURSOR_IGNORE),
|
|
3387
|
+
join(projectRoot, CURSOR_GLOBAL_SKILLS_DIR),
|
|
3388
|
+
join(projectRoot, CURSOR_GLOBAL_AGENTS_DIR),
|
|
3389
|
+
join(projectRoot, CURSOR_COMMANDS_DIR)
|
|
3384
3390
|
];
|
|
3385
3391
|
for (const p of candidates) {
|
|
3386
3392
|
const stat3 = await readFileSafe(p);
|
|
3387
3393
|
if (stat3 !== null && stat3.trim() !== "") return true;
|
|
3388
3394
|
}
|
|
3389
|
-
const skillFiles = await readDirRecursive(
|
|
3395
|
+
const skillFiles = await readDirRecursive(join(projectRoot, CURSOR_GLOBAL_SKILLS_DIR));
|
|
3390
3396
|
if (skillFiles.some((f) => f.endsWith(".md"))) return true;
|
|
3391
|
-
const agentFiles = await readDirRecursive(
|
|
3397
|
+
const agentFiles = await readDirRecursive(join(projectRoot, CURSOR_GLOBAL_AGENTS_DIR));
|
|
3392
3398
|
if (agentFiles.some((f) => f.endsWith(".md"))) return true;
|
|
3393
|
-
const commandFiles = await readDirRecursive(
|
|
3399
|
+
const commandFiles = await readDirRecursive(join(projectRoot, CURSOR_COMMANDS_DIR));
|
|
3394
3400
|
if (commandFiles.some((f) => f.endsWith(".md"))) return true;
|
|
3395
3401
|
return false;
|
|
3396
3402
|
}
|
|
3397
3403
|
async function importGlobalCursorRulesFromDir(projectRoot, results, normalize) {
|
|
3398
|
-
const destDir =
|
|
3404
|
+
const destDir = join(projectRoot, CURSOR_CANONICAL_RULES_DIR);
|
|
3399
3405
|
let rootWritten = false;
|
|
3400
|
-
const rulesDir =
|
|
3406
|
+
const rulesDir = join(projectRoot, CURSOR_RULES_DIR);
|
|
3401
3407
|
const batch = await importFileDirectory({
|
|
3402
3408
|
srcDir: rulesDir,
|
|
3403
3409
|
destDir,
|
|
@@ -3421,7 +3427,7 @@ async function importGlobalCursorRulesFromDir(projectRoot, results, normalize) {
|
|
|
3421
3427
|
return rootWritten;
|
|
3422
3428
|
}
|
|
3423
3429
|
async function importGlobalUserRules(projectRoot, results, normalize) {
|
|
3424
|
-
const srcPath =
|
|
3430
|
+
const srcPath = join(projectRoot, CURSOR_GLOBAL_USER_RULES);
|
|
3425
3431
|
const raw = await readFileSafe(srcPath);
|
|
3426
3432
|
if (raw === null || raw.trim() === "") return false;
|
|
3427
3433
|
return importCursorRootFile({
|
|
@@ -3433,7 +3439,7 @@ async function importGlobalUserRules(projectRoot, results, normalize) {
|
|
|
3433
3439
|
});
|
|
3434
3440
|
}
|
|
3435
3441
|
async function importGlobalDotCursorAgents(projectRoot, results, normalize) {
|
|
3436
|
-
const srcPath =
|
|
3442
|
+
const srcPath = join(projectRoot, CURSOR_DOT_CURSOR_AGENTS);
|
|
3437
3443
|
const raw = await readFileSafe(srcPath);
|
|
3438
3444
|
if (raw === null || raw.trim() === "") return false;
|
|
3439
3445
|
return importCursorRootFile({
|
|
@@ -3445,7 +3451,7 @@ async function importGlobalDotCursorAgents(projectRoot, results, normalize) {
|
|
|
3445
3451
|
});
|
|
3446
3452
|
}
|
|
3447
3453
|
async function importGlobalMcp(projectRoot, results) {
|
|
3448
|
-
const mcpPath =
|
|
3454
|
+
const mcpPath = join(projectRoot, CURSOR_GLOBAL_MCP_EXPORT);
|
|
3449
3455
|
const content = await readFileSafe(mcpPath);
|
|
3450
3456
|
if (content === null || content.trim() === "") return;
|
|
3451
3457
|
let parsed;
|
|
@@ -3455,8 +3461,8 @@ async function importGlobalMcp(projectRoot, results) {
|
|
|
3455
3461
|
return;
|
|
3456
3462
|
}
|
|
3457
3463
|
if (!parsed || typeof parsed !== "object" || !("mcpServers" in parsed)) return;
|
|
3458
|
-
const destPath =
|
|
3459
|
-
await mkdirp(
|
|
3464
|
+
const destPath = join(projectRoot, CURSOR_CANONICAL_MCP);
|
|
3465
|
+
await mkdirp(dirname(destPath));
|
|
3460
3466
|
await writeFileAtomic(destPath, content);
|
|
3461
3467
|
results.push({
|
|
3462
3468
|
fromTool: CURSOR_TARGET2,
|
|
@@ -3466,8 +3472,8 @@ async function importGlobalMcp(projectRoot, results) {
|
|
|
3466
3472
|
});
|
|
3467
3473
|
}
|
|
3468
3474
|
async function importGlobalAgents(projectRoot, results, normalize) {
|
|
3469
|
-
const agentsDir =
|
|
3470
|
-
const destDir =
|
|
3475
|
+
const agentsDir = join(projectRoot, CURSOR_GLOBAL_AGENTS_DIR);
|
|
3476
|
+
const destDir = join(projectRoot, CURSOR_CANONICAL_AGENTS_DIR);
|
|
3471
3477
|
results.push(
|
|
3472
3478
|
...await importFileDirectory({
|
|
3473
3479
|
srcDir: agentsDir,
|
|
@@ -3480,8 +3486,8 @@ async function importGlobalAgents(projectRoot, results, normalize) {
|
|
|
3480
3486
|
);
|
|
3481
3487
|
}
|
|
3482
3488
|
async function importGlobalCommands(projectRoot, results, normalize) {
|
|
3483
|
-
const commandsDir =
|
|
3484
|
-
const destDir =
|
|
3489
|
+
const commandsDir = join(projectRoot, CURSOR_COMMANDS_DIR);
|
|
3490
|
+
const destDir = join(projectRoot, CURSOR_CANONICAL_COMMANDS_DIR);
|
|
3485
3491
|
results.push(
|
|
3486
3492
|
...await importFileDirectory({
|
|
3487
3493
|
srcDir: commandsDir,
|
|
@@ -3528,8 +3534,8 @@ async function importFromCursor(projectRoot, options = {}) {
|
|
|
3528
3534
|
return results;
|
|
3529
3535
|
}
|
|
3530
3536
|
async function importCommands2(projectRoot, results, normalize) {
|
|
3531
|
-
const destDir =
|
|
3532
|
-
const commandsDir =
|
|
3537
|
+
const destDir = join(projectRoot, CURSOR_CANONICAL_COMMANDS_DIR);
|
|
3538
|
+
const commandsDir = join(projectRoot, CURSOR_COMMANDS_DIR);
|
|
3533
3539
|
results.push(
|
|
3534
3540
|
...await importFileDirectory({
|
|
3535
3541
|
srcDir: commandsDir,
|
|
@@ -3542,8 +3548,8 @@ async function importCommands2(projectRoot, results, normalize) {
|
|
|
3542
3548
|
);
|
|
3543
3549
|
}
|
|
3544
3550
|
async function importAgents2(projectRoot, results, normalize) {
|
|
3545
|
-
const destDir =
|
|
3546
|
-
const agentsDir =
|
|
3551
|
+
const destDir = join(projectRoot, CURSOR_CANONICAL_AGENTS_DIR);
|
|
3552
|
+
const agentsDir = join(projectRoot, CURSOR_AGENTS_DIR);
|
|
3547
3553
|
results.push(
|
|
3548
3554
|
...await importFileDirectory({
|
|
3549
3555
|
srcDir: agentsDir,
|
|
@@ -3556,7 +3562,7 @@ async function importAgents2(projectRoot, results, normalize) {
|
|
|
3556
3562
|
);
|
|
3557
3563
|
}
|
|
3558
3564
|
async function importMcp(projectRoot, results) {
|
|
3559
|
-
const mcpPath =
|
|
3565
|
+
const mcpPath = join(projectRoot, CURSOR_MCP);
|
|
3560
3566
|
const content = await readFileSafe(mcpPath);
|
|
3561
3567
|
if (!content) return;
|
|
3562
3568
|
let parsed;
|
|
@@ -3566,8 +3572,8 @@ async function importMcp(projectRoot, results) {
|
|
|
3566
3572
|
return;
|
|
3567
3573
|
}
|
|
3568
3574
|
if (!parsed || typeof parsed !== "object" || !("mcpServers" in parsed)) return;
|
|
3569
|
-
const destPath =
|
|
3570
|
-
await mkdirp(
|
|
3575
|
+
const destPath = join(projectRoot, CURSOR_CANONICAL_MCP);
|
|
3576
|
+
await mkdirp(dirname(destPath));
|
|
3571
3577
|
await writeFileAtomic(destPath, content);
|
|
3572
3578
|
results.push({
|
|
3573
3579
|
fromTool: "cursor",
|
|
@@ -3800,9 +3806,6 @@ var descriptor2 = {
|
|
|
3800
3806
|
detectionPaths: [".cursor/rules", ".cursor/mcp.json"]
|
|
3801
3807
|
};
|
|
3802
3808
|
|
|
3803
|
-
// src/targets/copilot/generator.ts
|
|
3804
|
-
import { basename as basename12 } from "path";
|
|
3805
|
-
|
|
3806
3809
|
// src/targets/copilot/constants.ts
|
|
3807
3810
|
var COPILOT_TARGET = "copilot";
|
|
3808
3811
|
var COPILOT_INSTRUCTIONS = ".github/copilot-instructions.md";
|
|
@@ -3825,9 +3828,6 @@ var COPILOT_GLOBAL_PROMPTS_DIR = ".copilot/prompts";
|
|
|
3825
3828
|
var COPILOT_GLOBAL_AGENTS_MD = ".copilot/AGENTS.md";
|
|
3826
3829
|
var COPILOT_GLOBAL_CLAUDE_SKILLS_DIR = ".claude/skills";
|
|
3827
3830
|
var COPILOT_GLOBAL_AGENTS_SKILLS_DIR = ".agents/skills";
|
|
3828
|
-
|
|
3829
|
-
// src/targets/copilot/command-prompt.ts
|
|
3830
|
-
import { basename as basename11 } from "path";
|
|
3831
3831
|
function toStringArray6(value) {
|
|
3832
3832
|
if (Array.isArray(value)) {
|
|
3833
3833
|
return value.filter((entry) => typeof entry === "string" && entry.length > 0);
|
|
@@ -3856,7 +3856,7 @@ function serializeCommandPrompt(command) {
|
|
|
3856
3856
|
}
|
|
3857
3857
|
function parseCommandPromptFrontmatter(frontmatter, promptPath) {
|
|
3858
3858
|
const nameFromMetadata = typeof frontmatter["x-agentsmesh-name"] === "string" ? frontmatter["x-agentsmesh-name"] : "";
|
|
3859
|
-
const name = (nameFromMetadata ||
|
|
3859
|
+
const name = (nameFromMetadata || basename(promptPath, ".prompt.md")).trim();
|
|
3860
3860
|
const allowedToolsFromMetadata = toStringArray6(frontmatter["x-agentsmesh-allowed-tools"]);
|
|
3861
3861
|
const allowedTools = allowedToolsFromMetadata.length > 0 ? allowedToolsFromMetadata : toStringArray6(frontmatter.tools);
|
|
3862
3862
|
return {
|
|
@@ -3873,7 +3873,7 @@ function hasHookCommand2(entry) {
|
|
|
3873
3873
|
|
|
3874
3874
|
// src/targets/copilot/generator.ts
|
|
3875
3875
|
function ruleSlug(source) {
|
|
3876
|
-
const name =
|
|
3876
|
+
const name = basename(source, ".md");
|
|
3877
3877
|
return name === "_root" ? "root" : name;
|
|
3878
3878
|
}
|
|
3879
3879
|
function mapHookEvent(event) {
|
|
@@ -4008,13 +4008,6 @@ function generateHooks3(canonical) {
|
|
|
4008
4008
|
}
|
|
4009
4009
|
];
|
|
4010
4010
|
}
|
|
4011
|
-
|
|
4012
|
-
// src/targets/copilot/importer.ts
|
|
4013
|
-
import { join as join23 } from "path";
|
|
4014
|
-
|
|
4015
|
-
// src/targets/copilot/hook-parser.ts
|
|
4016
|
-
import { join as join19, dirname as dirname13, basename as basename13 } from "path";
|
|
4017
|
-
import { stringify as yamlStringify4 } from "yaml";
|
|
4018
4011
|
function mapCopilotHookEvent(event) {
|
|
4019
4012
|
switch (event) {
|
|
4020
4013
|
case "preToolUse":
|
|
@@ -4040,7 +4033,7 @@ function extractWrapperCommand(content) {
|
|
|
4040
4033
|
return content.replace(/^#!.*\n/, "").replace(/^#.*\n/gm, "").replace(/^HOOK_DIR=.*\n/gm, "").replace(/^set -e\n?/m, "").trim();
|
|
4041
4034
|
}
|
|
4042
4035
|
async function importHooks(projectRoot, results) {
|
|
4043
|
-
const hooksDir =
|
|
4036
|
+
const hooksDir = join(projectRoot, COPILOT_HOOKS_DIR);
|
|
4044
4037
|
const allFiles = await readDirRecursive(hooksDir).catch(() => []);
|
|
4045
4038
|
const jsonFiles = allFiles.filter((file) => file.endsWith(".json"));
|
|
4046
4039
|
const hooks = {};
|
|
@@ -4062,7 +4055,7 @@ async function importHooks(projectRoot, results) {
|
|
|
4062
4055
|
const entryRecord = entry;
|
|
4063
4056
|
const bashPath = typeof entryRecord.bash === "string" ? entryRecord.bash : "";
|
|
4064
4057
|
if (!bashPath) continue;
|
|
4065
|
-
const scriptPath =
|
|
4058
|
+
const scriptPath = join(hooksDir, bashPath.replace(/^\.\//, ""));
|
|
4066
4059
|
const scriptContent = await readFileSafe(scriptPath);
|
|
4067
4060
|
if (!scriptContent) continue;
|
|
4068
4061
|
const command = extractWrapperCommand(scriptContent);
|
|
@@ -4076,37 +4069,34 @@ async function importHooks(projectRoot, results) {
|
|
|
4076
4069
|
}
|
|
4077
4070
|
}
|
|
4078
4071
|
}
|
|
4079
|
-
const legacyDir =
|
|
4072
|
+
const legacyDir = join(projectRoot, COPILOT_LEGACY_HOOKS_DIR);
|
|
4080
4073
|
const legacyFiles = await readDirRecursive(legacyDir).catch(() => []);
|
|
4081
4074
|
const shFiles = legacyFiles.filter(
|
|
4082
|
-
(file) =>
|
|
4075
|
+
(file) => dirname(file) === legacyDir && /^[^-]+-\d+\.sh$/i.test(basename(file))
|
|
4083
4076
|
);
|
|
4084
4077
|
for (const srcPath of shFiles) {
|
|
4085
4078
|
const content = await readFileSafe(srcPath);
|
|
4086
4079
|
if (!content) continue;
|
|
4087
|
-
const name =
|
|
4080
|
+
const name = basename(srcPath, ".sh");
|
|
4088
4081
|
const dashIdx = name.lastIndexOf("-");
|
|
4089
4082
|
const phase = dashIdx > 0 ? name.slice(0, dashIdx) : name;
|
|
4090
4083
|
if (!hooks[phase]) hooks[phase] = [];
|
|
4091
4084
|
hooks[phase].push({ matcher: "*", command: extractWrapperCommand(content), type: "command" });
|
|
4092
4085
|
}
|
|
4093
4086
|
if (Object.keys(hooks).length === 0) return;
|
|
4094
|
-
const destPath =
|
|
4095
|
-
await mkdirp(
|
|
4096
|
-
await writeFileAtomic(destPath,
|
|
4087
|
+
const destPath = join(projectRoot, COPILOT_CANONICAL_HOOKS);
|
|
4088
|
+
await mkdirp(dirname(destPath));
|
|
4089
|
+
await writeFileAtomic(destPath, stringify(hooks));
|
|
4097
4090
|
results.push({
|
|
4098
4091
|
fromTool: COPILOT_TARGET,
|
|
4099
|
-
fromPath:
|
|
4092
|
+
fromPath: join(projectRoot, COPILOT_HOOKS_DIR),
|
|
4100
4093
|
toPath: COPILOT_CANONICAL_HOOKS,
|
|
4101
4094
|
feature: "hooks"
|
|
4102
4095
|
});
|
|
4103
4096
|
}
|
|
4104
|
-
|
|
4105
|
-
// src/targets/copilot/importer-commands.ts
|
|
4106
|
-
import { join as join20 } from "path";
|
|
4107
4097
|
async function importCopilotCommands(projectRoot, results, normalize, promptsDirRel = COPILOT_PROMPTS_DIR) {
|
|
4108
|
-
const promptsDir =
|
|
4109
|
-
const destDir =
|
|
4098
|
+
const promptsDir = join(projectRoot, promptsDirRel);
|
|
4099
|
+
const destDir = join(projectRoot, COPILOT_CANONICAL_COMMANDS_DIR);
|
|
4110
4100
|
results.push(
|
|
4111
4101
|
...await importFileDirectory({
|
|
4112
4102
|
srcDir: promptsDir,
|
|
@@ -4116,13 +4106,13 @@ async function importCopilotCommands(projectRoot, results, normalize, promptsDir
|
|
|
4116
4106
|
normalize,
|
|
4117
4107
|
mapEntry: async ({ srcPath, relativePath, content }) => {
|
|
4118
4108
|
const previewRelativePath = relativePath.replace(/\.prompt\.md$/i, ".md");
|
|
4119
|
-
const previewDest =
|
|
4109
|
+
const previewDest = join(destDir, previewRelativePath);
|
|
4120
4110
|
const { frontmatter, body } = parseFrontmatter(normalize(content, srcPath, previewDest));
|
|
4121
4111
|
const command = parseCommandPromptFrontmatter(frontmatter, srcPath);
|
|
4122
4112
|
const relDir = previewRelativePath.includes("/") ? previewRelativePath.slice(0, previewRelativePath.lastIndexOf("/")) : "";
|
|
4123
4113
|
const fileName = `${command.name}.md`;
|
|
4124
4114
|
const relativeCommandPath = relDir ? `${relDir}/${fileName}` : fileName;
|
|
4125
|
-
const destPath =
|
|
4115
|
+
const destPath = join(destDir, relativeCommandPath);
|
|
4126
4116
|
return {
|
|
4127
4117
|
destPath,
|
|
4128
4118
|
toPath: `${COPILOT_CANONICAL_COMMANDS_DIR}/${relativeCommandPath}`,
|
|
@@ -4142,11 +4132,8 @@ async function importCopilotCommands(projectRoot, results, normalize, promptsDir
|
|
|
4142
4132
|
})
|
|
4143
4133
|
);
|
|
4144
4134
|
}
|
|
4145
|
-
|
|
4146
|
-
// src/targets/copilot/importer-agents.ts
|
|
4147
|
-
import { join as join21, basename as basename14, dirname as dirname14, relative as relative6 } from "path";
|
|
4148
4135
|
async function importAgents3(projectRoot, results, normalize, agentsDirRel = COPILOT_AGENTS_DIR) {
|
|
4149
|
-
const agentsDir =
|
|
4136
|
+
const agentsDir = join(projectRoot, agentsDirRel);
|
|
4150
4137
|
let files;
|
|
4151
4138
|
try {
|
|
4152
4139
|
files = await readDirRecursive(agentsDir);
|
|
@@ -4154,15 +4141,15 @@ async function importAgents3(projectRoot, results, normalize, agentsDirRel = COP
|
|
|
4154
4141
|
return;
|
|
4155
4142
|
}
|
|
4156
4143
|
const agentFiles = files.filter((f) => f.endsWith(".agent.md"));
|
|
4157
|
-
const destDir =
|
|
4144
|
+
const destDir = join(projectRoot, COPILOT_CANONICAL_AGENTS_DIR);
|
|
4158
4145
|
for (const srcPath of agentFiles) {
|
|
4159
4146
|
const content = await readFileSafe(srcPath);
|
|
4160
4147
|
if (!content) continue;
|
|
4161
|
-
const relativePath =
|
|
4148
|
+
const relativePath = relative(agentsDir, srcPath).replace(/\\/g, "/");
|
|
4162
4149
|
const relativeMdPath = relativePath.replace(/\.agent\.md$/i, ".md");
|
|
4163
|
-
const base =
|
|
4164
|
-
const destPath =
|
|
4165
|
-
await mkdirp(
|
|
4150
|
+
const base = basename(relativeMdPath, ".md");
|
|
4151
|
+
const destPath = join(destDir, relativeMdPath);
|
|
4152
|
+
await mkdirp(dirname(destPath));
|
|
4166
4153
|
const { frontmatter, body } = parseFrontmatter(normalize(content, srcPath, destPath));
|
|
4167
4154
|
const outContent = await serializeImportedAgentWithFallback(
|
|
4168
4155
|
destPath,
|
|
@@ -4181,11 +4168,8 @@ async function importAgents3(projectRoot, results, normalize, agentsDirRel = COP
|
|
|
4181
4168
|
});
|
|
4182
4169
|
}
|
|
4183
4170
|
}
|
|
4184
|
-
|
|
4185
|
-
// src/targets/copilot/skills-adapter.ts
|
|
4186
|
-
import { join as join22 } from "path";
|
|
4187
4171
|
async function importSkills2(projectRoot, results, normalize, skillsDirRel = COPILOT_SKILLS_DIR) {
|
|
4188
|
-
const skillsDir =
|
|
4172
|
+
const skillsDir = join(projectRoot, skillsDirRel);
|
|
4189
4173
|
const directorySkills = await findDirectorySkills(skillsDir);
|
|
4190
4174
|
const options = {
|
|
4191
4175
|
projectRoot,
|
|
@@ -4205,13 +4189,13 @@ async function importFromCopilot(projectRoot, options = {}) {
|
|
|
4205
4189
|
const scope = options.scope ?? "project";
|
|
4206
4190
|
const results = [];
|
|
4207
4191
|
const normalize = await createImportReferenceNormalizer(COPILOT_TARGET, projectRoot, scope);
|
|
4208
|
-
const destDir =
|
|
4192
|
+
const destDir = join(projectRoot, COPILOT_CANONICAL_RULES_DIR);
|
|
4209
4193
|
const instructionsRel = scope === "global" ? COPILOT_GLOBAL_INSTRUCTIONS : COPILOT_INSTRUCTIONS;
|
|
4210
|
-
const instructionsPath =
|
|
4194
|
+
const instructionsPath = join(projectRoot, instructionsRel);
|
|
4211
4195
|
const instructionsContent = await readFileSafe(instructionsPath);
|
|
4212
4196
|
if (instructionsContent !== null) {
|
|
4213
4197
|
await mkdirp(destDir);
|
|
4214
|
-
const destPath =
|
|
4198
|
+
const destPath = join(destDir, "_root.md");
|
|
4215
4199
|
const { frontmatter, body } = parseFrontmatter(
|
|
4216
4200
|
normalize(instructionsContent, instructionsPath, destPath)
|
|
4217
4201
|
);
|
|
@@ -4227,7 +4211,7 @@ async function importFromCopilot(projectRoot, options = {}) {
|
|
|
4227
4211
|
});
|
|
4228
4212
|
}
|
|
4229
4213
|
if (scope === "project") {
|
|
4230
|
-
const copilotDir =
|
|
4214
|
+
const copilotDir = join(projectRoot, COPILOT_CONTEXT_DIR);
|
|
4231
4215
|
results.push(
|
|
4232
4216
|
...await importFileDirectory({
|
|
4233
4217
|
srcDir: copilotDir,
|
|
@@ -4237,7 +4221,7 @@ async function importFromCopilot(projectRoot, options = {}) {
|
|
|
4237
4221
|
normalize,
|
|
4238
4222
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
4239
4223
|
const destFileName = relativePath.replace(/\.instructions\.md$/i, ".md");
|
|
4240
|
-
const destPath =
|
|
4224
|
+
const destPath = join(destDir, destFileName);
|
|
4241
4225
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
4242
4226
|
const globs = toGlobsArray(frontmatter.globs);
|
|
4243
4227
|
const canonicalFm = {
|
|
@@ -4257,7 +4241,7 @@ async function importFromCopilot(projectRoot, options = {}) {
|
|
|
4257
4241
|
}
|
|
4258
4242
|
})
|
|
4259
4243
|
);
|
|
4260
|
-
const newInstDir =
|
|
4244
|
+
const newInstDir = join(projectRoot, COPILOT_INSTRUCTIONS_DIR);
|
|
4261
4245
|
results.push(
|
|
4262
4246
|
...await importFileDirectory({
|
|
4263
4247
|
srcDir: newInstDir,
|
|
@@ -4267,7 +4251,7 @@ async function importFromCopilot(projectRoot, options = {}) {
|
|
|
4267
4251
|
normalize,
|
|
4268
4252
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
4269
4253
|
const relativeMdPath = relativePath.endsWith(".instructions.md") ? relativePath.replace(/\.instructions\.md$/i, ".md") : relativePath;
|
|
4270
|
-
const destPath =
|
|
4254
|
+
const destPath = join(destDir, relativeMdPath);
|
|
4271
4255
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
4272
4256
|
const globs = toGlobsArray(
|
|
4273
4257
|
frontmatter.applyTo !== void 0 ? frontmatter.applyTo : frontmatter.globs
|
|
@@ -4350,15 +4334,12 @@ function lintHooks(canonical) {
|
|
|
4350
4334
|
})
|
|
4351
4335
|
);
|
|
4352
4336
|
}
|
|
4353
|
-
|
|
4354
|
-
// src/targets/copilot/hook-assets.ts
|
|
4355
|
-
import { join as join24, relative as relative7 } from "path";
|
|
4356
4337
|
var SCRIPT_PREFIX_RE = /^(?<prefix>\s*(?:(?:bash|sh|zsh)\s+)?)["']?(?<path>(?:\.\.\/|\.\/|[^/\s"'`]+\/)[^\s"'`]+)["']?(?<suffix>(?:\s.*)?)$/;
|
|
4357
4338
|
function safePhaseName(phase) {
|
|
4358
4339
|
return phase.replace(/[^a-zA-Z0-9]/g, "-").toLowerCase();
|
|
4359
4340
|
}
|
|
4360
4341
|
function toRepoRelative(projectRoot, sourcePath) {
|
|
4361
|
-
const repoRelative =
|
|
4342
|
+
const repoRelative = relative(projectRoot, sourcePath).replace(/\\/g, "/");
|
|
4362
4343
|
if (!repoRelative || repoRelative.startsWith("../")) return null;
|
|
4363
4344
|
return repoRelative;
|
|
4364
4345
|
}
|
|
@@ -4373,7 +4354,7 @@ async function buildAssetOutput(projectRoot, command) {
|
|
|
4373
4354
|
const match = command.match(SCRIPT_PREFIX_RE);
|
|
4374
4355
|
const sourceToken = match?.groups?.["path"];
|
|
4375
4356
|
if (!sourceToken) return null;
|
|
4376
|
-
const sourcePath =
|
|
4357
|
+
const sourcePath = join(projectRoot, sourceToken);
|
|
4377
4358
|
const assetContent = await readFileSafe(sourcePath);
|
|
4378
4359
|
if (assetContent === null) return null;
|
|
4379
4360
|
const repoRelative = toRepoRelative(projectRoot, sourcePath);
|
|
@@ -4425,9 +4406,6 @@ async function addHookScriptAssets(projectRoot, canonical, outputs) {
|
|
|
4425
4406
|
}
|
|
4426
4407
|
return [...outputs, ...wrapperOutputs, ...assetOutputs.values()];
|
|
4427
4408
|
}
|
|
4428
|
-
|
|
4429
|
-
// src/targets/copilot/scope-extras.ts
|
|
4430
|
-
import { join as join25 } from "path";
|
|
4431
4409
|
function computeStatus2(existing, content) {
|
|
4432
4410
|
if (existing === null) return "created";
|
|
4433
4411
|
if (existing !== content) return "updated";
|
|
@@ -4438,7 +4416,7 @@ var generateCopilotGlobalExtras = async (canonical, projectRoot, scope, enabledF
|
|
|
4438
4416
|
const root = canonical.rules.find((r) => r.root);
|
|
4439
4417
|
if (!root) return [];
|
|
4440
4418
|
const content = root.body.trim();
|
|
4441
|
-
const existing = await readFileSafe(
|
|
4419
|
+
const existing = await readFileSafe(join(projectRoot, COPILOT_GLOBAL_AGENTS_MD));
|
|
4442
4420
|
return [
|
|
4443
4421
|
{
|
|
4444
4422
|
target: "copilot",
|
|
@@ -4603,10 +4581,6 @@ var descriptor3 = {
|
|
|
4603
4581
|
".github/hooks"
|
|
4604
4582
|
]
|
|
4605
4583
|
};
|
|
4606
|
-
|
|
4607
|
-
// src/targets/import/embedded-skill.ts
|
|
4608
|
-
import { readdir as readdir2 } from "fs/promises";
|
|
4609
|
-
import { dirname as dirname15, join as join26, relative as relative8 } from "path";
|
|
4610
4584
|
var AB_SKILLS2 = ".agentsmesh/skills";
|
|
4611
4585
|
function generateEmbeddedSkills(canonical, skillsDir) {
|
|
4612
4586
|
const outputs = [];
|
|
@@ -4631,19 +4605,19 @@ function generateEmbeddedSkills(canonical, skillsDir) {
|
|
|
4631
4605
|
return outputs;
|
|
4632
4606
|
}
|
|
4633
4607
|
async function importEmbeddedSkills(projectRoot, skillsDir, fromTool, results, normalize) {
|
|
4634
|
-
const entries = await
|
|
4608
|
+
const entries = await readdir(join(projectRoot, skillsDir), {
|
|
4635
4609
|
encoding: "utf8",
|
|
4636
4610
|
withFileTypes: true
|
|
4637
4611
|
}).catch(() => null);
|
|
4638
4612
|
if (entries === null) return;
|
|
4639
4613
|
for (const entry of entries) {
|
|
4640
4614
|
if (!entry.isDirectory()) continue;
|
|
4641
|
-
const sourceSkillDir =
|
|
4642
|
-
const sourceSkillFile =
|
|
4615
|
+
const sourceSkillDir = join(projectRoot, skillsDir, entry.name);
|
|
4616
|
+
const sourceSkillFile = join(sourceSkillDir, "SKILL.md");
|
|
4643
4617
|
const sourceSkillContent = await readFileSafe(sourceSkillFile);
|
|
4644
4618
|
if (sourceSkillContent === null) continue;
|
|
4645
|
-
const destinationSkillDir =
|
|
4646
|
-
const destinationSkillFile =
|
|
4619
|
+
const destinationSkillDir = join(projectRoot, AB_SKILLS2, entry.name);
|
|
4620
|
+
const destinationSkillFile = join(destinationSkillDir, "SKILL.md");
|
|
4647
4621
|
const { frontmatter, body } = parseFrontmatter(
|
|
4648
4622
|
normalize(sourceSkillContent, sourceSkillFile, destinationSkillFile)
|
|
4649
4623
|
);
|
|
@@ -4663,11 +4637,11 @@ async function importEmbeddedSkills(projectRoot, skillsDir, fromTool, results, n
|
|
|
4663
4637
|
const sourceFiles = await readDirRecursive(sourceSkillDir);
|
|
4664
4638
|
for (const sourcePath of sourceFiles) {
|
|
4665
4639
|
if (sourcePath === sourceSkillFile) continue;
|
|
4666
|
-
const relativePath =
|
|
4640
|
+
const relativePath = relative(sourceSkillDir, sourcePath).replace(/\\/g, "/");
|
|
4667
4641
|
const sourceContent = await readFileSafe(sourcePath);
|
|
4668
4642
|
if (sourceContent === null) continue;
|
|
4669
|
-
const destinationPath =
|
|
4670
|
-
await mkdirp(
|
|
4643
|
+
const destinationPath = join(destinationSkillDir, relativePath);
|
|
4644
|
+
await mkdirp(dirname(destinationPath));
|
|
4671
4645
|
await writeFileAtomic(destinationPath, normalize(sourceContent, sourcePath, destinationPath));
|
|
4672
4646
|
results.push({
|
|
4673
4647
|
fromTool,
|
|
@@ -4678,9 +4652,6 @@ async function importEmbeddedSkills(projectRoot, skillsDir, fromTool, results, n
|
|
|
4678
4652
|
}
|
|
4679
4653
|
}
|
|
4680
4654
|
}
|
|
4681
|
-
|
|
4682
|
-
// src/targets/continue/command-rule.ts
|
|
4683
|
-
import { basename as basename15 } from "path";
|
|
4684
4655
|
function toStringArray7(value) {
|
|
4685
4656
|
if (Array.isArray(value)) {
|
|
4686
4657
|
return value.filter((entry) => typeof entry === "string" && entry.length > 0);
|
|
@@ -4707,7 +4678,7 @@ function serializeCommandRule(command) {
|
|
|
4707
4678
|
return serializeFrontmatter(frontmatter, command.body.trim() || "");
|
|
4708
4679
|
}
|
|
4709
4680
|
function parseCommandRuleFrontmatter(frontmatter, filePath) {
|
|
4710
|
-
const fileName =
|
|
4681
|
+
const fileName = basename(filePath, ".md");
|
|
4711
4682
|
const fromMetadata = typeof frontmatter["x-agentsmesh-name"] === "string" ? frontmatter["x-agentsmesh-name"] : "";
|
|
4712
4683
|
const name = (fromMetadata || fileName).trim();
|
|
4713
4684
|
return {
|
|
@@ -4770,15 +4741,11 @@ function generateMcp3(canonical) {
|
|
|
4770
4741
|
function generateSkills4(canonical) {
|
|
4771
4742
|
return generateEmbeddedSkills(canonical, CONTINUE_SKILLS_DIR);
|
|
4772
4743
|
}
|
|
4773
|
-
|
|
4774
|
-
// src/targets/continue/importer.ts
|
|
4775
|
-
import { basename as basename16, extname, join as join27, relative as relative9 } from "path";
|
|
4776
|
-
import { parse as parseYaml } from "yaml";
|
|
4777
4744
|
function isContinueRootRuleRelativePath(relativePath) {
|
|
4778
4745
|
return relativePath === "general.md" || relativePath === "_root.md";
|
|
4779
4746
|
}
|
|
4780
4747
|
function readMcpServers(content, extension) {
|
|
4781
|
-
const parsed = extension === ".json" ? JSON.parse(content) :
|
|
4748
|
+
const parsed = extension === ".json" ? JSON.parse(content) : parse(content) ?? {};
|
|
4782
4749
|
const rawServers = parsed.mcpServers;
|
|
4783
4750
|
if (rawServers && typeof rawServers === "object" && !Array.isArray(rawServers)) {
|
|
4784
4751
|
const servers = {};
|
|
@@ -4809,16 +4776,16 @@ async function importFromContinue(projectRoot) {
|
|
|
4809
4776
|
return results;
|
|
4810
4777
|
}
|
|
4811
4778
|
async function importRules2(projectRoot, results, normalize) {
|
|
4812
|
-
const files = (await readDirRecursive(
|
|
4779
|
+
const files = (await readDirRecursive(join(projectRoot, CONTINUE_RULES_DIR))).filter(
|
|
4813
4780
|
(file) => file.endsWith(".md")
|
|
4814
4781
|
);
|
|
4815
|
-
const rulesRoot =
|
|
4782
|
+
const rulesRoot = join(projectRoot, CONTINUE_RULES_DIR);
|
|
4816
4783
|
for (const srcPath of files) {
|
|
4817
4784
|
const source = await readFileSafe(srcPath);
|
|
4818
4785
|
if (!source) continue;
|
|
4819
|
-
const relativePath =
|
|
4786
|
+
const relativePath = relative(rulesRoot, srcPath).replace(/\\/g, "/");
|
|
4820
4787
|
const canonicalRelative = isContinueRootRuleRelativePath(relativePath) ? "_root.md" : relativePath;
|
|
4821
|
-
const destPath =
|
|
4788
|
+
const destPath = join(projectRoot, CONTINUE_CANONICAL_RULES_DIR, canonicalRelative);
|
|
4822
4789
|
const { frontmatter, body } = parseFrontmatter(normalize(source, srcPath, destPath));
|
|
4823
4790
|
const canonicalFrontmatter = {
|
|
4824
4791
|
description: typeof frontmatter.description === "string" ? frontmatter.description : void 0,
|
|
@@ -4838,21 +4805,21 @@ async function importRules2(projectRoot, results, normalize) {
|
|
|
4838
4805
|
}
|
|
4839
4806
|
}
|
|
4840
4807
|
async function importCommands3(projectRoot, results, normalize) {
|
|
4841
|
-
const files = (await readDirRecursive(
|
|
4808
|
+
const files = (await readDirRecursive(join(projectRoot, CONTINUE_PROMPTS_DIR))).filter(
|
|
4842
4809
|
(file) => file.endsWith(".md")
|
|
4843
4810
|
);
|
|
4844
|
-
const promptsRoot =
|
|
4811
|
+
const promptsRoot = join(projectRoot, CONTINUE_PROMPTS_DIR);
|
|
4845
4812
|
for (const srcPath of files) {
|
|
4846
4813
|
const source = await readFileSafe(srcPath);
|
|
4847
4814
|
if (!source) continue;
|
|
4848
|
-
const relativePath =
|
|
4849
|
-
const destPath =
|
|
4815
|
+
const relativePath = relative(promptsRoot, srcPath).replace(/\\/g, "/");
|
|
4816
|
+
const destPath = join(projectRoot, CONTINUE_CANONICAL_COMMANDS_DIR, relativePath);
|
|
4850
4817
|
const { frontmatter, body } = parseFrontmatter(normalize(source, srcPath, destPath));
|
|
4851
4818
|
const command = parseCommandRuleFrontmatter(frontmatter, srcPath);
|
|
4852
|
-
const commandName = command.name ||
|
|
4819
|
+
const commandName = command.name || basename(relativePath, ".md");
|
|
4853
4820
|
const relativeDir = relativePath.includes("/") ? relativePath.slice(0, relativePath.lastIndexOf("/")) : "";
|
|
4854
4821
|
const relativeCommandPath = relativeDir ? `${relativeDir}/${commandName}.md` : `${commandName}.md`;
|
|
4855
|
-
const commandPath =
|
|
4822
|
+
const commandPath = join(projectRoot, CONTINUE_CANONICAL_COMMANDS_DIR, relativeCommandPath);
|
|
4856
4823
|
const content = await serializeImportedCommandWithFallback(
|
|
4857
4824
|
commandPath,
|
|
4858
4825
|
{
|
|
@@ -4873,7 +4840,7 @@ async function importCommands3(projectRoot, results, normalize) {
|
|
|
4873
4840
|
}
|
|
4874
4841
|
}
|
|
4875
4842
|
async function importMcp2(projectRoot, results) {
|
|
4876
|
-
const files = (await readDirRecursive(
|
|
4843
|
+
const files = (await readDirRecursive(join(projectRoot, CONTINUE_MCP_DIR))).filter(
|
|
4877
4844
|
(file) => [".json", ".yaml", ".yml"].includes(extname(file))
|
|
4878
4845
|
);
|
|
4879
4846
|
const mergedServers = {};
|
|
@@ -4885,7 +4852,7 @@ async function importMcp2(projectRoot, results) {
|
|
|
4885
4852
|
importedFrom.push(srcPath);
|
|
4886
4853
|
}
|
|
4887
4854
|
if (Object.keys(mergedServers).length === 0) return;
|
|
4888
|
-
const destPath =
|
|
4855
|
+
const destPath = join(projectRoot, CONTINUE_CANONICAL_MCP);
|
|
4889
4856
|
await writeFileAtomic(destPath, JSON.stringify({ mcpServers: mergedServers }, null, 2));
|
|
4890
4857
|
for (const fromPath of importedFrom) {
|
|
4891
4858
|
results.push({
|
|
@@ -4917,13 +4884,6 @@ function lintCommands3(canonical) {
|
|
|
4917
4884
|
)
|
|
4918
4885
|
);
|
|
4919
4886
|
}
|
|
4920
|
-
|
|
4921
|
-
// src/targets/continue/scope-extras.ts
|
|
4922
|
-
import { join as join29 } from "path";
|
|
4923
|
-
|
|
4924
|
-
// src/targets/continue/global-config.ts
|
|
4925
|
-
import { join as join28, basename as basename17 } from "path";
|
|
4926
|
-
import { stringify as yamlStringify5 } from "yaml";
|
|
4927
4887
|
function computeStatus3(existing, content) {
|
|
4928
4888
|
if (existing === null) return "created";
|
|
4929
4889
|
if (existing !== content) return "updated";
|
|
@@ -4943,7 +4903,7 @@ var generateContinueGlobalConfig = async (canonical, projectRoot, scope, enabled
|
|
|
4943
4903
|
};
|
|
4944
4904
|
if (hasRules && canonical.rules.length > 0) {
|
|
4945
4905
|
config.rules = canonical.rules.map((rule) => ({
|
|
4946
|
-
name: rule.description ||
|
|
4906
|
+
name: rule.description || basename(rule.source, ".md"),
|
|
4947
4907
|
rule: rule.body.trim()
|
|
4948
4908
|
}));
|
|
4949
4909
|
}
|
|
@@ -4961,8 +4921,8 @@ var generateContinueGlobalConfig = async (canonical, projectRoot, scope, enabled
|
|
|
4961
4921
|
config.mcpServers = servers.map(([name, server]) => ({ name, ...server }));
|
|
4962
4922
|
}
|
|
4963
4923
|
}
|
|
4964
|
-
const content =
|
|
4965
|
-
const existing = await readFileSafe(
|
|
4924
|
+
const content = stringify(config);
|
|
4925
|
+
const existing = await readFileSafe(join(projectRoot, CONTINUE_GLOBAL_CONFIG));
|
|
4966
4926
|
return [
|
|
4967
4927
|
{
|
|
4968
4928
|
target: "continue",
|
|
@@ -4991,7 +4951,7 @@ var generateContinueScopeExtras = async (canonical, projectRoot, scope, enabledF
|
|
|
4991
4951
|
const root = canonical.rules.find((r) => r.root);
|
|
4992
4952
|
if (!root) return configResults;
|
|
4993
4953
|
const content = root.body.trim();
|
|
4994
|
-
const existing = await readFileSafe(
|
|
4954
|
+
const existing = await readFileSafe(join(projectRoot, CONTINUE_GLOBAL_AGENTS_MD));
|
|
4995
4955
|
return [
|
|
4996
4956
|
...configResults,
|
|
4997
4957
|
{
|
|
@@ -5109,9 +5069,6 @@ var descriptor4 = {
|
|
|
5109
5069
|
detectionPaths: [".continue/rules", ".continue/skills", ".continue/mcpServers"]
|
|
5110
5070
|
};
|
|
5111
5071
|
|
|
5112
|
-
// src/targets/junie/generator.ts
|
|
5113
|
-
import { basename as basename18 } from "path";
|
|
5114
|
-
|
|
5115
5072
|
// src/core/mcp-servers.ts
|
|
5116
5073
|
function isStdioMcpServer(server) {
|
|
5117
5074
|
return "command" in server;
|
|
@@ -5133,7 +5090,7 @@ function generateRules5(canonical) {
|
|
|
5133
5090
|
for (const rule of canonical.rules) {
|
|
5134
5091
|
if (rule.root) continue;
|
|
5135
5092
|
if (rule.targets.length > 0 && !rule.targets.includes("junie")) continue;
|
|
5136
|
-
const slug =
|
|
5093
|
+
const slug = basename(rule.source, ".md");
|
|
5137
5094
|
outputs.push({
|
|
5138
5095
|
path: `${JUNIE_RULES_DIR}/${slug}.md`,
|
|
5139
5096
|
content: rule.body.trim() || ""
|
|
@@ -5208,12 +5165,6 @@ function renderJunieGlobalInstructions(canonical) {
|
|
|
5208
5165
|
});
|
|
5209
5166
|
return appendEmbeddedRulesBlock(root?.body.trim() ?? "", nonRootRules);
|
|
5210
5167
|
}
|
|
5211
|
-
|
|
5212
|
-
// src/targets/junie/importer.ts
|
|
5213
|
-
import { join as join31 } from "path";
|
|
5214
|
-
|
|
5215
|
-
// src/targets/junie/importer-commands-agents-mcp-ignore.ts
|
|
5216
|
-
import { join as join30 } from "path";
|
|
5217
5168
|
function readMcpServers2(content) {
|
|
5218
5169
|
const parsed = JSON.parse(content);
|
|
5219
5170
|
const rawServers = parsed.mcpServers;
|
|
@@ -5245,13 +5196,13 @@ function readMcpServers2(content) {
|
|
|
5245
5196
|
return servers;
|
|
5246
5197
|
}
|
|
5247
5198
|
async function importJunieMcp(projectRoot, results) {
|
|
5248
|
-
const srcPath =
|
|
5199
|
+
const srcPath = join(projectRoot, JUNIE_MCP_FILE);
|
|
5249
5200
|
const content = await readFileSafe(srcPath);
|
|
5250
5201
|
if (content === null) return;
|
|
5251
5202
|
const servers = readMcpServers2(content);
|
|
5252
5203
|
if (Object.keys(servers).length === 0) return;
|
|
5253
5204
|
await writeFileAtomic(
|
|
5254
|
-
|
|
5205
|
+
join(projectRoot, JUNIE_CANONICAL_MCP),
|
|
5255
5206
|
JSON.stringify({ mcpServers: servers }, null, 2)
|
|
5256
5207
|
);
|
|
5257
5208
|
results.push({
|
|
@@ -5262,8 +5213,8 @@ async function importJunieMcp(projectRoot, results) {
|
|
|
5262
5213
|
});
|
|
5263
5214
|
}
|
|
5264
5215
|
async function importJunieCommands(projectRoot, results, normalize) {
|
|
5265
|
-
const srcDir =
|
|
5266
|
-
const destDir =
|
|
5216
|
+
const srcDir = join(projectRoot, JUNIE_COMMANDS_DIR);
|
|
5217
|
+
const destDir = join(projectRoot, JUNIE_CANONICAL_COMMANDS_DIR);
|
|
5267
5218
|
results.push(
|
|
5268
5219
|
...await importFileDirectory({
|
|
5269
5220
|
srcDir,
|
|
@@ -5272,7 +5223,7 @@ async function importJunieCommands(projectRoot, results, normalize) {
|
|
|
5272
5223
|
fromTool: "junie",
|
|
5273
5224
|
normalize,
|
|
5274
5225
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
5275
|
-
const destPath =
|
|
5226
|
+
const destPath = join(destDir, relativePath);
|
|
5276
5227
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
5277
5228
|
const normalized = await serializeImportedCommandWithFallback(
|
|
5278
5229
|
destPath,
|
|
@@ -5295,8 +5246,8 @@ async function importJunieCommands(projectRoot, results, normalize) {
|
|
|
5295
5246
|
);
|
|
5296
5247
|
}
|
|
5297
5248
|
async function importJunieAgents(projectRoot, results, normalize) {
|
|
5298
|
-
const srcDir =
|
|
5299
|
-
const destDir =
|
|
5249
|
+
const srcDir = join(projectRoot, JUNIE_AGENTS_DIR);
|
|
5250
|
+
const destDir = join(projectRoot, JUNIE_CANONICAL_AGENTS_DIR);
|
|
5300
5251
|
results.push(
|
|
5301
5252
|
...await importFileDirectory({
|
|
5302
5253
|
srcDir,
|
|
@@ -5305,7 +5256,7 @@ async function importJunieAgents(projectRoot, results, normalize) {
|
|
|
5305
5256
|
fromTool: "junie",
|
|
5306
5257
|
normalize,
|
|
5307
5258
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
5308
|
-
const destPath =
|
|
5259
|
+
const destPath = join(destDir, relativePath);
|
|
5309
5260
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
5310
5261
|
return {
|
|
5311
5262
|
destPath,
|
|
@@ -5318,10 +5269,10 @@ async function importJunieAgents(projectRoot, results, normalize) {
|
|
|
5318
5269
|
);
|
|
5319
5270
|
}
|
|
5320
5271
|
async function importJunieIgnore(projectRoot, results) {
|
|
5321
|
-
const srcPath =
|
|
5272
|
+
const srcPath = join(projectRoot, JUNIE_IGNORE);
|
|
5322
5273
|
const content = await readFileSafe(srcPath);
|
|
5323
5274
|
if (content === null) return;
|
|
5324
|
-
await writeFileAtomic(
|
|
5275
|
+
await writeFileAtomic(join(projectRoot, JUNIE_CANONICAL_IGNORE), content.trimEnd());
|
|
5325
5276
|
results.push({
|
|
5326
5277
|
fromTool: JUNIE_TARGET,
|
|
5327
5278
|
fromPath: srcPath,
|
|
@@ -5333,9 +5284,9 @@ async function importJunieIgnore(projectRoot, results) {
|
|
|
5333
5284
|
// src/targets/junie/importer.ts
|
|
5334
5285
|
async function importRules3(projectRoot, results, normalize) {
|
|
5335
5286
|
const sources = [JUNIE_DOT_AGENTS, JUNIE_GUIDELINES, JUNIE_CI_GUIDELINES, JUNIE_AGENTS_FALLBACK];
|
|
5336
|
-
const destPath =
|
|
5287
|
+
const destPath = join(projectRoot, JUNIE_CANONICAL_ROOT_RULE);
|
|
5337
5288
|
for (const relPath of sources) {
|
|
5338
|
-
const srcPath =
|
|
5289
|
+
const srcPath = join(projectRoot, relPath);
|
|
5339
5290
|
const content = await readFileSafe(srcPath);
|
|
5340
5291
|
if (content === null) continue;
|
|
5341
5292
|
const split = await splitEmbeddedRulesToCanonical({
|
|
@@ -5368,8 +5319,8 @@ async function importRules3(projectRoot, results, normalize) {
|
|
|
5368
5319
|
}
|
|
5369
5320
|
}
|
|
5370
5321
|
async function importNonRootRules(projectRoot, results, normalize) {
|
|
5371
|
-
const srcDir =
|
|
5372
|
-
const destDir =
|
|
5322
|
+
const srcDir = join(projectRoot, JUNIE_RULES_DIR);
|
|
5323
|
+
const destDir = join(projectRoot, JUNIE_CANONICAL_RULES_DIR);
|
|
5373
5324
|
results.push(
|
|
5374
5325
|
...await importFileDirectory({
|
|
5375
5326
|
srcDir,
|
|
@@ -5378,7 +5329,7 @@ async function importNonRootRules(projectRoot, results, normalize) {
|
|
|
5378
5329
|
fromTool: "junie",
|
|
5379
5330
|
normalize,
|
|
5380
5331
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
5381
|
-
const destPath =
|
|
5332
|
+
const destPath = join(destDir, relativePath);
|
|
5382
5333
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
5383
5334
|
const output = await serializeImportedRuleWithFallback(
|
|
5384
5335
|
destPath,
|
|
@@ -5576,12 +5527,6 @@ var descriptor5 = {
|
|
|
5576
5527
|
".aiignore"
|
|
5577
5528
|
]
|
|
5578
5529
|
};
|
|
5579
|
-
|
|
5580
|
-
// src/targets/kiro/generator.ts
|
|
5581
|
-
import { basename as basename19 } from "path";
|
|
5582
|
-
|
|
5583
|
-
// src/targets/kiro/hook-format.ts
|
|
5584
|
-
import { stringify as yamlStringify6 } from "yaml";
|
|
5585
5530
|
var CANONICAL_TO_KIRO = {
|
|
5586
5531
|
UserPromptSubmit: "promptSubmit",
|
|
5587
5532
|
SubagentStop: "agentStop",
|
|
@@ -5667,7 +5612,7 @@ function parseKiroHookFile(content) {
|
|
|
5667
5612
|
return toCanonicalEntry(file);
|
|
5668
5613
|
}
|
|
5669
5614
|
function serializeCanonicalHooks(hooks) {
|
|
5670
|
-
return
|
|
5615
|
+
return stringify(hooks).trimEnd();
|
|
5671
5616
|
}
|
|
5672
5617
|
|
|
5673
5618
|
// src/targets/kiro/generator.ts
|
|
@@ -5695,7 +5640,7 @@ function generateRules6(canonical) {
|
|
|
5695
5640
|
for (const rule of canonical.rules) {
|
|
5696
5641
|
if (rule.root) continue;
|
|
5697
5642
|
if (rule.targets.length > 0 && !rule.targets.includes(KIRO_TARGET)) continue;
|
|
5698
|
-
const slug =
|
|
5643
|
+
const slug = basename(rule.source, ".md");
|
|
5699
5644
|
outputs.push({
|
|
5700
5645
|
path: `${KIRO_STEERING_DIR}/${slug}.md`,
|
|
5701
5646
|
content: serializeFrontmatter(steeringFrontmatter(rule), rule.body.trim() || "")
|
|
@@ -5741,12 +5686,6 @@ function generateIgnore4(canonical) {
|
|
|
5741
5686
|
if (canonical.ignore.length === 0) return [];
|
|
5742
5687
|
return [{ path: KIRO_IGNORE, content: canonical.ignore.join("\n") }];
|
|
5743
5688
|
}
|
|
5744
|
-
|
|
5745
|
-
// src/targets/kiro/importer.ts
|
|
5746
|
-
import { basename as basename20, join as join33 } from "path";
|
|
5747
|
-
|
|
5748
|
-
// src/targets/kiro/importer-agents-mcp-hooks-ignore.ts
|
|
5749
|
-
import { join as join32 } from "path";
|
|
5750
5689
|
function readMcpServers3(content) {
|
|
5751
5690
|
const parsed = JSON.parse(content);
|
|
5752
5691
|
const rawServers = parsed.mcpServers;
|
|
@@ -5776,8 +5715,8 @@ function readMcpServers3(content) {
|
|
|
5776
5715
|
return servers;
|
|
5777
5716
|
}
|
|
5778
5717
|
async function importKiroAgents(projectRoot, results, normalize) {
|
|
5779
|
-
const srcDir =
|
|
5780
|
-
const destDir =
|
|
5718
|
+
const srcDir = join(projectRoot, KIRO_AGENTS_DIR);
|
|
5719
|
+
const destDir = join(projectRoot, KIRO_CANONICAL_AGENTS_DIR);
|
|
5781
5720
|
results.push(
|
|
5782
5721
|
...await importFileDirectory({
|
|
5783
5722
|
srcDir,
|
|
@@ -5786,7 +5725,7 @@ async function importKiroAgents(projectRoot, results, normalize) {
|
|
|
5786
5725
|
fromTool: KIRO_TARGET,
|
|
5787
5726
|
normalize,
|
|
5788
5727
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
5789
|
-
const destPath =
|
|
5728
|
+
const destPath = join(destDir, relativePath);
|
|
5790
5729
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
5791
5730
|
return {
|
|
5792
5731
|
destPath,
|
|
@@ -5800,24 +5739,24 @@ async function importKiroAgents(projectRoot, results, normalize) {
|
|
|
5800
5739
|
}
|
|
5801
5740
|
async function importKiroMcp(projectRoot, results, scope) {
|
|
5802
5741
|
const mcpRel = scope === "global" ? KIRO_GLOBAL_MCP_FILE : KIRO_MCP_FILE;
|
|
5803
|
-
const content = await readFileSafe(
|
|
5742
|
+
const content = await readFileSafe(join(projectRoot, mcpRel));
|
|
5804
5743
|
if (content === null) return;
|
|
5805
5744
|
const servers = readMcpServers3(content);
|
|
5806
5745
|
if (Object.keys(servers).length === 0) return;
|
|
5807
5746
|
await writeFileAtomic(
|
|
5808
|
-
|
|
5747
|
+
join(projectRoot, KIRO_CANONICAL_MCP),
|
|
5809
5748
|
JSON.stringify({ mcpServers: servers }, null, 2)
|
|
5810
5749
|
);
|
|
5811
5750
|
results.push({
|
|
5812
5751
|
fromTool: KIRO_TARGET,
|
|
5813
|
-
fromPath:
|
|
5752
|
+
fromPath: join(projectRoot, mcpRel),
|
|
5814
5753
|
toPath: KIRO_CANONICAL_MCP,
|
|
5815
5754
|
feature: "mcp"
|
|
5816
5755
|
});
|
|
5817
5756
|
}
|
|
5818
5757
|
async function importKiroHooks(projectRoot, results) {
|
|
5819
5758
|
const hooks = {};
|
|
5820
|
-
for (const absPath of await readDirRecursive(
|
|
5759
|
+
for (const absPath of await readDirRecursive(join(projectRoot, KIRO_HOOKS_DIR))) {
|
|
5821
5760
|
if (!absPath.endsWith(".kiro.hook")) continue;
|
|
5822
5761
|
const parsed = parseKiroHookFile(await readFileSafe(absPath) ?? "");
|
|
5823
5762
|
if (!parsed) continue;
|
|
@@ -5825,22 +5764,22 @@ async function importKiroHooks(projectRoot, results) {
|
|
|
5825
5764
|
hooks[parsed.event].push(parsed.entry);
|
|
5826
5765
|
}
|
|
5827
5766
|
if (Object.keys(hooks).length === 0) return;
|
|
5828
|
-
await writeFileAtomic(
|
|
5767
|
+
await writeFileAtomic(join(projectRoot, KIRO_CANONICAL_HOOKS), serializeCanonicalHooks(hooks));
|
|
5829
5768
|
results.push({
|
|
5830
5769
|
fromTool: KIRO_TARGET,
|
|
5831
|
-
fromPath:
|
|
5770
|
+
fromPath: join(projectRoot, KIRO_HOOKS_DIR),
|
|
5832
5771
|
toPath: KIRO_CANONICAL_HOOKS,
|
|
5833
5772
|
feature: "hooks"
|
|
5834
5773
|
});
|
|
5835
5774
|
}
|
|
5836
5775
|
async function importKiroIgnore(projectRoot, results, scope) {
|
|
5837
5776
|
const ignoreRel = scope === "global" ? KIRO_GLOBAL_IGNORE : KIRO_IGNORE;
|
|
5838
|
-
const content = await readFileSafe(
|
|
5777
|
+
const content = await readFileSafe(join(projectRoot, ignoreRel));
|
|
5839
5778
|
if (content === null) return;
|
|
5840
|
-
await writeFileAtomic(
|
|
5779
|
+
await writeFileAtomic(join(projectRoot, KIRO_CANONICAL_IGNORE), content.trimEnd());
|
|
5841
5780
|
results.push({
|
|
5842
5781
|
fromTool: KIRO_TARGET,
|
|
5843
|
-
fromPath:
|
|
5782
|
+
fromPath: join(projectRoot, ignoreRel),
|
|
5844
5783
|
toPath: KIRO_CANONICAL_IGNORE,
|
|
5845
5784
|
feature: "ignore"
|
|
5846
5785
|
});
|
|
@@ -5862,10 +5801,10 @@ function canonicalRuleMeta(frontmatter) {
|
|
|
5862
5801
|
async function importRoot(projectRoot, results, normalize, scope) {
|
|
5863
5802
|
const candidates = scope === "global" ? [KIRO_GLOBAL_STEERING_AGENTS_MD, KIRO_AGENTS_MD] : [KIRO_AGENTS_MD, KIRO_GLOBAL_STEERING_AGENTS_MD];
|
|
5864
5803
|
for (const rel2 of candidates) {
|
|
5865
|
-
const srcPath =
|
|
5804
|
+
const srcPath = join(projectRoot, rel2);
|
|
5866
5805
|
const content = await readFileSafe(srcPath);
|
|
5867
5806
|
if (content === null) continue;
|
|
5868
|
-
const destPath =
|
|
5807
|
+
const destPath = join(projectRoot, KIRO_CANONICAL_ROOT_RULE);
|
|
5869
5808
|
const { frontmatter, body } = parseFrontmatter(normalize(content, srcPath, destPath));
|
|
5870
5809
|
await writeFileAtomic(
|
|
5871
5810
|
destPath,
|
|
@@ -5883,14 +5822,14 @@ async function importRoot(projectRoot, results, normalize, scope) {
|
|
|
5883
5822
|
async function importRules4(projectRoot, results, normalize) {
|
|
5884
5823
|
results.push(
|
|
5885
5824
|
...await importFileDirectory({
|
|
5886
|
-
srcDir:
|
|
5887
|
-
destDir:
|
|
5825
|
+
srcDir: join(projectRoot, KIRO_STEERING_DIR),
|
|
5826
|
+
destDir: join(projectRoot, KIRO_CANONICAL_RULES_DIR),
|
|
5888
5827
|
extensions: [".md"],
|
|
5889
5828
|
fromTool: KIRO_TARGET,
|
|
5890
5829
|
normalize,
|
|
5891
5830
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
5892
|
-
if (
|
|
5893
|
-
const destPath =
|
|
5831
|
+
if (basename(relativePath) === "AGENTS.md") return null;
|
|
5832
|
+
const destPath = join(projectRoot, KIRO_CANONICAL_RULES_DIR, relativePath);
|
|
5894
5833
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
5895
5834
|
return {
|
|
5896
5835
|
destPath,
|
|
@@ -6124,9 +6063,6 @@ function generateRules7(canonical) {
|
|
|
6124
6063
|
}
|
|
6125
6064
|
return outputs;
|
|
6126
6065
|
}
|
|
6127
|
-
|
|
6128
|
-
// src/targets/gemini-cli/command-namespace.ts
|
|
6129
|
-
import { relative as relative10 } from "path";
|
|
6130
6066
|
function canonicalCommandNameToGeminiTomlPath(cmdName, commandsDir) {
|
|
6131
6067
|
const parts = cmdName.split(":").filter(Boolean);
|
|
6132
6068
|
const fileBase = parts.length > 0 ? parts.pop() : cmdName;
|
|
@@ -6342,19 +6278,6 @@ function generateGeminiPermissionsPolicies(canonical) {
|
|
|
6342
6278
|
}
|
|
6343
6279
|
];
|
|
6344
6280
|
}
|
|
6345
|
-
|
|
6346
|
-
// src/targets/gemini-cli/importer.ts
|
|
6347
|
-
import { join as join39 } from "path";
|
|
6348
|
-
|
|
6349
|
-
// src/targets/gemini-cli/importer-mappers.ts
|
|
6350
|
-
import { join as join36 } from "path";
|
|
6351
|
-
import { parse as parseToml2 } from "smol-toml";
|
|
6352
|
-
|
|
6353
|
-
// src/targets/gemini-cli/format-helpers.ts
|
|
6354
|
-
import { join as join35 } from "path";
|
|
6355
|
-
|
|
6356
|
-
// src/targets/gemini-cli/format-helpers-shared.ts
|
|
6357
|
-
import { parse as parseToml } from "smol-toml";
|
|
6358
6281
|
function mapGeminiHookEvent(event) {
|
|
6359
6282
|
switch (event) {
|
|
6360
6283
|
case "BeforeTool":
|
|
@@ -6382,7 +6305,7 @@ function parseFlexibleFrontmatter(content) {
|
|
|
6382
6305
|
try {
|
|
6383
6306
|
const tomlStr = content.slice(3, tomlClose).trim();
|
|
6384
6307
|
const body = content.slice(tomlClose + 3).trim();
|
|
6385
|
-
const parsed = tomlStr === "" ? {} :
|
|
6308
|
+
const parsed = tomlStr === "" ? {} : parse$1(tomlStr) ?? {};
|
|
6386
6309
|
const frontmatter = parsed;
|
|
6387
6310
|
return { frontmatter, body };
|
|
6388
6311
|
} catch {
|
|
@@ -6392,12 +6315,8 @@ function parseFlexibleFrontmatter(content) {
|
|
|
6392
6315
|
}
|
|
6393
6316
|
return { frontmatter: {}, body: content.trim() };
|
|
6394
6317
|
}
|
|
6395
|
-
|
|
6396
|
-
// src/targets/gemini-cli/format-helpers-settings.ts
|
|
6397
|
-
import { join as join34 } from "path";
|
|
6398
|
-
import { stringify as stringifyYaml } from "yaml";
|
|
6399
6318
|
async function importGeminiSettings(projectRoot, results) {
|
|
6400
|
-
const settingsPath =
|
|
6319
|
+
const settingsPath = join(projectRoot, GEMINI_SETTINGS);
|
|
6401
6320
|
const settingsContent = await readFileSafe(settingsPath);
|
|
6402
6321
|
if (settingsContent === null) return;
|
|
6403
6322
|
let settings;
|
|
@@ -6408,8 +6327,8 @@ async function importGeminiSettings(projectRoot, results) {
|
|
|
6408
6327
|
if (!settings) return;
|
|
6409
6328
|
const mcpServers = settings.mcpServers;
|
|
6410
6329
|
if (mcpServers !== void 0 && typeof mcpServers === "object" && mcpServers !== null && Object.keys(mcpServers).length > 0) {
|
|
6411
|
-
const mcpPath =
|
|
6412
|
-
await mkdirp(
|
|
6330
|
+
const mcpPath = join(projectRoot, GEMINI_CANONICAL_MCP);
|
|
6331
|
+
await mkdirp(join(projectRoot, ".agentsmesh"));
|
|
6413
6332
|
await writeFileAtomic(mcpPath, JSON.stringify({ mcpServers }, null, 2));
|
|
6414
6333
|
results.push({
|
|
6415
6334
|
fromTool: "gemini-cli",
|
|
@@ -6420,8 +6339,8 @@ async function importGeminiSettings(projectRoot, results) {
|
|
|
6420
6339
|
}
|
|
6421
6340
|
const ignorePatterns = settings.ignorePatterns;
|
|
6422
6341
|
if (Array.isArray(ignorePatterns) && ignorePatterns.length > 0 && ignorePatterns.every((p) => typeof p === "string")) {
|
|
6423
|
-
const ignorePath =
|
|
6424
|
-
await mkdirp(
|
|
6342
|
+
const ignorePath = join(projectRoot, GEMINI_CANONICAL_IGNORE);
|
|
6343
|
+
await mkdirp(join(projectRoot, ".agentsmesh"));
|
|
6425
6344
|
await writeFileAtomic(ignorePath, ignorePatterns.join("\n") + "\n");
|
|
6426
6345
|
results.push({
|
|
6427
6346
|
fromTool: "gemini-cli",
|
|
@@ -6463,9 +6382,9 @@ async function importGeminiSettings(projectRoot, results) {
|
|
|
6463
6382
|
);
|
|
6464
6383
|
if (mappedHooks.length > 0) {
|
|
6465
6384
|
const hooksYaml = Object.fromEntries(mappedHooks);
|
|
6466
|
-
const hooksPath =
|
|
6467
|
-
await mkdirp(
|
|
6468
|
-
await writeFileAtomic(hooksPath,
|
|
6385
|
+
const hooksPath = join(projectRoot, GEMINI_CANONICAL_HOOKS);
|
|
6386
|
+
await mkdirp(join(projectRoot, ".agentsmesh"));
|
|
6387
|
+
await writeFileAtomic(hooksPath, stringify(hooksYaml, { lineWidth: 0 }).trimEnd());
|
|
6469
6388
|
results.push({
|
|
6470
6389
|
fromTool: "gemini-cli",
|
|
6471
6390
|
fromPath: settingsPath,
|
|
@@ -6478,13 +6397,13 @@ async function importGeminiSettings(projectRoot, results) {
|
|
|
6478
6397
|
|
|
6479
6398
|
// src/targets/gemini-cli/format-helpers.ts
|
|
6480
6399
|
async function importGeminiIgnore(projectRoot, results) {
|
|
6481
|
-
const geminiIgnorePath =
|
|
6400
|
+
const geminiIgnorePath = join(projectRoot, GEMINI_IGNORE);
|
|
6482
6401
|
const geminiIgnoreContent = await readFileSafe(geminiIgnorePath);
|
|
6483
6402
|
if (geminiIgnoreContent !== null && geminiIgnoreContent.trim()) {
|
|
6484
6403
|
const patterns = geminiIgnoreContent.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
6485
6404
|
if (patterns.length > 0) {
|
|
6486
|
-
await mkdirp(
|
|
6487
|
-
const ignorePath =
|
|
6405
|
+
await mkdirp(join(projectRoot, ".agentsmesh"));
|
|
6406
|
+
const ignorePath = join(projectRoot, GEMINI_CANONICAL_IGNORE);
|
|
6488
6407
|
await writeFileAtomic(ignorePath, patterns.join("\n") + "\n");
|
|
6489
6408
|
results.push({
|
|
6490
6409
|
fromTool: "gemini-cli",
|
|
@@ -6499,7 +6418,7 @@ async function importGeminiIgnore(projectRoot, results) {
|
|
|
6499
6418
|
// src/targets/gemini-cli/importer-mappers.ts
|
|
6500
6419
|
async function mapGeminiRuleFile(relativePath, destDir, normalizeTo) {
|
|
6501
6420
|
const relativeMdPath = relativePath.replace(/\\/g, "/");
|
|
6502
|
-
const destPath =
|
|
6421
|
+
const destPath = join(destDir, relativeMdPath);
|
|
6503
6422
|
const { frontmatter, body } = parseFlexibleFrontmatter(normalizeTo(destPath));
|
|
6504
6423
|
const globs = toGlobsArray(frontmatter.globs);
|
|
6505
6424
|
const canonicalFm = {
|
|
@@ -6519,7 +6438,7 @@ async function mapGeminiRuleFile(relativePath, destDir, normalizeTo) {
|
|
|
6519
6438
|
}
|
|
6520
6439
|
async function mapGeminiCommandFile(relativePath, destDir, normalizeTo) {
|
|
6521
6440
|
const relativeMdPath = relativePath.replace(/\.(toml|md)$/i, ".md").replace(/\\/g, "/");
|
|
6522
|
-
const destPath =
|
|
6441
|
+
const destPath = join(destDir, relativeMdPath);
|
|
6523
6442
|
const normalized = normalizeTo(destPath);
|
|
6524
6443
|
const { frontmatter, body } = relativePath.endsWith(".toml") ? parseTomlCommand(normalized) : parseFlexibleFrontmatter(normalized);
|
|
6525
6444
|
const fromCamel = toToolsArray(frontmatter.allowedTools);
|
|
@@ -6543,7 +6462,7 @@ async function mapGeminiCommandFile(relativePath, destDir, normalizeTo) {
|
|
|
6543
6462
|
}
|
|
6544
6463
|
function parseTomlCommand(normalized) {
|
|
6545
6464
|
try {
|
|
6546
|
-
const parsed =
|
|
6465
|
+
const parsed = parse$1(normalized);
|
|
6547
6466
|
return {
|
|
6548
6467
|
frontmatter: parsed,
|
|
6549
6468
|
body: typeof parsed.prompt === "string" ? parsed.prompt : ""
|
|
@@ -6552,11 +6471,6 @@ function parseTomlCommand(normalized) {
|
|
|
6552
6471
|
return { frontmatter: {}, body: normalized.trim() };
|
|
6553
6472
|
}
|
|
6554
6473
|
}
|
|
6555
|
-
|
|
6556
|
-
// src/targets/gemini-cli/policies-importer.ts
|
|
6557
|
-
import { parse as parseToml3 } from "smol-toml";
|
|
6558
|
-
import { stringify as stringifyYaml2 } from "yaml";
|
|
6559
|
-
import { join as join37 } from "path";
|
|
6560
6474
|
function unescapeRegexLiteral(value) {
|
|
6561
6475
|
return value.replace(/\\(.)/g, "$1");
|
|
6562
6476
|
}
|
|
@@ -6584,7 +6498,7 @@ function argsPatternToReadExpr(argsPattern) {
|
|
|
6584
6498
|
}
|
|
6585
6499
|
async function importGeminiPolicies(projectRoot) {
|
|
6586
6500
|
const results = [];
|
|
6587
|
-
const policiesDir =
|
|
6501
|
+
const policiesDir = join(projectRoot, GEMINI_POLICIES_DIR);
|
|
6588
6502
|
let policyFiles;
|
|
6589
6503
|
try {
|
|
6590
6504
|
policyFiles = await readDirRecursive(policiesDir);
|
|
@@ -6602,7 +6516,7 @@ async function importGeminiPolicies(projectRoot) {
|
|
|
6602
6516
|
if (!content) continue;
|
|
6603
6517
|
let parsed;
|
|
6604
6518
|
try {
|
|
6605
|
-
parsed =
|
|
6519
|
+
parsed = parse$1(content);
|
|
6606
6520
|
} catch {
|
|
6607
6521
|
continue;
|
|
6608
6522
|
}
|
|
@@ -6645,21 +6559,18 @@ async function importGeminiPolicies(projectRoot) {
|
|
|
6645
6559
|
}
|
|
6646
6560
|
}
|
|
6647
6561
|
if (allow.length === 0 && deny.length === 0) return results;
|
|
6648
|
-
await mkdirp(
|
|
6649
|
-
const outPath =
|
|
6650
|
-
const yaml =
|
|
6562
|
+
await mkdirp(join(projectRoot, ".agentsmesh"));
|
|
6563
|
+
const outPath = join(projectRoot, GEMINI_CANONICAL_PERMISSIONS);
|
|
6564
|
+
const yaml = stringify({ allow, deny });
|
|
6651
6565
|
await writeFileAtomic(outPath, yaml.trimEnd() + "\n");
|
|
6652
6566
|
results.push({
|
|
6653
6567
|
fromTool: GEMINI_TARGET,
|
|
6654
|
-
fromPath:
|
|
6568
|
+
fromPath: join(projectRoot, GEMINI_POLICIES_DIR),
|
|
6655
6569
|
toPath: GEMINI_CANONICAL_PERMISSIONS,
|
|
6656
6570
|
feature: "permissions"
|
|
6657
6571
|
});
|
|
6658
6572
|
return results;
|
|
6659
6573
|
}
|
|
6660
|
-
|
|
6661
|
-
// src/targets/gemini-cli/importer-strip.ts
|
|
6662
|
-
import { realpathSync as realpathSync3 } from "fs";
|
|
6663
6574
|
function stripProjectRootCanonicalPrefix(content, projectRoot) {
|
|
6664
6575
|
const variants = /* @__PURE__ */ new Set([
|
|
6665
6576
|
projectRoot,
|
|
@@ -6667,8 +6578,8 @@ function stripProjectRootCanonicalPrefix(content, projectRoot) {
|
|
|
6667
6578
|
projectRoot.replace(/\//g, "\\")
|
|
6668
6579
|
]);
|
|
6669
6580
|
try {
|
|
6670
|
-
variants.add(
|
|
6671
|
-
variants.add(
|
|
6581
|
+
variants.add(realpathSync(projectRoot));
|
|
6582
|
+
variants.add(realpathSync.native(projectRoot));
|
|
6672
6583
|
} catch {
|
|
6673
6584
|
}
|
|
6674
6585
|
const stripped = Array.from(variants).reduce((next, variant) => {
|
|
@@ -6677,23 +6588,20 @@ function stripProjectRootCanonicalPrefix(content, projectRoot) {
|
|
|
6677
6588
|
}, content);
|
|
6678
6589
|
return stripped.replace(/(?:[A-Za-z]:)?[^\s"'`()<>]+[/\\]\.agentsmesh[/\\]/g, ".agentsmesh/");
|
|
6679
6590
|
}
|
|
6680
|
-
|
|
6681
|
-
// src/targets/gemini-cli/importer-skills-agents.ts
|
|
6682
|
-
import { basename as basename21, dirname as dirname16, join as join38, relative as relative11 } from "path";
|
|
6683
6591
|
async function importGeminiSkillsAndAgents(projectRoot, results, normalize) {
|
|
6684
|
-
const geminiSkillsPath =
|
|
6592
|
+
const geminiSkillsPath = join(projectRoot, GEMINI_SKILLS_DIR);
|
|
6685
6593
|
const skillDirs = await readDirRecursive(geminiSkillsPath);
|
|
6686
|
-
const skillMdFiles = skillDirs.filter((f) =>
|
|
6594
|
+
const skillMdFiles = skillDirs.filter((f) => basename(f) === "SKILL.md");
|
|
6687
6595
|
for (const srcPath of skillMdFiles) {
|
|
6688
6596
|
const content = await readFileSafe(srcPath);
|
|
6689
6597
|
if (!content) continue;
|
|
6690
|
-
const skillName =
|
|
6598
|
+
const skillName = basename(srcPath.slice(0, -"/SKILL.md".length));
|
|
6691
6599
|
const rawParsed = parseFrontmatter(content);
|
|
6692
6600
|
const projectedAgent = parseProjectedAgentSkillFrontmatter(rawParsed.frontmatter, skillName);
|
|
6693
6601
|
if (projectedAgent) {
|
|
6694
|
-
const agentsDir =
|
|
6602
|
+
const agentsDir = join(projectRoot, GEMINI_CANONICAL_AGENTS_DIR);
|
|
6695
6603
|
await mkdirp(agentsDir);
|
|
6696
|
-
const agentPath =
|
|
6604
|
+
const agentPath = join(agentsDir, `${projectedAgent.name}.md`);
|
|
6697
6605
|
await writeFileAtomic(
|
|
6698
6606
|
agentPath,
|
|
6699
6607
|
serializeImportedAgent(projectedAgent, normalize(rawParsed.body, srcPath, agentPath))
|
|
@@ -6706,9 +6614,9 @@ async function importGeminiSkillsAndAgents(projectRoot, results, normalize) {
|
|
|
6706
6614
|
});
|
|
6707
6615
|
continue;
|
|
6708
6616
|
}
|
|
6709
|
-
const destPath =
|
|
6617
|
+
const destPath = join(projectRoot, GEMINI_CANONICAL_SKILLS_DIR, skillName, "SKILL.md");
|
|
6710
6618
|
const normalized = normalize(content, srcPath, destPath);
|
|
6711
|
-
const skillDir =
|
|
6619
|
+
const skillDir = join(projectRoot, GEMINI_CANONICAL_SKILLS_DIR, skillName);
|
|
6712
6620
|
await mkdirp(skillDir);
|
|
6713
6621
|
const { frontmatter, body } = parseFrontmatter(normalized);
|
|
6714
6622
|
await writeFileAtomic(
|
|
@@ -6721,14 +6629,14 @@ async function importGeminiSkillsAndAgents(projectRoot, results, normalize) {
|
|
|
6721
6629
|
toPath: `${GEMINI_CANONICAL_SKILLS_DIR}/${skillName}/SKILL.md`,
|
|
6722
6630
|
feature: "skills"
|
|
6723
6631
|
});
|
|
6724
|
-
const allSkillFiles = await readDirRecursive(
|
|
6632
|
+
const allSkillFiles = await readDirRecursive(dirname(srcPath));
|
|
6725
6633
|
for (const absPath of allSkillFiles) {
|
|
6726
6634
|
if (absPath === srcPath) continue;
|
|
6727
6635
|
const supportContent = await readFileSafe(absPath);
|
|
6728
6636
|
if (supportContent === null) continue;
|
|
6729
|
-
const relPath =
|
|
6730
|
-
const destSupportPath =
|
|
6731
|
-
await mkdirp(
|
|
6637
|
+
const relPath = relative(dirname(srcPath), absPath).replace(/\\/g, "/");
|
|
6638
|
+
const destSupportPath = join(skillDir, relPath);
|
|
6639
|
+
await mkdirp(dirname(destSupportPath));
|
|
6732
6640
|
await writeFileAtomic(destSupportPath, normalize(supportContent, absPath, destSupportPath));
|
|
6733
6641
|
results.push({
|
|
6734
6642
|
fromTool: "gemini-cli",
|
|
@@ -6738,7 +6646,7 @@ async function importGeminiSkillsAndAgents(projectRoot, results, normalize) {
|
|
|
6738
6646
|
});
|
|
6739
6647
|
}
|
|
6740
6648
|
}
|
|
6741
|
-
const geminiAgentsPath =
|
|
6649
|
+
const geminiAgentsPath = join(projectRoot, GEMINI_AGENTS_DIR);
|
|
6742
6650
|
try {
|
|
6743
6651
|
const agentFiles = await readDirRecursive(geminiAgentsPath);
|
|
6744
6652
|
const agentMdFiles = agentFiles.filter((f) => f.endsWith(".md"));
|
|
@@ -6746,11 +6654,11 @@ async function importGeminiSkillsAndAgents(projectRoot, results, normalize) {
|
|
|
6746
6654
|
const content = await readFileSafe(srcPath);
|
|
6747
6655
|
if (!content) continue;
|
|
6748
6656
|
const { frontmatter, body } = parseFrontmatter(content);
|
|
6749
|
-
const relPath =
|
|
6657
|
+
const relPath = relative(geminiAgentsPath, srcPath).replace(/\\/g, "/");
|
|
6750
6658
|
const relativeMdPath = relPath.replace(/\.md$/i, ".md");
|
|
6751
|
-
const agentsDir =
|
|
6659
|
+
const agentsDir = join(projectRoot, GEMINI_CANONICAL_AGENTS_DIR);
|
|
6752
6660
|
await mkdirp(agentsDir);
|
|
6753
|
-
const destPath =
|
|
6661
|
+
const destPath = join(agentsDir, relativeMdPath);
|
|
6754
6662
|
const normalizedBody = normalize(body, srcPath, destPath);
|
|
6755
6663
|
await writeFileAtomic(
|
|
6756
6664
|
destPath,
|
|
@@ -6758,7 +6666,7 @@ async function importGeminiSkillsAndAgents(projectRoot, results, normalize) {
|
|
|
6758
6666
|
destPath,
|
|
6759
6667
|
{
|
|
6760
6668
|
...frontmatter,
|
|
6761
|
-
name: typeof frontmatter.name === "string" ? frontmatter.name :
|
|
6669
|
+
name: typeof frontmatter.name === "string" ? frontmatter.name : basename(relativeMdPath, ".md"),
|
|
6762
6670
|
maxTurns: frontmatter.maxTurns ?? frontmatter["max-turns"] ?? frontmatter.max_turns,
|
|
6763
6671
|
permissionMode: frontmatter.permissionMode ?? frontmatter["permission-mode"] ?? frontmatter.permission_mode,
|
|
6764
6672
|
disallowedTools: frontmatter.disallowedTools ?? frontmatter["disallowed-tools"] ?? frontmatter.disallowed_tools
|
|
@@ -6782,12 +6690,12 @@ async function importFromGemini(projectRoot) {
|
|
|
6782
6690
|
const results = [];
|
|
6783
6691
|
const normalize = await createImportReferenceNormalizer(GEMINI_TARGET, projectRoot);
|
|
6784
6692
|
const normalizeCodex = await createImportReferenceNormalizer("codex-cli", projectRoot);
|
|
6785
|
-
const rulesDir =
|
|
6786
|
-
const commandsDir =
|
|
6787
|
-
const geminiRootPath =
|
|
6788
|
-
const compatAgentsRootPath =
|
|
6789
|
-
const compatInnerRootPath =
|
|
6790
|
-
const systemPath =
|
|
6693
|
+
const rulesDir = join(projectRoot, GEMINI_CANONICAL_RULES_DIR);
|
|
6694
|
+
const commandsDir = join(projectRoot, GEMINI_CANONICAL_COMMANDS_DIR);
|
|
6695
|
+
const geminiRootPath = join(projectRoot, GEMINI_ROOT);
|
|
6696
|
+
const compatAgentsRootPath = join(projectRoot, GEMINI_COMPAT_AGENTS);
|
|
6697
|
+
const compatInnerRootPath = join(projectRoot, GEMINI_COMPAT_INNER_ROOT);
|
|
6698
|
+
const systemPath = join(projectRoot, GEMINI_SYSTEM);
|
|
6791
6699
|
const geminiRootContent = await readFileSafe(geminiRootPath);
|
|
6792
6700
|
const compatAgentsRootContent = await readFileSafe(compatAgentsRootPath);
|
|
6793
6701
|
const compatInnerRootContent = await readFileSafe(compatInnerRootPath);
|
|
@@ -6802,7 +6710,7 @@ async function importFromGemini(projectRoot) {
|
|
|
6802
6710
|
const rootContent = rootCandidate?.content ?? null;
|
|
6803
6711
|
if (rootContent !== null) {
|
|
6804
6712
|
await mkdirp(rulesDir);
|
|
6805
|
-
const destPath =
|
|
6713
|
+
const destPath = join(rulesDir, "_root.md");
|
|
6806
6714
|
const compatContent = rootSourcePath === compatAgentsRootPath || rootSourcePath === compatInnerRootPath ? normalizeCodex(rootContent, rootSourcePath, destPath) : rootContent;
|
|
6807
6715
|
const split = await splitEmbeddedRulesToCanonical({
|
|
6808
6716
|
content: compatContent,
|
|
@@ -6833,7 +6741,7 @@ async function importFromGemini(projectRoot) {
|
|
|
6833
6741
|
feature: "rules"
|
|
6834
6742
|
});
|
|
6835
6743
|
}
|
|
6836
|
-
const geminiRulesPath =
|
|
6744
|
+
const geminiRulesPath = join(projectRoot, GEMINI_RULES_DIR);
|
|
6837
6745
|
results.push(
|
|
6838
6746
|
...await importFileDirectory({
|
|
6839
6747
|
srcDir: geminiRulesPath,
|
|
@@ -6844,7 +6752,7 @@ async function importFromGemini(projectRoot) {
|
|
|
6844
6752
|
mapEntry: ({ relativePath, normalizeTo }) => mapGeminiRuleFile(relativePath, rulesDir, normalizeTo)
|
|
6845
6753
|
})
|
|
6846
6754
|
);
|
|
6847
|
-
const geminiCommandsPath =
|
|
6755
|
+
const geminiCommandsPath = join(projectRoot, GEMINI_COMMANDS_DIR);
|
|
6848
6756
|
results.push(
|
|
6849
6757
|
...await importFileDirectory({
|
|
6850
6758
|
srcDir: geminiCommandsPath,
|
|
@@ -7052,11 +6960,8 @@ var descriptor7 = {
|
|
|
7052
6960
|
buildImportPaths: buildGeminiCliImportPaths,
|
|
7053
6961
|
detectionPaths: ["GEMINI.md", ".gemini"]
|
|
7054
6962
|
};
|
|
7055
|
-
|
|
7056
|
-
// src/targets/cline/generator.ts
|
|
7057
|
-
import { basename as basename22 } from "path";
|
|
7058
6963
|
function ruleSlug2(source) {
|
|
7059
|
-
const name =
|
|
6964
|
+
const name = basename(source, ".md");
|
|
7060
6965
|
return name === "_root" ? "root" : name;
|
|
7061
6966
|
}
|
|
7062
6967
|
function generateRules8(canonical) {
|
|
@@ -7162,17 +7067,11 @@ function generateSkills8(canonical) {
|
|
|
7162
7067
|
}
|
|
7163
7068
|
return outputs;
|
|
7164
7069
|
}
|
|
7165
|
-
|
|
7166
|
-
// src/targets/cline/importer.ts
|
|
7167
|
-
import { join as join45 } from "path";
|
|
7168
|
-
|
|
7169
|
-
// src/targets/cline/importer-mappers.ts
|
|
7170
|
-
import { join as join40 } from "path";
|
|
7171
7070
|
async function mapClineRuleFile(relativePath, destDir, normalizeTo) {
|
|
7172
7071
|
if (relativePath === "workflows" || relativePath.startsWith("workflows/")) return null;
|
|
7173
7072
|
const relativeMdPath = relativePath.replace(/\\/g, "/");
|
|
7174
7073
|
if (relativeMdPath === "_root.md") return null;
|
|
7175
|
-
const destPath =
|
|
7074
|
+
const destPath = join(destDir, relativeMdPath);
|
|
7176
7075
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
7177
7076
|
const globs = toGlobsArray(frontmatter.paths ?? frontmatter.globs);
|
|
7178
7077
|
const canonicalFm = {
|
|
@@ -7191,7 +7090,7 @@ async function mapClineRuleFile(relativePath, destDir, normalizeTo) {
|
|
|
7191
7090
|
};
|
|
7192
7091
|
}
|
|
7193
7092
|
async function mapClineWorkflowFile(relativePath, destDir, normalizeTo) {
|
|
7194
|
-
const destPath =
|
|
7093
|
+
const destPath = join(destDir, relativePath);
|
|
7195
7094
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
7196
7095
|
const hasFrontmatterDescription = Object.prototype.hasOwnProperty.call(
|
|
7197
7096
|
frontmatter,
|
|
@@ -7227,17 +7126,13 @@ async function mapClineWorkflowFile(relativePath, destDir, normalizeTo) {
|
|
|
7227
7126
|
)
|
|
7228
7127
|
};
|
|
7229
7128
|
}
|
|
7230
|
-
|
|
7231
|
-
// src/targets/cline/importer-rules.ts
|
|
7232
|
-
import { stat as stat2 } from "fs/promises";
|
|
7233
|
-
import { join as join41 } from "path";
|
|
7234
7129
|
async function importClineRules(projectRoot, results, normalize) {
|
|
7235
|
-
const destRulesDir =
|
|
7236
|
-
const clineRulesPath =
|
|
7237
|
-
const clineRulesRaw =
|
|
7130
|
+
const destRulesDir = join(projectRoot, CLINE_CANONICAL_RULES_DIR);
|
|
7131
|
+
const clineRulesPath = join(projectRoot, CLINE_RULES_DIR);
|
|
7132
|
+
const clineRulesRaw = join(projectRoot, CLINE_RULES_DIR);
|
|
7238
7133
|
let clineRulesIsFile = false;
|
|
7239
7134
|
try {
|
|
7240
|
-
const clineRulesStat = await
|
|
7135
|
+
const clineRulesStat = await stat(clineRulesRaw);
|
|
7241
7136
|
clineRulesIsFile = clineRulesStat.isFile();
|
|
7242
7137
|
} catch {
|
|
7243
7138
|
}
|
|
@@ -7245,7 +7140,7 @@ async function importClineRules(projectRoot, results, normalize) {
|
|
|
7245
7140
|
const flatContent = await readFileSafe(clineRulesRaw);
|
|
7246
7141
|
if (flatContent !== null) {
|
|
7247
7142
|
await mkdirp(destRulesDir);
|
|
7248
|
-
const destPath =
|
|
7143
|
+
const destPath = join(destRulesDir, "_root.md");
|
|
7249
7144
|
const { frontmatter, body } = parseFrontmatter(
|
|
7250
7145
|
normalize(flatContent, clineRulesRaw, destPath)
|
|
7251
7146
|
);
|
|
@@ -7263,15 +7158,15 @@ async function importClineRules(projectRoot, results, normalize) {
|
|
|
7263
7158
|
return clineRulesIsFile;
|
|
7264
7159
|
}
|
|
7265
7160
|
let rootSourcePath = null;
|
|
7266
|
-
const rootPath =
|
|
7161
|
+
const rootPath = join(clineRulesPath, "_root.md");
|
|
7267
7162
|
const rootContent = await readFileSafe(rootPath);
|
|
7268
7163
|
if (rootContent === null) {
|
|
7269
|
-
const agentsMdPath =
|
|
7164
|
+
const agentsMdPath = join(projectRoot, CLINE_AGENTS_MD);
|
|
7270
7165
|
const agentsMdContent = await readFileSafe(agentsMdPath);
|
|
7271
7166
|
if (agentsMdContent !== null) {
|
|
7272
7167
|
rootSourcePath = agentsMdPath;
|
|
7273
7168
|
await mkdirp(destRulesDir);
|
|
7274
|
-
const destPath =
|
|
7169
|
+
const destPath = join(destRulesDir, "_root.md");
|
|
7275
7170
|
const { frontmatter, body } = parseFrontmatter(
|
|
7276
7171
|
normalize(agentsMdContent, agentsMdPath, destPath)
|
|
7277
7172
|
);
|
|
@@ -7294,7 +7189,7 @@ async function importClineRules(projectRoot, results, normalize) {
|
|
|
7294
7189
|
if (fc !== null) {
|
|
7295
7190
|
rootSourcePath = first;
|
|
7296
7191
|
await mkdirp(destRulesDir);
|
|
7297
|
-
const destPath =
|
|
7192
|
+
const destPath = join(destRulesDir, "_root.md");
|
|
7298
7193
|
const { frontmatter, body } = parseFrontmatter(normalize(fc, first, destPath));
|
|
7299
7194
|
const hasRoot = frontmatter.root === true;
|
|
7300
7195
|
const outFm = hasRoot ? frontmatter : { ...frontmatter, root: true };
|
|
@@ -7312,7 +7207,7 @@ async function importClineRules(projectRoot, results, normalize) {
|
|
|
7312
7207
|
} else {
|
|
7313
7208
|
rootSourcePath = rootPath;
|
|
7314
7209
|
await mkdirp(destRulesDir);
|
|
7315
|
-
const destPath =
|
|
7210
|
+
const destPath = join(destRulesDir, "_root.md");
|
|
7316
7211
|
const { frontmatter, body } = parseFrontmatter(normalize(rootContent, rootPath, destPath));
|
|
7317
7212
|
const hasRoot = frontmatter.root === true;
|
|
7318
7213
|
const outFm = hasRoot ? frontmatter : { ...frontmatter, root: true };
|
|
@@ -7340,9 +7235,6 @@ async function importClineRules(projectRoot, results, normalize) {
|
|
|
7340
7235
|
);
|
|
7341
7236
|
return clineRulesIsFile;
|
|
7342
7237
|
}
|
|
7343
|
-
|
|
7344
|
-
// src/targets/cline/mcp-mapper.ts
|
|
7345
|
-
import { join as join42 } from "path";
|
|
7346
7238
|
function mapClineServerToCanonical(raw) {
|
|
7347
7239
|
if (!raw || typeof raw !== "object") return null;
|
|
7348
7240
|
const obj = raw;
|
|
@@ -7367,7 +7259,7 @@ function mapClineServerToCanonical(raw) {
|
|
|
7367
7259
|
}
|
|
7368
7260
|
async function importClineMcp(projectRoot, results) {
|
|
7369
7261
|
const candidatePaths = [CLINE_MCP_SETTINGS, CLINE_MCP_SETTINGS_LEGACY].map(
|
|
7370
|
-
(path) =>
|
|
7262
|
+
(path) => join(projectRoot, path)
|
|
7371
7263
|
);
|
|
7372
7264
|
let mcpPath = null;
|
|
7373
7265
|
let mcpContent = null;
|
|
@@ -7394,9 +7286,9 @@ async function importClineMcp(projectRoot, results) {
|
|
|
7394
7286
|
if (server) mcpServers[n] = server;
|
|
7395
7287
|
}
|
|
7396
7288
|
if (Object.keys(mcpServers).length > 0) {
|
|
7397
|
-
await mkdirp(
|
|
7289
|
+
await mkdirp(join(projectRoot, ".agentsmesh"));
|
|
7398
7290
|
await writeFileAtomic(
|
|
7399
|
-
|
|
7291
|
+
join(projectRoot, CLINE_CANONICAL_MCP),
|
|
7400
7292
|
JSON.stringify({ mcpServers }, null, 2)
|
|
7401
7293
|
);
|
|
7402
7294
|
results.push({
|
|
@@ -7408,11 +7300,8 @@ async function importClineMcp(projectRoot, results) {
|
|
|
7408
7300
|
}
|
|
7409
7301
|
}
|
|
7410
7302
|
}
|
|
7411
|
-
|
|
7412
|
-
// src/targets/cline/skills-adapter.ts
|
|
7413
|
-
import { join as join43 } from "path";
|
|
7414
7303
|
async function importClineSkills(projectRoot, results, normalize, skillsRelDir = CLINE_SKILLS_DIR) {
|
|
7415
|
-
const skillsDir =
|
|
7304
|
+
const skillsDir = join(projectRoot, skillsRelDir);
|
|
7416
7305
|
const directorySkills = await findDirectorySkills(skillsDir);
|
|
7417
7306
|
const options = {
|
|
7418
7307
|
projectRoot,
|
|
@@ -7423,15 +7312,15 @@ async function importClineSkills(projectRoot, results, normalize, skillsRelDir =
|
|
|
7423
7312
|
results
|
|
7424
7313
|
};
|
|
7425
7314
|
for (const [skillName, skillDir] of directorySkills) {
|
|
7426
|
-
const skillMdPath =
|
|
7315
|
+
const skillMdPath = join(skillDir, "SKILL.md");
|
|
7427
7316
|
const content = await readFileSafe(skillMdPath);
|
|
7428
7317
|
if (!content) continue;
|
|
7429
7318
|
const rawParsed = parseFrontmatter(content);
|
|
7430
7319
|
const projectedAgent = parseProjectedAgentSkillFrontmatter(rawParsed.frontmatter, skillName);
|
|
7431
7320
|
if (projectedAgent) {
|
|
7432
|
-
const destAgentsDir =
|
|
7321
|
+
const destAgentsDir = join(projectRoot, CLINE_CANONICAL_AGENTS_DIR);
|
|
7433
7322
|
await mkdirp(destAgentsDir);
|
|
7434
|
-
const agentPath =
|
|
7323
|
+
const agentPath = join(destAgentsDir, `${projectedAgent.name}.md`);
|
|
7435
7324
|
await writeFileAtomic(
|
|
7436
7325
|
agentPath,
|
|
7437
7326
|
serializeImportedAgent(projectedAgent, normalize(rawParsed.body, skillMdPath, agentPath))
|
|
@@ -7447,17 +7336,13 @@ async function importClineSkills(projectRoot, results, normalize, skillsRelDir =
|
|
|
7447
7336
|
await importDirectorySkill(skillName, skillDir, options);
|
|
7448
7337
|
}
|
|
7449
7338
|
}
|
|
7450
|
-
|
|
7451
|
-
// src/targets/cline/hook-importer.ts
|
|
7452
|
-
import { join as join44, basename as basename23, dirname as dirname17 } from "path";
|
|
7453
|
-
import { stringify as yamlStringify7 } from "yaml";
|
|
7454
7339
|
function extractMeta(content, key) {
|
|
7455
7340
|
const match = content.match(new RegExp(`^# agentsmesh-${key}:\\s*(.+)$`, "m"));
|
|
7456
7341
|
return match?.[1]?.trim() ?? null;
|
|
7457
7342
|
}
|
|
7458
7343
|
async function loadHooksFromDir(dir, hooks) {
|
|
7459
7344
|
const files = await readDirRecursive(dir).catch(() => []);
|
|
7460
|
-
const shFiles = files.filter((f) =>
|
|
7345
|
+
const shFiles = files.filter((f) => basename(f).endsWith(".sh") && dirname(f) === dir);
|
|
7461
7346
|
for (const srcPath of shFiles) {
|
|
7462
7347
|
const content = await readFileSafe(srcPath);
|
|
7463
7348
|
if (!content) continue;
|
|
@@ -7471,15 +7356,15 @@ async function loadHooksFromDir(dir, hooks) {
|
|
|
7471
7356
|
}
|
|
7472
7357
|
async function importClineHooks(projectRoot, results) {
|
|
7473
7358
|
const hooks = {};
|
|
7474
|
-
await loadHooksFromDir(
|
|
7475
|
-
await loadHooksFromDir(
|
|
7359
|
+
await loadHooksFromDir(join(projectRoot, CLINE_HOOKS_DIR), hooks);
|
|
7360
|
+
await loadHooksFromDir(join(projectRoot, CLINE_GLOBAL_HOOKS_DIR), hooks);
|
|
7476
7361
|
if (Object.keys(hooks).length === 0) return;
|
|
7477
|
-
const destPath =
|
|
7478
|
-
await mkdirp(
|
|
7479
|
-
await writeFileAtomic(destPath,
|
|
7362
|
+
const destPath = join(projectRoot, CLINE_CANONICAL_HOOKS);
|
|
7363
|
+
await mkdirp(dirname(destPath));
|
|
7364
|
+
await writeFileAtomic(destPath, stringify(hooks));
|
|
7480
7365
|
results.push({
|
|
7481
7366
|
fromTool: CLINE_TARGET,
|
|
7482
|
-
fromPath:
|
|
7367
|
+
fromPath: join(projectRoot, CLINE_GLOBAL_HOOKS_DIR),
|
|
7483
7368
|
toPath: CLINE_CANONICAL_HOOKS,
|
|
7484
7369
|
feature: "hooks"
|
|
7485
7370
|
});
|
|
@@ -7490,7 +7375,7 @@ async function importFromCline(projectRoot) {
|
|
|
7490
7375
|
const results = [];
|
|
7491
7376
|
const normalize = await createImportReferenceNormalizer(CLINE_TARGET, projectRoot);
|
|
7492
7377
|
const clineRulesIsFile = await importClineRules(projectRoot, results, normalize);
|
|
7493
|
-
const ignorePath =
|
|
7378
|
+
const ignorePath = join(projectRoot, CLINE_IGNORE);
|
|
7494
7379
|
const ignoreContent = await readFileSafe(ignorePath);
|
|
7495
7380
|
if (ignoreContent !== null && ignoreContent.trim()) {
|
|
7496
7381
|
const lines = ignoreContent.split(/\r?\n/);
|
|
@@ -7500,8 +7385,8 @@ async function importFromCline(projectRoot) {
|
|
|
7500
7385
|
if (t && !t.startsWith("#")) patterns.push(t);
|
|
7501
7386
|
}
|
|
7502
7387
|
if (patterns.length > 0) {
|
|
7503
|
-
await mkdirp(
|
|
7504
|
-
const destIgnorePath =
|
|
7388
|
+
await mkdirp(join(projectRoot, ".agentsmesh"));
|
|
7389
|
+
const destIgnorePath = join(projectRoot, CLINE_CANONICAL_IGNORE);
|
|
7505
7390
|
await writeFileAtomic(destIgnorePath, patterns.join("\n"));
|
|
7506
7391
|
results.push({
|
|
7507
7392
|
fromTool: "cline",
|
|
@@ -7512,11 +7397,11 @@ async function importFromCline(projectRoot) {
|
|
|
7512
7397
|
}
|
|
7513
7398
|
}
|
|
7514
7399
|
await importClineMcp(projectRoot, results);
|
|
7515
|
-
const destCommandsDir =
|
|
7400
|
+
const destCommandsDir = join(projectRoot, CLINE_CANONICAL_COMMANDS_DIR);
|
|
7516
7401
|
if (!clineRulesIsFile) {
|
|
7517
7402
|
results.push(
|
|
7518
7403
|
...await importFileDirectory({
|
|
7519
|
-
srcDir:
|
|
7404
|
+
srcDir: join(projectRoot, CLINE_WORKFLOWS_DIR),
|
|
7520
7405
|
destDir: destCommandsDir,
|
|
7521
7406
|
extensions: [".md"],
|
|
7522
7407
|
fromTool: "cline",
|
|
@@ -7679,9 +7564,6 @@ var descriptor8 = {
|
|
|
7679
7564
|
detectionPaths: [".clinerules", ".cline"]
|
|
7680
7565
|
};
|
|
7681
7566
|
|
|
7682
|
-
// src/targets/codex-cli/generator/rules.ts
|
|
7683
|
-
import { basename as basename25 } from "path";
|
|
7684
|
-
|
|
7685
7567
|
// src/targets/codex-cli/constants.ts
|
|
7686
7568
|
var CODEX_TARGET = "codex-cli";
|
|
7687
7569
|
var CODEX_MD = "codex.md";
|
|
@@ -7706,11 +7588,8 @@ var CODEX_RULE_EMBED_B64_END = "# am-body-b64-end";
|
|
|
7706
7588
|
var CODEX_RULE_EMBED_B64_LINE = "# am64:";
|
|
7707
7589
|
var CODEX_RULE_INDEX_START = "<!-- agentsmesh:codex-rule-index:start -->";
|
|
7708
7590
|
var CODEX_RULE_INDEX_END = "<!-- agentsmesh:codex-rule-index:end -->";
|
|
7709
|
-
|
|
7710
|
-
// src/targets/codex-cli/instruction-mirror.ts
|
|
7711
|
-
import { basename as basename24 } from "path";
|
|
7712
7591
|
function ruleSlug3(source) {
|
|
7713
|
-
return
|
|
7592
|
+
return basename(source, ".md");
|
|
7714
7593
|
}
|
|
7715
7594
|
function codexInstructionMirrorPath(rule) {
|
|
7716
7595
|
return `${CODEX_INSTRUCTIONS_DIR}/${ruleSlug3(rule.source)}.md`;
|
|
@@ -7810,7 +7689,7 @@ function generateRules9(canonical) {
|
|
|
7810
7689
|
}
|
|
7811
7690
|
for (const rule of canonical.rules) {
|
|
7812
7691
|
if (rule.root) continue;
|
|
7813
|
-
const slug =
|
|
7692
|
+
const slug = basename(rule.source, ".md");
|
|
7814
7693
|
if (rule.targets.length > 0 && !rule.targets.includes("codex-cli")) continue;
|
|
7815
7694
|
if (rule.codexEmit === "execution") {
|
|
7816
7695
|
outputs.push({
|
|
@@ -7937,10 +7816,6 @@ function serializeMcpToToml(mcpServers) {
|
|
|
7937
7816
|
function needsTomlQuoting(key) {
|
|
7938
7817
|
return !/^[A-Za-z0-9_-]+$/.test(key);
|
|
7939
7818
|
}
|
|
7940
|
-
|
|
7941
|
-
// src/targets/codex-cli/mcp-helpers.ts
|
|
7942
|
-
import { join as join46 } from "path";
|
|
7943
|
-
import { parse as parseToml4 } from "smol-toml";
|
|
7944
7819
|
function mapTomlServerToCanonical(raw) {
|
|
7945
7820
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
7946
7821
|
const obj = raw;
|
|
@@ -7961,12 +7836,12 @@ function mapTomlServerToCanonical(raw) {
|
|
|
7961
7836
|
};
|
|
7962
7837
|
}
|
|
7963
7838
|
async function importMcp3(projectRoot, results) {
|
|
7964
|
-
const configPath =
|
|
7839
|
+
const configPath = join(projectRoot, CODEX_CONFIG_TOML);
|
|
7965
7840
|
const content = await readFileSafe(configPath);
|
|
7966
7841
|
if (content === null) return;
|
|
7967
7842
|
let parsed;
|
|
7968
7843
|
try {
|
|
7969
|
-
parsed =
|
|
7844
|
+
parsed = parse$1(content);
|
|
7970
7845
|
} catch {
|
|
7971
7846
|
return;
|
|
7972
7847
|
}
|
|
@@ -7980,9 +7855,9 @@ async function importMcp3(projectRoot, results) {
|
|
|
7980
7855
|
if (server) mcpServers[name] = server;
|
|
7981
7856
|
}
|
|
7982
7857
|
if (Object.keys(mcpServers).length === 0) return;
|
|
7983
|
-
await mkdirp(
|
|
7858
|
+
await mkdirp(join(projectRoot, ".agentsmesh"));
|
|
7984
7859
|
await writeFileAtomic(
|
|
7985
|
-
|
|
7860
|
+
join(projectRoot, CODEX_CANONICAL_MCP),
|
|
7986
7861
|
JSON.stringify({ mcpServers }, null, 2)
|
|
7987
7862
|
);
|
|
7988
7863
|
results.push({
|
|
@@ -7992,13 +7867,6 @@ async function importMcp3(projectRoot, results) {
|
|
|
7992
7867
|
feature: "mcp"
|
|
7993
7868
|
});
|
|
7994
7869
|
}
|
|
7995
|
-
|
|
7996
|
-
// src/targets/codex-cli/skills-adapter.ts
|
|
7997
|
-
import { readdir as readdir3 } from "fs/promises";
|
|
7998
|
-
import { join as join47 } from "path";
|
|
7999
|
-
|
|
8000
|
-
// src/targets/import/scoped-agents-import.ts
|
|
8001
|
-
import { rm } from "fs/promises";
|
|
8002
7870
|
function shouldImportScopedAgentsRule(relDir) {
|
|
8003
7871
|
const segments = relDir.split("/").filter(Boolean);
|
|
8004
7872
|
if (segments.length === 0) return false;
|
|
@@ -8021,8 +7889,8 @@ async function importSkills3(projectRoot, results, normalize) {
|
|
|
8021
7889
|
results
|
|
8022
7890
|
};
|
|
8023
7891
|
for (const skillsRoot of [CODEX_SKILLS_DIR, CODEX_SKILLS_FALLBACK_DIR]) {
|
|
8024
|
-
const skillsDir =
|
|
8025
|
-
const entries = await
|
|
7892
|
+
const skillsDir = join(projectRoot, skillsRoot);
|
|
7893
|
+
const entries = await readdir(skillsDir, {
|
|
8026
7894
|
encoding: "utf8",
|
|
8027
7895
|
withFileTypes: true
|
|
8028
7896
|
}).catch(() => null);
|
|
@@ -8030,21 +7898,21 @@ async function importSkills3(projectRoot, results, normalize) {
|
|
|
8030
7898
|
let importedAny = false;
|
|
8031
7899
|
for (const ent of entries) {
|
|
8032
7900
|
if (!ent.isDirectory() && !ent.isSymbolicLink()) continue;
|
|
8033
|
-
const skillPath =
|
|
8034
|
-
const skillMdPath =
|
|
7901
|
+
const skillPath = join(skillsDir, ent.name);
|
|
7902
|
+
const skillMdPath = join(skillPath, "SKILL.md");
|
|
8035
7903
|
const skillMdContent = await readFileSafe(skillMdPath);
|
|
8036
7904
|
if (!skillMdContent) continue;
|
|
8037
7905
|
importedAny = true;
|
|
8038
7906
|
const skillName = ent.name;
|
|
8039
|
-
const destSkillPath =
|
|
7907
|
+
const destSkillPath = join(projectRoot, CODEX_CANONICAL_SKILLS_DIR, skillName, "SKILL.md");
|
|
8040
7908
|
const normalized = normalize(skillMdContent, skillMdPath, destSkillPath);
|
|
8041
7909
|
const { frontmatter, body } = parseFrontmatter(normalized);
|
|
8042
7910
|
const command = parseCommandSkillFrontmatter(frontmatter, ent.name);
|
|
8043
7911
|
if (command) {
|
|
8044
|
-
await removePathIfExists(
|
|
8045
|
-
const destCommandsDir =
|
|
7912
|
+
await removePathIfExists(join(projectRoot, CODEX_CANONICAL_SKILLS_DIR, skillName));
|
|
7913
|
+
const destCommandsDir = join(projectRoot, CODEX_CANONICAL_COMMANDS_DIR);
|
|
8046
7914
|
await mkdirp(destCommandsDir);
|
|
8047
|
-
const commandPath =
|
|
7915
|
+
const commandPath = join(destCommandsDir, `${command.name}.md`);
|
|
8048
7916
|
await writeFileAtomic(
|
|
8049
7917
|
commandPath,
|
|
8050
7918
|
serializeImportedCommand(command, normalize(body, skillMdPath, commandPath))
|
|
@@ -8059,10 +7927,10 @@ async function importSkills3(projectRoot, results, normalize) {
|
|
|
8059
7927
|
}
|
|
8060
7928
|
const projectedAgent = parseProjectedAgentSkillFrontmatter(frontmatter, ent.name);
|
|
8061
7929
|
if (projectedAgent) {
|
|
8062
|
-
await removePathIfExists(
|
|
8063
|
-
const destAgentsDir =
|
|
7930
|
+
await removePathIfExists(join(projectRoot, CODEX_CANONICAL_SKILLS_DIR, skillName));
|
|
7931
|
+
const destAgentsDir = join(projectRoot, CODEX_CANONICAL_AGENTS_DIR);
|
|
8064
7932
|
await mkdirp(destAgentsDir);
|
|
8065
|
-
const agentPath =
|
|
7933
|
+
const agentPath = join(destAgentsDir, `${projectedAgent.name}.md`);
|
|
8066
7934
|
await writeFileAtomic(
|
|
8067
7935
|
agentPath,
|
|
8068
7936
|
serializeImportedAgent(projectedAgent, normalize(body, skillMdPath, agentPath))
|
|
@@ -8080,22 +7948,18 @@ async function importSkills3(projectRoot, results, normalize) {
|
|
|
8080
7948
|
if (importedAny) return;
|
|
8081
7949
|
}
|
|
8082
7950
|
}
|
|
8083
|
-
|
|
8084
|
-
// src/targets/codex-cli/importer-agents.ts
|
|
8085
|
-
import { basename as basename26, join as join48 } from "path";
|
|
8086
|
-
import { parse as parseToml5 } from "smol-toml";
|
|
8087
7951
|
async function importCodexAgentsFromToml(projectRoot, results, normalize) {
|
|
8088
|
-
const agentsPath =
|
|
8089
|
-
const agentsDestDir =
|
|
7952
|
+
const agentsPath = join(projectRoot, CODEX_AGENTS_DIR);
|
|
7953
|
+
const agentsDestDir = join(projectRoot, CODEX_CANONICAL_AGENTS_DIR);
|
|
8090
7954
|
try {
|
|
8091
7955
|
const agentFiles = await readDirRecursive(agentsPath);
|
|
8092
7956
|
const tomlFiles = agentFiles.filter((f) => f.endsWith(".toml"));
|
|
8093
7957
|
for (const srcPath of tomlFiles) {
|
|
8094
7958
|
const content = await readFileSafe(srcPath);
|
|
8095
7959
|
if (!content) continue;
|
|
8096
|
-
const parsed =
|
|
7960
|
+
const parsed = parse$1(content);
|
|
8097
7961
|
if (!parsed || typeof parsed !== "object") continue;
|
|
8098
|
-
const name = typeof parsed.name === "string" ? parsed.name :
|
|
7962
|
+
const name = typeof parsed.name === "string" ? parsed.name : basename(srcPath, ".toml");
|
|
8099
7963
|
const description = typeof parsed.description === "string" ? parsed.description : "";
|
|
8100
7964
|
const body = typeof parsed.developer_instructions === "string" ? parsed.developer_instructions.trim() : "";
|
|
8101
7965
|
const model = typeof parsed.model === "string" ? parsed.model : "";
|
|
@@ -8103,7 +7967,7 @@ async function importCodexAgentsFromToml(projectRoot, results, normalize) {
|
|
|
8103
7967
|
const permissionMode = sandbox === "read-only" ? "read-only" : sandbox === "workspace-write" ? "allow" : "";
|
|
8104
7968
|
const mcpServers = Array.isArray(parsed.mcp_servers) ? parsed.mcp_servers.filter((s) => typeof s === "string") : [];
|
|
8105
7969
|
await mkdirp(agentsDestDir);
|
|
8106
|
-
const destPath =
|
|
7970
|
+
const destPath = join(agentsDestDir, `${name}.md`);
|
|
8107
7971
|
const normalizedBody = normalize(body, srcPath, destPath);
|
|
8108
7972
|
const agent = {
|
|
8109
7973
|
name,
|
|
@@ -8130,15 +7994,6 @@ async function importCodexAgentsFromToml(projectRoot, results, normalize) {
|
|
|
8130
7994
|
} catch {
|
|
8131
7995
|
}
|
|
8132
7996
|
}
|
|
8133
|
-
|
|
8134
|
-
// src/targets/codex-cli/importer-rules.ts
|
|
8135
|
-
import { dirname as dirname18, join as join50, relative as relative13 } from "path";
|
|
8136
|
-
|
|
8137
|
-
// src/targets/codex-cli/import-codex-non-root-rules.ts
|
|
8138
|
-
import { join as join49, relative as relative12 } from "path";
|
|
8139
|
-
|
|
8140
|
-
// src/targets/codex-cli/codex-rules-embed.ts
|
|
8141
|
-
import { Buffer } from "buffer";
|
|
8142
7997
|
function tryParseEmbeddedCanonicalFromCodexRules(content) {
|
|
8143
7998
|
if (!content.includes(CODEX_RULE_EMBED_MARKER)) return null;
|
|
8144
7999
|
const jsonLine = content.split("\n").find((l) => l.startsWith(CODEX_RULE_EMBED_JSON_PREFIX));
|
|
@@ -8181,15 +8036,15 @@ function tryParseEmbeddedCanonicalFromCodexRules(content) {
|
|
|
8181
8036
|
// src/targets/codex-cli/import-codex-non-root-rules.ts
|
|
8182
8037
|
async function importCodexNonRootRuleFiles(projectRoot, destDir, normalize) {
|
|
8183
8038
|
const results = [];
|
|
8184
|
-
const codexRulesPath =
|
|
8039
|
+
const codexRulesPath = join(projectRoot, CODEX_RULES_DIR);
|
|
8185
8040
|
try {
|
|
8186
8041
|
const ruleFiles = await readDirRecursive(codexRulesPath);
|
|
8187
8042
|
const mdFiles = ruleFiles.filter((f) => f.endsWith(".md"));
|
|
8188
8043
|
for (const srcPath of mdFiles) {
|
|
8189
8044
|
const content = await readFileSafe(srcPath);
|
|
8190
8045
|
if (!content) continue;
|
|
8191
|
-
const relativePath =
|
|
8192
|
-
const destPath =
|
|
8046
|
+
const relativePath = relative(codexRulesPath, srcPath).replace(/\\/g, "/");
|
|
8047
|
+
const destPath = join(destDir, relativePath);
|
|
8193
8048
|
const { frontmatter, body } = parseFrontmatter(normalize(content, srcPath, destPath));
|
|
8194
8049
|
await mkdirp(destDir);
|
|
8195
8050
|
const outFm = frontmatter.root === true ? frontmatter : { ...frontmatter, root: false };
|
|
@@ -8206,8 +8061,8 @@ async function importCodexNonRootRuleFiles(projectRoot, destDir, normalize) {
|
|
|
8206
8061
|
for (const srcPath of starlarkFiles) {
|
|
8207
8062
|
const raw = await readFileSafe(srcPath);
|
|
8208
8063
|
if (!raw) continue;
|
|
8209
|
-
const relativePath =
|
|
8210
|
-
const destPath =
|
|
8064
|
+
const relativePath = relative(codexRulesPath, srcPath).replace(/\\/g, "/").replace(/\.rules$/i, ".md");
|
|
8065
|
+
const destPath = join(destDir, relativePath);
|
|
8211
8066
|
await mkdirp(destDir);
|
|
8212
8067
|
const embedded = tryParseEmbeddedCanonicalFromCodexRules(raw);
|
|
8213
8068
|
if (embedded) {
|
|
@@ -8248,20 +8103,20 @@ async function importCodexNonRootRuleFiles(projectRoot, destDir, normalize) {
|
|
|
8248
8103
|
|
|
8249
8104
|
// src/targets/codex-cli/importer-rules.ts
|
|
8250
8105
|
async function importCodexRules(projectRoot, results, normalize, normalizeWindsurf, layoutScope) {
|
|
8251
|
-
const codexPath =
|
|
8252
|
-
const agentsPath =
|
|
8253
|
-
const globalOverridePath =
|
|
8254
|
-
const globalAgentsPath =
|
|
8106
|
+
const codexPath = join(projectRoot, CODEX_MD);
|
|
8107
|
+
const agentsPath = join(projectRoot, AGENTS_MD);
|
|
8108
|
+
const globalOverridePath = join(projectRoot, CODEX_GLOBAL_AGENTS_OVERRIDE_MD);
|
|
8109
|
+
const globalAgentsPath = join(projectRoot, CODEX_GLOBAL_AGENTS_MD);
|
|
8255
8110
|
const globalOverrideContent = layoutScope === "global" ? await readFileSafe(globalOverridePath) : null;
|
|
8256
8111
|
const globalAgentsContent = layoutScope === "global" ? await readFileSafe(globalAgentsPath) : null;
|
|
8257
8112
|
const agentsContent = layoutScope === "project" ? await readFileSafe(agentsPath) : null;
|
|
8258
8113
|
const codexContent = layoutScope === "project" ? await readFileSafe(codexPath) : null;
|
|
8259
8114
|
const sourcePath = globalOverrideContent !== null ? globalOverridePath : globalAgentsContent !== null ? globalAgentsPath : agentsContent !== null ? agentsPath : codexPath;
|
|
8260
|
-
const destDir =
|
|
8115
|
+
const destDir = join(projectRoot, CODEX_CANONICAL_RULES_DIR);
|
|
8261
8116
|
const content = globalOverrideContent ?? globalAgentsContent ?? agentsContent ?? codexContent;
|
|
8262
8117
|
if (content !== null) {
|
|
8263
8118
|
await mkdirp(destDir);
|
|
8264
|
-
const destPath =
|
|
8119
|
+
const destPath = join(destDir, "_root.md");
|
|
8265
8120
|
const stripped = sourcePath === agentsPath || sourcePath === globalAgentsPath || sourcePath === globalOverridePath ? stripCodexRuleIndex(content) : content;
|
|
8266
8121
|
const split = await splitEmbeddedRulesToCanonical({
|
|
8267
8122
|
content: stripped,
|
|
@@ -8299,16 +8154,16 @@ async function importCodexRules(projectRoot, results, normalize, normalizeWindsu
|
|
|
8299
8154
|
fromTool: "codex-cli",
|
|
8300
8155
|
normalize,
|
|
8301
8156
|
mapEntry: async ({ srcPath, normalizeTo }) => {
|
|
8302
|
-
const relDir =
|
|
8157
|
+
const relDir = relative(projectRoot, dirname(srcPath)).replace(/\\/g, "/");
|
|
8303
8158
|
const isOverride = srcPath.endsWith("/AGENTS.override.md");
|
|
8304
8159
|
if (!relDir || relDir === ".") return null;
|
|
8305
8160
|
if (!isOverride && !srcPath.endsWith("/AGENTS.md")) return null;
|
|
8306
8161
|
const ruleName = relDir.replace(/\//g, "-");
|
|
8307
8162
|
if (!shouldImportScopedAgentsRule(relDir)) {
|
|
8308
|
-
await removePathIfExists(
|
|
8163
|
+
await removePathIfExists(join(destDir, `${ruleName}.md`));
|
|
8309
8164
|
return null;
|
|
8310
8165
|
}
|
|
8311
|
-
const destPath =
|
|
8166
|
+
const destPath = join(destDir, `${ruleName}.md`);
|
|
8312
8167
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
8313
8168
|
return {
|
|
8314
8169
|
destPath,
|
|
@@ -8332,15 +8187,15 @@ async function importCodexRules(projectRoot, results, normalize, normalizeWindsu
|
|
|
8332
8187
|
}
|
|
8333
8188
|
async function importInstructionMirrors(projectRoot, destDir, results, normalize) {
|
|
8334
8189
|
try {
|
|
8335
|
-
const files = await readDirRecursive(
|
|
8190
|
+
const files = await readDirRecursive(join(projectRoot, CODEX_INSTRUCTIONS_DIR));
|
|
8336
8191
|
const instructionFiles = files.filter((file) => file.endsWith(".md"));
|
|
8337
|
-
const instructionsRoot =
|
|
8192
|
+
const instructionsRoot = join(projectRoot, CODEX_INSTRUCTIONS_DIR);
|
|
8338
8193
|
for (const srcPath of instructionFiles) {
|
|
8339
|
-
const relativePath =
|
|
8194
|
+
const relativePath = relative(instructionsRoot, srcPath).replace(/\\/g, "/");
|
|
8340
8195
|
if (relativePath === "_root.md") continue;
|
|
8341
8196
|
const content = await readFileSafe(srcPath);
|
|
8342
8197
|
if (!content) continue;
|
|
8343
|
-
const destPath =
|
|
8198
|
+
const destPath = join(destDir, relativePath);
|
|
8344
8199
|
const { frontmatter, body } = parseFrontmatter(normalize(content, srcPath, destPath));
|
|
8345
8200
|
await mkdirp(destDir);
|
|
8346
8201
|
const outFm = frontmatter.root === true ? frontmatter : { ...frontmatter, root: false };
|
|
@@ -8373,9 +8228,6 @@ async function importFromCodex(projectRoot, options) {
|
|
|
8373
8228
|
await importMcp3(projectRoot, results);
|
|
8374
8229
|
return results;
|
|
8375
8230
|
}
|
|
8376
|
-
|
|
8377
|
-
// src/targets/codex-cli/linter.ts
|
|
8378
|
-
import { relative as relative14 } from "path";
|
|
8379
8231
|
function lintRules9(canonical, projectRoot, _projectFiles) {
|
|
8380
8232
|
const { rules } = canonical;
|
|
8381
8233
|
if (rules.length === 0) return [];
|
|
@@ -8384,7 +8236,7 @@ function lintRules9(canonical, projectRoot, _projectFiles) {
|
|
|
8384
8236
|
return [
|
|
8385
8237
|
{
|
|
8386
8238
|
level: "warning",
|
|
8387
|
-
file:
|
|
8239
|
+
file: relative(projectRoot, rules[0].source),
|
|
8388
8240
|
target: CODEX_TARGET,
|
|
8389
8241
|
message: "Codex needs a root rule to generate AGENTS.md. Add root: true to a rule."
|
|
8390
8242
|
}
|
|
@@ -8541,9 +8393,6 @@ var descriptor9 = {
|
|
|
8541
8393
|
]
|
|
8542
8394
|
};
|
|
8543
8395
|
|
|
8544
|
-
// src/targets/windsurf/generator/rules.ts
|
|
8545
|
-
import { basename as basename27 } from "path";
|
|
8546
|
-
|
|
8547
8396
|
// src/targets/windsurf/constants.ts
|
|
8548
8397
|
var WINDSURF_TARGET = "windsurf";
|
|
8549
8398
|
var WINDSURF_RULES_ROOT = ".windsurfrules";
|
|
@@ -8573,7 +8422,7 @@ var WINDSURF_GLOBAL_AGENTS_SKILLS_DIR = ".agents/skills";
|
|
|
8573
8422
|
|
|
8574
8423
|
// src/targets/windsurf/generator/rules.ts
|
|
8575
8424
|
function ruleSlug4(source) {
|
|
8576
|
-
const name =
|
|
8425
|
+
const name = basename(source, ".md");
|
|
8577
8426
|
return name === "_root" ? "root" : name;
|
|
8578
8427
|
}
|
|
8579
8428
|
function directoryScopedRuleDir(globs) {
|
|
@@ -8717,12 +8566,6 @@ function generateSkills10(canonical) {
|
|
|
8717
8566
|
}
|
|
8718
8567
|
return outputs;
|
|
8719
8568
|
}
|
|
8720
|
-
|
|
8721
|
-
// src/targets/windsurf/importer.ts
|
|
8722
|
-
import { join as join54, dirname as dirname20, relative as relative16 } from "path";
|
|
8723
|
-
|
|
8724
|
-
// src/targets/windsurf/importer-workflows.ts
|
|
8725
|
-
import { join as join51, relative as relative15 } from "path";
|
|
8726
8569
|
function toStringArray8(value) {
|
|
8727
8570
|
if (Array.isArray(value)) {
|
|
8728
8571
|
return value.filter((entry) => typeof entry === "string").map((entry) => entry.trim()).filter(Boolean);
|
|
@@ -8733,16 +8576,16 @@ function toStringArray8(value) {
|
|
|
8733
8576
|
return [];
|
|
8734
8577
|
}
|
|
8735
8578
|
async function importWorkflows(projectRoot, results, normalize) {
|
|
8736
|
-
const workflowsDir =
|
|
8579
|
+
const workflowsDir = join(projectRoot, WINDSURF_WORKFLOWS_DIR);
|
|
8737
8580
|
const workflowFiles = await readDirRecursive(workflowsDir);
|
|
8738
8581
|
const workflowMdFiles = workflowFiles.filter((f) => f.endsWith(".md"));
|
|
8739
|
-
const destCommandsDir =
|
|
8582
|
+
const destCommandsDir = join(projectRoot, WINDSURF_CANONICAL_COMMANDS_DIR);
|
|
8740
8583
|
for (const srcPath of workflowMdFiles) {
|
|
8741
8584
|
const content = await readFileSafe(srcPath);
|
|
8742
8585
|
if (!content) continue;
|
|
8743
|
-
const relativePath =
|
|
8586
|
+
const relativePath = relative(workflowsDir, srcPath).replace(/\\/g, "/");
|
|
8744
8587
|
await mkdirp(destCommandsDir);
|
|
8745
|
-
const destPath =
|
|
8588
|
+
const destPath = join(destCommandsDir, relativePath);
|
|
8746
8589
|
const normalized = normalize(content, srcPath, destPath);
|
|
8747
8590
|
const { frontmatter, body } = parseFrontmatter(normalized);
|
|
8748
8591
|
const outContent = await serializeImportedCommandWithFallback(
|
|
@@ -8767,11 +8610,8 @@ async function importWorkflows(projectRoot, results, normalize) {
|
|
|
8767
8610
|
});
|
|
8768
8611
|
}
|
|
8769
8612
|
}
|
|
8770
|
-
|
|
8771
|
-
// src/targets/windsurf/skills-adapter.ts
|
|
8772
|
-
import { join as join52 } from "path";
|
|
8773
8613
|
async function importSkills4(projectRoot, results, normalize, skillsRelDir = WINDSURF_SKILLS_DIR) {
|
|
8774
|
-
const skillsDir =
|
|
8614
|
+
const skillsDir = join(projectRoot, skillsRelDir);
|
|
8775
8615
|
const directorySkills = await findDirectorySkills(skillsDir);
|
|
8776
8616
|
const options = {
|
|
8777
8617
|
projectRoot,
|
|
@@ -8782,16 +8622,16 @@ async function importSkills4(projectRoot, results, normalize, skillsRelDir = WIN
|
|
|
8782
8622
|
results
|
|
8783
8623
|
};
|
|
8784
8624
|
for (const [skillName, skillDir] of directorySkills) {
|
|
8785
|
-
const skillMdPath =
|
|
8625
|
+
const skillMdPath = join(skillDir, "SKILL.md");
|
|
8786
8626
|
const content = await readFileSafe(skillMdPath);
|
|
8787
8627
|
if (!content) continue;
|
|
8788
8628
|
const rawParsed = parseFrontmatter(content);
|
|
8789
8629
|
const projectedAgent = parseProjectedAgentSkillFrontmatter(rawParsed.frontmatter, skillName);
|
|
8790
8630
|
if (projectedAgent) {
|
|
8791
|
-
await removePathIfExists(
|
|
8792
|
-
const destAgentsDir =
|
|
8631
|
+
await removePathIfExists(join(projectRoot, WINDSURF_CANONICAL_SKILLS_DIR, skillName));
|
|
8632
|
+
const destAgentsDir = join(projectRoot, WINDSURF_CANONICAL_AGENTS_DIR);
|
|
8793
8633
|
await mkdirp(destAgentsDir);
|
|
8794
|
-
const agentPath =
|
|
8634
|
+
const agentPath = join(destAgentsDir, `${projectedAgent.name}.md`);
|
|
8795
8635
|
await writeFileAtomic(
|
|
8796
8636
|
agentPath,
|
|
8797
8637
|
serializeImportedAgent(projectedAgent, normalize(rawParsed.body, skillMdPath, agentPath))
|
|
@@ -8807,12 +8647,8 @@ async function importSkills4(projectRoot, results, normalize, skillsRelDir = WIN
|
|
|
8807
8647
|
await importDirectorySkill(skillName, skillDir, options);
|
|
8808
8648
|
}
|
|
8809
8649
|
}
|
|
8810
|
-
|
|
8811
|
-
// src/targets/windsurf/importer-hooks-mcp.ts
|
|
8812
|
-
import { dirname as dirname19, join as join53 } from "path";
|
|
8813
|
-
import { stringify as yamlStringify8 } from "yaml";
|
|
8814
8650
|
async function importWindsurfHooks(projectRoot, results) {
|
|
8815
|
-
const hooksPath =
|
|
8651
|
+
const hooksPath = join(projectRoot, WINDSURF_HOOKS_FILE);
|
|
8816
8652
|
const hooksContent = await readFileSafe(hooksPath);
|
|
8817
8653
|
if (!hooksContent) return;
|
|
8818
8654
|
try {
|
|
@@ -8820,9 +8656,9 @@ async function importWindsurfHooks(projectRoot, results) {
|
|
|
8820
8656
|
if (!parsed.hooks || typeof parsed.hooks !== "object" || Array.isArray(parsed.hooks)) return;
|
|
8821
8657
|
const canonical = windsurfHooksToCanonical(parsed.hooks);
|
|
8822
8658
|
if (Object.keys(canonical).length === 0) return;
|
|
8823
|
-
const destPath =
|
|
8824
|
-
await mkdirp(
|
|
8825
|
-
await writeFileAtomic(destPath,
|
|
8659
|
+
const destPath = join(projectRoot, WINDSURF_CANONICAL_HOOKS);
|
|
8660
|
+
await mkdirp(dirname(destPath));
|
|
8661
|
+
await writeFileAtomic(destPath, stringify(canonical));
|
|
8826
8662
|
results.push({
|
|
8827
8663
|
fromTool: WINDSURF_TARGET,
|
|
8828
8664
|
fromPath: hooksPath,
|
|
@@ -8883,14 +8719,14 @@ function windsurfHooksToCanonical(hooks) {
|
|
|
8883
8719
|
async function importWindsurfMcp(projectRoot, results) {
|
|
8884
8720
|
const sourceCandidates = [WINDSURF_MCP_EXAMPLE_FILE, WINDSURF_MCP_CONFIG_FILE];
|
|
8885
8721
|
for (const relPath of sourceCandidates) {
|
|
8886
|
-
const srcPath =
|
|
8722
|
+
const srcPath = join(projectRoot, relPath);
|
|
8887
8723
|
const content = await readFileSafe(srcPath);
|
|
8888
8724
|
if (!content) continue;
|
|
8889
8725
|
try {
|
|
8890
8726
|
const parsed = JSON.parse(content);
|
|
8891
8727
|
if (!parsed.mcpServers || typeof parsed.mcpServers !== "object") continue;
|
|
8892
|
-
const destPath =
|
|
8893
|
-
await mkdirp(
|
|
8728
|
+
const destPath = join(projectRoot, WINDSURF_CANONICAL_MCP);
|
|
8729
|
+
await mkdirp(dirname(destPath));
|
|
8894
8730
|
await writeFileAtomic(destPath, JSON.stringify({ mcpServers: parsed.mcpServers }, null, 2));
|
|
8895
8731
|
results.push({
|
|
8896
8732
|
fromTool: WINDSURF_TARGET,
|
|
@@ -8910,12 +8746,12 @@ async function importFromWindsurf(projectRoot, options) {
|
|
|
8910
8746
|
const results = [];
|
|
8911
8747
|
const normalize = await createImportReferenceNormalizer(WINDSURF_TARGET, projectRoot);
|
|
8912
8748
|
const normalizeCodex = await createImportReferenceNormalizer("codex-cli", projectRoot);
|
|
8913
|
-
const destRulesDir =
|
|
8914
|
-
const rootPath =
|
|
8749
|
+
const destRulesDir = join(projectRoot, WINDSURF_CANONICAL_RULES_DIR);
|
|
8750
|
+
const rootPath = join(projectRoot, WINDSURF_RULES_ROOT);
|
|
8915
8751
|
const rootContent = await readFileSafe(rootPath);
|
|
8916
8752
|
if (rootContent !== null) {
|
|
8917
8753
|
await mkdirp(destRulesDir);
|
|
8918
|
-
const destPath =
|
|
8754
|
+
const destPath = join(destRulesDir, "_root.md");
|
|
8919
8755
|
const body = normalize(rootContent, rootPath, destPath).trim();
|
|
8920
8756
|
const outContent = await serializeImportedRuleWithFallback(destPath, { root: true }, body);
|
|
8921
8757
|
await writeFileAtomic(destPath, outContent);
|
|
@@ -8927,11 +8763,11 @@ async function importFromWindsurf(projectRoot, options) {
|
|
|
8927
8763
|
});
|
|
8928
8764
|
}
|
|
8929
8765
|
if (rootContent === null) {
|
|
8930
|
-
const agentsMdPath =
|
|
8766
|
+
const agentsMdPath = join(projectRoot, WINDSURF_AGENTS_MD);
|
|
8931
8767
|
const agentsMdContent = await readFileSafe(agentsMdPath);
|
|
8932
8768
|
if (agentsMdContent !== null) {
|
|
8933
8769
|
await mkdirp(destRulesDir);
|
|
8934
|
-
const destPath =
|
|
8770
|
+
const destPath = join(destRulesDir, "_root.md");
|
|
8935
8771
|
const body = normalize(
|
|
8936
8772
|
normalizeCodex(agentsMdContent, agentsMdPath, destPath),
|
|
8937
8773
|
agentsMdPath,
|
|
@@ -8956,14 +8792,14 @@ async function importFromWindsurf(projectRoot, options) {
|
|
|
8956
8792
|
fromTool: "windsurf",
|
|
8957
8793
|
normalize,
|
|
8958
8794
|
mapEntry: async ({ srcPath, normalizeTo }) => {
|
|
8959
|
-
const relDir =
|
|
8795
|
+
const relDir = relative(projectRoot, dirname(srcPath)).replace(/\\/g, "/");
|
|
8960
8796
|
if (!relDir || relDir === "." || !srcPath.endsWith("/AGENTS.md")) return null;
|
|
8961
8797
|
const ruleName = relDir.replace(/\//g, "-");
|
|
8962
8798
|
if (!shouldImportScopedAgentsRule(relDir)) {
|
|
8963
|
-
await removePathIfExists(
|
|
8799
|
+
await removePathIfExists(join(destRulesDir, `${ruleName}.md`));
|
|
8964
8800
|
return null;
|
|
8965
8801
|
}
|
|
8966
|
-
const destPath =
|
|
8802
|
+
const destPath = join(destRulesDir, `${ruleName}.md`);
|
|
8967
8803
|
return {
|
|
8968
8804
|
destPath,
|
|
8969
8805
|
toPath: `${WINDSURF_CANONICAL_RULES_DIR}/${ruleName}.md`,
|
|
@@ -8978,7 +8814,7 @@ async function importFromWindsurf(projectRoot, options) {
|
|
|
8978
8814
|
})
|
|
8979
8815
|
);
|
|
8980
8816
|
}
|
|
8981
|
-
const rulesDir =
|
|
8817
|
+
const rulesDir = join(projectRoot, WINDSURF_RULES_DIR);
|
|
8982
8818
|
results.push(
|
|
8983
8819
|
...await importFileDirectory({
|
|
8984
8820
|
srcDir: rulesDir,
|
|
@@ -8988,7 +8824,7 @@ async function importFromWindsurf(projectRoot, options) {
|
|
|
8988
8824
|
normalize,
|
|
8989
8825
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
8990
8826
|
if (relativePath === "_root.md" && rootContent !== null) return null;
|
|
8991
|
-
const destPath =
|
|
8827
|
+
const destPath = join(destRulesDir, relativePath);
|
|
8992
8828
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
8993
8829
|
const normalizedFrontmatter = { ...frontmatter };
|
|
8994
8830
|
if (typeof normalizedFrontmatter.glob === "string" && normalizedFrontmatter.glob.trim()) {
|
|
@@ -9008,10 +8844,10 @@ async function importFromWindsurf(projectRoot, options) {
|
|
|
9008
8844
|
}
|
|
9009
8845
|
})
|
|
9010
8846
|
);
|
|
9011
|
-
let ignorePath =
|
|
8847
|
+
let ignorePath = join(projectRoot, WINDSURF_IGNORE);
|
|
9012
8848
|
let ignoreContent = await readFileSafe(ignorePath);
|
|
9013
8849
|
if (ignoreContent === null || !ignoreContent.trim()) {
|
|
9014
|
-
ignorePath =
|
|
8850
|
+
ignorePath = join(projectRoot, CODEIUM_IGNORE);
|
|
9015
8851
|
ignoreContent = await readFileSafe(ignorePath);
|
|
9016
8852
|
}
|
|
9017
8853
|
if (ignoreContent !== null && ignoreContent.trim()) {
|
|
@@ -9022,8 +8858,8 @@ async function importFromWindsurf(projectRoot, options) {
|
|
|
9022
8858
|
if (t && !t.startsWith("#")) patterns.push(t);
|
|
9023
8859
|
}
|
|
9024
8860
|
if (patterns.length > 0) {
|
|
9025
|
-
await mkdirp(
|
|
9026
|
-
const destIgnorePath =
|
|
8861
|
+
await mkdirp(join(projectRoot, ".agentsmesh"));
|
|
8862
|
+
const destIgnorePath = join(projectRoot, WINDSURF_CANONICAL_IGNORE);
|
|
9027
8863
|
await writeFileAtomic(destIgnorePath, patterns.join("\n"));
|
|
9028
8864
|
results.push({
|
|
9029
8865
|
fromTool: "windsurf",
|
|
@@ -9039,9 +8875,6 @@ async function importFromWindsurf(projectRoot, options) {
|
|
|
9039
8875
|
await importWindsurfMcp(projectRoot, results);
|
|
9040
8876
|
return results;
|
|
9041
8877
|
}
|
|
9042
|
-
|
|
9043
|
-
// src/targets/windsurf/linter.ts
|
|
9044
|
-
import { relative as relative17 } from "path";
|
|
9045
8878
|
function lintRules10(canonical, projectRoot, _projectFiles) {
|
|
9046
8879
|
const diags = [];
|
|
9047
8880
|
const { rules } = canonical;
|
|
@@ -9050,7 +8883,7 @@ function lintRules10(canonical, projectRoot, _projectFiles) {
|
|
|
9050
8883
|
if (!hasRoot) {
|
|
9051
8884
|
diags.push({
|
|
9052
8885
|
level: "warning",
|
|
9053
|
-
file:
|
|
8886
|
+
file: relative(projectRoot, rules[0].source),
|
|
9054
8887
|
target: WINDSURF_TARGET,
|
|
9055
8888
|
message: "Windsurf needs a root rule to generate AGENTS.md. Add root: true to a rule."
|
|
9056
8889
|
});
|
|
@@ -9233,9 +9066,6 @@ var descriptor10 = {
|
|
|
9233
9066
|
buildImportPaths: buildWindsurfImportPaths,
|
|
9234
9067
|
detectionPaths: [".windsurfrules", ".windsurf"]
|
|
9235
9068
|
};
|
|
9236
|
-
|
|
9237
|
-
// src/targets/antigravity/generator.ts
|
|
9238
|
-
import { basename as basename28 } from "path";
|
|
9239
9069
|
function generateRules11(canonical) {
|
|
9240
9070
|
const root = canonical.rules.find((r) => r.root);
|
|
9241
9071
|
if (!root) return [];
|
|
@@ -9245,7 +9075,7 @@ function generateRules11(canonical) {
|
|
|
9245
9075
|
for (const rule of canonical.rules) {
|
|
9246
9076
|
if (rule.root) continue;
|
|
9247
9077
|
if (rule.targets.length > 0 && !rule.targets.includes("antigravity")) continue;
|
|
9248
|
-
const slug =
|
|
9078
|
+
const slug = basename(rule.source, ".md");
|
|
9249
9079
|
outputs.push({
|
|
9250
9080
|
path: `${ANTIGRAVITY_RULES_DIR}/${slug}.md`,
|
|
9251
9081
|
content: rule.body.trim() || ""
|
|
@@ -9286,12 +9116,9 @@ function renderAntigravityGlobalInstructions(canonical) {
|
|
|
9286
9116
|
});
|
|
9287
9117
|
return appendEmbeddedRulesBlock(root?.body.trim() ?? "", nonRootRules);
|
|
9288
9118
|
}
|
|
9289
|
-
|
|
9290
|
-
// src/targets/antigravity/importer.ts
|
|
9291
|
-
import { basename as basename29, join as join55 } from "path";
|
|
9292
9119
|
async function importRootRule(projectRoot, results, normalize, scope) {
|
|
9293
|
-
const primary = scope === "global" ?
|
|
9294
|
-
const legacy =
|
|
9120
|
+
const primary = scope === "global" ? join(projectRoot, ANTIGRAVITY_GLOBAL_ROOT) : join(projectRoot, ANTIGRAVITY_RULES_ROOT);
|
|
9121
|
+
const legacy = join(projectRoot, ANTIGRAVITY_RULES_ROOT_LEGACY);
|
|
9295
9122
|
let srcPath = primary;
|
|
9296
9123
|
let content = await readFileSafe(primary);
|
|
9297
9124
|
if (scope === "project" && content === null) {
|
|
@@ -9299,7 +9126,7 @@ async function importRootRule(projectRoot, results, normalize, scope) {
|
|
|
9299
9126
|
content = await readFileSafe(legacy);
|
|
9300
9127
|
}
|
|
9301
9128
|
if (content === null) return;
|
|
9302
|
-
const destPath =
|
|
9129
|
+
const destPath = join(projectRoot, ANTIGRAVITY_CANONICAL_ROOT_RULE);
|
|
9303
9130
|
const split = await splitEmbeddedRulesToCanonical({
|
|
9304
9131
|
content,
|
|
9305
9132
|
projectRoot,
|
|
@@ -9311,7 +9138,7 @@ async function importRootRule(projectRoot, results, normalize, scope) {
|
|
|
9311
9138
|
results.push(...split.results);
|
|
9312
9139
|
const { body } = parseFrontmatter(normalize(split.rootContent, srcPath, destPath));
|
|
9313
9140
|
const output = await serializeImportedRuleWithFallback(destPath, { root: true }, body);
|
|
9314
|
-
await mkdirp(
|
|
9141
|
+
await mkdirp(join(projectRoot, ANTIGRAVITY_CANONICAL_RULES_DIR));
|
|
9315
9142
|
await writeFileAtomic(destPath, output);
|
|
9316
9143
|
results.push({
|
|
9317
9144
|
fromTool: ANTIGRAVITY_TARGET,
|
|
@@ -9321,8 +9148,8 @@ async function importRootRule(projectRoot, results, normalize, scope) {
|
|
|
9321
9148
|
});
|
|
9322
9149
|
}
|
|
9323
9150
|
async function importNonRootRules2(projectRoot, results, normalize) {
|
|
9324
|
-
const srcDir =
|
|
9325
|
-
const destDir =
|
|
9151
|
+
const srcDir = join(projectRoot, ANTIGRAVITY_RULES_DIR);
|
|
9152
|
+
const destDir = join(projectRoot, ANTIGRAVITY_CANONICAL_RULES_DIR);
|
|
9326
9153
|
results.push(
|
|
9327
9154
|
...await importFileDirectory({
|
|
9328
9155
|
srcDir,
|
|
@@ -9331,9 +9158,9 @@ async function importNonRootRules2(projectRoot, results, normalize) {
|
|
|
9331
9158
|
fromTool: ANTIGRAVITY_TARGET,
|
|
9332
9159
|
normalize,
|
|
9333
9160
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
9334
|
-
if (
|
|
9161
|
+
if (basename(relativePath) === "general.md" || basename(relativePath) === "_root.md")
|
|
9335
9162
|
return null;
|
|
9336
|
-
const destPath =
|
|
9163
|
+
const destPath = join(destDir, relativePath);
|
|
9337
9164
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
9338
9165
|
const output = await serializeImportedRuleWithFallback(
|
|
9339
9166
|
destPath,
|
|
@@ -9356,8 +9183,8 @@ async function importNonRootRules2(projectRoot, results, normalize) {
|
|
|
9356
9183
|
}
|
|
9357
9184
|
async function importWorkflows2(projectRoot, results, normalize, scope) {
|
|
9358
9185
|
const workflowsRel = scope === "global" ? ANTIGRAVITY_GLOBAL_WORKFLOWS_DIR : ANTIGRAVITY_WORKFLOWS_DIR;
|
|
9359
|
-
const srcDir =
|
|
9360
|
-
const destDir =
|
|
9186
|
+
const srcDir = join(projectRoot, workflowsRel);
|
|
9187
|
+
const destDir = join(projectRoot, ANTIGRAVITY_CANONICAL_COMMANDS_DIR);
|
|
9361
9188
|
results.push(
|
|
9362
9189
|
...await importFileDirectory({
|
|
9363
9190
|
srcDir,
|
|
@@ -9366,7 +9193,7 @@ async function importWorkflows2(projectRoot, results, normalize, scope) {
|
|
|
9366
9193
|
fromTool: ANTIGRAVITY_TARGET,
|
|
9367
9194
|
normalize,
|
|
9368
9195
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
9369
|
-
const destPath =
|
|
9196
|
+
const destPath = join(destDir, relativePath);
|
|
9370
9197
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
9371
9198
|
const normalized = await serializeImportedCommandWithFallback(
|
|
9372
9199
|
destPath,
|
|
@@ -9389,7 +9216,7 @@ async function importWorkflows2(projectRoot, results, normalize, scope) {
|
|
|
9389
9216
|
);
|
|
9390
9217
|
}
|
|
9391
9218
|
async function importMcp4(projectRoot, results) {
|
|
9392
|
-
const mcpPath =
|
|
9219
|
+
const mcpPath = join(projectRoot, ANTIGRAVITY_GLOBAL_MCP_CONFIG);
|
|
9393
9220
|
const content = await readFileSafe(mcpPath);
|
|
9394
9221
|
if (!content) return;
|
|
9395
9222
|
let parsed;
|
|
@@ -9399,8 +9226,8 @@ async function importMcp4(projectRoot, results) {
|
|
|
9399
9226
|
return;
|
|
9400
9227
|
}
|
|
9401
9228
|
if (!parsed || typeof parsed !== "object" || !("mcpServers" in parsed)) return;
|
|
9402
|
-
const destPath =
|
|
9403
|
-
await mkdirp(
|
|
9229
|
+
const destPath = join(projectRoot, ANTIGRAVITY_CANONICAL_MCP);
|
|
9230
|
+
await mkdirp(join(projectRoot, ".agentsmesh"));
|
|
9404
9231
|
await writeFileAtomic(destPath, content);
|
|
9405
9232
|
results.push({
|
|
9406
9233
|
fromTool: ANTIGRAVITY_TARGET,
|
|
@@ -9549,14 +9376,6 @@ var descriptor11 = {
|
|
|
9549
9376
|
".agents/workflows/"
|
|
9550
9377
|
]
|
|
9551
9378
|
};
|
|
9552
|
-
|
|
9553
|
-
// src/targets/roo-code/index.ts
|
|
9554
|
-
import { join as join58, basename as basename31 } from "path";
|
|
9555
|
-
import { stringify as yamlStringify10 } from "yaml";
|
|
9556
|
-
|
|
9557
|
-
// src/targets/roo-code/generator.ts
|
|
9558
|
-
import { basename as basename30 } from "path";
|
|
9559
|
-
import { stringify as yamlStringify9 } from "yaml";
|
|
9560
9379
|
function generateRules12(canonical) {
|
|
9561
9380
|
const outputs = [];
|
|
9562
9381
|
const root = canonical.rules.find((rule) => rule.root);
|
|
@@ -9569,7 +9388,7 @@ function generateRules12(canonical) {
|
|
|
9569
9388
|
for (const rule of canonical.rules) {
|
|
9570
9389
|
if (rule.root) continue;
|
|
9571
9390
|
if (rule.targets.length > 0 && !rule.targets.includes(ROO_CODE_TARGET)) continue;
|
|
9572
|
-
const slug =
|
|
9391
|
+
const slug = basename(rule.source, ".md");
|
|
9573
9392
|
outputs.push({
|
|
9574
9393
|
path: `${ROO_CODE_RULES_DIR}/${slug}.md`,
|
|
9575
9394
|
content: rule.body.trim() || ""
|
|
@@ -9606,21 +9425,14 @@ function generateSkills12(canonical) {
|
|
|
9606
9425
|
function generateAgents10(canonical) {
|
|
9607
9426
|
if (canonical.agents.length === 0) return [];
|
|
9608
9427
|
const customModes = canonical.agents.map((agent) => {
|
|
9609
|
-
const slug =
|
|
9428
|
+
const slug = basename(agent.source, ".md");
|
|
9610
9429
|
const mode = { slug, name: agent.name };
|
|
9611
9430
|
if (agent.description) mode.description = agent.description;
|
|
9612
9431
|
if (agent.body.trim()) mode.roleDefinition = agent.body.trim();
|
|
9613
9432
|
return mode;
|
|
9614
9433
|
});
|
|
9615
|
-
return [{ path: ROO_CODE_MODES_FILE, content:
|
|
9434
|
+
return [{ path: ROO_CODE_MODES_FILE, content: stringify({ customModes }) }];
|
|
9616
9435
|
}
|
|
9617
|
-
|
|
9618
|
-
// src/targets/roo-code/importer.ts
|
|
9619
|
-
import { readdir as readdir4 } from "fs/promises";
|
|
9620
|
-
import { join as join57 } from "path";
|
|
9621
|
-
|
|
9622
|
-
// src/targets/roo-code/importer-commands-mcp-ignore.ts
|
|
9623
|
-
import { join as join56 } from "path";
|
|
9624
9436
|
function readMcpServers4(content) {
|
|
9625
9437
|
const parsed = JSON.parse(content);
|
|
9626
9438
|
const rawServers = parsed.mcpServers;
|
|
@@ -9652,8 +9464,8 @@ function readMcpServers4(content) {
|
|
|
9652
9464
|
return servers;
|
|
9653
9465
|
}
|
|
9654
9466
|
async function importRooCommands(projectRoot, results, normalize) {
|
|
9655
|
-
const srcDir =
|
|
9656
|
-
const destDir =
|
|
9467
|
+
const srcDir = join(projectRoot, ROO_CODE_COMMANDS_DIR);
|
|
9468
|
+
const destDir = join(projectRoot, ROO_CODE_CANONICAL_COMMANDS_DIR);
|
|
9657
9469
|
results.push(
|
|
9658
9470
|
...await importFileDirectory({
|
|
9659
9471
|
srcDir,
|
|
@@ -9662,7 +9474,7 @@ async function importRooCommands(projectRoot, results, normalize) {
|
|
|
9662
9474
|
fromTool: ROO_CODE_TARGET,
|
|
9663
9475
|
normalize,
|
|
9664
9476
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
9665
|
-
const destPath =
|
|
9477
|
+
const destPath = join(destDir, relativePath);
|
|
9666
9478
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
9667
9479
|
const output = await serializeImportedCommandWithFallback(
|
|
9668
9480
|
destPath,
|
|
@@ -9685,13 +9497,13 @@ async function importRooCommands(projectRoot, results, normalize) {
|
|
|
9685
9497
|
);
|
|
9686
9498
|
}
|
|
9687
9499
|
async function importRooMcp(projectRoot, results, scope) {
|
|
9688
|
-
const srcPath = scope === "global" ?
|
|
9500
|
+
const srcPath = scope === "global" ? join(projectRoot, ROO_CODE_GLOBAL_MCP_FILE) : join(projectRoot, ROO_CODE_MCP_FILE);
|
|
9689
9501
|
const content = await readFileSafe(srcPath);
|
|
9690
9502
|
if (content === null) return;
|
|
9691
9503
|
const servers = readMcpServers4(content);
|
|
9692
9504
|
if (Object.keys(servers).length === 0) return;
|
|
9693
9505
|
await writeFileAtomic(
|
|
9694
|
-
|
|
9506
|
+
join(projectRoot, ROO_CODE_CANONICAL_MCP),
|
|
9695
9507
|
JSON.stringify({ mcpServers: servers }, null, 2)
|
|
9696
9508
|
);
|
|
9697
9509
|
results.push({
|
|
@@ -9702,10 +9514,10 @@ async function importRooMcp(projectRoot, results, scope) {
|
|
|
9702
9514
|
});
|
|
9703
9515
|
}
|
|
9704
9516
|
async function importRooIgnore(projectRoot, results) {
|
|
9705
|
-
const srcPath =
|
|
9517
|
+
const srcPath = join(projectRoot, ROO_CODE_IGNORE);
|
|
9706
9518
|
const content = await readFileSafe(srcPath);
|
|
9707
9519
|
if (content === null) return;
|
|
9708
|
-
await writeFileAtomic(
|
|
9520
|
+
await writeFileAtomic(join(projectRoot, ROO_CODE_CANONICAL_IGNORE), content.trimEnd());
|
|
9709
9521
|
results.push({
|
|
9710
9522
|
fromTool: ROO_CODE_TARGET,
|
|
9711
9523
|
fromPath: srcPath,
|
|
@@ -9716,10 +9528,10 @@ async function importRooIgnore(projectRoot, results) {
|
|
|
9716
9528
|
|
|
9717
9529
|
// src/targets/roo-code/importer.ts
|
|
9718
9530
|
async function importRootRule2(projectRoot, results, normalize, scope) {
|
|
9719
|
-
const destPath =
|
|
9531
|
+
const destPath = join(projectRoot, ROO_CODE_CANONICAL_ROOT_RULE);
|
|
9720
9532
|
const sources = scope === "global" ? [ROO_CODE_GLOBAL_AGENTS_MD, ROO_CODE_ROOT_RULE, ROO_CODE_ROOT_RULE_FALLBACK] : [ROO_CODE_ROOT_RULE, ROO_CODE_ROOT_RULE_FALLBACK];
|
|
9721
9533
|
for (const relPath of sources) {
|
|
9722
|
-
const srcPath =
|
|
9534
|
+
const srcPath = join(projectRoot, relPath);
|
|
9723
9535
|
const content = await readFileSafe(srcPath);
|
|
9724
9536
|
if (content === null) continue;
|
|
9725
9537
|
const { frontmatter, body } = parseFrontmatter(normalize(content, srcPath, destPath));
|
|
@@ -9743,8 +9555,8 @@ async function importRootRule2(projectRoot, results, normalize, scope) {
|
|
|
9743
9555
|
}
|
|
9744
9556
|
}
|
|
9745
9557
|
async function importNonRootRules3(projectRoot, results, normalize) {
|
|
9746
|
-
const srcDir =
|
|
9747
|
-
const destDir =
|
|
9558
|
+
const srcDir = join(projectRoot, ROO_CODE_RULES_DIR);
|
|
9559
|
+
const destDir = join(projectRoot, ROO_CODE_CANONICAL_RULES_DIR);
|
|
9748
9560
|
const rootRuleName = "00-root.md";
|
|
9749
9561
|
results.push(
|
|
9750
9562
|
...await importFileDirectory({
|
|
@@ -9755,7 +9567,7 @@ async function importNonRootRules3(projectRoot, results, normalize) {
|
|
|
9755
9567
|
normalize,
|
|
9756
9568
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
9757
9569
|
if (relativePath === rootRuleName) return null;
|
|
9758
|
-
const destPath =
|
|
9570
|
+
const destPath = join(destDir, relativePath);
|
|
9759
9571
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
9760
9572
|
const output = await serializeImportedRuleWithFallback(
|
|
9761
9573
|
destPath,
|
|
@@ -9777,17 +9589,17 @@ async function importNonRootRules3(projectRoot, results, normalize) {
|
|
|
9777
9589
|
);
|
|
9778
9590
|
}
|
|
9779
9591
|
async function importPerModeRules(projectRoot, results, normalize) {
|
|
9780
|
-
const rooDir =
|
|
9592
|
+
const rooDir = join(projectRoot, ROO_CODE_DIR);
|
|
9781
9593
|
let entries;
|
|
9782
9594
|
try {
|
|
9783
|
-
entries = await
|
|
9595
|
+
entries = await readdir(rooDir, { withFileTypes: true });
|
|
9784
9596
|
} catch {
|
|
9785
9597
|
return;
|
|
9786
9598
|
}
|
|
9787
9599
|
const modeRuleDirs = entries.filter((e) => e.isDirectory() && e.name.startsWith("rules-")).map((e) => e.name);
|
|
9788
9600
|
for (const dirName of modeRuleDirs) {
|
|
9789
|
-
const srcDir =
|
|
9790
|
-
const destDir =
|
|
9601
|
+
const srcDir = join(rooDir, dirName);
|
|
9602
|
+
const destDir = join(projectRoot, ROO_CODE_CANONICAL_RULES_DIR);
|
|
9791
9603
|
results.push(
|
|
9792
9604
|
...await importFileDirectory({
|
|
9793
9605
|
srcDir,
|
|
@@ -9796,7 +9608,7 @@ async function importPerModeRules(projectRoot, results, normalize) {
|
|
|
9796
9608
|
fromTool: ROO_CODE_TARGET,
|
|
9797
9609
|
normalize,
|
|
9798
9610
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
9799
|
-
const destPath =
|
|
9611
|
+
const destPath = join(destDir, relativePath);
|
|
9800
9612
|
const { frontmatter, body } = parseFrontmatter(normalizeTo(destPath));
|
|
9801
9613
|
const output = await serializeImportedRuleWithFallback(
|
|
9802
9614
|
destPath,
|
|
@@ -9882,14 +9694,14 @@ var generateRooGlobalExtras = async (canonical, projectRoot, scope, enabledFeatu
|
|
|
9882
9694
|
if (scope !== "global") return [];
|
|
9883
9695
|
if (!enabledFeatures.has("agents") || canonical.agents.length === 0) return [];
|
|
9884
9696
|
const customModes = canonical.agents.map((agent) => {
|
|
9885
|
-
const slug =
|
|
9697
|
+
const slug = basename(agent.source, ".md");
|
|
9886
9698
|
const mode = { slug, name: agent.name };
|
|
9887
9699
|
if (agent.description) mode.description = agent.description;
|
|
9888
9700
|
if (agent.body.trim()) mode.roleDefinition = agent.body.trim();
|
|
9889
9701
|
return mode;
|
|
9890
9702
|
});
|
|
9891
|
-
const content =
|
|
9892
|
-
const existing = await readFileSafe(
|
|
9703
|
+
const content = stringify({ customModes });
|
|
9704
|
+
const existing = await readFileSafe(join(projectRoot, ROO_CODE_GLOBAL_MODES_FILE));
|
|
9893
9705
|
return [
|
|
9894
9706
|
{
|
|
9895
9707
|
target: "roo-code",
|
|
@@ -10030,6 +9842,7 @@ var BUILTIN_TARGETS = [
|
|
|
10030
9842
|
var _builtinTargetsMap;
|
|
10031
9843
|
function builtinTargetsMap() {
|
|
10032
9844
|
if (!_builtinTargetsMap) {
|
|
9845
|
+
assertSharedArtifactOwnersUnique(BUILTIN_TARGETS);
|
|
10033
9846
|
_builtinTargetsMap = new Map(BUILTIN_TARGETS.map((d) => [d.id, d]));
|
|
10034
9847
|
}
|
|
10035
9848
|
return _builtinTargetsMap;
|
|
@@ -10038,33 +9851,17 @@ function getBuiltinTargetDefinition(target13) {
|
|
|
10038
9851
|
return builtinTargetsMap().get(target13);
|
|
10039
9852
|
}
|
|
10040
9853
|
function getTargetCapabilities(target13, scope = "project") {
|
|
10041
|
-
const descriptor13 = getBuiltinTargetDefinition(target13);
|
|
9854
|
+
const descriptor13 = getBuiltinTargetDefinition(target13) ?? getDescriptor(target13);
|
|
10042
9855
|
if (!descriptor13) return void 0;
|
|
10043
9856
|
const raw = scope === "global" ? descriptor13.globalSupport?.capabilities ?? descriptor13.globalCapabilities ?? descriptor13.capabilities : descriptor13.capabilities;
|
|
10044
9857
|
return normalizeTargetCapabilities(raw);
|
|
10045
9858
|
}
|
|
10046
9859
|
|
|
10047
|
-
// src/targets/catalog/registry.ts
|
|
10048
|
-
var descriptorRegistry = /* @__PURE__ */ new Map();
|
|
10049
|
-
var builtinDescriptors = new Map(BUILTIN_TARGETS.map((d) => [d.id, d]));
|
|
10050
|
-
function registerTargetDescriptor(descriptor13) {
|
|
10051
|
-
descriptorRegistry.set(descriptor13.id, descriptor13);
|
|
10052
|
-
}
|
|
10053
|
-
function getDescriptor(name) {
|
|
10054
|
-
return descriptorRegistry.get(name) ?? builtinDescriptors.get(name);
|
|
10055
|
-
}
|
|
10056
|
-
function getAllDescriptors() {
|
|
10057
|
-
return [...descriptorRegistry.values()];
|
|
10058
|
-
}
|
|
10059
|
-
|
|
10060
9860
|
// src/public/targets.ts
|
|
10061
9861
|
function getTargetCatalog() {
|
|
10062
9862
|
return BUILTIN_TARGETS;
|
|
10063
9863
|
}
|
|
10064
|
-
|
|
10065
|
-
|
|
10066
|
-
|
|
10067
|
-
getTargetCatalog,
|
|
10068
|
-
registerTargetDescriptor
|
|
10069
|
-
};
|
|
9864
|
+
|
|
9865
|
+
export { getAllDescriptors, getDescriptor, getTargetCatalog, registerTargetDescriptor };
|
|
9866
|
+
//# sourceMappingURL=targets.js.map
|
|
10070
9867
|
//# sourceMappingURL=targets.js.map
|