agents-anywhere 0.7.2 → 0.7.4

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.
Files changed (2) hide show
  1. package/dist/cli.js +77 -18
  2. package/package.json +1 -1
package/dist/cli.js CHANGED
@@ -1104,7 +1104,42 @@ async function initCommand(repoDir, options) {
1104
1104
  }
1105
1105
  if (fs4.existsSync(import_node_path5.default.join(targetDir, "agents-anywhere.json"))) {
1106
1106
  warn(`Config repo already exists at ${targetDir}`);
1107
- info("Run `agents-anywhere link` to connect your agents.");
1107
+ let hasRemote = false;
1108
+ try {
1109
+ const remote = (0, import_node_child_process2.execSync)("git remote get-url origin", {
1110
+ cwd: targetDir,
1111
+ encoding: "utf-8",
1112
+ stdio: ["pipe", "pipe", "pipe"]
1113
+ }).trim();
1114
+ info(`Remote: ${remote}`);
1115
+ hasRemote = true;
1116
+ } catch {
1117
+ warn("No git remote configured.");
1118
+ }
1119
+ if (process.stdin.isTTY) {
1120
+ const shouldRelink = await (0, import_confirm.default)({
1121
+ message: "Re-link agents and sync MCP configs?",
1122
+ default: true
1123
+ });
1124
+ if (shouldRelink) {
1125
+ heading("Linking agent configs...");
1126
+ for (const agent of installed) {
1127
+ const results = linkAgent(agent.definition, targetDir);
1128
+ const linked = results.filter(
1129
+ (r) => r.action === "linked" || r.action === "backed-up-and-linked"
1130
+ );
1131
+ if (linked.length > 0) {
1132
+ success(`${agent.definition.name} \u2014 ${linked.length} item(s) linked`);
1133
+ } else {
1134
+ info(`${agent.definition.name} \u2014 already linked`);
1135
+ }
1136
+ }
1137
+ syncMCPToAllAgents(targetDir, installed);
1138
+ }
1139
+ if (!hasRemote) {
1140
+ await promptGitHubRepo(targetDir);
1141
+ }
1142
+ }
1108
1143
  return;
1109
1144
  }
1110
1145
  const primary = await promptPrimaryAgent(installed);
@@ -1182,6 +1217,42 @@ async function promptPrimaryAgent(installed) {
1182
1217
  });
1183
1218
  return candidates.find((c) => c.definition.id === chosen);
1184
1219
  }
1220
+ function resolveSourcePath(sourcePath, configDir, item) {
1221
+ const isSymlink = lstatExists(sourcePath) && fs4.lstatSync(sourcePath).isSymbolicLink();
1222
+ if (isSymlink) {
1223
+ try {
1224
+ const realPath = fs4.realpathSync(sourcePath);
1225
+ if (fs4.existsSync(realPath)) return realPath;
1226
+ } catch {
1227
+ }
1228
+ const backup = findBackup(configDir, item);
1229
+ if (backup) {
1230
+ const backupPath = import_node_path5.default.join(configDir, backup);
1231
+ if (lstatExists(backupPath) && fs4.lstatSync(backupPath).isSymbolicLink()) {
1232
+ try {
1233
+ const realBackup = fs4.realpathSync(backupPath);
1234
+ if (fs4.existsSync(realBackup)) return realBackup;
1235
+ } catch {
1236
+ return null;
1237
+ }
1238
+ }
1239
+ if (fs4.existsSync(backupPath)) return backupPath;
1240
+ }
1241
+ return null;
1242
+ }
1243
+ if (fs4.existsSync(sourcePath)) return sourcePath;
1244
+ return null;
1245
+ }
1246
+ function findBackup(dir, item) {
1247
+ try {
1248
+ const entries = fs4.readdirSync(dir);
1249
+ const prefix = `${item}.backup.`;
1250
+ const backups = entries.filter((e) => e.startsWith(prefix)).sort().reverse();
1251
+ return backups[0];
1252
+ } catch {
1253
+ return void 0;
1254
+ }
1255
+ }
1185
1256
  function copyPortableFiles(installed, repoDir) {
1186
1257
  heading("Copying portable files...");
1187
1258
  for (const agent of installed) {
@@ -1199,26 +1270,14 @@ function copyPortableFiles(installed, repoDir) {
1199
1270
  if (ignoreRoots.has(item) || credBasenames.has(item)) continue;
1200
1271
  const sourcePath = import_node_path5.default.join(configDir, item);
1201
1272
  const destPath = import_node_path5.default.join(agentRepoDir, item);
1202
- if (!fs4.existsSync(sourcePath)) continue;
1203
- if (lstatExists(sourcePath) && fs4.lstatSync(sourcePath).isSymbolicLink()) {
1204
- const realPath = fs4.realpathSync(sourcePath);
1205
- if (!fs4.existsSync(realPath)) continue;
1206
- const stat2 = fs4.statSync(realPath);
1207
- if (stat2.isDirectory()) {
1208
- fs4.cpSync(realPath, destPath, { recursive: true });
1209
- } else {
1210
- fs4.mkdirSync(import_node_path5.default.dirname(destPath), { recursive: true });
1211
- fs4.copyFileSync(realPath, destPath);
1212
- }
1213
- copied++;
1214
- continue;
1215
- }
1216
- const stat = fs4.statSync(sourcePath);
1273
+ const resolvedSource = resolveSourcePath(sourcePath, configDir, item);
1274
+ if (!resolvedSource) continue;
1275
+ const stat = fs4.statSync(resolvedSource);
1217
1276
  if (stat.isDirectory()) {
1218
- fs4.cpSync(sourcePath, destPath, { recursive: true, dereference: true });
1277
+ fs4.cpSync(resolvedSource, destPath, { recursive: true, dereference: true });
1219
1278
  } else {
1220
1279
  fs4.mkdirSync(import_node_path5.default.dirname(destPath), { recursive: true });
1221
- fs4.copyFileSync(sourcePath, destPath);
1280
+ fs4.copyFileSync(resolvedSource, destPath);
1222
1281
  }
1223
1282
  copied++;
1224
1283
  }
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "agents-anywhere",
3
- "version": "0.7.2",
3
+ "version": "0.7.4",
4
4
  "description": "Manage your AI coding agent configs in one place. One MCP config for every tool. Sync between devices with git.",
5
5
  "main": "dist/index.js",
6
6
  "module": "dist/index.mjs",