agentsmesh 0.21.0 → 0.23.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/canonical.js CHANGED
@@ -1,5 +1,6 @@
1
1
  import { join, basename, dirname, relative, extname, resolve, posix, win32 } from 'path';
2
2
  import { access, readdir, readFile, realpath, stat, rm, mkdir, lstat, unlink, writeFile, rename, chmod, mkdtemp, cp } from 'fs/promises';
3
+ import { setTimeout } from 'timers/promises';
3
4
  import { constants, existsSync, realpathSync, statSync } from 'fs';
4
5
  import { stringify, parse } from 'yaml';
5
6
  import { z } from 'zod';
@@ -220,6 +221,27 @@ var init_fs_traverse = __esm({
220
221
  MAX_SEGMENT_REPETITIONS = 3;
221
222
  }
222
223
  });
224
+ async function renameWithRetry(from, to, options = {}) {
225
+ const attempts = options.attempts ?? 5;
226
+ const delayMs = options.delayMs ?? 50;
227
+ for (let attempt = 0; ; attempt++) {
228
+ try {
229
+ await rename(from, to);
230
+ return;
231
+ } catch (err) {
232
+ const code = err.code;
233
+ const transient = code !== void 0 && TRANSIENT_RENAME_CODES.has(code);
234
+ if (!transient || attempt >= attempts - 1) throw err;
235
+ await setTimeout(delayMs * 2 ** attempt);
236
+ }
237
+ }
238
+ }
239
+ var TRANSIENT_RENAME_CODES;
240
+ var init_rename_retry = __esm({
241
+ "src/utils/filesystem/rename-retry.ts"() {
242
+ TRANSIENT_RENAME_CODES = /* @__PURE__ */ new Set(["EPERM", "EACCES", "EBUSY", "ENOTEMPTY", "EEXIST"]);
243
+ }
244
+ });
223
245
  async function readFileSafe(path) {
224
246
  try {
225
247
  const data = await readFile(path, "utf-8");
@@ -306,6 +328,7 @@ var init_fs = __esm({
306
328
  init_fs_text_encoding();
307
329
  init_fs_traverse();
308
330
  init_fs_text_encoding();
331
+ init_rename_retry();
309
332
  }
310
333
  });
311
334
  function parseFrontmatter(content) {
@@ -487,7 +510,7 @@ function validateCapabilityImplementations(descriptor31, capabilities17, ctx, pa
487
510
  });
488
511
  }
489
512
  }
