@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.cjs CHANGED
@@ -691,7 +691,7 @@ function validateGitHubName(name, type) {
691
691
  }
692
692
  }
693
693
  function getTempCodexPath(config) {
694
- const codexRepo = config.codex_repository || "codex";
694
+ const codexRepo = config.codex_repo || "codex";
695
695
  const sanitizedOrg = sanitizePathComponent(config.organization);
696
696
  const sanitizedRepo = sanitizePathComponent(codexRepo);
697
697
  return path4__namespace.join(
@@ -710,7 +710,7 @@ async function isValidGitRepo(repoPath) {
710
710
  }
711
711
  }
712
712
  function getCodexRepoUrl(config) {
713
- const codexRepo = config.codex_repository || "codex";
713
+ const codexRepo = config.codex_repo || "codex";
714
714
  validateGitHubName(config.organization, "organization");
715
715
  validateGitHubName(codexRepo, "repository");
716
716
  return `https://github.com/${config.organization}/${codexRepo}.git`;
@@ -1911,8 +1911,8 @@ function syncCommand() {
1911
1911
  };
1912
1912
  let plan;
1913
1913
  let routingScan;
1914
+ let codexRepoPath;
1914
1915
  if (direction === "from-codex") {
1915
- let codexRepoPath;
1916
1916
  try {
1917
1917
  const { ensureCodexCloned: ensureCodexCloned2 } = await Promise.resolve().then(() => (init_codex_repository(), codex_repository_exports));
1918
1918
  if (!options.json) {
@@ -1947,13 +1947,13 @@ function syncCommand() {
1947
1947
  console.log(chalk7__default.default.dim(" 1. Check file/directory permissions"));
1948
1948
  console.log(chalk7__default.default.dim(" 2. Ensure you have access to the repository"));
1949
1949
  } else if (error.message.includes("not found") || error.message.includes("does not exist")) {
1950
- console.log(chalk7__default.default.dim(` Repository not found: ${config.organization}/${config.codex_repository || "codex"}`));
1950
+ console.log(chalk7__default.default.dim(` Repository not found: ${config.organization}/${config.codex_repo || "codex"}`));
1951
1951
  console.log(chalk7__default.default.dim(" 1. Verify the repository exists on GitHub"));
1952
1952
  console.log(chalk7__default.default.dim(" 2. Check organization and repository names in config"));
1953
1953
  } else {
1954
1954
  console.log(chalk7__default.default.dim(" 1. Ensure git is installed: git --version"));
1955
1955
  console.log(chalk7__default.default.dim(" 2. Check GitHub auth: gh auth status"));
1956
- console.log(chalk7__default.default.dim(` 3. Verify repo exists: ${config.organization}/${config.codex_repository || "codex"}`));
1956
+ console.log(chalk7__default.default.dim(` 3. Verify repo exists: ${config.organization}/${config.codex_repo || "codex"}`));
1957
1957
  }
1958
1958
  process.exit(1);
1959
1959
  }
@@ -1966,14 +1966,32 @@ function syncCommand() {
1966
1966
  plan = planWithRouting;
1967
1967
  routingScan = planWithRouting.routingScan;
1968
1968
  } else {
1969
+ try {
1970
+ const { ensureCodexCloned: ensureCodexCloned2 } = await Promise.resolve().then(() => (init_codex_repository(), codex_repository_exports));
1971
+ if (!options.json) {
1972
+ console.log(chalk7__default.default.blue("\u2139 Cloning/updating codex repository..."));
1973
+ }
1974
+ codexRepoPath = await ensureCodexCloned2(config, {
1975
+ branch: targetBranch
1976
+ });
1977
+ if (!options.json) {
1978
+ console.log(chalk7__default.default.dim(` Codex cloned to: ${codexRepoPath}`));
1979
+ }
1980
+ } catch (error) {
1981
+ console.error(chalk7__default.default.red("Error:"), "Failed to clone codex repository");
1982
+ console.error(chalk7__default.default.dim(` ${error.message}`));
1983
+ process.exit(1);
1984
+ }
1969
1985
  plan = await syncManager.createPlan(
1970
1986
  config.organization,
1971
1987
  projectName,
1972
1988
  sourceDir,
1973
1989
  [],
1974
- // Empty target - we don't scan codex for to-codex direction
1990
+ // Empty target - treat all files as creates
1975
1991
  syncOptions
1976
1992
  );
1993
+ plan.source = sourceDir;
1994
+ plan.target = path4__namespace.join(codexRepoPath, config.organization, projectName);
1977
1995
  }
1978
1996
  if (plan.totalFiles === 0) {
1979
1997
  if (options.json) {
@@ -2091,6 +2109,25 @@ Total: ${plan.totalFiles} files (${formatBytes(plan.totalBytes)})`));
2091
2109
  const startTime = Date.now();
2092
2110
  const result = await syncManager.executePlan(plan, syncOptions);
2093
2111
  const duration = Date.now() - startTime;
2112
+ if (direction === "to-codex" && codexRepoPath && result.synced > 0) {
2113
+ try {
2114
+ if (!options.json) {
2115
+ console.log(chalk7__default.default.blue("Committing and pushing to codex..."));
2116
+ }
2117
+ const { RepoManager } = await import('@fractary/core/repo');
2118
+ const repoManager = new RepoManager({}, codexRepoPath);
2119
+ await repoManager.stageAll();
2120
+ await repoManager.commit({
2121
+ message: `Sync ${result.synced} files from ${projectName}`
2122
+ });
2123
+ await repoManager.push({});
2124
+ if (!options.json) {
2125
+ console.log(chalk7__default.default.dim(" Changes pushed to codex repository"));
2126
+ }
2127
+ } catch (error) {
2128
+ console.error(chalk7__default.default.red("Error pushing to codex:"), error.message);
2129
+ }
2130
+ }
2094
2131
  console.log("");
2095
2132
  if (result.success) {
2096
2133
  console.log(chalk7__default.default.green(`\u2713 Sync completed successfully`));