@prover-coder-ai/context-doc 1.0.9 → 1.0.10

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.
@@ -96,6 +96,17 @@ const selectRelevantFiles = (files, locator) => Effect.reduce(files, [], (acc, f
96
96
  }
97
97
  return acc;
98
98
  })));
99
+ const resolveLocator = (options) => pipe(readRepositoryUrl(options.cwd, options.repositoryUrlOverride), Effect.map((repositoryUrl) => buildProjectLocator(repositoryUrl, options.cwd)), Effect.catchAll(() => Effect.gen(function* (__) {
100
+ yield* __(Console.log("Codex repository url missing; falling back to cwd-only match"));
101
+ return buildProjectLocator(options.cwd, options.cwd);
102
+ })));
103
+ const copyCodexFiles = (sourceDir, destinationDir, locator) => Effect.gen(function* (_) {
104
+ yield* _(ensureDirectory(destinationDir));
105
+ const allJsonlFiles = yield* _(collectJsonlFiles(sourceDir));
106
+ const relevantFiles = yield* _(selectRelevantFiles(allJsonlFiles, locator));
107
+ yield* _(Effect.forEach(relevantFiles, (filePath) => copyRelevantFile(sourceDir, destinationDir, filePath)));
108
+ yield* _(Console.log(`Codex: copied ${relevantFiles.length} files from ${sourceDir} to ${destinationDir}`));
109
+ });
99
110
  // CHANGE: Extract Codex dialog sync into dedicated module for clarity.
100
111
  // WHY: Separate Codex-specific shell effects from other sync flows.
101
112
  // QUOTE(ТЗ): "вынеси в отдельный файл"
@@ -107,17 +118,12 @@ const selectRelevantFiles = (files, locator) => Effect.reduce(files, [], (acc, f
107
118
  // INVARIANT: ∀f ∈ copiedFiles: linesMatchProject(f, locator)
108
119
  // COMPLEXITY: O(n) time / O(n) space, n = |files|
109
120
  export const syncCodex = (options) => Effect.gen(function* (_) {
110
- const repositoryUrl = yield* _(readRepositoryUrl(options.cwd, options.repositoryUrlOverride));
121
+ const locator = yield* _(resolveLocator(options));
111
122
  const sourceDir = yield* _(resolveSourceDir(options.cwd, options.sourceDir, options.metaRoot));
112
123
  const destinationDir = options.destinationDir ?? path.join(options.cwd, ".knowledge", ".codex");
113
124
  if (path.resolve(sourceDir) === path.resolve(destinationDir)) {
114
125
  yield* _(Console.log("Codex source equals destination; skipping copy to avoid duplicates"));
115
126
  return;
116
127
  }
117
- yield* _(ensureDirectory(destinationDir));
118
- const locator = buildProjectLocator(repositoryUrl, options.cwd);
119
- const allJsonlFiles = yield* _(collectJsonlFiles(sourceDir));
120
- const relevantFiles = yield* _(selectRelevantFiles(allJsonlFiles, locator));
121
- yield* _(Effect.forEach(relevantFiles, (filePath) => copyRelevantFile(sourceDir, destinationDir, filePath)));
122
- yield* _(Console.log(`Codex: copied ${relevantFiles.length} files from ${sourceDir} to ${destinationDir}`));
128
+ yield* _(copyCodexFiles(sourceDir, destinationDir, locator));
123
129
  }).pipe(Effect.catchAll((error) => Console.log(`Codex source not found; skipped syncing Codex dialog files (${error.reason})`)));
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@prover-coder-ai/context-doc",
3
- "version": "1.0.9",
3
+ "version": "1.0.10",
4
4
  "description": "",
5
5
  "type": "module",
6
6
  "scripts": {
@@ -155,6 +155,47 @@ const selectRelevantFiles = (
155
155
  ),
156
156
  );
157
157
 
158
+ const resolveLocator = (
159
+ options: SyncOptions,
160
+ ): Effect.Effect<ProjectLocator, SyncError> =>
161
+ pipe(
162
+ readRepositoryUrl(options.cwd, options.repositoryUrlOverride),
163
+ Effect.map((repositoryUrl) =>
164
+ buildProjectLocator(repositoryUrl, options.cwd),
165
+ ),
166
+ Effect.catchAll(() =>
167
+ Effect.gen(function* (__) {
168
+ yield* __(
169
+ Console.log(
170
+ "Codex repository url missing; falling back to cwd-only match",
171
+ ),
172
+ );
173
+ return buildProjectLocator(options.cwd, options.cwd);
174
+ }),
175
+ ),
176
+ );
177
+
178
+ const copyCodexFiles = (
179
+ sourceDir: string,
180
+ destinationDir: string,
181
+ locator: ProjectLocator,
182
+ ): Effect.Effect<void, SyncError> =>
183
+ Effect.gen(function* (_) {
184
+ yield* _(ensureDirectory(destinationDir));
185
+ const allJsonlFiles = yield* _(collectJsonlFiles(sourceDir));
186
+ const relevantFiles = yield* _(selectRelevantFiles(allJsonlFiles, locator));
187
+ yield* _(
188
+ Effect.forEach(relevantFiles, (filePath) =>
189
+ copyRelevantFile(sourceDir, destinationDir, filePath),
190
+ ),
191
+ );
192
+ yield* _(
193
+ Console.log(
194
+ `Codex: copied ${relevantFiles.length} files from ${sourceDir} to ${destinationDir}`,
195
+ ),
196
+ );
197
+ });
198
+
158
199
  // CHANGE: Extract Codex dialog sync into dedicated module for clarity.
159
200
  // WHY: Separate Codex-specific shell effects from other sync flows.
160
201
  // QUOTE(ТЗ): "вынеси в отдельный файл"
@@ -169,9 +210,7 @@ export const syncCodex = (
169
210
  options: SyncOptions,
170
211
  ): Effect.Effect<void, SyncError> =>
171
212
  Effect.gen(function* (_) {
172
- const repositoryUrl = yield* _(
173
- readRepositoryUrl(options.cwd, options.repositoryUrlOverride),
174
- );
213
+ const locator = yield* _(resolveLocator(options));
175
214
  const sourceDir = yield* _(
176
215
  resolveSourceDir(options.cwd, options.sourceDir, options.metaRoot),
177
216
  );
@@ -187,23 +226,7 @@ export const syncCodex = (
187
226
  return;
188
227
  }
189
228
 
190
- yield* _(ensureDirectory(destinationDir));
191
-
192
- const locator = buildProjectLocator(repositoryUrl, options.cwd);
193
- const allJsonlFiles = yield* _(collectJsonlFiles(sourceDir));
194
- const relevantFiles = yield* _(selectRelevantFiles(allJsonlFiles, locator));
195
-
196
- yield* _(
197
- Effect.forEach(relevantFiles, (filePath) =>
198
- copyRelevantFile(sourceDir, destinationDir, filePath),
199
- ),
200
- );
201
-
202
- yield* _(
203
- Console.log(
204
- `Codex: copied ${relevantFiles.length} files from ${sourceDir} to ${destinationDir}`,
205
- ),
206
- );
229
+ yield* _(copyCodexFiles(sourceDir, destinationDir, locator));
207
230
  }).pipe(
208
231
  Effect.catchAll((error) =>
209
232
  Console.log(