allagents 0.2.1 → 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.
Files changed (2) hide show
  1. package/dist/index.js +114 -50
  2. package/package.json +1 -1
package/dist/index.js CHANGED
@@ -11059,36 +11059,11 @@ import { dirname as dirname6, join as join11 } from "node:path";
11059
11059
  import { fileURLToPath as fileURLToPath3 } from "node:url";
11060
11060
 
11061
11061
  // src/core/workspace.ts
11062
- import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile4 } from "node:fs/promises";
11062
+ import { mkdir as mkdir5, readFile as readFile6, writeFile as writeFile4, copyFile as copyFile2 } from "node:fs/promises";
11063
11063
  import { existsSync as existsSync7 } from "node:fs";
11064
- import { join as join8, resolve as resolve5, dirname as dirname5, relative as relative2, sep } from "node:path";
11064
+ import { join as join8, resolve as resolve5, dirname as dirname5, relative as relative2, sep, isAbsolute as isAbsolute2 } from "node:path";
11065
11065
  import { fileURLToPath as fileURLToPath2 } from "node:url";
11066
11066
 
11067
- // src/core/sync.ts
11068
- import { existsSync as existsSync6 } from "node:fs";
11069
- import { rm, unlink, rmdir } from "node:fs/promises";
11070
- import { join as join7, resolve as resolve4, dirname as dirname4, relative } from "node:path";
11071
-
11072
- // src/constants.ts
11073
- var CONFIG_DIR = ".allagents";
11074
- var SYNC_STATE_FILE = "sync-state.json";
11075
- var WORKSPACE_CONFIG_FILE = "workspace.yaml";
11076
- var WORKSPACE_CONFIG_PATH = `${CONFIG_DIR}/${WORKSPACE_CONFIG_FILE}`;
11077
- var WORKSPACE_RULES = `
11078
- <!-- WORKSPACE-RULES:START -->
11079
- ## Rule: Workspace Discovery
11080
- TRIGGER: Any task
11081
- ACTION: Read \`.allagents/workspace.yaml\` to get repository paths and project domains
11082
-
11083
- ## Rule: Correct Repository Paths
11084
- TRIGGER: File operations (read, search, modify)
11085
- ACTION: Use repository paths from \`.allagents/workspace.yaml\`, not assumptions
11086
- <!-- WORKSPACE-RULES:END -->
11087
- `;
11088
-
11089
- // src/utils/workspace-parser.ts
11090
- import { readFile } from "node:fs/promises";
11091
-
11092
11067
  // node_modules/js-yaml/dist/js-yaml.mjs
11093
11068
  /*! js-yaml 4.1.1 https://github.com/nodeca/js-yaml @license MIT */
