@fractary/codex 0.5.1 → 0.5.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.
package/dist/index.cjs CHANGED
@@ -3115,16 +3115,19 @@ var SyncManager = class {
3115
3115
  };
3116
3116
  const plan = createSyncPlan(sourceFiles, targetFiles, planOptions, this.config);
3117
3117
  plan.estimatedTime = estimateSyncTime(plan);
3118
+ plan.source = codexDir;
3119
+ plan.target = ".fractary/codex/cache";
3118
3120
  return {
3119
3121
  ...plan,
3120
3122
  routingScan
3121
3123
  };
3122
3124
  }
3123
3125
  /**
3124
- * Execute a sync plan (dry run)
3126
+ * Execute a sync plan
3125
3127
  *
3126
- * In a real implementation, this would actually copy files.
3127
- * For the SDK, we provide the plan and let consumers execute.
3128
+ * Copies files from source to target based on the plan.
3129
+ * For from-codex syncs, files are copied to .fractary/codex/cache/ preserving full paths.
3130
+ * For to-codex syncs, files are copied to the codex repository.
3128
3131
  */
3129
3132
  async executePlan(plan, options) {
3130
3133
  const startTime = Date.now();
@@ -3150,7 +3153,30 @@ var SyncManager = class {
3150
3153
  if (options?.onProgress) {
3151
3154
  options.onProgress(i + 1, plan.totalFiles, file.path);
3152
3155
  }
3153
- synced++;
3156
+ if (file.operation === "create" || file.operation === "update") {
3157
+ const sourcePath = `${plan.source}/${file.path}`;
3158
+ const targetPath = `${plan.target}/${file.path}`;
3159
+ const fs4 = await import('fs/promises');
3160
+ const path6 = await import('path');
3161
+ const targetDir = path6.dirname(targetPath);
3162
+ await fs4.mkdir(targetDir, { recursive: true });
3163
+ await fs4.copyFile(sourcePath, targetPath);
3164
+ synced++;
3165
+ } else if (file.operation === "delete") {
3166
+ const targetPath = `${plan.target}/${file.path}`;
3167
+ const fs4 = await import('fs/promises');
3168
+ try {
3169
+ await fs4.unlink(targetPath);
3170
+ synced++;
3171
+ } catch (error) {
3172
+ if (error.code !== "ENOENT") {
3173
+ throw error;
3174
+ }
3175
+ synced++;
3176
+ }
3177
+ } else {
3178
+ synced++;
3179
+ }
3154
3180
  } catch (error) {
3155
3181
  failed++;
3156
3182
  errors.push({