agentsmesh 0.21.0 → 0.22.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 +57 -0
- package/README.md +13 -1
- package/dist/canonical.js +22 -2
- package/dist/canonical.js.map +1 -1
- package/dist/cli.js +204 -162
- package/dist/engine.js +122 -4
- package/dist/engine.js.map +1 -1
- package/dist/index.d.ts +1 -0
- package/dist/index.js +592 -221
- package/dist/index.js.map +1 -1
- package/dist/lessons.d.ts +155 -0
- package/dist/lessons.js +305 -0
- package/dist/lessons.js.map +1 -0
- package/dist/targets.js +22 -2
- package/dist/targets.js.map +1 -1
- package/package.json +11 -2
package/dist/index.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { z } from 'zod';
|
|
2
|
-
import {
|
|
3
|
-
import { join,
|
|
2
|
+
import { parse, stringify } from 'yaml';
|
|
3
|
+
import { join, relative, sep, dirname, isAbsolute, resolve, basename, win32, posix, extname } from 'path';
|
|
4
4
|
import { access, readdir, readFile, realpath, stat, rm, mkdir, lstat, unlink, writeFile, rename, chmod, mkdtemp, cp } from 'fs/promises';
|
|
5
|
-
import {
|
|
5
|
+
import { existsSync, readFileSync, writeFileSync, mkdirSync, appendFileSync, constants, realpathSync, statSync } from 'fs';
|
|
6
6
|
import { parse as parse$1 } from 'smol-toml';
|
|
7
7
|
import { Buffer } from 'buffer';
|
|
8
8
|
import { homedir, tmpdir } from 'os';
|
|
@@ -12,6 +12,7 @@ import { fileURLToPath, pathToFileURL, URL } from 'url';
|
|
|
12
12
|
import { promisify } from 'util';
|
|
13
13
|
import * as tar from 'tar';
|
|
14
14
|
import { createTwoFilesPatch } from 'diff';
|
|
15
|
+
import picomatch from 'picomatch';
|
|
15
16
|
|
|
16
17
|
var __defProp = Object.defineProperty;
|
|
17
18
|
var __getOwnPropNames = Object.getOwnPropertyNames;
|
|
@@ -1049,7 +1050,7 @@ ${legacy}`, "");
|
|
|
1049
1050
|
}
|
|
1050
1051
|
return result.trim();
|
|
1051
1052
|
}
|
|
1052
|
-
var ROOT_INSTRUCTION_BODY_V1, ROOT_INSTRUCTION_BODY_V2, ROOT_INSTRUCTION_BODY_V3, ROOT_INSTRUCTION_BODY_V4, ROOT_INSTRUCTION_BODY_V5, ROOT_INSTRUCTION_BODY_V6, ROOT_INSTRUCTION_BODY_V7, ROOT_INSTRUCTION_BODY_V8, ROOT_INSTRUCTION_BODY, LEGACY_AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH, LEGACY_AGENTSMESH_ROOT_INSTRUCTION_SECTION, AGENTSMESH_CONTRACT_WITH_V1_BODY, AGENTSMESH_CONTRACT_WITH_V2_BODY, AGENTSMESH_CONTRACT_WITH_V3_BODY, AGENTSMESH_CONTRACT_WITH_V4_BODY, AGENTSMESH_CONTRACT_WITH_V5_BODY, AGENTSMESH_CONTRACT_WITH_V6_BODY, AGENTSMESH_CONTRACT_WITH_V7_BODY, AGENTSMESH_CONTRACT_WITH_V8_BODY, AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH, LEGACY_FORMS;
|
|
1053
|
+
var ROOT_INSTRUCTION_BODY_V1, ROOT_INSTRUCTION_BODY_V2, ROOT_INSTRUCTION_BODY_V3, ROOT_INSTRUCTION_BODY_V4, ROOT_INSTRUCTION_BODY_V5, ROOT_INSTRUCTION_BODY_V6, ROOT_INSTRUCTION_BODY_V7, ROOT_INSTRUCTION_BODY_V8, ROOT_INSTRUCTION_BODY_V9, ROOT_INSTRUCTION_BODY_V10, ROOT_INSTRUCTION_BODY, LEGACY_AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH, LEGACY_AGENTSMESH_ROOT_INSTRUCTION_SECTION, AGENTSMESH_CONTRACT_WITH_V1_BODY, AGENTSMESH_CONTRACT_WITH_V2_BODY, AGENTSMESH_CONTRACT_WITH_V3_BODY, AGENTSMESH_CONTRACT_WITH_V4_BODY, AGENTSMESH_CONTRACT_WITH_V5_BODY, AGENTSMESH_CONTRACT_WITH_V6_BODY, AGENTSMESH_CONTRACT_WITH_V7_BODY, AGENTSMESH_CONTRACT_WITH_V8_BODY, AGENTSMESH_CONTRACT_WITH_V9_BODY, AGENTSMESH_CONTRACT_WITH_V10_BODY, AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH, LEGACY_FORMS;
|
|
1053
1054
|
var init_root_instruction_paragraph = __esm({
|
|
1054
1055
|
"src/targets/projection/root-instruction-paragraph.ts"() {
|
|
1055
1056
|
init_managed_blocks();
|
|
@@ -1061,7 +1062,9 @@ var init_root_instruction_paragraph = __esm({
|
|
|
1061
1062
|
ROOT_INSTRUCTION_BODY_V6 = "Create canonical files in `.agentsmesh`: `rules/_root.md` and `rules/*.md` are Markdown rules; `commands/*.md`, `agents/*.md`, and `skills/*/SKILL.md` plus supporting files use Claude-style frontmatter Markdown; `mcp.json` is MCP JSON; `hooks.yaml` and `permissions.yaml` are YAML; `ignore` is gitignore-style text. Then run `agentsmesh generate`.";
|
|
1062
1063
|
ROOT_INSTRUCTION_BODY_V7 = "`.agentsmesh` is the only folder you edit or add these files in: `rules/_root.md` and `rules/*.md` are Markdown rules; `commands/*.md`, `agents/*.md`, and `skills/*/SKILL.md` plus supporting files use Claude-style frontmatter Markdown; `mcp.json` is MCP JSON; `hooks.yaml` and `permissions.yaml` are YAML; `ignore` is gitignore-style text. Do not edit generated tool files; run `agentsmesh generate`.";
|
|
1063
1064
|
ROOT_INSTRUCTION_BODY_V8 = "`agentsmesh.yaml` selects targets/features (`agentsmesh.local.yaml` overrides locally), and `.agentsmesh` is the only place to add or edit canonical items: `rules/_root.md`, `rules/*.md`, `commands/*.md`, `agents/*.md`, `skills/*/SKILL.md` plus supporting files, `mcp.json`, `hooks.yaml`, `permissions.yaml`, and `ignore`; if missing run `agentsmesh init`, use `agentsmesh import --from <tool>` for native configs, `agentsmesh install <source>` or `install --sync` for reusable packs, then run `agentsmesh generate`. Use `diff`, `lint`, `check`, `watch`, `matrix`, and `merge` as needed; never edit generated tool files.";
|
|
1064
|
-
|
|
1065
|
+
ROOT_INSTRUCTION_BODY_V9 = "`agentsmesh.yaml` selects targets/features (`agentsmesh.local.yaml` overrides locally), and `.agentsmesh` is the only place to add or edit canonical items: `rules/_root.md`, `rules/*.md`, `commands/*.md`, `agents/*.md`, `skills/*/SKILL.md` plus supporting files, `mcp.json`, `hooks.yaml`, `permissions.yaml`, and `ignore`; if missing run `agentsmesh init`, use `agentsmesh import --from <tool>` for native configs, `agentsmesh install <source>` or `install --sync` for reusable packs, then run `agentsmesh generate`. Use `diff`, `lint`, `check`, `watch`, `matrix`, `merge`, and `refresh` as needed; never edit generated tool files.";
|
|
1066
|
+
ROOT_INSTRUCTION_BODY_V10 = "**MUST follow when changing any rule, agent, command, skill, hook, MCP server, permission, or ignore pattern.** `agentsmesh.yaml` selects targets/features (`agentsmesh.local.yaml` overrides locally), and `.agentsmesh` is the only place to add or edit canonical items: `rules/_root.md`, `rules/*.md`, `commands/*.md`, `agents/*.md`, `skills/*/SKILL.md` plus supporting files, `mcp.json`, `hooks.yaml`, `permissions.yaml`, and `ignore`; if missing run `agentsmesh init`, use `agentsmesh import --from <tool>` for native configs, `agentsmesh install <source>` or `install --sync` for reusable packs, then run `agentsmesh generate`. Use `diff`, `lint`, `check`, `watch`, `matrix`, `merge`, and `refresh` as needed; never edit generated tool files.";
|
|
1067
|
+
ROOT_INSTRUCTION_BODY = "**NEVER edit generated files** (`.claude/`, `.cursor/`, `AGENTS.md`, `.github/copilot-instructions.md`, and similar target outputs) \u2014 `agentsmesh generate` overwrites them. **All changes MUST go through `.agentsmesh` first**: edit `rules/_root.md`, `rules/*.md`, `commands/*.md`, `agents/*.md`, `skills/*/SKILL.md` plus supporting files, `mcp.json`, `hooks.yaml`, `permissions.yaml`, and `ignore`; `agentsmesh.yaml` selects targets/features (`agentsmesh.local.yaml` overrides locally); if missing run `agentsmesh init`, use `agentsmesh import --from <tool>` for native configs, `agentsmesh install <source>` or `install --sync` for reusable packs, then run `agentsmesh generate`. Use `diff`, `lint`, `check`, `watch`, `matrix`, `merge`, and `refresh` as needed.";
|
|
1065
1068
|
LEGACY_AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH = ROOT_INSTRUCTION_BODY_V1;
|
|
1066
1069
|
LEGACY_AGENTSMESH_ROOT_INSTRUCTION_SECTION = `## Project-Specific Rules
|
|
1067
1070
|
|
|
@@ -1090,12 +1093,20 @@ ${ROOT_INSTRUCTION_BODY_V7}`;
|
|
|
1090
1093
|
AGENTSMESH_CONTRACT_WITH_V8_BODY = `## AgentsMesh Generation Contract
|
|
1091
1094
|
|
|
1092
1095
|
${ROOT_INSTRUCTION_BODY_V8}`;
|
|
1096
|
+
AGENTSMESH_CONTRACT_WITH_V9_BODY = `## AgentsMesh Generation Contract
|
|
1097
|
+
|
|
1098
|
+
${ROOT_INSTRUCTION_BODY_V9}`;
|
|
1099
|
+
AGENTSMESH_CONTRACT_WITH_V10_BODY = `## AgentsMesh Generation Contract
|
|
1100
|
+
|
|
1101
|
+
${ROOT_INSTRUCTION_BODY_V10}`;
|
|
1093
1102
|
AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH = `${ROOT_CONTRACT_START}
|
|
1094
1103
|
## AgentsMesh Generation Contract
|
|
1095
1104
|
|
|
1096
1105
|
${ROOT_INSTRUCTION_BODY}
|
|
1097
1106
|
${ROOT_CONTRACT_END}`;
|
|
1098
1107
|
LEGACY_FORMS = [
|
|
1108
|
+
AGENTSMESH_CONTRACT_WITH_V10_BODY,
|
|
1109
|
+
AGENTSMESH_CONTRACT_WITH_V9_BODY,
|
|
1099
1110
|
AGENTSMESH_CONTRACT_WITH_V8_BODY,
|
|
1100
1111
|
AGENTSMESH_CONTRACT_WITH_V7_BODY,
|
|
1101
1112
|
AGENTSMESH_CONTRACT_WITH_V6_BODY,
|
|
@@ -1275,7 +1286,7 @@ function generateEmbeddedSkills(canonical, skillsDir) {
|
|
|
1275
1286
|
}
|
|
1276
1287
|
return outputs;
|
|
1277
1288
|
}
|
|
1278
|
-
async function importEmbeddedSkills(projectRoot, skillsDir, fromTool, results,
|
|
1289
|
+
async function importEmbeddedSkills(projectRoot, skillsDir, fromTool, results, normalize2) {
|
|
1279
1290
|
const entries = await readdir(join(projectRoot, skillsDir), {
|
|
1280
1291
|
encoding: "utf8",
|
|
1281
1292
|
withFileTypes: true
|
|
@@ -1290,7 +1301,7 @@ async function importEmbeddedSkills(projectRoot, skillsDir, fromTool, results, n
|
|
|
1290
1301
|
const destinationSkillDir = join(projectRoot, AB_SKILLS, entry.name);
|
|
1291
1302
|
const destinationSkillFile = join(destinationSkillDir, "SKILL.md");
|
|
1292
1303
|
const { frontmatter, body } = parseFrontmatter(
|
|
1293
|
-
|
|
1304
|
+
normalize2(sourceSkillContent, sourceSkillFile, destinationSkillFile)
|
|
1294
1305
|
);
|
|
1295
1306
|
const projectedCommand = parseCommandSkillFrontmatter(frontmatter, entry.name);
|
|
1296
1307
|
if (projectedCommand) {
|
|
@@ -1300,7 +1311,7 @@ async function importEmbeddedSkills(projectRoot, skillsDir, fromTool, results, n
|
|
|
1300
1311
|
const commandPath = join(destDir, `${projectedCommand.name}.md`);
|
|
1301
1312
|
await writeFileAtomic(
|
|
1302
1313
|
commandPath,
|
|
1303
|
-
serializeImportedCommand(projectedCommand,
|
|
1314
|
+
serializeImportedCommand(projectedCommand, normalize2(body, sourceSkillFile, commandPath))
|
|
1304
1315
|
);
|
|
1305
1316
|
results.push({
|
|
1306
1317
|
fromTool,
|
|
@@ -1318,7 +1329,7 @@ async function importEmbeddedSkills(projectRoot, skillsDir, fromTool, results, n
|
|
|
1318
1329
|
const agentPath = join(destDir, `${projectedAgent.name}.md`);
|
|
1319
1330
|
await writeFileAtomic(
|
|
1320
1331
|
agentPath,
|
|
1321
|
-
serializeImportedAgent(projectedAgent,
|
|
1332
|
+
serializeImportedAgent(projectedAgent, normalize2(body, sourceSkillFile, agentPath))
|
|
1322
1333
|
);
|
|
1323
1334
|
results.push({
|
|
1324
1335
|
fromTool,
|
|
@@ -1349,7 +1360,7 @@ async function importEmbeddedSkills(projectRoot, skillsDir, fromTool, results, n
|
|
|
1349
1360
|
if (sourceContent === null) continue;
|
|
1350
1361
|
const destinationPath = join(destinationSkillDir, relativePath);
|
|
1351
1362
|
await mkdirp(dirname(destinationPath));
|
|
1352
|
-
await writeFileAtomic(destinationPath,
|
|
1363
|
+
await writeFileAtomic(destinationPath, normalize2(sourceContent, sourcePath, destinationPath));
|
|
1353
1364
|
results.push({
|
|
1354
1365
|
fromTool,
|
|
1355
1366
|
fromPath: sourcePath,
|
|
@@ -2506,7 +2517,7 @@ var init_import_descriptor = __esm({
|
|
|
2506
2517
|
];
|
|
2507
2518
|
}
|
|
2508
2519
|
});
|
|
2509
|
-
async function runSingleFile(spec, sources, projectRoot, fromTool,
|
|
2520
|
+
async function runSingleFile(spec, sources, projectRoot, fromTool, normalize2) {
|
|
2510
2521
|
if (!spec.canonicalRootFilename) {
|
|
2511
2522
|
throw new Error(`singleFile spec for ${spec.feature} must set canonicalRootFilename`);
|
|
2512
2523
|
}
|
|
@@ -2517,7 +2528,7 @@ async function runSingleFile(spec, sources, projectRoot, fromTool, normalize) {
|
|
|
2517
2528
|
if (content === null) continue;
|
|
2518
2529
|
await mkdirp(destDir);
|
|
2519
2530
|
const destPath = join(destDir, spec.canonicalRootFilename);
|
|
2520
|
-
const normalizeTo = (destinationFile) =>
|
|
2531
|
+
const normalizeTo = (destinationFile) => normalize2(content, srcPath, destinationFile);
|
|
2521
2532
|
if (spec.map) {
|
|
2522
2533
|
let mapping;
|
|
2523
2534
|
try {
|
|
@@ -2560,7 +2571,7 @@ async function runSingleFile(spec, sources, projectRoot, fromTool, normalize) {
|
|
|
2560
2571
|
}
|
|
2561
2572
|
return [];
|
|
2562
2573
|
}
|
|
2563
|
-
async function runDirectory(spec, sources, projectRoot, fromTool,
|
|
2574
|
+
async function runDirectory(spec, sources, projectRoot, fromTool, normalize2) {
|
|
2564
2575
|
const mapper = resolveMapper(spec);
|
|
2565
2576
|
const destDir = join(projectRoot, spec.canonicalDir);
|
|
2566
2577
|
const results = [];
|
|
@@ -2571,7 +2582,7 @@ async function runDirectory(spec, sources, projectRoot, fromTool, normalize) {
|
|
|
2571
2582
|
destDir,
|
|
2572
2583
|
extensions: [...spec.extensions ?? [".md"]],
|
|
2573
2584
|
fromTool,
|
|
2574
|
-
normalize,
|
|
2585
|
+
normalize: normalize2,
|
|
2575
2586
|
mapEntry: async ({ srcPath, relativePath, content, normalizeTo }) => {
|
|
2576
2587
|
if (isPreservedBoilerplate(basename(srcPath))) return null;
|
|
2577
2588
|
let mapping;
|
|
@@ -2676,28 +2687,28 @@ async function runMcpJson(spec, sources, projectRoot, fromTool) {
|
|
|
2676
2687
|
}
|
|
2677
2688
|
return [];
|
|
2678
2689
|
}
|
|
2679
|
-
function dispatchSpec(spec, sources, projectRoot, fromTool,
|
|
2690
|
+
function dispatchSpec(spec, sources, projectRoot, fromTool, normalize2) {
|
|
2680
2691
|
switch (spec.mode) {
|
|
2681
2692
|
case "singleFile":
|
|
2682
|
-
return runSingleFile(spec, sources, projectRoot, fromTool,
|
|
2693
|
+
return runSingleFile(spec, sources, projectRoot, fromTool, normalize2);
|
|
2683
2694
|
case "directory":
|
|
2684
|
-
return runDirectory(spec, sources, projectRoot, fromTool,
|
|
2695
|
+
return runDirectory(spec, sources, projectRoot, fromTool, normalize2);
|
|
2685
2696
|
case "flatFile":
|
|
2686
2697
|
return runFlatFile(spec, sources, projectRoot, fromTool);
|
|
2687
2698
|
case "mcpJson":
|
|
2688
2699
|
return runMcpJson(spec, sources, projectRoot, fromTool);
|
|
2689
2700
|
}
|
|
2690
2701
|
}
|
|
2691
|
-
async function runSpec(spec, scope, projectRoot, fromTool,
|
|
2702
|
+
async function runSpec(spec, scope, projectRoot, fromTool, normalize2) {
|
|
2692
2703
|
const primary = resolveScopedSources(spec.source, scope);
|
|
2693
2704
|
const fallback = resolveScopedSources(spec.fallbacks, scope);
|
|
2694
2705
|
if (primary.length === 0 && fallback.length === 0) return [];
|
|
2695
2706
|
if (primary.length > 0) {
|
|
2696
|
-
const results = await dispatchSpec(spec, primary, projectRoot, fromTool,
|
|
2707
|
+
const results = await dispatchSpec(spec, primary, projectRoot, fromTool, normalize2);
|
|
2697
2708
|
if (results.length > 0) return results;
|
|
2698
2709
|
}
|
|
2699
2710
|
if (fallback.length > 0) {
|
|
2700
|
-
return dispatchSpec(spec, fallback, projectRoot, fromTool,
|
|
2711
|
+
return dispatchSpec(spec, fallback, projectRoot, fromTool, normalize2);
|
|
2701
2712
|
}
|
|
2702
2713
|
return [];
|
|
2703
2714
|
}
|
|
@@ -2710,11 +2721,11 @@ function specsForFeature(importer, feature) {
|
|
|
2710
2721
|
async function runDescriptorImport(descriptor31, projectRoot, scope, options) {
|
|
2711
2722
|
const importer = descriptor31.importer;
|
|
2712
2723
|
if (!importer) return [];
|
|
2713
|
-
const
|
|
2724
|
+
const normalize2 = options?.normalize ?? await createImportReferenceNormalizer(descriptor31.id, projectRoot, scope);
|
|
2714
2725
|
const results = [];
|
|
2715
2726
|
for (const feature of IMPORT_FEATURE_ORDER) {
|
|
2716
2727
|
for (const spec of specsForFeature(importer, feature)) {
|
|
2717
|
-
results.push(...await runSpec(spec, scope, projectRoot, descriptor31.id,
|
|
2728
|
+
results.push(...await runSpec(spec, scope, projectRoot, descriptor31.id, normalize2));
|
|
2718
2729
|
}
|
|
2719
2730
|
}
|
|
2720
2731
|
return results;
|
|
@@ -2738,10 +2749,10 @@ var init_descriptor_import_runner = __esm({
|
|
|
2738
2749
|
async function importFromAider(projectRoot, options = {}) {
|
|
2739
2750
|
const scope = options.scope ?? "project";
|
|
2740
2751
|
const results = [];
|
|
2741
|
-
const
|
|
2742
|
-
results.push(...await runDescriptorImport(descriptor, projectRoot, scope, { normalize }));
|
|
2752
|
+
const normalize2 = await createImportReferenceNormalizer(AIDER_TARGET, projectRoot, scope);
|
|
2753
|
+
results.push(...await runDescriptorImport(descriptor, projectRoot, scope, { normalize: normalize2 }));
|
|
2743
2754
|
const skillsDir = scope === "global" ? AIDER_GLOBAL_SKILLS_DIR : AIDER_SKILLS_DIR;
|
|
2744
|
-
await importEmbeddedSkills(projectRoot, skillsDir, AIDER_TARGET, results,
|
|
2755
|
+
await importEmbeddedSkills(projectRoot, skillsDir, AIDER_TARGET, results, normalize2);
|
|
2745
2756
|
return results;
|
|
2746
2757
|
}
|
|
2747
2758
|
var init_importer = __esm({
|
|
@@ -4980,10 +4991,10 @@ var init_mcp_import = __esm({
|
|
|
4980
4991
|
async function importFromAmp(projectRoot, options = {}) {
|
|
4981
4992
|
const scope = options.scope ?? "project";
|
|
4982
4993
|
const results = [];
|
|
4983
|
-
const
|
|
4984
|
-
results.push(...await runDescriptorImport(descriptor3, projectRoot, scope, { normalize }));
|
|
4994
|
+
const normalize2 = await createImportReferenceNormalizer(AMP_TARGET, projectRoot, scope);
|
|
4995
|
+
results.push(...await runDescriptorImport(descriptor3, projectRoot, scope, { normalize: normalize2 }));
|
|
4985
4996
|
const skillsDir = scope === "global" ? AMP_GLOBAL_SKILLS_DIR : AMP_SKILLS_DIR;
|
|
4986
|
-
await importEmbeddedSkills(projectRoot, skillsDir, AMP_TARGET, results,
|
|
4997
|
+
await importEmbeddedSkills(projectRoot, skillsDir, AMP_TARGET, results, normalize2);
|
|
4987
4998
|
const mcpFile = scope === "global" ? AMP_GLOBAL_MCP_FILE : AMP_MCP_FILE;
|
|
4988
4999
|
await importAmpMcp(projectRoot, mcpFile, results);
|
|
4989
5000
|
return results;
|
|
@@ -5331,7 +5342,7 @@ var init_embedded_rules = __esm({
|
|
|
5331
5342
|
init_import_metadata();
|
|
5332
5343
|
}
|
|
5333
5344
|
});
|
|
5334
|
-
async function importRootRule(projectRoot, results,
|
|
5345
|
+
async function importRootRule(projectRoot, results, normalize2, scope) {
|
|
5335
5346
|
const primary = scope === "global" ? ANTIGRAVITY_GLOBAL_ROOT : ANTIGRAVITY_RULES_ROOT;
|
|
5336
5347
|
const candidates = scope === "project" ? [primary, ANTIGRAVITY_RULES_ROOT_LEGACY] : [primary];
|
|
5337
5348
|
for (const rel2 of candidates) {
|
|
@@ -5345,10 +5356,10 @@ async function importRootRule(projectRoot, results, normalize, scope) {
|
|
|
5345
5356
|
rulesDir: ANTIGRAVITY_CANONICAL_RULES_DIR,
|
|
5346
5357
|
sourcePath: srcPath,
|
|
5347
5358
|
fromTool: ANTIGRAVITY_TARGET,
|
|
5348
|
-
normalize
|
|
5359
|
+
normalize: normalize2
|
|
5349
5360
|
});
|
|
5350
5361
|
results.push(...split.results);
|
|
5351
|
-
const { body } = parseFrontmatter(
|
|
5362
|
+
const { body } = parseFrontmatter(normalize2(split.rootContent, srcPath, destPath));
|
|
5352
5363
|
const output = await serializeImportedRuleWithFallback(destPath, { root: true }, body);
|
|
5353
5364
|
await mkdirp(join(projectRoot, ANTIGRAVITY_CANONICAL_RULES_DIR));
|
|
5354
5365
|
await writeFileAtomic(destPath, output);
|
|
@@ -5364,15 +5375,15 @@ async function importRootRule(projectRoot, results, normalize, scope) {
|
|
|
5364
5375
|
async function importFromAntigravity(projectRoot, options = {}) {
|
|
5365
5376
|
const scope = options.scope ?? "project";
|
|
5366
5377
|
const results = [];
|
|
5367
|
-
const
|
|
5368
|
-
await importRootRule(projectRoot, results,
|
|
5369
|
-
results.push(...await runDescriptorImport(descriptor4, projectRoot, scope, { normalize }));
|
|
5378
|
+
const normalize2 = await createImportReferenceNormalizer(ANTIGRAVITY_TARGET, projectRoot, scope);
|
|
5379
|
+
await importRootRule(projectRoot, results, normalize2, scope);
|
|
5380
|
+
results.push(...await runDescriptorImport(descriptor4, projectRoot, scope, { normalize: normalize2 }));
|
|
5370
5381
|
await importEmbeddedSkills(
|
|
5371
5382
|
projectRoot,
|
|
5372
5383
|
scope === "global" ? ANTIGRAVITY_GLOBAL_SKILLS_DIR : ANTIGRAVITY_SKILLS_DIR,
|
|
5373
5384
|
ANTIGRAVITY_TARGET,
|
|
5374
5385
|
results,
|
|
5375
|
-
|
|
5386
|
+
normalize2
|
|
5376
5387
|
);
|
|
5377
5388
|
return results;
|
|
5378
5389
|
}
|
|
@@ -5788,7 +5799,7 @@ function canonicalRuleMeta(frontmatter, isRoot) {
|
|
|
5788
5799
|
}
|
|
5789
5800
|
return meta;
|
|
5790
5801
|
}
|
|
5791
|
-
async function importRules(projectRoot, results,
|
|
5802
|
+
async function importRules(projectRoot, results, normalize2, scope) {
|
|
5792
5803
|
const rulesDir = scope === "global" ? AUGMENT_CODE_GLOBAL_RULES_DIR : AUGMENT_CODE_RULES_DIR;
|
|
5793
5804
|
const destDir = join(projectRoot, AUGMENT_CODE_CANONICAL_RULES_DIR);
|
|
5794
5805
|
results.push(
|
|
@@ -5797,7 +5808,7 @@ async function importRules(projectRoot, results, normalize, scope) {
|
|
|
5797
5808
|
destDir,
|
|
5798
5809
|
extensions: [".md"],
|
|
5799
5810
|
fromTool: AUGMENT_CODE_TARGET,
|
|
5800
|
-
normalize,
|
|
5811
|
+
normalize: normalize2,
|
|
5801
5812
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
5802
5813
|
const isRoot = relativePath === "_root.md" || basename(relativePath) === "_root.md";
|
|
5803
5814
|
const destPath = join(destDir, relativePath);
|
|
@@ -5816,7 +5827,7 @@ async function importRules(projectRoot, results, normalize, scope) {
|
|
|
5816
5827
|
})
|
|
5817
5828
|
);
|
|
5818
5829
|
}
|
|
5819
|
-
async function importCommands(projectRoot, results,
|
|
5830
|
+
async function importCommands(projectRoot, results, normalize2, scope) {
|
|
5820
5831
|
const commandsDir = scope === "global" ? AUGMENT_CODE_GLOBAL_COMMANDS_DIR : AUGMENT_CODE_COMMANDS_DIR;
|
|
5821
5832
|
const destDir = join(projectRoot, ".agentsmesh/commands");
|
|
5822
5833
|
results.push(
|
|
@@ -5825,7 +5836,7 @@ async function importCommands(projectRoot, results, normalize, scope) {
|
|
|
5825
5836
|
destDir,
|
|
5826
5837
|
extensions: [".md"],
|
|
5827
5838
|
fromTool: AUGMENT_CODE_TARGET,
|
|
5828
|
-
normalize,
|
|
5839
|
+
normalize: normalize2,
|
|
5829
5840
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
5830
5841
|
const name = basename(relativePath, ".md");
|
|
5831
5842
|
const destPath = join(destDir, `${name}.md`);
|
|
@@ -5848,11 +5859,11 @@ async function importCommands(projectRoot, results, normalize, scope) {
|
|
|
5848
5859
|
async function importFromAugmentCode(projectRoot, options = {}) {
|
|
5849
5860
|
const scope = options.scope ?? "project";
|
|
5850
5861
|
const results = [];
|
|
5851
|
-
const
|
|
5852
|
-
await importRules(projectRoot, results,
|
|
5853
|
-
await importCommands(projectRoot, results,
|
|
5862
|
+
const normalize2 = await createImportReferenceNormalizer(AUGMENT_CODE_TARGET, projectRoot, scope);
|
|
5863
|
+
await importRules(projectRoot, results, normalize2, scope);
|
|
5864
|
+
await importCommands(projectRoot, results, normalize2, scope);
|
|
5854
5865
|
const skillsDir = scope === "global" ? AUGMENT_CODE_GLOBAL_SKILLS_DIR : AUGMENT_CODE_SKILLS_DIR;
|
|
5855
|
-
await importEmbeddedSkills(projectRoot, skillsDir, AUGMENT_CODE_TARGET, results,
|
|
5866
|
+
await importEmbeddedSkills(projectRoot, skillsDir, AUGMENT_CODE_TARGET, results, normalize2);
|
|
5856
5867
|
const settingsFile = scope === "global" ? AUGMENT_CODE_GLOBAL_SETTINGS_FILE : AUGMENT_CODE_SETTINGS_FILE;
|
|
5857
5868
|
await importAugmentSettings(projectRoot, settingsFile, results);
|
|
5858
5869
|
if (scope === "project") {
|
|
@@ -6470,7 +6481,7 @@ var init_settings_helpers2 = __esm({
|
|
|
6470
6481
|
init_constants7();
|
|
6471
6482
|
}
|
|
6472
6483
|
});
|
|
6473
|
-
async function importClaudeSkills(projectRoot, results,
|
|
6484
|
+
async function importClaudeSkills(projectRoot, results, normalize2) {
|
|
6474
6485
|
const skillsBaseDir = join(projectRoot, CLAUDE_SKILLS_DIR);
|
|
6475
6486
|
const destBase = join(projectRoot, CLAUDE_CANONICAL_SKILLS_DIR);
|
|
6476
6487
|
const allFiles = await readDirRecursive(skillsBaseDir);
|
|
@@ -6481,7 +6492,7 @@ async function importClaudeSkills(projectRoot, results, normalize) {
|
|
|
6481
6492
|
const destSkillDir = join(destBase, skillName);
|
|
6482
6493
|
const skillMdContent = await readFileSafe(skillMdPath);
|
|
6483
6494
|
if (skillMdContent === null) continue;
|
|
6484
|
-
const normalizedSkillMd =
|
|
6495
|
+
const normalizedSkillMd = normalize2(
|
|
6485
6496
|
skillMdContent,
|
|
6486
6497
|
skillMdPath,
|
|
6487
6498
|
join(destSkillDir, "SKILL.md")
|
|
@@ -6499,7 +6510,7 @@ async function importClaudeSkills(projectRoot, results, normalize) {
|
|
|
6499
6510
|
const relPath = relative(skillDir, filePath);
|
|
6500
6511
|
const destPath = join(destSkillDir, relPath);
|
|
6501
6512
|
await mkdirp(dirname(destPath));
|
|
6502
|
-
const normalized =
|
|
6513
|
+
const normalized = normalize2(fileContent, filePath, destPath);
|
|
6503
6514
|
await writeFileAtomic(
|
|
6504
6515
|
destPath,
|
|
6505
6516
|
relPath === "SKILL.md" ? await serializeImportedSkillWithFallback(
|
|
@@ -6531,9 +6542,9 @@ var init_importer_skills = __esm({
|
|
|
6531
6542
|
async function importFromClaudeCode(projectRoot, options = {}) {
|
|
6532
6543
|
const scope = options.scope ?? "project";
|
|
6533
6544
|
const results = [];
|
|
6534
|
-
const
|
|
6535
|
-
results.push(...await runDescriptorImport(descriptor6, projectRoot, scope, { normalize }));
|
|
6536
|
-
await importClaudeSkills(projectRoot, results,
|
|
6545
|
+
const normalize2 = await createImportReferenceNormalizer("claude-code", projectRoot, scope);
|
|
6546
|
+
results.push(...await runDescriptorImport(descriptor6, projectRoot, scope, { normalize: normalize2 }));
|
|
6547
|
+
await importClaudeSkills(projectRoot, results, normalize2);
|
|
6537
6548
|
await importClaudeHooksJson(projectRoot, results);
|
|
6538
6549
|
await importSettings(projectRoot, results);
|
|
6539
6550
|
return results;
|
|
@@ -6993,7 +7004,7 @@ var init_importer_mappers = __esm({
|
|
|
6993
7004
|
init_constants8();
|
|
6994
7005
|
}
|
|
6995
7006
|
});
|
|
6996
|
-
async function importClineRules(projectRoot, results,
|
|
7007
|
+
async function importClineRules(projectRoot, results, normalize2) {
|
|
6997
7008
|
const destRulesDir = join(projectRoot, CLINE_CANONICAL_RULES_DIR);
|
|
6998
7009
|
const clineRulesPath = join(projectRoot, CLINE_RULES_DIR);
|
|
6999
7010
|
const clineRulesRaw = join(projectRoot, CLINE_RULES_DIR);
|
|
@@ -7009,7 +7020,7 @@ async function importClineRules(projectRoot, results, normalize) {
|
|
|
7009
7020
|
await mkdirp(destRulesDir);
|
|
7010
7021
|
const destPath = join(destRulesDir, "_root.md");
|
|
7011
7022
|
const { frontmatter, body } = parseFrontmatter(
|
|
7012
|
-
|
|
7023
|
+
normalize2(flatContent, clineRulesRaw, destPath)
|
|
7013
7024
|
);
|
|
7014
7025
|
const hasRoot = frontmatter.root === true;
|
|
7015
7026
|
const outFm = hasRoot ? frontmatter : { ...frontmatter, root: true };
|
|
@@ -7035,7 +7046,7 @@ async function importClineRules(projectRoot, results, normalize) {
|
|
|
7035
7046
|
await mkdirp(destRulesDir);
|
|
7036
7047
|
const destPath = join(destRulesDir, "_root.md");
|
|
7037
7048
|
const { frontmatter, body } = parseFrontmatter(
|
|
7038
|
-
|
|
7049
|
+
normalize2(agentsMdContent, agentsMdPath, destPath)
|
|
7039
7050
|
);
|
|
7040
7051
|
const hasRoot = frontmatter.root === true;
|
|
7041
7052
|
const outFm = hasRoot ? frontmatter : { ...frontmatter, root: true };
|
|
@@ -7057,7 +7068,7 @@ async function importClineRules(projectRoot, results, normalize) {
|
|
|
7057
7068
|
rootSourcePath = first;
|
|
7058
7069
|
await mkdirp(destRulesDir);
|
|
7059
7070
|
const destPath = join(destRulesDir, "_root.md");
|
|
7060
|
-
const { frontmatter, body } = parseFrontmatter(
|
|
7071
|
+
const { frontmatter, body } = parseFrontmatter(normalize2(fc, first, destPath));
|
|
7061
7072
|
const hasRoot = frontmatter.root === true;
|
|
7062
7073
|
const outFm = hasRoot ? frontmatter : { ...frontmatter, root: true };
|
|
7063
7074
|
const outContent = await serializeImportedRuleWithFallback(destPath, outFm, body);
|
|
@@ -7075,7 +7086,7 @@ async function importClineRules(projectRoot, results, normalize) {
|
|
|
7075
7086
|
rootSourcePath = rootPath;
|
|
7076
7087
|
await mkdirp(destRulesDir);
|
|
7077
7088
|
const destPath = join(destRulesDir, "_root.md");
|
|
7078
|
-
const { frontmatter, body } = parseFrontmatter(
|
|
7089
|
+
const { frontmatter, body } = parseFrontmatter(normalize2(rootContent, rootPath, destPath));
|
|
7079
7090
|
const hasRoot = frontmatter.root === true;
|
|
7080
7091
|
const outFm = hasRoot ? frontmatter : { ...frontmatter, root: true };
|
|
7081
7092
|
const outContent = await serializeImportedRuleWithFallback(destPath, outFm, body);
|
|
@@ -7093,7 +7104,7 @@ async function importClineRules(projectRoot, results, normalize) {
|
|
|
7093
7104
|
destDir: destRulesDir,
|
|
7094
7105
|
extensions: [".md"],
|
|
7095
7106
|
fromTool: "cline",
|
|
7096
|
-
normalize,
|
|
7107
|
+
normalize: normalize2,
|
|
7097
7108
|
mapEntry: async ({ srcPath, relativePath, normalizeTo }) => {
|
|
7098
7109
|
if (srcPath === rootSourcePath) return null;
|
|
7099
7110
|
return mapClineRuleFile(relativePath, destRulesDir, normalizeTo);
|
|
@@ -7380,12 +7391,12 @@ var init_skill_import_pipeline = __esm({
|
|
|
7380
7391
|
});
|
|
7381
7392
|
|
|
7382
7393
|
// src/targets/cline/skills-adapter.ts
|
|
7383
|
-
async function importClineSkills(projectRoot, results,
|
|
7394
|
+
async function importClineSkills(projectRoot, results, normalize2, skillsRelDir = CLINE_SKILLS_DIR) {
|
|
7384
7395
|
const options = {
|
|
7385
7396
|
projectRoot,
|
|
7386
7397
|
destCanonicalSkillsDir: CLINE_CANONICAL_SKILLS_DIR,
|
|
7387
7398
|
targetName: "cline",
|
|
7388
|
-
normalize,
|
|
7399
|
+
normalize: normalize2,
|
|
7389
7400
|
results
|
|
7390
7401
|
};
|
|
7391
7402
|
await importSkillsDirectory([skillsRelDir], options, [
|
|
@@ -7439,8 +7450,8 @@ var init_hook_importer = __esm({
|
|
|
7439
7450
|
});
|
|
7440
7451
|
async function importFromCline(projectRoot) {
|
|
7441
7452
|
const results = [];
|
|
7442
|
-
const
|
|
7443
|
-
const clineRulesIsFile = await importClineRules(projectRoot, results,
|
|
7453
|
+
const normalize2 = await createImportReferenceNormalizer(CLINE_TARGET, projectRoot);
|
|
7454
|
+
const clineRulesIsFile = await importClineRules(projectRoot, results, normalize2);
|
|
7444
7455
|
const ignorePath = join(projectRoot, CLINE_IGNORE);
|
|
7445
7456
|
const ignoreContent = await readFileSafe(ignorePath);
|
|
7446
7457
|
if (ignoreContent !== null && ignoreContent.trim()) {
|
|
@@ -7471,12 +7482,12 @@ async function importFromCline(projectRoot) {
|
|
|
7471
7482
|
destDir: destCommandsDir,
|
|
7472
7483
|
extensions: [".md"],
|
|
7473
7484
|
fromTool: "cline",
|
|
7474
|
-
normalize,
|
|
7485
|
+
normalize: normalize2,
|
|
7475
7486
|
mapEntry: ({ relativePath, normalizeTo }) => mapClineWorkflowFile(relativePath, destCommandsDir, normalizeTo)
|
|
7476
7487
|
})
|
|
7477
7488
|
);
|
|
7478
7489
|
}
|
|
7479
|
-
await importClineSkills(projectRoot, results,
|
|
7490
|
+
await importClineSkills(projectRoot, results, normalize2);
|
|
7480
7491
|
await importClineHooks(projectRoot, results);
|
|
7481
7492
|
return results;
|
|
7482
7493
|
}
|
|
@@ -8059,12 +8070,12 @@ var init_mcp_helpers = __esm({
|
|
|
8059
8070
|
});
|
|
8060
8071
|
|
|
8061
8072
|
// src/targets/codex-cli/skills-adapter.ts
|
|
8062
|
-
async function importSkills(projectRoot, results,
|
|
8073
|
+
async function importSkills(projectRoot, results, normalize2) {
|
|
8063
8074
|
const options = {
|
|
8064
8075
|
projectRoot,
|
|
8065
8076
|
destCanonicalSkillsDir: CODEX_CANONICAL_SKILLS_DIR,
|
|
8066
8077
|
targetName: CODEX_TARGET,
|
|
8067
|
-
normalize,
|
|
8078
|
+
normalize: normalize2,
|
|
8068
8079
|
results
|
|
8069
8080
|
};
|
|
8070
8081
|
await importSkillsDirectory([CODEX_SKILLS_DIR, CODEX_SKILLS_FALLBACK_DIR], options, [
|
|
@@ -8078,7 +8089,7 @@ var init_skills_adapter2 = __esm({
|
|
|
8078
8089
|
init_constants28();
|
|
8079
8090
|
}
|
|
8080
8091
|
});
|
|
8081
|
-
async function importCodexAgentsFromToml(projectRoot, results,
|
|
8092
|
+
async function importCodexAgentsFromToml(projectRoot, results, normalize2) {
|
|
8082
8093
|
const agentsPath = join(projectRoot, CODEX_AGENTS_DIR);
|
|
8083
8094
|
const agentsDestDir = join(projectRoot, CODEX_CANONICAL_AGENTS_DIR);
|
|
8084
8095
|
try {
|
|
@@ -8098,7 +8109,7 @@ async function importCodexAgentsFromToml(projectRoot, results, normalize) {
|
|
|
8098
8109
|
const mcpServers = Array.isArray(parsed.mcp_servers) ? parsed.mcp_servers.filter((s) => typeof s === "string") : [];
|
|
8099
8110
|
await mkdirp(agentsDestDir);
|
|
8100
8111
|
const destPath = join(agentsDestDir, `${name}.md`);
|
|
8101
|
-
const normalizedBody =
|
|
8112
|
+
const normalizedBody = normalize2(body, srcPath, destPath);
|
|
8102
8113
|
const agent = {
|
|
8103
8114
|
name,
|
|
8104
8115
|
description,
|
|
@@ -8174,7 +8185,7 @@ var init_codex_rules_embed = __esm({
|
|
|
8174
8185
|
init_constants28();
|
|
8175
8186
|
}
|
|
8176
8187
|
});
|
|
8177
|
-
async function importCodexNonRootRuleFiles(projectRoot, destDir,
|
|
8188
|
+
async function importCodexNonRootRuleFiles(projectRoot, destDir, normalize2) {
|
|
8178
8189
|
const results = [];
|
|
8179
8190
|
const codexRulesPath = join(projectRoot, CODEX_RULES_DIR);
|
|
8180
8191
|
try {
|
|
@@ -8185,7 +8196,7 @@ async function importCodexNonRootRuleFiles(projectRoot, destDir, normalize) {
|
|
|
8185
8196
|
if (!content) continue;
|
|
8186
8197
|
const relativePath = relative(codexRulesPath, srcPath).replace(/\\/g, "/");
|
|
8187
8198
|
const destPath = join(destDir, relativePath);
|
|
8188
|
-
const { frontmatter, body } = parseFrontmatter(
|
|
8199
|
+
const { frontmatter, body } = parseFrontmatter(normalize2(content, srcPath, destPath));
|
|
8189
8200
|
await mkdirp(destDir);
|
|
8190
8201
|
const outFm = frontmatter.root === true ? frontmatter : { ...frontmatter, root: false };
|
|
8191
8202
|
const outContent = await serializeImportedRuleWithFallback(destPath, outFm, body);
|
|
@@ -8213,7 +8224,7 @@ async function importCodexNonRootRuleFiles(projectRoot, destDir, normalize) {
|
|
|
8213
8224
|
globs: embedded.meta.globs,
|
|
8214
8225
|
root: false
|
|
8215
8226
|
},
|
|
8216
|
-
|
|
8227
|
+
normalize2(embedded.body, srcPath, destPath)
|
|
8217
8228
|
);
|
|
8218
8229
|
await writeFileAtomic(destPath, outContent);
|
|
8219
8230
|
} else {
|
|
@@ -8225,7 +8236,7 @@ async function importCodexNonRootRuleFiles(projectRoot, destDir, normalize) {
|
|
|
8225
8236
|
globs: [],
|
|
8226
8237
|
codex_emit: "execution"
|
|
8227
8238
|
},
|
|
8228
|
-
|
|
8239
|
+
normalize2(raw.trim(), srcPath, destPath)
|
|
8229
8240
|
);
|
|
8230
8241
|
await writeFileAtomic(destPath, outContent);
|
|
8231
8242
|
}
|
|
@@ -8249,7 +8260,7 @@ var init_import_codex_non_root_rules = __esm({
|
|
|
8249
8260
|
init_codex_rules_embed();
|
|
8250
8261
|
}
|
|
8251
8262
|
});
|
|
8252
|
-
async function importCodexRules(projectRoot, results,
|
|
8263
|
+
async function importCodexRules(projectRoot, results, normalize2, normalizeWindsurf, layoutScope) {
|
|
8253
8264
|
const codexPath = join(projectRoot, CODEX_MD);
|
|
8254
8265
|
const agentsPath = join(projectRoot, AGENTS_MD);
|
|
8255
8266
|
const globalOverridePath = join(projectRoot, CODEX_GLOBAL_AGENTS_OVERRIDE_MD);
|
|
@@ -8271,14 +8282,14 @@ async function importCodexRules(projectRoot, results, normalize, normalizeWindsu
|
|
|
8271
8282
|
rulesDir: CODEX_CANONICAL_RULES_DIR,
|
|
8272
8283
|
sourcePath,
|
|
8273
8284
|
fromTool: "codex-cli",
|
|
8274
|
-
normalize
|
|
8285
|
+
normalize: normalize2
|
|
8275
8286
|
});
|
|
8276
8287
|
results.push(...split.results);
|
|
8277
|
-
const normalizedContent = sourcePath === agentsPath || sourcePath === globalAgentsPath || sourcePath === globalOverridePath ?
|
|
8288
|
+
const normalizedContent = sourcePath === agentsPath || sourcePath === globalAgentsPath || sourcePath === globalOverridePath ? normalize2(
|
|
8278
8289
|
normalizeWindsurf(split.rootContent, sourcePath, destPath),
|
|
8279
8290
|
sourcePath,
|
|
8280
8291
|
destPath
|
|
8281
|
-
) :
|
|
8292
|
+
) : normalize2(split.rootContent, sourcePath, destPath);
|
|
8282
8293
|
const { frontmatter, body } = parseFrontmatter(normalizedContent);
|
|
8283
8294
|
const outFm = frontmatter.root === true ? frontmatter : { ...frontmatter, root: true };
|
|
8284
8295
|
const outContent = await serializeImportedRuleWithFallback(destPath, outFm, body);
|
|
@@ -8290,8 +8301,8 @@ async function importCodexRules(projectRoot, results, normalize, normalizeWindsu
|
|
|
8290
8301
|
feature: "rules"
|
|
8291
8302
|
});
|
|
8292
8303
|
}
|
|
8293
|
-
await importInstructionMirrors(projectRoot, destDir, results,
|
|
8294
|
-
results.push(...await importCodexNonRootRuleFiles(projectRoot, destDir,
|
|
8304
|
+
await importInstructionMirrors(projectRoot, destDir, results, normalize2);
|
|
8305
|
+
results.push(...await importCodexNonRootRuleFiles(projectRoot, destDir, normalize2));
|
|
8295
8306
|
if (layoutScope !== "global") {
|
|
8296
8307
|
results.push(
|
|
8297
8308
|
...await importFileDirectory({
|
|
@@ -8299,7 +8310,7 @@ async function importCodexRules(projectRoot, results, normalize, normalizeWindsu
|
|
|
8299
8310
|
destDir,
|
|
8300
8311
|
extensions: ["AGENTS.md", "AGENTS.override.md"],
|
|
8301
8312
|
fromTool: "codex-cli",
|
|
8302
|
-
normalize,
|
|
8313
|
+
normalize: normalize2,
|
|
8303
8314
|
mapEntry: async ({ srcPath, normalizeTo }) => {
|
|
8304
8315
|
const relDir = relative(projectRoot, dirname(srcPath)).replace(/\\/g, "/");
|
|
8305
8316
|
const fileName = basename(srcPath);
|
|
@@ -8333,7 +8344,7 @@ async function importCodexRules(projectRoot, results, normalize, normalizeWindsu
|
|
|
8333
8344
|
);
|
|
8334
8345
|
}
|
|
8335
8346
|
}
|
|
8336
|
-
async function importInstructionMirrors(projectRoot, destDir, results,
|
|
8347
|
+
async function importInstructionMirrors(projectRoot, destDir, results, normalize2) {
|
|
8337
8348
|
try {
|
|
8338
8349
|
const files = await readDirRecursive(join(projectRoot, CODEX_INSTRUCTIONS_DIR));
|
|
8339
8350
|
const instructionFiles = files.filter((file) => file.endsWith(".md"));
|
|
@@ -8344,7 +8355,7 @@ async function importInstructionMirrors(projectRoot, destDir, results, normalize
|
|
|
8344
8355
|
const content = await readFileSafe(srcPath);
|
|
8345
8356
|
if (!content) continue;
|
|
8346
8357
|
const destPath = join(destDir, relativePath);
|
|
8347
|
-
const { frontmatter, body } = parseFrontmatter(
|
|
8358
|
+
const { frontmatter, body } = parseFrontmatter(normalize2(content, srcPath, destPath));
|
|
8348
8359
|
await mkdirp(destDir);
|
|
8349
8360
|
const outFm = frontmatter.root === true ? frontmatter : { ...frontmatter, root: false };
|
|
8350
8361
|
const outContent = await serializeImportedRuleWithFallback(destPath, outFm, body);
|
|
@@ -8377,15 +8388,15 @@ var init_importer_rules2 = __esm({
|
|
|
8377
8388
|
async function importFromCodex(projectRoot, options) {
|
|
8378
8389
|
const layoutScope = options?.scope ?? "project";
|
|
8379
8390
|
const results = [];
|
|
8380
|
-
const
|
|
8391
|
+
const normalize2 = await createImportReferenceNormalizer(CODEX_TARGET, projectRoot, layoutScope);
|
|
8381
8392
|
const normalizeWindsurf = await createImportReferenceNormalizer(
|
|
8382
8393
|
"windsurf",
|
|
8383
8394
|
projectRoot,
|
|
8384
8395
|
layoutScope
|
|
8385
8396
|
);
|
|
8386
|
-
await importCodexRules(projectRoot, results,
|
|
8387
|
-
await importSkills(projectRoot, results,
|
|
8388
|
-
await importCodexAgentsFromToml(projectRoot, results,
|
|
8397
|
+
await importCodexRules(projectRoot, results, normalize2, normalizeWindsurf, layoutScope);
|
|
8398
|
+
await importSkills(projectRoot, results, normalize2);
|
|
8399
|
+
await importCodexAgentsFromToml(projectRoot, results, normalize2);
|
|
8389
8400
|
await importMcp(projectRoot, results);
|
|
8390
8401
|
return results;
|
|
8391
8402
|
}
|
|
@@ -8758,9 +8769,9 @@ async function importMcp2(projectRoot, results) {
|
|
|
8758
8769
|
}
|
|
8759
8770
|
async function importFromContinue(projectRoot) {
|
|
8760
8771
|
const results = [];
|
|
8761
|
-
const
|
|
8762
|
-
results.push(...await runDescriptorImport(descriptor9, projectRoot, "project", { normalize }));
|
|
8763
|
-
await importEmbeddedSkills(projectRoot, CONTINUE_SKILLS_DIR, CONTINUE_TARGET, results,
|
|
8772
|
+
const normalize2 = await createImportReferenceNormalizer(CONTINUE_TARGET, projectRoot);
|
|
8773
|
+
results.push(...await runDescriptorImport(descriptor9, projectRoot, "project", { normalize: normalize2 }));
|
|
8774
|
+
await importEmbeddedSkills(projectRoot, CONTINUE_SKILLS_DIR, CONTINUE_TARGET, results, normalize2);
|
|
8764
8775
|
await importMcp2(projectRoot, results);
|
|
8765
8776
|
return results;
|
|
8766
8777
|
}
|
|
@@ -9425,14 +9436,14 @@ var init_hook_parser = __esm({
|
|
|
9425
9436
|
init_constants29();
|
|
9426
9437
|
}
|
|
9427
9438
|
});
|
|
9428
|
-
async function importSkills2(projectRoot, results,
|
|
9439
|
+
async function importSkills2(projectRoot, results, normalize2, skillsDirRel = COPILOT_SKILLS_DIR) {
|
|
9429
9440
|
const skillsDir = join(projectRoot, skillsDirRel);
|
|
9430
9441
|
const directorySkills = await findDirectorySkills(skillsDir);
|
|
9431
9442
|
const options = {
|
|
9432
9443
|
projectRoot,
|
|
9433
9444
|
destCanonicalSkillsDir: COPILOT_CANONICAL_SKILLS_DIR,
|
|
9434
9445
|
targetName: COPILOT_TARGET,
|
|
9435
|
-
normalize,
|
|
9446
|
+
normalize: normalize2,
|
|
9436
9447
|
results
|
|
9437
9448
|
};
|
|
9438
9449
|
for (const [skillName, skillDir] of directorySkills) {
|
|
@@ -9450,12 +9461,12 @@ var init_skills_adapter3 = __esm({
|
|
|
9450
9461
|
async function importFromCopilot(projectRoot, options = {}) {
|
|
9451
9462
|
const scope = options.scope ?? "project";
|
|
9452
9463
|
const results = [];
|
|
9453
|
-
const
|
|
9454
|
-
results.push(...await runDescriptorImport(descriptor10, projectRoot, scope, { normalize }));
|
|
9464
|
+
const normalize2 = await createImportReferenceNormalizer(COPILOT_TARGET, projectRoot, scope);
|
|
9465
|
+
results.push(...await runDescriptorImport(descriptor10, projectRoot, scope, { normalize: normalize2 }));
|
|
9455
9466
|
await importSkills2(
|
|
9456
9467
|
projectRoot,
|
|
9457
9468
|
results,
|
|
9458
|
-
|
|
9469
|
+
normalize2,
|
|
9459
9470
|
scope === "global" ? COPILOT_GLOBAL_SKILLS_DIR : COPILOT_SKILLS_DIR
|
|
9460
9471
|
);
|
|
9461
9472
|
if (scope === "project") await importHooks(projectRoot, results);
|
|
@@ -10076,10 +10087,10 @@ var init_generator12 = __esm({
|
|
|
10076
10087
|
async function importFromCrush(projectRoot, options = {}) {
|
|
10077
10088
|
const scope = options.scope ?? "project";
|
|
10078
10089
|
const results = [];
|
|
10079
|
-
const
|
|
10080
|
-
results.push(...await runDescriptorImport(descriptor11, projectRoot, scope, { normalize }));
|
|
10090
|
+
const normalize2 = await createImportReferenceNormalizer(CRUSH_TARGET, projectRoot, scope);
|
|
10091
|
+
results.push(...await runDescriptorImport(descriptor11, projectRoot, scope, { normalize: normalize2 }));
|
|
10081
10092
|
const skillsDir = scope === "global" ? CRUSH_GLOBAL_SKILLS_DIR : CRUSH_SKILLS_DIR;
|
|
10082
|
-
await importEmbeddedSkills(projectRoot, skillsDir, CRUSH_TARGET, results,
|
|
10093
|
+
await importEmbeddedSkills(projectRoot, skillsDir, CRUSH_TARGET, results, normalize2);
|
|
10083
10094
|
await importCrushConfigJson(projectRoot, results);
|
|
10084
10095
|
return results;
|
|
10085
10096
|
}
|
|
@@ -10764,7 +10775,7 @@ var init_import_root_helpers = __esm({
|
|
|
10764
10775
|
init_constants11();
|
|
10765
10776
|
}
|
|
10766
10777
|
});
|
|
10767
|
-
async function importCursorRules(projectRoot, results,
|
|
10778
|
+
async function importCursorRules(projectRoot, results, normalize2) {
|
|
10768
10779
|
const destDir = join(projectRoot, CURSOR_CANONICAL_RULES_DIR);
|
|
10769
10780
|
let rootWritten = false;
|
|
10770
10781
|
const rulesDir = join(projectRoot, CURSOR_RULES_DIR);
|
|
@@ -10774,7 +10785,7 @@ async function importCursorRules(projectRoot, results, normalize) {
|
|
|
10774
10785
|
destDir,
|
|
10775
10786
|
extensions: [".mdc"],
|
|
10776
10787
|
fromTool: "cursor",
|
|
10777
|
-
normalize,
|
|
10788
|
+
normalize: normalize2,
|
|
10778
10789
|
mapEntry: async ({ srcPath, relativePath, normalizeTo }) => {
|
|
10779
10790
|
if (rootWritten) {
|
|
10780
10791
|
const raw = await readFileSafe(srcPath);
|
|
@@ -10798,7 +10809,7 @@ async function importCursorRules(projectRoot, results, normalize) {
|
|
|
10798
10809
|
results,
|
|
10799
10810
|
sourcePath: agentsPath,
|
|
10800
10811
|
content: agentsContent,
|
|
10801
|
-
normalize
|
|
10812
|
+
normalize: normalize2
|
|
10802
10813
|
});
|
|
10803
10814
|
}
|
|
10804
10815
|
}
|
|
@@ -10811,7 +10822,7 @@ async function importCursorRules(projectRoot, results, normalize) {
|
|
|
10811
10822
|
results,
|
|
10812
10823
|
sourcePath: cursorRulesPath,
|
|
10813
10824
|
content: cursorRulesContent,
|
|
10814
|
-
normalize
|
|
10825
|
+
normalize: normalize2
|
|
10815
10826
|
});
|
|
10816
10827
|
}
|
|
10817
10828
|
}
|
|
@@ -10956,14 +10967,14 @@ var init_settings_helpers3 = __esm({
|
|
|
10956
10967
|
init_constants11();
|
|
10957
10968
|
}
|
|
10958
10969
|
});
|
|
10959
|
-
async function importSkills3(projectRoot, results,
|
|
10970
|
+
async function importSkills3(projectRoot, results, normalize2, skillsRelDir = CURSOR_SKILLS_DIR) {
|
|
10960
10971
|
const skillsDir = join(projectRoot, skillsRelDir);
|
|
10961
10972
|
const directorySkills = await findDirectorySkills(skillsDir);
|
|
10962
10973
|
const options = {
|
|
10963
10974
|
projectRoot,
|
|
10964
10975
|
destCanonicalSkillsDir: CURSOR_CANONICAL_SKILLS_DIR,
|
|
10965
10976
|
targetName: "cursor",
|
|
10966
|
-
normalize,
|
|
10977
|
+
normalize: normalize2,
|
|
10967
10978
|
results
|
|
10968
10979
|
};
|
|
10969
10980
|
for (const [skillName, skillDir] of directorySkills) {
|
|
@@ -11015,7 +11026,7 @@ async function hasGlobalCursorArtifacts(projectRoot) {
|
|
|
11015
11026
|
if (commandFiles.some((f) => f.endsWith(".md"))) return true;
|
|
11016
11027
|
return false;
|
|
11017
11028
|
}
|
|
11018
|
-
async function importGlobalCursorRulesFromDir(projectRoot, results,
|
|
11029
|
+
async function importGlobalCursorRulesFromDir(projectRoot, results, normalize2) {
|
|
11019
11030
|
const destDir = join(projectRoot, CURSOR_CANONICAL_RULES_DIR);
|
|
11020
11031
|
let rootWritten = false;
|
|
11021
11032
|
const rulesDir = join(projectRoot, CURSOR_RULES_DIR);
|
|
@@ -11024,7 +11035,7 @@ async function importGlobalCursorRulesFromDir(projectRoot, results, normalize) {
|
|
|
11024
11035
|
destDir,
|
|
11025
11036
|
extensions: [".mdc"],
|
|
11026
11037
|
fromTool: CURSOR_TARGET2,
|
|
11027
|
-
normalize,
|
|
11038
|
+
normalize: normalize2,
|
|
11028
11039
|
mapEntry: async ({ srcPath, relativePath, normalizeTo }) => {
|
|
11029
11040
|
if (rootWritten) {
|
|
11030
11041
|
const raw = await readFileSafe(srcPath);
|
|
@@ -11041,7 +11052,7 @@ async function importGlobalCursorRulesFromDir(projectRoot, results, normalize) {
|
|
|
11041
11052
|
results.push(...batch);
|
|
11042
11053
|
return rootWritten;
|
|
11043
11054
|
}
|
|
11044
|
-
async function importGlobalUserRules(projectRoot, results,
|
|
11055
|
+
async function importGlobalUserRules(projectRoot, results, normalize2) {
|
|
11045
11056
|
const srcPath = join(projectRoot, CURSOR_GLOBAL_USER_RULES);
|
|
11046
11057
|
const raw = await readFileSafe(srcPath);
|
|
11047
11058
|
if (raw === null || raw.trim() === "") return false;
|
|
@@ -11050,10 +11061,10 @@ async function importGlobalUserRules(projectRoot, results, normalize) {
|
|
|
11050
11061
|
results,
|
|
11051
11062
|
sourcePath: srcPath,
|
|
11052
11063
|
content: raw.trim(),
|
|
11053
|
-
normalize
|
|
11064
|
+
normalize: normalize2
|
|
11054
11065
|
});
|
|
11055
11066
|
}
|
|
11056
|
-
async function importGlobalDotCursorAgents(projectRoot, results,
|
|
11067
|
+
async function importGlobalDotCursorAgents(projectRoot, results, normalize2) {
|
|
11057
11068
|
const srcPath = join(projectRoot, CURSOR_DOT_CURSOR_AGENTS);
|
|
11058
11069
|
const raw = await readFileSafe(srcPath);
|
|
11059
11070
|
if (raw === null || raw.trim() === "") return false;
|
|
@@ -11062,7 +11073,7 @@ async function importGlobalDotCursorAgents(projectRoot, results, normalize) {
|
|
|
11062
11073
|
results,
|
|
11063
11074
|
sourcePath: srcPath,
|
|
11064
11075
|
content: raw.trim(),
|
|
11065
|
-
normalize
|
|
11076
|
+
normalize: normalize2
|
|
11066
11077
|
});
|
|
11067
11078
|
}
|
|
11068
11079
|
async function importGlobalMcp(projectRoot, results) {
|
|
@@ -11086,7 +11097,7 @@ async function importGlobalMcp(projectRoot, results) {
|
|
|
11086
11097
|
feature: "mcp"
|
|
11087
11098
|
});
|
|
11088
11099
|
}
|
|
11089
|
-
async function importGlobalAgents(projectRoot, results,
|
|
11100
|
+
async function importGlobalAgents(projectRoot, results, normalize2) {
|
|
11090
11101
|
const agentsDir = join(projectRoot, CURSOR_AGENTS_DIR);
|
|
11091
11102
|
const destDir = join(projectRoot, CURSOR_CANONICAL_AGENTS_DIR);
|
|
11092
11103
|
results.push(
|
|
@@ -11095,12 +11106,12 @@ async function importGlobalAgents(projectRoot, results, normalize) {
|
|
|
11095
11106
|
destDir,
|
|
11096
11107
|
extensions: [".md"],
|
|
11097
11108
|
fromTool: CURSOR_TARGET2,
|
|
11098
|
-
normalize,
|
|
11109
|
+
normalize: normalize2,
|
|
11099
11110
|
mapEntry: ({ relativePath, normalizeTo }) => mapCursorAgentFile(relativePath, destDir, normalizeTo)
|
|
11100
11111
|
})
|
|
11101
11112
|
);
|
|
11102
11113
|
}
|
|
11103
|
-
async function importGlobalCommands(projectRoot, results,
|
|
11114
|
+
async function importGlobalCommands(projectRoot, results, normalize2) {
|
|
11104
11115
|
const commandsDir = join(projectRoot, CURSOR_COMMANDS_DIR);
|
|
11105
11116
|
const destDir = join(projectRoot, CURSOR_CANONICAL_COMMANDS_DIR);
|
|
11106
11117
|
results.push(
|
|
@@ -11109,7 +11120,7 @@ async function importGlobalCommands(projectRoot, results, normalize) {
|
|
|
11109
11120
|
destDir,
|
|
11110
11121
|
extensions: [".md"],
|
|
11111
11122
|
fromTool: CURSOR_TARGET2,
|
|
11112
|
-
normalize,
|
|
11123
|
+
normalize: normalize2,
|
|
11113
11124
|
mapEntry: ({ relativePath, normalizeTo }) => mapCursorCommandFile(relativePath, destDir, normalizeTo)
|
|
11114
11125
|
})
|
|
11115
11126
|
);
|
|
@@ -11131,14 +11142,14 @@ var init_import_global_exports_helpers = __esm({
|
|
|
11131
11142
|
async function importFromCursorGlobalExports(projectRoot) {
|
|
11132
11143
|
if (!await hasGlobalCursorArtifacts(projectRoot)) return [];
|
|
11133
11144
|
const results = [];
|
|
11134
|
-
const
|
|
11135
|
-
let rootWritten = await importGlobalCursorRulesFromDir(projectRoot, results,
|
|
11136
|
-
if (!rootWritten) rootWritten = await importGlobalUserRules(projectRoot, results,
|
|
11137
|
-
if (!rootWritten) await importGlobalDotCursorAgents(projectRoot, results,
|
|
11145
|
+
const normalize2 = await createImportReferenceNormalizer(CURSOR_TARGET2, projectRoot, "global");
|
|
11146
|
+
let rootWritten = await importGlobalCursorRulesFromDir(projectRoot, results, normalize2);
|
|
11147
|
+
if (!rootWritten) rootWritten = await importGlobalUserRules(projectRoot, results, normalize2);
|
|
11148
|
+
if (!rootWritten) await importGlobalDotCursorAgents(projectRoot, results, normalize2);
|
|
11138
11149
|
await importGlobalMcp(projectRoot, results);
|
|
11139
|
-
await importSkills3(projectRoot, results,
|
|
11140
|
-
await importGlobalAgents(projectRoot, results,
|
|
11141
|
-
await importGlobalCommands(projectRoot, results,
|
|
11150
|
+
await importSkills3(projectRoot, results, normalize2, CURSOR_SKILLS_DIR);
|
|
11151
|
+
await importGlobalAgents(projectRoot, results, normalize2);
|
|
11152
|
+
await importGlobalCommands(projectRoot, results, normalize2);
|
|
11142
11153
|
await importSettings2(projectRoot, results);
|
|
11143
11154
|
await importIgnore(projectRoot, results);
|
|
11144
11155
|
return results;
|
|
@@ -11177,10 +11188,10 @@ async function importFromCursor(projectRoot, options = {}) {
|
|
|
11177
11188
|
return importFromCursorGlobalExports(projectRoot);
|
|
11178
11189
|
}
|
|
11179
11190
|
const results = [];
|
|
11180
|
-
const
|
|
11181
|
-
await importCursorRules(projectRoot, results,
|
|
11182
|
-
results.push(...await runDescriptorImport(descriptor12, projectRoot, "project", { normalize }));
|
|
11183
|
-
await importSkills3(projectRoot, results,
|
|
11191
|
+
const normalize2 = await createImportReferenceNormalizer("cursor", projectRoot);
|
|
11192
|
+
await importCursorRules(projectRoot, results, normalize2);
|
|
11193
|
+
results.push(...await runDescriptorImport(descriptor12, projectRoot, "project", { normalize: normalize2 }));
|
|
11194
|
+
await importSkills3(projectRoot, results, normalize2);
|
|
11184
11195
|
await importMcp3(projectRoot, results);
|
|
11185
11196
|
await importSettings2(projectRoot, results);
|
|
11186
11197
|
await importIgnore(projectRoot, results);
|
|
@@ -11538,14 +11549,14 @@ var init_generator15 = __esm({
|
|
|
11538
11549
|
async function importFromDeepagentsCli(projectRoot, options = {}) {
|
|
11539
11550
|
const scope = options.scope ?? "project";
|
|
11540
11551
|
const results = [];
|
|
11541
|
-
const
|
|
11552
|
+
const normalize2 = await createImportReferenceNormalizer(
|
|
11542
11553
|
DEEPAGENTS_CLI_TARGET,
|
|
11543
11554
|
projectRoot,
|
|
11544
11555
|
scope
|
|
11545
11556
|
);
|
|
11546
|
-
results.push(...await runDescriptorImport(descriptor13, projectRoot, scope, { normalize }));
|
|
11557
|
+
results.push(...await runDescriptorImport(descriptor13, projectRoot, scope, { normalize: normalize2 }));
|
|
11547
11558
|
const skillsDir = scope === "global" ? DEEPAGENTS_CLI_GLOBAL_SKILLS_DIR : DEEPAGENTS_CLI_SKILLS_DIR;
|
|
11548
|
-
await importEmbeddedSkills(projectRoot, skillsDir, DEEPAGENTS_CLI_TARGET, results,
|
|
11559
|
+
await importEmbeddedSkills(projectRoot, skillsDir, DEEPAGENTS_CLI_TARGET, results, normalize2);
|
|
11549
11560
|
return results;
|
|
11550
11561
|
}
|
|
11551
11562
|
var init_importer13 = __esm({
|
|
@@ -11872,10 +11883,10 @@ var init_mcp_import2 = __esm({
|
|
|
11872
11883
|
async function importFromFactoryDroid(projectRoot, options = {}) {
|
|
11873
11884
|
const scope = options.scope ?? "project";
|
|
11874
11885
|
const results = [];
|
|
11875
|
-
const
|
|
11876
|
-
results.push(...await runDescriptorImport(descriptor14, projectRoot, scope, { normalize }));
|
|
11886
|
+
const normalize2 = await createImportReferenceNormalizer(FACTORY_DROID_TARGET, projectRoot, scope);
|
|
11887
|
+
results.push(...await runDescriptorImport(descriptor14, projectRoot, scope, { normalize: normalize2 }));
|
|
11877
11888
|
const skillsDir = scope === "global" ? FACTORY_DROID_GLOBAL_SKILLS_DIR : FACTORY_DROID_SKILLS_DIR;
|
|
11878
|
-
await importEmbeddedSkills(projectRoot, skillsDir, FACTORY_DROID_TARGET, results,
|
|
11889
|
+
await importEmbeddedSkills(projectRoot, skillsDir, FACTORY_DROID_TARGET, results, normalize2);
|
|
11879
11890
|
const mcpFile = scope === "global" ? FACTORY_DROID_GLOBAL_MCP_FILE : FACTORY_DROID_MCP_FILE;
|
|
11880
11891
|
await importFactoryDroidMcp(projectRoot, mcpFile, results);
|
|
11881
11892
|
return results;
|
|
@@ -12689,7 +12700,7 @@ var init_importer_strip = __esm({
|
|
|
12689
12700
|
"src/targets/gemini-cli/importer-strip.ts"() {
|
|
12690
12701
|
}
|
|
12691
12702
|
});
|
|
12692
|
-
async function importGeminiSkillsAndAgents(projectRoot, results,
|
|
12703
|
+
async function importGeminiSkillsAndAgents(projectRoot, results, normalize2) {
|
|
12693
12704
|
const geminiSkillsPath = join(projectRoot, GEMINI_SKILLS_DIR);
|
|
12694
12705
|
const skillDirs = await readDirRecursive(geminiSkillsPath);
|
|
12695
12706
|
const skillMdFiles = skillDirs.filter((f) => basename(f) === "SKILL.md");
|
|
@@ -12705,7 +12716,7 @@ async function importGeminiSkillsAndAgents(projectRoot, results, normalize) {
|
|
|
12705
12716
|
const agentPath = join(agentsDir, `${projectedAgent.name}.md`);
|
|
12706
12717
|
await writeFileAtomic(
|
|
12707
12718
|
agentPath,
|
|
12708
|
-
serializeImportedAgent(projectedAgent,
|
|
12719
|
+
serializeImportedAgent(projectedAgent, normalize2(rawParsed.body, srcPath, agentPath))
|
|
12709
12720
|
);
|
|
12710
12721
|
results.push({
|
|
12711
12722
|
fromTool: "gemini-cli",
|
|
@@ -12716,7 +12727,7 @@ async function importGeminiSkillsAndAgents(projectRoot, results, normalize) {
|
|
|
12716
12727
|
continue;
|
|
12717
12728
|
}
|
|
12718
12729
|
const destPath = join(projectRoot, GEMINI_CANONICAL_SKILLS_DIR, skillName, "SKILL.md");
|
|
12719
|
-
const normalized =
|
|
12730
|
+
const normalized = normalize2(content, srcPath, destPath);
|
|
12720
12731
|
const skillDir = join(projectRoot, GEMINI_CANONICAL_SKILLS_DIR, skillName);
|
|
12721
12732
|
await mkdirp(skillDir);
|
|
12722
12733
|
const { frontmatter, body } = parseFrontmatter(normalized);
|
|
@@ -12738,7 +12749,7 @@ async function importGeminiSkillsAndAgents(projectRoot, results, normalize) {
|
|
|
12738
12749
|
const relPath = relative(dirname(srcPath), absPath).replace(/\\/g, "/");
|
|
12739
12750
|
const destSupportPath = join(skillDir, relPath);
|
|
12740
12751
|
await mkdirp(dirname(destSupportPath));
|
|
12741
|
-
await writeFileAtomic(destSupportPath,
|
|
12752
|
+
await writeFileAtomic(destSupportPath, normalize2(supportContent, absPath, destSupportPath));
|
|
12742
12753
|
results.push({
|
|
12743
12754
|
fromTool: "gemini-cli",
|
|
12744
12755
|
fromPath: absPath,
|
|
@@ -12760,7 +12771,7 @@ async function importGeminiSkillsAndAgents(projectRoot, results, normalize) {
|
|
|
12760
12771
|
const agentsDir = join(projectRoot, GEMINI_CANONICAL_AGENTS_DIR);
|
|
12761
12772
|
await mkdirp(agentsDir);
|
|
12762
12773
|
const destPath = join(agentsDir, relativeMdPath);
|
|
12763
|
-
const normalizedBody =
|
|
12774
|
+
const normalizedBody = normalize2(body, srcPath, destPath);
|
|
12764
12775
|
await writeFileAtomic(
|
|
12765
12776
|
destPath,
|
|
12766
12777
|
await serializeImportedAgentWithFallback(
|
|
@@ -12794,7 +12805,7 @@ var init_importer_skills_agents = __esm({
|
|
|
12794
12805
|
init_constants30();
|
|
12795
12806
|
}
|
|
12796
12807
|
});
|
|
12797
|
-
async function importRootRule2(projectRoot, results,
|
|
12808
|
+
async function importRootRule2(projectRoot, results, normalize2) {
|
|
12798
12809
|
const normalizeCodex = await createImportReferenceNormalizer("codex-cli", projectRoot);
|
|
12799
12810
|
const rulesDir = join(projectRoot, GEMINI_CANONICAL_RULES_DIR);
|
|
12800
12811
|
const compatAgentsRootPath = join(projectRoot, GEMINI_COMPAT_AGENTS);
|
|
@@ -12825,10 +12836,10 @@ async function importRootRule2(projectRoot, results, normalize) {
|
|
|
12825
12836
|
rulesDir: GEMINI_CANONICAL_RULES_DIR,
|
|
12826
12837
|
sourcePath: rootSourcePath,
|
|
12827
12838
|
fromTool: GEMINI_TARGET,
|
|
12828
|
-
normalize
|
|
12839
|
+
normalize: normalize2
|
|
12829
12840
|
});
|
|
12830
12841
|
results.push(...split.results);
|
|
12831
|
-
const compatNormalized =
|
|
12842
|
+
const compatNormalized = normalize2(split.rootContent, rootSourcePath, destPath);
|
|
12832
12843
|
const normalizedRoot = stripProjectRootCanonicalPrefix(
|
|
12833
12844
|
compatNormalized.replace(/\.agents\/skills\//g, ".agentsmesh/skills/").replace(/\.agents\\skills\\/g, ".agentsmesh/skills/"),
|
|
12834
12845
|
projectRoot
|
|
@@ -12850,10 +12861,10 @@ async function importRootRule2(projectRoot, results, normalize) {
|
|
|
12850
12861
|
}
|
|
12851
12862
|
async function importFromGemini(projectRoot) {
|
|
12852
12863
|
const results = [];
|
|
12853
|
-
const
|
|
12854
|
-
await importRootRule2(projectRoot, results,
|
|
12855
|
-
results.push(...await runDescriptorImport(descriptor15, projectRoot, "project", { normalize }));
|
|
12856
|
-
await importGeminiSkillsAndAgents(projectRoot, results,
|
|
12864
|
+
const normalize2 = await createImportReferenceNormalizer(GEMINI_TARGET, projectRoot);
|
|
12865
|
+
await importRootRule2(projectRoot, results, normalize2);
|
|
12866
|
+
results.push(...await runDescriptorImport(descriptor15, projectRoot, "project", { normalize: normalize2 }));
|
|
12867
|
+
await importGeminiSkillsAndAgents(projectRoot, results, normalize2);
|
|
12857
12868
|
await importGeminiSettings(projectRoot, results);
|
|
12858
12869
|
await importGeminiIgnore(projectRoot, results);
|
|
12859
12870
|
results.push(...await importGeminiPolicies(projectRoot));
|
|
@@ -13254,10 +13265,10 @@ var init_generator19 = __esm({
|
|
|
13254
13265
|
async function importFromGoose(projectRoot, options = {}) {
|
|
13255
13266
|
const scope = options.scope ?? "project";
|
|
13256
13267
|
const results = [];
|
|
13257
|
-
const
|
|
13258
|
-
results.push(...await runDescriptorImport(descriptor16, projectRoot, scope, { normalize }));
|
|
13268
|
+
const normalize2 = await createImportReferenceNormalizer(GOOSE_TARGET, projectRoot, scope);
|
|
13269
|
+
results.push(...await runDescriptorImport(descriptor16, projectRoot, scope, { normalize: normalize2 }));
|
|
13259
13270
|
const skillsDir = scope === "global" ? GOOSE_GLOBAL_SKILLS_DIR : GOOSE_SKILLS_DIR;
|
|
13260
|
-
await importEmbeddedSkills(projectRoot, skillsDir, GOOSE_TARGET, results,
|
|
13271
|
+
await importEmbeddedSkills(projectRoot, skillsDir, GOOSE_TARGET, results, normalize2);
|
|
13261
13272
|
return results;
|
|
13262
13273
|
}
|
|
13263
13274
|
var init_importer16 = __esm({
|
|
@@ -13489,8 +13500,8 @@ var init_generator20 = __esm({
|
|
|
13489
13500
|
// src/targets/jules/importer.ts
|
|
13490
13501
|
async function importFromJules(projectRoot, options = {}) {
|
|
13491
13502
|
const scope = options.scope ?? "project";
|
|
13492
|
-
const
|
|
13493
|
-
return runDescriptorImport(descriptor17, projectRoot, scope, { normalize });
|
|
13503
|
+
const normalize2 = await createImportReferenceNormalizer(JULES_TARGET, projectRoot, scope);
|
|
13504
|
+
return runDescriptorImport(descriptor17, projectRoot, scope, { normalize: normalize2 });
|
|
13494
13505
|
}
|
|
13495
13506
|
var init_importer17 = __esm({
|
|
13496
13507
|
"src/targets/jules/importer.ts"() {
|
|
@@ -13759,7 +13770,7 @@ var init_generator21 = __esm({
|
|
|
13759
13770
|
init_constants16();
|
|
13760
13771
|
}
|
|
13761
13772
|
});
|
|
13762
|
-
async function importRootRule3(projectRoot, results,
|
|
13773
|
+
async function importRootRule3(projectRoot, results, normalize2) {
|
|
13763
13774
|
const sources = [JUNIE_DOT_AGENTS, JUNIE_GUIDELINES, JUNIE_CI_GUIDELINES, JUNIE_AGENTS_FALLBACK];
|
|
13764
13775
|
const destPath = join(projectRoot, JUNIE_CANONICAL_ROOT_RULE);
|
|
13765
13776
|
for (const relPath of sources) {
|
|
@@ -13772,10 +13783,10 @@ async function importRootRule3(projectRoot, results, normalize) {
|
|
|
13772
13783
|
rulesDir: JUNIE_CANONICAL_RULES_DIR,
|
|
13773
13784
|
sourcePath: srcPath,
|
|
13774
13785
|
fromTool: JUNIE_TARGET,
|
|
13775
|
-
normalize
|
|
13786
|
+
normalize: normalize2
|
|
13776
13787
|
});
|
|
13777
13788
|
results.push(...split.results);
|
|
13778
|
-
const { frontmatter, body } = parseFrontmatter(
|
|
13789
|
+
const { frontmatter, body } = parseFrontmatter(normalize2(split.rootContent, srcPath, destPath));
|
|
13779
13790
|
const output = await serializeImportedRuleWithFallback(
|
|
13780
13791
|
destPath,
|
|
13781
13792
|
{
|
|
@@ -13797,10 +13808,10 @@ async function importRootRule3(projectRoot, results, normalize) {
|
|
|
13797
13808
|
}
|
|
13798
13809
|
async function importFromJunie(projectRoot) {
|
|
13799
13810
|
const results = [];
|
|
13800
|
-
const
|
|
13801
|
-
await importRootRule3(projectRoot, results,
|
|
13802
|
-
results.push(...await runDescriptorImport(descriptor18, projectRoot, "project", { normalize }));
|
|
13803
|
-
await importEmbeddedSkills(projectRoot, JUNIE_SKILLS_DIR, JUNIE_TARGET, results,
|
|
13811
|
+
const normalize2 = await createImportReferenceNormalizer(JUNIE_TARGET, projectRoot);
|
|
13812
|
+
await importRootRule3(projectRoot, results, normalize2);
|
|
13813
|
+
results.push(...await runDescriptorImport(descriptor18, projectRoot, "project", { normalize: normalize2 }));
|
|
13814
|
+
await importEmbeddedSkills(projectRoot, JUNIE_SKILLS_DIR, JUNIE_TARGET, results, normalize2);
|
|
13804
13815
|
return results;
|
|
13805
13816
|
}
|
|
13806
13817
|
var init_importer18 = __esm({
|
|
@@ -14192,7 +14203,7 @@ async function pathExists(absolutePath) {
|
|
|
14192
14203
|
return false;
|
|
14193
14204
|
}
|
|
14194
14205
|
}
|
|
14195
|
-
async function importLegacyRules(projectRoot, results,
|
|
14206
|
+
async function importLegacyRules(projectRoot, results, normalize2) {
|
|
14196
14207
|
const srcDir = join(projectRoot, KILO_CODE_LEGACY_RULES_DIR);
|
|
14197
14208
|
if (!await pathExists(srcDir)) return;
|
|
14198
14209
|
const destDir = join(projectRoot, KILO_CODE_CANONICAL_RULES_DIR);
|
|
@@ -14201,7 +14212,7 @@ async function importLegacyRules(projectRoot, results, normalize) {
|
|
|
14201
14212
|
const rootContent = hasCurrentRoot ? null : await readFileSafe(rootSourceFile);
|
|
14202
14213
|
if (rootContent !== null) {
|
|
14203
14214
|
const destPath = join(projectRoot, CANONICAL_ROOT_RULE_PATH);
|
|
14204
|
-
const normalized =
|
|
14215
|
+
const normalized = normalize2(rootContent, rootSourceFile, destPath);
|
|
14205
14216
|
const { body } = parseFrontmatter(normalized);
|
|
14206
14217
|
const serialized = await serializeImportedRuleWithFallback(destPath, { root: true }, body);
|
|
14207
14218
|
await writeFileAtomic(destPath, serialized);
|
|
@@ -14218,7 +14229,7 @@ async function importLegacyRules(projectRoot, results, normalize) {
|
|
|
14218
14229
|
destDir,
|
|
14219
14230
|
extensions: [".md"],
|
|
14220
14231
|
fromTool: KILO_CODE_TARGET,
|
|
14221
|
-
normalize,
|
|
14232
|
+
normalize: normalize2,
|
|
14222
14233
|
mapEntry: async ({ srcPath, relativePath, content, normalizeTo }) => {
|
|
14223
14234
|
const mapping = await kiloNonRootRuleMapper({
|
|
14224
14235
|
absolutePath: srcPath,
|
|
@@ -14234,7 +14245,7 @@ async function importLegacyRules(projectRoot, results, normalize) {
|
|
|
14234
14245
|
})
|
|
14235
14246
|
);
|
|
14236
14247
|
}
|
|
14237
|
-
async function importLegacyWorkflows(projectRoot, results,
|
|
14248
|
+
async function importLegacyWorkflows(projectRoot, results, normalize2) {
|
|
14238
14249
|
const srcDir = join(projectRoot, KILO_CODE_LEGACY_WORKFLOWS_DIR);
|
|
14239
14250
|
if (!await pathExists(srcDir)) return;
|
|
14240
14251
|
const destDir = join(projectRoot, KILO_CODE_CANONICAL_COMMANDS_DIR);
|
|
@@ -14244,7 +14255,7 @@ async function importLegacyWorkflows(projectRoot, results, normalize) {
|
|
|
14244
14255
|
destDir,
|
|
14245
14256
|
extensions: [".md"],
|
|
14246
14257
|
fromTool: KILO_CODE_TARGET,
|
|
14247
|
-
normalize,
|
|
14258
|
+
normalize: normalize2,
|
|
14248
14259
|
mapEntry: async ({ srcPath, relativePath, content, normalizeTo }) => {
|
|
14249
14260
|
const mapping = await kiloCommandMapper({
|
|
14250
14261
|
absolutePath: srcPath,
|
|
@@ -14259,7 +14270,7 @@ async function importLegacyWorkflows(projectRoot, results, normalize) {
|
|
|
14259
14270
|
})
|
|
14260
14271
|
);
|
|
14261
14272
|
}
|
|
14262
|
-
async function importLegacyModes(projectRoot, results,
|
|
14273
|
+
async function importLegacyModes(projectRoot, results, normalize2) {
|
|
14263
14274
|
const sourceFile = join(projectRoot, KILO_CODE_LEGACY_MODES_FILE);
|
|
14264
14275
|
const content = await readFileSafe(sourceFile);
|
|
14265
14276
|
if (content === null) return;
|
|
@@ -14288,7 +14299,7 @@ ${whenToUse}` : role;
|
|
|
14288
14299
|
if (description) frontmatter.description = description;
|
|
14289
14300
|
if (typeof mode.name === "string" && mode.name.length > 0) frontmatter.name = mode.name;
|
|
14290
14301
|
const serialized = await serializeImportedAgentWithFallback(destPath, frontmatter, body);
|
|
14291
|
-
const normalized =
|
|
14302
|
+
const normalized = normalize2(serialized, sourceFile, destPath);
|
|
14292
14303
|
await writeFileAtomic(destPath, normalized);
|
|
14293
14304
|
results.push({
|
|
14294
14305
|
feature: "agents",
|
|
@@ -14301,25 +14312,25 @@ ${whenToUse}` : role;
|
|
|
14301
14312
|
async function importFromKiloCode(projectRoot, options = {}) {
|
|
14302
14313
|
const scope = options.scope ?? "project";
|
|
14303
14314
|
const results = [];
|
|
14304
|
-
const
|
|
14305
|
-
results.push(...await runDescriptorImport(descriptor19, projectRoot, scope, { normalize }));
|
|
14315
|
+
const normalize2 = await createImportReferenceNormalizer(KILO_CODE_TARGET, projectRoot, scope);
|
|
14316
|
+
results.push(...await runDescriptorImport(descriptor19, projectRoot, scope, { normalize: normalize2 }));
|
|
14306
14317
|
await importEmbeddedSkills(
|
|
14307
14318
|
projectRoot,
|
|
14308
14319
|
KILO_CODE_SKILLS_DIR,
|
|
14309
14320
|
KILO_CODE_TARGET,
|
|
14310
14321
|
results,
|
|
14311
|
-
|
|
14322
|
+
normalize2
|
|
14312
14323
|
);
|
|
14313
14324
|
if (scope === "project") {
|
|
14314
|
-
await importLegacyRules(projectRoot, results,
|
|
14315
|
-
await importLegacyWorkflows(projectRoot, results,
|
|
14316
|
-
await importLegacyModes(projectRoot, results,
|
|
14325
|
+
await importLegacyRules(projectRoot, results, normalize2);
|
|
14326
|
+
await importLegacyWorkflows(projectRoot, results, normalize2);
|
|
14327
|
+
await importLegacyModes(projectRoot, results, normalize2);
|
|
14317
14328
|
await importEmbeddedSkills(
|
|
14318
14329
|
projectRoot,
|
|
14319
14330
|
KILO_CODE_LEGACY_SKILLS_DIR,
|
|
14320
14331
|
KILO_CODE_TARGET,
|
|
14321
14332
|
results,
|
|
14322
|
-
|
|
14333
|
+
normalize2
|
|
14323
14334
|
);
|
|
14324
14335
|
}
|
|
14325
14336
|
return results;
|
|
@@ -14788,14 +14799,14 @@ function canonicalRuleMeta2(frontmatter) {
|
|
|
14788
14799
|
if (inclusion === "fileMatch") meta.trigger = "glob";
|
|
14789
14800
|
return meta;
|
|
14790
14801
|
}
|
|
14791
|
-
async function importRoot(projectRoot, results,
|
|
14802
|
+
async function importRoot(projectRoot, results, normalize2, scope) {
|
|
14792
14803
|
const candidates = scope === "global" ? [KIRO_GLOBAL_STEERING_AGENTS_MD, KIRO_AGENTS_MD] : [KIRO_AGENTS_MD, KIRO_GLOBAL_STEERING_AGENTS_MD];
|
|
14793
14804
|
for (const rel2 of candidates) {
|
|
14794
14805
|
const srcPath = join(projectRoot, rel2);
|
|
14795
14806
|
const content = await readFileSafe(srcPath);
|
|
14796
14807
|
if (content === null) continue;
|
|
14797
14808
|
const destPath = join(projectRoot, KIRO_CANONICAL_ROOT_RULE);
|
|
14798
|
-
const { frontmatter, body } = parseFrontmatter(
|
|
14809
|
+
const { frontmatter, body } = parseFrontmatter(normalize2(content, srcPath, destPath));
|
|
14799
14810
|
await writeFileAtomic(
|
|
14800
14811
|
destPath,
|
|
14801
14812
|
await serializeImportedRuleWithFallback(destPath, { ...frontmatter, root: true }, body)
|
|
@@ -14809,7 +14820,7 @@ async function importRoot(projectRoot, results, normalize, scope) {
|
|
|
14809
14820
|
return;
|
|
14810
14821
|
}
|
|
14811
14822
|
}
|
|
14812
|
-
async function importNonRootRules(projectRoot, results,
|
|
14823
|
+
async function importNonRootRules(projectRoot, results, normalize2) {
|
|
14813
14824
|
const destDir = join(projectRoot, KIRO_CANONICAL_RULES_DIR);
|
|
14814
14825
|
results.push(
|
|
14815
14826
|
...await importFileDirectory({
|
|
@@ -14817,7 +14828,7 @@ async function importNonRootRules(projectRoot, results, normalize) {
|
|
|
14817
14828
|
destDir,
|
|
14818
14829
|
extensions: [".md"],
|
|
14819
14830
|
fromTool: KIRO_TARGET,
|
|
14820
|
-
normalize,
|
|
14831
|
+
normalize: normalize2,
|
|
14821
14832
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
14822
14833
|
if (basename(relativePath) === "AGENTS.md") return null;
|
|
14823
14834
|
const destPath = join(destDir, relativePath);
|
|
@@ -14859,11 +14870,11 @@ async function importHooks2(projectRoot, results) {
|
|
|
14859
14870
|
async function importFromKiro(projectRoot, options = {}) {
|
|
14860
14871
|
const scope = options.scope ?? "project";
|
|
14861
14872
|
const results = [];
|
|
14862
|
-
const
|
|
14863
|
-
await importRoot(projectRoot, results,
|
|
14864
|
-
await importNonRootRules(projectRoot, results,
|
|
14865
|
-
results.push(...await runDescriptorImport(descriptor20, projectRoot, scope, { normalize }));
|
|
14866
|
-
await importEmbeddedSkills(projectRoot, KIRO_SKILLS_DIR, KIRO_TARGET, results,
|
|
14873
|
+
const normalize2 = await createImportReferenceNormalizer(KIRO_TARGET, projectRoot, scope);
|
|
14874
|
+
await importRoot(projectRoot, results, normalize2, scope);
|
|
14875
|
+
await importNonRootRules(projectRoot, results, normalize2);
|
|
14876
|
+
results.push(...await runDescriptorImport(descriptor20, projectRoot, scope, { normalize: normalize2 }));
|
|
14877
|
+
await importEmbeddedSkills(projectRoot, KIRO_SKILLS_DIR, KIRO_TARGET, results, normalize2);
|
|
14867
14878
|
if (scope === "project") await importHooks2(projectRoot, results);
|
|
14868
14879
|
return results;
|
|
14869
14880
|
}
|
|
@@ -15247,9 +15258,9 @@ async function importMcp4(projectRoot, scope, results) {
|
|
|
15247
15258
|
async function importFromOpenCode(projectRoot, options = {}) {
|
|
15248
15259
|
const scope = options.scope ?? "project";
|
|
15249
15260
|
const results = [];
|
|
15250
|
-
const
|
|
15251
|
-
results.push(...await runDescriptorImport(descriptor21, projectRoot, scope, { normalize }));
|
|
15252
|
-
await importEmbeddedSkills(projectRoot, OPENCODE_SKILLS_DIR, OPENCODE_TARGET, results,
|
|
15261
|
+
const normalize2 = await createImportReferenceNormalizer(OPENCODE_TARGET, projectRoot, scope);
|
|
15262
|
+
results.push(...await runDescriptorImport(descriptor21, projectRoot, scope, { normalize: normalize2 }));
|
|
15263
|
+
await importEmbeddedSkills(projectRoot, OPENCODE_SKILLS_DIR, OPENCODE_TARGET, results, normalize2);
|
|
15253
15264
|
await importMcp4(projectRoot, scope, results);
|
|
15254
15265
|
return results;
|
|
15255
15266
|
}
|
|
@@ -15608,10 +15619,10 @@ var init_generator25 = __esm({
|
|
|
15608
15619
|
async function importFromPiAgent(projectRoot, options = {}) {
|
|
15609
15620
|
const scope = options.scope ?? "project";
|
|
15610
15621
|
const results = [];
|
|
15611
|
-
const
|
|
15612
|
-
results.push(...await runDescriptorImport(descriptor22, projectRoot, scope, { normalize }));
|
|
15622
|
+
const normalize2 = await createImportReferenceNormalizer(PI_AGENT_TARGET, projectRoot, scope);
|
|
15623
|
+
results.push(...await runDescriptorImport(descriptor22, projectRoot, scope, { normalize: normalize2 }));
|
|
15613
15624
|
const skillsDir = scope === "global" ? PI_AGENT_GLOBAL_SKILLS_DIR : PI_AGENT_SKILLS_DIR;
|
|
15614
|
-
await importEmbeddedSkills(projectRoot, skillsDir, PI_AGENT_TARGET, results,
|
|
15625
|
+
await importEmbeddedSkills(projectRoot, skillsDir, PI_AGENT_TARGET, results, normalize2);
|
|
15615
15626
|
return results;
|
|
15616
15627
|
}
|
|
15617
15628
|
var init_importer22 = __esm({
|
|
@@ -15900,9 +15911,18 @@ function generateIgnore12(canonical) {
|
|
|
15900
15911
|
if (!canonical.ignore || canonical.ignore.length === 0) return [];
|
|
15901
15912
|
return [{ path: QWEN_IGNORE, content: canonical.ignore.join("\n") }];
|
|
15902
15913
|
}
|
|
15914
|
+
function renderQwenGlobalInstructions(canonical) {
|
|
15915
|
+
const root = canonical.rules.find((rule) => rule.root);
|
|
15916
|
+
const nonRootRules = canonical.rules.filter((rule) => {
|
|
15917
|
+
if (rule.root) return false;
|
|
15918
|
+
return rule.targets.length === 0 || rule.targets.includes(QWEN_CODE_TARGET);
|
|
15919
|
+
});
|
|
15920
|
+
return appendEmbeddedRulesBlock(root?.body.trim() ?? "", nonRootRules);
|
|
15921
|
+
}
|
|
15903
15922
|
var init_generator26 = __esm({
|
|
15904
15923
|
"src/targets/qwen-code/generator.ts"() {
|
|
15905
15924
|
init_markdown();
|
|
15925
|
+
init_managed_blocks();
|
|
15906
15926
|
init_constants21();
|
|
15907
15927
|
}
|
|
15908
15928
|
});
|
|
@@ -15911,10 +15931,10 @@ var init_generator26 = __esm({
|
|
|
15911
15931
|
async function importFromQwenCode(projectRoot, options = {}) {
|
|
15912
15932
|
const scope = options.scope ?? "project";
|
|
15913
15933
|
const results = [];
|
|
15914
|
-
const
|
|
15915
|
-
results.push(...await runDescriptorImport(descriptor23, projectRoot, scope, { normalize }));
|
|
15934
|
+
const normalize2 = await createImportReferenceNormalizer(QWEN_CODE_TARGET, projectRoot, scope);
|
|
15935
|
+
results.push(...await runDescriptorImport(descriptor23, projectRoot, scope, { normalize: normalize2 }));
|
|
15916
15936
|
const skillsDir = scope === "global" ? QWEN_GLOBAL_SKILLS_DIR : QWEN_SKILLS_DIR;
|
|
15917
|
-
await importEmbeddedSkills(projectRoot, skillsDir, QWEN_CODE_TARGET, results,
|
|
15937
|
+
await importEmbeddedSkills(projectRoot, skillsDir, QWEN_CODE_TARGET, results, normalize2);
|
|
15918
15938
|
return results;
|
|
15919
15939
|
}
|
|
15920
15940
|
var init_importer23 = __esm({
|
|
@@ -15985,6 +16005,7 @@ var init_qwen_code2 = __esm({
|
|
|
15985
16005
|
};
|
|
15986
16006
|
globalLayout22 = {
|
|
15987
16007
|
rootInstructionPath: QWEN_GLOBAL_ROOT,
|
|
16008
|
+
renderPrimaryRootInstruction: renderQwenGlobalInstructions,
|
|
15988
16009
|
skillDir: QWEN_GLOBAL_SKILLS_DIR,
|
|
15989
16010
|
managedOutputs: {
|
|
15990
16011
|
dirs: [QWEN_GLOBAL_COMMANDS_DIR, QWEN_GLOBAL_AGENTS_DIR, QWEN_GLOBAL_SKILLS_DIR],
|
|
@@ -16181,14 +16202,14 @@ var init_generator27 = __esm({
|
|
|
16181
16202
|
async function importFromReplitAgent(projectRoot, options = {}) {
|
|
16182
16203
|
const scope = options.scope ?? "project";
|
|
16183
16204
|
const results = [];
|
|
16184
|
-
const
|
|
16185
|
-
results.push(...await runDescriptorImport(descriptor24, projectRoot, scope, { normalize }));
|
|
16205
|
+
const normalize2 = await createImportReferenceNormalizer(REPLIT_AGENT_TARGET, projectRoot, scope);
|
|
16206
|
+
results.push(...await runDescriptorImport(descriptor24, projectRoot, scope, { normalize: normalize2 }));
|
|
16186
16207
|
await importEmbeddedSkills(
|
|
16187
16208
|
projectRoot,
|
|
16188
16209
|
REPLIT_AGENT_SKILLS_DIR,
|
|
16189
16210
|
REPLIT_AGENT_TARGET,
|
|
16190
16211
|
results,
|
|
16191
|
-
|
|
16212
|
+
normalize2
|
|
16192
16213
|
);
|
|
16193
16214
|
return results;
|
|
16194
16215
|
}
|
|
@@ -16479,7 +16500,7 @@ var init_import_mappers9 = __esm({
|
|
|
16479
16500
|
};
|
|
16480
16501
|
}
|
|
16481
16502
|
});
|
|
16482
|
-
async function importPerModeRules(projectRoot, results,
|
|
16503
|
+
async function importPerModeRules(projectRoot, results, normalize2) {
|
|
16483
16504
|
const rooDir = join(projectRoot, ROO_CODE_DIR);
|
|
16484
16505
|
let entries;
|
|
16485
16506
|
try {
|
|
@@ -16496,7 +16517,7 @@ async function importPerModeRules(projectRoot, results, normalize) {
|
|
|
16496
16517
|
destDir,
|
|
16497
16518
|
extensions: [".md"],
|
|
16498
16519
|
fromTool: ROO_CODE_TARGET,
|
|
16499
|
-
normalize,
|
|
16520
|
+
normalize: normalize2,
|
|
16500
16521
|
mapEntry: async ({ srcPath, relativePath, content, normalizeTo }) => {
|
|
16501
16522
|
const mapping = await rooNonRootRuleMapper({
|
|
16502
16523
|
absolutePath: srcPath,
|
|
@@ -16515,10 +16536,10 @@ async function importPerModeRules(projectRoot, results, normalize) {
|
|
|
16515
16536
|
async function importFromRooCode(projectRoot, options = {}) {
|
|
16516
16537
|
const scope = options.scope ?? "project";
|
|
16517
16538
|
const results = [];
|
|
16518
|
-
const
|
|
16519
|
-
results.push(...await runDescriptorImport(descriptor25, projectRoot, scope, { normalize }));
|
|
16520
|
-
await importPerModeRules(projectRoot, results,
|
|
16521
|
-
await importEmbeddedSkills(projectRoot, ROO_CODE_SKILLS_DIR, ROO_CODE_TARGET, results,
|
|
16539
|
+
const normalize2 = await createImportReferenceNormalizer(ROO_CODE_TARGET, projectRoot, scope);
|
|
16540
|
+
results.push(...await runDescriptorImport(descriptor25, projectRoot, scope, { normalize: normalize2 }));
|
|
16541
|
+
await importPerModeRules(projectRoot, results, normalize2);
|
|
16542
|
+
await importEmbeddedSkills(projectRoot, ROO_CODE_SKILLS_DIR, ROO_CODE_TARGET, results, normalize2);
|
|
16522
16543
|
return results;
|
|
16523
16544
|
}
|
|
16524
16545
|
var init_importer25 = __esm({
|
|
@@ -16832,10 +16853,10 @@ var init_generator29 = __esm({
|
|
|
16832
16853
|
async function importFromRovodev(projectRoot, options = {}) {
|
|
16833
16854
|
const scope = options.scope ?? "project";
|
|
16834
16855
|
const results = [];
|
|
16835
|
-
const
|
|
16836
|
-
results.push(...await runDescriptorImport(descriptor26, projectRoot, scope, { normalize }));
|
|
16856
|
+
const normalize2 = await createImportReferenceNormalizer(ROVODEV_TARGET, projectRoot, scope);
|
|
16857
|
+
results.push(...await runDescriptorImport(descriptor26, projectRoot, scope, { normalize: normalize2 }));
|
|
16837
16858
|
const skillsDir = scope === "global" ? ROVODEV_GLOBAL_SKILLS_DIR : ROVODEV_SKILLS_DIR;
|
|
16838
|
-
await importEmbeddedSkills(projectRoot, skillsDir, ROVODEV_TARGET, results,
|
|
16859
|
+
await importEmbeddedSkills(projectRoot, skillsDir, ROVODEV_TARGET, results, normalize2);
|
|
16839
16860
|
return results;
|
|
16840
16861
|
}
|
|
16841
16862
|
var init_importer26 = __esm({
|
|
@@ -17093,14 +17114,14 @@ var init_generator30 = __esm({
|
|
|
17093
17114
|
init_constants25();
|
|
17094
17115
|
}
|
|
17095
17116
|
});
|
|
17096
|
-
async function importRoot2(projectRoot, results,
|
|
17117
|
+
async function importRoot2(projectRoot, results, normalize2, scope) {
|
|
17097
17118
|
const candidates = scope === "global" ? [TRAE_GLOBAL_ROOT_RULE, TRAE_PROJECT_RULES] : [TRAE_PROJECT_RULES, TRAE_GLOBAL_ROOT_RULE];
|
|
17098
17119
|
for (const rel2 of candidates) {
|
|
17099
17120
|
const srcPath = join(projectRoot, rel2);
|
|
17100
17121
|
const content = await readFileSafe(srcPath);
|
|
17101
17122
|
if (content === null) continue;
|
|
17102
17123
|
const destPath = join(projectRoot, CANONICAL_ROOT_RULE);
|
|
17103
|
-
const { frontmatter, body } = parseFrontmatter(
|
|
17124
|
+
const { frontmatter, body } = parseFrontmatter(normalize2(content, srcPath, destPath));
|
|
17104
17125
|
await mkdirp(join(projectRoot, TRAE_CANONICAL_RULES_DIR));
|
|
17105
17126
|
await writeFileAtomic(
|
|
17106
17127
|
destPath,
|
|
@@ -17115,7 +17136,7 @@ async function importRoot2(projectRoot, results, normalize, scope) {
|
|
|
17115
17136
|
return;
|
|
17116
17137
|
}
|
|
17117
17138
|
}
|
|
17118
|
-
async function importNonRootRules2(projectRoot, results,
|
|
17139
|
+
async function importNonRootRules2(projectRoot, results, normalize2, scope) {
|
|
17119
17140
|
const srcDir = join(projectRoot, scope === "global" ? TRAE_GLOBAL_RULES_DIR : TRAE_RULES_DIR);
|
|
17120
17141
|
const destDir = join(projectRoot, TRAE_CANONICAL_RULES_DIR);
|
|
17121
17142
|
results.push(
|
|
@@ -17124,7 +17145,7 @@ async function importNonRootRules2(projectRoot, results, normalize, scope) {
|
|
|
17124
17145
|
destDir,
|
|
17125
17146
|
extensions: [".md"],
|
|
17126
17147
|
fromTool: TRAE_TARGET,
|
|
17127
|
-
normalize,
|
|
17148
|
+
normalize: normalize2,
|
|
17128
17149
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
17129
17150
|
const filename = basename(relativePath);
|
|
17130
17151
|
if (filename === "project_rules.md" || filename === "rules.md") return null;
|
|
@@ -17147,16 +17168,16 @@ async function importNonRootRules2(projectRoot, results, normalize, scope) {
|
|
|
17147
17168
|
async function importFromTrae(projectRoot, options = {}) {
|
|
17148
17169
|
const scope = options.scope ?? "project";
|
|
17149
17170
|
const results = [];
|
|
17150
|
-
const
|
|
17151
|
-
await importRoot2(projectRoot, results,
|
|
17152
|
-
await importNonRootRules2(projectRoot, results,
|
|
17153
|
-
results.push(...await runDescriptorImport(descriptor27, projectRoot, scope, { normalize }));
|
|
17171
|
+
const normalize2 = await createImportReferenceNormalizer(TRAE_TARGET, projectRoot, scope);
|
|
17172
|
+
await importRoot2(projectRoot, results, normalize2, scope);
|
|
17173
|
+
await importNonRootRules2(projectRoot, results, normalize2, scope);
|
|
17174
|
+
results.push(...await runDescriptorImport(descriptor27, projectRoot, scope, { normalize: normalize2 }));
|
|
17154
17175
|
await importEmbeddedSkills(
|
|
17155
17176
|
projectRoot,
|
|
17156
17177
|
scope === "global" ? TRAE_GLOBAL_SKILLS_DIR : TRAE_SKILLS_DIR,
|
|
17157
17178
|
TRAE_TARGET,
|
|
17158
17179
|
results,
|
|
17159
|
-
|
|
17180
|
+
normalize2
|
|
17160
17181
|
);
|
|
17161
17182
|
return results;
|
|
17162
17183
|
}
|
|
@@ -17383,10 +17404,10 @@ var init_generator31 = __esm({
|
|
|
17383
17404
|
async function importFromWarp(projectRoot, options = {}) {
|
|
17384
17405
|
const scope = options.scope ?? "project";
|
|
17385
17406
|
const results = [];
|
|
17386
|
-
const
|
|
17387
|
-
results.push(...await runDescriptorImport(descriptor28, projectRoot, scope, { normalize }));
|
|
17407
|
+
const normalize2 = await createImportReferenceNormalizer(WARP_TARGET, projectRoot, scope);
|
|
17408
|
+
results.push(...await runDescriptorImport(descriptor28, projectRoot, scope, { normalize: normalize2 }));
|
|
17388
17409
|
const skillsDir = scope === "global" ? WARP_GLOBAL_SKILLS_DIR : WARP_SKILLS_DIR;
|
|
17389
|
-
await importEmbeddedSkills(projectRoot, skillsDir, WARP_TARGET, results,
|
|
17410
|
+
await importEmbeddedSkills(projectRoot, skillsDir, WARP_TARGET, results, normalize2);
|
|
17390
17411
|
return results;
|
|
17391
17412
|
}
|
|
17392
17413
|
var init_importer28 = __esm({
|
|
@@ -17848,7 +17869,7 @@ function toStringArray8(value) {
|
|
|
17848
17869
|
}
|
|
17849
17870
|
return [];
|
|
17850
17871
|
}
|
|
17851
|
-
async function importWorkflows(projectRoot, results,
|
|
17872
|
+
async function importWorkflows(projectRoot, results, normalize2) {
|
|
17852
17873
|
const workflowsDir = join(projectRoot, WINDSURF_WORKFLOWS_DIR);
|
|
17853
17874
|
const workflowFiles = await readDirRecursive(workflowsDir);
|
|
17854
17875
|
const workflowMdFiles = workflowFiles.filter((f) => f.endsWith(".md"));
|
|
@@ -17859,7 +17880,7 @@ async function importWorkflows(projectRoot, results, normalize) {
|
|
|
17859
17880
|
const relativePath = relative(workflowsDir, srcPath).replace(/\\/g, "/");
|
|
17860
17881
|
await mkdirp(destCommandsDir);
|
|
17861
17882
|
const destPath = join(destCommandsDir, relativePath);
|
|
17862
|
-
const normalized =
|
|
17883
|
+
const normalized = normalize2(content, srcPath, destPath);
|
|
17863
17884
|
const { frontmatter, body } = parseFrontmatter(normalized);
|
|
17864
17885
|
const outContent = await serializeImportedCommandWithFallback(
|
|
17865
17886
|
destPath,
|
|
@@ -17893,12 +17914,12 @@ var init_importer_workflows = __esm({
|
|
|
17893
17914
|
});
|
|
17894
17915
|
|
|
17895
17916
|
// src/targets/windsurf/skills-adapter.ts
|
|
17896
|
-
async function importSkills4(projectRoot, results,
|
|
17917
|
+
async function importSkills4(projectRoot, results, normalize2, skillsRelDir = WINDSURF_SKILLS_DIR) {
|
|
17897
17918
|
const options = {
|
|
17898
17919
|
projectRoot,
|
|
17899
17920
|
destCanonicalSkillsDir: WINDSURF_CANONICAL_SKILLS_DIR,
|
|
17900
17921
|
targetName: "windsurf",
|
|
17901
|
-
normalize,
|
|
17922
|
+
normalize: normalize2,
|
|
17902
17923
|
results
|
|
17903
17924
|
};
|
|
17904
17925
|
await importSkillsDirectory([skillsRelDir], options, [
|
|
@@ -18012,7 +18033,7 @@ var init_importer_hooks_mcp = __esm({
|
|
|
18012
18033
|
async function importFromWindsurf(projectRoot, options) {
|
|
18013
18034
|
const layoutScope = options?.scope ?? "project";
|
|
18014
18035
|
const results = [];
|
|
18015
|
-
const
|
|
18036
|
+
const normalize2 = await createImportReferenceNormalizer(WINDSURF_TARGET, projectRoot);
|
|
18016
18037
|
const normalizeCodex = await createImportReferenceNormalizer("codex-cli", projectRoot);
|
|
18017
18038
|
const destRulesDir = join(projectRoot, WINDSURF_CANONICAL_RULES_DIR);
|
|
18018
18039
|
const rootPath = join(projectRoot, WINDSURF_RULES_ROOT);
|
|
@@ -18020,7 +18041,7 @@ async function importFromWindsurf(projectRoot, options) {
|
|
|
18020
18041
|
if (rootContent !== null) {
|
|
18021
18042
|
await mkdirp(destRulesDir);
|
|
18022
18043
|
const destPath = join(destRulesDir, "_root.md");
|
|
18023
|
-
const body =
|
|
18044
|
+
const body = normalize2(rootContent, rootPath, destPath).trim();
|
|
18024
18045
|
const outContent = await serializeImportedRuleWithFallback(destPath, { root: true }, body);
|
|
18025
18046
|
await writeFileAtomic(destPath, outContent);
|
|
18026
18047
|
results.push({
|
|
@@ -18036,7 +18057,7 @@ async function importFromWindsurf(projectRoot, options) {
|
|
|
18036
18057
|
if (agentsMdContent !== null) {
|
|
18037
18058
|
await mkdirp(destRulesDir);
|
|
18038
18059
|
const destPath = join(destRulesDir, "_root.md");
|
|
18039
|
-
const body =
|
|
18060
|
+
const body = normalize2(
|
|
18040
18061
|
normalizeCodex(agentsMdContent, agentsMdPath, destPath),
|
|
18041
18062
|
agentsMdPath,
|
|
18042
18063
|
destPath
|
|
@@ -18058,7 +18079,7 @@ async function importFromWindsurf(projectRoot, options) {
|
|
|
18058
18079
|
destDir: destRulesDir,
|
|
18059
18080
|
extensions: ["AGENTS.md"],
|
|
18060
18081
|
fromTool: "windsurf",
|
|
18061
|
-
normalize,
|
|
18082
|
+
normalize: normalize2,
|
|
18062
18083
|
mapEntry: async ({ srcPath, normalizeTo }) => {
|
|
18063
18084
|
const relDir = relative(projectRoot, dirname(srcPath)).replace(/\\/g, "/");
|
|
18064
18085
|
if (!relDir || relDir === "." || basename(srcPath) !== "AGENTS.md") return null;
|
|
@@ -18089,7 +18110,7 @@ async function importFromWindsurf(projectRoot, options) {
|
|
|
18089
18110
|
destDir: destRulesDir,
|
|
18090
18111
|
extensions: [".md"],
|
|
18091
18112
|
fromTool: "windsurf",
|
|
18092
|
-
normalize,
|
|
18113
|
+
normalize: normalize2,
|
|
18093
18114
|
mapEntry: async ({ relativePath, normalizeTo }) => {
|
|
18094
18115
|
if (relativePath === "_root.md" && rootContent !== null) return null;
|
|
18095
18116
|
const destPath = join(destRulesDir, relativePath);
|
|
@@ -18137,8 +18158,8 @@ async function importFromWindsurf(projectRoot, options) {
|
|
|
18137
18158
|
});
|
|
18138
18159
|
}
|
|
18139
18160
|
}
|
|
18140
|
-
await importWorkflows(projectRoot, results,
|
|
18141
|
-
await importSkills4(projectRoot, results,
|
|
18161
|
+
await importWorkflows(projectRoot, results, normalize2);
|
|
18162
|
+
await importSkills4(projectRoot, results, normalize2);
|
|
18142
18163
|
await importWindsurfHooks(projectRoot, results);
|
|
18143
18164
|
await importWindsurfMcp(projectRoot, results);
|
|
18144
18165
|
return results;
|
|
@@ -18452,8 +18473,8 @@ var init_mcp_import3 = __esm({
|
|
|
18452
18473
|
async function importFromZed(projectRoot, options = {}) {
|
|
18453
18474
|
const scope = options.scope ?? "project";
|
|
18454
18475
|
const results = [];
|
|
18455
|
-
const
|
|
18456
|
-
results.push(...await runDescriptorImport(descriptor30, projectRoot, scope, { normalize }));
|
|
18476
|
+
const normalize2 = await createImportReferenceNormalizer(ZED_TARGET, projectRoot, scope);
|
|
18477
|
+
results.push(...await runDescriptorImport(descriptor30, projectRoot, scope, { normalize: normalize2 }));
|
|
18457
18478
|
const mcpFile = scope === "global" ? ZED_GLOBAL_SETTINGS_FILE : ZED_SETTINGS_FILE;
|
|
18458
18479
|
await importZedMcp(projectRoot, mcpFile, results);
|
|
18459
18480
|
return results;
|
|
@@ -22565,6 +22586,135 @@ function lintRuleScopeInversion(input) {
|
|
|
22565
22586
|
}
|
|
22566
22587
|
return out2;
|
|
22567
22588
|
}
|
|
22589
|
+
var TriggersSchema = z.object({
|
|
22590
|
+
file_globs: z.array(z.string()),
|
|
22591
|
+
command_patterns: z.array(z.string()),
|
|
22592
|
+
keywords: z.array(z.string())
|
|
22593
|
+
}).refine((t) => t.file_globs.length + t.command_patterns.length + t.keywords.length > 0, {
|
|
22594
|
+
message: "cluster must declare at least one trigger of any type"
|
|
22595
|
+
});
|
|
22596
|
+
var ClusterSchema = z.object({
|
|
22597
|
+
topic: z.string().regex(/^[a-z0-9-]+$/, "topic must be kebab-case"),
|
|
22598
|
+
/**
|
|
22599
|
+
* Project-relative path (forward slashes) to the cluster's markdown body.
|
|
22600
|
+
* Conventionally `.agentsmesh/lessons/topics/<topic>.md`, but any project
|
|
22601
|
+
* path is accepted — universal across every agent target.
|
|
22602
|
+
*/
|
|
22603
|
+
file: z.string().regex(/\.md$/, "file must be a .md path"),
|
|
22604
|
+
summary: z.string().min(1),
|
|
22605
|
+
triggers: TriggersSchema
|
|
22606
|
+
});
|
|
22607
|
+
var LessonsIndexSchema = z.object({
|
|
22608
|
+
version: z.literal(1),
|
|
22609
|
+
/**
|
|
22610
|
+
* Zero clusters is valid — supports `agentsmesh init --lessons` scaffolding a
|
|
22611
|
+
* fresh project. Topics accumulate via `distill:apply` as failures are
|
|
22612
|
+
* captured.
|
|
22613
|
+
*/
|
|
22614
|
+
clusters: z.array(ClusterSchema)
|
|
22615
|
+
});
|
|
22616
|
+
function parseIndex(raw) {
|
|
22617
|
+
return LessonsIndexSchema.parse(raw);
|
|
22618
|
+
}
|
|
22619
|
+
var BASE_REL = ".agentsmesh/lessons";
|
|
22620
|
+
function lessonsPaths(projectRoot) {
|
|
22621
|
+
const base = join(projectRoot, BASE_REL);
|
|
22622
|
+
return {
|
|
22623
|
+
base,
|
|
22624
|
+
journal: join(base, "journal.md"),
|
|
22625
|
+
index: join(base, "index.yaml"),
|
|
22626
|
+
ledger: join(base, "distill-ledger.yaml"),
|
|
22627
|
+
proposal: join(base, "distill-proposal.md"),
|
|
22628
|
+
topicsDir: join(base, "topics")
|
|
22629
|
+
};
|
|
22630
|
+
}
|
|
22631
|
+
function toRelPath(projectRoot, absolute) {
|
|
22632
|
+
return relative(projectRoot, absolute).split(sep).join("/");
|
|
22633
|
+
}
|
|
22634
|
+
var LESSONS_JOURNAL_TEMPLATE = "# Lessons Learned\n\n";
|
|
22635
|
+
var LESSONS_INDEX_TEMPLATE = "version: 1\nclusters: []\n";
|
|
22636
|
+
var LESSONS_PROCEDURAL_RULE = `## Lessons (MUST do \u2014 non-negotiable)
|
|
22637
|
+
|
|
22638
|
+
Two rituals. Universal across every agent harness \u2014 described in tool-agnostic action verbs ("read a file", "edit a file", "run a shell command"); use whatever read / write-patch / shell-exec tool your harness exposes. Skipping either ritual is a process violation; the same paid-for failure recurs next session.
|
|
22639
|
+
|
|
22640
|
+
**Recall \u2014 BEFORE editing any file or running any shell command:**
|
|
22641
|
+
|
|
22642
|
+
1. Read \`.agentsmesh/lessons/index.yaml\`.
|
|
22643
|
+
2. For every cluster whose triggers match \u2014 \`file_globs\` against the target file path, \`command_patterns\` (regex) against the shell command, or \`keywords\` (case-insensitive substring) against the active task description \u2014 read its \`file\` (e.g. \`.agentsmesh/lessons/topics/<topic>.md\`).
|
|
22644
|
+
3. Apply the loaded rules to the action.
|
|
22645
|
+
4. Then \u2014 and only then \u2014 perform the edit or run the command.
|
|
22646
|
+
|
|
22647
|
+
Rejected excuses: *"the edit is small"* \u2192 apply it. *"I read this earlier in the session"* \u2192 context may have compacted; re-read. *"no trigger fires"* \u2192 proceed; you've done your part.
|
|
22648
|
+
|
|
22649
|
+
**Capture \u2014 IMMEDIATELY after any failure** (test, CI, lint, code review, user correction, regression you spotted yourself, OR any mistake by anyone in the loop):
|
|
22650
|
+
|
|
22651
|
+
1. Append one bullet to \`.agentsmesh/lessons/journal.md\` in this exact shape:
|
|
22652
|
+
\`- **<short heading>**: <what went wrong>. <root cause>. <imperative rule that prevents recurrence>.\`
|
|
22653
|
+
2. Read \`.agentsmesh/lessons/index.yaml\` and identify which topic the lesson belongs to (use the \`summary:\` fields).
|
|
22654
|
+
3. If the lesson teaches a NEW rule: edit that topic's \`## Rules\` section to add it, citing \`(Evidence: L<journal-line>)\`. If it only reinforces an existing rule, the journal entry alone suffices.
|
|
22655
|
+
|
|
22656
|
+
Rejected excuses: *"it wasn't really a failure"* \u2192 if you fixed something, it was. *"I'll capture it later"* \u2192 no; do it now while context is fresh. *"no topic fits"* \u2192 still record in journal; an unrouted bullet is recoverable, a forgotten one is not.
|
|
22657
|
+
|
|
22658
|
+
**These two rituals are load-bearing. Treat them with the same discipline as TDD.**`;
|
|
22659
|
+
|
|
22660
|
+
// src/core/lint/shared/lessons.ts
|
|
22661
|
+
var LESSONS_TARGET = "lessons";
|
|
22662
|
+
var INDEX_REL = ".agentsmesh/lessons/index.yaml";
|
|
22663
|
+
var ROOT_RULE_REL = ".agentsmesh/rules/_root.md";
|
|
22664
|
+
var LESSONS_HEADING = /^## Lessons \(/m;
|
|
22665
|
+
var RULES_HEADING = /^## Rules\b/m;
|
|
22666
|
+
function lintLessonsSubsystem(projectRoot, scope) {
|
|
22667
|
+
if (scope === "global") return [];
|
|
22668
|
+
const paths = lessonsPaths(projectRoot);
|
|
22669
|
+
if (!existsSync(paths.index)) return [];
|
|
22670
|
+
const out2 = [];
|
|
22671
|
+
const parsed = LessonsIndexSchema.safeParse(parse(readFileSync(paths.index, "utf8")));
|
|
22672
|
+
if (!parsed.success) {
|
|
22673
|
+
return [diag("error", INDEX_REL, `index.yaml is invalid: ${parsed.error.issues[0].message}`)];
|
|
22674
|
+
}
|
|
22675
|
+
for (const cluster of parsed.data.clusters) {
|
|
22676
|
+
const topicAbs = join(projectRoot, cluster.file);
|
|
22677
|
+
if (!existsSync(topicAbs)) {
|
|
22678
|
+
out2.push(
|
|
22679
|
+
diag("error", cluster.file, `topic file for cluster "${cluster.topic}" does not exist.`)
|
|
22680
|
+
);
|
|
22681
|
+
continue;
|
|
22682
|
+
}
|
|
22683
|
+
if (!RULES_HEADING.test(readFileSync(topicAbs, "utf8"))) {
|
|
22684
|
+
out2.push(
|
|
22685
|
+
diag("warning", cluster.file, `topic "${cluster.topic}" is missing a "## Rules" section.`)
|
|
22686
|
+
);
|
|
22687
|
+
}
|
|
22688
|
+
for (const pattern of cluster.triggers.command_patterns) {
|
|
22689
|
+
try {
|
|
22690
|
+
new RegExp(pattern);
|
|
22691
|
+
} catch {
|
|
22692
|
+
out2.push(
|
|
22693
|
+
diag(
|
|
22694
|
+
"warning",
|
|
22695
|
+
INDEX_REL,
|
|
22696
|
+
`cluster "${cluster.topic}" command_patterns entry is not a valid regex: ${pattern}`
|
|
22697
|
+
)
|
|
22698
|
+
);
|
|
22699
|
+
}
|
|
22700
|
+
}
|
|
22701
|
+
}
|
|
22702
|
+
const rootRuleAbs = join(projectRoot, ROOT_RULE_REL);
|
|
22703
|
+
const rootRuleBody = existsSync(rootRuleAbs) ? readFileSync(rootRuleAbs, "utf8") : "";
|
|
22704
|
+
if (!LESSONS_HEADING.test(rootRuleBody)) {
|
|
22705
|
+
out2.push(
|
|
22706
|
+
diag(
|
|
22707
|
+
"warning",
|
|
22708
|
+
ROOT_RULE_REL,
|
|
22709
|
+
'lessons procedural rule ("## Lessons (...)") is missing from _root.md \u2014 recall/capture enforcement will not fire.'
|
|
22710
|
+
)
|
|
22711
|
+
);
|
|
22712
|
+
}
|
|
22713
|
+
return out2;
|
|
22714
|
+
}
|
|
22715
|
+
function diag(level, file, message) {
|
|
22716
|
+
return { level, file, target: LESSONS_TARGET, message };
|
|
22717
|
+
}
|
|
22568
22718
|
|
|
22569
22719
|
// src/core/lint/linter.ts
|
|
22570
22720
|
var EXCLUDE_DIRS = ["node_modules", ".git", "dist", "coverage", ".agentsmesh"];
|
|
@@ -22585,7 +22735,7 @@ async function runLint(config, canonical, projectRoot, targetFilter, options = {
|
|
|
22585
22735
|
const hasMcp = config.features.includes("mcp");
|
|
22586
22736
|
const hasPermissions = config.features.includes("permissions");
|
|
22587
22737
|
const hasHooks = config.features.includes("hooks");
|
|
22588
|
-
const diagnostics = [];
|
|
22738
|
+
const diagnostics = [...lintLessonsSubsystem(projectRoot, scope)];
|
|
22589
22739
|
const projectFiles = scope === "global" ? [] : await getProjectFiles(projectRoot);
|
|
22590
22740
|
for (const target31 of targets) {
|
|
22591
22741
|
const fullDesc = getDescriptor(target31);
|
|
@@ -22988,7 +23138,228 @@ function copyTargetDescriptor(descriptor31) {
|
|
|
22988
23138
|
function getTargetCatalog() {
|
|
22989
23139
|
return Object.freeze(BUILTIN_TARGETS.map(copyTargetDescriptor));
|
|
22990
23140
|
}
|
|
23141
|
+
function normalize(bullet) {
|
|
23142
|
+
return bullet.split("\n").map((line) => line.replace(/\s+$/, "")).join("\n").trim().replace(/^[-*]\s+/, "");
|
|
23143
|
+
}
|
|
23144
|
+
function hashBullet(bullet) {
|
|
23145
|
+
return createHash("sha256").update(normalize(bullet)).digest("hex").slice(0, 16);
|
|
23146
|
+
}
|
|
23147
|
+
|
|
23148
|
+
// src/lessons/bullet-parser.ts
|
|
23149
|
+
function parseBullets(markdown) {
|
|
23150
|
+
const bullets = [];
|
|
23151
|
+
let current = null;
|
|
23152
|
+
let lineNumber = 0;
|
|
23153
|
+
for (const line of markdown.split("\n")) {
|
|
23154
|
+
lineNumber += 1;
|
|
23155
|
+
if (/^[-*]\s+/.test(line)) {
|
|
23156
|
+
if (current !== null) bullets.push(current);
|
|
23157
|
+
current = { text: line, lineNumber };
|
|
23158
|
+
} else if (current !== null) {
|
|
23159
|
+
if (line.length === 0) {
|
|
23160
|
+
bullets.push(current);
|
|
23161
|
+
current = null;
|
|
23162
|
+
} else if (/^\s+\S/.test(line)) {
|
|
23163
|
+
current.text += `
|
|
23164
|
+
${line}`;
|
|
23165
|
+
} else {
|
|
23166
|
+
bullets.push(current);
|
|
23167
|
+
current = null;
|
|
23168
|
+
}
|
|
23169
|
+
}
|
|
23170
|
+
}
|
|
23171
|
+
if (current !== null) bullets.push(current);
|
|
23172
|
+
return bullets;
|
|
23173
|
+
}
|
|
23174
|
+
function fileMatch(globs, path) {
|
|
23175
|
+
return globs.some((g) => picomatch(g, { dot: true })(path));
|
|
23176
|
+
}
|
|
23177
|
+
function cmdMatch(patterns, cmd) {
|
|
23178
|
+
return patterns.some((p) => {
|
|
23179
|
+
try {
|
|
23180
|
+
return new RegExp(p).test(cmd);
|
|
23181
|
+
} catch {
|
|
23182
|
+
return false;
|
|
23183
|
+
}
|
|
23184
|
+
});
|
|
23185
|
+
}
|
|
23186
|
+
function kwMatch(keywords, text) {
|
|
23187
|
+
const lower = text.toLowerCase();
|
|
23188
|
+
return keywords.some((k) => lower.includes(k.toLowerCase()));
|
|
23189
|
+
}
|
|
23190
|
+
function matchTriggers(clusters, event) {
|
|
23191
|
+
return clusters.filter((c2) => {
|
|
23192
|
+
const t = c2.triggers;
|
|
23193
|
+
switch (event.kind) {
|
|
23194
|
+
case "edit":
|
|
23195
|
+
case "write":
|
|
23196
|
+
return fileMatch(t.file_globs, event.filePath);
|
|
23197
|
+
case "bash":
|
|
23198
|
+
return cmdMatch(t.command_patterns, event.command);
|
|
23199
|
+
case "task":
|
|
23200
|
+
return kwMatch(t.keywords, event.text);
|
|
23201
|
+
}
|
|
23202
|
+
});
|
|
23203
|
+
}
|
|
23204
|
+
var LedgerSchema = z.object({
|
|
23205
|
+
version: z.literal(1),
|
|
23206
|
+
assignments: z.record(z.string(), z.string())
|
|
23207
|
+
});
|
|
23208
|
+
function loadLedger(path) {
|
|
23209
|
+
if (!existsSync(path)) return { version: 1, assignments: {} };
|
|
23210
|
+
return LedgerSchema.parse(parse(readFileSync(path, "utf8")));
|
|
23211
|
+
}
|
|
23212
|
+
function saveLedger(path, ledger) {
|
|
23213
|
+
writeFileSync(path, stringify(ledger), "utf8");
|
|
23214
|
+
}
|
|
23215
|
+
|
|
23216
|
+
// src/lessons/scoring.ts
|
|
23217
|
+
function scoreBullet(bullet, clusters) {
|
|
23218
|
+
const lower = bullet.toLowerCase();
|
|
23219
|
+
return clusters.map((cluster) => {
|
|
23220
|
+
const t = cluster.triggers;
|
|
23221
|
+
const kwHits = t.keywords.filter((k) => lower.includes(k.toLowerCase())).length;
|
|
23222
|
+
const pathHits = t.file_globs.filter((g) => {
|
|
23223
|
+
const stem = g.replace(/[*{}[\]?!]/g, "").replace(/\/+/g, "/").trim();
|
|
23224
|
+
return stem.length > 2 && lower.includes(stem.toLowerCase());
|
|
23225
|
+
}).length;
|
|
23226
|
+
const cmdHits = t.command_patterns.filter((p) => {
|
|
23227
|
+
try {
|
|
23228
|
+
return new RegExp(p, "i").test(bullet);
|
|
23229
|
+
} catch {
|
|
23230
|
+
return false;
|
|
23231
|
+
}
|
|
23232
|
+
}).length;
|
|
23233
|
+
return { cluster, score: kwHits * 2 + pathHits + cmdHits };
|
|
23234
|
+
}).filter((s) => s.score > 0).sort((a, b) => b.score - a.score);
|
|
23235
|
+
}
|
|
23236
|
+
function loadLessonsIndex(projectRoot) {
|
|
23237
|
+
const raw = readFileSync(lessonsPaths(projectRoot).index, "utf8");
|
|
23238
|
+
return parseIndex(parse(raw));
|
|
23239
|
+
}
|
|
23240
|
+
function readTriggeredLessons(projectRoot, event) {
|
|
23241
|
+
const index = loadLessonsIndex(projectRoot);
|
|
23242
|
+
const contentByPath = /* @__PURE__ */ new Map();
|
|
23243
|
+
return matchTriggers(index.clusters, normalizeToolEvent(projectRoot, event)).map(
|
|
23244
|
+
(cluster) => {
|
|
23245
|
+
const filePath = resolveProjectFile(projectRoot, cluster.file);
|
|
23246
|
+
let content = contentByPath.get(cluster.file);
|
|
23247
|
+
if (content === void 0) {
|
|
23248
|
+
content = readFileSync(filePath, "utf8");
|
|
23249
|
+
contentByPath.set(cluster.file, content);
|
|
23250
|
+
}
|
|
23251
|
+
return {
|
|
23252
|
+
cluster,
|
|
23253
|
+
relativePath: cluster.file,
|
|
23254
|
+
filePath,
|
|
23255
|
+
content
|
|
23256
|
+
};
|
|
23257
|
+
}
|
|
23258
|
+
);
|
|
23259
|
+
}
|
|
23260
|
+
function formatLessonBullet(input) {
|
|
23261
|
+
const heading = compact(input.heading);
|
|
23262
|
+
if (heading.length === 0) throw new Error("Lesson heading must not be empty.");
|
|
23263
|
+
return [
|
|
23264
|
+
`- **${heading}**:`,
|
|
23265
|
+
sentence(input.whatWentWrong),
|
|
23266
|
+
sentence(input.rootCause),
|
|
23267
|
+
sentence(input.rule)
|
|
23268
|
+
].join(" ");
|
|
23269
|
+
}
|
|
23270
|
+
function appendLessonToJournal(projectRoot, input) {
|
|
23271
|
+
const journalPath = lessonsPaths(projectRoot).journal;
|
|
23272
|
+
const bullet = formatLessonBullet(input);
|
|
23273
|
+
const current = existsSync(journalPath) ? readFileSync(journalPath, "utf8") : "";
|
|
23274
|
+
const prefix = current.length === 0 || current.endsWith("\n") ? "" : "\n";
|
|
23275
|
+
const lineNumber = nextLineNumber(current);
|
|
23276
|
+
mkdirSync(dirname(journalPath), { recursive: true });
|
|
23277
|
+
appendFileSync(journalPath, `${prefix}${bullet}
|
|
23278
|
+
`, "utf8");
|
|
23279
|
+
return { journalPath, bullet, lineNumber };
|
|
23280
|
+
}
|
|
23281
|
+
function resolveProjectFile(projectRoot, relPath) {
|
|
23282
|
+
if (isAbsolute(relPath) || /^[A-Za-z]:[\\/]/.test(relPath)) {
|
|
23283
|
+
throw new Error(`Lessons file must be project-relative: ${relPath}`);
|
|
23284
|
+
}
|
|
23285
|
+
const root = resolve(projectRoot);
|
|
23286
|
+
const filePath = resolve(root, relPath);
|
|
23287
|
+
const backToRoot = relative(root, filePath);
|
|
23288
|
+
if (backToRoot === "" || backToRoot.startsWith("..") || isAbsolute(backToRoot)) {
|
|
23289
|
+
throw new Error(`Lessons file escapes the project root: ${relPath}`);
|
|
23290
|
+
}
|
|
23291
|
+
return filePath;
|
|
23292
|
+
}
|
|
23293
|
+
function normalizeToolEvent(projectRoot, event) {
|
|
23294
|
+
if (event.kind !== "edit" && event.kind !== "write") return event;
|
|
23295
|
+
return { ...event, filePath: normalizeEventPath(projectRoot, event.filePath) };
|
|
23296
|
+
}
|
|
23297
|
+
function normalizeEventPath(projectRoot, filePath) {
|
|
23298
|
+
const normalized = filePath.replaceAll("\\", "/");
|
|
23299
|
+
const root = resolve(projectRoot).replaceAll("\\", "/");
|
|
23300
|
+
if (normalized === root) return ".";
|
|
23301
|
+
if (normalized.startsWith(`${root}/`)) return normalized.slice(root.length + 1);
|
|
23302
|
+
return normalized.replace(/^\.\//, "");
|
|
23303
|
+
}
|
|
23304
|
+
function compact(value) {
|
|
23305
|
+
return value.replace(/\s+/g, " ").trim();
|
|
23306
|
+
}
|
|
23307
|
+
function sentence(value) {
|
|
23308
|
+
const compacted = compact(value);
|
|
23309
|
+
if (compacted.length === 0) throw new Error("Lesson sentence must not be empty.");
|
|
23310
|
+
return /[.!?]$/.test(compacted) ? compacted : `${compacted}.`;
|
|
23311
|
+
}
|
|
23312
|
+
function nextLineNumber(current) {
|
|
23313
|
+
if (current.length === 0) return 1;
|
|
23314
|
+
const lineCount = current.split("\n").length;
|
|
23315
|
+
return current.endsWith("\n") ? lineCount : lineCount + 1;
|
|
23316
|
+
}
|
|
23317
|
+
function scaffoldLessons(projectRoot) {
|
|
23318
|
+
const paths = lessonsPaths(projectRoot);
|
|
23319
|
+
const created = [];
|
|
23320
|
+
const skipped = [];
|
|
23321
|
+
mkdirSync(paths.topicsDir, { recursive: true });
|
|
23322
|
+
for (const [path, template] of [
|
|
23323
|
+
[paths.journal, LESSONS_JOURNAL_TEMPLATE],
|
|
23324
|
+
[paths.index, LESSONS_INDEX_TEMPLATE]
|
|
23325
|
+
]) {
|
|
23326
|
+
if (existsSync(path)) {
|
|
23327
|
+
skipped.push(path);
|
|
23328
|
+
} else {
|
|
23329
|
+
mkdirSync(dirname(path), { recursive: true });
|
|
23330
|
+
writeFileSync(path, template, "utf8");
|
|
23331
|
+
created.push(path);
|
|
23332
|
+
}
|
|
23333
|
+
}
|
|
23334
|
+
const rootRuleUpdated = appendProceduralRule(projectRoot);
|
|
23335
|
+
return { created, skipped, rootRuleUpdated };
|
|
23336
|
+
}
|
|
23337
|
+
function appendProceduralRule(projectRoot) {
|
|
23338
|
+
const rootRule = join(projectRoot, ".agentsmesh/rules/_root.md");
|
|
23339
|
+
if (!existsSync(rootRule)) {
|
|
23340
|
+
mkdirSync(dirname(rootRule), { recursive: true });
|
|
23341
|
+
const seeded = `---
|
|
23342
|
+
root: true
|
|
23343
|
+
description: ""
|
|
23344
|
+
---
|
|
23345
|
+
|
|
23346
|
+
# Operational Guidelines
|
|
23347
|
+
|
|
23348
|
+
${LESSONS_PROCEDURAL_RULE}
|
|
23349
|
+
`;
|
|
23350
|
+
writeFileSync(rootRule, seeded, "utf8");
|
|
23351
|
+
return true;
|
|
23352
|
+
}
|
|
23353
|
+
const current = readFileSync(rootRule, "utf8");
|
|
23354
|
+
if (/^## Lessons \(/m.test(current)) return false;
|
|
23355
|
+
const next = current.endsWith("\n") ? current : `${current}
|
|
23356
|
+
`;
|
|
23357
|
+
writeFileSync(rootRule, `${next}
|
|
23358
|
+
${LESSONS_PROCEDURAL_RULE}
|
|
23359
|
+
`, "utf8");
|
|
23360
|
+
return true;
|
|
23361
|
+
}
|
|
22991
23362
|
|
|
22992
|
-
export { AgentsMeshError, ConfigNotFoundError, ConfigValidationError, FileSystemError, GenerationError, ImportError, LockAcquisitionError, RemoteFetchError, TargetNotFoundError, check, computeDiff2 as computeDiff, diff, formatDiffSummary, generate, getAllDescriptors, getDescriptor, getTargetCatalog, importFrom, lint, loadCanonical, loadCanonicalFiles, loadConfig2 as loadConfig, loadConfigFromDirectory, loadProjectContext, registerTargetDescriptor, resolveOutputCollisions };
|
|
23363
|
+
export { AgentsMeshError, ConfigNotFoundError, ConfigValidationError, FileSystemError, GenerationError, ImportError, LESSONS_INDEX_TEMPLATE, LESSONS_JOURNAL_TEMPLATE, LESSONS_PROCEDURAL_RULE, LessonsIndexSchema, LockAcquisitionError, RemoteFetchError, TargetNotFoundError, appendLessonToJournal, check, computeDiff2 as computeDiff, diff, formatDiffSummary, formatLessonBullet, generate, getAllDescriptors, getDescriptor, getTargetCatalog, hashBullet, importFrom, lessonsPaths, lint, loadCanonical, loadCanonicalFiles, loadConfig2 as loadConfig, loadConfigFromDirectory, loadLedger, loadLessonsIndex, loadProjectContext, matchTriggers, parseBullets, parseIndex, readTriggeredLessons, registerTargetDescriptor, resolveOutputCollisions, saveLedger, scaffoldLessons, scoreBullet, toRelPath };
|
|
22993
23364
|
//# sourceMappingURL=index.js.map
|
|
22994
23365
|
//# sourceMappingURL=index.js.map
|