@posthog/agent 2.1.48 → 2.1.59

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.d.ts CHANGED
@@ -1,4 +1,4 @@
1
- export { A as AcpConnection, a as AcpConnectionConfig, b as Agent, c as AgentAdapter, C as CodexProcessOptions, I as InProcessAcpConnection, O as OtelLogConfig, d as OtelLogWriter, S as SessionContext, e as SessionLogWriter, f as SessionLogWriterOptions, g as createAcpConnection } from './agent-DcBmoTR4.js';
1
+ export { A as AcpConnection, a as AcpConnectionConfig, b as Agent, c as AgentAdapter, C as CodexProcessOptions, I as InProcessAcpConnection, O as OtelLogConfig, d as OtelLogWriter, S as SessionContext, e as SessionLogWriter, f as SessionLogWriterOptions, g as createAcpConnection } from './agent-9gv5HohC.js';
2
2
  import { McpServerConfig } from '@anthropic-ai/claude-agent-sdk';
3
3
  import { L as Logger } from './logger-DDBiMOOD.js';
4
4
  export { a as LoggerConfig } from './logger-DDBiMOOD.js';
package/dist/index.js CHANGED
@@ -809,10 +809,10 @@ var require_src2 = __commonJS({
809
809
  var fs_1 = __require("fs");
810
810
  var debug_1 = __importDefault(require_src());
811
811
  var log = debug_1.default("@kwsites/file-exists");
812
- function check(path7, isFile, isDirectory) {
813
- log(`checking %s`, path7);
812
+ function check(path8, isFile, isDirectory) {
813
+ log(`checking %s`, path8);
814
814
  try {
815
- const stat = fs_1.statSync(path7);
815
+ const stat = fs_1.statSync(path8);
816
816
  if (stat.isFile() && isFile) {
817
817
  log(`[OK] path represents a file`);
818
818
  return true;
@@ -832,8 +832,8 @@ var require_src2 = __commonJS({
832
832
  throw e;
833
833
  }
834
834
  }
835
- function exists2(path7, type = exports.READABLE) {
836
- return check(path7, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
835
+ function exists2(path8, type = exports.READABLE) {
836
+ return check(path8, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
837
837
  }
838
838
  exports.exists = exists2;
839
839
  exports.FILE = 1;
@@ -1174,7 +1174,7 @@ import { v7 as uuidv7 } from "uuid";
1174
1174
  // package.json
1175
1175
  var package_default = {
1176
1176
  name: "@posthog/agent",
1177
- version: "2.1.48",
1177
+ version: "2.1.59",
1178
1178
  repository: "https://github.com/PostHog/twig",
1179
1179
  description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
1180
1180
  exports: {
@@ -1239,7 +1239,8 @@ var package_default = {
1239
1239
  test: "vitest run",
1240
1240
  "test:watch": "vitest",
1241
1241
  typecheck: "pnpm exec tsc --noEmit",
1242
- prepublishOnly: "pnpm run build"
1242
+ prepublishOnly: "pnpm run build",
1243
+ clean: "rm -rf dist .turbo"
1243
1244
  },
1244
1245
  engines: {
1245
1246
  node: ">=20.0.0"
@@ -1596,8 +1597,8 @@ var ToolContentBuilder = class {
1596
1597
  this.items.push({ type: "content", content: image(data, mimeType, uri) });
1597
1598
  return this;
1598
1599
  }
1599
- diff(path7, oldText, newText) {
1600
- this.items.push({ type: "diff", path: path7, oldText, newText });
1600
+ diff(path8, oldText, newText) {
1601
+ this.items.push({ type: "diff", path: path8, oldText, newText });
1601
1602
  return this;
1602
1603
  }
1603
1604
  build() {
@@ -1787,13 +1788,13 @@ function toolInfoFromToolUse(toolUse, cachedFileContent, logger = new Logger({ d
1787
1788
  locations: []
1788
1789
  };
1789
1790
  case "Edit": {
1790
- const path7 = input?.file_path ? String(input.file_path) : void 0;
1791
+ const path8 = input?.file_path ? String(input.file_path) : void 0;
1791
1792
  let oldText = input?.old_string ? String(input.old_string) : null;
1792
1793
  let newText = input?.new_string ? String(input.new_string) : "";
1793
1794
  let affectedLines = [];
1794
- if (path7 && oldText) {
1795
+ if (path8 && oldText) {
1795
1796
  try {
1796
- const oldContent = cachedFileContent[path7] || "";
1797
+ const oldContent = cachedFileContent[path8] || "";
1797
1798
  const newContent = replaceAndCalculateLocation(oldContent, [
1798
1799
  {
1799
1800
  oldText,
@@ -1809,17 +1810,17 @@ function toolInfoFromToolUse(toolUse, cachedFileContent, logger = new Logger({ d
1809
1810
  }
1810
1811
  }
1811
1812
  return {
1812
- title: path7 ? `Edit \`${path7}\`` : "Edit",
1813
+ title: path8 ? `Edit \`${path8}\`` : "Edit",
1813
1814
  kind: "edit",
1814
- content: input && path7 ? [
1815
+ content: input && path8 ? [
1815
1816
  {
1816
1817
  type: "diff",
1817
- path: path7,
1818
+ path: path8,
1818
1819
  oldText,
1819
1820
  newText
1820
1821
  }
1821
1822
  ] : [],
1822
- locations: path7 ? affectedLines.length > 0 ? affectedLines.map((line) => ({ line, path: path7 })) : [{ path: path7 }] : []
1823
+ locations: path8 ? affectedLines.length > 0 ? affectedLines.map((line) => ({ line, path: path8 })) : [{ path: path8 }] : []
1823
1824
  };
1824
1825
  }
1825
1826
  case "Write": {
@@ -4313,6 +4314,8 @@ var PostHogAPIClient = class {
4313
4314
  };
4314
4315
 
4315
4316
  // src/session-log-writer.ts
4317
+ import fs3 from "fs";
4318
+ import path4 from "path";
4316
4319
  var SessionLogWriter = class _SessionLogWriter {
4317
4320
  static FLUSH_DEBOUNCE_MS = 500;
4318
4321
  static FLUSH_MAX_INTERVAL_MS = 5e3;
@@ -4326,8 +4329,10 @@ var SessionLogWriter = class _SessionLogWriter {
4326
4329
  sessions = /* @__PURE__ */ new Map();
4327
4330
  messageCounts = /* @__PURE__ */ new Map();
4328
4331
  logger;
4332
+ localCachePath;
4329
4333
  constructor(options = {}) {
4330
4334
  this.posthogAPI = options.posthogAPI;
4335
+ this.localCachePath = options.localCachePath;
4331
4336
  this.logger = options.logger ?? new Logger({ debug: false, prefix: "[SessionLogWriter]" });
4332
4337
  }
4333
4338
  async flushAll() {
@@ -4357,6 +4362,21 @@ var SessionLogWriter = class _SessionLogWriter {
4357
4362
  });
4358
4363
  this.sessions.set(sessionId, { context });
4359
4364
  this.lastFlushAttemptTime.set(sessionId, Date.now());
4365
+ if (this.localCachePath) {
4366
+ const sessionDir = path4.join(
4367
+ this.localCachePath,
4368
+ "sessions",
4369
+ context.runId
4370
+ );
4371
+ try {
4372
+ fs3.mkdirSync(sessionDir, { recursive: true });
4373
+ } catch (error) {
4374
+ this.logger.warn("Failed to create local cache directory", {
4375
+ sessionDir,
4376
+ error
4377
+ });
4378
+ }
4379
+ }
4360
4380
  }
4361
4381
  isRegistered(sessionId) {
4362
4382
  return this.sessions.has(sessionId);
@@ -4394,6 +4414,7 @@ var SessionLogWriter = class _SessionLogWriter {
4394
4414
  timestamp,
4395
4415
  notification: message
4396
4416
  };
4417
+ this.writeToLocalCache(sessionId, entry);
4397
4418
  if (this.posthogAPI) {
4398
4419
  const pending = this.pendingEntries.get(sessionId) ?? [];
4399
4420
  pending.push(entry);
@@ -4494,6 +4515,7 @@ var SessionLogWriter = class _SessionLogWriter {
4494
4515
  }
4495
4516
  }
4496
4517
  };
4518
+ this.writeToLocalCache(sessionId, entry);
4497
4519
  if (this.posthogAPI) {
4498
4520
  const pending = this.pendingEntries.get(sessionId) ?? [];
4499
4521
  pending.push(entry);
@@ -4521,6 +4543,23 @@ var SessionLogWriter = class _SessionLogWriter {
4521
4543
  const timeout = setTimeout(() => this.flush(sessionId), delay2);
4522
4544
  this.flushTimeouts.set(sessionId, timeout);
4523
4545
  }
4546
+ writeToLocalCache(sessionId, entry) {
4547
+ if (!this.localCachePath) return;
4548
+ const session = this.sessions.get(sessionId);
4549
+ if (!session) return;
4550
+ const logPath = path4.join(
4551
+ this.localCachePath,
4552
+ "sessions",
4553
+ session.context.runId,
4554
+ "logs.ndjson"
4555
+ );
4556
+ try {
4557
+ fs3.appendFileSync(logPath, `${JSON.stringify(entry)}
4558
+ `);
4559
+ } catch (error) {
4560
+ this.logger.warn("Failed to write to local cache", { logPath, error });
4561
+ }
4562
+ }
4524
4563
  };
4525
4564
 
4526
4565
  // src/agent.ts
@@ -4544,7 +4583,8 @@ var Agent = class {
4544
4583
  if (config.posthog && !config.skipLogPersistence) {
4545
4584
  this.sessionLogWriter = new SessionLogWriter({
4546
4585
  posthogAPI: this.posthogAPI,
4547
- logger: this.logger.child("SessionLogWriter")
4586
+ logger: this.logger.child("SessionLogWriter"),
4587
+ localCachePath: config.localCachePath
4548
4588
  });
4549
4589
  }
4550
4590
  }
@@ -4826,8 +4866,8 @@ var Saga = class {
4826
4866
  };
4827
4867
 
4828
4868
  // ../git/dist/queries.js
4829
- import * as fs4 from "fs/promises";
4830
- import * as path5 from "path";
4869
+ import * as fs5 from "fs/promises";
4870
+ import * as path6 from "path";
4831
4871
 
4832
4872
  // ../../node_modules/simple-git/dist/esm/index.js
4833
4873
  var import_file_exists = __toESM(require_dist(), 1);
@@ -4866,8 +4906,8 @@ function pathspec(...paths) {
4866
4906
  cache.set(key, paths);
4867
4907
  return key;
4868
4908
  }
4869
- function isPathSpec(path7) {
4870
- return path7 instanceof String && cache.has(path7);
4909
+ function isPathSpec(path8) {
4910
+ return path8 instanceof String && cache.has(path8);
4871
4911
  }
4872
4912
  function toPaths(pathSpec) {
4873
4913
  return cache.get(pathSpec) || [];
@@ -4956,8 +4996,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
4956
4996
  function forEachLineWithContent(input, callback) {
4957
4997
  return toLinesWithContent(input, true).map((line) => callback(line));
4958
4998
  }
4959
- function folderExists(path7) {
4960
- return (0, import_file_exists.exists)(path7, import_file_exists.FOLDER);
4999
+ function folderExists(path8) {
5000
+ return (0, import_file_exists.exists)(path8, import_file_exists.FOLDER);
4961
5001
  }
4962
5002
  function append(target, item) {
4963
5003
  if (Array.isArray(target)) {
@@ -5361,8 +5401,8 @@ function checkIsRepoRootTask() {
5361
5401
  commands,
5362
5402
  format: "utf-8",
5363
5403
  onError,
5364
- parser(path7) {
5365
- return /^\.(git)?$/.test(path7.trim());
5404
+ parser(path8) {
5405
+ return /^\.(git)?$/.test(path8.trim());
5366
5406
  }
5367
5407
  };
5368
5408
  }
@@ -5796,11 +5836,11 @@ function parseGrep(grep) {
5796
5836
  const paths = /* @__PURE__ */ new Set();
5797
5837
  const results = {};
5798
5838
  forEachLineWithContent(grep, (input) => {
5799
- const [path7, line, preview] = input.split(NULL);
5800
- paths.add(path7);
5801
- (results[path7] = results[path7] || []).push({
5839
+ const [path8, line, preview] = input.split(NULL);
5840
+ paths.add(path8);
5841
+ (results[path8] = results[path8] || []).push({
5802
5842
  line: asNumber(line),
5803
- path: path7,
5843
+ path: path8,
5804
5844
  preview
5805
5845
  });
5806
5846
  });
@@ -6565,14 +6605,14 @@ var init_hash_object = __esm({
6565
6605
  init_task();
6566
6606
  }
6567
6607
  });
6568
- function parseInit(bare, path7, text2) {
6608
+ function parseInit(bare, path8, text2) {
6569
6609
  const response = String(text2).trim();
6570
6610
  let result;
6571
6611
  if (result = initResponseRegex.exec(response)) {
6572
- return new InitSummary(bare, path7, false, result[1]);
6612
+ return new InitSummary(bare, path8, false, result[1]);
6573
6613
  }
6574
6614
  if (result = reInitResponseRegex.exec(response)) {
6575
- return new InitSummary(bare, path7, true, result[1]);
6615
+ return new InitSummary(bare, path8, true, result[1]);
6576
6616
  }
6577
6617
  let gitDir = "";
6578
6618
  const tokens = response.split(" ");
@@ -6583,7 +6623,7 @@ function parseInit(bare, path7, text2) {
6583
6623
  break;
6584
6624
  }
6585
6625
  }
6586
- return new InitSummary(bare, path7, /^re/i.test(response), gitDir);
6626
+ return new InitSummary(bare, path8, /^re/i.test(response), gitDir);
6587
6627
  }
6588
6628
  var InitSummary;
6589
6629
  var initResponseRegex;
@@ -6592,9 +6632,9 @@ var init_InitSummary = __esm({
6592
6632
  "src/lib/responses/InitSummary.ts"() {
6593
6633
  "use strict";
6594
6634
  InitSummary = class {
6595
- constructor(bare, path7, existing, gitDir) {
6635
+ constructor(bare, path8, existing, gitDir) {
6596
6636
  this.bare = bare;
6597
- this.path = path7;
6637
+ this.path = path8;
6598
6638
  this.existing = existing;
6599
6639
  this.gitDir = gitDir;
6600
6640
  }
@@ -6606,7 +6646,7 @@ var init_InitSummary = __esm({
6606
6646
  function hasBareCommand(command) {
6607
6647
  return command.includes(bareCommand);
6608
6648
  }
6609
- function initTask(bare = false, path7, customArgs) {
6649
+ function initTask(bare = false, path8, customArgs) {
6610
6650
  const commands = ["init", ...customArgs];
6611
6651
  if (bare && !hasBareCommand(commands)) {
6612
6652
  commands.splice(1, 0, bareCommand);
@@ -6615,7 +6655,7 @@ function initTask(bare = false, path7, customArgs) {
6615
6655
  commands,
6616
6656
  format: "utf-8",
6617
6657
  parser(text2) {
6618
- return parseInit(commands.includes("--bare"), path7, text2);
6658
+ return parseInit(commands.includes("--bare"), path8, text2);
6619
6659
  }
6620
6660
  };
6621
6661
  }
@@ -7431,12 +7471,12 @@ var init_FileStatusSummary = __esm({
7431
7471
  "use strict";
7432
7472
  fromPathRegex = /^(.+)\0(.+)$/;
7433
7473
  FileStatusSummary = class {
7434
- constructor(path7, index, working_dir) {
7435
- this.path = path7;
7474
+ constructor(path8, index, working_dir) {
7475
+ this.path = path8;
7436
7476
  this.index = index;
7437
7477
  this.working_dir = working_dir;
7438
7478
  if (index === "R" || working_dir === "R") {
7439
- const detail = fromPathRegex.exec(path7) || [null, path7, path7];
7479
+ const detail = fromPathRegex.exec(path8) || [null, path8, path8];
7440
7480
  this.from = detail[2] || "";
7441
7481
  this.path = detail[1] || "";
7442
7482
  }
@@ -7467,14 +7507,14 @@ function splitLine(result, lineStr) {
7467
7507
  default:
7468
7508
  return;
7469
7509
  }
7470
- function data(index, workingDir, path7) {
7510
+ function data(index, workingDir, path8) {
7471
7511
  const raw = `${index}${workingDir}`;
7472
7512
  const handler = parsers6.get(raw);
7473
7513
  if (handler) {
7474
- handler(result, path7);
7514
+ handler(result, path8);
7475
7515
  }
7476
7516
  if (raw !== "##" && raw !== "!!") {
7477
- result.files.push(new FileStatusSummary(path7, index, workingDir));
7517
+ result.files.push(new FileStatusSummary(path8, index, workingDir));
7478
7518
  }
7479
7519
  }
7480
7520
  }
@@ -7787,9 +7827,9 @@ var init_simple_git_api = __esm({
7787
7827
  next
7788
7828
  );
7789
7829
  }
7790
- hashObject(path7, write) {
7830
+ hashObject(path8, write) {
7791
7831
  return this._runTask(
7792
- hashObjectTask(path7, write === true),
7832
+ hashObjectTask(path8, write === true),
7793
7833
  trailingFunctionArgument(arguments)
7794
7834
  );
7795
7835
  }
@@ -8142,8 +8182,8 @@ var init_branch = __esm({
8142
8182
  }
8143
8183
  });
8144
8184
  function toPath(input) {
8145
- const path7 = input.trim().replace(/^["']|["']$/g, "");
8146
- return path7 && normalize(path7);
8185
+ const path8 = input.trim().replace(/^["']|["']$/g, "");
8186
+ return path8 && normalize(path8);
8147
8187
  }
8148
8188
  var parseCheckIgnore;
8149
8189
  var init_CheckIgnore = __esm({
@@ -8457,8 +8497,8 @@ __export(sub_module_exports, {
8457
8497
  subModuleTask: () => subModuleTask,
8458
8498
  updateSubModuleTask: () => updateSubModuleTask
8459
8499
  });
8460
- function addSubModuleTask(repo, path7) {
8461
- return subModuleTask(["add", repo, path7]);
8500
+ function addSubModuleTask(repo, path8) {
8501
+ return subModuleTask(["add", repo, path8]);
8462
8502
  }
8463
8503
  function initSubModuleTask(customArgs) {
8464
8504
  return subModuleTask(["init", ...customArgs]);
@@ -8788,8 +8828,8 @@ var require_git = __commonJS2({
8788
8828
  }
8789
8829
  return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
8790
8830
  };
8791
- Git2.prototype.submoduleAdd = function(repo, path7, then) {
8792
- return this._runTask(addSubModuleTask2(repo, path7), trailingFunctionArgument2(arguments));
8831
+ Git2.prototype.submoduleAdd = function(repo, path8, then) {
8832
+ return this._runTask(addSubModuleTask2(repo, path8), trailingFunctionArgument2(arguments));
8793
8833
  };
8794
8834
  Git2.prototype.submoduleUpdate = function(args, then) {
8795
8835
  return this._runTask(
@@ -9390,22 +9430,22 @@ function createGitClient(baseDir, options) {
9390
9430
 
9391
9431
  // ../git/dist/lock-detector.js
9392
9432
  import { execFile } from "child_process";
9393
- import fs3 from "fs/promises";
9394
- import path4 from "path";
9433
+ import fs4 from "fs/promises";
9434
+ import path5 from "path";
9395
9435
  import { promisify } from "util";
9396
9436
  var execFileAsync = promisify(execFile);
9397
9437
  async function getIndexLockPath(repoPath) {
9398
9438
  try {
9399
9439
  const { stdout } = await execFileAsync("git", ["rev-parse", "--git-path", "index.lock"], { cwd: repoPath });
9400
- return path4.resolve(repoPath, stdout.trim());
9440
+ return path5.resolve(repoPath, stdout.trim());
9401
9441
  } catch {
9402
- return path4.join(repoPath, ".git", "index.lock");
9442
+ return path5.join(repoPath, ".git", "index.lock");
9403
9443
  }
9404
9444
  }
9405
9445
  async function getLockInfo(repoPath) {
9406
9446
  const lockPath = await getIndexLockPath(repoPath);
9407
9447
  try {
9408
- const stat = await fs3.stat(lockPath);
9448
+ const stat = await fs4.stat(lockPath);
9409
9449
  return {
9410
9450
  path: lockPath,
9411
9451
  ageMs: Date.now() - stat.mtimeMs
@@ -9416,7 +9456,7 @@ async function getLockInfo(repoPath) {
9416
9456
  }
9417
9457
  async function removeLock(repoPath) {
9418
9458
  const lockPath = await getIndexLockPath(repoPath);
9419
- await fs3.rm(lockPath, { force: true });
9459
+ await fs4.rm(lockPath, { force: true });
9420
9460
  }
9421
9461
  async function isLocked(repoPath) {
9422
9462
  return await getLockInfo(repoPath) !== null;
@@ -9596,8 +9636,8 @@ import { join as join5 } from "path";
9596
9636
 
9597
9637
  // ../git/dist/sagas/tree.js
9598
9638
  import { existsSync as existsSync4 } from "fs";
9599
- import * as fs5 from "fs/promises";
9600
- import * as path6 from "path";
9639
+ import * as fs6 from "fs/promises";
9640
+ import * as path7 from "path";
9601
9641
  import * as tar from "tar";
9602
9642
 
9603
9643
  // ../git/dist/git-saga.js
@@ -9623,14 +9663,14 @@ var CaptureTreeSaga = class extends GitSaga {
9623
9663
  tempIndexPath = null;
9624
9664
  async executeGitOperations(input) {
9625
9665
  const { baseDir, lastTreeHash, archivePath, signal } = input;
9626
- const tmpDir = path6.join(baseDir, ".git", "twig-tmp");
9666
+ const tmpDir = path7.join(baseDir, ".git", "twig-tmp");
9627
9667
  await this.step({
9628
9668
  name: "create_tmp_dir",
9629
- execute: () => fs5.mkdir(tmpDir, { recursive: true }),
9669
+ execute: () => fs6.mkdir(tmpDir, { recursive: true }),
9630
9670
  rollback: async () => {
9631
9671
  }
9632
9672
  });
9633
- this.tempIndexPath = path6.join(tmpDir, `index-${Date.now()}`);
9673
+ this.tempIndexPath = path7.join(tmpDir, `index-${Date.now()}`);
9634
9674
  const tempIndexGit = this.git.env({
9635
9675
  ...process.env,
9636
9676
  GIT_INDEX_FILE: this.tempIndexPath
@@ -9640,7 +9680,7 @@ var CaptureTreeSaga = class extends GitSaga {
9640
9680
  execute: () => tempIndexGit.raw(["read-tree", "HEAD"]),
9641
9681
  rollback: async () => {
9642
9682
  if (this.tempIndexPath) {
9643
- await fs5.rm(this.tempIndexPath, { force: true }).catch(() => {
9683
+ await fs6.rm(this.tempIndexPath, { force: true }).catch(() => {
9644
9684
  });
9645
9685
  }
9646
9686
  }
@@ -9649,7 +9689,7 @@ var CaptureTreeSaga = class extends GitSaga {
9649
9689
  const treeHash = await this.readOnlyStep("write_tree", () => tempIndexGit.raw(["write-tree"]));
9650
9690
  if (lastTreeHash && treeHash === lastTreeHash) {
9651
9691
  this.log.debug("No changes since last capture", { treeHash });
9652
- await fs5.rm(this.tempIndexPath, { force: true }).catch(() => {
9692
+ await fs6.rm(this.tempIndexPath, { force: true }).catch(() => {
9653
9693
  });
9654
9694
  return { snapshot: null, changed: false };
9655
9695
  }
@@ -9661,7 +9701,7 @@ var CaptureTreeSaga = class extends GitSaga {
9661
9701
  }
9662
9702
  });
9663
9703
  const changes = await this.readOnlyStep("get_changes", () => this.getChanges(this.git, baseCommit, treeHash));
9664
- await fs5.rm(this.tempIndexPath, { force: true }).catch(() => {
9704
+ await fs6.rm(this.tempIndexPath, { force: true }).catch(() => {
9665
9705
  });
9666
9706
  const snapshot = {
9667
9707
  treeHash,
@@ -9685,15 +9725,15 @@ var CaptureTreeSaga = class extends GitSaga {
9685
9725
  if (filesToArchive.length === 0) {
9686
9726
  return void 0;
9687
9727
  }
9688
- const existingFiles = filesToArchive.filter((f) => existsSync4(path6.join(baseDir, f)));
9728
+ const existingFiles = filesToArchive.filter((f) => existsSync4(path7.join(baseDir, f)));
9689
9729
  if (existingFiles.length === 0) {
9690
9730
  return void 0;
9691
9731
  }
9692
9732
  await this.step({
9693
9733
  name: "create_archive",
9694
9734
  execute: async () => {
9695
- const archiveDir = path6.dirname(archivePath);
9696
- await fs5.mkdir(archiveDir, { recursive: true });
9735
+ const archiveDir = path7.dirname(archivePath);
9736
+ await fs6.mkdir(archiveDir, { recursive: true });
9697
9737
  await tar.create({
9698
9738
  gzip: true,
9699
9739
  file: archivePath,
@@ -9701,7 +9741,7 @@ var CaptureTreeSaga = class extends GitSaga {
9701
9741
  }, existingFiles);
9702
9742
  },
9703
9743
  rollback: async () => {
9704
- await fs5.rm(archivePath, { force: true }).catch(() => {
9744
+ await fs6.rm(archivePath, { force: true }).catch(() => {
9705
9745
  });
9706
9746
  }
9707
9747
  });
@@ -9800,9 +9840,9 @@ var ApplyTreeSaga = class extends GitSaga {
9800
9840
  const filesToExtract = changes.filter((c) => c.status !== "D").map((c) => c.path);
9801
9841
  await this.readOnlyStep("backup_existing_files", async () => {
9802
9842
  for (const filePath of filesToExtract) {
9803
- const fullPath = path6.join(baseDir, filePath);
9843
+ const fullPath = path7.join(baseDir, filePath);
9804
9844
  try {
9805
- const content = await fs5.readFile(fullPath);
9845
+ const content = await fs6.readFile(fullPath);
9806
9846
  this.fileBackups.set(filePath, content);
9807
9847
  } catch {
9808
9848
  }
@@ -9819,16 +9859,16 @@ var ApplyTreeSaga = class extends GitSaga {
9819
9859
  },
9820
9860
  rollback: async () => {
9821
9861
  for (const filePath of this.extractedFiles) {
9822
- const fullPath = path6.join(baseDir, filePath);
9862
+ const fullPath = path7.join(baseDir, filePath);
9823
9863
  const backup = this.fileBackups.get(filePath);
9824
9864
  if (backup) {
9825
- const dir = path6.dirname(fullPath);
9826
- await fs5.mkdir(dir, { recursive: true }).catch(() => {
9865
+ const dir = path7.dirname(fullPath);
9866
+ await fs6.mkdir(dir, { recursive: true }).catch(() => {
9827
9867
  });
9828
- await fs5.writeFile(fullPath, backup).catch(() => {
9868
+ await fs6.writeFile(fullPath, backup).catch(() => {
9829
9869
  });
9830
9870
  } else {
9831
- await fs5.rm(fullPath, { force: true }).catch(() => {
9871
+ await fs6.rm(fullPath, { force: true }).catch(() => {
9832
9872
  });
9833
9873
  }
9834
9874
  }
@@ -9836,10 +9876,10 @@ var ApplyTreeSaga = class extends GitSaga {
9836
9876
  });
9837
9877
  }
9838
9878
  for (const change of changes.filter((c) => c.status === "D")) {
9839
- const fullPath = path6.join(baseDir, change.path);
9879
+ const fullPath = path7.join(baseDir, change.path);
9840
9880
  const backupContent = await this.readOnlyStep(`backup_${change.path}`, async () => {
9841
9881
  try {
9842
- return await fs5.readFile(fullPath);
9882
+ return await fs6.readFile(fullPath);
9843
9883
  } catch {
9844
9884
  return null;
9845
9885
  }
@@ -9847,15 +9887,15 @@ var ApplyTreeSaga = class extends GitSaga {
9847
9887
  await this.step({
9848
9888
  name: `delete_${change.path}`,
9849
9889
  execute: async () => {
9850
- await fs5.rm(fullPath, { force: true });
9890
+ await fs6.rm(fullPath, { force: true });
9851
9891
  this.log.debug(`Deleted file: ${change.path}`);
9852
9892
  },
9853
9893
  rollback: async () => {
9854
9894
  if (backupContent) {
9855
- const dir = path6.dirname(fullPath);
9856
- await fs5.mkdir(dir, { recursive: true }).catch(() => {
9895
+ const dir = path7.dirname(fullPath);
9896
+ await fs6.mkdir(dir, { recursive: true }).catch(() => {
9857
9897
  });
9858
- await fs5.writeFile(fullPath, backupContent).catch(() => {
9898
+ await fs6.writeFile(fullPath, backupContent).catch(() => {
9859
9899
  });
9860
9900
  }
9861
9901
  }