@fractary/codex-cli 0.10.3 → 0.10.6

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
@@ -1830,13 +1830,16 @@ function syncCommand() {
1830
1830
  }
1831
1831
  const { createSyncManager, createLocalStorage, detectCurrentProject } = await import('@fractary/codex');
1832
1832
  let projectName = name;
1833
+ if (!projectName) {
1834
+ projectName = config.project || void 0;
1835
+ }
1833
1836
  if (!projectName) {
1834
1837
  const detected = detectCurrentProject();
1835
1838
  projectName = detected.project || void 0;
1836
1839
  }
1837
1840
  if (!projectName) {
1838
1841
  console.error(chalk7__default.default.red("Error:"), "Could not determine project name.");
1839
- console.log(chalk7__default.default.dim("Provide project name as argument or run from a git repository."));
1842
+ console.log(chalk7__default.default.dim("Provide project name as argument, set codex.project in config, or run from a git repository."));
1840
1843
  process.exit(1);
1841
1844
  }
1842
1845
  const validDirections = ["to-codex", "from-codex", "bidirectional"];
@@ -1902,12 +1905,14 @@ function syncCommand() {
1902
1905
  dryRun: options.dryRun,
1903
1906
  force: options.force,
1904
1907
  include: includePatterns,
1905
- exclude: excludePatterns
1908
+ exclude: excludePatterns,
1909
+ // Pass pre-matched files to SDK (bypasses SDK's internal non-recursive scanning)
1910
+ sourceFiles: targetFiles
1906
1911
  };
1907
1912
  let plan;
1908
1913
  let routingScan;
1914
+ let codexRepoPath;
1909
1915
  if (direction === "from-codex") {
1910
- let codexRepoPath;
1911
1916
  try {
1912
1917
  const { ensureCodexCloned: ensureCodexCloned2 } = await Promise.resolve().then(() => (init_codex_repository(), codex_repository_exports));
1913
1918
  if (!options.json) {
@@ -1961,13 +1966,32 @@ function syncCommand() {
1961
1966
  plan = planWithRouting;
1962
1967
  routingScan = planWithRouting.routingScan;
1963
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
+ }
1964
1985
  plan = await syncManager.createPlan(
1965
1986
  config.organization,
1966
1987
  projectName,
1967
1988
  sourceDir,
1968
- targetFiles,
1989
+ [],
1990
+ // Empty target - treat all files as creates
1969
1991
  syncOptions
1970
1992
  );
1993
+ plan.source = sourceDir;
1994
+ plan.target = path4__namespace.join(codexRepoPath, config.organization, projectName);
1971
1995
  }
1972
1996
  if (plan.totalFiles === 0) {
1973
1997
  if (options.json) {
@@ -2085,6 +2109,25 @@ Total: ${plan.totalFiles} files (${formatBytes(plan.totalBytes)})`));
2085
2109
  const startTime = Date.now();
2086
2110
  const result = await syncManager.executePlan(plan, syncOptions);
2087
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
+ }
2088
2131
  console.log("");
2089
2132
  if (result.success) {
2090
2133
  console.log(chalk7__default.default.green(`\u2713 Sync completed successfully`));