490
- var capabilityLevelSchema, capabilitiesSchema, generatorsSchema, pathResolversSchema, layoutSchema, globalSupportSchema, legacyGlobalKeys, generatorRequirements, settingsBackedFeatures, conversionDefaultsSchema, metadataSchema, targetDescriptorSchemaBase;
513
+ var capabilityLevelSchema, capabilitiesSchema, generatorsSchema, pathResolversSchema, layoutSchema, globalSupportSchema, legacyGlobalKeys, generatorRequirements, settingsBackedFeatures, conversionDefaultsSchema, metadataSchema, nativePickStrategySchema, nativeInstallSchema, targetDescriptorSchemaBase;
491
514
  var init_target_descriptor_schema = __esm({
492
515
  "src/targets/catalog/target-descriptor.schema.ts"() {
493
516
  capabilityLevelSchema = z.union([
@@ -561,6 +584,22 @@ var init_target_descriptor_schema = __esm({
561
584
  officialUrl: z.string().min(1),
562
585
  shortDescription: z.string().min(1)
563
586
  }).passthrough();
587
+ nativePickStrategySchema = z.discriminatedUnion("kind", [
588
+ z.object({ kind: z.literal("basename"), suffix: z.string().min(1) }),
589
+ z.object({ kind: z.literal("skillDir") }),
590
+ z.object({ kind: z.literal("firstSegment") })
591
+ ]);
592
+ nativeInstallSchema = z.object({
593
+ pickPaths: z.array(
594
+ z.object({
595
+ prefix: z.string().min(1),
596
+ feature: z.enum(["commands", "rules", "agents", "skills"]),
597
+ strategy: nativePickStrategySchema
598
+ })
599
+ ).optional(),
600
+ inferPick: z.function().optional(),
601
+ dialectHints: z.array(z.object({ frontmatterKey: z.string().min(1) })).optional()
602
+ }).strict();
564
603
  targetDescriptorSchemaBase = z.object({
565
604
  id: z.string().regex(/^[a-z][a-z0-9-]*$/, "Target id must be lowercase with hyphens"),
566
605
  metadata: metadataSchema,
@@ -572,6 +611,7 @@ var init_target_descriptor_schema = __esm({
572
611
  globalSupport: globalSupportSchema.optional(),
573
612
  buildImportPaths: z.function(),
574
613
  detectionPaths: z.array(z.string()),
614
+ nativeInstall: nativeInstallSchema.optional(),
575
615
  excludeFromStarterInit: z.boolean().optional(),
576
616
  conversionDefaults: conversionDefaultsSchema.optional(),
577
617
  emitScopedSettings: z.function().optional(),
@@ -1050,7 +1090,7 @@ ${legacy}`, "");
1050
1090
  }
1051
1091
  return result.trim();
1052
1092
  }
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, 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;
1093
+ 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;
1054
1094
  var init_root_instruction_paragraph = __esm({
1055
1095
  "src/targets/projection/root-instruction-paragraph.ts"() {
1056
1096
  init_managed_blocks();
@@ -1062,7 +1102,9 @@ var init_root_instruction_paragraph = __esm({
1062
1102
  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`.";
1063
1103
  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`.";
1064
1104
  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.";
1065
- ROOT_INSTRUCTION_BODY = "`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.";
1105
+ 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.";
1106
+ 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.";
1107
+ 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.";
1066
1108
  LEGACY_AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH = ROOT_INSTRUCTION_BODY_V1;
1067
1109
  LEGACY_AGENTSMESH_ROOT_INSTRUCTION_SECTION = `## Project-Specific Rules
1068
1110
 
@@ -1091,12 +1133,20 @@ ${ROOT_INSTRUCTION_BODY_V7}`;
1091
1133
  AGENTSMESH_CONTRACT_WITH_V8_BODY = `## AgentsMesh Generation Contract
1092
1134
 
1093
1135
  ${ROOT_INSTRUCTION_BODY_V8}`;
1136
+ AGENTSMESH_CONTRACT_WITH_V9_BODY = `## AgentsMesh Generation Contract
1137
+
1138
+ ${ROOT_INSTRUCTION_BODY_V9}`;
1139
+ AGENTSMESH_CONTRACT_WITH_V10_BODY = `## AgentsMesh Generation Contract
1140
+
1141
+ ${ROOT_INSTRUCTION_BODY_V10}`;
1094
1142
  AGENTSMESH_ROOT_INSTRUCTION_PARAGRAPH = `${ROOT_CONTRACT_START}
1095
1143
  ## AgentsMesh Generation Contract
1096
1144
 
1097
1145
  ${ROOT_INSTRUCTION_BODY}
1098
1146
  ${ROOT_CONTRACT_END}`;
1099
1147
  LEGACY_FORMS = [
1148
+ AGENTSMESH_CONTRACT_WITH_V10_BODY,
1149
+ AGENTSMESH_CONTRACT_WITH_V9_BODY,
1100
1150
  AGENTSMESH_CONTRACT_WITH_V8_BODY,
1101
1151
  AGENTSMESH_CONTRACT_WITH_V7_BODY,
1102
1152
  AGENTSMESH_CONTRACT_WITH_V6_BODY,
@@ -2000,9 +2050,8 @@ function shouldRewritePathToken(fullContent, start, end, matchText, rewriteBareP
2000
2050
  const before = fullContent[start - 1];
2001
2051
  const after = fullContent[end];
2002
2052
  if (isMarkdownReferenceDefinitionDestination(fullContent, start, candidateEnd)) return true;
2003
- if (before === "'" && after === "'" || before === '"' && after === '"' || before === "`" && after === "`") {
2004
- return true;
2005
- }
2053
+ if (before === "`" && after === "`") return true;
2054
+ if (before === "'" && after === "'" || before === '"' && after === '"') return false;
2006
2055
  if (before === "<" && after === ">") return true;
2007
2056
  if (before === "[" && after === "]") {
2008
2057
  if (!rewriteBarePathTokens && !isRootRelativePathToken(normalizedCandidate) && markdownBracketLabelDuplicatesDestination(fullContent, start, matchText)) {
@@ -3250,12 +3299,12 @@ var init_augment_code = __esm({
3250
3299
  });
3251
3300
 
3252
3301
  // src/targets/claude-code/constants.ts
3253
- var CLAUDE_CODE_TARGET, CLAUDE_ROOT, CLAUDE_LEGACY_ROOT, CLAUDE_RULES_DIR, CLAUDE_COMMANDS_DIR, CLAUDE_AGENTS_DIR, CLAUDE_SKILLS_DIR, CLAUDE_SETTINGS, CLAUDE_HOOKS_JSON, CLAUDE_OUTPUT_STYLES_DIR, CLAUDE_IGNORE, CLAUDE_MCP_JSON, CLAUDE_GLOBAL_MCP_JSON, CLAUDE_CANONICAL_RULES_DIR, CLAUDE_CANONICAL_COMMANDS_DIR, CLAUDE_CANONICAL_AGENTS_DIR, CLAUDE_CANONICAL_SKILLS_DIR, CLAUDE_CANONICAL_MCP, CLAUDE_CANONICAL_PERMISSIONS, CLAUDE_CANONICAL_HOOKS, CLAUDE_CANONICAL_IGNORE;
3302
+ var CLAUDE_CODE_TARGET, CLAUDE_ROOT, CLAUDE_NESTED_ROOT, CLAUDE_RULES_DIR, CLAUDE_COMMANDS_DIR, CLAUDE_AGENTS_DIR, CLAUDE_SKILLS_DIR, CLAUDE_SETTINGS, CLAUDE_HOOKS_JSON, CLAUDE_OUTPUT_STYLES_DIR, CLAUDE_IGNORE, CLAUDE_MCP_JSON, CLAUDE_GLOBAL_MCP_JSON, CLAUDE_CANONICAL_RULES_DIR, CLAUDE_CANONICAL_COMMANDS_DIR, CLAUDE_CANONICAL_AGENTS_DIR, CLAUDE_CANONICAL_SKILLS_DIR, CLAUDE_CANONICAL_MCP, CLAUDE_CANONICAL_PERMISSIONS, CLAUDE_CANONICAL_HOOKS, CLAUDE_CANONICAL_IGNORE;
3254
3303
  var init_constants7 = __esm({
3255
3304
  "src/targets/claude-code/constants.ts"() {
3256
3305
  CLAUDE_CODE_TARGET = "claude-code";
3257
- CLAUDE_ROOT = ".claude/CLAUDE.md";
3258
- CLAUDE_LEGACY_ROOT = "CLAUDE.md";
3306
+ CLAUDE_ROOT = "CLAUDE.md";
3307
+ CLAUDE_NESTED_ROOT = ".claude/CLAUDE.md";
3259
3308
  CLAUDE_RULES_DIR = ".claude/rules";
3260
3309
  CLAUDE_COMMANDS_DIR = ".claude/commands";
3261
3310
  CLAUDE_AGENTS_DIR = ".claude/agents";
@@ -5117,7 +5166,8 @@ var init_amp2 = __esm({
5117
5166
  markAsRoot: true
5118
5167
  }
5119
5168
  },
5120
- emitScopedSettings(canonical, _scope) {
5169
+ emitScopedSettings(canonical, _scope, enabledFeatures) {
5170
+ if (!enabledFeatures.has("mcp")) return [];
5121
5171
  if (!canonical.mcp || Object.keys(canonical.mcp.mcpServers).length === 0) return [];
5122
5172
  return [
5123
5173
  {
@@ -5869,12 +5919,12 @@ function mergeAugmentSettings(existing, newContent) {
5869
5919
  if (overlay.hooks !== void 0) base.hooks = overlay.hooks;
5870
5920
  return JSON.stringify(base, null, 2);
5871
5921
  }
5872
- function buildSettingsContent(canonical) {
5922
+ function buildSettingsContent(canonical, enabledFeatures) {
5873
5923
  const settings = {};
5874
- if (canonical.mcp && Object.keys(canonical.mcp.mcpServers).length > 0) {
5924
+ if (enabledFeatures.has("mcp") && canonical.mcp && Object.keys(canonical.mcp.mcpServers).length > 0) {
5875
5925
  settings.mcpServers = canonical.mcp.mcpServers;
5876
5926
  }
5877
- if (canonical.hooks && Object.keys(canonical.hooks).length > 0) {
5927
+ if (enabledFeatures.has("hooks") && canonical.hooks && Object.keys(canonical.hooks).length > 0) {
5878
5928
  settings.hooks = serializeHooksForSettings(canonical.hooks);
5879
5929
  }
5880
5930
  if (Object.keys(settings).length === 0) return null;
@@ -6003,8 +6053,8 @@ var init_augment_code2 = __esm({
6003
6053
  ],
6004
6054
  layout: globalLayout5
6005
6055
  },
6006
- emitScopedSettings(canonical) {
6007
- const content = buildSettingsContent(canonical);
6056
+ emitScopedSettings(canonical, _scope, enabledFeatures) {
6057
+ const content = buildSettingsContent(canonical, enabledFeatures);
6008
6058
  if (content === null) return [];
6009
6059
  return [{ path: AUGMENT_CODE_SETTINGS_FILE, content }];
6010
6060
  },
@@ -6552,7 +6602,10 @@ var init_claude_code2 = __esm({
6552
6602
  skillDir: ".claude/skills",
6553
6603
  managedOutputs: {
6554
6604
  dirs: [".claude/agents", ".claude/commands", ".claude/rules", ".claude/skills"],
6555
- files: [".claude/CLAUDE.md", ".claude/settings.json", ".claudeignore", ".mcp.json"]
6605
+ // CLAUDE_NESTED_ROOT is the pre-migration project location; listing it here lets
6606
+ // `cleanupStaleGeneratedOutputs` evict a leftover `.claude/CLAUDE.md` once generation
6607
+ // writes the root `CLAUDE.md`, so Claude Code never concatenates both into context.
6608
+ files: [CLAUDE_ROOT, CLAUDE_NESTED_ROOT, ".claude/settings.json", ".claudeignore", ".mcp.json"]
6556
6609
  },
6557
6610
  paths: {
6558
6611
  rulePath(slug, _rule) {
@@ -6567,7 +6620,7 @@ var init_claude_code2 = __esm({
6567
6620
  }
6568
6621
  };
6569
6622
  globalLayout6 = {
6570
- rootInstructionPath: CLAUDE_ROOT,
6623
+ rootInstructionPath: CLAUDE_NESTED_ROOT,
6571
6624
  skillDir: ".claude/skills",
6572
6625
  renderPrimaryRootInstruction: renderClaudeGlobalPrimaryInstructions,
6573
6626
  managedOutputs: {
@@ -6580,7 +6633,7 @@ var init_claude_code2 = __esm({
6580
6633
  ".agents/skills"
6581
6634
  ],
6582
6635
  files: [
6583
- ".claude/CLAUDE.md",
6636
+ CLAUDE_NESTED_ROOT,
6584
6637
  ".claude/settings.json",
6585
6638
  CLAUDE_GLOBAL_MCP_JSON,
6586
6639
  CLAUDE_HOOKS_JSON,
@@ -6588,6 +6641,7 @@ var init_claude_code2 = __esm({
6588
6641
  ]
6589
6642
  },
6590
6643
  rewriteGeneratedPath(path) {
6644
+ if (path === CLAUDE_ROOT) return CLAUDE_NESTED_ROOT;
6591
6645
  if (path === CLAUDE_MCP_JSON) return CLAUDE_GLOBAL_MCP_JSON;
6592
6646
  return path;
6593
6647
  },
@@ -6651,10 +6705,11 @@ var init_claude_code2 = __esm({
6651
6705
  importer: {
6652
6706
  rules: [
6653
6707
  {
6654
- // Root rule: prefer .claude/CLAUDE.md, fall back to legacy CLAUDE.md (project only).
6708
+ // Root rule: project prefers root CLAUDE.md, falls back to nested .claude/CLAUDE.md;
6709
+ // global reads the nested .claude/CLAUDE.md.
6655
6710
  feature: "rules",
6656
6711
  mode: "singleFile",
6657
- source: { project: [CLAUDE_ROOT, CLAUDE_LEGACY_ROOT], global: [CLAUDE_ROOT] },
6712
+ source: { project: [CLAUDE_ROOT, CLAUDE_NESTED_ROOT], global: [CLAUDE_NESTED_ROOT] },
6658
6713
  canonicalDir: CLAUDE_CANONICAL_RULES_DIR,
6659
6714
  canonicalRootFilename: "_root.md",
6660
6715
  markAsRoot: true
@@ -6700,7 +6755,23 @@ var init_claude_code2 = __esm({
6700
6755
  }
6701
6756
  },
6702
6757
  buildImportPaths: buildClaudeCodeImportPaths,
6703
- detectionPaths: ["CLAUDE.md", ".claude/rules", ".claude/commands"]
6758
+ detectionPaths: [CLAUDE_ROOT, CLAUDE_NESTED_ROOT, ".claude/rules", ".claude/commands"],
6759
+ nativeInstall: {
6760
+ pickPaths: [
6761
+ {
6762
+ prefix: ".claude/commands",
6763
+ feature: "commands",
6764
+ strategy: { kind: "basename", suffix: ".md" }
6765
+ },
6766
+ { prefix: ".claude/rules", feature: "rules", strategy: { kind: "basename", suffix: ".md" } },
6767
+ {
6768
+ prefix: ".claude/agents",
6769
+ feature: "agents",
6770
+ strategy: { kind: "basename", suffix: ".md" }
6771
+ },
6772
+ { prefix: ".claude/skills/", feature: "skills", strategy: { kind: "firstSegment" } }
6773
+ ]
6774
+ }
6704
6775
  };
6705
6776
  }
6706
6777
  });
@@ -7579,6 +7650,16 @@ var init_cline2 = __esm({
7579
7650
  },
7580
7651
  buildImportPaths: buildClineImportPaths,
7581
7652
  detectionPaths: [".clinerules", ".cline"],
7653
+ nativeInstall: {
7654
+ pickPaths: [
7655
+ { prefix: CLINE_SKILLS_DIR, feature: "skills", strategy: { kind: "skillDir" } },
7656
+ {
7657
+ prefix: CLINE_WORKFLOWS_DIR,
7658
+ feature: "commands",
7659
+ strategy: { kind: "basename", suffix: ".md" }
7660
+ }
7661
+ ]
7662
+ },
7582
7663
  conversionDefaults: { agentsToSkills: true }
7583
7664
  };
7584
7665
  }
@@ -8497,6 +8578,11 @@ var init_codex_cli2 = __esm({
8497
8578
  ".codex/agents",
8498
8579
  ".codex/rules"
8499
8580
  ],
8581
+ nativeInstall: {
8582
+ pickPaths: [
8583
+ { prefix: ".codex", feature: "rules", strategy: { kind: "basename", suffix: ".md" } }
8584
+ ]
8585
+ },
8500
8586
  excludeFromStarterInit: true,
8501
8587
  conversionDefaults: { commandsToSkills: true, agentsToSkills: false }
8502
8588
  };
@@ -9000,6 +9086,21 @@ var init_continue2 = __esm({
9000
9086
  },
9001
9087
  buildImportPaths: buildContinueImportPaths,
9002
9088
  detectionPaths: [".continue/rules", ".continue/skills", ".continue/mcpServers"],
9089
+ nativeInstall: {
9090
+ pickPaths: [
9091
+ {
9092
+ prefix: ".continue/rules",
9093
+ feature: "rules",
9094
+ strategy: { kind: "basename", suffix: ".md" }
9095
+ },
9096
+ {
9097
+ prefix: ".continue/prompts",
9098
+ feature: "commands",
9099
+ strategy: { kind: "basename", suffix: ".md" }
9100
+ },
9101
+ { prefix: ".continue/skills", feature: "skills", strategy: { kind: "skillDir" } }
9102
+ ]
9103
+ },
9003
9104
  conversionDefaults: { agentsToSkills: true }
9004
9105
  };
9005
9106
  }
@@ -9367,6 +9468,80 @@ var init_importer10 = __esm({
9367
9468
  init_copilot2();
9368
9469
  }
9369
9470
  });
9471
+ async function skillNamesFromNativeSkillDir(scanRoot) {
9472
+ const files = await readDirRecursive(scanRoot);
9473
+ const names = /* @__PURE__ */ new Set();
9474
+ for (const f of files) {
9475
+ if (basename(f) === "SKILL.md") {
9476
+ names.add(basename(dirname(f)));
9477
+ continue;
9478
+ }
9479
+ const rel2 = relative(scanRoot, f).replace(/\\/g, "/");
9480
+ if (!rel2.includes("/") && f.toLowerCase().endsWith(".md")) {
9481
+ names.add(basename(f, ".md"));
9482
+ }
9483
+ }
9484
+ return [...names].filter(Boolean).sort();
9485
+ }
9486
+ var init_native_skill_scan = __esm({
9487
+ "src/install/native/native-skill-scan.ts"() {
9488
+ init_fs();
9489
+ }
9490
+ });
9491
+ async function inferCopilotPickFromPath(repoRoot, posixPath) {
9492
+ const scan = join(repoRoot, ...posixPath.split("/"));
9493
+ if (posixPath.startsWith(COPILOT_PROMPTS_DIR)) {
9494
+ const files = await readDirRecursive(scan);
9495
+ const commands = [
9496
+ ...new Set(
9497
+ files.filter((f) => f.toLowerCase().endsWith(".prompt.md")).map((f) => basename(f, ".prompt.md"))
9498
+ )
9499
+ ].sort();
9500
+ return commands.length ? { commands } : {};
9501
+ }
9502
+ if (posixPath.startsWith(".github/copilot") && !posixPath.includes("copilot-instructions.md")) {
9503
+ const files = await readDirRecursive(scan);
9504
+ const rules = [
9505
+ ...new Set(
9506
+ files.filter((f) => f.includes(".instructions.md")).map((f) => basename(f).replace(/\.instructions\.md$/i, ""))
9507
+ )
9508
+ ].sort();
9509
+ return rules.length ? { rules } : {};
9510
+ }
9511
+ if (posixPath.startsWith(".github/instructions")) {
9512
+ const files = await readDirRecursive(scan);
9513
+ const names = /* @__PURE__ */ new Set();
9514
+ for (const f of files) {
9515
+ const b = basename(f);
9516
+ if (b.toLowerCase().endsWith(".instructions.md"))
9517
+ names.add(b.replace(/\.instructions\.md$/i, ""));
9518
+ else if (b.toLowerCase().endsWith(".md")) names.add(basename(f, ".md"));
9519
+ }
9520
+ const rules = [...names].sort();
9521
+ return rules.length ? { rules } : {};
9522
+ }
9523
+ if (posixPath.startsWith(".github/skills")) {
9524
+ const skills = await skillNamesFromNativeSkillDir(scan);
9525
+ return skills.length ? { skills } : {};
9526
+ }
9527
+ if (posixPath.startsWith(".github/agents")) {
9528
+ const files = await readDirRecursive(scan);
9529
+ const agents = [
9530
+ ...new Set(
9531
+ files.filter((f) => f.toLowerCase().endsWith(".agent.md")).map((f) => basename(f, ".agent.md"))
9532
+ )
9533
+ ].sort();
9534
+ return agents.length ? { agents } : {};
9535
+ }
9536
+ return {};
9537
+ }
9538
+ var init_native_path_pick_infer_copilot = __esm({
9539
+ "src/install/native/native-path-pick-infer-copilot.ts"() {
9540
+ init_fs();
9541
+ init_constants29();
9542
+ init_native_skill_scan();
9543
+ }
9544
+ });
9370
9545
  function pruneUndefined3(record) {
9371
9546
  for (const key of Object.keys(record)) {
9372
9547
  if (record[key] === void 0) delete record[key];
@@ -9656,6 +9831,7 @@ var init_copilot2 = __esm({
9656
9831
  init_generator11();
9657
9832
  init_constants29();
9658
9833
  init_importer10();
9834
+ init_native_path_pick_infer_copilot();
9659
9835
  init_import_mappers4();
9660
9836
  init_linter10();
9661
9837
  init_import_map_builders();
@@ -9870,7 +10046,8 @@ var init_copilot2 = __esm({
9870
10046
  ".github/skills",
9871
10047
  ".github/agents",
9872
10048
  ".github/hooks"
9873
- ]
10049
+ ],
10050
+ nativeInstall: { inferPick: inferCopilotPickFromPath }
9874
10051
  };
9875
10052
  }
9876
10053
  });
@@ -11370,6 +11547,23 @@ var init_cursor2 = __esm({
11370
11547
  },
11371
11548
  buildImportPaths: buildCursorImportPaths,
11372
11549
  detectionPaths: [".cursor/rules", ".cursor/mcp.json"],
11550
+ nativeInstall: {
11551
+ pickPaths: [
11552
+ { prefix: ".cursor/rules", feature: "rules", strategy: { kind: "basename", suffix: ".mdc" } },
11553
+ {
11554
+ prefix: ".cursor/commands",
11555
+ feature: "commands",
11556
+ strategy: { kind: "basename", suffix: ".md" }
11557
+ },
11558
+ {
11559
+ prefix: ".cursor/agents",
11560
+ feature: "agents",
11561
+ strategy: { kind: "basename", suffix: ".md" }
11562
+ },
11563
+ { prefix: ".cursor/skills", feature: "skills", strategy: { kind: "skillDir" } }
11564
+ ],
11565
+ dialectHints: [{ frontmatterKey: "alwaysApply" }]
11566
+ },
11373
11567
  preservesManualActivation: true
11374
11568
  };
11375
11569
  }
@@ -12131,18 +12325,18 @@ function mapHookEvent2(event) {
12131
12325
  return null;
12132
12326
  }
12133
12327
  }
12134
- function generateGeminiSettingsFiles(canonical) {
12328
+ function generateGeminiSettingsFiles(canonical, enabledFeatures) {
12135
12329
  const settings = {};
12136
12330
  let hasAnyNativeSettings = false;
12137
- if (canonical.mcp && Object.keys(canonical.mcp.mcpServers).length > 0) {
12331
+ if (enabledFeatures.has("mcp") && canonical.mcp && Object.keys(canonical.mcp.mcpServers).length > 0) {
12138
12332
  settings.mcpServers = canonical.mcp.mcpServers;
12139
12333
  hasAnyNativeSettings = true;
12140
12334
  }
12141
- if (canonical.agents.length > 0) {
12335
+ if (enabledFeatures.has("agents") && canonical.agents.length > 0) {
12142
12336
  settings.experimental = { enableAgents: true };
12143
12337
  hasAnyNativeSettings = true;
12144
12338
  }
12145
- if (canonical.hooks) {
12339
+ if (enabledFeatures.has("hooks") && canonical.hooks) {
12146
12340
  const hookEntries = Object.entries(canonical.hooks).flatMap(([event, entries]) => {
12147
12341
  const mappedEvent = mapHookEvent2(event);
12148
12342
  if (!mappedEvent || !Array.isArray(entries)) return [];
@@ -12758,6 +12952,36 @@ var init_importer15 = __esm({
12758
12952
  init_importer_skills_agents();
12759
12953
  }
12760
12954
  });
12955
+ function isUnderGeminiCommands(pathInRepoPosix) {
12956
+ const p = pathInRepoPosix.replace(/^\/+|\/+$/g, "");
12957
+ return p === ".gemini/commands" || p.startsWith(".gemini/commands/");
12958
+ }
12959
+ async function inferGeminiCommandNamesFromFiles(repoRoot, pathInRepoPosix) {
12960
+ const commandsRoot = join(repoRoot, ...GEMINI_COMMANDS_DIR.split("/"));
12961
+ const scanDir = join(repoRoot, ...pathInRepoPosix.split("/"));
12962
+ const files = await readDirRecursive(scanDir);
12963
+ const names = [];
12964
+ for (const f of files) {
12965
+ if (!/\.(toml|md)$/i.test(f)) continue;
12966
+ const rel2 = relative(commandsRoot, f).replace(/\\/g, "/");
12967
+ if (rel2.startsWith("..") || rel2 === "") continue;
12968
+ const noExt = rel2.replace(/\.(toml|md)$/i, "");
12969
+ const name = noExt.split("/").filter(Boolean).join(":");
12970
+ if (name) names.push(name);
12971
+ }
12972
+ return [...new Set(names)].sort();
12973
+ }
12974
+ async function inferGeminiPick(repoRoot, posixPath) {
12975
+ if (!isUnderGeminiCommands(posixPath)) return {};
12976
+ const commands = await inferGeminiCommandNamesFromFiles(repoRoot, posixPath);
12977
+ return commands.length ? { commands } : {};
12978
+ }
12979
+ var init_gemini_install_commands = __esm({
12980
+ "src/install/native/gemini-install-commands.ts"() {
12981
+ init_fs();
12982
+ init_constants30();
12983
+ }
12984
+ });
12761
12985
  async function mapGeminiRuleFile(relativePath, destDir, normalizeTo) {
12762
12986
  const relativeMdPath = relativePath.replace(/\\/g, "/");
12763
12987
  const destPath = join(destDir, relativeMdPath);
@@ -12869,12 +13093,12 @@ var init_lint12 = __esm({
12869
13093
  });
12870
13094
 
12871
13095
  // src/targets/gemini-cli/scoped-settings-emit.ts
12872
- function emitScopedGeminiSettings(canonical, scope) {
13096
+ function emitScopedGeminiSettings(canonical, scope, enabledFeatures) {
12873
13097
  if (scope === "project") {
12874
13098
  const caps = getTargetCapabilities("gemini-cli", scope);
12875
13099
  if (caps?.ignore.flavor !== "settings-embedded") return [];
12876
13100
  }
12877
- return generateGeminiSettingsFiles(canonical);
13101
+ return generateGeminiSettingsFiles(canonical, enabledFeatures);
12878
13102
  }
12879
13103
  var init_scoped_settings_emit = __esm({
12880
13104
  "src/targets/gemini-cli/scoped-settings-emit.ts"() {
@@ -12892,6 +13116,7 @@ var init_gemini_cli2 = __esm({
12892
13116
  init_policies_generator();
12893
13117
  init_constants30();
12894
13118
  init_importer15();
13119
+ init_gemini_install_commands();
12895
13120
  init_import_mappers6();
12896
13121
  init_linter15();
12897
13122
  init_import_map_builders();
@@ -13087,6 +13312,7 @@ var init_gemini_cli2 = __esm({
13087
13312
  },
13088
13313
  buildImportPaths: buildGeminiCliImportPaths,
13089
13314
  detectionPaths: ["GEMINI.md", ".gemini"],
13315
+ nativeInstall: { inferPick: inferGeminiPick },
13090
13316
  conversionDefaults: { agentsToSkills: false }
13091
13317
  };
13092
13318
  }
@@ -13928,7 +14154,23 @@ var init_junie2 = __esm({
13928
14154
  ".junie/skills",
13929
14155
  ".junie/mcp/mcp.json",
13930
14156
  ".aiignore"
13931
- ]
14157
+ ],
14158
+ nativeInstall: {
14159
+ pickPaths: [
14160
+ {
14161
+ prefix: ".junie/commands",
14162
+ feature: "commands",
14163
+ strategy: { kind: "basename", suffix: ".md" }
14164
+ },
14165
+ { prefix: ".junie/rules", feature: "rules", strategy: { kind: "basename", suffix: ".md" } },
14166
+ {
14167
+ prefix: ".junie/agents",
14168
+ feature: "agents",
14169
+ strategy: { kind: "basename", suffix: ".md" }
14170
+ },
14171
+ { prefix: ".junie/skills", feature: "skills", strategy: { kind: "skillDir" } }
14172
+ ]
14173
+ }
13932
14174
  };
13933
14175
  }
13934
14176
  });
@@ -15783,9 +16025,18 @@ function generateIgnore12(canonical) {
15783
16025
  if (!canonical.ignore || canonical.ignore.length === 0) return [];
15784
16026
  return [{ path: QWEN_IGNORE, content: canonical.ignore.join("\n") }];
15785
16027
  }
16028
+ function renderQwenGlobalInstructions(canonical) {
16029
+ const root = canonical.rules.find((rule) => rule.root);
16030
+ const nonRootRules = canonical.rules.filter((rule) => {
16031
+ if (rule.root) return false;
16032
+ return rule.targets.length === 0 || rule.targets.includes(QWEN_CODE_TARGET);
16033
+ });
16034
+ return appendEmbeddedRulesBlock(root?.body.trim() ?? "", nonRootRules);
16035
+ }
15786
16036
  var init_generator26 = __esm({
15787
16037
  "src/targets/qwen-code/generator.ts"() {
15788
16038
  init_markdown();
16039
+ init_managed_blocks();
15789
16040
  init_constants21();
15790
16041
  }
15791
16042
  });
@@ -15868,6 +16119,7 @@ var init_qwen_code2 = __esm({
15868
16119
  };
15869
16120
  globalLayout22 = {
15870
16121
  rootInstructionPath: QWEN_GLOBAL_ROOT,
16122
+ renderPrimaryRootInstruction: renderQwenGlobalInstructions,
15871
16123
  skillDir: QWEN_GLOBAL_SKILLS_DIR,
15872
16124
  managedOutputs: {
15873
16125
  dirs: [QWEN_GLOBAL_COMMANDS_DIR, QWEN_GLOBAL_AGENTS_DIR, QWEN_GLOBAL_SKILLS_DIR],
@@ -18268,6 +18520,16 @@ var init_windsurf2 = __esm({
18268
18520
  },
18269
18521
  buildImportPaths: buildWindsurfImportPaths,
18270
18522
  detectionPaths: [".windsurfrules", ".windsurf"],
18523
+ nativeInstall: {
18524
+ pickPaths: [
18525
+ {
18526
+ prefix: ".windsurf/rules",
18527
+ feature: "rules",
18528
+ strategy: { kind: "basename", suffix: ".md" }
18529
+ }
18530
+ ],
18531
+ dialectHints: [{ frontmatterKey: "trigger" }]
18532
+ },
18271
18533
  conversionDefaults: { agentsToSkills: true }
18272
18534
  };
18273
18535
  }
@@ -18542,7 +18804,8 @@ var init_zed2 = __esm({
18542
18804
  markAsRoot: true
18543
18805
  }
18544
18806
  },
18545
- emitScopedSettings(canonical, _scope) {
18807
+ emitScopedSettings(canonical, _scope, enabledFeatures) {
18808
+ if (!enabledFeatures.has("mcp")) return [];
18546
18809
  if (!canonical.mcp || Object.keys(canonical.mcp.mcpServers).length === 0) return [];
18547
18810
  const contextServers = {};
18548
18811
  for (const [name, server] of Object.entries(canonical.mcp.mcpServers)) {
@@ -18597,7 +18860,10 @@ function getBuiltinTargetDefinition(target31) {
18597
18860
  function getTargetCapabilities(target31, scope = "project") {
18598
18861
  const descriptor31 = getBuiltinTargetDefinition(target31) ?? getDescriptor(target31);
18599
18862
  if (!descriptor31) return void 0;
18600
- const raw = scope === "global" ? descriptor31.globalSupport?.capabilities ?? descriptor31.capabilities : descriptor31.capabilities;
18863
+ if (scope === "global" && !descriptor31.globalSupport) {
18864
+ return normalizeTargetCapabilities(ALL_NONE_CAPABILITIES);
18865
+ }
18866
+ const raw = scope === "global" ? descriptor31.globalSupport.capabilities : descriptor31.capabilities;
18601
18867
  return normalizeTargetCapabilities(raw);
18602
18868
  }
18603
18869
  function getTargetDetectionPaths(target31, scope = "project") {
@@ -18653,6 +18919,7 @@ function isConversionUpgrading(descriptor31, feature, config, scope) {
18653
18919
  function getEffectiveTargetSupportLevel(target31, feature, config, scope = "project") {
18654
18920
  const baseLevel = getTargetCapabilities(target31, scope)?.[feature]?.level ?? "none";
18655
18921
  const descriptor31 = getBuiltinTargetDefinition(target31) ?? getDescriptor(target31);
18922
+ if (scope === "global" && descriptor31 && !descriptor31.globalSupport) return "none";
18656
18923
  if (baseLevel === "none" && isConversionUpgrading(descriptor31, feature, config, scope)) {
18657
18924
  return "embedded";
18658
18925
  }
@@ -18666,7 +18933,7 @@ function resolveTargetFeatureGenerator(target31, feature, config, scope = "proje
18666
18933
  const pick = PICK_FEATURE_GENERATOR[feature];
18667
18934
  return pick === null ? void 0 : pick(descriptor31.generators);
18668
18935
  }
18669
- var BUILTIN_TARGETS, _builtinTargetsMap, PICK_FEATURE_GENERATOR;
18936
+ var ALL_NONE_CAPABILITIES, BUILTIN_TARGETS, _builtinTargetsMap, PICK_FEATURE_GENERATOR;
18670
18937
  var init_builtin_targets = __esm({
18671
18938
  "src/targets/catalog/builtin-targets.ts"() {
18672
18939
  init_conversions();
@@ -18704,6 +18971,17 @@ var init_builtin_targets = __esm({
18704
18971
  init_warp2();
18705
18972
  init_windsurf2();
18706
18973
  init_zed2();
18974
+ ALL_NONE_CAPABILITIES = {
18975
+ rules: "none",
18976
+ additionalRules: "none",
18977
+ commands: "none",
18978
+ agents: "none",
18979
+ skills: "none",
18980
+ mcp: "none",
18981
+ hooks: "none",
18982
+ ignore: "none",
18983
+ permissions: "none"
18984
+ };
18707
18985
  BUILTIN_TARGETS = [
18708
18986
  descriptor,
18709
18987
  descriptor2,
@@ -18798,7 +19076,7 @@ async function fetchGitRemoteExtend(parsed, extendName, options, cacheDir, build
18798
19076
  await cloneRepo(resolveCloneUrl(parsed), stagedRepoDir);
18799
19077
  if (parsed.ref) await checkoutRef(stagedRepoDir, parsed.ref);
18800
19078
  await rm(cacheRoot, { recursive: true, force: true });
18801
- await rename(stagedRoot, cacheRoot);
19079
+ await renameWithRetry(stagedRoot, cacheRoot);
18802
19080
  return readCachedRepo(cacheRepoDir);
18803
19081
  } catch (err) {
18804
19082
  await rm(stagedRoot, { recursive: true, force: true });
@@ -19360,6 +19638,23 @@ function assertNoBasenameCollisions(feature, paths, stripExt) {
19360
19638
  }
19361
19639
  }
19362
19640
 
19641
+ // src/utils/output/color.ts
19642
+ function noColorRequested() {
19643
+ const value = process.env.NO_COLOR;
19644
+ return value !== void 0 && value !== "";
19645
+ }
19646
+ function forceColorRequested() {
19647
+ const value = process.env.FORCE_COLOR;
19648
+ if (value === void 0) return void 0;
19649
+ return value !== "0" && value !== "false";
19650
+ }
19651
+ function colorEnabled(stream = process.stdout) {
19652
+ const forced = forceColorRequested();
19653
+ if (forced !== void 0) return forced;
19654
+ if (noColorRequested()) return false;
19655
+ return stream.isTTY === true;
19656
+ }
19657
+
19363
19658
  // src/utils/output/logger.ts
19364
19659
  var C = {
19365
19660
  green: "\x1B[32m",
@@ -19368,16 +19663,14 @@ var C = {
19368
19663
  cyan: "\x1B[36m",
19369
19664
  reset: "\x1B[0m"
19370
19665
  };
19371
- function out(text) {
19372
- {
19373
- process.stdout.write(text);
19374
- }
19666
+ function outStream() {
19667
+ return process.stdout;
19375
19668
  }
19376
- function noColor() {
19377
- return process.env.NO_COLOR !== void 0 && process.env.NO_COLOR !== "";
19669
+ function out(text) {
19670
+ outStream().write(text);
19378
19671
  }
19379
- function c(code, text) {
19380
- return noColor() ? text : `${code}${text}${C.reset}`;
19672
+ function c(code, text, stream) {
19673
+ return colorEnabled(stream) ? `${code}${text}${C.reset}` : text;
19381
19674
  }
19382
19675
  function pad(str, width) {
19383
19676
  const len = [...str].length;
@@ -19385,20 +19678,20 @@ function pad(str, width) {
19385
19678
  }
19386
19679
  var logger = {
19387
19680
  info(msg) {
19388
- out(c(C.cyan, msg) + "\n");
19681
+ out(c(C.cyan, msg, outStream()) + "\n");
19389
19682
  },
19390
19683
  warn(msg) {
19391
- process.stderr.write(c(C.yellow, "\u26A0 ") + msg + "\n");
19684
+ process.stderr.write(c(C.yellow, "\u26A0 ", process.stderr) + msg + "\n");
19392
19685
  },
19393
19686
  error(msg) {
19394
- process.stderr.write(c(C.red, "\u2717 ") + msg + "\n");
19687
+ process.stderr.write(c(C.red, "\u2717 ", process.stderr) + msg + "\n");
19395
19688
  },
19396
19689
  success(msg) {
19397
- out(c(C.green, "\u2713 ") + msg + "\n");
19690
+ out(c(C.green, "\u2713 ", outStream()) + msg + "\n");
19398
19691
  },
19399
19692
  debug(msg) {
19400
19693
  if (process.env.AGENTSMESH_DEBUG === "1") {
19401
- out(c(C.cyan, "[debug] ") + msg + "\n");
19694
+ out(c(C.cyan, "[debug] ", outStream()) + msg + "\n");
19402
19695
  }
19403
19696
  },
19404
19697
  table(rows) {