@posthog/agent 2.3.62 → 2.3.67
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/agent.js +41 -41
- package/dist/agent.js.map +1 -1
- package/dist/posthog-api.js +3 -3
- package/dist/posthog-api.js.map +1 -1
- package/dist/server/agent-server.js +93 -93
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +80 -80
- package/dist/server/bin.cjs.map +1 -1
- package/package.json +3 -3
- package/src/adapters/claude/conversion/acp-to-sdk.ts +3 -3
|
@@ -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(
|
|
813
|
-
log(`checking %s`,
|
|
812
|
+
function check(path12, isFile, isDirectory) {
|
|
813
|
+
log(`checking %s`, path12);
|
|
814
814
|
try {
|
|
815
|
-
const stat = fs_1.statSync(
|
|
815
|
+
const stat = fs_1.statSync(path12);
|
|
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(
|
|
836
|
-
return check(
|
|
835
|
+
function exists2(path12, type = exports.READABLE) {
|
|
836
|
+
return check(path12, (type & exports.FILE) > 0, (type & exports.FOLDER) > 0);
|
|
837
837
|
}
|
|
838
838
|
exports.exists = exists2;
|
|
839
839
|
exports.FILE = 1;
|
|
@@ -908,7 +908,7 @@ import { Hono } from "hono";
|
|
|
908
908
|
// package.json
|
|
909
909
|
var package_default = {
|
|
910
910
|
name: "@posthog/agent",
|
|
911
|
-
version: "2.3.
|
|
911
|
+
version: "2.3.67",
|
|
912
912
|
repository: "https://github.com/PostHog/code",
|
|
913
913
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
914
914
|
exports: {
|
|
@@ -972,13 +972,13 @@ var package_default = {
|
|
|
972
972
|
author: "PostHog",
|
|
973
973
|
license: "SEE LICENSE IN LICENSE",
|
|
974
974
|
scripts: {
|
|
975
|
-
build: "
|
|
975
|
+
build: "node ../../scripts/rimraf.mjs dist && tsup",
|
|
976
976
|
dev: "tsup --watch",
|
|
977
977
|
test: "vitest run",
|
|
978
978
|
"test:watch": "vitest",
|
|
979
979
|
typecheck: "pnpm exec tsc --noEmit",
|
|
980
980
|
prepublishOnly: "pnpm run build",
|
|
981
|
-
clean: "
|
|
981
|
+
clean: "node ../../scripts/rimraf.mjs dist .turbo"
|
|
982
982
|
},
|
|
983
983
|
engines: {
|
|
984
984
|
node: ">=20.0.0"
|
|
@@ -1294,7 +1294,7 @@ function nodeWritableToWebWritable(nodeStream) {
|
|
|
1294
1294
|
import { randomUUID } from "crypto";
|
|
1295
1295
|
import * as fs4 from "fs";
|
|
1296
1296
|
import * as os4 from "os";
|
|
1297
|
-
import * as
|
|
1297
|
+
import * as path6 from "path";
|
|
1298
1298
|
import {
|
|
1299
1299
|
RequestError as RequestError2
|
|
1300
1300
|
} from "@agentclientprotocol/sdk";
|
|
@@ -1465,6 +1465,7 @@ var BaseAcpAgent = class {
|
|
|
1465
1465
|
};
|
|
1466
1466
|
|
|
1467
1467
|
// src/adapters/claude/conversion/acp-to-sdk.ts
|
|
1468
|
+
import * as path from "path";
|
|
1468
1469
|
function sdkText(value) {
|
|
1469
1470
|
return { type: "text", text: value };
|
|
1470
1471
|
}
|
|
@@ -1472,12 +1473,11 @@ function formatUriAsLink(uri) {
|
|
|
1472
1473
|
try {
|
|
1473
1474
|
if (uri.startsWith("file://")) {
|
|
1474
1475
|
const filePath = uri.slice(7);
|
|
1475
|
-
const name =
|
|
1476
|
+
const name = path.basename(filePath) || filePath;
|
|
1476
1477
|
return `[@${name}](${uri})`;
|
|
1477
1478
|
}
|
|
1478
1479
|
if (uri.startsWith("zed://")) {
|
|
1479
|
-
const
|
|
1480
|
-
const name = parts[parts.length - 1] || uri;
|
|
1480
|
+
const name = path.basename(uri) || uri;
|
|
1481
1481
|
return `[@${name}](${uri})`;
|
|
1482
1482
|
}
|
|
1483
1483
|
return uri;
|
|
@@ -1582,8 +1582,8 @@ var ToolContentBuilder = class {
|
|
|
1582
1582
|
this.items.push({ type: "content", content: image(data, mimeType, uri) });
|
|
1583
1583
|
return this;
|
|
1584
1584
|
}
|
|
1585
|
-
diff(
|
|
1586
|
-
this.items.push({ type: "diff", path:
|
|
1585
|
+
diff(path12, oldText, newText) {
|
|
1586
|
+
this.items.push({ type: "diff", path: path12, oldText, newText });
|
|
1587
1587
|
return this;
|
|
1588
1588
|
}
|
|
1589
1589
|
build() {
|
|
@@ -1669,7 +1669,7 @@ var createPreToolUseHook = (settingsManager, logger) => async (input, _toolUseID
|
|
|
1669
1669
|
|
|
1670
1670
|
// src/adapters/claude/conversion/tool-use-to-acp.ts
|
|
1671
1671
|
import fs from "fs";
|
|
1672
|
-
import
|
|
1672
|
+
import path2 from "path";
|
|
1673
1673
|
|
|
1674
1674
|
// src/adapters/claude/mcp/tool-metadata.ts
|
|
1675
1675
|
var mcpToolMetadataCache = /* @__PURE__ */ new Map();
|
|
@@ -1755,10 +1755,10 @@ function stripSystemReminders(value) {
|
|
|
1755
1755
|
}
|
|
1756
1756
|
function toDisplayPath(filePath, cwd) {
|
|
1757
1757
|
if (!cwd) return filePath;
|
|
1758
|
-
const resolvedCwd =
|
|
1759
|
-
const resolvedFile =
|
|
1760
|
-
if (resolvedFile.startsWith(resolvedCwd +
|
|
1761
|
-
return
|
|
1758
|
+
const resolvedCwd = path2.resolve(cwd);
|
|
1759
|
+
const resolvedFile = path2.resolve(filePath);
|
|
1760
|
+
if (resolvedFile.startsWith(resolvedCwd + path2.sep) || resolvedFile === resolvedCwd) {
|
|
1761
|
+
return path2.relative(resolvedCwd, resolvedFile);
|
|
1762
1762
|
}
|
|
1763
1763
|
return filePath;
|
|
1764
1764
|
}
|
|
@@ -2867,18 +2867,18 @@ async function handleUserAssistantMessage(message, context) {
|
|
|
2867
2867
|
|
|
2868
2868
|
// src/adapters/claude/plan/utils.ts
|
|
2869
2869
|
import * as os from "os";
|
|
2870
|
-
import * as
|
|
2870
|
+
import * as path3 from "path";
|
|
2871
2871
|
function getClaudeConfigDir() {
|
|
2872
|
-
return process.env.CLAUDE_CONFIG_DIR ||
|
|
2872
|
+
return process.env.CLAUDE_CONFIG_DIR || path3.join(os.homedir(), ".claude");
|
|
2873
2873
|
}
|
|
2874
2874
|
function getClaudePlansDir() {
|
|
2875
|
-
return
|
|
2875
|
+
return path3.join(getClaudeConfigDir(), "plans");
|
|
2876
2876
|
}
|
|
2877
2877
|
function isClaudePlanFilePath(filePath) {
|
|
2878
2878
|
if (!filePath) return false;
|
|
2879
|
-
const resolved =
|
|
2880
|
-
const plansDir =
|
|
2881
|
-
return resolved === plansDir || resolved.startsWith(plansDir +
|
|
2879
|
+
const resolved = path3.resolve(filePath);
|
|
2880
|
+
const plansDir = path3.resolve(getClaudePlansDir());
|
|
2881
|
+
return resolved === plansDir || resolved.startsWith(plansDir + path3.sep);
|
|
2882
2882
|
}
|
|
2883
2883
|
function isPlanReady(plan) {
|
|
2884
2884
|
if (!plan) return false;
|
|
@@ -3518,7 +3518,7 @@ function getEffortOptions(modelId) {
|
|
|
3518
3518
|
import { spawn } from "child_process";
|
|
3519
3519
|
import * as fs2 from "fs";
|
|
3520
3520
|
import * as os2 from "os";
|
|
3521
|
-
import * as
|
|
3521
|
+
import * as path4 from "path";
|
|
3522
3522
|
|
|
3523
3523
|
// src/adapters/claude/session/instructions.ts
|
|
3524
3524
|
var BRANCH_NAMING = `
|
|
@@ -3664,8 +3664,8 @@ function buildSpawnWrapper(sessionId, onProcessSpawned, onProcessExited, logger)
|
|
|
3664
3664
|
};
|
|
3665
3665
|
}
|
|
3666
3666
|
function ensureLocalSettings(cwd) {
|
|
3667
|
-
const claudeDir =
|
|
3668
|
-
const localSettingsPath =
|
|
3667
|
+
const claudeDir = path4.join(cwd, ".claude");
|
|
3668
|
+
const localSettingsPath = path4.join(claudeDir, "settings.local.json");
|
|
3669
3669
|
try {
|
|
3670
3670
|
if (!fs2.existsSync(localSettingsPath)) {
|
|
3671
3671
|
fs2.mkdirSync(claudeDir, { recursive: true });
|
|
@@ -3736,8 +3736,8 @@ function buildSessionOptions(params) {
|
|
|
3736
3736
|
return options;
|
|
3737
3737
|
}
|
|
3738
3738
|
function clearStatsigCache() {
|
|
3739
|
-
const statsigPath =
|
|
3740
|
-
process.env.CLAUDE_CONFIG_DIR ||
|
|
3739
|
+
const statsigPath = path4.join(
|
|
3740
|
+
process.env.CLAUDE_CONFIG_DIR || path4.join(os2.homedir(), ".claude"),
|
|
3741
3741
|
"statsig"
|
|
3742
3742
|
);
|
|
3743
3743
|
fs2.rm(statsigPath, { recursive: true, force: true }, () => {
|
|
@@ -3747,7 +3747,7 @@ function clearStatsigCache() {
|
|
|
3747
3747
|
// src/adapters/claude/session/settings.ts
|
|
3748
3748
|
import * as fs3 from "fs";
|
|
3749
3749
|
import * as os3 from "os";
|
|
3750
|
-
import * as
|
|
3750
|
+
import * as path5 from "path";
|
|
3751
3751
|
import { minimatch } from "minimatch";
|
|
3752
3752
|
var ACP_TOOL_NAME_PREFIX = "mcp__acp__";
|
|
3753
3753
|
var acpToolNames = {
|
|
@@ -3787,13 +3787,13 @@ function parseRule(rule) {
|
|
|
3787
3787
|
function normalizePath(filePath, cwd) {
|
|
3788
3788
|
let resolved = filePath;
|
|
3789
3789
|
if (resolved.startsWith("~/")) {
|
|
3790
|
-
resolved =
|
|
3790
|
+
resolved = path5.join(os3.homedir(), resolved.slice(2));
|
|
3791
3791
|
} else if (resolved.startsWith("./")) {
|
|
3792
|
-
resolved =
|
|
3793
|
-
} else if (!
|
|
3794
|
-
resolved =
|
|
3792
|
+
resolved = path5.join(cwd, resolved.slice(2));
|
|
3793
|
+
} else if (!path5.isAbsolute(resolved)) {
|
|
3794
|
+
resolved = path5.join(cwd, resolved);
|
|
3795
3795
|
}
|
|
3796
|
-
return
|
|
3796
|
+
return path5.normalize(resolved).replace(/\\/g, "/");
|
|
3797
3797
|
}
|
|
3798
3798
|
function matchesGlob(pattern, filePath, cwd) {
|
|
3799
3799
|
const normalizedPattern = normalizePath(pattern, cwd);
|
|
@@ -3877,14 +3877,14 @@ var SettingsManager = class {
|
|
|
3877
3877
|
this.initialized = true;
|
|
3878
3878
|
}
|
|
3879
3879
|
getUserSettingsPath() {
|
|
3880
|
-
const configDir = process.env.CLAUDE_CONFIG_DIR ||
|
|
3881
|
-
return
|
|
3880
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || path5.join(os3.homedir(), ".claude");
|
|
3881
|
+
return path5.join(configDir, "settings.json");
|
|
3882
3882
|
}
|
|
3883
3883
|
getProjectSettingsPath() {
|
|
3884
|
-
return
|
|
3884
|
+
return path5.join(this.cwd, ".claude", "settings.json");
|
|
3885
3885
|
}
|
|
3886
3886
|
getLocalSettingsPath() {
|
|
3887
|
-
return
|
|
3887
|
+
return path5.join(this.cwd, ".claude", "settings.local.json");
|
|
3888
3888
|
}
|
|
3889
3889
|
async loadAllSettings() {
|
|
3890
3890
|
const [userSettings, projectSettings, localSettings, enterpriseSettings] = await Promise.all([
|
|
@@ -4049,7 +4049,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
4049
4049
|
};
|
|
4050
4050
|
}
|
|
4051
4051
|
async newSession(params) {
|
|
4052
|
-
if (fs4.existsSync(
|
|
4052
|
+
if (fs4.existsSync(path6.resolve(os4.homedir(), ".claude.json.backup")) && !fs4.existsSync(path6.resolve(os4.homedir(), ".claude.json"))) {
|
|
4053
4053
|
throw RequestError2.authRequired();
|
|
4054
4054
|
}
|
|
4055
4055
|
const response = await this.createSession(params, {
|
|
@@ -5171,7 +5171,7 @@ function createCodexConnection(config) {
|
|
|
5171
5171
|
import { randomUUID as randomUUID2 } from "crypto";
|
|
5172
5172
|
import * as fs5 from "fs/promises";
|
|
5173
5173
|
import * as os5 from "os";
|
|
5174
|
-
import * as
|
|
5174
|
+
import * as path7 from "path";
|
|
5175
5175
|
var CHARS_PER_TOKEN = 4;
|
|
5176
5176
|
var DEFAULT_MAX_TOKENS = 15e4;
|
|
5177
5177
|
function estimateTurnTokens(turn) {
|
|
@@ -5518,7 +5518,7 @@ var Saga = class {
|
|
|
5518
5518
|
|
|
5519
5519
|
// ../git/dist/queries.js
|
|
5520
5520
|
import * as fs7 from "fs/promises";
|
|
5521
|
-
import * as
|
|
5521
|
+
import * as path9 from "path";
|
|
5522
5522
|
|
|
5523
5523
|
// ../../node_modules/simple-git/dist/esm/index.js
|
|
5524
5524
|
var import_file_exists = __toESM(require_dist(), 1);
|
|
@@ -5557,8 +5557,8 @@ function pathspec(...paths) {
|
|
|
5557
5557
|
cache.set(key, paths);
|
|
5558
5558
|
return key;
|
|
5559
5559
|
}
|
|
5560
|
-
function isPathSpec(
|
|
5561
|
-
return
|
|
5560
|
+
function isPathSpec(path12) {
|
|
5561
|
+
return path12 instanceof String && cache.has(path12);
|
|
5562
5562
|
}
|
|
5563
5563
|
function toPaths(pathSpec) {
|
|
5564
5564
|
return cache.get(pathSpec) || [];
|
|
@@ -5647,8 +5647,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
5647
5647
|
function forEachLineWithContent(input, callback) {
|
|
5648
5648
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
5649
5649
|
}
|
|
5650
|
-
function folderExists(
|
|
5651
|
-
return (0, import_file_exists.exists)(
|
|
5650
|
+
function folderExists(path12) {
|
|
5651
|
+
return (0, import_file_exists.exists)(path12, import_file_exists.FOLDER);
|
|
5652
5652
|
}
|
|
5653
5653
|
function append(target, item) {
|
|
5654
5654
|
if (Array.isArray(target)) {
|
|
@@ -6052,8 +6052,8 @@ function checkIsRepoRootTask() {
|
|
|
6052
6052
|
commands,
|
|
6053
6053
|
format: "utf-8",
|
|
6054
6054
|
onError,
|
|
6055
|
-
parser(
|
|
6056
|
-
return /^\.(git)?$/.test(
|
|
6055
|
+
parser(path12) {
|
|
6056
|
+
return /^\.(git)?$/.test(path12.trim());
|
|
6057
6057
|
}
|
|
6058
6058
|
};
|
|
6059
6059
|
}
|
|
@@ -6487,11 +6487,11 @@ function parseGrep(grep) {
|
|
|
6487
6487
|
const paths = /* @__PURE__ */ new Set();
|
|
6488
6488
|
const results = {};
|
|
6489
6489
|
forEachLineWithContent(grep, (input) => {
|
|
6490
|
-
const [
|
|
6491
|
-
paths.add(
|
|
6492
|
-
(results[
|
|
6490
|
+
const [path12, line, preview] = input.split(NULL);
|
|
6491
|
+
paths.add(path12);
|
|
6492
|
+
(results[path12] = results[path12] || []).push({
|
|
6493
6493
|
line: asNumber(line),
|
|
6494
|
-
path:
|
|
6494
|
+
path: path12,
|
|
6495
6495
|
preview
|
|
6496
6496
|
});
|
|
6497
6497
|
});
|
|
@@ -7256,14 +7256,14 @@ var init_hash_object = __esm({
|
|
|
7256
7256
|
init_task();
|
|
7257
7257
|
}
|
|
7258
7258
|
});
|
|
7259
|
-
function parseInit(bare,
|
|
7259
|
+
function parseInit(bare, path12, text2) {
|
|
7260
7260
|
const response = String(text2).trim();
|
|
7261
7261
|
let result;
|
|
7262
7262
|
if (result = initResponseRegex.exec(response)) {
|
|
7263
|
-
return new InitSummary(bare,
|
|
7263
|
+
return new InitSummary(bare, path12, false, result[1]);
|
|
7264
7264
|
}
|
|
7265
7265
|
if (result = reInitResponseRegex.exec(response)) {
|
|
7266
|
-
return new InitSummary(bare,
|
|
7266
|
+
return new InitSummary(bare, path12, true, result[1]);
|
|
7267
7267
|
}
|
|
7268
7268
|
let gitDir = "";
|
|
7269
7269
|
const tokens = response.split(" ");
|
|
@@ -7274,7 +7274,7 @@ function parseInit(bare, path11, text2) {
|
|
|
7274
7274
|
break;
|
|
7275
7275
|
}
|
|
7276
7276
|
}
|
|
7277
|
-
return new InitSummary(bare,
|
|
7277
|
+
return new InitSummary(bare, path12, /^re/i.test(response), gitDir);
|
|
7278
7278
|
}
|
|
7279
7279
|
var InitSummary;
|
|
7280
7280
|
var initResponseRegex;
|
|
@@ -7283,9 +7283,9 @@ var init_InitSummary = __esm({
|
|
|
7283
7283
|
"src/lib/responses/InitSummary.ts"() {
|
|
7284
7284
|
"use strict";
|
|
7285
7285
|
InitSummary = class {
|
|
7286
|
-
constructor(bare,
|
|
7286
|
+
constructor(bare, path12, existing, gitDir) {
|
|
7287
7287
|
this.bare = bare;
|
|
7288
|
-
this.path =
|
|
7288
|
+
this.path = path12;
|
|
7289
7289
|
this.existing = existing;
|
|
7290
7290
|
this.gitDir = gitDir;
|
|
7291
7291
|
}
|
|
@@ -7297,7 +7297,7 @@ var init_InitSummary = __esm({
|
|
|
7297
7297
|
function hasBareCommand(command) {
|
|
7298
7298
|
return command.includes(bareCommand);
|
|
7299
7299
|
}
|
|
7300
|
-
function initTask(bare = false,
|
|
7300
|
+
function initTask(bare = false, path12, customArgs) {
|
|
7301
7301
|
const commands = ["init", ...customArgs];
|
|
7302
7302
|
if (bare && !hasBareCommand(commands)) {
|
|
7303
7303
|
commands.splice(1, 0, bareCommand);
|
|
@@ -7306,7 +7306,7 @@ function initTask(bare = false, path11, customArgs) {
|
|
|
7306
7306
|
commands,
|
|
7307
7307
|
format: "utf-8",
|
|
7308
7308
|
parser(text2) {
|
|
7309
|
-
return parseInit(commands.includes("--bare"),
|
|
7309
|
+
return parseInit(commands.includes("--bare"), path12, text2);
|
|
7310
7310
|
}
|
|
7311
7311
|
};
|
|
7312
7312
|
}
|
|
@@ -8122,12 +8122,12 @@ var init_FileStatusSummary = __esm({
|
|
|
8122
8122
|
"use strict";
|
|
8123
8123
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
8124
8124
|
FileStatusSummary = class {
|
|
8125
|
-
constructor(
|
|
8126
|
-
this.path =
|
|
8125
|
+
constructor(path12, index, working_dir) {
|
|
8126
|
+
this.path = path12;
|
|
8127
8127
|
this.index = index;
|
|
8128
8128
|
this.working_dir = working_dir;
|
|
8129
8129
|
if (index === "R" || working_dir === "R") {
|
|
8130
|
-
const detail = fromPathRegex.exec(
|
|
8130
|
+
const detail = fromPathRegex.exec(path12) || [null, path12, path12];
|
|
8131
8131
|
this.from = detail[2] || "";
|
|
8132
8132
|
this.path = detail[1] || "";
|
|
8133
8133
|
}
|
|
@@ -8158,14 +8158,14 @@ function splitLine(result, lineStr) {
|
|
|
8158
8158
|
default:
|
|
8159
8159
|
return;
|
|
8160
8160
|
}
|
|
8161
|
-
function data(index, workingDir,
|
|
8161
|
+
function data(index, workingDir, path12) {
|
|
8162
8162
|
const raw = `${index}${workingDir}`;
|
|
8163
8163
|
const handler = parsers6.get(raw);
|
|
8164
8164
|
if (handler) {
|
|
8165
|
-
handler(result,
|
|
8165
|
+
handler(result, path12);
|
|
8166
8166
|
}
|
|
8167
8167
|
if (raw !== "##" && raw !== "!!") {
|
|
8168
|
-
result.files.push(new FileStatusSummary(
|
|
8168
|
+
result.files.push(new FileStatusSummary(path12, index, workingDir));
|
|
8169
8169
|
}
|
|
8170
8170
|
}
|
|
8171
8171
|
}
|
|
@@ -8478,9 +8478,9 @@ var init_simple_git_api = __esm({
|
|
|
8478
8478
|
next
|
|
8479
8479
|
);
|
|
8480
8480
|
}
|
|
8481
|
-
hashObject(
|
|
8481
|
+
hashObject(path12, write) {
|
|
8482
8482
|
return this._runTask(
|
|
8483
|
-
hashObjectTask(
|
|
8483
|
+
hashObjectTask(path12, write === true),
|
|
8484
8484
|
trailingFunctionArgument(arguments)
|
|
8485
8485
|
);
|
|
8486
8486
|
}
|
|
@@ -8833,8 +8833,8 @@ var init_branch = __esm({
|
|
|
8833
8833
|
}
|
|
8834
8834
|
});
|
|
8835
8835
|
function toPath(input) {
|
|
8836
|
-
const
|
|
8837
|
-
return
|
|
8836
|
+
const path12 = input.trim().replace(/^["']|["']$/g, "");
|
|
8837
|
+
return path12 && normalize2(path12);
|
|
8838
8838
|
}
|
|
8839
8839
|
var parseCheckIgnore;
|
|
8840
8840
|
var init_CheckIgnore = __esm({
|
|
@@ -9148,8 +9148,8 @@ __export(sub_module_exports, {
|
|
|
9148
9148
|
subModuleTask: () => subModuleTask,
|
|
9149
9149
|
updateSubModuleTask: () => updateSubModuleTask
|
|
9150
9150
|
});
|
|
9151
|
-
function addSubModuleTask(repo,
|
|
9152
|
-
return subModuleTask(["add", repo,
|
|
9151
|
+
function addSubModuleTask(repo, path12) {
|
|
9152
|
+
return subModuleTask(["add", repo, path12]);
|
|
9153
9153
|
}
|
|
9154
9154
|
function initSubModuleTask(customArgs) {
|
|
9155
9155
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -9479,8 +9479,8 @@ var require_git = __commonJS2({
|
|
|
9479
9479
|
}
|
|
9480
9480
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
9481
9481
|
};
|
|
9482
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
9483
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
9482
|
+
Git2.prototype.submoduleAdd = function(repo, path12, then) {
|
|
9483
|
+
return this._runTask(addSubModuleTask2(repo, path12), trailingFunctionArgument2(arguments));
|
|
9484
9484
|
};
|
|
9485
9485
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
9486
9486
|
return this._runTask(
|
|
@@ -10082,15 +10082,15 @@ function createGitClient(baseDir, options) {
|
|
|
10082
10082
|
// ../git/dist/lock-detector.js
|
|
10083
10083
|
import { execFile } from "child_process";
|
|
10084
10084
|
import fs6 from "fs/promises";
|
|
10085
|
-
import
|
|
10085
|
+
import path8 from "path";
|
|
10086
10086
|
import { promisify } from "util";
|
|
10087
10087
|
var execFileAsync = promisify(execFile);
|
|
10088
10088
|
async function getIndexLockPath(repoPath) {
|
|
10089
10089
|
try {
|
|
10090
10090
|
const { stdout } = await execFileAsync("git", ["rev-parse", "--git-path", "index.lock"], { cwd: repoPath });
|
|
10091
|
-
return
|
|
10091
|
+
return path8.resolve(repoPath, stdout.trim());
|
|
10092
10092
|
} catch {
|
|
10093
|
-
return
|
|
10093
|
+
return path8.join(repoPath, ".git", "index.lock");
|
|
10094
10094
|
}
|
|
10095
10095
|
}
|
|
10096
10096
|
async function getLockInfo(repoPath) {
|
|
@@ -10279,7 +10279,7 @@ import { join as join7 } from "path";
|
|
|
10279
10279
|
// ../git/dist/sagas/tree.js
|
|
10280
10280
|
import { existsSync as existsSync4 } from "fs";
|
|
10281
10281
|
import * as fs8 from "fs/promises";
|
|
10282
|
-
import * as
|
|
10282
|
+
import * as path10 from "path";
|
|
10283
10283
|
import * as tar from "tar";
|
|
10284
10284
|
|
|
10285
10285
|
// ../git/dist/git-saga.js
|
|
@@ -10306,14 +10306,14 @@ var CaptureTreeSaga = class extends GitSaga {
|
|
|
10306
10306
|
tempIndexPath = null;
|
|
10307
10307
|
async executeGitOperations(input) {
|
|
10308
10308
|
const { baseDir, lastTreeHash, archivePath, signal } = input;
|
|
10309
|
-
const tmpDir =
|
|
10309
|
+
const tmpDir = path10.join(baseDir, ".git", "posthog-code-tmp");
|
|
10310
10310
|
await this.step({
|
|
10311
10311
|
name: "create_tmp_dir",
|
|
10312
10312
|
execute: () => fs8.mkdir(tmpDir, { recursive: true }),
|
|
10313
10313
|
rollback: async () => {
|
|
10314
10314
|
}
|
|
10315
10315
|
});
|
|
10316
|
-
this.tempIndexPath =
|
|
10316
|
+
this.tempIndexPath = path10.join(tmpDir, `index-${Date.now()}`);
|
|
10317
10317
|
const tempIndexGit = this.git.env({
|
|
10318
10318
|
...process.env,
|
|
10319
10319
|
GIT_INDEX_FILE: this.tempIndexPath
|
|
@@ -10368,14 +10368,14 @@ var CaptureTreeSaga = class extends GitSaga {
|
|
|
10368
10368
|
if (filesToArchive.length === 0) {
|
|
10369
10369
|
return void 0;
|
|
10370
10370
|
}
|
|
10371
|
-
const existingFiles = filesToArchive.filter((f) => existsSync4(
|
|
10371
|
+
const existingFiles = filesToArchive.filter((f) => existsSync4(path10.join(baseDir, f)));
|
|
10372
10372
|
if (existingFiles.length === 0) {
|
|
10373
10373
|
return void 0;
|
|
10374
10374
|
}
|
|
10375
10375
|
await this.step({
|
|
10376
10376
|
name: "create_archive",
|
|
10377
10377
|
execute: async () => {
|
|
10378
|
-
const archiveDir =
|
|
10378
|
+
const archiveDir = path10.dirname(archivePath);
|
|
10379
10379
|
await fs8.mkdir(archiveDir, { recursive: true });
|
|
10380
10380
|
await tar.create({
|
|
10381
10381
|
gzip: true,
|
|
@@ -10484,7 +10484,7 @@ var ApplyTreeSaga = class extends GitSaga {
|
|
|
10484
10484
|
const filesToExtract = changes.filter((c) => c.status !== "D").map((c) => c.path);
|
|
10485
10485
|
await this.readOnlyStep("backup_existing_files", async () => {
|
|
10486
10486
|
for (const filePath of filesToExtract) {
|
|
10487
|
-
const fullPath =
|
|
10487
|
+
const fullPath = path10.join(baseDir, filePath);
|
|
10488
10488
|
try {
|
|
10489
10489
|
const content = await fs8.readFile(fullPath);
|
|
10490
10490
|
this.fileBackups.set(filePath, content);
|
|
@@ -10503,10 +10503,10 @@ var ApplyTreeSaga = class extends GitSaga {
|
|
|
10503
10503
|
},
|
|
10504
10504
|
rollback: async () => {
|
|
10505
10505
|
for (const filePath of this.extractedFiles) {
|
|
10506
|
-
const fullPath =
|
|
10506
|
+
const fullPath = path10.join(baseDir, filePath);
|
|
10507
10507
|
const backup = this.fileBackups.get(filePath);
|
|
10508
10508
|
if (backup) {
|
|
10509
|
-
const dir =
|
|
10509
|
+
const dir = path10.dirname(fullPath);
|
|
10510
10510
|
await fs8.mkdir(dir, { recursive: true }).catch(() => {
|
|
10511
10511
|
});
|
|
10512
10512
|
await fs8.writeFile(fullPath, backup).catch(() => {
|
|
@@ -10520,7 +10520,7 @@ var ApplyTreeSaga = class extends GitSaga {
|
|
|
10520
10520
|
});
|
|
10521
10521
|
}
|
|
10522
10522
|
for (const change of changes.filter((c) => c.status === "D")) {
|
|
10523
|
-
const fullPath =
|
|
10523
|
+
const fullPath = path10.join(baseDir, change.path);
|
|
10524
10524
|
const backupContent = await this.readOnlyStep(`backup_${change.path}`, async () => {
|
|
10525
10525
|
try {
|
|
10526
10526
|
return await fs8.readFile(fullPath);
|
|
@@ -10536,7 +10536,7 @@ var ApplyTreeSaga = class extends GitSaga {
|
|
|
10536
10536
|
},
|
|
10537
10537
|
rollback: async () => {
|
|
10538
10538
|
if (backupContent) {
|
|
10539
|
-
const dir =
|
|
10539
|
+
const dir = path10.dirname(fullPath);
|
|
10540
10540
|
await fs8.mkdir(dir, { recursive: true }).catch(() => {
|
|
10541
10541
|
});
|
|
10542
10542
|
await fs8.writeFile(fullPath, backupContent).catch(() => {
|
|
@@ -11102,7 +11102,7 @@ async function resumeFromLog(config) {
|
|
|
11102
11102
|
// src/session-log-writer.ts
|
|
11103
11103
|
import fs9 from "fs";
|
|
11104
11104
|
import fsp from "fs/promises";
|
|
11105
|
-
import
|
|
11105
|
+
import path11 from "path";
|
|
11106
11106
|
var SessionLogWriter = class _SessionLogWriter {
|
|
11107
11107
|
static FLUSH_DEBOUNCE_MS = 500;
|
|
11108
11108
|
static FLUSH_MAX_INTERVAL_MS = 5e3;
|
|
@@ -11141,7 +11141,7 @@ var SessionLogWriter = class _SessionLogWriter {
|
|
|
11141
11141
|
this.sessions.set(sessionId, { context, currentTurnMessages: [] });
|
|
11142
11142
|
this.lastFlushAttemptTime.set(sessionId, Date.now());
|
|
11143
11143
|
if (this.localCachePath) {
|
|
11144
|
-
const sessionDir =
|
|
11144
|
+
const sessionDir = path11.join(
|
|
11145
11145
|
this.localCachePath,
|
|
11146
11146
|
"sessions",
|
|
11147
11147
|
context.runId
|
|
@@ -11363,7 +11363,7 @@ var SessionLogWriter = class _SessionLogWriter {
|
|
|
11363
11363
|
if (!this.localCachePath) return;
|
|
11364
11364
|
const session = this.sessions.get(sessionId);
|
|
11365
11365
|
if (!session) return;
|
|
11366
|
-
const logPath =
|
|
11366
|
+
const logPath = path11.join(
|
|
11367
11367
|
this.localCachePath,
|
|
11368
11368
|
"sessions",
|
|
11369
11369
|
session.context.runId,
|
|
@@ -11382,13 +11382,13 @@ var SessionLogWriter = class _SessionLogWriter {
|
|
|
11382
11382
|
}
|
|
11383
11383
|
}
|
|
11384
11384
|
static async cleanupOldSessions(localCachePath) {
|
|
11385
|
-
const sessionsDir =
|
|
11385
|
+
const sessionsDir = path11.join(localCachePath, "sessions");
|
|
11386
11386
|
let deleted = 0;
|
|
11387
11387
|
try {
|
|
11388
11388
|
const entries = await fsp.readdir(sessionsDir);
|
|
11389
11389
|
const now = Date.now();
|
|
11390
11390
|
for (const entry of entries) {
|
|
11391
|
-
const entryPath =
|
|
11391
|
+
const entryPath = path11.join(sessionsDir, entry);
|
|
11392
11392
|
try {
|
|
11393
11393
|
const stats = await fsp.stat(entryPath);
|
|
11394
11394
|
if (stats.isDirectory() && now - stats.birthtimeMs > _SessionLogWriter.SESSIONS_MAX_AGE_MS) {
|