@fractary/codex-cli 0.10.4 → 0.10.7

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/dist/cli.js CHANGED
@@ -658,7 +658,7 @@ function validateGitHubName(name, type) {
658
658
  }
659
659
  }
660
660
  function getTempCodexPath(config) {
661
- const codexRepo = config.codex_repository || "codex";
661
+ const codexRepo = config.codex_repo || "codex";
662
662
  const sanitizedOrg = sanitizePathComponent(config.organization);
663
663
  const sanitizedRepo = sanitizePathComponent(codexRepo);
664
664
  return path5.join(
@@ -677,7 +677,7 @@ async function isValidGitRepo(repoPath) {
677
677
  }
678
678
  }
679
679
  function getCodexRepoUrl(config) {
680
- const codexRepo = config.codex_repository || "codex";
680
+ const codexRepo = config.codex_repo || "codex";
681
681
  validateGitHubName(config.organization, "organization");
682
682
  validateGitHubName(codexRepo, "repository");
683
683
  return `https://github.com/${config.organization}/${codexRepo}.git`;
@@ -1878,8 +1878,8 @@ function syncCommand() {
1878
1878
  };
1879
1879
  let plan;
1880
1880
  let routingScan;
1881
+ let codexRepoPath;
1881
1882
  if (direction === "from-codex") {
1882
- let codexRepoPath;
1883
1883
  try {
1884
1884
  const { ensureCodexCloned: ensureCodexCloned2 } = await Promise.resolve().then(() => (init_codex_repository(), codex_repository_exports));
1885
1885
  if (!options.json) {
@@ -1914,13 +1914,13 @@ function syncCommand() {
1914
1914
  console.log(chalk7.dim(" 1. Check file/directory permissions"));
1915
1915
  console.log(chalk7.dim(" 2. Ensure you have access to the repository"));
1916
1916
  } else if (error.message.includes("not found") || error.message.includes("does not exist")) {
1917
- console.log(chalk7.dim(` Repository not found: ${config.organization}/${config.codex_repository || "codex"}`));
1917
+ console.log(chalk7.dim(` Repository not found: ${config.organization}/${config.codex_repo || "codex"}`));
1918
1918
  console.log(chalk7.dim(" 1. Verify the repository exists on GitHub"));
1919
1919
  console.log(chalk7.dim(" 2. Check organization and repository names in config"));
1920
1920
  } else {
1921
1921
  console.log(chalk7.dim(" 1. Ensure git is installed: git --version"));
1922
1922
  console.log(chalk7.dim(" 2. Check GitHub auth: gh auth status"));
1923
- console.log(chalk7.dim(` 3. Verify repo exists: ${config.organization}/${config.codex_repository || "codex"}`));
1923
+ console.log(chalk7.dim(` 3. Verify repo exists: ${config.organization}/${config.codex_repo || "codex"}`));
1924
1924
  }
1925
1925
  process.exit(1);
1926
1926
  }
@@ -1933,14 +1933,32 @@ function syncCommand() {
1933
1933
  plan = planWithRouting;
1934
1934
  routingScan = planWithRouting.routingScan;
1935
1935
  } else {
1936
+ try {
1937
+ const { ensureCodexCloned: ensureCodexCloned2 } = await Promise.resolve().then(() => (init_codex_repository(), codex_repository_exports));
1938
+ if (!options.json) {
1939
+ console.log(chalk7.blue("\u2139 Cloning/updating codex repository..."));
1940
+ }
1941
+ codexRepoPath = await ensureCodexCloned2(config, {
1942
+ branch: targetBranch
1943
+ });
1944
+ if (!options.json) {
1945
+ console.log(chalk7.dim(` Codex cloned to: ${codexRepoPath}`));
1946
+ }
1947
+ } catch (error) {
1948
+ console.error(chalk7.red("Error:"), "Failed to clone codex repository");
1949
+ console.error(chalk7.dim(` ${error.message}`));
1950
+ process.exit(1);
1951
+ }
1936
1952
  plan = await syncManager.createPlan(
1937
1953
  config.organization,
1938
1954
  projectName,
1939
1955
  sourceDir,
1940
1956
  [],
1941
- // Empty target - we don't scan codex for to-codex direction
1957
+ // Empty target - treat all files as creates
1942
1958
  syncOptions
1943
1959
  );
1960
+ plan.source = sourceDir;
1961
+ plan.target = path5.join(codexRepoPath, config.organization, projectName);
1944
1962
  }
1945
1963
  if (plan.totalFiles === 0) {
1946
1964
  if (options.json) {
@@ -2058,6 +2076,25 @@ Total: ${plan.totalFiles} files (${formatBytes(plan.totalBytes)})`));
2058
2076
  const startTime = Date.now();
2059
2077
  const result = await syncManager.executePlan(plan, syncOptions);
2060
2078
  const duration = Date.now() - startTime;
2079
+ if (direction === "to-codex" && codexRepoPath && result.synced > 0) {
2080
+ try {
2081
+ if (!options.json) {
2082
+ console.log(chalk7.blue("Committing and pushing to codex..."));
2083
+ }
2084
+ const { RepoManager } = await import('@fractary/core/repo');
2085
+ const repoManager = new RepoManager({}, codexRepoPath);
2086
+ await repoManager.stageAll();
2087
+ await repoManager.commit({
2088
+ message: `Sync ${result.synced} files from ${projectName}`
2089
+ });
2090
+ await repoManager.push({});
2091
+ if (!options.json) {
2092
+ console.log(chalk7.dim(" Changes pushed to codex repository"));
2093
+ }
2094
+ } catch (error) {
2095
+ console.error(chalk7.red("Error pushing to codex:"), error.message);
2096
+ }
2097
+ }
2061
2098
  console.log("");
2062
2099
  if (result.success) {
2063
2100
  console.log(chalk7.green(`\u2713 Sync completed successfully`));