@posthog/agent 2.1.48 → 2.1.53

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