replicas-engine 0.1.253 → 0.1.254

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.
Files changed (2) hide show
  1. package/dist/src/index.js +29 -20
  2. package/package.json +1 -1
package/dist/src/index.js CHANGED
@@ -297,7 +297,7 @@ var WORKSPACE_SIZES = ["small", "large"];
297
297
  var INVALID_WORKSPACE_SIZE_ERROR = `Invalid size: must be one of ${WORKSPACE_SIZES.join(", ")}`;
298
298
 
299
299
  // ../shared/src/e2b.ts
300
- var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-06-02-v3";
300
+ var E2B_TEMPLATE_NAME = "replicas-sandbox-2026-06-02-v4";
301
301
 
302
302
  // ../shared/src/runtime-env.ts
303
303
  function parsePosixEnvFile(content) {
@@ -2728,7 +2728,7 @@ var codexTokenManager = new CodexTokenManager();
2728
2728
 
2729
2729
  // src/git/service.ts
2730
2730
  import { readdir, stat } from "fs/promises";
2731
- import { existsSync as existsSync2, unlinkSync } from "fs";
2731
+ import { existsSync as existsSync2, readFileSync as readFileSync3, unlinkSync } from "fs";
2732
2732
  import { execFileSync as execFileSync2, spawnSync } from "child_process";
2733
2733
  import { join as join5 } from "path";
2734
2734
 
@@ -2937,27 +2937,21 @@ var GitService = class {
2937
2937
  }
2938
2938
  async listRepos(options) {
2939
2939
  const includeDiffs = options?.includeDiffs === true;
2940
- if (includeDiffs) {
2941
- const repos2 = await this.refreshRepos();
2942
- return repos2.map((repo) => ({
2943
- ...repo,
2944
- gitDiff: repo.gitDiff ? { ...repo.gitDiff, fullDiff: this.getFullGitDiff(repo.path, repo.defaultBranch) } : null
2945
- }));
2946
- }
2947
2940
  const repos = await this.listRepositories();
2948
2941
  const states = [];
2949
2942
  for (const repo of repos) {
2950
2943
  try {
2951
2944
  const persistedState = await loadRepoState(repo.name);
2952
2945
  const currentBranch = getCurrentBranch(repo.path) ?? repo.defaultBranch;
2953
- const persistedMatchesCurrentBranch = persistedState?.currentBranch === currentBranch;
2946
+ const gitDiff = this.getGitDiffStats(repo.path, repo.defaultBranch);
2954
2947
  states.push({
2955
2948
  name: repo.name,
2956
2949
  path: repo.path,
2957
2950
  defaultBranch: repo.defaultBranch,
2958
2951
  currentBranch,
2959
2952
  prUrls: persistedState?.prUrls ?? [],
2960
- gitDiff: persistedMatchesCurrentBranch ? persistedState.gitDiff : null,
2953
+ // fullDiff may be empty if the diff subprocess fails.
2954
+ gitDiff: includeDiffs && gitDiff ? { ...gitDiff, fullDiff: this.getFullGitDiff(repo.path, repo.defaultBranch) } : gitDiff,
2961
2955
  startHooksCompleted: persistedState?.startHooksCompleted ?? false
2962
2956
  });
2963
2957
  } catch {
@@ -3120,17 +3114,20 @@ var GitService = class {
3120
3114
  return null;
3121
3115
  }
3122
3116
  }
3123
- getUntrackedDiff(repoPath, extraFlags = []) {
3117
+ listUntrackedPaths(repoPath) {
3124
3118
  const listing = execFileSync2("git", ["ls-files", "--others", "--exclude-standard", "-z"], {
3125
3119
  cwd: repoPath,
3126
3120
  encoding: "utf-8",
3127
3121
  stdio: ["pipe", "pipe", "pipe"]
3128
3122
  });
3129
- const paths = listing.split("\0").filter(Boolean);
3123
+ return listing.split("\0").filter(Boolean);
3124
+ }
3125
+ getUntrackedDiff(repoPath) {
3126
+ const paths = this.listUntrackedPaths(repoPath);
3130
3127
  if (paths.length === 0) return "";
3131
3128
  try {
3132
3129
  execFileSync2("git", ["add", "--intent-to-add", "--", ...paths], { cwd: repoPath, stdio: ["pipe", "pipe", "pipe"] });
3133
- const result = spawnSync("git", ["diff", ...extraFlags, "--", ...paths], {
3130
+ const result = spawnSync("git", ["diff", "--", ...paths], {
3134
3131
  cwd: repoPath,
3135
3132
  encoding: "utf-8",
3136
3133
  maxBuffer: 50 * 1024 * 1024
@@ -3145,9 +3142,21 @@ var GitService = class {
3145
3142
  }
3146
3143
  countUntrackedAddedLines(repoPath) {
3147
3144
  try {
3148
- const output = this.getUntrackedDiff(repoPath, ["--shortstat"]);
3149
- const match = output.match(/(\d+) insertion/);
3150
- return match ? parseInt(match[1], 10) : 0;
3145
+ return this.listUntrackedPaths(repoPath).reduce((total, path4) => {
3146
+ try {
3147
+ const contents = readFileSync3(join5(repoPath, path4));
3148
+ if (contents.length === 0 || contents.includes(0)) {
3149
+ return total;
3150
+ }
3151
+ let lines = 0;
3152
+ for (const byte of contents) {
3153
+ if (byte === 10) lines += 1;
3154
+ }
3155
+ return total + lines + (contents[contents.length - 1] === 10 ? 0 : 1);
3156
+ } catch {
3157
+ return total;
3158
+ }
3159
+ }, 0);
3151
3160
  } catch (error) {
3152
3161
  console.error("Error counting untracked added lines:", error);
3153
3162
  return 0;
@@ -6222,7 +6231,7 @@ var AspClient = class {
6222
6231
  // src/managers/codex-asp/app-server-process.ts
6223
6232
  var DEFAULT_CODEX_BINARY = "codex";
6224
6233
  var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
6225
- var ENGINE_PACKAGE_VERSION = "0.1.253";
6234
+ var ENGINE_PACKAGE_VERSION = "0.1.254";
6226
6235
  var INITIALIZE_METHOD = "initialize";
6227
6236
  var INITIALIZED_NOTIFICATION = "initialized";
6228
6237
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -6489,7 +6498,7 @@ function isCodexAuthError(error) {
6489
6498
  }
6490
6499
 
6491
6500
  // src/managers/codex-asp/mappers.ts
6492
- import { existsSync as existsSync6, readFileSync as readFileSync3 } from "fs";
6501
+ import { existsSync as existsSync6, readFileSync as readFileSync4 } from "fs";
6493
6502
  var localImageCache = /* @__PURE__ */ new Map();
6494
6503
  var DEFAULT_MODEL = DEFAULT_CODEX_MODEL;
6495
6504
  var THREAD_START_METHOD = "thread/start";
@@ -6570,7 +6579,7 @@ function userImageForLocalPath(path4) {
6570
6579
  const image = {
6571
6580
  type: "image",
6572
6581
  mediaType: inferMediaType(path4),
6573
- data: readFileSync3(path4).toString("base64")
6582
+ data: readFileSync4(path4).toString("base64")
6574
6583
  };
6575
6584
  if (image.data.length > 0) localImageCache.set(path4, image);
6576
6585
  return image;
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.253",
3
+ "version": "0.1.254",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",