agentsmesh 0.2.0 → 0.2.2
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 +26 -15
- package/LICENSE +1 -1
- package/README.md +44 -44
- package/dist/cli.js +553 -402
- package/dist/cli.js.map +1 -1
- package/package.json +23 -25
package/dist/cli.js
CHANGED
|
@@ -99,7 +99,7 @@ var logger = {
|
|
|
99
99
|
process.stdout.write(c(C.green, "\u2713 ") + msg + "\n");
|
|
100
100
|
},
|
|
101
101
|
debug(msg) {
|
|
102
|
-
if (process.env.
|
|
102
|
+
if (process.env.AGENTSMESH_DEBUG === "1") {
|
|
103
103
|
process.stdout.write(c(C.cyan, "[debug] ") + msg + "\n");
|
|
104
104
|
}
|
|
105
105
|
},
|
|
@@ -135,13 +135,13 @@ var GLOBAL_FLAGS = [
|
|
|
135
135
|
var COMMANDS = [
|
|
136
136
|
{
|
|
137
137
|
name: "init",
|
|
138
|
-
usage: "
|
|
139
|
-
description: "Create
|
|
138
|
+
usage: "agentsmesh init [flags]",
|
|
139
|
+
description: "Create agentsmesh.yaml, agentsmesh.local.yaml, and canonical .agentsmesh scaffold",
|
|
140
140
|
flags: [{ name: "--yes", description: "Auto-import detected tool configs without prompting" }]
|
|
141
141
|
},
|
|
142
142
|
{
|
|
143
143
|
name: "generate",
|
|
144
|
-
usage: "
|
|
144
|
+
usage: "agentsmesh generate [flags]",
|
|
145
145
|
description: "Generate target files from canonical sources",
|
|
146
146
|
flags: [
|
|
147
147
|
{ name: "--targets <csv>", description: "Limit generation to target IDs (comma-separated)" },
|
|
@@ -154,13 +154,13 @@ var COMMANDS = [
|
|
|
154
154
|
},
|
|
155
155
|
{
|
|
156
156
|
name: "import",
|
|
157
|
-
usage: "
|
|
158
|
-
description: "Import existing tool config into canonical .
|
|
157
|
+
usage: "agentsmesh import --from <target>",
|
|
158
|
+
description: "Import existing tool config into canonical .agentsmesh files",
|
|
159
159
|
flags: [{ name: "--from <target>", description: "Source tool ID to import from (required)" }]
|
|
160
160
|
},
|
|
161
161
|
{
|
|
162
162
|
name: "install",
|
|
163
|
-
usage: "
|
|
163
|
+
usage: "agentsmesh install <source> [flags]",
|
|
164
164
|
description: "Install canonical resources from local/remote sources",
|
|
165
165
|
flags: [
|
|
166
166
|
{
|
|
@@ -169,7 +169,7 @@ var COMMANDS = [
|
|
|
169
169
|
},
|
|
170
170
|
{
|
|
171
171
|
name: "--sync",
|
|
172
|
-
description: "Reinstall missing packs recorded in .
|
|
172
|
+
description: "Reinstall missing packs recorded in .agentsmesh/installs.yaml"
|
|
173
173
|
},
|
|
174
174
|
{
|
|
175
175
|
name: "--path <dir>",
|
|
@@ -200,13 +200,13 @@ var COMMANDS = [
|
|
|
200
200
|
},
|
|
201
201
|
{
|
|
202
202
|
name: "diff",
|
|
203
|
-
usage: "
|
|
203
|
+
usage: "agentsmesh diff [flags]",
|
|
204
204
|
description: "Show patch-style output for what generate would change",
|
|
205
205
|
flags: [{ name: "--targets <csv>", description: "Limit diff to target IDs (comma-separated)" }]
|
|
206
206
|
},
|
|
207
207
|
{
|
|
208
208
|
name: "lint",
|
|
209
|
-
usage: "
|
|
209
|
+
usage: "agentsmesh lint [flags]",
|
|
210
210
|
description: "Validate canonical files against target constraints",
|
|
211
211
|
flags: [
|
|
212
212
|
{ name: "--targets <csv>", description: "Limit linting to target IDs (comma-separated)" }
|
|
@@ -214,7 +214,7 @@ var COMMANDS = [
|
|
|
214
214
|
},
|
|
215
215
|
{
|
|
216
216
|
name: "watch",
|
|
217
|
-
usage: "
|
|
217
|
+
usage: "agentsmesh watch [flags]",
|
|
218
218
|
description: "Watch canonical files and regenerate on change",
|
|
219
219
|
flags: [
|
|
220
220
|
{
|
|
@@ -225,19 +225,19 @@ var COMMANDS = [
|
|
|
225
225
|
},
|
|
226
226
|
{
|
|
227
227
|
name: "check",
|
|
228
|
-
usage: "
|
|
229
|
-
description: "Verify canonical files still match .
|
|
228
|
+
usage: "agentsmesh check",
|
|
229
|
+
description: "Verify canonical files still match .agentsmesh/.lock",
|
|
230
230
|
flags: []
|
|
231
231
|
},
|
|
232
232
|
{
|
|
233
233
|
name: "merge",
|
|
234
|
-
usage: "
|
|
235
|
-
description: "Resolve .
|
|
234
|
+
usage: "agentsmesh merge",
|
|
235
|
+
description: "Resolve .agentsmesh/.lock merge conflicts from current canonical state",
|
|
236
236
|
flags: []
|
|
237
237
|
},
|
|
238
238
|
{
|
|
239
239
|
name: "matrix",
|
|
240
|
-
usage: "
|
|
240
|
+
usage: "agentsmesh matrix [flags]",
|
|
241
241
|
description: "Print compatibility matrix for enabled features and targets",
|
|
242
242
|
flags: [
|
|
243
243
|
{ name: "--targets <csv>", description: "Limit matrix columns to target IDs" },
|
|
@@ -255,7 +255,7 @@ function printHelp() {
|
|
|
255
255
|
Usage: ${command.usage}
|
|
256
256
|
${formatFlags(command.flags)}`;
|
|
257
257
|
}).join("\n\n");
|
|
258
|
-
logger.info(`
|
|
258
|
+
logger.info(`agentsmesh <command> [flags]
|
|
259
259
|
|
|
260
260
|
Global flags:
|
|
261
261
|
${formatFlags(GLOBAL_FLAGS)}
|
|
@@ -263,7 +263,7 @@ ${formatFlags(GLOBAL_FLAGS)}
|
|
|
263
263
|
Commands:
|
|
264
264
|
${commandLines}
|
|
265
265
|
|
|
266
|
-
Tip: run "
|
|
266
|
+
Tip: run "agentsmesh <command> --help" for this same command reference.`);
|
|
267
267
|
}
|
|
268
268
|
|
|
269
269
|
// src/cli/version.ts
|
|
@@ -278,7 +278,7 @@ function getVersion() {
|
|
|
278
278
|
return pkg.version;
|
|
279
279
|
}
|
|
280
280
|
function printVersion() {
|
|
281
|
-
process.stdout.write(`
|
|
281
|
+
process.stdout.write(`agentsmesh v${pkg.version}
|
|
282
282
|
`);
|
|
283
283
|
}
|
|
284
284
|
|
|
@@ -424,7 +424,7 @@ import { basename, dirname as dirname3, join as join3, relative } from "path";
|
|
|
424
424
|
|
|
425
425
|
// src/targets/codex-cli/command-skill.ts
|
|
426
426
|
init_markdown();
|
|
427
|
-
var CODEX_COMMAND_SKILL_PREFIX = "
|
|
427
|
+
var CODEX_COMMAND_SKILL_PREFIX = "am-command-";
|
|
428
428
|
var LEGACY_CODEX_COMMAND_SKILL_PREFIX = "ab-command-";
|
|
429
429
|
function toStringArray(value) {
|
|
430
430
|
if (Array.isArray(value)) {
|
|
@@ -442,26 +442,26 @@ function serializeCommandSkill(command) {
|
|
|
442
442
|
const frontmatter = {
|
|
443
443
|
name: commandSkillDirName(command.name),
|
|
444
444
|
description: command.description || void 0,
|
|
445
|
-
"x-
|
|
446
|
-
"x-
|
|
447
|
-
"x-
|
|
445
|
+
"x-agentsmesh-kind": "command",
|
|
446
|
+
"x-agentsmesh-name": command.name,
|
|
447
|
+
"x-agentsmesh-allowed-tools": command.allowedTools.length > 0 ? command.allowedTools : void 0
|
|
448
448
|
};
|
|
449
449
|
if (frontmatter.description === void 0) delete frontmatter.description;
|
|
450
|
-
if (frontmatter["x-
|
|
451
|
-
delete frontmatter["x-
|
|
450
|
+
if (frontmatter["x-agentsmesh-allowed-tools"] === void 0) {
|
|
451
|
+
delete frontmatter["x-agentsmesh-allowed-tools"];
|
|
452
452
|
}
|
|
453
453
|
return serializeFrontmatter(frontmatter, command.body.trim() || "");
|
|
454
454
|
}
|
|
455
455
|
function parseCommandSkillFrontmatter(frontmatter, dirName) {
|
|
456
|
-
if (frontmatter["x-
|
|
457
|
-
const metadataName = typeof frontmatter["x-
|
|
456
|
+
if (frontmatter["x-agentsmesh-kind"] !== "command") return null;
|
|
457
|
+
const metadataName = typeof frontmatter["x-agentsmesh-name"] === "string" ? frontmatter["x-agentsmesh-name"] : "";
|
|
458
458
|
const derivedName = dirName.startsWith(CODEX_COMMAND_SKILL_PREFIX) ? dirName.slice(CODEX_COMMAND_SKILL_PREFIX.length) : dirName.startsWith(LEGACY_CODEX_COMMAND_SKILL_PREFIX) ? dirName.slice(LEGACY_CODEX_COMMAND_SKILL_PREFIX.length) : "";
|
|
459
459
|
const name = (metadataName || derivedName).trim();
|
|
460
460
|
if (!name) return null;
|
|
461
461
|
return {
|
|
462
462
|
name,
|
|
463
463
|
description: typeof frontmatter.description === "string" ? frontmatter.description : "",
|
|
464
|
-
allowedTools: toStringArray(frontmatter["x-
|
|
464
|
+
allowedTools: toStringArray(frontmatter["x-agentsmesh-allowed-tools"])
|
|
465
465
|
};
|
|
466
466
|
}
|
|
467
467
|
function serializeImportedCommand(command, body) {
|
|
@@ -476,7 +476,7 @@ function serializeImportedCommand(command, body) {
|
|
|
476
476
|
|
|
477
477
|
// src/targets/projected-agent-skill.ts
|
|
478
478
|
init_markdown();
|
|
479
|
-
var PROJECTED_AGENT_SKILL_PREFIX = "
|
|
479
|
+
var PROJECTED_AGENT_SKILL_PREFIX = "am-agent-";
|
|
480
480
|
var LEGACY_PROJECTED_AGENT_SKILL_PREFIX = "ab-agent-";
|
|
481
481
|
function toStringArray2(value) {
|
|
482
482
|
if (Array.isArray(value)) {
|
|
@@ -505,17 +505,17 @@ function serializeProjectedAgentSkill(agent) {
|
|
|
505
505
|
const frontmatter = {
|
|
506
506
|
name: projectedAgentSkillDirName(agent.name),
|
|
507
507
|
description: agent.description || void 0,
|
|
508
|
-
"x-
|
|
509
|
-
"x-
|
|
510
|
-
"x-
|
|
511
|
-
"x-
|
|
512
|
-
"x-
|
|
513
|
-
"x-
|
|
514
|
-
"x-
|
|
515
|
-
"x-
|
|
516
|
-
"x-
|
|
517
|
-
"x-
|
|
518
|
-
"x-
|
|
508
|
+
"x-agentsmesh-kind": "agent",
|
|
509
|
+
"x-agentsmesh-name": agent.name,
|
|
510
|
+
"x-agentsmesh-tools": agent.tools.length > 0 ? agent.tools : void 0,
|
|
511
|
+
"x-agentsmesh-disallowed-tools": agent.disallowedTools.length > 0 ? agent.disallowedTools : void 0,
|
|
512
|
+
"x-agentsmesh-model": agent.model || void 0,
|
|
513
|
+
"x-agentsmesh-permission-mode": agent.permissionMode || void 0,
|
|
514
|
+
"x-agentsmesh-max-turns": agent.maxTurns > 0 ? agent.maxTurns : void 0,
|
|
515
|
+
"x-agentsmesh-mcp-servers": agent.mcpServers.length > 0 ? agent.mcpServers : void 0,
|
|
516
|
+
"x-agentsmesh-hooks": Object.keys(agent.hooks).length > 0 ? agent.hooks : void 0,
|
|
517
|
+
"x-agentsmesh-skills": agent.skills.length > 0 ? agent.skills : void 0,
|
|
518
|
+
"x-agentsmesh-memory": agent.memory || void 0
|
|
519
519
|
};
|
|
520
520
|
Object.keys(frontmatter).forEach((key) => {
|
|
521
521
|
if (frontmatter[key] === void 0) delete frontmatter[key];
|
|
@@ -523,23 +523,23 @@ function serializeProjectedAgentSkill(agent) {
|
|
|
523
523
|
return serializeFrontmatter(frontmatter, agent.body.trim() || "");
|
|
524
524
|
}
|
|
525
525
|
function parseProjectedAgentSkillFrontmatter(frontmatter, dirName) {
|
|
526
|
-
if (frontmatter["x-
|
|
527
|
-
const metadataName = typeof frontmatter["x-
|
|
526
|
+
if (frontmatter["x-agentsmesh-kind"] !== "agent") return null;
|
|
527
|
+
const metadataName = typeof frontmatter["x-agentsmesh-name"] === "string" ? frontmatter["x-agentsmesh-name"] : "";
|
|
528
528
|
const derivedName = dirName.startsWith(PROJECTED_AGENT_SKILL_PREFIX) ? dirName.slice(PROJECTED_AGENT_SKILL_PREFIX.length) : dirName.startsWith(LEGACY_PROJECTED_AGENT_SKILL_PREFIX) ? dirName.slice(LEGACY_PROJECTED_AGENT_SKILL_PREFIX.length) : "";
|
|
529
529
|
const name = (metadataName || derivedName).trim();
|
|
530
530
|
if (!name) return null;
|
|
531
531
|
return {
|
|
532
532
|
name,
|
|
533
533
|
description: typeof frontmatter.description === "string" ? frontmatter.description : "",
|
|
534
|
-
tools: toStringArray2(frontmatter["x-
|
|
535
|
-
disallowedTools: toStringArray2(frontmatter["x-
|
|
536
|
-
model: typeof frontmatter["x-
|
|
537
|
-
permissionMode: typeof frontmatter["x-
|
|
538
|
-
maxTurns: typeof frontmatter["x-
|
|
539
|
-
mcpServers: toStringArray2(frontmatter["x-
|
|
540
|
-
hooks: toHooks(frontmatter["x-
|
|
541
|
-
skills: toStringArray2(frontmatter["x-
|
|
542
|
-
memory: typeof frontmatter["x-
|
|
534
|
+
tools: toStringArray2(frontmatter["x-agentsmesh-tools"]),
|
|
535
|
+
disallowedTools: toStringArray2(frontmatter["x-agentsmesh-disallowed-tools"]),
|
|
536
|
+
model: typeof frontmatter["x-agentsmesh-model"] === "string" ? frontmatter["x-agentsmesh-model"] : "",
|
|
537
|
+
permissionMode: typeof frontmatter["x-agentsmesh-permission-mode"] === "string" ? frontmatter["x-agentsmesh-permission-mode"] : "",
|
|
538
|
+
maxTurns: typeof frontmatter["x-agentsmesh-max-turns"] === "number" ? frontmatter["x-agentsmesh-max-turns"] : Number(frontmatter["x-agentsmesh-max-turns"] ?? 0),
|
|
539
|
+
mcpServers: toStringArray2(frontmatter["x-agentsmesh-mcp-servers"]),
|
|
540
|
+
hooks: toHooks(frontmatter["x-agentsmesh-hooks"]),
|
|
541
|
+
skills: toStringArray2(frontmatter["x-agentsmesh-skills"]),
|
|
542
|
+
memory: typeof frontmatter["x-agentsmesh-memory"] === "string" ? frontmatter["x-agentsmesh-memory"] : ""
|
|
543
543
|
};
|
|
544
544
|
}
|
|
545
545
|
function serializeImportedAgent(agent, body) {
|
|
@@ -563,10 +563,10 @@ function serializeImportedAgent(agent, body) {
|
|
|
563
563
|
}
|
|
564
564
|
|
|
565
565
|
// src/core/import-reference-map-shared.ts
|
|
566
|
-
var AB_RULES = ".
|
|
567
|
-
var AB_COMMANDS = ".
|
|
568
|
-
var AB_AGENTS = ".
|
|
569
|
-
var AB_SKILLS = ".
|
|
566
|
+
var AB_RULES = ".agentsmesh/rules";
|
|
567
|
+
var AB_COMMANDS = ".agentsmesh/commands";
|
|
568
|
+
var AB_AGENTS = ".agentsmesh/agents";
|
|
569
|
+
var AB_SKILLS = ".agentsmesh/skills";
|
|
570
570
|
function rel(projectRoot, absPath) {
|
|
571
571
|
return relative(projectRoot, absPath).replace(/\\/g, "/");
|
|
572
572
|
}
|
|
@@ -647,9 +647,9 @@ async function addScopedAgentsMappings(refs, projectRoot) {
|
|
|
647
647
|
}
|
|
648
648
|
|
|
649
649
|
// src/core/import-reference-map-builders.ts
|
|
650
|
-
var AB_RULES2 = ".
|
|
651
|
-
var AB_COMMANDS2 = ".
|
|
652
|
-
var AB_AGENTS2 = ".
|
|
650
|
+
var AB_RULES2 = ".agentsmesh/rules";
|
|
651
|
+
var AB_COMMANDS2 = ".agentsmesh/commands";
|
|
652
|
+
var AB_AGENTS2 = ".agentsmesh/agents";
|
|
653
653
|
function addCopilotInstructionMapping(refs, fromPath) {
|
|
654
654
|
if (fromPath.endsWith(".instructions.md")) {
|
|
655
655
|
refs.set(fromPath, `${AB_RULES2}/${basename2(fromPath, ".instructions.md")}.md`);
|
|
@@ -886,7 +886,7 @@ function rootFallbackPath(token, projectRoot) {
|
|
|
886
886
|
import { existsSync, realpathSync } from "fs";
|
|
887
887
|
import { isAbsolute, win32 as win322 } from "path";
|
|
888
888
|
var ROOT_RELATIVE_PREFIXES = [
|
|
889
|
-
".
|
|
889
|
+
".agentsmesh/",
|
|
890
890
|
".claude/",
|
|
891
891
|
".cursor/",
|
|
892
892
|
".github/",
|
|
@@ -913,7 +913,7 @@ var EXTERNAL_REF_PATTERNS = [
|
|
|
913
913
|
/\/\/[A-Za-z0-9][\w.-]*\.[A-Za-z]{2,}[^\s<>()\]]*/g
|
|
914
914
|
];
|
|
915
915
|
var FENCED_CODE_BLOCK = /^(?:```|~~~)[^\n]*\n[\s\S]*?^(?:```|~~~)/gm;
|
|
916
|
-
var PATH_TOKEN = /(?:\.\.[\\/]|\.\/|\.\\|\/[A-Za-z0-9._-]|[A-Za-z]:[\\/][A-Za-z0-9._-]|\.
|
|
916
|
+
var PATH_TOKEN = /(?:\.\.[\\/]|\.\/|\.\\|\/[A-Za-z0-9._-]|[A-Za-z]:[\\/][A-Za-z0-9._-]|\.agentsmesh[\\/]|\.claude[\\/]|\.cursor[\\/]|\.github[\\/]|\.continue[\\/]|\.junie[\\/]|\.gemini[\\/]|\.clinerules[\\/]|\.cline[\\/]|\.agents[\\/]|\.windsurf[\\/]|(?:[A-Za-z0-9._-]+[\\/])+|[A-Za-z0-9._-]+\.[A-Za-z0-9._-]+)[A-Za-z0-9._@%+~:\\/-]*/g;
|
|
917
917
|
var LINE_NUMBER_SUFFIX = /(?::(\d+)){1,2}$/;
|
|
918
918
|
function resolveProjectPath(token, projectRoot, sourceFile) {
|
|
919
919
|
const api = pathApi(projectRoot);
|
|
@@ -1191,9 +1191,9 @@ async function importFileDirectory(opts) {
|
|
|
1191
1191
|
// src/targets/claude-code/importer-mappers.ts
|
|
1192
1192
|
init_markdown();
|
|
1193
1193
|
import { basename as basename4, join as join5 } from "path";
|
|
1194
|
-
var AB_RULES3 = ".
|
|
1195
|
-
var AB_COMMANDS3 = ".
|
|
1196
|
-
var AB_AGENTS3 = ".
|
|
1194
|
+
var AB_RULES3 = ".agentsmesh/rules";
|
|
1195
|
+
var AB_COMMANDS3 = ".agentsmesh/commands";
|
|
1196
|
+
var AB_AGENTS3 = ".agentsmesh/agents";
|
|
1197
1197
|
async function mapClaudeRuleFile(srcPath, destDir, normalizeTo) {
|
|
1198
1198
|
const name = basename4(srcPath, ".md");
|
|
1199
1199
|
const destPath = join5(destDir, `${name}.md`);
|
|
@@ -1250,9 +1250,9 @@ function hasHookText(entry) {
|
|
|
1250
1250
|
import { stringify as yamlStringify2 } from "yaml";
|
|
1251
1251
|
var CLAUDE_SETTINGS = ".claude/settings.json";
|
|
1252
1252
|
var CLAUDE_MCP_JSON = ".mcp.json";
|
|
1253
|
-
var AB_MCP = ".
|
|
1254
|
-
var AB_PERMISSIONS = ".
|
|
1255
|
-
var AB_HOOKS = ".
|
|
1253
|
+
var AB_MCP = ".agentsmesh/mcp.json";
|
|
1254
|
+
var AB_PERMISSIONS = ".agentsmesh/permissions.yaml";
|
|
1255
|
+
var AB_HOOKS = ".agentsmesh/hooks.yaml";
|
|
1256
1256
|
function claudeHooksToCanonical(hooks) {
|
|
1257
1257
|
const result = {};
|
|
1258
1258
|
for (const [event, entries] of Object.entries(hooks)) {
|
|
@@ -1367,11 +1367,11 @@ var CLAUDE_COMMANDS_DIR = ".claude/commands";
|
|
|
1367
1367
|
var CLAUDE_AGENTS_DIR = ".claude/agents";
|
|
1368
1368
|
var CLAUDE_SKILLS_DIR = ".claude/skills";
|
|
1369
1369
|
var CLAUDEIGNORE = ".claudeignore";
|
|
1370
|
-
var AB_RULES4 = ".
|
|
1371
|
-
var AB_COMMANDS4 = ".
|
|
1372
|
-
var AB_AGENTS4 = ".
|
|
1373
|
-
var AB_SKILLS2 = ".
|
|
1374
|
-
var AB_IGNORE = ".
|
|
1370
|
+
var AB_RULES4 = ".agentsmesh/rules";
|
|
1371
|
+
var AB_COMMANDS4 = ".agentsmesh/commands";
|
|
1372
|
+
var AB_AGENTS4 = ".agentsmesh/agents";
|
|
1373
|
+
var AB_SKILLS2 = ".agentsmesh/skills";
|
|
1374
|
+
var AB_IGNORE = ".agentsmesh/ignore";
|
|
1375
1375
|
async function importFromClaudeCode(projectRoot) {
|
|
1376
1376
|
const results = [];
|
|
1377
1377
|
const normalize = await createImportReferenceNormalizer("claude-code", projectRoot);
|
|
@@ -1526,8 +1526,8 @@ function toStringRecord(value) {
|
|
|
1526
1526
|
}
|
|
1527
1527
|
|
|
1528
1528
|
// src/targets/cline/importer-mappers.ts
|
|
1529
|
-
var
|
|
1530
|
-
var
|
|
1529
|
+
var AGENTSMESH_RULES = ".agentsmesh/rules";
|
|
1530
|
+
var AGENTSMESH_COMMANDS = ".agentsmesh/commands";
|
|
1531
1531
|
async function mapClineRuleFile(srcPath, destDir, normalizeTo) {
|
|
1532
1532
|
if (srcPath.includes("/workflows/")) return null;
|
|
1533
1533
|
const name = basename6(srcPath, ".md");
|
|
@@ -1545,7 +1545,7 @@ async function mapClineRuleFile(srcPath, destDir, normalizeTo) {
|
|
|
1545
1545
|
});
|
|
1546
1546
|
return {
|
|
1547
1547
|
destPath,
|
|
1548
|
-
toPath: `${
|
|
1548
|
+
toPath: `${AGENTSMESH_RULES}/${name}.md`,
|
|
1549
1549
|
feature: "rules",
|
|
1550
1550
|
content: await serializeImportedRuleWithFallback(destPath, canonicalFm, body)
|
|
1551
1551
|
};
|
|
@@ -1574,7 +1574,7 @@ async function mapClineWorkflowFile(srcPath, destDir, normalizeTo) {
|
|
|
1574
1574
|
}
|
|
1575
1575
|
return {
|
|
1576
1576
|
destPath,
|
|
1577
|
-
toPath: `${
|
|
1577
|
+
toPath: `${AGENTSMESH_COMMANDS}/${name}.md`,
|
|
1578
1578
|
feature: "commands",
|
|
1579
1579
|
content: await serializeImportedCommandWithFallback(
|
|
1580
1580
|
destPath,
|
|
@@ -1600,7 +1600,7 @@ var CLINE_HOOKS_DIR = ".clinerules/hooks";
|
|
|
1600
1600
|
|
|
1601
1601
|
// src/targets/cline/mcp-mapper.ts
|
|
1602
1602
|
import { join as join9 } from "path";
|
|
1603
|
-
var
|
|
1603
|
+
var AGENTSMESH_MCP = ".agentsmesh/mcp.json";
|
|
1604
1604
|
function mapClineServerToCanonical(raw) {
|
|
1605
1605
|
if (!raw || typeof raw !== "object") return null;
|
|
1606
1606
|
const obj = raw;
|
|
@@ -1640,15 +1640,15 @@ async function importClineMcp(projectRoot, results) {
|
|
|
1640
1640
|
if (server) mcpServers[n] = server;
|
|
1641
1641
|
}
|
|
1642
1642
|
if (Object.keys(mcpServers).length > 0) {
|
|
1643
|
-
await mkdirp(join9(projectRoot, ".
|
|
1643
|
+
await mkdirp(join9(projectRoot, ".agentsmesh"));
|
|
1644
1644
|
await writeFileAtomic(
|
|
1645
|
-
join9(projectRoot,
|
|
1645
|
+
join9(projectRoot, AGENTSMESH_MCP),
|
|
1646
1646
|
JSON.stringify({ mcpServers }, null, 2)
|
|
1647
1647
|
);
|
|
1648
1648
|
results.push({
|
|
1649
1649
|
fromTool: "cline",
|
|
1650
1650
|
fromPath: mcpPath,
|
|
1651
|
-
toPath:
|
|
1651
|
+
toPath: AGENTSMESH_MCP,
|
|
1652
1652
|
feature: "mcp"
|
|
1653
1653
|
});
|
|
1654
1654
|
}
|
|
@@ -1659,8 +1659,8 @@ async function importClineMcp(projectRoot, results) {
|
|
|
1659
1659
|
import { readdir as readdir2 } from "fs/promises";
|
|
1660
1660
|
import { join as join10 } from "path";
|
|
1661
1661
|
init_markdown();
|
|
1662
|
-
var
|
|
1663
|
-
var
|
|
1662
|
+
var AGENTSMESH_AGENTS = ".agentsmesh/agents";
|
|
1663
|
+
var AGENTSMESH_SKILLS = ".agentsmesh/skills";
|
|
1664
1664
|
async function importClineSkills(projectRoot, results, normalize) {
|
|
1665
1665
|
const skillsDir = join10(projectRoot, CLINE_SKILLS_DIR);
|
|
1666
1666
|
const skillDirs = [];
|
|
@@ -1683,7 +1683,7 @@ async function importClineSkills(projectRoot, results, normalize) {
|
|
|
1683
1683
|
const rawParsed = parseFrontmatter(content);
|
|
1684
1684
|
const projectedAgent = parseProjectedAgentSkillFrontmatter(rawParsed.frontmatter, name);
|
|
1685
1685
|
if (projectedAgent) {
|
|
1686
|
-
const destAgentsDir = join10(projectRoot,
|
|
1686
|
+
const destAgentsDir = join10(projectRoot, AGENTSMESH_AGENTS);
|
|
1687
1687
|
await mkdirp(destAgentsDir);
|
|
1688
1688
|
const agentPath = join10(destAgentsDir, `${projectedAgent.name}.md`);
|
|
1689
1689
|
await writeFileAtomic(
|
|
@@ -1693,15 +1693,15 @@ async function importClineSkills(projectRoot, results, normalize) {
|
|
|
1693
1693
|
results.push({
|
|
1694
1694
|
fromTool: "cline",
|
|
1695
1695
|
fromPath: skillMdPath,
|
|
1696
|
-
toPath: `${
|
|
1696
|
+
toPath: `${AGENTSMESH_AGENTS}/${projectedAgent.name}.md`,
|
|
1697
1697
|
feature: "agents"
|
|
1698
1698
|
});
|
|
1699
1699
|
continue;
|
|
1700
1700
|
}
|
|
1701
|
-
const destSkillPath = join10(projectRoot,
|
|
1701
|
+
const destSkillPath = join10(projectRoot, AGENTSMESH_SKILLS, name, "SKILL.md");
|
|
1702
1702
|
const normalized = normalize(content, skillMdPath, destSkillPath);
|
|
1703
1703
|
const { frontmatter, body } = parseFrontmatter(normalized);
|
|
1704
|
-
const destSkillDir = join10(projectRoot,
|
|
1704
|
+
const destSkillDir = join10(projectRoot, AGENTSMESH_SKILLS, name);
|
|
1705
1705
|
await mkdirp(destSkillDir);
|
|
1706
1706
|
const canonicalFm = {
|
|
1707
1707
|
description: typeof frontmatter.description === "string" ? frontmatter.description : void 0
|
|
@@ -1712,7 +1712,7 @@ async function importClineSkills(projectRoot, results, normalize) {
|
|
|
1712
1712
|
results.push({
|
|
1713
1713
|
fromTool: "cline",
|
|
1714
1714
|
fromPath: skillMdPath,
|
|
1715
|
-
toPath: `${
|
|
1715
|
+
toPath: `${AGENTSMESH_SKILLS}/${name}/SKILL.md`,
|
|
1716
1716
|
feature: "skills"
|
|
1717
1717
|
});
|
|
1718
1718
|
const allFiles = await readDirRecursive(skillPath);
|
|
@@ -1727,7 +1727,7 @@ async function importClineSkills(projectRoot, results, normalize) {
|
|
|
1727
1727
|
results.push({
|
|
1728
1728
|
fromTool: "cline",
|
|
1729
1729
|
fromPath: absPath,
|
|
1730
|
-
toPath: `${
|
|
1730
|
+
toPath: `${AGENTSMESH_SKILLS}/${name}/${relPath}`,
|
|
1731
1731
|
feature: "skills"
|
|
1732
1732
|
});
|
|
1733
1733
|
}
|
|
@@ -1735,13 +1735,13 @@ async function importClineSkills(projectRoot, results, normalize) {
|
|
|
1735
1735
|
}
|
|
1736
1736
|
|
|
1737
1737
|
// src/targets/cline/importer.ts
|
|
1738
|
-
var
|
|
1739
|
-
var
|
|
1740
|
-
var
|
|
1738
|
+
var AGENTSMESH_RULES2 = ".agentsmesh/rules";
|
|
1739
|
+
var AGENTSMESH_COMMANDS2 = ".agentsmesh/commands";
|
|
1740
|
+
var AGENTSMESH_IGNORE = ".agentsmesh/ignore";
|
|
1741
1741
|
async function importFromCline(projectRoot) {
|
|
1742
1742
|
const results = [];
|
|
1743
1743
|
const normalize = await createImportReferenceNormalizer("cline", projectRoot);
|
|
1744
|
-
const destRulesDir = join11(projectRoot,
|
|
1744
|
+
const destRulesDir = join11(projectRoot, AGENTSMESH_RULES2);
|
|
1745
1745
|
const clineRulesPath = join11(projectRoot, CLINE_RULES_DIR);
|
|
1746
1746
|
const clineRulesRaw = join11(projectRoot, CLINE_RULES_DIR);
|
|
1747
1747
|
let clineRulesIsFile = false;
|
|
@@ -1765,7 +1765,7 @@ async function importFromCline(projectRoot) {
|
|
|
1765
1765
|
results.push({
|
|
1766
1766
|
fromTool: "cline",
|
|
1767
1767
|
fromPath: clineRulesRaw,
|
|
1768
|
-
toPath: `${
|
|
1768
|
+
toPath: `${AGENTSMESH_RULES2}/_root.md`,
|
|
1769
1769
|
feature: "rules"
|
|
1770
1770
|
});
|
|
1771
1771
|
}
|
|
@@ -1790,7 +1790,7 @@ async function importFromCline(projectRoot) {
|
|
|
1790
1790
|
results.push({
|
|
1791
1791
|
fromTool: "cline",
|
|
1792
1792
|
fromPath: agentsMdPath,
|
|
1793
|
-
toPath: `${
|
|
1793
|
+
toPath: `${AGENTSMESH_RULES2}/_root.md`,
|
|
1794
1794
|
feature: "rules"
|
|
1795
1795
|
});
|
|
1796
1796
|
} else {
|
|
@@ -1811,7 +1811,7 @@ async function importFromCline(projectRoot) {
|
|
|
1811
1811
|
results.push({
|
|
1812
1812
|
fromTool: "cline",
|
|
1813
1813
|
fromPath: first,
|
|
1814
|
-
toPath: `${
|
|
1814
|
+
toPath: `${AGENTSMESH_RULES2}/_root.md`,
|
|
1815
1815
|
feature: "rules"
|
|
1816
1816
|
});
|
|
1817
1817
|
}
|
|
@@ -1829,7 +1829,7 @@ async function importFromCline(projectRoot) {
|
|
|
1829
1829
|
results.push({
|
|
1830
1830
|
fromTool: "cline",
|
|
1831
1831
|
fromPath: rootPath,
|
|
1832
|
-
toPath: `${
|
|
1832
|
+
toPath: `${AGENTSMESH_RULES2}/_root.md`,
|
|
1833
1833
|
feature: "rules"
|
|
1834
1834
|
});
|
|
1835
1835
|
}
|
|
@@ -1857,19 +1857,19 @@ async function importFromCline(projectRoot) {
|
|
|
1857
1857
|
if (t && !t.startsWith("#")) patterns.push(t);
|
|
1858
1858
|
}
|
|
1859
1859
|
if (patterns.length > 0) {
|
|
1860
|
-
await mkdirp(join11(projectRoot, ".
|
|
1861
|
-
const destIgnorePath = join11(projectRoot,
|
|
1860
|
+
await mkdirp(join11(projectRoot, ".agentsmesh"));
|
|
1861
|
+
const destIgnorePath = join11(projectRoot, AGENTSMESH_IGNORE);
|
|
1862
1862
|
await writeFileAtomic(destIgnorePath, patterns.join("\n"));
|
|
1863
1863
|
results.push({
|
|
1864
1864
|
fromTool: "cline",
|
|
1865
1865
|
fromPath: ignorePath,
|
|
1866
|
-
toPath:
|
|
1866
|
+
toPath: AGENTSMESH_IGNORE,
|
|
1867
1867
|
feature: "ignore"
|
|
1868
1868
|
});
|
|
1869
1869
|
}
|
|
1870
1870
|
}
|
|
1871
1871
|
await importClineMcp(projectRoot, results);
|
|
1872
|
-
const destCommandsDir = join11(projectRoot,
|
|
1872
|
+
const destCommandsDir = join11(projectRoot, AGENTSMESH_COMMANDS2);
|
|
1873
1873
|
if (!clineRulesIsFile) {
|
|
1874
1874
|
results.push(
|
|
1875
1875
|
...await importFileDirectory({
|
|
@@ -1893,9 +1893,9 @@ init_markdown();
|
|
|
1893
1893
|
// src/targets/cursor/importer-mappers.ts
|
|
1894
1894
|
init_markdown();
|
|
1895
1895
|
import { basename as basename7, join as join12 } from "path";
|
|
1896
|
-
var AB_RULES5 = ".
|
|
1897
|
-
var AB_COMMANDS5 = ".
|
|
1898
|
-
var AB_AGENTS5 = ".
|
|
1896
|
+
var AB_RULES5 = ".agentsmesh/rules";
|
|
1897
|
+
var AB_COMMANDS5 = ".agentsmesh/commands";
|
|
1898
|
+
var AB_AGENTS5 = ".agentsmesh/agents";
|
|
1899
1899
|
async function mapCursorRuleFile(srcPath, destDir, normalizeTo, onRootRule) {
|
|
1900
1900
|
const name = basename7(srcPath, ".mdc");
|
|
1901
1901
|
const destPath = join12(destDir, `${name}.md`);
|
|
@@ -1951,9 +1951,9 @@ var CURSOR_SETTINGS = ".cursor/settings.json";
|
|
|
1951
1951
|
var CURSOR_HOOKS = ".cursor/hooks.json";
|
|
1952
1952
|
var CURSORIGNORE = ".cursorignore";
|
|
1953
1953
|
var CURSORINDEXINGIGNORE = ".cursorindexingignore";
|
|
1954
|
-
var AB_PERMISSIONS2 = ".
|
|
1955
|
-
var AB_HOOKS2 = ".
|
|
1956
|
-
var AB_IGNORE2 = ".
|
|
1954
|
+
var AB_PERMISSIONS2 = ".agentsmesh/permissions.yaml";
|
|
1955
|
+
var AB_HOOKS2 = ".agentsmesh/hooks.yaml";
|
|
1956
|
+
var AB_IGNORE2 = ".agentsmesh/ignore";
|
|
1957
1957
|
function cursorHooksToCanonical(hooks) {
|
|
1958
1958
|
const result = {};
|
|
1959
1959
|
for (const [event, entries] of Object.entries(hooks)) {
|
|
@@ -2081,7 +2081,7 @@ async function importIgnore2(projectRoot, results) {
|
|
|
2081
2081
|
// src/targets/cursor/skills-helpers.ts
|
|
2082
2082
|
import { join as join14, basename as basename8, dirname as dirname8, relative as relative3 } from "path";
|
|
2083
2083
|
var CURSOR_SKILLS_DIR = ".cursor/skills";
|
|
2084
|
-
var AB_SKILLS3 = ".
|
|
2084
|
+
var AB_SKILLS3 = ".agentsmesh/skills";
|
|
2085
2085
|
async function importSkills2(projectRoot, results, normalize) {
|
|
2086
2086
|
const destBase = join14(projectRoot, AB_SKILLS3);
|
|
2087
2087
|
const skillsDir = join14(projectRoot, CURSOR_SKILLS_DIR);
|
|
@@ -2135,10 +2135,10 @@ var CURSOR_RULES_DIR = ".cursor/rules";
|
|
|
2135
2135
|
var CURSOR_COMMANDS_DIR = ".cursor/commands";
|
|
2136
2136
|
var CURSOR_AGENTS_DIR = ".cursor/agents";
|
|
2137
2137
|
var CURSOR_MCP = ".cursor/mcp.json";
|
|
2138
|
-
var AB_RULES6 = ".
|
|
2139
|
-
var AB_COMMANDS6 = ".
|
|
2140
|
-
var AB_AGENTS6 = ".
|
|
2141
|
-
var AB_MCP2 = ".
|
|
2138
|
+
var AB_RULES6 = ".agentsmesh/rules";
|
|
2139
|
+
var AB_COMMANDS6 = ".agentsmesh/commands";
|
|
2140
|
+
var AB_AGENTS6 = ".agentsmesh/agents";
|
|
2141
|
+
var AB_MCP2 = ".agentsmesh/mcp.json";
|
|
2142
2142
|
async function importFromCursor(projectRoot) {
|
|
2143
2143
|
const results = [];
|
|
2144
2144
|
const normalize = await createImportReferenceNormalizer("cursor", projectRoot);
|
|
@@ -2284,11 +2284,11 @@ init_markdown();
|
|
|
2284
2284
|
|
|
2285
2285
|
// src/targets/codex-cli/codex-rules-embed.ts
|
|
2286
2286
|
import { Buffer as Buffer2 } from "buffer";
|
|
2287
|
-
var MARKER = "
|
|
2288
|
-
var JSON_PREFIX = "#
|
|
2289
|
-
var B64_BEGIN = "#
|
|
2290
|
-
var B64_END = "#
|
|
2291
|
-
var B64_LINE = "#
|
|
2287
|
+
var MARKER = "am-codex-rule:v1";
|
|
2288
|
+
var JSON_PREFIX = "# am-json: ";
|
|
2289
|
+
var B64_BEGIN = "# am-body-b64-begin";
|
|
2290
|
+
var B64_END = "# am-body-b64-end";
|
|
2291
|
+
var B64_LINE = "# am64:";
|
|
2292
2292
|
function tryParseEmbeddedCanonicalFromCodexRules(content) {
|
|
2293
2293
|
if (!content.includes(MARKER)) return null;
|
|
2294
2294
|
const jsonLine = content.split("\n").find((l) => l.startsWith(JSON_PREFIX));
|
|
@@ -2329,7 +2329,7 @@ function tryParseEmbeddedCanonicalFromCodexRules(content) {
|
|
|
2329
2329
|
}
|
|
2330
2330
|
|
|
2331
2331
|
// src/targets/codex-cli/import-codex-non-root-rules.ts
|
|
2332
|
-
var AB_RULES7 = ".
|
|
2332
|
+
var AB_RULES7 = ".agentsmesh/rules";
|
|
2333
2333
|
async function importCodexNonRootRuleFiles(projectRoot, destDir, normalize) {
|
|
2334
2334
|
const results = [];
|
|
2335
2335
|
const codexRulesPath = join16(projectRoot, CODEX_RULES_DIR);
|
|
@@ -2400,7 +2400,7 @@ async function importCodexNonRootRuleFiles(projectRoot, destDir, normalize) {
|
|
|
2400
2400
|
// src/targets/codex-cli/mcp-helpers.ts
|
|
2401
2401
|
import { join as join17 } from "path";
|
|
2402
2402
|
import { parse as parseToml } from "smol-toml";
|
|
2403
|
-
var AB_MCP3 = ".
|
|
2403
|
+
var AB_MCP3 = ".agentsmesh/mcp.json";
|
|
2404
2404
|
function mapTomlServerToCanonical(raw) {
|
|
2405
2405
|
if (!raw || typeof raw !== "object" || Array.isArray(raw)) return null;
|
|
2406
2406
|
const obj = raw;
|
|
@@ -2440,7 +2440,7 @@ async function importMcp2(projectRoot, results) {
|
|
|
2440
2440
|
if (server) mcpServers[name] = server;
|
|
2441
2441
|
}
|
|
2442
2442
|
if (Object.keys(mcpServers).length === 0) return;
|
|
2443
|
-
await mkdirp(join17(projectRoot, ".
|
|
2443
|
+
await mkdirp(join17(projectRoot, ".agentsmesh"));
|
|
2444
2444
|
await writeFileAtomic(join17(projectRoot, AB_MCP3), JSON.stringify({ mcpServers }, null, 2));
|
|
2445
2445
|
results.push({
|
|
2446
2446
|
fromTool: "codex-cli",
|
|
@@ -2469,9 +2469,9 @@ async function removePathIfExists(path) {
|
|
|
2469
2469
|
}
|
|
2470
2470
|
|
|
2471
2471
|
// src/targets/codex-cli/skills-helpers.ts
|
|
2472
|
-
var AB_COMMANDS7 = ".
|
|
2473
|
-
var AB_AGENTS7 = ".
|
|
2474
|
-
var AB_SKILLS4 = ".
|
|
2472
|
+
var AB_COMMANDS7 = ".agentsmesh/commands";
|
|
2473
|
+
var AB_AGENTS7 = ".agentsmesh/agents";
|
|
2474
|
+
var AB_SKILLS4 = ".agentsmesh/skills";
|
|
2475
2475
|
async function importSkills3(projectRoot, results, normalize) {
|
|
2476
2476
|
for (const skillsRoot of [CODEX_SKILLS_DIR, CODEX_SKILLS_FALLBACK_DIR]) {
|
|
2477
2477
|
const skillsDir = join18(projectRoot, skillsRoot);
|
|
@@ -2569,7 +2569,7 @@ async function importSkills3(projectRoot, results, normalize) {
|
|
|
2569
2569
|
|
|
2570
2570
|
// src/targets/codex-cli/importer.ts
|
|
2571
2571
|
import { parse as parseToml2 } from "smol-toml";
|
|
2572
|
-
var AB_RULES8 = ".
|
|
2572
|
+
var AB_RULES8 = ".agentsmesh/rules";
|
|
2573
2573
|
async function importFromCodex(projectRoot) {
|
|
2574
2574
|
const results = [];
|
|
2575
2575
|
const normalize = await createImportReferenceNormalizer("codex-cli", projectRoot);
|
|
@@ -2582,7 +2582,7 @@ async function importFromCodex(projectRoot) {
|
|
|
2582
2582
|
}
|
|
2583
2583
|
async function importAgents3(projectRoot, results, normalize) {
|
|
2584
2584
|
const agentsPath = join19(projectRoot, CODEX_AGENTS_DIR);
|
|
2585
|
-
const agentsDestDir = join19(projectRoot, ".
|
|
2585
|
+
const agentsDestDir = join19(projectRoot, ".agentsmesh/agents");
|
|
2586
2586
|
try {
|
|
2587
2587
|
const agentFiles = await readDirRecursive(agentsPath);
|
|
2588
2588
|
const tomlFiles = agentFiles.filter((f) => f.endsWith(".toml"));
|
|
@@ -2619,7 +2619,7 @@ async function importAgents3(projectRoot, results, normalize) {
|
|
|
2619
2619
|
results.push({
|
|
2620
2620
|
fromTool: "codex-cli",
|
|
2621
2621
|
fromPath: srcPath,
|
|
2622
|
-
toPath: `.
|
|
2622
|
+
toPath: `.agentsmesh/agents/${name}.md`,
|
|
2623
2623
|
feature: "agents"
|
|
2624
2624
|
});
|
|
2625
2625
|
}
|
|
@@ -2710,9 +2710,9 @@ var WINDSURF_SKILLS_DIR = ".windsurf/skills";
|
|
|
2710
2710
|
import { join as join20, basename as basename11 } from "path";
|
|
2711
2711
|
import { readdir as readdir4 } from "fs/promises";
|
|
2712
2712
|
init_markdown();
|
|
2713
|
-
var
|
|
2714
|
-
var
|
|
2715
|
-
var
|
|
2713
|
+
var AGENTSMESH_COMMANDS3 = ".agentsmesh/commands";
|
|
2714
|
+
var AGENTSMESH_AGENTS2 = ".agentsmesh/agents";
|
|
2715
|
+
var AGENTSMESH_SKILLS2 = ".agentsmesh/skills";
|
|
2716
2716
|
function toStringArray5(value) {
|
|
2717
2717
|
if (Array.isArray(value)) {
|
|
2718
2718
|
return value.filter((entry) => typeof entry === "string").map((entry) => entry.trim()).filter(Boolean);
|
|
@@ -2726,7 +2726,7 @@ async function importWorkflows(projectRoot, results, normalize) {
|
|
|
2726
2726
|
const workflowsDir = join20(projectRoot, WINDSURF_WORKFLOWS_DIR);
|
|
2727
2727
|
const workflowFiles = await readDirRecursive(workflowsDir);
|
|
2728
2728
|
const workflowMdFiles = workflowFiles.filter((f) => f.endsWith(".md"));
|
|
2729
|
-
const destCommandsDir = join20(projectRoot,
|
|
2729
|
+
const destCommandsDir = join20(projectRoot, AGENTSMESH_COMMANDS3);
|
|
2730
2730
|
for (const srcPath of workflowMdFiles) {
|
|
2731
2731
|
const content = await readFileSafe(srcPath);
|
|
2732
2732
|
if (!content) continue;
|
|
@@ -2752,7 +2752,7 @@ async function importWorkflows(projectRoot, results, normalize) {
|
|
|
2752
2752
|
results.push({
|
|
2753
2753
|
fromTool: "windsurf",
|
|
2754
2754
|
fromPath: srcPath,
|
|
2755
|
-
toPath: `${
|
|
2755
|
+
toPath: `${AGENTSMESH_COMMANDS3}/${name}.md`,
|
|
2756
2756
|
feature: "commands"
|
|
2757
2757
|
});
|
|
2758
2758
|
}
|
|
@@ -2770,8 +2770,8 @@ async function importSkills4(projectRoot, results, normalize) {
|
|
|
2770
2770
|
const rawParsed = parseFrontmatter(skillContent);
|
|
2771
2771
|
const projectedAgent = parseProjectedAgentSkillFrontmatter(rawParsed.frontmatter, ent.name);
|
|
2772
2772
|
if (projectedAgent) {
|
|
2773
|
-
await removePathIfExists(join20(projectRoot,
|
|
2774
|
-
const destAgentsDir = join20(projectRoot,
|
|
2773
|
+
await removePathIfExists(join20(projectRoot, AGENTSMESH_SKILLS2, ent.name));
|
|
2774
|
+
const destAgentsDir = join20(projectRoot, AGENTSMESH_AGENTS2);
|
|
2775
2775
|
await mkdirp(destAgentsDir);
|
|
2776
2776
|
const agentPath = join20(destAgentsDir, `${projectedAgent.name}.md`);
|
|
2777
2777
|
await writeFileAtomic(
|
|
@@ -2781,12 +2781,12 @@ async function importSkills4(projectRoot, results, normalize) {
|
|
|
2781
2781
|
results.push({
|
|
2782
2782
|
fromTool: "windsurf",
|
|
2783
2783
|
fromPath: skillMdPath,
|
|
2784
|
-
toPath: `${
|
|
2784
|
+
toPath: `${AGENTSMESH_AGENTS2}/${projectedAgent.name}.md`,
|
|
2785
2785
|
feature: "agents"
|
|
2786
2786
|
});
|
|
2787
2787
|
continue;
|
|
2788
2788
|
}
|
|
2789
|
-
const destSkillDir = join20(projectRoot,
|
|
2789
|
+
const destSkillDir = join20(projectRoot, AGENTSMESH_SKILLS2, ent.name);
|
|
2790
2790
|
const destSkillPath = join20(destSkillDir, "SKILL.md");
|
|
2791
2791
|
const normalized = normalize(skillContent, skillMdPath, destSkillPath);
|
|
2792
2792
|
await mkdirp(destSkillDir);
|
|
@@ -2794,7 +2794,7 @@ async function importSkills4(projectRoot, results, normalize) {
|
|
|
2794
2794
|
results.push({
|
|
2795
2795
|
fromTool: "windsurf",
|
|
2796
2796
|
fromPath: skillMdPath,
|
|
2797
|
-
toPath: `${
|
|
2797
|
+
toPath: `${AGENTSMESH_SKILLS2}/${ent.name}/SKILL.md`,
|
|
2798
2798
|
feature: "skills"
|
|
2799
2799
|
});
|
|
2800
2800
|
const allSkillFiles = await readDirRecursive(skillPath);
|
|
@@ -2809,7 +2809,7 @@ async function importSkills4(projectRoot, results, normalize) {
|
|
|
2809
2809
|
results.push({
|
|
2810
2810
|
fromTool: "windsurf",
|
|
2811
2811
|
fromPath: absPath,
|
|
2812
|
-
toPath: `${
|
|
2812
|
+
toPath: `${AGENTSMESH_SKILLS2}/${ent.name}/${relPath}`,
|
|
2813
2813
|
feature: "skills"
|
|
2814
2814
|
});
|
|
2815
2815
|
}
|
|
@@ -2819,15 +2819,15 @@ async function importSkills4(projectRoot, results, normalize) {
|
|
|
2819
2819
|
}
|
|
2820
2820
|
|
|
2821
2821
|
// src/targets/windsurf/importer.ts
|
|
2822
|
-
var
|
|
2823
|
-
var
|
|
2824
|
-
var
|
|
2825
|
-
var
|
|
2822
|
+
var AGENTSMESH_RULES3 = ".agentsmesh/rules";
|
|
2823
|
+
var AGENTSMESH_IGNORE2 = ".agentsmesh/ignore";
|
|
2824
|
+
var AGENTSMESH_HOOKS = ".agentsmesh/hooks.yaml";
|
|
2825
|
+
var AGENTSMESH_MCP2 = ".agentsmesh/mcp.json";
|
|
2826
2826
|
async function importFromWindsurf(projectRoot) {
|
|
2827
2827
|
const results = [];
|
|
2828
2828
|
const normalize = await createImportReferenceNormalizer("windsurf", projectRoot);
|
|
2829
2829
|
const normalizeCodex = await createImportReferenceNormalizer("codex-cli", projectRoot);
|
|
2830
|
-
const destRulesDir = join21(projectRoot,
|
|
2830
|
+
const destRulesDir = join21(projectRoot, AGENTSMESH_RULES3);
|
|
2831
2831
|
const rootPath = join21(projectRoot, WINDSURF_RULES_ROOT);
|
|
2832
2832
|
const rootContent = await readFileSafe(rootPath);
|
|
2833
2833
|
if (rootContent !== null) {
|
|
@@ -2839,7 +2839,7 @@ async function importFromWindsurf(projectRoot) {
|
|
|
2839
2839
|
results.push({
|
|
2840
2840
|
fromTool: "windsurf",
|
|
2841
2841
|
fromPath: rootPath,
|
|
2842
|
-
toPath: `${
|
|
2842
|
+
toPath: `${AGENTSMESH_RULES3}/_root.md`,
|
|
2843
2843
|
feature: "rules"
|
|
2844
2844
|
});
|
|
2845
2845
|
}
|
|
@@ -2859,7 +2859,7 @@ async function importFromWindsurf(projectRoot) {
|
|
|
2859
2859
|
results.push({
|
|
2860
2860
|
fromTool: "windsurf",
|
|
2861
2861
|
fromPath: agentsMdPath,
|
|
2862
|
-
toPath: `${
|
|
2862
|
+
toPath: `${AGENTSMESH_RULES3}/_root.md`,
|
|
2863
2863
|
feature: "rules"
|
|
2864
2864
|
});
|
|
2865
2865
|
}
|
|
@@ -2882,7 +2882,7 @@ async function importFromWindsurf(projectRoot) {
|
|
|
2882
2882
|
const destPath = join21(destRulesDir, `${ruleName}.md`);
|
|
2883
2883
|
return {
|
|
2884
2884
|
destPath,
|
|
2885
|
-
toPath: `${
|
|
2885
|
+
toPath: `${AGENTSMESH_RULES3}/${ruleName}.md`,
|
|
2886
2886
|
feature: "rules",
|
|
2887
2887
|
content: await serializeImportedRuleWithFallback(
|
|
2888
2888
|
destPath,
|
|
@@ -2913,7 +2913,7 @@ async function importFromWindsurf(projectRoot) {
|
|
|
2913
2913
|
}
|
|
2914
2914
|
return {
|
|
2915
2915
|
destPath,
|
|
2916
|
-
toPath: `${
|
|
2916
|
+
toPath: `${AGENTSMESH_RULES3}/${name}.md`,
|
|
2917
2917
|
feature: "rules",
|
|
2918
2918
|
content: await serializeImportedRuleWithFallback(
|
|
2919
2919
|
destPath,
|
|
@@ -2938,13 +2938,13 @@ async function importFromWindsurf(projectRoot) {
|
|
|
2938
2938
|
if (t && !t.startsWith("#")) patterns.push(t);
|
|
2939
2939
|
}
|
|
2940
2940
|
if (patterns.length > 0) {
|
|
2941
|
-
await mkdirp(join21(projectRoot, ".
|
|
2942
|
-
const destIgnorePath = join21(projectRoot,
|
|
2941
|
+
await mkdirp(join21(projectRoot, ".agentsmesh"));
|
|
2942
|
+
const destIgnorePath = join21(projectRoot, AGENTSMESH_IGNORE2);
|
|
2943
2943
|
await writeFileAtomic(destIgnorePath, patterns.join("\n"));
|
|
2944
2944
|
results.push({
|
|
2945
2945
|
fromTool: "windsurf",
|
|
2946
2946
|
fromPath: ignorePath,
|
|
2947
|
-
toPath:
|
|
2947
|
+
toPath: AGENTSMESH_IGNORE2,
|
|
2948
2948
|
feature: "ignore"
|
|
2949
2949
|
});
|
|
2950
2950
|
}
|
|
@@ -2964,13 +2964,13 @@ async function importHooks(projectRoot, results) {
|
|
|
2964
2964
|
if (!parsed.hooks || typeof parsed.hooks !== "object" || Array.isArray(parsed.hooks)) return;
|
|
2965
2965
|
const canonical = windsurfHooksToCanonical(parsed.hooks);
|
|
2966
2966
|
if (Object.keys(canonical).length === 0) return;
|
|
2967
|
-
const destPath = join21(projectRoot,
|
|
2967
|
+
const destPath = join21(projectRoot, AGENTSMESH_HOOKS);
|
|
2968
2968
|
await mkdirp(dirname12(destPath));
|
|
2969
2969
|
await writeFileAtomic(destPath, yamlStringify4(canonical));
|
|
2970
2970
|
results.push({
|
|
2971
2971
|
fromTool: "windsurf",
|
|
2972
2972
|
fromPath: hooksPath,
|
|
2973
|
-
toPath:
|
|
2973
|
+
toPath: AGENTSMESH_HOOKS,
|
|
2974
2974
|
feature: "hooks"
|
|
2975
2975
|
});
|
|
2976
2976
|
} catch {
|
|
@@ -3033,13 +3033,13 @@ async function importMcp3(projectRoot, results) {
|
|
|
3033
3033
|
try {
|
|
3034
3034
|
const parsed = JSON.parse(content);
|
|
3035
3035
|
if (!parsed.mcpServers || typeof parsed.mcpServers !== "object") continue;
|
|
3036
|
-
const destPath = join21(projectRoot,
|
|
3036
|
+
const destPath = join21(projectRoot, AGENTSMESH_MCP2);
|
|
3037
3037
|
await mkdirp(dirname12(destPath));
|
|
3038
3038
|
await writeFileAtomic(destPath, JSON.stringify({ mcpServers: parsed.mcpServers }, null, 2));
|
|
3039
3039
|
results.push({
|
|
3040
3040
|
fromTool: "windsurf",
|
|
3041
3041
|
fromPath: srcPath,
|
|
3042
|
-
toPath:
|
|
3042
|
+
toPath: AGENTSMESH_MCP2,
|
|
3043
3043
|
feature: "mcp"
|
|
3044
3044
|
});
|
|
3045
3045
|
return;
|
|
@@ -3080,20 +3080,20 @@ function serializeCommandPrompt(command) {
|
|
|
3080
3080
|
const frontmatter = {
|
|
3081
3081
|
agent: "agent",
|
|
3082
3082
|
description: command.description || void 0,
|
|
3083
|
-
"x-
|
|
3084
|
-
"x-
|
|
3085
|
-
"x-
|
|
3083
|
+
"x-agentsmesh-kind": "command",
|
|
3084
|
+
"x-agentsmesh-name": command.name,
|
|
3085
|
+
"x-agentsmesh-allowed-tools": command.allowedTools.length > 0 ? command.allowedTools : void 0
|
|
3086
3086
|
};
|
|
3087
3087
|
if (frontmatter.description === void 0) delete frontmatter.description;
|
|
3088
|
-
if (frontmatter["x-
|
|
3089
|
-
delete frontmatter["x-
|
|
3088
|
+
if (frontmatter["x-agentsmesh-allowed-tools"] === void 0) {
|
|
3089
|
+
delete frontmatter["x-agentsmesh-allowed-tools"];
|
|
3090
3090
|
}
|
|
3091
3091
|
return serializeFrontmatter(frontmatter, command.body.trim() || "");
|
|
3092
3092
|
}
|
|
3093
3093
|
function parseCommandPromptFrontmatter(frontmatter, promptPath) {
|
|
3094
|
-
const nameFromMetadata = typeof frontmatter["x-
|
|
3094
|
+
const nameFromMetadata = typeof frontmatter["x-agentsmesh-name"] === "string" ? frontmatter["x-agentsmesh-name"] : "";
|
|
3095
3095
|
const name = (nameFromMetadata || basename13(promptPath, ".prompt.md")).trim();
|
|
3096
|
-
const allowedToolsFromMetadata = toStringArray6(frontmatter["x-
|
|
3096
|
+
const allowedToolsFromMetadata = toStringArray6(frontmatter["x-agentsmesh-allowed-tools"]);
|
|
3097
3097
|
const allowedTools = allowedToolsFromMetadata.length > 0 ? allowedToolsFromMetadata : toStringArray6(frontmatter.tools);
|
|
3098
3098
|
return {
|
|
3099
3099
|
name,
|
|
@@ -3114,7 +3114,7 @@ function serializeImportedCommand2(command, body) {
|
|
|
3114
3114
|
// src/targets/copilot/hook-parser.ts
|
|
3115
3115
|
import { join as join22, dirname as dirname13, basename as basename14 } from "path";
|
|
3116
3116
|
import { stringify as yamlStringify5 } from "yaml";
|
|
3117
|
-
var AB_HOOKS3 = ".
|
|
3117
|
+
var AB_HOOKS3 = ".agentsmesh/hooks.yaml";
|
|
3118
3118
|
function mapCopilotHookEvent(event) {
|
|
3119
3119
|
switch (event) {
|
|
3120
3120
|
case "preToolUse":
|
|
@@ -3135,7 +3135,7 @@ function extractMatcher(comment) {
|
|
|
3135
3135
|
return match?.[1]?.trim() || "*";
|
|
3136
3136
|
}
|
|
3137
3137
|
function extractWrapperCommand(content) {
|
|
3138
|
-
const metadataMatch = content.match(/^#
|
|
3138
|
+
const metadataMatch = content.match(/^# agentsmesh-command:\s*(.+)$/m);
|
|
3139
3139
|
if (metadataMatch?.[1]) return metadataMatch[1].trim();
|
|
3140
3140
|
return content.replace(/^#!.*\n/, "").replace(/^#.*\n/gm, "").replace(/^HOOK_DIR=.*\n/gm, "").replace(/^set -e\n?/m, "").trim();
|
|
3141
3141
|
}
|
|
@@ -3205,7 +3205,7 @@ async function importHooks2(projectRoot, results) {
|
|
|
3205
3205
|
// src/targets/copilot/agents-skills-helpers.ts
|
|
3206
3206
|
import { join as join23, basename as basename15, dirname as dirname14 } from "path";
|
|
3207
3207
|
init_markdown();
|
|
3208
|
-
var AB_AGENTS8 = ".
|
|
3208
|
+
var AB_AGENTS8 = ".agentsmesh/agents";
|
|
3209
3209
|
async function importAgents4(projectRoot, results, normalize) {
|
|
3210
3210
|
const agentsDir = join23(projectRoot, COPILOT_AGENTS_DIR);
|
|
3211
3211
|
let files;
|
|
@@ -3251,7 +3251,7 @@ async function importSkills5(projectRoot, results, normalize) {
|
|
|
3251
3251
|
const content = await readFileSafe(skillMdPath);
|
|
3252
3252
|
if (!content) continue;
|
|
3253
3253
|
const skillName = basename15(dirname14(skillMdPath));
|
|
3254
|
-
const destSkillDir = join23(projectRoot, ".
|
|
3254
|
+
const destSkillDir = join23(projectRoot, ".agentsmesh", "skills", skillName);
|
|
3255
3255
|
const allSkillFiles = await readDirRecursive(dirname14(skillMdPath));
|
|
3256
3256
|
for (const absPath of allSkillFiles) {
|
|
3257
3257
|
const fileContent = await readFileSafe(absPath);
|
|
@@ -3263,7 +3263,7 @@ async function importSkills5(projectRoot, results, normalize) {
|
|
|
3263
3263
|
results.push({
|
|
3264
3264
|
fromTool: "copilot",
|
|
3265
3265
|
fromPath: absPath,
|
|
3266
|
-
toPath: `.
|
|
3266
|
+
toPath: `.agentsmesh/skills/${skillName}/${relPath}`,
|
|
3267
3267
|
feature: "skills"
|
|
3268
3268
|
});
|
|
3269
3269
|
}
|
|
@@ -3271,12 +3271,12 @@ async function importSkills5(projectRoot, results, normalize) {
|
|
|
3271
3271
|
}
|
|
3272
3272
|
|
|
3273
3273
|
// src/targets/copilot/importer.ts
|
|
3274
|
-
var
|
|
3275
|
-
var AB_COMMANDS8 = ".
|
|
3274
|
+
var AGENTSMESH_RULES4 = ".agentsmesh/rules";
|
|
3275
|
+
var AB_COMMANDS8 = ".agentsmesh/commands";
|
|
3276
3276
|
async function importFromCopilot(projectRoot) {
|
|
3277
3277
|
const results = [];
|
|
3278
3278
|
const normalize = await createImportReferenceNormalizer("copilot", projectRoot);
|
|
3279
|
-
const destDir = join24(projectRoot,
|
|
3279
|
+
const destDir = join24(projectRoot, AGENTSMESH_RULES4);
|
|
3280
3280
|
const instructionsPath = join24(projectRoot, COPILOT_INSTRUCTIONS);
|
|
3281
3281
|
const instructionsContent = await readFileSafe(instructionsPath);
|
|
3282
3282
|
if (instructionsContent !== null) {
|
|
@@ -3292,7 +3292,7 @@ async function importFromCopilot(projectRoot) {
|
|
|
3292
3292
|
results.push({
|
|
3293
3293
|
fromTool: "copilot",
|
|
3294
3294
|
fromPath: instructionsPath,
|
|
3295
|
-
toPath: `${
|
|
3295
|
+
toPath: `${AGENTSMESH_RULES4}/_root.md`,
|
|
3296
3296
|
feature: "rules"
|
|
3297
3297
|
});
|
|
3298
3298
|
}
|
|
@@ -3319,7 +3319,7 @@ async function importFromCopilot(projectRoot) {
|
|
|
3319
3319
|
});
|
|
3320
3320
|
return {
|
|
3321
3321
|
destPath,
|
|
3322
|
-
toPath: `${
|
|
3322
|
+
toPath: `${AGENTSMESH_RULES4}/${destFileName}`,
|
|
3323
3323
|
feature: "rules",
|
|
3324
3324
|
content: await serializeImportedRuleWithFallback(destPath, canonicalFm, body)
|
|
3325
3325
|
};
|
|
@@ -3351,7 +3351,7 @@ async function importFromCopilot(projectRoot) {
|
|
|
3351
3351
|
});
|
|
3352
3352
|
return {
|
|
3353
3353
|
destPath,
|
|
3354
|
-
toPath: `${
|
|
3354
|
+
toPath: `${AGENTSMESH_RULES4}/${base}.md`,
|
|
3355
3355
|
feature: "rules",
|
|
3356
3356
|
content: await serializeImportedRuleWithFallback(destPath, canonicalFm, body)
|
|
3357
3357
|
};
|
|
@@ -3399,7 +3399,7 @@ init_markdown();
|
|
|
3399
3399
|
import { readdir as readdir5 } from "fs/promises";
|
|
3400
3400
|
import { dirname as dirname15, join as join25, relative as relative7 } from "path";
|
|
3401
3401
|
init_markdown();
|
|
3402
|
-
var AB_SKILLS5 = ".
|
|
3402
|
+
var AB_SKILLS5 = ".agentsmesh/skills";
|
|
3403
3403
|
function generateEmbeddedSkills(canonical, skillsDir) {
|
|
3404
3404
|
const outputs = [];
|
|
3405
3405
|
for (const skill of canonical.skills) {
|
|
@@ -3480,7 +3480,7 @@ import { basename as basename17 } from "path";
|
|
|
3480
3480
|
var CONTINUE_RULES_DIR = ".continue/rules";
|
|
3481
3481
|
var CONTINUE_PROMPTS_DIR = ".continue/prompts";
|
|
3482
3482
|
var CONTINUE_MCP_DIR = ".continue/mcpServers";
|
|
3483
|
-
var CONTINUE_MCP_FILE = `${CONTINUE_MCP_DIR}/
|
|
3483
|
+
var CONTINUE_MCP_FILE = `${CONTINUE_MCP_DIR}/agentsmesh.json`;
|
|
3484
3484
|
var CONTINUE_ROOT_RULE = `${CONTINUE_RULES_DIR}/_root.md`;
|
|
3485
3485
|
var CONTINUE_SKILLS_DIR = ".continue/skills";
|
|
3486
3486
|
|
|
@@ -3500,24 +3500,24 @@ function continueCommandRulePath(name) {
|
|
|
3500
3500
|
function serializeCommandRule(command) {
|
|
3501
3501
|
const frontmatter = {
|
|
3502
3502
|
description: command.description || void 0,
|
|
3503
|
-
"x-
|
|
3504
|
-
"x-
|
|
3505
|
-
"x-
|
|
3503
|
+
"x-agentsmesh-kind": "command",
|
|
3504
|
+
"x-agentsmesh-name": command.name,
|
|
3505
|
+
"x-agentsmesh-allowed-tools": command.allowedTools.length > 0 ? command.allowedTools : void 0
|
|
3506
3506
|
};
|
|
3507
3507
|
if (frontmatter.description === void 0) delete frontmatter.description;
|
|
3508
|
-
if (frontmatter["x-
|
|
3509
|
-
delete frontmatter["x-
|
|
3508
|
+
if (frontmatter["x-agentsmesh-allowed-tools"] === void 0) {
|
|
3509
|
+
delete frontmatter["x-agentsmesh-allowed-tools"];
|
|
3510
3510
|
}
|
|
3511
3511
|
return serializeFrontmatter(frontmatter, command.body.trim() || "");
|
|
3512
3512
|
}
|
|
3513
3513
|
function parseCommandRuleFrontmatter(frontmatter, filePath) {
|
|
3514
3514
|
const fileName = basename17(filePath, ".md");
|
|
3515
|
-
const fromMetadata = typeof frontmatter["x-
|
|
3515
|
+
const fromMetadata = typeof frontmatter["x-agentsmesh-name"] === "string" ? frontmatter["x-agentsmesh-name"] : "";
|
|
3516
3516
|
const name = (fromMetadata || fileName).trim();
|
|
3517
3517
|
return {
|
|
3518
3518
|
name,
|
|
3519
3519
|
description: typeof frontmatter.description === "string" ? frontmatter.description : "",
|
|
3520
|
-
allowedTools: toStringArray7(frontmatter["x-
|
|
3520
|
+
allowedTools: toStringArray7(frontmatter["x-agentsmesh-allowed-tools"])
|
|
3521
3521
|
};
|
|
3522
3522
|
}
|
|
3523
3523
|
function serializeImportedCommand3(command, body) {
|
|
@@ -3531,9 +3531,9 @@ function serializeImportedCommand3(command, body) {
|
|
|
3531
3531
|
}
|
|
3532
3532
|
|
|
3533
3533
|
// src/targets/continue/importer.ts
|
|
3534
|
-
var AB_RULES9 = ".
|
|
3535
|
-
var AB_COMMANDS9 = ".
|
|
3536
|
-
var AB_MCP4 = ".
|
|
3534
|
+
var AB_RULES9 = ".agentsmesh/rules";
|
|
3535
|
+
var AB_COMMANDS9 = ".agentsmesh/commands";
|
|
3536
|
+
var AB_MCP4 = ".agentsmesh/mcp.json";
|
|
3537
3537
|
function readMcpServers(content, extension) {
|
|
3538
3538
|
const parsed = extension === ".json" ? JSON.parse(content) : parseYaml(content) ?? {};
|
|
3539
3539
|
const rawServers = parsed.mcpServers;
|
|
@@ -3647,12 +3647,12 @@ async function importMcp4(projectRoot, results) {
|
|
|
3647
3647
|
// src/targets/junie/importer.ts
|
|
3648
3648
|
import { basename as basename19, join as join27 } from "path";
|
|
3649
3649
|
init_markdown();
|
|
3650
|
-
var AB_RULE = ".
|
|
3651
|
-
var AB_RULES_DIR = ".
|
|
3652
|
-
var AB_COMMANDS_DIR = ".
|
|
3653
|
-
var AB_AGENTS_DIR = ".
|
|
3654
|
-
var AB_MCP5 = ".
|
|
3655
|
-
var AB_IGNORE3 = ".
|
|
3650
|
+
var AB_RULE = ".agentsmesh/rules/_root.md";
|
|
3651
|
+
var AB_RULES_DIR = ".agentsmesh/rules";
|
|
3652
|
+
var AB_COMMANDS_DIR = ".agentsmesh/commands";
|
|
3653
|
+
var AB_AGENTS_DIR = ".agentsmesh/agents";
|
|
3654
|
+
var AB_MCP5 = ".agentsmesh/mcp.json";
|
|
3655
|
+
var AB_IGNORE3 = ".agentsmesh/ignore";
|
|
3656
3656
|
function readMcpServers2(content) {
|
|
3657
3657
|
const parsed = JSON.parse(content);
|
|
3658
3658
|
const rawServers = parsed.mcpServers;
|
|
@@ -3860,9 +3860,9 @@ var GEMINI_SYSTEM = ".gemini/system.md";
|
|
|
3860
3860
|
var GEMINI_DEFAULT_POLICIES_FILE = `${GEMINI_POLICIES_DIR}/permissions.toml`;
|
|
3861
3861
|
|
|
3862
3862
|
// src/targets/gemini-cli/format-helpers.ts
|
|
3863
|
-
var
|
|
3864
|
-
var
|
|
3865
|
-
var
|
|
3863
|
+
var AGENTSMESH_MCP3 = ".agentsmesh/mcp.json";
|
|
3864
|
+
var AGENTSMESH_HOOKS2 = ".agentsmesh/hooks.yaml";
|
|
3865
|
+
var AGENTSMESH_IGNORE3 = ".agentsmesh/ignore";
|
|
3866
3866
|
function mapGeminiHookEvent(event) {
|
|
3867
3867
|
switch (event) {
|
|
3868
3868
|
case "BeforeTool":
|
|
@@ -3912,25 +3912,25 @@ async function importGeminiSettings(projectRoot, results) {
|
|
|
3912
3912
|
if (!settings) return;
|
|
3913
3913
|
const mcpServers = settings.mcpServers;
|
|
3914
3914
|
if (mcpServers !== void 0 && typeof mcpServers === "object" && mcpServers !== null && Object.keys(mcpServers).length > 0) {
|
|
3915
|
-
const mcpPath = join28(projectRoot,
|
|
3916
|
-
await mkdirp(join28(projectRoot, ".
|
|
3915
|
+
const mcpPath = join28(projectRoot, AGENTSMESH_MCP3);
|
|
3916
|
+
await mkdirp(join28(projectRoot, ".agentsmesh"));
|
|
3917
3917
|
await writeFileAtomic(mcpPath, JSON.stringify({ mcpServers }, null, 2));
|
|
3918
3918
|
results.push({
|
|
3919
3919
|
fromTool: "gemini-cli",
|
|
3920
3920
|
fromPath: settingsPath,
|
|
3921
|
-
toPath:
|
|
3921
|
+
toPath: AGENTSMESH_MCP3,
|
|
3922
3922
|
feature: "mcp"
|
|
3923
3923
|
});
|
|
3924
3924
|
}
|
|
3925
3925
|
const ignorePatterns = settings.ignorePatterns;
|
|
3926
3926
|
if (Array.isArray(ignorePatterns) && ignorePatterns.length > 0 && ignorePatterns.every((p) => typeof p === "string")) {
|
|
3927
|
-
const ignorePath = join28(projectRoot,
|
|
3928
|
-
await mkdirp(join28(projectRoot, ".
|
|
3927
|
+
const ignorePath = join28(projectRoot, AGENTSMESH_IGNORE3);
|
|
3928
|
+
await mkdirp(join28(projectRoot, ".agentsmesh"));
|
|
3929
3929
|
await writeFileAtomic(ignorePath, ignorePatterns.join("\n") + "\n");
|
|
3930
3930
|
results.push({
|
|
3931
3931
|
fromTool: "gemini-cli",
|
|
3932
3932
|
fromPath: settingsPath,
|
|
3933
|
-
toPath:
|
|
3933
|
+
toPath: AGENTSMESH_IGNORE3,
|
|
3934
3934
|
feature: "ignore"
|
|
3935
3935
|
});
|
|
3936
3936
|
}
|
|
@@ -3967,13 +3967,13 @@ async function importGeminiSettings(projectRoot, results) {
|
|
|
3967
3967
|
);
|
|
3968
3968
|
if (mappedHooks.length > 0) {
|
|
3969
3969
|
const hooksYaml = Object.fromEntries(mappedHooks);
|
|
3970
|
-
const hooksPath = join28(projectRoot,
|
|
3971
|
-
await mkdirp(join28(projectRoot, ".
|
|
3970
|
+
const hooksPath = join28(projectRoot, AGENTSMESH_HOOKS2);
|
|
3971
|
+
await mkdirp(join28(projectRoot, ".agentsmesh"));
|
|
3972
3972
|
await writeFileAtomic(hooksPath, stringifyYaml(hooksYaml, { lineWidth: 0 }).trimEnd());
|
|
3973
3973
|
results.push({
|
|
3974
3974
|
fromTool: "gemini-cli",
|
|
3975
3975
|
fromPath: settingsPath,
|
|
3976
|
-
toPath:
|
|
3976
|
+
toPath: AGENTSMESH_HOOKS2,
|
|
3977
3977
|
feature: "hooks"
|
|
3978
3978
|
});
|
|
3979
3979
|
}
|
|
@@ -3985,13 +3985,13 @@ async function importGeminiIgnore(projectRoot, results) {
|
|
|
3985
3985
|
if (geminiIgnoreContent !== null && geminiIgnoreContent.trim()) {
|
|
3986
3986
|
const patterns = geminiIgnoreContent.split(/\r?\n/).map((line) => line.trim()).filter((line) => line && !line.startsWith("#"));
|
|
3987
3987
|
if (patterns.length > 0) {
|
|
3988
|
-
await mkdirp(join28(projectRoot, ".
|
|
3989
|
-
const ignorePath = join28(projectRoot,
|
|
3988
|
+
await mkdirp(join28(projectRoot, ".agentsmesh"));
|
|
3989
|
+
const ignorePath = join28(projectRoot, AGENTSMESH_IGNORE3);
|
|
3990
3990
|
await writeFileAtomic(ignorePath, patterns.join("\n") + "\n");
|
|
3991
3991
|
results.push({
|
|
3992
3992
|
fromTool: "gemini-cli",
|
|
3993
3993
|
fromPath: geminiIgnorePath,
|
|
3994
|
-
toPath:
|
|
3994
|
+
toPath: AGENTSMESH_IGNORE3,
|
|
3995
3995
|
feature: "ignore"
|
|
3996
3996
|
});
|
|
3997
3997
|
}
|
|
@@ -3999,8 +3999,8 @@ async function importGeminiIgnore(projectRoot, results) {
|
|
|
3999
3999
|
}
|
|
4000
4000
|
|
|
4001
4001
|
// src/targets/gemini-cli/importer-mappers.ts
|
|
4002
|
-
var
|
|
4003
|
-
var
|
|
4002
|
+
var AGENTSMESH_RULES5 = ".agentsmesh/rules";
|
|
4003
|
+
var AGENTSMESH_COMMANDS4 = ".agentsmesh/commands";
|
|
4004
4004
|
async function mapGeminiRuleFile(srcPath, destDir, normalizeTo) {
|
|
4005
4005
|
const destFileName = `${basename20(srcPath, ".md")}.md`;
|
|
4006
4006
|
const destPath = join29(destDir, destFileName);
|
|
@@ -4016,7 +4016,7 @@ async function mapGeminiRuleFile(srcPath, destDir, normalizeTo) {
|
|
|
4016
4016
|
});
|
|
4017
4017
|
return {
|
|
4018
4018
|
destPath,
|
|
4019
|
-
toPath: `${
|
|
4019
|
+
toPath: `${AGENTSMESH_RULES5}/${destFileName}`,
|
|
4020
4020
|
feature: "rules",
|
|
4021
4021
|
content: await serializeImportedRuleWithFallback(destPath, canonicalFm, body)
|
|
4022
4022
|
};
|
|
@@ -4033,7 +4033,7 @@ async function mapGeminiCommandFile(srcPath, destDir, normalizeTo, geminiCommand
|
|
|
4033
4033
|
const allowedTools = fromCamel.length > 0 ? fromCamel : fromKebab;
|
|
4034
4034
|
return {
|
|
4035
4035
|
destPath,
|
|
4036
|
-
toPath: `${
|
|
4036
|
+
toPath: `${AGENTSMESH_COMMANDS4}/${name}.md`,
|
|
4037
4037
|
feature: "commands",
|
|
4038
4038
|
content: await serializeImportedCommandWithFallback(
|
|
4039
4039
|
destPath,
|
|
@@ -4063,7 +4063,7 @@ function parseTomlCommand(normalized) {
|
|
|
4063
4063
|
import { parse as parseToml5 } from "smol-toml";
|
|
4064
4064
|
import { stringify as stringifyYaml2 } from "yaml";
|
|
4065
4065
|
import { join as join30 } from "path";
|
|
4066
|
-
var AB_PERMISSIONS3 = ".
|
|
4066
|
+
var AB_PERMISSIONS3 = ".agentsmesh/permissions.yaml";
|
|
4067
4067
|
function unescapeRegexLiteral(value) {
|
|
4068
4068
|
return value.replace(/\\(.)/g, "$1");
|
|
4069
4069
|
}
|
|
@@ -4152,7 +4152,7 @@ async function importGeminiPolicies(projectRoot) {
|
|
|
4152
4152
|
}
|
|
4153
4153
|
}
|
|
4154
4154
|
if (allow.length === 0 && deny.length === 0) return results;
|
|
4155
|
-
await mkdirp(join30(projectRoot, ".
|
|
4155
|
+
await mkdirp(join30(projectRoot, ".agentsmesh"));
|
|
4156
4156
|
const outPath = join30(projectRoot, AB_PERMISSIONS3);
|
|
4157
4157
|
const yaml = stringifyYaml2({ allow, deny });
|
|
4158
4158
|
await writeFileAtomic(outPath, yaml.trimEnd() + "\n");
|
|
@@ -4166,15 +4166,15 @@ async function importGeminiPolicies(projectRoot) {
|
|
|
4166
4166
|
}
|
|
4167
4167
|
|
|
4168
4168
|
// src/targets/gemini-cli/importer.ts
|
|
4169
|
-
var
|
|
4170
|
-
var
|
|
4171
|
-
var
|
|
4172
|
-
var
|
|
4169
|
+
var AGENTSMESH_RULES6 = ".agentsmesh/rules";
|
|
4170
|
+
var AGENTSMESH_COMMANDS5 = ".agentsmesh/commands";
|
|
4171
|
+
var AGENTSMESH_AGENTS3 = ".agentsmesh/agents";
|
|
4172
|
+
var AGENTSMESH_SKILLS3 = ".agentsmesh/skills";
|
|
4173
4173
|
async function importFromGemini(projectRoot) {
|
|
4174
4174
|
const results = [];
|
|
4175
4175
|
const normalize = await createImportReferenceNormalizer("gemini-cli", projectRoot);
|
|
4176
|
-
const rulesDir = join31(projectRoot,
|
|
4177
|
-
const commandsDir = join31(projectRoot,
|
|
4176
|
+
const rulesDir = join31(projectRoot, AGENTSMESH_RULES6);
|
|
4177
|
+
const commandsDir = join31(projectRoot, AGENTSMESH_COMMANDS5);
|
|
4178
4178
|
const geminiRootPath = join31(projectRoot, GEMINI_ROOT);
|
|
4179
4179
|
const compatAgentsRootPath = join31(projectRoot, GEMINI_COMPAT_AGENTS);
|
|
4180
4180
|
const compatInnerRootPath = join31(projectRoot, GEMINI_COMPAT_INNER_ROOT);
|
|
@@ -4204,7 +4204,7 @@ async function importFromGemini(projectRoot) {
|
|
|
4204
4204
|
results.push({
|
|
4205
4205
|
fromTool: "gemini-cli",
|
|
4206
4206
|
fromPath: rootSourcePath,
|
|
4207
|
-
toPath: `${
|
|
4207
|
+
toPath: `${AGENTSMESH_RULES6}/_root.md`,
|
|
4208
4208
|
feature: "rules"
|
|
4209
4209
|
});
|
|
4210
4210
|
}
|
|
@@ -4240,7 +4240,7 @@ async function importFromGemini(projectRoot) {
|
|
|
4240
4240
|
const rawParsed = parseFrontmatter(content);
|
|
4241
4241
|
const projectedAgent = parseProjectedAgentSkillFrontmatter(rawParsed.frontmatter, skillName);
|
|
4242
4242
|
if (projectedAgent) {
|
|
4243
|
-
const agentsDir = join31(projectRoot,
|
|
4243
|
+
const agentsDir = join31(projectRoot, AGENTSMESH_AGENTS3);
|
|
4244
4244
|
await mkdirp(agentsDir);
|
|
4245
4245
|
const agentPath = join31(agentsDir, `${projectedAgent.name}.md`);
|
|
4246
4246
|
await writeFileAtomic(
|
|
@@ -4250,20 +4250,20 @@ async function importFromGemini(projectRoot) {
|
|
|
4250
4250
|
results.push({
|
|
4251
4251
|
fromTool: "gemini-cli",
|
|
4252
4252
|
fromPath: srcPath,
|
|
4253
|
-
toPath: `${
|
|
4253
|
+
toPath: `${AGENTSMESH_AGENTS3}/${projectedAgent.name}.md`,
|
|
4254
4254
|
feature: "agents"
|
|
4255
4255
|
});
|
|
4256
4256
|
continue;
|
|
4257
4257
|
}
|
|
4258
|
-
const destPath = join31(projectRoot,
|
|
4258
|
+
const destPath = join31(projectRoot, AGENTSMESH_SKILLS3, skillName, "SKILL.md");
|
|
4259
4259
|
const normalized = normalize(content, srcPath, destPath);
|
|
4260
|
-
const skillDir = join31(projectRoot,
|
|
4260
|
+
const skillDir = join31(projectRoot, AGENTSMESH_SKILLS3, skillName);
|
|
4261
4261
|
await mkdirp(skillDir);
|
|
4262
4262
|
await writeFileAtomic(destPath, normalized);
|
|
4263
4263
|
results.push({
|
|
4264
4264
|
fromTool: "gemini-cli",
|
|
4265
4265
|
fromPath: srcPath,
|
|
4266
|
-
toPath: `${
|
|
4266
|
+
toPath: `${AGENTSMESH_SKILLS3}/${skillName}/SKILL.md`,
|
|
4267
4267
|
feature: "skills"
|
|
4268
4268
|
});
|
|
4269
4269
|
const allSkillFiles = await readDirRecursive(dirname16(srcPath));
|
|
@@ -4278,7 +4278,7 @@ async function importFromGemini(projectRoot) {
|
|
|
4278
4278
|
results.push({
|
|
4279
4279
|
fromTool: "gemini-cli",
|
|
4280
4280
|
fromPath: absPath,
|
|
4281
|
-
toPath: `${
|
|
4281
|
+
toPath: `${AGENTSMESH_SKILLS3}/${skillName}/${relPath}`,
|
|
4282
4282
|
feature: "skills"
|
|
4283
4283
|
});
|
|
4284
4284
|
}
|
|
@@ -4293,7 +4293,7 @@ async function importFromGemini(projectRoot) {
|
|
|
4293
4293
|
if (!content) continue;
|
|
4294
4294
|
const { frontmatter, body } = parseFrontmatter(content);
|
|
4295
4295
|
const name = typeof frontmatter.name === "string" ? frontmatter.name : basename21(srcPath, ".md");
|
|
4296
|
-
const agentsDir = join31(projectRoot,
|
|
4296
|
+
const agentsDir = join31(projectRoot, AGENTSMESH_AGENTS3);
|
|
4297
4297
|
await mkdirp(agentsDir);
|
|
4298
4298
|
const destPath = join31(agentsDir, `${name}.md`);
|
|
4299
4299
|
const normalizedBody = normalize(body, srcPath, destPath);
|
|
@@ -4312,7 +4312,7 @@ async function importFromGemini(projectRoot) {
|
|
|
4312
4312
|
results.push({
|
|
4313
4313
|
fromTool: "gemini-cli",
|
|
4314
4314
|
fromPath: srcPath,
|
|
4315
|
-
toPath: `${
|
|
4315
|
+
toPath: `${AGENTSMESH_AGENTS3}/${name}.md`,
|
|
4316
4316
|
feature: "agents"
|
|
4317
4317
|
});
|
|
4318
4318
|
}
|
|
@@ -4551,7 +4551,7 @@ function lintRules9(canonical, projectRoot, _projectFiles) {
|
|
|
4551
4551
|
if (unsupported.length > 0) {
|
|
4552
4552
|
diags.push({
|
|
4553
4553
|
level: "warning",
|
|
4554
|
-
file: ".
|
|
4554
|
+
file: ".agentsmesh",
|
|
4555
4555
|
target: TARGET9,
|
|
4556
4556
|
message: `Windsurf cannot project these features yet: ${unsupported.join(", ")}.`
|
|
4557
4557
|
});
|
|
@@ -4740,7 +4740,7 @@ var extendSourceSchema = z.object({
|
|
|
4740
4740
|
version: z.string().optional(),
|
|
4741
4741
|
target: targetSchema.optional(),
|
|
4742
4742
|
features: z.array(featureSchema),
|
|
4743
|
-
/** Repo-relative POSIX path for discovery (skill packs, nested .
|
|
4743
|
+
/** Repo-relative POSIX path for discovery (skill packs, nested .agentsmesh). */
|
|
4744
4744
|
path: z.string().optional(),
|
|
4745
4745
|
pick: extendPickSchema.optional()
|
|
4746
4746
|
});
|
|
@@ -4770,8 +4770,8 @@ var configSchema = z.object({
|
|
|
4770
4770
|
});
|
|
4771
4771
|
|
|
4772
4772
|
// src/config/loader.ts
|
|
4773
|
-
var CONFIG_FILENAME = "
|
|
4774
|
-
var LOCAL_CONFIG_FILENAME = "
|
|
4773
|
+
var CONFIG_FILENAME = "agentsmesh.yaml";
|
|
4774
|
+
var LOCAL_CONFIG_FILENAME = "agentsmesh.local.yaml";
|
|
4775
4775
|
async function findConfigPath(startDir) {
|
|
4776
4776
|
let dir = resolve2(startDir);
|
|
4777
4777
|
while (true) {
|
|
@@ -4790,7 +4790,7 @@ async function loadConfig(configPath) {
|
|
|
4790
4790
|
const content = await readFileSafe(configPath);
|
|
4791
4791
|
if (content === null) {
|
|
4792
4792
|
throw new Error(
|
|
4793
|
-
`Config file not found: ${configPath}. Create
|
|
4793
|
+
`Config file not found: ${configPath}. Create agentsmesh.yaml in project root.`
|
|
4794
4794
|
);
|
|
4795
4795
|
}
|
|
4796
4796
|
const raw = parseYaml2(content);
|
|
@@ -4848,7 +4848,7 @@ async function loadConfigFromDir(startDir) {
|
|
|
4848
4848
|
const configPath = await findConfigPath(startDir);
|
|
4849
4849
|
if (configPath === null) {
|
|
4850
4850
|
throw new Error(
|
|
4851
|
-
`No
|
|
4851
|
+
`No agentsmesh.yaml found from ${startDir}. Run 'agentsmesh init' to create one.`
|
|
4852
4852
|
);
|
|
4853
4853
|
}
|
|
4854
4854
|
const configDir = dirname17(configPath);
|
|
@@ -4865,7 +4865,7 @@ async function loadConfigFromDir(startDir) {
|
|
|
4865
4865
|
} else {
|
|
4866
4866
|
const issues = parsed.error.issues.map((i) => i.message).join("; ");
|
|
4867
4867
|
logger.warn(
|
|
4868
|
-
`Ignoring invalid
|
|
4868
|
+
`Ignoring invalid agentsmesh.local.yaml at ${localPath}: ${issues}. Using project config instead.`
|
|
4869
4869
|
);
|
|
4870
4870
|
}
|
|
4871
4871
|
}
|
|
@@ -4917,7 +4917,7 @@ async function fetchGitRemoteExtend(parsed, extendName, options, cacheDir, build
|
|
|
4917
4917
|
const allowFallback = options.allowOfflineFallback !== false;
|
|
4918
4918
|
if (allowFallback && await hasCachedRepo(cacheRepoDir)) {
|
|
4919
4919
|
console.warn(
|
|
4920
|
-
`[
|
|
4920
|
+
`[agentsmesh] Remote fetch failed for ${extendName}; using cached version. Error: ${err instanceof Error ? err.message : String(err)}`
|
|
4921
4921
|
);
|
|
4922
4922
|
return readCachedRepo(cacheRepoDir);
|
|
4923
4923
|
}
|
|
@@ -4935,7 +4935,7 @@ async function hasCachedRepo(repoDir) {
|
|
|
4935
4935
|
}
|
|
4936
4936
|
function resolveCloneUrl(parsed) {
|
|
4937
4937
|
if ("cloneUrl" in parsed) {
|
|
4938
|
-
const token = process.env.
|
|
4938
|
+
const token = process.env.AGENTSMESH_GITLAB_TOKEN;
|
|
4939
4939
|
if (token) {
|
|
4940
4940
|
const url = new URL(parsed.cloneUrl);
|
|
4941
4941
|
if (url.protocol === "https:") {
|
|
@@ -4992,7 +4992,7 @@ async function resolveLatestTag(org, repo, token) {
|
|
|
4992
4992
|
return data.tag_name;
|
|
4993
4993
|
}
|
|
4994
4994
|
async function fetchGithubRemoteExtend(parsed, extendName, options, cacheDir, buildCacheKey2, allowDefaultBranchFallback = false) {
|
|
4995
|
-
const token = options.token ?? process.env.
|
|
4995
|
+
const token = options.token ?? process.env.AGENTSMESH_GITHUB_TOKEN;
|
|
4996
4996
|
const refresh = options.refresh === true;
|
|
4997
4997
|
let tag = parsed.tag;
|
|
4998
4998
|
if (tag === "latest") {
|
|
@@ -5023,7 +5023,7 @@ async function fetchGithubRemoteExtend(parsed, extendName, options, cacheDir, bu
|
|
|
5023
5023
|
const topDir2 = await findExtractTopDir(extractDir);
|
|
5024
5024
|
if (topDir2) {
|
|
5025
5025
|
console.warn(
|
|
5026
|
-
`[
|
|
5026
|
+
`[agentsmesh] Network failed for ${extendName}; using cached version. Error: ${err instanceof Error ? err.message : String(err)}`
|
|
5027
5027
|
);
|
|
5028
5028
|
return { resolvedPath: join34(extractDir, topDir2), version: tag };
|
|
5029
5029
|
}
|
|
@@ -5178,7 +5178,7 @@ async function cleanInstallCache(source, cacheDir) {
|
|
|
5178
5178
|
}
|
|
5179
5179
|
async function sweepStaleCache(cacheDir, maxAgeMs) {
|
|
5180
5180
|
const dir = cacheDir ?? getCacheDir();
|
|
5181
|
-
const threshold = maxAgeMs ?? Number(process.env.
|
|
5181
|
+
const threshold = maxAgeMs ?? Number(process.env.AGENTSMESH_CACHE_MAX_AGE_DAYS ?? 30) * 864e5;
|
|
5182
5182
|
let entries;
|
|
5183
5183
|
try {
|
|
5184
5184
|
entries = await readdir7(dir);
|
|
@@ -5210,9 +5210,9 @@ function buildCacheKey(provider, identifier, ref) {
|
|
|
5210
5210
|
return `${safe(provider)}_${safe(identifier)}_${safe(ref)}`;
|
|
5211
5211
|
}
|
|
5212
5212
|
function getCacheDir() {
|
|
5213
|
-
const env = process.env.
|
|
5213
|
+
const env = process.env.AGENTSMESH_CACHE;
|
|
5214
5214
|
if (env) return env;
|
|
5215
|
-
return join36(homedir(), ".
|
|
5215
|
+
return join36(homedir(), ".agentsmesh", "cache");
|
|
5216
5216
|
}
|
|
5217
5217
|
async function fetchRemoteExtend(source, extendName, options = {}) {
|
|
5218
5218
|
const parsed = parseRemoteSource(source);
|
|
@@ -5285,7 +5285,7 @@ async function resolveExtendPaths(config, configDir, options = {}) {
|
|
|
5285
5285
|
const resolvedPath = resolve3(configDir, ext.source);
|
|
5286
5286
|
if (!await exists(resolvedPath)) {
|
|
5287
5287
|
throw new Error(
|
|
5288
|
-
`Extend "${ext.name}": path does not exist: ${resolvedPath}. Check extends.source in
|
|
5288
|
+
`Extend "${ext.name}": path does not exist: ${resolvedPath}. Check extends.source in agentsmesh.yaml.`
|
|
5289
5289
|
);
|
|
5290
5290
|
}
|
|
5291
5291
|
result.push({
|
|
@@ -5455,6 +5455,10 @@ async function readContent(path) {
|
|
|
5455
5455
|
return c2 ?? "";
|
|
5456
5456
|
}
|
|
5457
5457
|
var SKILL_FILE = "SKILL.md";
|
|
5458
|
+
var EXCLUDED_DIR_PREFIXES = [".git", "node_modules"];
|
|
5459
|
+
function sanitizeSkillName(raw) {
|
|
5460
|
+
return raw.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
5461
|
+
}
|
|
5458
5462
|
async function listSupportingFiles(skillDir) {
|
|
5459
5463
|
const files = await readDirRecursive(skillDir);
|
|
5460
5464
|
const result = [];
|
|
@@ -5462,6 +5466,9 @@ async function listSupportingFiles(skillDir) {
|
|
|
5462
5466
|
const raw = absPath.slice(skillDir.length + 1);
|
|
5463
5467
|
const name = raw.replace(/\\/g, "/");
|
|
5464
5468
|
if (name === SKILL_FILE || name.endsWith(`/${SKILL_FILE}`)) continue;
|
|
5469
|
+
const firstSegment = name.split("/")[0];
|
|
5470
|
+
if (EXCLUDED_DIR_PREFIXES.some((p) => firstSegment === p)) continue;
|
|
5471
|
+
if (name === ".DS_Store" || name.endsWith("/.DS_Store")) continue;
|
|
5465
5472
|
const content = await readContent(absPath);
|
|
5466
5473
|
result.push({ relativePath: name, absolutePath: absPath, content });
|
|
5467
5474
|
}
|
|
@@ -5473,9 +5480,10 @@ async function parseSkillDirectory(skillDir) {
|
|
|
5473
5480
|
if (!content) return null;
|
|
5474
5481
|
const { frontmatter, body } = parseFrontmatter(content);
|
|
5475
5482
|
const supportingFiles = await listSupportingFiles(skillDir);
|
|
5483
|
+
const fmName = typeof frontmatter.name === "string" ? sanitizeSkillName(frontmatter.name) : "";
|
|
5476
5484
|
return {
|
|
5477
5485
|
source: skillPath,
|
|
5478
|
-
name: basename25(skillDir),
|
|
5486
|
+
name: fmName || basename25(skillDir),
|
|
5479
5487
|
description: typeof frontmatter.description === "string" ? frontmatter.description : "",
|
|
5480
5488
|
body,
|
|
5481
5489
|
supportingFiles
|
|
@@ -5648,7 +5656,7 @@ async function parseIgnore(ignorePath) {
|
|
|
5648
5656
|
|
|
5649
5657
|
// src/canonical/loader.ts
|
|
5650
5658
|
async function loadCanonicalFiles(projectRoot) {
|
|
5651
|
-
const abDir = join38(projectRoot, ".
|
|
5659
|
+
const abDir = join38(projectRoot, ".agentsmesh");
|
|
5652
5660
|
const [rules, commands, agents, skills, mcp, permissions, hooks, ignore] = await Promise.all([
|
|
5653
5661
|
parseRules(join38(abDir, "rules")),
|
|
5654
5662
|
parseCommands(join38(abDir, "commands")),
|
|
@@ -5973,7 +5981,7 @@ async function loadSkillsForPartialSlice(sliceRoot) {
|
|
|
5973
5981
|
return [];
|
|
5974
5982
|
}
|
|
5975
5983
|
async function loadCanonicalSliceAtPath(sliceRoot) {
|
|
5976
|
-
const ab = join41(sliceRoot, ".
|
|
5984
|
+
const ab = join41(sliceRoot, ".agentsmesh");
|
|
5977
5985
|
if (await exists(ab)) {
|
|
5978
5986
|
return loadCanonicalFiles(sliceRoot);
|
|
5979
5987
|
}
|
|
@@ -5984,7 +5992,7 @@ async function loadCanonicalSliceAtPath(sliceRoot) {
|
|
|
5984
5992
|
partial.skills = await loadSkillsForPartialSlice(sliceRoot);
|
|
5985
5993
|
if (isCanonicalSliceEmpty(partial)) {
|
|
5986
5994
|
throw new Error(
|
|
5987
|
-
`No installable resources at ${sliceRoot}. Expected .
|
|
5995
|
+
`No installable resources at ${sliceRoot}. Expected .agentsmesh/, or rules/, commands/, agents/, or Anthropic-style skills (SKILL.md).`
|
|
5988
5996
|
);
|
|
5989
5997
|
}
|
|
5990
5998
|
return partial;
|
|
@@ -6006,8 +6014,8 @@ function emptyCanonical2() {
|
|
|
6006
6014
|
async function loadCanonicalForExtend(ext) {
|
|
6007
6015
|
const base = ext.resolvedPath;
|
|
6008
6016
|
if (!ext.path) {
|
|
6009
|
-
const
|
|
6010
|
-
if (!await exists(
|
|
6017
|
+
const agentsmeshDir = join42(base, ".agentsmesh");
|
|
6018
|
+
if (!await exists(agentsmeshDir)) {
|
|
6011
6019
|
if (await isSkillPackLayout(base)) {
|
|
6012
6020
|
const skills = await loadSkillsAtExtendPath(base);
|
|
6013
6021
|
return { ...emptyCanonical2(), skills };
|
|
@@ -6016,11 +6024,11 @@ async function loadCanonicalForExtend(ext) {
|
|
|
6016
6024
|
if (!targetName) {
|
|
6017
6025
|
throw new Error(
|
|
6018
6026
|
`Extend "${ext.name}": No supported agent configuration found in ${base}.
|
|
6019
|
-
Expected one of: .
|
|
6027
|
+
Expected one of: .agentsmesh/, ${KNOWN_NATIVE_PATHS.join(", ")}.`
|
|
6020
6028
|
);
|
|
6021
6029
|
}
|
|
6022
6030
|
logger.info(
|
|
6023
|
-
`[
|
|
6031
|
+
`[agentsmesh] Extend "${ext.name}": ${ext.target ? "specified" : "detected"} ${targetName} format, importing to .agentsmesh/...`
|
|
6024
6032
|
);
|
|
6025
6033
|
await importNativeToCanonical(base, targetName);
|
|
6026
6034
|
}
|
|
@@ -6031,10 +6039,10 @@ Expected one of: .agentsbridge/, ${KNOWN_NATIVE_PATHS.join(", ")}.`
|
|
|
6031
6039
|
throw new Error(`Extend "${ext.name}": path does not exist: ${rawRoot}`);
|
|
6032
6040
|
}
|
|
6033
6041
|
if (ext.target) {
|
|
6034
|
-
const
|
|
6035
|
-
if (!await exists(
|
|
6042
|
+
const agentsmeshDir = join42(base, ".agentsmesh");
|
|
6043
|
+
if (!await exists(agentsmeshDir)) {
|
|
6036
6044
|
logger.info(
|
|
6037
|
-
`[
|
|
6045
|
+
`[agentsmesh] Extend "${ext.name}": path "${ext.path}" with target "${ext.target}" \u2014 importing at extend root, then loading canonical.`
|
|
6038
6046
|
);
|
|
6039
6047
|
await importNativeToCanonical(base, ext.target);
|
|
6040
6048
|
}
|
|
@@ -6063,7 +6071,7 @@ function applyExtendPick(canonical, features, pick, extendName) {
|
|
|
6063
6071
|
for (const n of pick.skills) {
|
|
6064
6072
|
if (!prev.some((s) => s.name === n)) {
|
|
6065
6073
|
logger.warn(
|
|
6066
|
-
`[
|
|
6074
|
+
`[agentsmesh] pick name "${n}" not found in skills from extend "${extendName}".`
|
|
6067
6075
|
);
|
|
6068
6076
|
}
|
|
6069
6077
|
}
|
|
@@ -6075,7 +6083,7 @@ function applyExtendPick(canonical, features, pick, extendName) {
|
|
|
6075
6083
|
for (const n of pick.commands) {
|
|
6076
6084
|
if (!prev.some((c2) => c2.name === n)) {
|
|
6077
6085
|
logger.warn(
|
|
6078
|
-
`[
|
|
6086
|
+
`[agentsmesh] pick name "${n}" not found in commands from extend "${extendName}".`
|
|
6079
6087
|
);
|
|
6080
6088
|
}
|
|
6081
6089
|
}
|
|
@@ -6087,7 +6095,7 @@ function applyExtendPick(canonical, features, pick, extendName) {
|
|
|
6087
6095
|
for (const n of pick.agents) {
|
|
6088
6096
|
if (!prev.some((a) => a.name === n)) {
|
|
6089
6097
|
logger.warn(
|
|
6090
|
-
`[
|
|
6098
|
+
`[agentsmesh] pick name "${n}" not found in agents from extend "${extendName}".`
|
|
6091
6099
|
);
|
|
6092
6100
|
}
|
|
6093
6101
|
}
|
|
@@ -6103,7 +6111,7 @@ function applyExtendPick(canonical, features, pick, extendName) {
|
|
|
6103
6111
|
for (const n of pick.rules) {
|
|
6104
6112
|
if (!prev.some((r) => stem(r.source) === n)) {
|
|
6105
6113
|
logger.warn(
|
|
6106
|
-
`[
|
|
6114
|
+
`[agentsmesh] pick name "${n}" not found in rules from extend "${extendName}".`
|
|
6107
6115
|
);
|
|
6108
6116
|
}
|
|
6109
6117
|
}
|
|
@@ -6300,7 +6308,7 @@ async function loadCanonicalWithExtends(config, configDir, options = {}) {
|
|
|
6300
6308
|
const picked = applyExtendPick(filtered, ext.features, ext.pick, ext.name);
|
|
6301
6309
|
merged = mergeCanonicalFiles(merged, picked);
|
|
6302
6310
|
}
|
|
6303
|
-
const packsCanonical = await loadPacksCanonical(join45(configDir, ".
|
|
6311
|
+
const packsCanonical = await loadPacksCanonical(join45(configDir, ".agentsmesh"));
|
|
6304
6312
|
merged = mergeCanonicalFiles(merged, packsCanonical);
|
|
6305
6313
|
const localCanonical = await loadCanonicalFiles(configDir);
|
|
6306
6314
|
merged = mergeCanonicalFiles(merged, localCanonical);
|
|
@@ -6429,7 +6437,7 @@ async function buildExtendChecksums(resolvedExtends) {
|
|
|
6429
6437
|
result[ext.name] = ext.version;
|
|
6430
6438
|
continue;
|
|
6431
6439
|
}
|
|
6432
|
-
const abDir = join46(ext.resolvedPath, ".
|
|
6440
|
+
const abDir = join46(ext.resolvedPath, ".agentsmesh");
|
|
6433
6441
|
const checksums = await buildChecksums(abDir);
|
|
6434
6442
|
const fingerprint = Object.keys(checksums).sort().map((p) => `${p}:${checksums[p]}`).join("\n");
|
|
6435
6443
|
const h = hashContent(fingerprint);
|
|
@@ -6871,7 +6879,7 @@ function generateHooks3(canonical) {
|
|
|
6871
6879
|
if (Object.keys(hooks).length === 0) return [];
|
|
6872
6880
|
return [
|
|
6873
6881
|
{
|
|
6874
|
-
path: `${COPILOT_HOOKS_DIR}/
|
|
6882
|
+
path: `${COPILOT_HOOKS_DIR}/agentsmesh.json`,
|
|
6875
6883
|
content: JSON.stringify({ version: 1, hooks }, null, 2)
|
|
6876
6884
|
}
|
|
6877
6885
|
];
|
|
@@ -7079,7 +7087,7 @@ function generateRules6(canonical) {
|
|
|
7079
7087
|
const content = nonEmpty.join("\n\n---\n\n");
|
|
7080
7088
|
const outputs = [{ path: GEMINI_ROOT, content }];
|
|
7081
7089
|
if (root) {
|
|
7082
|
-
const compatAgentsContent = root.body.trim().replace(/\.
|
|
7090
|
+
const compatAgentsContent = root.body.trim().replace(/\.agentsmesh\/skills\//g, ".agents/skills/");
|
|
7083
7091
|
outputs.push({ path: GEMINI_COMPAT_AGENTS, content: compatAgentsContent });
|
|
7084
7092
|
}
|
|
7085
7093
|
return outputs;
|
|
@@ -7331,8 +7339,8 @@ function safeEventName(event) {
|
|
|
7331
7339
|
function buildHookScript(command, matcher) {
|
|
7332
7340
|
return [
|
|
7333
7341
|
"#!/usr/bin/env bash",
|
|
7334
|
-
`#
|
|
7335
|
-
`#
|
|
7342
|
+
`# agentsmesh-matcher: ${matcher}`,
|
|
7343
|
+
`# agentsmesh-command: ${command}`,
|
|
7336
7344
|
"set -e",
|
|
7337
7345
|
command,
|
|
7338
7346
|
""
|
|
@@ -7467,7 +7475,7 @@ function toSafeCodexRulesContent(body) {
|
|
|
7467
7475
|
if (looksLikeCodexRulesDsl(trimmed)) return `${trimmed}
|
|
7468
7476
|
`;
|
|
7469
7477
|
const lines = [
|
|
7470
|
-
"#
|
|
7478
|
+
"# agentsmesh: canonical execution rule body is not Codex DSL",
|
|
7471
7479
|
"# The original body is preserved below as comments.",
|
|
7472
7480
|
"# Replace with Codex rules DSL (for example prefix_rule(...)) to enforce behavior.",
|
|
7473
7481
|
"#",
|
|
@@ -7777,7 +7785,7 @@ function addDirectoryMapping2(refs, from, to) {
|
|
|
7777
7785
|
function addSkillDirectoryMappings(refs, canonicalPath, targetPath) {
|
|
7778
7786
|
let fromDir = posix2.dirname(canonicalPath);
|
|
7779
7787
|
let toDir = posix2.dirname(targetPath);
|
|
7780
|
-
while (fromDir !== ".
|
|
7788
|
+
while (fromDir !== ".agentsmesh/skills" && fromDir !== ".") {
|
|
7781
7789
|
addDirectoryMapping2(refs, fromDir, toDir);
|
|
7782
7790
|
fromDir = posix2.dirname(fromDir);
|
|
7783
7791
|
toDir = posix2.dirname(toDir);
|
|
@@ -7897,24 +7905,24 @@ function buildReferenceMap(target10, canonical, config) {
|
|
|
7897
7905
|
const refs = /* @__PURE__ */ new Map();
|
|
7898
7906
|
for (const rule of canonical.rules) {
|
|
7899
7907
|
const path = ruleTargetPath(target10, rule);
|
|
7900
|
-
if (path) refs.set(`.
|
|
7908
|
+
if (path) refs.set(`.agentsmesh/rules/${basename36(rule.source)}`, path);
|
|
7901
7909
|
}
|
|
7902
7910
|
for (const command of canonical.commands) {
|
|
7903
7911
|
const path = commandTargetPath(target10, command.name, config);
|
|
7904
|
-
if (path) refs.set(`.
|
|
7912
|
+
if (path) refs.set(`.agentsmesh/commands/${command.name}.md`, path);
|
|
7905
7913
|
}
|
|
7906
7914
|
for (const agent of canonical.agents) {
|
|
7907
7915
|
const path = agentTargetPath(target10, agent.name, config);
|
|
7908
|
-
if (path) refs.set(`.
|
|
7916
|
+
if (path) refs.set(`.agentsmesh/agents/${agent.name}.md`, path);
|
|
7909
7917
|
}
|
|
7910
7918
|
const skillDir = SKILL_DIRS[target10];
|
|
7911
7919
|
if (!skillDir) return refs;
|
|
7912
7920
|
for (const skill of canonical.skills) {
|
|
7913
|
-
addDirectoryMapping3(refs, `.
|
|
7914
|
-
refs.set(`.
|
|
7921
|
+
addDirectoryMapping3(refs, `.agentsmesh/skills/${skill.name}`, `${skillDir}/${skill.name}`);
|
|
7922
|
+
refs.set(`.agentsmesh/skills/${skill.name}/SKILL.md`, `${skillDir}/${skill.name}/SKILL.md`);
|
|
7915
7923
|
for (const file of skill.supportingFiles) {
|
|
7916
7924
|
const relativePath = file.relativePath.replace(/\\/g, "/");
|
|
7917
|
-
const canonicalPath = `.
|
|
7925
|
+
const canonicalPath = `.agentsmesh/skills/${skill.name}/${relativePath}`;
|
|
7918
7926
|
const targetPath = `${skillDir}/${skill.name}/${relativePath}`;
|
|
7919
7927
|
refs.set(canonicalPath, targetPath);
|
|
7920
7928
|
addSkillDirectoryMappings(refs, canonicalPath, targetPath);
|
|
@@ -7976,21 +7984,21 @@ function preferEquivalentCodexAgents(results, canonical, config) {
|
|
|
7976
7984
|
|
|
7977
7985
|
// src/core/reference-rewriter.ts
|
|
7978
7986
|
import { existsSync as existsSync3 } from "fs";
|
|
7979
|
-
import { dirname as
|
|
7987
|
+
import { dirname as dirname20, join as join48 } from "path";
|
|
7980
7988
|
|
|
7981
7989
|
// src/core/output-source-map.ts
|
|
7982
|
-
import { join as join47, normalize as normalizePath2 } from "path";
|
|
7990
|
+
import { dirname as dirname19, join as join47, normalize as normalizePath2 } from "path";
|
|
7983
7991
|
function canonicalRulePath(rule) {
|
|
7984
|
-
return `.
|
|
7992
|
+
return `.agentsmesh/rules/${rule.source.split("/").pop()}`;
|
|
7985
7993
|
}
|
|
7986
7994
|
function canonicalCommandPath(command) {
|
|
7987
|
-
return `.
|
|
7995
|
+
return `.agentsmesh/commands/${command.name}.md`;
|
|
7988
7996
|
}
|
|
7989
7997
|
function canonicalAgentPath(agent) {
|
|
7990
|
-
return `.
|
|
7998
|
+
return `.agentsmesh/agents/${agent.name}.md`;
|
|
7991
7999
|
}
|
|
7992
8000
|
function canonicalSkillPath(skill) {
|
|
7993
|
-
return `.
|
|
8001
|
+
return `.agentsmesh/skills/${skill.name}/SKILL.md`;
|
|
7994
8002
|
}
|
|
7995
8003
|
function directoryScopedRuleDir2(globs) {
|
|
7996
8004
|
if (globs.length === 0) return null;
|
|
@@ -8025,6 +8033,22 @@ function ruleOutputPaths(target10, rule, refs) {
|
|
|
8025
8033
|
}
|
|
8026
8034
|
return paths;
|
|
8027
8035
|
}
|
|
8036
|
+
function addPackSkillPaths(refs, target10, canonical, projectRoot) {
|
|
8037
|
+
const skillDir = SKILL_DIRS[target10];
|
|
8038
|
+
if (!skillDir) return;
|
|
8039
|
+
const packsPrefix = join47(projectRoot, ".agentsmesh", "packs");
|
|
8040
|
+
for (const skill of canonical.skills) {
|
|
8041
|
+
const skillSourceDir = dirname19(skill.source);
|
|
8042
|
+
if (!skillSourceDir.startsWith(packsPrefix)) continue;
|
|
8043
|
+
const targetSkillDir = normalizePath2(join47(projectRoot, skillDir, skill.name));
|
|
8044
|
+
refs.set(normalizePath2(skillSourceDir), targetSkillDir);
|
|
8045
|
+
refs.set(normalizePath2(skill.source), normalizePath2(join47(targetSkillDir, "SKILL.md")));
|
|
8046
|
+
for (const file of skill.supportingFiles) {
|
|
8047
|
+
const targetFilePath = normalizePath2(join47(targetSkillDir, file.relativePath));
|
|
8048
|
+
refs.set(normalizePath2(file.absolutePath), targetFilePath);
|
|
8049
|
+
}
|
|
8050
|
+
}
|
|
8051
|
+
}
|
|
8028
8052
|
function buildArtifactPathMap(target10, canonical, config, projectRoot, destinationPath) {
|
|
8029
8053
|
const refs = new Map(
|
|
8030
8054
|
[...buildReferenceMap(target10, canonical, config)].map(([canonicalPath, targetPath]) => [
|
|
@@ -8041,6 +8065,7 @@ function buildArtifactPathMap(target10, canonical, config, projectRoot, destinat
|
|
|
8041
8065
|
);
|
|
8042
8066
|
}
|
|
8043
8067
|
}
|
|
8068
|
+
addPackSkillPaths(refs, target10, canonical, projectRoot);
|
|
8044
8069
|
return refs;
|
|
8045
8070
|
}
|
|
8046
8071
|
function buildOutputSourceMap(target10, canonical, config) {
|
|
@@ -8063,7 +8088,7 @@ function buildOutputSourceMap(target10, canonical, config) {
|
|
|
8063
8088
|
const skillTargetPath = refs.get(canonicalSkillPath(skill));
|
|
8064
8089
|
if (skillTargetPath) sourceMap.set(skillTargetPath, skill.source);
|
|
8065
8090
|
for (const file of skill.supportingFiles) {
|
|
8066
|
-
const canonicalPath = `.
|
|
8091
|
+
const canonicalPath = `.agentsmesh/skills/${skill.name}/${file.relativePath.replace(/\\/g, "/")}`;
|
|
8067
8092
|
const targetPath = refs.get(canonicalPath);
|
|
8068
8093
|
if (targetPath) sourceMap.set(targetPath, file.absolutePath);
|
|
8069
8094
|
}
|
|
@@ -8077,11 +8102,11 @@ function collectPlannedPaths(projectRoot, results) {
|
|
|
8077
8102
|
for (const result of results) {
|
|
8078
8103
|
const absolutePath = join48(projectRoot, result.path);
|
|
8079
8104
|
planned.add(absolutePath);
|
|
8080
|
-
let current =
|
|
8105
|
+
let current = dirname20(absolutePath);
|
|
8081
8106
|
while (current.startsWith(projectRoot) && !planned.has(current)) {
|
|
8082
8107
|
planned.add(current);
|
|
8083
8108
|
if (current === projectRoot) break;
|
|
8084
|
-
current =
|
|
8109
|
+
current = dirname20(current);
|
|
8085
8110
|
}
|
|
8086
8111
|
}
|
|
8087
8112
|
return planned;
|
|
@@ -8241,8 +8266,8 @@ function wrapperPath(event, index) {
|
|
|
8241
8266
|
function buildWrapper(command, matcher) {
|
|
8242
8267
|
return [
|
|
8243
8268
|
"#!/usr/bin/env bash",
|
|
8244
|
-
`#
|
|
8245
|
-
`#
|
|
8269
|
+
`# agentsmesh-matcher: ${matcher}`,
|
|
8270
|
+
`# agentsmesh-command: ${command}`,
|
|
8246
8271
|
"set -e",
|
|
8247
8272
|
command,
|
|
8248
8273
|
""
|
|
@@ -8614,11 +8639,11 @@ function formatVerboseDetails(canonical) {
|
|
|
8614
8639
|
if (count > 0) lines.push(`hooks: ${count} entries in hooks.yaml`);
|
|
8615
8640
|
}
|
|
8616
8641
|
if (canonical.ignore.length > 0) {
|
|
8617
|
-
lines.push("ignore: .
|
|
8642
|
+
lines.push("ignore: .agentsmesh/ignore");
|
|
8618
8643
|
}
|
|
8619
8644
|
if (canonical.permissions) {
|
|
8620
8645
|
const total = canonical.permissions.allow.length + canonical.permissions.deny.length;
|
|
8621
|
-
if (total > 0) lines.push("permissions: .
|
|
8646
|
+
if (total > 0) lines.push("permissions: .agentsmesh/permissions.yaml");
|
|
8622
8647
|
}
|
|
8623
8648
|
if (lines.length === 0) return "";
|
|
8624
8649
|
return "\nPer-file details:\n" + lines.join("\n") + "\n";
|
|
@@ -8634,7 +8659,7 @@ async function runMatrix(flags, projectRoot) {
|
|
|
8634
8659
|
const targets = targetFilter ?? config.targets;
|
|
8635
8660
|
const rows = buildCompatibilityMatrix(config, canonical);
|
|
8636
8661
|
if (rows.length === 0) {
|
|
8637
|
-
logger.info("No features enabled. Enable features in
|
|
8662
|
+
logger.info("No features enabled. Enable features in agentsmesh.yaml.");
|
|
8638
8663
|
return;
|
|
8639
8664
|
}
|
|
8640
8665
|
const table = formatMatrix(rows, targets);
|
|
@@ -8658,7 +8683,7 @@ function ensurePathInsideRoot(rootDir, relativePath, target10) {
|
|
|
8658
8683
|
}
|
|
8659
8684
|
async function runGenerate(flags, projectRoot, options = {}) {
|
|
8660
8685
|
if (flags.features !== void 0) {
|
|
8661
|
-
throw new Error("--features is no longer supported. Configure features in
|
|
8686
|
+
throw new Error("--features is no longer supported. Configure features in agentsmesh.yaml.");
|
|
8662
8687
|
}
|
|
8663
8688
|
const root = projectRoot ?? process.cwd();
|
|
8664
8689
|
const checkOnly = flags.check === true;
|
|
@@ -8670,7 +8695,7 @@ async function runGenerate(flags, projectRoot, options = {}) {
|
|
|
8670
8695
|
const { config, configDir } = await loadConfigFromDir(root);
|
|
8671
8696
|
const lockFeatures = config.collaboration?.lock_features ?? [];
|
|
8672
8697
|
if (config.collaboration?.strategy === "lock" && !force && lockFeatures.length > 0) {
|
|
8673
|
-
const abDir = join52(configDir, ".
|
|
8698
|
+
const abDir = join52(configDir, ".agentsmesh");
|
|
8674
8699
|
const existingLock = await readLock(abDir);
|
|
8675
8700
|
if (existingLock !== null) {
|
|
8676
8701
|
const currentChecksums = await buildChecksums(abDir);
|
|
@@ -8684,7 +8709,7 @@ async function runGenerate(flags, projectRoot, options = {}) {
|
|
|
8684
8709
|
for (const violation of violations) {
|
|
8685
8710
|
logger.error(` ${violation}`);
|
|
8686
8711
|
}
|
|
8687
|
-
logger.error("Run '
|
|
8712
|
+
logger.error("Run 'agentsmesh generate --force' to accept these changes.");
|
|
8688
8713
|
throw new Error("Locked feature violation. Use --force to override.");
|
|
8689
8714
|
}
|
|
8690
8715
|
}
|
|
@@ -8705,7 +8730,7 @@ async function runGenerate(flags, projectRoot, options = {}) {
|
|
|
8705
8730
|
return 0;
|
|
8706
8731
|
}
|
|
8707
8732
|
if (!dryRun) {
|
|
8708
|
-
const abDir = join52(configDir, ".
|
|
8733
|
+
const abDir = join52(configDir, ".agentsmesh");
|
|
8709
8734
|
const checksums = await buildChecksums(abDir);
|
|
8710
8735
|
const extendChecksums = resolvedExtends.length > 0 ? await buildExtendChecksums(resolvedExtends) : {};
|
|
8711
8736
|
const packChecksums = await buildPackChecksums(join52(abDir, "packs"));
|
|
@@ -8719,10 +8744,10 @@ async function runGenerate(flags, projectRoot, options = {}) {
|
|
|
8719
8744
|
packs: packChecksums
|
|
8720
8745
|
});
|
|
8721
8746
|
try {
|
|
8722
|
-
await ensureCacheSymlink(getCacheDir(), join52(configDir, ".
|
|
8747
|
+
await ensureCacheSymlink(getCacheDir(), join52(configDir, ".agentsmeshcache"));
|
|
8723
8748
|
} catch (err) {
|
|
8724
8749
|
logger.warn(
|
|
8725
|
-
`Could not create .
|
|
8750
|
+
`Could not create .agentsmeshcache symlink: ${err instanceof Error ? err.message : String(err)}`
|
|
8726
8751
|
);
|
|
8727
8752
|
}
|
|
8728
8753
|
}
|
|
@@ -8740,7 +8765,7 @@ async function runGenerate(flags, projectRoot, options = {}) {
|
|
|
8740
8765
|
for (const r of drifted) {
|
|
8741
8766
|
logger.error(`[check] ${r.status} ${r.path} (${r.target})`);
|
|
8742
8767
|
}
|
|
8743
|
-
logger.error("Generated files are out of sync. Run '
|
|
8768
|
+
logger.error("Generated files are out of sync. Run 'agentsmesh generate' to update them.");
|
|
8744
8769
|
return 1;
|
|
8745
8770
|
}
|
|
8746
8771
|
for (const r of results) {
|
|
@@ -8761,7 +8786,7 @@ async function runGenerate(flags, projectRoot, options = {}) {
|
|
|
8761
8786
|
} else {
|
|
8762
8787
|
logger.info(`Nothing changed. (${unchanged} unchanged)`);
|
|
8763
8788
|
}
|
|
8764
|
-
const abDir = join52(configDir, ".
|
|
8789
|
+
const abDir = join52(configDir, ".agentsmesh");
|
|
8765
8790
|
const checksums = await buildChecksums(abDir);
|
|
8766
8791
|
const extendChecksums = resolvedExtends.length > 0 ? await buildExtendChecksums(resolvedExtends) : {};
|
|
8767
8792
|
const packChecksums = await buildPackChecksums(join52(abDir, "packs"));
|
|
@@ -8775,10 +8800,10 @@ async function runGenerate(flags, projectRoot, options = {}) {
|
|
|
8775
8800
|
packs: packChecksums
|
|
8776
8801
|
});
|
|
8777
8802
|
try {
|
|
8778
|
-
await ensureCacheSymlink(getCacheDir(), join52(configDir, ".
|
|
8803
|
+
await ensureCacheSymlink(getCacheDir(), join52(configDir, ".agentsmeshcache"));
|
|
8779
8804
|
} catch (err) {
|
|
8780
8805
|
logger.warn(
|
|
8781
|
-
`Could not create .
|
|
8806
|
+
`Could not create .agentsmeshcache symlink: ${err instanceof Error ? err.message : String(err)}`
|
|
8782
8807
|
);
|
|
8783
8808
|
}
|
|
8784
8809
|
}
|
|
@@ -8992,9 +9017,9 @@ async function detectExistingConfigs(projectRoot) {
|
|
|
8992
9017
|
}
|
|
8993
9018
|
|
|
8994
9019
|
// src/cli/commands/init.ts
|
|
8995
|
-
var CONFIG_FILENAME2 = "
|
|
8996
|
-
var LOCAL_CONFIG_FILENAME2 = "
|
|
8997
|
-
var GITIGNORE_ENTRIES = ["
|
|
9020
|
+
var CONFIG_FILENAME2 = "agentsmesh.yaml";
|
|
9021
|
+
var LOCAL_CONFIG_FILENAME2 = "agentsmesh.local.yaml";
|
|
9022
|
+
var GITIGNORE_ENTRIES = ["agentsmesh.local.yaml", ".agentsmeshcache"];
|
|
8998
9023
|
var IMPORTERS = {
|
|
8999
9024
|
"claude-code": importFromClaudeCode,
|
|
9000
9025
|
cursor: importFromCursor,
|
|
@@ -9016,29 +9041,29 @@ async function appendToGitignore(projectRoot) {
|
|
|
9016
9041
|
await writeFileAtomic(gitignorePath, current + suffix + toAdd.join("\n") + "\n");
|
|
9017
9042
|
}
|
|
9018
9043
|
async function writeScaffold(projectRoot) {
|
|
9019
|
-
const ab = (rel2) => join54(projectRoot, ".
|
|
9044
|
+
const ab = (rel2) => join54(projectRoot, ".agentsmesh", rel2);
|
|
9020
9045
|
await mkdirp(ab("rules"));
|
|
9021
9046
|
await writeFileAtomic(ab("rules/_root.md"), TEMPLATE_ROOT_RULE);
|
|
9022
|
-
logger.success("Created .
|
|
9047
|
+
logger.success("Created .agentsmesh/rules/_root.md");
|
|
9023
9048
|
await writeFileAtomic(ab("rules/example.md"), TEMPLATE_EXAMPLE_RULE);
|
|
9024
|
-
logger.success("Created .
|
|
9049
|
+
logger.success("Created .agentsmesh/rules/example.md");
|
|
9025
9050
|
await mkdirp(ab("commands"));
|
|
9026
9051
|
await writeFileAtomic(ab("commands/example.md"), TEMPLATE_EXAMPLE_COMMAND);
|
|
9027
|
-
logger.success("Created .
|
|
9052
|
+
logger.success("Created .agentsmesh/commands/example.md");
|
|
9028
9053
|
await mkdirp(ab("agents"));
|
|
9029
9054
|
await writeFileAtomic(ab("agents/example.md"), TEMPLATE_EXAMPLE_AGENT);
|
|
9030
|
-
logger.success("Created .
|
|
9055
|
+
logger.success("Created .agentsmesh/agents/example.md");
|
|
9031
9056
|
await mkdirp(ab("skills/example"));
|
|
9032
9057
|
await writeFileAtomic(ab("skills/example/SKILL.md"), TEMPLATE_EXAMPLE_SKILL);
|
|
9033
|
-
logger.success("Created .
|
|
9058
|
+
logger.success("Created .agentsmesh/skills/example/SKILL.md");
|
|
9034
9059
|
await writeFileAtomic(ab("mcp.json"), TEMPLATE_MCP);
|
|
9035
|
-
logger.success("Created .
|
|
9060
|
+
logger.success("Created .agentsmesh/mcp.json");
|
|
9036
9061
|
await writeFileAtomic(ab("hooks.yaml"), TEMPLATE_HOOKS);
|
|
9037
|
-
logger.success("Created .
|
|
9062
|
+
logger.success("Created .agentsmesh/hooks.yaml");
|
|
9038
9063
|
await writeFileAtomic(ab("permissions.yaml"), TEMPLATE_PERMISSIONS);
|
|
9039
|
-
logger.success("Created .
|
|
9064
|
+
logger.success("Created .agentsmesh/permissions.yaml");
|
|
9040
9065
|
await writeFileAtomic(ab("ignore"), TEMPLATE_IGNORE);
|
|
9041
|
-
logger.success("Created .
|
|
9066
|
+
logger.success("Created .agentsmesh/ignore");
|
|
9042
9067
|
}
|
|
9043
9068
|
async function runInit(projectRoot, options = {}) {
|
|
9044
9069
|
const configPath = join54(projectRoot, CONFIG_FILENAME2);
|
|
@@ -9067,7 +9092,7 @@ async function runInit(projectRoot, options = {}) {
|
|
|
9067
9092
|
logger.success(`Created ${CONFIG_FILENAME2} (targets: ${existing.join(", ")})`);
|
|
9068
9093
|
} else {
|
|
9069
9094
|
logger.info(
|
|
9070
|
-
`Run '
|
|
9095
|
+
`Run 'agentsmesh init --yes' to auto-import, or 'agentsmesh import --from <tool>' manually.`
|
|
9071
9096
|
);
|
|
9072
9097
|
await writeScaffold(projectRoot);
|
|
9073
9098
|
await writeFileAtomic(configPath, buildConfig([]));
|
|
@@ -9091,7 +9116,7 @@ async function runImport(flags, projectRoot) {
|
|
|
9091
9116
|
const root = projectRoot ?? process.cwd();
|
|
9092
9117
|
const from = flags.from;
|
|
9093
9118
|
if (typeof from !== "string" || !from) {
|
|
9094
|
-
throw new Error("--from is required. Example:
|
|
9119
|
+
throw new Error("--from is required. Example: agentsmesh import --from claude-code");
|
|
9095
9120
|
}
|
|
9096
9121
|
const normalized = from.toLowerCase().trim();
|
|
9097
9122
|
if (!isBuiltinTargetId(normalized)) {
|
|
@@ -9108,7 +9133,7 @@ async function runImport(flags, projectRoot) {
|
|
|
9108
9133
|
logger.success(`${fromRel} \u2192 ${r.toPath}`);
|
|
9109
9134
|
}
|
|
9110
9135
|
logger.info(
|
|
9111
|
-
`Imported ${results.length} file(s). Run '
|
|
9136
|
+
`Imported ${results.length} file(s). Run 'agentsmesh generate' to sync to other tools.`
|
|
9112
9137
|
);
|
|
9113
9138
|
}
|
|
9114
9139
|
|
|
@@ -9250,7 +9275,7 @@ function lintMcp(canonical, target10) {
|
|
|
9250
9275
|
if (target10 === "cursor" && usesCursorSensitiveInterpolation(server)) {
|
|
9251
9276
|
diagnostics.push({
|
|
9252
9277
|
level: "warning",
|
|
9253
|
-
file: ".
|
|
9278
|
+
file: ".agentsmesh/mcp.json",
|
|
9254
9279
|
target: target10,
|
|
9255
9280
|
message: `MCP server "${name}" uses env vars or URL/header interpolation; Cursor handling may differ from canonical MCP.`
|
|
9256
9281
|
});
|
|
@@ -9258,7 +9283,7 @@ function lintMcp(canonical, target10) {
|
|
|
9258
9283
|
if (target10 === "codex-cli" && typeof server.description === "string" && server.description) {
|
|
9259
9284
|
diagnostics.push({
|
|
9260
9285
|
level: "warning",
|
|
9261
|
-
file: ".
|
|
9286
|
+
file: ".agentsmesh/mcp.json",
|
|
9262
9287
|
target: target10,
|
|
9263
9288
|
message: `MCP server "${name}" has a description, but codex-cli does not project MCP descriptions into .codex/config.toml.`
|
|
9264
9289
|
});
|
|
@@ -9266,7 +9291,7 @@ function lintMcp(canonical, target10) {
|
|
|
9266
9291
|
if (target10 === "codex-cli" && isUrlMcpServer(server)) {
|
|
9267
9292
|
diagnostics.push({
|
|
9268
9293
|
level: "warning",
|
|
9269
|
-
file: ".
|
|
9294
|
+
file: ".agentsmesh/mcp.json",
|
|
9270
9295
|
target: target10,
|
|
9271
9296
|
message: `MCP server "${name}" uses ${server.type} transport; codex-cli only generates stdio MCP servers.`
|
|
9272
9297
|
});
|
|
@@ -9274,7 +9299,7 @@ function lintMcp(canonical, target10) {
|
|
|
9274
9299
|
if (target10 === "junie" && isUrlMcpServer(server)) {
|
|
9275
9300
|
diagnostics.push({
|
|
9276
9301
|
level: "warning",
|
|
9277
|
-
file: ".
|
|
9302
|
+
file: ".agentsmesh/mcp.json",
|
|
9278
9303
|
target: target10,
|
|
9279
9304
|
message: `MCP server "${name}" uses ${server.type} transport; Junie project mcp.json currently documents stdio MCP servers only.`
|
|
9280
9305
|
});
|
|
@@ -9292,7 +9317,7 @@ function lintPermissions(canonical, target10) {
|
|
|
9292
9317
|
return [
|
|
9293
9318
|
{
|
|
9294
9319
|
level: "warning",
|
|
9295
|
-
file: ".
|
|
9320
|
+
file: ".agentsmesh/permissions.yaml",
|
|
9296
9321
|
target: target10,
|
|
9297
9322
|
message: "Cursor permissions are partial; tool-level allow/deny may lose fidelity."
|
|
9298
9323
|
}
|
|
@@ -9306,7 +9331,7 @@ function lintHooks(canonical, target10) {
|
|
|
9306
9331
|
const supported = /* @__PURE__ */ new Set(["PreToolUse", "PostToolUse", "Notification"]);
|
|
9307
9332
|
return Object.keys(canonical.hooks).filter((event) => !supported.has(event)).map((event) => ({
|
|
9308
9333
|
level: "warning",
|
|
9309
|
-
file: ".
|
|
9334
|
+
file: ".agentsmesh/hooks.yaml",
|
|
9310
9335
|
target: target10,
|
|
9311
9336
|
message: `${event} is not supported by gemini-cli; only PreToolUse, PostToolUse, and Notification are projected.`
|
|
9312
9337
|
}));
|
|
@@ -9315,7 +9340,7 @@ function lintHooks(canonical, target10) {
|
|
|
9315
9340
|
const supported = /* @__PURE__ */ new Set(["PreToolUse", "PostToolUse", "Notification", "UserPromptSubmit"]);
|
|
9316
9341
|
return Object.keys(canonical.hooks).filter((event) => !supported.has(event)).map((event) => ({
|
|
9317
9342
|
level: "warning",
|
|
9318
|
-
file: ".
|
|
9343
|
+
file: ".agentsmesh/hooks.yaml",
|
|
9319
9344
|
target: target10,
|
|
9320
9345
|
message: `${event} is not supported by Copilot hooks; only PreToolUse, PostToolUse, Notification, and UserPromptSubmit are projected.`
|
|
9321
9346
|
}));
|
|
@@ -9324,7 +9349,7 @@ function lintHooks(canonical, target10) {
|
|
|
9324
9349
|
}
|
|
9325
9350
|
|
|
9326
9351
|
// src/core/linter.ts
|
|
9327
|
-
var EXCLUDE_DIRS = ["node_modules", ".git", "dist", "coverage", ".
|
|
9352
|
+
var EXCLUDE_DIRS = ["node_modules", ".git", "dist", "coverage", ".agentsmesh"];
|
|
9328
9353
|
async function getProjectFiles(projectRoot) {
|
|
9329
9354
|
const all = await readDirRecursive(projectRoot);
|
|
9330
9355
|
const filtered = all.filter((p) => {
|
|
@@ -9402,7 +9427,7 @@ import chokidar from "chokidar";
|
|
|
9402
9427
|
var DEBOUNCE_MS = 300;
|
|
9403
9428
|
function shouldIgnoreWatchPath(configDir, changedPath) {
|
|
9404
9429
|
const relPath = relative18(configDir, changedPath).replace(/\\/g, "/");
|
|
9405
|
-
return relPath.endsWith(".
|
|
9430
|
+
return relPath.endsWith(".agentsmesh/.lock") || relPath.endsWith(".agentsmesh/.lock.tmp");
|
|
9406
9431
|
}
|
|
9407
9432
|
function featureFingerprint(features, rulesCount, commandsCount, agentsCount, skillsCount, mcpServerCount, permissionsCount, hooksCount, ignoreCount) {
|
|
9408
9433
|
return JSON.stringify({
|
|
@@ -9421,9 +9446,9 @@ async function runWatch(flags, projectRoot) {
|
|
|
9421
9446
|
const root = projectRoot ?? process.cwd();
|
|
9422
9447
|
const { configDir } = await loadConfigFromDir(root);
|
|
9423
9448
|
const paths = [
|
|
9424
|
-
join55(configDir, ".
|
|
9425
|
-
join55(configDir, "
|
|
9426
|
-
join55(configDir, "
|
|
9449
|
+
join55(configDir, ".agentsmesh"),
|
|
9450
|
+
join55(configDir, "agentsmesh.yaml"),
|
|
9451
|
+
join55(configDir, "agentsmesh.local.yaml")
|
|
9427
9452
|
];
|
|
9428
9453
|
let debounceTimer = null;
|
|
9429
9454
|
let lastFingerprint = null;
|
|
@@ -9484,7 +9509,7 @@ async function runWatch(flags, projectRoot) {
|
|
|
9484
9509
|
if (shouldIgnoreWatchPath(configDir, changedPath)) return;
|
|
9485
9510
|
schedule();
|
|
9486
9511
|
});
|
|
9487
|
-
logger.info("Watching .
|
|
9512
|
+
logger.info("Watching .agentsmesh/ and agentsmesh.yaml...");
|
|
9488
9513
|
pendingRun = run();
|
|
9489
9514
|
await pendingRun;
|
|
9490
9515
|
pendingRun = null;
|
|
@@ -9507,10 +9532,10 @@ async function runCheck(flags, projectRoot) {
|
|
|
9507
9532
|
void flags;
|
|
9508
9533
|
const root = projectRoot ?? process.cwd();
|
|
9509
9534
|
const { config, configDir } = await loadConfigFromDir(root);
|
|
9510
|
-
const abDir = join56(configDir, ".
|
|
9535
|
+
const abDir = join56(configDir, ".agentsmesh");
|
|
9511
9536
|
const lock = await readLock(abDir);
|
|
9512
9537
|
if (lock === null) {
|
|
9513
|
-
logger.error("Not initialized for collaboration. Run '
|
|
9538
|
+
logger.error("Not initialized for collaboration. Run 'agentsmesh generate' first.");
|
|
9514
9539
|
return 1;
|
|
9515
9540
|
}
|
|
9516
9541
|
const current = await buildChecksums(abDir);
|
|
@@ -9571,7 +9596,7 @@ async function runCheck(flags, projectRoot) {
|
|
|
9571
9596
|
logger.error(` ${p} was removed${suffix}`);
|
|
9572
9597
|
}
|
|
9573
9598
|
logger.info(
|
|
9574
|
-
"Run '
|
|
9599
|
+
"Run 'agentsmesh merge' to resolve, or 'agentsmesh generate --force' to accept current state."
|
|
9575
9600
|
);
|
|
9576
9601
|
return 1;
|
|
9577
9602
|
}
|
|
@@ -9580,7 +9605,7 @@ async function runCheck(flags, projectRoot) {
|
|
|
9580
9605
|
import { join as join58 } from "path";
|
|
9581
9606
|
|
|
9582
9607
|
// src/core/merger.ts
|
|
9583
|
-
import { dirname as
|
|
9608
|
+
import { dirname as dirname21, join as join57 } from "path";
|
|
9584
9609
|
var LOCK_FILENAME2 = ".lock";
|
|
9585
9610
|
var CONFLICT_MARKER = "<<<<<<<";
|
|
9586
9611
|
async function hasLockConflict(abDir) {
|
|
@@ -9595,7 +9620,7 @@ async function resolveLockConflict(abDir, libVersion, config) {
|
|
|
9595
9620
|
throw new Error("No conflict to resolve.");
|
|
9596
9621
|
}
|
|
9597
9622
|
const checksums = await buildChecksums(abDir);
|
|
9598
|
-
const configDir =
|
|
9623
|
+
const configDir = dirname21(abDir);
|
|
9599
9624
|
const resolvedExtends = config ? await resolveExtendPaths(config, configDir) : [];
|
|
9600
9625
|
const extendChecksums = resolvedExtends.length > 0 ? await buildExtendChecksums(resolvedExtends) : {};
|
|
9601
9626
|
const packChecksums = await buildPackChecksums(join57(abDir, "packs"));
|
|
@@ -9615,7 +9640,7 @@ async function runMerge(flags, projectRoot) {
|
|
|
9615
9640
|
void flags;
|
|
9616
9641
|
const root = projectRoot ?? process.cwd();
|
|
9617
9642
|
const { config, configDir } = await loadConfigFromDir(root);
|
|
9618
|
-
const abDir = join58(configDir, ".
|
|
9643
|
+
const abDir = join58(configDir, ".agentsmesh");
|
|
9619
9644
|
const hasConflict = await hasLockConflict(abDir);
|
|
9620
9645
|
if (!hasConflict) {
|
|
9621
9646
|
logger.info("No conflicts to resolve.");
|
|
@@ -9626,7 +9651,7 @@ async function runMerge(flags, projectRoot) {
|
|
|
9626
9651
|
}
|
|
9627
9652
|
|
|
9628
9653
|
// src/install/run-install.ts
|
|
9629
|
-
import { join as
|
|
9654
|
+
import { join as join72 } from "path";
|
|
9630
9655
|
|
|
9631
9656
|
// src/install/git-pin.ts
|
|
9632
9657
|
import { execFile as execFile2 } from "child_process";
|
|
@@ -10001,6 +10026,50 @@ function parseGitlabBlobUrl(urlStr) {
|
|
|
10001
10026
|
return null;
|
|
10002
10027
|
}
|
|
10003
10028
|
}
|
|
10029
|
+
var GITHUB_ROUTE_WORDS = /* @__PURE__ */ new Set([
|
|
10030
|
+
"tree",
|
|
10031
|
+
"blob",
|
|
10032
|
+
"commit",
|
|
10033
|
+
"releases",
|
|
10034
|
+
"actions",
|
|
10035
|
+
"issues",
|
|
10036
|
+
"pulls",
|
|
10037
|
+
"settings",
|
|
10038
|
+
"wiki",
|
|
10039
|
+
"discussions",
|
|
10040
|
+
"security",
|
|
10041
|
+
"projects",
|
|
10042
|
+
"packages"
|
|
10043
|
+
]);
|
|
10044
|
+
function parseGithubRepoUrl(urlStr) {
|
|
10045
|
+
try {
|
|
10046
|
+
const u = new URL3(urlStr);
|
|
10047
|
+
if (u.hostname !== "github.com") return null;
|
|
10048
|
+
const parts = u.pathname.split("/").filter(Boolean).map((s) => s.replace(/\.git$/i, ""));
|
|
10049
|
+
if (parts.length < 2) return null;
|
|
10050
|
+
if (parts.length > 2 || GITHUB_ROUTE_WORDS.has(parts[1])) return null;
|
|
10051
|
+
const org = parts[0];
|
|
10052
|
+
const repo = parts[1];
|
|
10053
|
+
return { org, repo };
|
|
10054
|
+
} catch {
|
|
10055
|
+
return null;
|
|
10056
|
+
}
|
|
10057
|
+
}
|
|
10058
|
+
function parseGitlabRepoUrl(urlStr) {
|
|
10059
|
+
try {
|
|
10060
|
+
const u = new URL3(urlStr);
|
|
10061
|
+
if (u.hostname !== "gitlab.com") return null;
|
|
10062
|
+
const parts = u.pathname.split("/").filter(Boolean).map((s) => s.replace(/\.git$/i, ""));
|
|
10063
|
+
if (parts.length < 2) return null;
|
|
10064
|
+
if (parts.includes("-")) return null;
|
|
10065
|
+
const project = parts[parts.length - 1];
|
|
10066
|
+
const namespace = parts.slice(0, -1).join("/");
|
|
10067
|
+
if (!namespace || !project) return null;
|
|
10068
|
+
return { namespace, project };
|
|
10069
|
+
} catch {
|
|
10070
|
+
return null;
|
|
10071
|
+
}
|
|
10072
|
+
}
|
|
10004
10073
|
function parseGitSshGithub(ssh) {
|
|
10005
10074
|
const m = ssh.match(/^git@github\.com:([^/]+)\/(.+?)(?:\.git)?$/i);
|
|
10006
10075
|
if (!m) return null;
|
|
@@ -10038,26 +10107,48 @@ async function parseInstallSource(raw, configDir, explicitPath) {
|
|
|
10038
10107
|
};
|
|
10039
10108
|
}
|
|
10040
10109
|
if (trimmed.startsWith("https://") || trimmed.startsWith("http://")) {
|
|
10041
|
-
const
|
|
10042
|
-
if (
|
|
10110
|
+
const ghDetailed = parseGithubTreeUrl(trimmed) ?? parseGithubBlobUrl(trimmed);
|
|
10111
|
+
if (ghDetailed) {
|
|
10112
|
+
return {
|
|
10113
|
+
kind: "github",
|
|
10114
|
+
rawRef: ghDetailed.ref,
|
|
10115
|
+
org: ghDetailed.org,
|
|
10116
|
+
repo: ghDetailed.repo,
|
|
10117
|
+
gitRemoteUrl: `https://github.com/${ghDetailed.org}/${ghDetailed.repo}.git`,
|
|
10118
|
+
pathInRepo: pathFlag || ghDetailed.path
|
|
10119
|
+
};
|
|
10120
|
+
}
|
|
10121
|
+
const ghBare = parseGithubRepoUrl(trimmed);
|
|
10122
|
+
if (ghBare) {
|
|
10043
10123
|
return {
|
|
10044
10124
|
kind: "github",
|
|
10045
|
-
rawRef:
|
|
10046
|
-
org:
|
|
10047
|
-
repo:
|
|
10048
|
-
gitRemoteUrl: `https://github.com/${
|
|
10049
|
-
pathInRepo: pathFlag
|
|
10125
|
+
rawRef: "HEAD",
|
|
10126
|
+
org: ghBare.org,
|
|
10127
|
+
repo: ghBare.repo,
|
|
10128
|
+
gitRemoteUrl: `https://github.com/${ghBare.org}/${ghBare.repo}.git`,
|
|
10129
|
+
pathInRepo: pathFlag
|
|
10050
10130
|
};
|
|
10051
10131
|
}
|
|
10052
|
-
const
|
|
10053
|
-
if (
|
|
10132
|
+
const glDetailed = parseGitlabTreeUrl(trimmed) ?? parseGitlabBlobUrl(trimmed);
|
|
10133
|
+
if (glDetailed) {
|
|
10054
10134
|
return {
|
|
10055
10135
|
kind: "gitlab",
|
|
10056
|
-
rawRef:
|
|
10057
|
-
org:
|
|
10058
|
-
repo:
|
|
10059
|
-
gitRemoteUrl: `https://gitlab.com/${
|
|
10060
|
-
pathInRepo: pathFlag ||
|
|
10136
|
+
rawRef: glDetailed.ref,
|
|
10137
|
+
org: glDetailed.namespace,
|
|
10138
|
+
repo: glDetailed.project,
|
|
10139
|
+
gitRemoteUrl: `https://gitlab.com/${glDetailed.namespace}/${glDetailed.project}.git`,
|
|
10140
|
+
pathInRepo: pathFlag || glDetailed.path
|
|
10141
|
+
};
|
|
10142
|
+
}
|
|
10143
|
+
const glBare = parseGitlabRepoUrl(trimmed);
|
|
10144
|
+
if (glBare) {
|
|
10145
|
+
return {
|
|
10146
|
+
kind: "gitlab",
|
|
10147
|
+
rawRef: "HEAD",
|
|
10148
|
+
org: glBare.namespace,
|
|
10149
|
+
repo: glBare.project,
|
|
10150
|
+
gitRemoteUrl: `https://gitlab.com/${glBare.namespace}/${glBare.project}.git`,
|
|
10151
|
+
pathInRepo: pathFlag
|
|
10061
10152
|
};
|
|
10062
10153
|
}
|
|
10063
10154
|
}
|
|
@@ -10127,7 +10218,7 @@ async function parseInstallSource(raw, configDir, explicitPath) {
|
|
|
10127
10218
|
if (!await exists(absLocal)) {
|
|
10128
10219
|
throw new Error(`Path does not exist: ${absLocal}`);
|
|
10129
10220
|
}
|
|
10130
|
-
const abMarker = `${sep2}.
|
|
10221
|
+
const abMarker = `${sep2}.agentsmesh${sep2}`;
|
|
10131
10222
|
const idx = absLocal.indexOf(abMarker);
|
|
10132
10223
|
if (idx >= 0) {
|
|
10133
10224
|
const root = absLocal.slice(0, idx);
|
|
@@ -10282,7 +10373,7 @@ function mergeExtendList(existing, incoming) {
|
|
|
10282
10373
|
|
|
10283
10374
|
// src/install/yaml-writer.ts
|
|
10284
10375
|
import { parse as parseYaml7, stringify } from "yaml";
|
|
10285
|
-
async function
|
|
10376
|
+
async function writeAgentsmeshWithNewExtend(configPath, currentConfig, entry) {
|
|
10286
10377
|
const content = await readFileSafe(configPath);
|
|
10287
10378
|
if (content === null) throw new Error(`Missing config: ${configPath}`);
|
|
10288
10379
|
const raw = parseYaml7(content);
|
|
@@ -10303,9 +10394,9 @@ async function writeInstallAsExtend(args) {
|
|
|
10303
10394
|
${JSON.stringify(entry, null, 2)}`);
|
|
10304
10395
|
return;
|
|
10305
10396
|
}
|
|
10306
|
-
const configPath = join59(configDir, "
|
|
10307
|
-
await
|
|
10308
|
-
logger.success(`Wrote extends entry "${entry.name}" to
|
|
10397
|
+
const configPath = join59(configDir, "agentsmesh.yaml");
|
|
10398
|
+
await writeAgentsmeshWithNewExtend(configPath, config, entry);
|
|
10399
|
+
logger.success(`Wrote extends entry "${entry.name}" to agentsmesh.yaml.`);
|
|
10309
10400
|
}
|
|
10310
10401
|
function toNewExtendEntry(args) {
|
|
10311
10402
|
return {
|
|
@@ -10324,7 +10415,7 @@ import { join as join63 } from "path";
|
|
|
10324
10415
|
import { rename as rename4 } from "fs/promises";
|
|
10325
10416
|
|
|
10326
10417
|
// src/install/pack-writer.ts
|
|
10327
|
-
import { join as join60, basename as basename39, dirname as
|
|
10418
|
+
import { join as join60, basename as basename39, dirname as dirname22 } from "path";
|
|
10328
10419
|
import { rm as rm6, rename as rename3, mkdir as mkdir5, copyFile as copyFile2 } from "fs/promises";
|
|
10329
10420
|
import { stringify as yamlStringify6 } from "yaml";
|
|
10330
10421
|
|
|
@@ -10385,7 +10476,7 @@ async function writeSkills(canonical, packDir) {
|
|
|
10385
10476
|
await copyFile2(skill.source, join60(skillDestDir, "SKILL.md"));
|
|
10386
10477
|
for (const sf of skill.supportingFiles) {
|
|
10387
10478
|
const destPath = join60(skillDestDir, sf.relativePath);
|
|
10388
|
-
await mkdirp(
|
|
10479
|
+
await mkdirp(dirname22(destPath));
|
|
10389
10480
|
await copyFile2(sf.absolutePath, destPath);
|
|
10390
10481
|
}
|
|
10391
10482
|
}
|
|
@@ -10430,7 +10521,7 @@ async function materializePack(packsDir, packName, canonical, metadataInput) {
|
|
|
10430
10521
|
}
|
|
10431
10522
|
|
|
10432
10523
|
// src/install/pack-merge.ts
|
|
10433
|
-
import { join as join61, basename as basename40, dirname as
|
|
10524
|
+
import { join as join61, basename as basename40, dirname as dirname23 } from "path";
|
|
10434
10525
|
import { copyFile as copyFile3 } from "fs/promises";
|
|
10435
10526
|
import { stringify as yamlStringify7 } from "yaml";
|
|
10436
10527
|
function union(a, b) {
|
|
@@ -10493,7 +10584,7 @@ async function mergeSkills(canonical, packDir) {
|
|
|
10493
10584
|
await copyFile3(skill.source, join61(destDir, "SKILL.md"));
|
|
10494
10585
|
for (const sf of skill.supportingFiles) {
|
|
10495
10586
|
const destPath = join61(destDir, sf.relativePath);
|
|
10496
|
-
await mkdirp(
|
|
10587
|
+
await mkdirp(dirname23(destPath));
|
|
10497
10588
|
await copyFile3(sf.absolutePath, destPath);
|
|
10498
10589
|
}
|
|
10499
10590
|
}
|
|
@@ -10568,7 +10659,7 @@ function sameInstallIdentity(a, b) {
|
|
|
10568
10659
|
return a.source === b.source && a.target === b.target && a.as === b.as && sameFeatures2(a.features, b.features);
|
|
10569
10660
|
}
|
|
10570
10661
|
function manifestPath(configDir) {
|
|
10571
|
-
return join62(configDir, ".
|
|
10662
|
+
return join62(configDir, ".agentsmesh", "installs.yaml");
|
|
10572
10663
|
}
|
|
10573
10664
|
async function readInstallManifest(configDir) {
|
|
10574
10665
|
const content = await readFileSafe(manifestPath(configDir));
|
|
@@ -10641,7 +10732,7 @@ async function installAsPack(args) {
|
|
|
10641
10732
|
manualAs,
|
|
10642
10733
|
renameExistingPack
|
|
10643
10734
|
} = args;
|
|
10644
|
-
const packsDir = join63(configDir, ".
|
|
10735
|
+
const packsDir = join63(configDir, ".agentsmesh", "packs");
|
|
10645
10736
|
const selectedCanonical = applySelection(narrowed, selected);
|
|
10646
10737
|
const now = (/* @__PURE__ */ new Date()).toISOString();
|
|
10647
10738
|
const parsedTarget = yamlTarget !== void 0 ? targetSchema.parse(yamlTarget) : void 0;
|
|
@@ -10688,7 +10779,7 @@ async function installAsPack(args) {
|
|
|
10688
10779
|
persistedPick = mergedMeta.pick;
|
|
10689
10780
|
persistedPath = mergedMeta.path;
|
|
10690
10781
|
persistedPaths = mergedMeta.paths;
|
|
10691
|
-
logger.success(`Updated pack "${mergedMeta.name}" in .
|
|
10782
|
+
logger.success(`Updated pack "${mergedMeta.name}" in .agentsmesh/packs/.`);
|
|
10692
10783
|
} else {
|
|
10693
10784
|
const collidingMeta = await readPackMetadata(join63(packsDir, packName));
|
|
10694
10785
|
if (collidingMeta) {
|
|
@@ -10709,7 +10800,7 @@ async function installAsPack(args) {
|
|
|
10709
10800
|
...pathScope(pathInRepo),
|
|
10710
10801
|
...manualAs !== void 0 && { as: manualAs }
|
|
10711
10802
|
});
|
|
10712
|
-
logger.success(`Installed pack "${packName}" to .
|
|
10803
|
+
logger.success(`Installed pack "${packName}" to .agentsmesh/packs/.`);
|
|
10713
10804
|
}
|
|
10714
10805
|
await upsertInstallManifestEntry(
|
|
10715
10806
|
configDir,
|
|
@@ -10736,12 +10827,12 @@ import { join as join64 } from "path";
|
|
|
10736
10827
|
async function syncInstalledPacks(args) {
|
|
10737
10828
|
const installs = await readInstallManifest(args.configDir);
|
|
10738
10829
|
if (installs.length === 0) {
|
|
10739
|
-
logger.info("No recorded installs found in .
|
|
10830
|
+
logger.info("No recorded installs found in .agentsmesh/installs.yaml.");
|
|
10740
10831
|
return;
|
|
10741
10832
|
}
|
|
10742
10833
|
const missing = [];
|
|
10743
10834
|
for (const entry of installs) {
|
|
10744
|
-
const packDir = join64(args.configDir, ".
|
|
10835
|
+
const packDir = join64(args.configDir, ".agentsmesh", "packs", entry.name);
|
|
10745
10836
|
if (!await exists(packDir)) {
|
|
10746
10837
|
missing.push(entry);
|
|
10747
10838
|
}
|
|
@@ -10753,7 +10844,7 @@ async function syncInstalledPacks(args) {
|
|
|
10753
10844
|
for (const entry of missing) {
|
|
10754
10845
|
await args.reinstall(entry);
|
|
10755
10846
|
}
|
|
10756
|
-
logger.success(`Reinstalled ${missing.length} pack(s) from .
|
|
10847
|
+
logger.success(`Reinstalled ${missing.length} pack(s) from .agentsmesh/installs.yaml.`);
|
|
10757
10848
|
}
|
|
10758
10849
|
async function maybeRunInstallSync(args) {
|
|
10759
10850
|
if (!args.sync) return false;
|
|
@@ -10919,13 +11010,70 @@ function narrowDiscoveredForInstallScope(canonical, options) {
|
|
|
10919
11010
|
}
|
|
10920
11011
|
|
|
10921
11012
|
// src/install/manual-install-scope.ts
|
|
10922
|
-
import { basename as basename41, dirname as
|
|
10923
|
-
import { cp, mkdtemp, stat as stat5, rm as rm7 } from "fs/promises";
|
|
11013
|
+
import { basename as basename41, dirname as dirname24, join as join65, relative as relative22 } from "path";
|
|
11014
|
+
import { cp as cp2, mkdtemp, stat as stat5, rm as rm7 } from "fs/promises";
|
|
10924
11015
|
import { tmpdir } from "os";
|
|
11016
|
+
|
|
11017
|
+
// src/install/skill-repo-filter.ts
|
|
11018
|
+
import { relative as relative21 } from "path";
|
|
11019
|
+
import { cp } from "fs/promises";
|
|
11020
|
+
init_markdown();
|
|
11021
|
+
var REPO_BOILERPLATE_FILES = /* @__PURE__ */ new Set([
|
|
11022
|
+
"README.md",
|
|
11023
|
+
"README.rst",
|
|
11024
|
+
"README.txt",
|
|
11025
|
+
"README",
|
|
11026
|
+
"LICENSE",
|
|
11027
|
+
"LICENSE.md",
|
|
11028
|
+
"LICENSE.txt",
|
|
11029
|
+
"LICENSE-MIT",
|
|
11030
|
+
"LICENSE-APACHE",
|
|
11031
|
+
"CONTRIBUTING.md",
|
|
11032
|
+
"CHANGELOG.md",
|
|
11033
|
+
"CODE_OF_CONDUCT.md",
|
|
11034
|
+
"package.json",
|
|
11035
|
+
"package-lock.json",
|
|
11036
|
+
"pnpm-lock.yaml",
|
|
11037
|
+
"yarn.lock",
|
|
11038
|
+
".gitignore",
|
|
11039
|
+
".gitattributes",
|
|
11040
|
+
".editorconfig",
|
|
11041
|
+
".DS_Store"
|
|
11042
|
+
]);
|
|
11043
|
+
var REPO_BOILERPLATE_DIRS = /* @__PURE__ */ new Set([
|
|
11044
|
+
".git",
|
|
11045
|
+
".github",
|
|
11046
|
+
".gitlab",
|
|
11047
|
+
"node_modules",
|
|
11048
|
+
".vscode",
|
|
11049
|
+
".idea"
|
|
11050
|
+
]);
|
|
11051
|
+
async function readSkillFrontmatterName(skillMdPath) {
|
|
11052
|
+
const content = await readFileSafe(skillMdPath);
|
|
11053
|
+
if (!content) return "";
|
|
11054
|
+
const { frontmatter } = parseFrontmatter(content);
|
|
11055
|
+
if (typeof frontmatter.name !== "string") return "";
|
|
11056
|
+
return frontmatter.name.toLowerCase().replace(/[^a-z0-9-]+/g, "-").replace(/-+/g, "-").replace(/^-|-$/g, "");
|
|
11057
|
+
}
|
|
11058
|
+
async function cpFilteredSkill(sourceRoot, destDir) {
|
|
11059
|
+
await cp(sourceRoot, destDir, {
|
|
11060
|
+
recursive: true,
|
|
11061
|
+
filter: (src) => {
|
|
11062
|
+
const rel2 = relative21(sourceRoot, src).replace(/\\/g, "/");
|
|
11063
|
+
if (rel2 === "") return true;
|
|
11064
|
+
const first = rel2.split("/")[0];
|
|
11065
|
+
if (REPO_BOILERPLATE_DIRS.has(first)) return false;
|
|
11066
|
+
if (!rel2.includes("/") && REPO_BOILERPLATE_FILES.has(rel2)) return false;
|
|
11067
|
+
return true;
|
|
11068
|
+
}
|
|
11069
|
+
});
|
|
11070
|
+
}
|
|
11071
|
+
|
|
11072
|
+
// src/install/manual-install-scope.ts
|
|
10925
11073
|
async function createStageRoot() {
|
|
10926
|
-
const stageBase = await mkdtemp(join65(tmpdir(), "
|
|
11074
|
+
const stageBase = await mkdtemp(join65(tmpdir(), "am-install-manual-"));
|
|
10927
11075
|
const discoveryRoot = join65(stageBase, "repo");
|
|
10928
|
-
await mkdirp(join65(discoveryRoot, ".
|
|
11076
|
+
await mkdirp(join65(discoveryRoot, ".agentsmesh"));
|
|
10929
11077
|
return {
|
|
10930
11078
|
discoveryRoot,
|
|
10931
11079
|
cleanup: async () => {
|
|
@@ -10940,7 +11088,7 @@ async function stageMarkdownCollection(sourceRoot, destinationDir) {
|
|
|
10940
11088
|
throw new Error(`Manual install only supports .md files for this collection: ${sourceRoot}`);
|
|
10941
11089
|
}
|
|
10942
11090
|
await mkdirp(destinationDir);
|
|
10943
|
-
await
|
|
11091
|
+
await cp2(sourceRoot, join65(destinationDir, basename41(sourceRoot)));
|
|
10944
11092
|
return;
|
|
10945
11093
|
}
|
|
10946
11094
|
const files = (await readDirRecursive(sourceRoot)).filter(
|
|
@@ -10960,7 +11108,7 @@ async function stageMarkdownCollection(sourceRoot, destinationDir) {
|
|
|
10960
11108
|
);
|
|
10961
11109
|
}
|
|
10962
11110
|
usedNames.set(name, file);
|
|
10963
|
-
await
|
|
11111
|
+
await cp2(file, join65(destinationDir, name));
|
|
10964
11112
|
}
|
|
10965
11113
|
}
|
|
10966
11114
|
async function stagePreferredSkills(sourceRoot, destinationDir, preferredSkillNames) {
|
|
@@ -10971,7 +11119,7 @@ async function stagePreferredSkills(sourceRoot, destinationDir, preferredSkillNa
|
|
|
10971
11119
|
const matches = /* @__PURE__ */ new Map();
|
|
10972
11120
|
for (const file of await readDirRecursive(sourceRoot)) {
|
|
10973
11121
|
if (!file.endsWith("/SKILL.md") && !file.endsWith("\\SKILL.md")) continue;
|
|
10974
|
-
const skillDir =
|
|
11122
|
+
const skillDir = dirname24(file);
|
|
10975
11123
|
const skillName = basename41(skillDir);
|
|
10976
11124
|
if (!wanted.has(skillName)) continue;
|
|
10977
11125
|
const previous = matches.get(skillName);
|
|
@@ -10985,7 +11133,7 @@ async function stagePreferredSkills(sourceRoot, destinationDir, preferredSkillNa
|
|
|
10985
11133
|
if (matches.size !== preferredSkillNames.length) return false;
|
|
10986
11134
|
await mkdirp(destinationDir);
|
|
10987
11135
|
for (const skillName of preferredSkillNames) {
|
|
10988
|
-
await
|
|
11136
|
+
await cp2(matches.get(skillName), join65(destinationDir, skillName), { recursive: true });
|
|
10989
11137
|
}
|
|
10990
11138
|
return true;
|
|
10991
11139
|
}
|
|
@@ -10995,10 +11143,10 @@ async function stageSkills(sourceRoot, destinationDir, options = {}) {
|
|
|
10995
11143
|
if (basename41(sourceRoot) !== "SKILL.md") {
|
|
10996
11144
|
throw new Error(`Manual skill install expects SKILL.md or a skill directory: ${sourceRoot}`);
|
|
10997
11145
|
}
|
|
10998
|
-
const skillName = basename41(
|
|
11146
|
+
const skillName = basename41(dirname24(sourceRoot));
|
|
10999
11147
|
const skillDir = join65(destinationDir, skillName);
|
|
11000
11148
|
await mkdirp(skillDir);
|
|
11001
|
-
await
|
|
11149
|
+
await cp2(dirname24(sourceRoot), skillDir, { recursive: true });
|
|
11002
11150
|
return;
|
|
11003
11151
|
}
|
|
11004
11152
|
if (await isSkillPackLayout(sourceRoot)) {
|
|
@@ -11006,9 +11154,11 @@ async function stageSkills(sourceRoot, destinationDir, options = {}) {
|
|
|
11006
11154
|
if (await stagePreferredSkills(sourceRoot, destinationDir, options.preferredSkillNames ?? [])) {
|
|
11007
11155
|
return;
|
|
11008
11156
|
}
|
|
11009
|
-
const
|
|
11157
|
+
const fmName = await readSkillFrontmatterName(join65(sourceRoot, "SKILL.md"));
|
|
11158
|
+
const skillName = fmName || basename41(sourceRoot);
|
|
11159
|
+
const skillDir = join65(destinationDir, skillName);
|
|
11010
11160
|
await mkdirp(destinationDir);
|
|
11011
|
-
await
|
|
11161
|
+
await cpFilteredSkill(sourceRoot, skillDir);
|
|
11012
11162
|
return;
|
|
11013
11163
|
}
|
|
11014
11164
|
if (await stagePreferredSkills(sourceRoot, destinationDir, options.preferredSkillNames ?? [])) {
|
|
@@ -11020,10 +11170,10 @@ async function stageSkills(sourceRoot, destinationDir, options = {}) {
|
|
|
11020
11170
|
for (const file of entries.filter(
|
|
11021
11171
|
(entry) => entry.endsWith("/SKILL.md") || entry.endsWith("\\SKILL.md")
|
|
11022
11172
|
)) {
|
|
11023
|
-
roots.add(
|
|
11173
|
+
roots.add(relative22(sourceRoot, dirname24(file)).split(/[\\/]/)[0]);
|
|
11024
11174
|
}
|
|
11025
11175
|
for (const root of roots) {
|
|
11026
|
-
await
|
|
11176
|
+
await cp2(join65(sourceRoot, root), join65(destinationDir, root), { recursive: true });
|
|
11027
11177
|
}
|
|
11028
11178
|
return;
|
|
11029
11179
|
}
|
|
@@ -11034,7 +11184,7 @@ async function stageSkills(sourceRoot, destinationDir, options = {}) {
|
|
|
11034
11184
|
async function stageManualInstallScope(sourceRoot, as, options = {}) {
|
|
11035
11185
|
const staged = await createStageRoot();
|
|
11036
11186
|
try {
|
|
11037
|
-
const destDir = join65(staged.discoveryRoot, ".
|
|
11187
|
+
const destDir = join65(staged.discoveryRoot, ".agentsmesh", as);
|
|
11038
11188
|
if (as === "skills") {
|
|
11039
11189
|
await stageSkills(sourceRoot, destDir, options);
|
|
11040
11190
|
} else {
|
|
@@ -11132,7 +11282,7 @@ function extendPickHasArrays(p) {
|
|
|
11132
11282
|
import { basename as basename44, join as join68 } from "path";
|
|
11133
11283
|
|
|
11134
11284
|
// src/install/gemini-install-commands.ts
|
|
11135
|
-
import { join as join66, relative as
|
|
11285
|
+
import { join as join66, relative as relative23 } from "path";
|
|
11136
11286
|
async function inferGeminiCommandNamesFromFiles(repoRoot, pathInRepoPosix) {
|
|
11137
11287
|
const commandsRoot = join66(repoRoot, ...GEMINI_COMMANDS_DIR.split("/"));
|
|
11138
11288
|
const scanDir = join66(repoRoot, ...pathInRepoPosix.split("/"));
|
|
@@ -11140,7 +11290,7 @@ async function inferGeminiCommandNamesFromFiles(repoRoot, pathInRepoPosix) {
|
|
|
11140
11290
|
const names = [];
|
|
11141
11291
|
for (const f of files) {
|
|
11142
11292
|
if (!/\.(toml|md)$/i.test(f)) continue;
|
|
11143
|
-
const rel2 =
|
|
11293
|
+
const rel2 = relative23(commandsRoot, f).replace(/\\/g, "/");
|
|
11144
11294
|
if (rel2.startsWith("..") || rel2 === "") continue;
|
|
11145
11295
|
const noExt = rel2.replace(/\.(toml|md)$/i, "");
|
|
11146
11296
|
const name = noExt.split("/").filter(Boolean).join(":");
|
|
@@ -11150,16 +11300,16 @@ async function inferGeminiCommandNamesFromFiles(repoRoot, pathInRepoPosix) {
|
|
|
11150
11300
|
}
|
|
11151
11301
|
|
|
11152
11302
|
// src/install/native-skill-scan.ts
|
|
11153
|
-
import { basename as basename42, dirname as
|
|
11303
|
+
import { basename as basename42, dirname as dirname25, relative as relative24 } from "path";
|
|
11154
11304
|
async function skillNamesFromNativeSkillDir(scanRoot) {
|
|
11155
11305
|
const files = await readDirRecursive(scanRoot);
|
|
11156
11306
|
const names = /* @__PURE__ */ new Set();
|
|
11157
11307
|
for (const f of files) {
|
|
11158
11308
|
if (basename42(f) === "SKILL.md") {
|
|
11159
|
-
names.add(basename42(
|
|
11309
|
+
names.add(basename42(dirname25(f)));
|
|
11160
11310
|
continue;
|
|
11161
11311
|
}
|
|
11162
|
-
const rel2 =
|
|
11312
|
+
const rel2 = relative24(scanRoot, f).replace(/\\/g, "/");
|
|
11163
11313
|
if (!rel2.includes("/") && f.toLowerCase().endsWith(".md")) {
|
|
11164
11314
|
names.add(basename42(f, ".md"));
|
|
11165
11315
|
}
|
|
@@ -11342,8 +11492,8 @@ function isImplicitPickEmpty(p) {
|
|
|
11342
11492
|
}
|
|
11343
11493
|
|
|
11344
11494
|
// src/install/native-install-scope.ts
|
|
11345
|
-
import { basename as basename45, join as join69, relative as
|
|
11346
|
-
import { cp as
|
|
11495
|
+
import { basename as basename45, join as join69, relative as relative25 } from "path";
|
|
11496
|
+
import { cp as cp3, mkdtemp as mkdtemp2, rm as rm8 } from "fs/promises";
|
|
11347
11497
|
import { tmpdir as tmpdir2 } from "os";
|
|
11348
11498
|
function normalizePath3(path) {
|
|
11349
11499
|
return path.replace(/\\/g, "/").replace(/\/+$/, "");
|
|
@@ -11359,13 +11509,13 @@ function addUnique(target10, value) {
|
|
|
11359
11509
|
return next;
|
|
11360
11510
|
}
|
|
11361
11511
|
async function makeStageRoot(repoRoot) {
|
|
11362
|
-
const stageBase = await mkdtemp2(join69(tmpdir2(), "
|
|
11512
|
+
const stageBase = await mkdtemp2(join69(tmpdir2(), "am-install-native-"));
|
|
11363
11513
|
const stageRoot = join69(stageBase, "repo");
|
|
11364
11514
|
const cleanup = async () => {
|
|
11365
11515
|
await rm8(stageBase, { recursive: true, force: true });
|
|
11366
11516
|
};
|
|
11367
11517
|
try {
|
|
11368
|
-
await
|
|
11518
|
+
await cp3(repoRoot, stageRoot, { recursive: true });
|
|
11369
11519
|
return { stageRoot, cleanup };
|
|
11370
11520
|
} catch (error) {
|
|
11371
11521
|
await cleanup();
|
|
@@ -11375,30 +11525,30 @@ async function makeStageRoot(repoRoot) {
|
|
|
11375
11525
|
function buildPickFromResults(results, stageRoot) {
|
|
11376
11526
|
let pick;
|
|
11377
11527
|
for (const result of results) {
|
|
11378
|
-
if (result.feature === "rules" && result.toPath.startsWith(".
|
|
11528
|
+
if (result.feature === "rules" && result.toPath.startsWith(".agentsmesh/rules/")) {
|
|
11379
11529
|
pick = {
|
|
11380
11530
|
...pick,
|
|
11381
11531
|
rules: addUnique(pick?.rules, basename45(result.toPath, ".md"))
|
|
11382
11532
|
};
|
|
11383
11533
|
continue;
|
|
11384
11534
|
}
|
|
11385
|
-
if (result.feature === "commands" && result.toPath.startsWith(".
|
|
11535
|
+
if (result.feature === "commands" && result.toPath.startsWith(".agentsmesh/commands/")) {
|
|
11386
11536
|
pick = {
|
|
11387
11537
|
...pick,
|
|
11388
11538
|
commands: addUnique(pick?.commands, basename45(result.toPath, ".md"))
|
|
11389
11539
|
};
|
|
11390
11540
|
continue;
|
|
11391
11541
|
}
|
|
11392
|
-
if (result.feature === "agents" && result.toPath.startsWith(".
|
|
11542
|
+
if (result.feature === "agents" && result.toPath.startsWith(".agentsmesh/agents/")) {
|
|
11393
11543
|
pick = {
|
|
11394
11544
|
...pick,
|
|
11395
11545
|
agents: addUnique(pick?.agents, basename45(result.toPath, ".md"))
|
|
11396
11546
|
};
|
|
11397
11547
|
continue;
|
|
11398
11548
|
}
|
|
11399
|
-
if (result.feature === "skills" && result.toPath.startsWith(".
|
|
11549
|
+
if (result.feature === "skills" && result.toPath.startsWith(".agentsmesh/skills/")) {
|
|
11400
11550
|
const rel2 = normalizePath3(
|
|
11401
|
-
|
|
11551
|
+
relative25(join69(stageRoot, ".agentsmesh", "skills"), join69(stageRoot, result.toPath))
|
|
11402
11552
|
);
|
|
11403
11553
|
const skillName = rel2.split("/")[0];
|
|
11404
11554
|
if (skillName) {
|
|
@@ -11458,8 +11608,8 @@ async function prepareInstallDiscovery(repoRoot, contentRoot, pathInRepo, option
|
|
|
11458
11608
|
}
|
|
11459
11609
|
const posixPath = pathInRepo.replace(/\\/g, "/").replace(/^\/+|\/+$/g, "");
|
|
11460
11610
|
validateTargetMatchesPath(explicitTarget, posixPath);
|
|
11461
|
-
const
|
|
11462
|
-
const hasAbRoot = await exists(
|
|
11611
|
+
const agentsmeshAtRoot = join70(repoRoot, ".agentsmesh");
|
|
11612
|
+
const hasAbRoot = await exists(agentsmeshAtRoot);
|
|
11463
11613
|
const pathHint = posixPath ? targetHintFromNativePath(posixPath) : void 0;
|
|
11464
11614
|
const detectedTarget = !hasAbRoot && !explicitTarget ? await detectNativeFormat(repoRoot) ?? void 0 : void 0;
|
|
11465
11615
|
if (!explicitTarget && pathHint && detectedTarget && pathHint !== detectedTarget) {
|
|
@@ -11468,7 +11618,7 @@ async function prepareInstallDiscovery(repoRoot, contentRoot, pathInRepo, option
|
|
|
11468
11618
|
);
|
|
11469
11619
|
}
|
|
11470
11620
|
const effectiveTarget = explicitTarget ?? pathHint ?? detectedTarget;
|
|
11471
|
-
const shouldStageNativeScope = Boolean(posixPath) && Boolean(effectiveTarget) && !posixPath.startsWith(".
|
|
11621
|
+
const shouldStageNativeScope = Boolean(posixPath) && Boolean(effectiveTarget) && !posixPath.startsWith(".agentsmesh");
|
|
11472
11622
|
if (!hasAbRoot && effectiveTarget) {
|
|
11473
11623
|
if (shouldStageNativeScope) {
|
|
11474
11624
|
const staged2 = await stageNativeInstallScope(repoRoot, posixPath, effectiveTarget);
|
|
@@ -11586,7 +11736,7 @@ function applyReplayInstallScope(narrowed, discoveredFeatures, replay) {
|
|
|
11586
11736
|
}
|
|
11587
11737
|
|
|
11588
11738
|
// src/install/manual-install-persistence.ts
|
|
11589
|
-
import { basename as basename46, dirname as
|
|
11739
|
+
import { basename as basename46, dirname as dirname26, join as join71 } from "path";
|
|
11590
11740
|
import { stat as stat6 } from "fs/promises";
|
|
11591
11741
|
function trimDot(pathInRepo) {
|
|
11592
11742
|
return pathInRepo === "." || pathInRepo === "" ? void 0 : pathInRepo;
|
|
@@ -11605,27 +11755,28 @@ async function resolveManualInstallPersistence(args) {
|
|
|
11605
11755
|
const info = await stat6(args.contentRoot);
|
|
11606
11756
|
if (args.as !== "skills" && info.isFile() && args.contentRoot.toLowerCase().endsWith(".md")) {
|
|
11607
11757
|
return {
|
|
11608
|
-
pathInRepo: trimDot(
|
|
11758
|
+
pathInRepo: trimDot(dirname26(normalizedPath)),
|
|
11609
11759
|
pick: markdownPick(args.as, normalizedPath || args.contentRoot)
|
|
11610
11760
|
};
|
|
11611
11761
|
}
|
|
11612
11762
|
if (args.as === "skills") {
|
|
11613
11763
|
if (info.isFile() && basename46(args.contentRoot) === "SKILL.md") {
|
|
11614
|
-
const skillDir = normalizedPath ?
|
|
11764
|
+
const skillDir = normalizedPath ? dirname26(normalizedPath) : dirname26(args.contentRoot);
|
|
11615
11765
|
return {
|
|
11616
|
-
pathInRepo: trimDot(
|
|
11766
|
+
pathInRepo: trimDot(dirname26(skillDir)),
|
|
11617
11767
|
pick: { skills: [basename46(skillDir)] }
|
|
11618
11768
|
};
|
|
11619
11769
|
}
|
|
11620
11770
|
if (info.isDirectory()) {
|
|
11621
11771
|
const skillDir = normalizedPath || basename46(args.contentRoot);
|
|
11622
|
-
const skillFile =
|
|
11772
|
+
const skillFile = join71(args.contentRoot.replace(/\/+$/g, ""), "SKILL.md");
|
|
11623
11773
|
try {
|
|
11624
11774
|
const skillStat = await stat6(skillFile);
|
|
11625
11775
|
if (skillStat.isFile()) {
|
|
11776
|
+
const fmName = await readSkillFrontmatterName(skillFile);
|
|
11626
11777
|
return {
|
|
11627
|
-
pathInRepo: trimDot(
|
|
11628
|
-
pick: { skills: [basename46(skillDir)] }
|
|
11778
|
+
pathInRepo: trimDot(dirname26(skillDir)),
|
|
11779
|
+
pick: { skills: [fmName || basename46(skillDir)] }
|
|
11629
11780
|
};
|
|
11630
11781
|
}
|
|
11631
11782
|
} catch {
|
|
@@ -11676,12 +11827,12 @@ async function runInstall(flags, args, projectRoot, replay) {
|
|
|
11676
11827
|
}
|
|
11677
11828
|
if (!sourceArg) {
|
|
11678
11829
|
throw new Error(
|
|
11679
|
-
"Missing source. Usage:
|
|
11830
|
+
"Missing source. Usage: agentsmesh install <source> [--path ...] [--target ...]"
|
|
11680
11831
|
);
|
|
11681
11832
|
}
|
|
11682
11833
|
const tty = process.stdin.isTTY;
|
|
11683
11834
|
if (!tty && !force && !dryRun) {
|
|
11684
|
-
throw new Error("Non-interactive terminal: use --force or --dry-run for
|
|
11835
|
+
throw new Error("Non-interactive terminal: use --force or --dry-run for agentsmesh install.");
|
|
11685
11836
|
}
|
|
11686
11837
|
const { config, configDir } = await loadConfigFromDir(projectRoot);
|
|
11687
11838
|
const parsed = await parseInstallSource(sourceArg, configDir, explicitPath);
|
|
@@ -11693,7 +11844,7 @@ async function runInstall(flags, args, projectRoot, replay) {
|
|
|
11693
11844
|
sourceArg
|
|
11694
11845
|
);
|
|
11695
11846
|
const pathInRepo = parsed.pathInRepo.replace(/^\/+|\/+$/g, "");
|
|
11696
|
-
const contentRoot = pathInRepo ?
|
|
11847
|
+
const contentRoot = pathInRepo ? join72(resolvedPath, pathInRepo) : resolvedPath;
|
|
11697
11848
|
if (!await exists(contentRoot)) {
|
|
11698
11849
|
throw new Error(`Install path does not exist: ${contentRoot}`);
|
|
11699
11850
|
}
|
|
@@ -11774,7 +11925,7 @@ async function runInstall(flags, args, projectRoot, replay) {
|
|
|
11774
11925
|
if (dryRun) return;
|
|
11775
11926
|
} else {
|
|
11776
11927
|
if (dryRun) {
|
|
11777
|
-
logger.info(`[dry-run] Would install pack "${entryName}" to .
|
|
11928
|
+
logger.info(`[dry-run] Would install pack "${entryName}" to .agentsmesh/packs/.`);
|
|
11778
11929
|
return;
|
|
11779
11930
|
}
|
|
11780
11931
|
await installAsPack({
|
|
@@ -11795,7 +11946,7 @@ async function runInstall(flags, args, projectRoot, replay) {
|
|
|
11795
11946
|
}
|
|
11796
11947
|
const genCode = await runGenerate({}, configDir);
|
|
11797
11948
|
if (genCode !== 0) {
|
|
11798
|
-
logger.warn("Generate failed after install. Fix the issue and run
|
|
11949
|
+
logger.warn("Generate failed after install. Fix the issue and run agentsmesh generate.");
|
|
11799
11950
|
}
|
|
11800
11951
|
} finally {
|
|
11801
11952
|
if (prep.cleanup) {
|
|
@@ -11925,7 +12076,7 @@ function isMainModule() {
|
|
|
11925
12076
|
const invokedResolved = resolve6(process.cwd(), invoked);
|
|
11926
12077
|
return invokedResolved === ourPath || realpathSync3(invokedResolved) === realpathSync3(ourPath);
|
|
11927
12078
|
} catch {
|
|
11928
|
-
return invoked.endsWith("cli.js") || invoked.includes("
|
|
12079
|
+
return invoked.endsWith("cli.js") || invoked.includes("agentsmesh");
|
|
11929
12080
|
}
|
|
11930
12081
|
}
|
|
11931
12082
|
if (isMainModule()) {
|