@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.js CHANGED
@@ -1797,13 +1797,16 @@ function syncCommand() {
1797
1797
  }
1798
1798
  const { createSyncManager, createLocalStorage, detectCurrentProject } = await import('@fractary/codex');
1799
1799
  let projectName = name;
1800
+ if (!projectName) {
1801
+ projectName = config.project || void 0;
1802
+ }
1800
1803
  if (!projectName) {
1801
1804
  const detected = detectCurrentProject();
1802
1805
  projectName = detected.project || void 0;
1803
1806
  }
1804
1807
  if (!projectName) {
1805
1808
  console.error(chalk7.red("Error:"), "Could not determine project name.");
1806
- console.log(chalk7.dim("Provide project name as argument or run from a git repository."));
1809
+ console.log(chalk7.dim("Provide project name as argument, set codex.project in config, or run from a git repository."));
1807
1810
  process.exit(1);
1808
1811
  }
1809
1812
  const validDirections = ["to-codex", "from-codex", "bidirectional"];
@@ -1869,12 +1872,14 @@ function syncCommand() {
1869
1872
  dryRun: options.dryRun,
1870
1873
  force: options.force,
1871
1874
  include: includePatterns,
1872
- exclude: excludePatterns
1875
+ exclude: excludePatterns,
1876
+ // Pass pre-matched files to SDK (bypasses SDK's internal non-recursive scanning)
1877
+ sourceFiles: targetFiles
1873
1878
  };
1874
1879
  let plan;
1875
1880
  let routingScan;
1881
+ let codexRepoPath;
1876
1882
  if (direction === "from-codex") {
1877
- let codexRepoPath;
1878
1883
  try {
1879
1884
  const { ensureCodexCloned: ensureCodexCloned2 } = await Promise.resolve().then(() => (init_codex_repository(), codex_repository_exports));
1880
1885
  if (!options.json) {
@@ -1928,13 +1933,32 @@ function syncCommand() {
1928
1933
  plan = planWithRouting;
1929
1934
  routingScan = planWithRouting.routingScan;
1930
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
+ }
1931
1952
  plan = await syncManager.createPlan(
1932
1953
  config.organization,
1933
1954
  projectName,
1934
1955
  sourceDir,
1935
- targetFiles,
1956
+ [],
1957
+ // Empty target - treat all files as creates
1936
1958
  syncOptions
1937
1959
  );
1960
+ plan.source = sourceDir;
1961
+ plan.target = path5.join(codexRepoPath, config.organization, projectName);
1938
1962
  }
1939
1963
  if (plan.totalFiles === 0) {
1940
1964
  if (options.json) {
@@ -2052,6 +2076,25 @@ Total: ${plan.totalFiles} files (${formatBytes(plan.totalBytes)})`));
2052
2076
  const startTime = Date.now();
2053
2077
  const result = await syncManager.executePlan(plan, syncOptions);
2054
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
+ }
2055
2098
  console.log("");
2056
2099
  if (result.success) {
2057
2100
  console.log(chalk7.green(`\u2713 Sync completed successfully`));