osborn 0.9.19 → 0.9.20
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.js +19 -7
- package/package.json +1 -1
package/dist/index.js
CHANGED
|
@@ -397,9 +397,22 @@ function startApiServer(workingDir, port) {
|
|
|
397
397
|
const destSlug = join(projectsDir, effectiveSlug);
|
|
398
398
|
mkdirSync(destSlug, { recursive: true });
|
|
399
399
|
const sourceSlugPath = join(effectiveSource, sourceSlug);
|
|
400
|
-
|
|
400
|
+
// Always rewrite EVERY `"cwd":"<anything>"` to the target workspace dir
|
|
401
|
+
// when targetWorkDir is provided. Earlier version tried to derive the
|
|
402
|
+
// source cwd from the slug name via dash-to-slash substitution, but
|
|
403
|
+
// slug encoding is ambiguous (hyphens in path components like
|
|
404
|
+
// `codespaces-blank` get expanded into directory boundaries). That
|
|
405
|
+
// version only caught the canonical sprite cwd and missed laptop +
|
|
406
|
+
// codespaces references inside the JSONL bodies. Migration test on
|
|
407
|
+
// bj2zgt → fly machine found 12 files still pointing at /Users/...
|
|
408
|
+
// or /workspaces/codespaces-blank after the old rewrite. The brute-
|
|
409
|
+
// force regex below is bulletproof: any `cwd` reference becomes the
|
|
410
|
+
// runtime workspace dir, period.
|
|
401
411
|
const destCwd = targetWorkDir ?? slugToCwd(effectiveSlug);
|
|
402
|
-
const needsCwdRewrite =
|
|
412
|
+
const needsCwdRewrite = !!targetWorkDir;
|
|
413
|
+
void sourceSlugPath; // silence linter — used below in walk
|
|
414
|
+
const cwdRewriteRe = /"cwd":"[^"]*"/g;
|
|
415
|
+
const cwdReplacement = `"cwd":"${destCwd}"`;
|
|
403
416
|
// Walk the source slug directory and copy files individually so we can:
|
|
404
417
|
// (a) skip AppleDouble per-file too (in case nested)
|
|
405
418
|
// (b) rewrite cwd inside .jsonl files when remapping across workspaces
|
|
@@ -432,12 +445,11 @@ function startApiServer(workingDir, port) {
|
|
|
432
445
|
if (!shouldWrite)
|
|
433
446
|
continue;
|
|
434
447
|
if (needsCwdRewrite && e.name.endsWith('.jsonl')) {
|
|
435
|
-
//
|
|
436
|
-
//
|
|
448
|
+
// Regex-rewrite every `"cwd":"<anything>"` → target. Catches all
|
|
449
|
+
// possible source cwds in one pass (laptop, codespaces, sprite,
|
|
450
|
+
// etc.) without depending on slug-derived heuristics.
|
|
437
451
|
const content = readFileSync(sp, 'utf8');
|
|
438
|
-
const
|
|
439
|
-
const replace = `"cwd":"${destCwd}"`;
|
|
440
|
-
const rewritten = content.split(find).join(replace);
|
|
452
|
+
const rewritten = content.replace(cwdRewriteRe, cwdReplacement);
|
|
441
453
|
writeFileSync(dp, rewritten);
|
|
442
454
|
}
|
|
443
455
|
else {
|