11094
11069
  function isNothing(subject) {
@@ -13736,6 +13711,32 @@ var safeLoad = renamed("safeLoad", "load");
13736
13711
  var safeLoadAll = renamed("safeLoadAll", "loadAll");
13737
13712
  var safeDump = renamed("safeDump", "dump");
13738
13713
 
13714
+ // src/core/sync.ts
13715
+ import { existsSync as existsSync6 } from "node:fs";
13716
+ import { rm, unlink, rmdir, copyFile } from "node:fs/promises";
13717
+ import { join as join7, resolve as resolve4, dirname as dirname4, relative } from "node:path";
13718
+
13719
+ // src/constants.ts
13720
+ var CONFIG_DIR = ".allagents";
13721
+ var SYNC_STATE_FILE = "sync-state.json";
13722
+ var WORKSPACE_CONFIG_FILE = "workspace.yaml";
13723
+ var WORKSPACE_CONFIG_PATH = `${CONFIG_DIR}/${WORKSPACE_CONFIG_FILE}`;
13724
+ var AGENT_FILES = ["AGENTS.md", "CLAUDE.md"];
13725
+ var WORKSPACE_RULES = `
13726
+ <!-- WORKSPACE-RULES:START -->
13727
+ ## Rule: Workspace Discovery
13728
+ TRIGGER: Any task
13729
+ ACTION: Read \`.allagents/workspace.yaml\` to get repository paths and project domains
13730
+
13731
+ ## Rule: Correct Repository Paths
13732
+ TRIGGER: File operations (read, search, modify)
13733
+ ACTION: Use repository paths from \`.allagents/workspace.yaml\`, not assumptions
13734
+ <!-- WORKSPACE-RULES:END -->
13735
+ `;
13736
+
13737
+ // src/utils/workspace-parser.ts
13738
+ import { readFile } from "node:fs/promises";
13739
+
13739
13740
  // node_modules/zod/v3/external.js
13740
13741
  var exports_external = {};
13741
13742
  __export(exports_external, {
@@ -19751,6 +19752,7 @@ async function validateSkill(skillDir) {
19751
19752
  }
19752
19753
 
19753
19754
  // src/core/transform.ts
19755
+ var AGENT_FILES2 = ["AGENTS.md", "CLAUDE.md"];
19754
19756
  async function ensureWorkspaceRules(filePath, rules) {
19755
19757
  const rulesContent = rules ?? WORKSPACE_RULES;
19756
19758
  const startMarker = "<!-- WORKSPACE-RULES:START -->";
@@ -19972,7 +19974,7 @@ async function copyWorkspaceFiles(sourcePath, workspacePath, files, options2 = {
19972
19974
  }
19973
19975
  if (dryRun) {
19974
19976
  results.push({ source: resolved.sourcePath, destination: destPath, action: "copied" });
19975
- if (resolved.relativePath === "CLAUDE.md" || resolved.relativePath === "AGENTS.md") {
19977
+ if (AGENT_FILES2.includes(resolved.relativePath)) {
19976
19978
  copiedAgentFiles.push(resolved.relativePath);
19977
19979
  }
19978
19980
  continue;
@@ -19982,7 +19984,7 @@ async function copyWorkspaceFiles(sourcePath, workspacePath, files, options2 = {
19982
19984
  const content = await readFile3(resolved.sourcePath, "utf-8");
19983
19985
  await writeFile(destPath, content, "utf-8");
19984
19986
  results.push({ source: resolved.sourcePath, destination: destPath, action: "copied" });
19985
- if (resolved.relativePath === "CLAUDE.md" || resolved.relativePath === "AGENTS.md") {
19987
+ if (AGENT_FILES2.includes(resolved.relativePath)) {
19986
19988
  copiedAgentFiles.push(resolved.relativePath);
19987
19989
  }
19988
19990
  } catch (error) {
@@ -20011,7 +20013,7 @@ async function copyWorkspaceFiles(sourcePath, workspacePath, files, options2 = {
20011
20013
  }
20012
20014
  if (dryRun) {
20013
20015
  results.push({ source: srcPath, destination: destPath, action: "copied" });
20014
- if (destFilename === "CLAUDE.md" || destFilename === "AGENTS.md") {
20016
+ if (AGENT_FILES2.includes(destFilename)) {
20015
20017
  copiedAgentFiles.push(destFilename);
20016
20018
  }
20017
20019
  continue;
@@ -20021,7 +20023,7 @@ async function copyWorkspaceFiles(sourcePath, workspacePath, files, options2 = {
20021
20023
  const content = await readFile3(srcPath, "utf-8");
20022
20024
  await writeFile(destPath, content, "utf-8");
20023
20025
  results.push({ source: srcPath, destination: destPath, action: "copied" });
20024
- if (destFilename === "CLAUDE.md" || destFilename === "AGENTS.md") {
20026
+ if (AGENT_FILES2.includes(destFilename)) {
20025
20027
  copiedAgentFiles.push(destFilename);
20026
20028
  }
20027
20029
  } catch (error) {
@@ -20033,19 +20035,19 @@ async function copyWorkspaceFiles(sourcePath, workspacePath, files, options2 = {
20033
20035
  });
20034
20036
  }
20035
20037
  }
20036
- const firstAgentFile = copiedAgentFiles[0];
20037
- if (firstAgentFile && !dryRun) {
20038
- const targetFile = copiedAgentFiles.includes("AGENTS.md") ? "AGENTS.md" : firstAgentFile;
20039
- const targetPath = join4(workspacePath, targetFile);
20040
- try {
20041
- await injectWorkspaceRules(targetPath);
20042
- } catch (error) {
20043
- results.push({
20044
- source: "WORKSPACE-RULES",
20045
- destination: targetPath,
20046
- action: "failed",
20047
- error: error instanceof Error ? error.message : "Failed to inject WORKSPACE-RULES"
20048
- });
20038
+ if (!dryRun) {
20039
+ for (const agentFile of copiedAgentFiles) {
20040
+ const targetPath = join4(workspacePath, agentFile);
20041
+ try {
20042
+ await injectWorkspaceRules(targetPath);
20043
+ } catch (error) {
20044
+ results.push({
20045
+ source: "WORKSPACE-RULES",
20046
+ destination: targetPath,
20047
+ action: "failed",
20048
+ error: error instanceof Error ? error.message : "Failed to inject WORKSPACE-RULES"
20049
+ });
20050
+ }
20049
20051
  }
20050
20052
  }
20051
20053
  return results;
@@ -20544,7 +20546,7 @@ async function copyValidatedPlugin(validatedPlugin, workspacePath, clients, dryR
20544
20546
  };
20545
20547
  }
20546
20548
  async function syncWorkspace(workspacePath = process.cwd(), options2 = {}) {
20547
- const { force = false, dryRun = false } = options2;
20549
+ const { force = false, dryRun = false, workspaceSourceBase } = options2;
20548
20550
  const configDir = join7(workspacePath, CONFIG_DIR);
20549
20551
  const configPath = join7(configDir, WORKSPACE_CONFIG_FILE);
20550
20552
  if (!existsSync6(configPath)) {
@@ -20576,7 +20578,8 @@ async function syncWorkspace(workspacePath = process.cwd(), options2 = {}) {
20576
20578
  const validatedPlugins = await validateAllPlugins(config.plugins, workspacePath, force);
20577
20579
  let validatedWorkspaceSource = null;
20578
20580
  if (config.workspace?.source) {
20579
- validatedWorkspaceSource = await validatePlugin(config.workspace.source, workspacePath, force);
20581
+ const sourceBasePath = workspaceSourceBase ?? workspacePath;
20582
+ validatedWorkspaceSource = await validatePlugin(config.workspace.source, sourceBasePath, force);
20580
20583
  if (!validatedWorkspaceSource.success) {
20581
20584
  return {
20582
20585
  success: false,
@@ -20621,7 +20624,23 @@ ${errors2}`
20621
20624
  const pluginResults = await Promise.all(validatedPlugins.map((validatedPlugin) => copyValidatedPlugin(validatedPlugin, workspacePath, config.clients, dryRun)));
20622
20625
  let workspaceFileResults = [];
20623
20626
  if (config.workspace && validatedWorkspaceSource) {
20624
- workspaceFileResults = await copyWorkspaceFiles(validatedWorkspaceSource.resolved, workspacePath, config.workspace.files, { dryRun });
20627
+ const sourcePath = validatedWorkspaceSource.resolved;
20628
+ const filesToCopy = [...config.workspace.files];
20629
+ for (const agentFile of AGENT_FILES) {
20630
+ const agentPath = join7(sourcePath, agentFile);
20631
+ if (existsSync6(agentPath) && !filesToCopy.includes(agentFile)) {
20632
+ filesToCopy.push(agentFile);
20633
+ }
20634
+ }
20635
+ workspaceFileResults = await copyWorkspaceFiles(sourcePath, workspacePath, filesToCopy, { dryRun });
20636
+ if (!dryRun && config.clients.includes("claude")) {
20637
+ const claudePath = join7(workspacePath, "CLAUDE.md");
20638
+ const agentsPath = join7(workspacePath, "AGENTS.md");
20639
+ const claudeExistsInSource = existsSync6(join7(sourcePath, "CLAUDE.md"));
20640
+ if (!claudeExistsInSource && existsSync6(agentsPath) && !existsSync6(claudePath)) {
20641
+ await copyFile(agentsPath, claudePath);
20642
+ }
20643
+ }
20625
20644
  }
20626
20645
  let totalCopied = 0;
20627
20646
  let totalFailed = 0;
@@ -20768,6 +20787,7 @@ async function initWorkspace(targetPath = ".", options2 = {}) {
20768
20787
  await mkdir5(absoluteTarget, { recursive: true });
20769
20788
  await mkdir5(configDir, { recursive: true });
20770
20789
  let workspaceYamlContent;
20790
+ let sourceDir;
20771
20791
  if (options2.from) {
20772
20792
  const fromPath = resolve5(options2.from);
20773
20793
  if (!existsSync7(fromPath)) {
@@ -20781,16 +20801,35 @@ async function initWorkspace(targetPath = ".", options2 = {}) {
20781
20801
  const rootPath = join8(fromPath, WORKSPACE_CONFIG_FILE);
20782
20802
  if (existsSync7(nestedPath)) {
20783
20803
  sourceYamlPath = nestedPath;
20804
+ sourceDir = fromPath;
20784
20805
  } else if (existsSync7(rootPath)) {
20785
20806
  sourceYamlPath = rootPath;
20807
+ sourceDir = fromPath;
20786
20808
  } else {
20787
20809
  throw new Error(`No workspace.yaml found in: ${fromPath}
20788
20810
  Expected at: ${nestedPath} or ${rootPath}`);
20789
20811
  }
20790
20812
  } else {
20791
20813
  sourceYamlPath = fromPath;
20814
+ const parentDir = dirname5(fromPath);
20815
+ if (parentDir.endsWith(CONFIG_DIR)) {
20816
+ sourceDir = dirname5(parentDir);
20817
+ } else {
20818
+ sourceDir = parentDir;
20819
+ }
20792
20820
  }
20793
20821
  workspaceYamlContent = await readFile6(sourceYamlPath, "utf-8");
20822
+ if (sourceDir) {
20823
+ const parsed2 = load(workspaceYamlContent);
20824
+ const workspace = parsed2?.workspace;
20825
+ if (workspace?.source) {
20826
+ const source = workspace.source;
20827
+ if (!isGitHubUrl(source) && !isAbsolute2(source)) {
20828
+ workspace.source = resolve5(sourceDir, source);
20829
+ workspaceYamlContent = dump(parsed2, { lineWidth: -1 });
20830
+ }
20831
+ }
20832
+ }
20794
20833
  console.log(`✓ Using workspace.yaml from: ${sourceYamlPath}`);
20795
20834
  } else {
20796
20835
  const defaultYamlPath = join8(defaultTemplatePath, CONFIG_DIR, WORKSPACE_CONFIG_FILE);
@@ -20800,12 +20839,37 @@ async function initWorkspace(targetPath = ".", options2 = {}) {
20800
20839
  workspaceYamlContent = await readFile6(defaultYamlPath, "utf-8");
20801
20840
  }
20802
20841
  await writeFile4(configPath, workspaceYamlContent, "utf-8");
20803
- const targetAgentsPath = join8(absoluteTarget, "AGENTS.md");
20804
- await ensureWorkspaceRules(targetAgentsPath);
20842
+ const copiedAgentFiles = [];
20843
+ const effectiveSourceDir = sourceDir ?? defaultTemplatePath;
20844
+ for (const agentFile of AGENT_FILES) {
20845
+ const sourcePath = join8(effectiveSourceDir, agentFile);
20846
+ if (existsSync7(sourcePath)) {
20847
+ const content = await readFile6(sourcePath, "utf-8");
20848
+ await writeFile4(join8(absoluteTarget, agentFile), content, "utf-8");
20849
+ copiedAgentFiles.push(agentFile);
20850
+ }
20851
+ }
20852
+ if (copiedAgentFiles.length === 0) {
20853
+ await ensureWorkspaceRules(join8(absoluteTarget, "AGENTS.md"));
20854
+ copiedAgentFiles.push("AGENTS.md");
20855
+ } else {
20856
+ for (const agentFile of copiedAgentFiles) {
20857
+ await ensureWorkspaceRules(join8(absoluteTarget, agentFile));
20858
+ }
20859
+ }
20860
+ const parsed = load(workspaceYamlContent);
20861
+ const clients = parsed?.clients ?? [];
20862
+ if (clients.includes("claude") && !copiedAgentFiles.includes("CLAUDE.md") && copiedAgentFiles.includes("AGENTS.md")) {
20863
+ const agentsPath = join8(absoluteTarget, "AGENTS.md");
20864
+ const claudePath = join8(absoluteTarget, "CLAUDE.md");
20865
+ await copyFile2(agentsPath, claudePath);
20866
+ }
20805
20867
  console.log(`✓ Workspace created at: ${absoluteTarget}`);
20806
20868
  console.log(`
20807
20869
  Syncing plugins...`);
20808
- const syncResult = await syncWorkspace(absoluteTarget);
20870
+ const syncResult = await syncWorkspace(absoluteTarget, {
20871
+ ...sourceDir && { workspaceSourceBase: sourceDir }
20872
+ });
20809
20873
  if (!syncResult.success && syncResult.error) {
20810
20874
  if (!syncResult.error.includes("Plugin validation failed")) {
20811
20875
  console.log(` Note: ${syncResult.error}`);
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "allagents",
3
- "version": "0.2.1",
3
+ "version": "0.2.2",
4
4
  "description": "CLI tool for managing multi-repo AI agent workspaces with plugin synchronization",
5
5
  "type": "module",
6
6
  "bin": {