replicas-engine 0.1.253 → 0.1.255

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 +34 -22
  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-v5";
301
301
 
302
302
  // ../shared/src/runtime-env.ts
303
303
  function parsePosixEnvFile(content) {
@@ -2067,6 +2067,9 @@ function isTerminalBackgroundTaskStatus(status) {
2067
2067
  return normalizeBackgroundTaskStatus(status) !== "in_progress";
2068
2068
  }
2069
2069
 
2070
+ // ../shared/src/display-message/constants.ts
2071
+ var USER_MESSAGE_MATCH_GRACE_PERIOD_MS = 3e4;
2072
+
2070
2073
  // ../shared/src/display-message/task-accumulator.ts
2071
2074
  function mapTaskStatus(status) {
2072
2075
  if (status === "in_progress" || status === "completed") return status;
@@ -2217,7 +2220,7 @@ function areSameUserMessageEvents(a, b) {
2217
2220
  const aItemId = getUserMessageItemId(a);
2218
2221
  const bItemId = getUserMessageItemId(b);
2219
2222
  if (aItemId || bItemId) return aItemId === bItemId;
2220
- return Math.abs(getEventTimestampMs(a) - getEventTimestampMs(b)) <= 3e4;
2223
+ return Math.abs(getEventTimestampMs(a) - getEventTimestampMs(b)) <= USER_MESSAGE_MATCH_GRACE_PERIOD_MS;
2221
2224
  }
2222
2225
 
2223
2226
  // ../shared/src/display-message/parsers/codex-asp-parser.ts
@@ -2728,7 +2731,7 @@ var codexTokenManager = new CodexTokenManager();
2728
2731
 
2729
2732
  // src/git/service.ts
2730
2733
  import { readdir, stat } from "fs/promises";
2731
- import { existsSync as existsSync2, unlinkSync } from "fs";
2734
+ import { existsSync as existsSync2, readFileSync as readFileSync3, unlinkSync } from "fs";
2732
2735
  import { execFileSync as execFileSync2, spawnSync } from "child_process";
2733
2736
  import { join as join5 } from "path";
2734
2737
 
@@ -2937,27 +2940,21 @@ var GitService = class {
2937
2940
  }
2938
2941
  async listRepos(options) {
2939
2942
  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
2943
  const repos = await this.listRepositories();
2948
2944
  const states = [];
2949
2945
  for (const repo of repos) {
2950
2946
  try {
2951
2947
  const persistedState = await loadRepoState(repo.name);
2952
2948
  const currentBranch = getCurrentBranch(repo.path) ?? repo.defaultBranch;
2953
- const persistedMatchesCurrentBranch = persistedState?.currentBranch === currentBranch;
2949
+ const gitDiff = this.getGitDiffStats(repo.path, repo.defaultBranch);
2954
2950
  states.push({
2955
2951
  name: repo.name,
2956
2952
  path: repo.path,
2957
2953
  defaultBranch: repo.defaultBranch,
2958
2954
  currentBranch,
2959
2955
  prUrls: persistedState?.prUrls ?? [],
2960
- gitDiff: persistedMatchesCurrentBranch ? persistedState.gitDiff : null,
2956
+ // fullDiff may be empty if the diff subprocess fails.
2957
+ gitDiff: includeDiffs && gitDiff ? { ...gitDiff, fullDiff: this.getFullGitDiff(repo.path, repo.defaultBranch) } : gitDiff,
2961
2958
  startHooksCompleted: persistedState?.startHooksCompleted ?? false
2962
2959
  });
2963
2960
  } catch {
@@ -3120,17 +3117,20 @@ var GitService = class {
3120
3117
  return null;
3121
3118
  }
3122
3119
  }
3123
- getUntrackedDiff(repoPath, extraFlags = []) {
3120
+ listUntrackedPaths(repoPath) {
3124
3121
  const listing = execFileSync2("git", ["ls-files", "--others", "--exclude-standard", "-z"], {
3125
3122
  cwd: repoPath,
3126
3123
  encoding: "utf-8",
3127
3124
  stdio: ["pipe", "pipe", "pipe"]
3128
3125
  });
3129
- const paths = listing.split("\0").filter(Boolean);
3126
+ return listing.split("\0").filter(Boolean);
3127
+ }
3128
+ getUntrackedDiff(repoPath) {
3129
+ const paths = this.listUntrackedPaths(repoPath);
3130
3130
  if (paths.length === 0) return "";
3131
3131
  try {
3132
3132
  execFileSync2("git", ["add", "--intent-to-add", "--", ...paths], { cwd: repoPath, stdio: ["pipe", "pipe", "pipe"] });
3133
- const result = spawnSync("git", ["diff", ...extraFlags, "--", ...paths], {
3133
+ const result = spawnSync("git", ["diff", "--", ...paths], {
3134
3134
  cwd: repoPath,
3135
3135
  encoding: "utf-8",
3136
3136
  maxBuffer: 50 * 1024 * 1024
@@ -3145,9 +3145,21 @@ var GitService = class {
3145
3145
  }
3146
3146
  countUntrackedAddedLines(repoPath) {
3147
3147
  try {
3148
- const output = this.getUntrackedDiff(repoPath, ["--shortstat"]);
3149
- const match = output.match(/(\d+) insertion/);
3150
- return match ? parseInt(match[1], 10) : 0;
3148
+ return this.listUntrackedPaths(repoPath).reduce((total, path4) => {
3149
+ try {
3150
+ const contents = readFileSync3(join5(repoPath, path4));
3151
+ if (contents.length === 0 || contents.includes(0)) {
3152
+ return total;
3153
+ }
3154
+ let lines = 0;
3155
+ for (const byte of contents) {
3156
+ if (byte === 10) lines += 1;
3157
+ }
3158
+ return total + lines + (contents[contents.length - 1] === 10 ? 0 : 1);
3159
+ } catch {
3160
+ return total;
3161
+ }
3162
+ }, 0);
3151
3163
  } catch (error) {
3152
3164
  console.error("Error counting untracked added lines:", error);
3153
3165
  return 0;
@@ -6222,7 +6234,7 @@ var AspClient = class {
6222
6234
  // src/managers/codex-asp/app-server-process.ts
6223
6235
  var DEFAULT_CODEX_BINARY = "codex";
6224
6236
  var DEFAULT_CODEX_ARGS = ["app-server", "--listen", "stdio://"];
6225
- var ENGINE_PACKAGE_VERSION = "0.1.253";
6237
+ var ENGINE_PACKAGE_VERSION = "0.1.255";
6226
6238
  var INITIALIZE_METHOD = "initialize";
6227
6239
  var INITIALIZED_NOTIFICATION = "initialized";
6228
6240
  var ACCOUNT_LOGIN_START_METHOD = "account/login/start";
@@ -6489,7 +6501,7 @@ function isCodexAuthError(error) {
6489
6501
  }
6490
6502
 
6491
6503
  // src/managers/codex-asp/mappers.ts
6492
- import { existsSync as existsSync6, readFileSync as readFileSync3 } from "fs";
6504
+ import { existsSync as existsSync6, readFileSync as readFileSync4 } from "fs";
6493
6505
  var localImageCache = /* @__PURE__ */ new Map();
6494
6506
  var DEFAULT_MODEL = DEFAULT_CODEX_MODEL;
6495
6507
  var THREAD_START_METHOD = "thread/start";
@@ -6570,7 +6582,7 @@ function userImageForLocalPath(path4) {
6570
6582
  const image = {
6571
6583
  type: "image",
6572
6584
  mediaType: inferMediaType(path4),
6573
- data: readFileSync3(path4).toString("base64")
6585
+ data: readFileSync4(path4).toString("base64")
6574
6586
  };
6575
6587
  if (image.data.length > 0) localImageCache.set(path4, image);
6576
6588
  return image;
@@ -8863,7 +8875,7 @@ function isSameAcceptedUserEvent(event, acceptedEvent) {
8863
8875
  if (areSameUserMessageEvents(event, acceptedEvent)) return true;
8864
8876
  const eventMessage = getUserMessage(event);
8865
8877
  const acceptedMessage = getUserMessage(acceptedEvent);
8866
- return Boolean(eventMessage) && eventMessage === acceptedMessage && Math.abs(getEventTimestampMs(event) - getEventTimestampMs(acceptedEvent)) <= 3e4;
8878
+ return Boolean(eventMessage) && eventMessage === acceptedMessage && Math.abs(getEventTimestampMs(event) - getEventTimestampMs(acceptedEvent)) <= USER_MESSAGE_MATCH_GRACE_PERIOD_MS;
8867
8879
  }
8868
8880
  function getCodexTranscriptUserMessages(transcript) {
8869
8881
  if (!transcript) return [];
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "replicas-engine",
3
- "version": "0.1.253",
3
+ "version": "0.1.255",
4
4
  "description": "Lightweight API server for Replicas workspaces",
5
5
  "type": "module",
6
6
  "main": "dist/src/index.js",