allagents 0.5.1 → 0.5.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.
Files changed (2) hide show
  1. package/dist/index.js +41 -14
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -19441,9 +19441,14 @@ function parsePluginSource(source, baseDir = process.cwd()) {
19441
19441
  normalized: normalizePluginPath(source, baseDir)
19442
19442
  };
19443
19443
  }
19444
- function getPluginCachePath(owner, repo) {
19444
+ function sanitizeBranchForPath(branch) {
19445
+ return branch.replace(/[/\\:*?"<>|]/g, "_");
19446
+ }
19447
+ function getPluginCachePath(owner, repo, branch) {
19445
19448
  const homeDir = process.env.HOME || process.env.USERPROFILE || "~";
19446
- return resolve(homeDir, ".allagents", "plugins", "marketplaces", `${owner}-${repo}`);
19449
+ const basePath = `${owner}-${repo}`;
19450
+ const cacheName = branch ? `${basePath}@${sanitizeBranchForPath(branch)}` : basePath;
19451
+ return resolve(homeDir, ".allagents", "plugins", "marketplaces", cacheName);
19447
19452
  }
19448
19453
  function validatePluginSource(source) {
19449
19454
  if (!source || source.trim() === "") {
@@ -19557,7 +19562,7 @@ import { mkdir, readdir, stat } from "node:fs/promises";
19557
19562
  import { existsSync } from "node:fs";
19558
19563
  import { dirname, join, resolve as resolve2 } from "node:path";
19559
19564
  async function fetchPlugin(url, options2 = {}) {
19560
- const { force = false } = options2;
19565
+ const { force = false, branch } = options2;
19561
19566
  const validation = validatePluginSource(url);
19562
19567
  if (!validation.valid) {
19563
19568
  return {
@@ -19577,7 +19582,7 @@ async function fetchPlugin(url, options2 = {}) {
19577
19582
  };
19578
19583
  }
19579
19584
  const { owner, repo } = parsed;
19580
- const cachePath = getPluginCachePath(owner, repo);
19585
+ const cachePath = getPluginCachePath(owner, repo, branch);
19581
19586
  try {
19582
19587
  await execa("gh", ["--version"]);
19583
19588
  } catch {
@@ -19608,7 +19613,11 @@ async function fetchPlugin(url, options2 = {}) {
19608
19613
  }
19609
19614
  const parentDir = dirname(cachePath);
19610
19615
  await mkdir(parentDir, { recursive: true });
19611
- await execa("gh", ["repo", "clone", `${owner}/${repo}`, cachePath]);
19616
+ if (branch) {
19617
+ await execa("gh", ["repo", "clone", `${owner}/${repo}`, cachePath, "--", "--branch", branch]);
19618
+ } else {
19619
+ await execa("gh", ["repo", "clone", `${owner}/${repo}`, cachePath]);
19620
+ }
19612
19621
  return {
19613
19622
  success: true,
19614
19623
  action: "fetched",
@@ -20781,7 +20790,11 @@ async function validatePlugin(pluginSource, workspacePath, force) {
20781
20790
  };
20782
20791
  }
20783
20792
  if (isGitHubUrl(pluginSource)) {
20784
- const fetchResult = await fetchPlugin(pluginSource, { force });
20793
+ const parsed = parseGitHubUrl(pluginSource);
20794
+ const fetchResult = await fetchPlugin(pluginSource, {
20795
+ force,
20796
+ ...parsed?.branch && { branch: parsed.branch }
20797
+ });
20785
20798
  if (!fetchResult.success) {
20786
20799
  return {
20787
20800
  plugin: pluginSource,
@@ -20790,7 +20803,6 @@ async function validatePlugin(pluginSource, workspacePath, force) {
20790
20803
  ...fetchResult.error && { error: fetchResult.error }
20791
20804
  };
20792
20805
  }
20793
- const parsed = parseGitHubUrl(pluginSource);
20794
20806
  const resolvedPath2 = parsed?.subpath ? join7(fetchResult.cachePath, parsed.subpath) : fetchResult.cachePath;
20795
20807
  return {
20796
20808
  plugin: pluginSource,
@@ -21309,13 +21321,28 @@ async function initWorkspace(targetPath = ".", options2 = {}) {
21309
21321
  }
21310
21322
  await writeFile4(configPath, workspaceYamlContent, "utf-8");
21311
21323
  const copiedAgentFiles = [];
21312
- const effectiveSourceDir = sourceDir ?? defaultTemplatePath;
21313
- for (const agentFile of AGENT_FILES) {
21314
- const sourcePath = join8(effectiveSourceDir, agentFile);
21315
- if (existsSync7(sourcePath)) {
21316
- const content = await readFile6(sourcePath, "utf-8");
21317
- await writeFile4(join8(absoluteTarget, agentFile), content, "utf-8");
21318
- copiedAgentFiles.push(agentFile);
21324
+ if (options2.from && isGitHubUrl(options2.from)) {
21325
+ const parsedUrl = parseGitHubUrl(options2.from);
21326
+ if (parsedUrl) {
21327
+ const basePath = parsedUrl.subpath || "";
21328
+ for (const agentFile of AGENT_FILES) {
21329
+ const filePath = basePath ? `${basePath}/${agentFile}` : agentFile;
21330
+ const content = await fetchFileFromGitHub(parsedUrl.owner, parsedUrl.repo, filePath, parsedUrl.branch);
21331
+ if (content) {
21332
+ await writeFile4(join8(absoluteTarget, agentFile), content, "utf-8");
21333
+ copiedAgentFiles.push(agentFile);
21334
+ }
21335
+ }
21336
+ }
21337
+ } else {
21338
+ const effectiveSourceDir = sourceDir ?? defaultTemplatePath;
21339
+ for (const agentFile of AGENT_FILES) {
21340
+ const sourcePath = join8(effectiveSourceDir, agentFile);
21341
+ if (existsSync7(sourcePath)) {
21342
+ const content = await readFile6(sourcePath, "utf-8");
21343
+ await writeFile4(join8(absoluteTarget, agentFile), content, "utf-8");
21344
+ copiedAgentFiles.push(agentFile);
21345
+ }
21319
21346
  }
21320
21347
  }
21321
21348
  if (copiedAgentFiles.length === 0) {
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allagents",
3
- "version": "0.5.1",
3
+ "version": "0.5.2",
4
4
  "description": "CLI tool for managing multi-repo AI agent workspaces with plugin synchronization",
5
5
  "type": "module",
6
6
  "bin": {