@posthog/agent 2.3.53 → 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/adapters/claude/conversion/tool-use-to-acp.js.map +1 -1
- package/dist/adapters/claude/tools.js.map +1 -1
- package/dist/agent.js +66 -46
- package/dist/agent.js.map +1 -1
- package/dist/index.d.ts +7 -1
- package/dist/index.js +4 -0
- package/dist/index.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 +118 -98
- package/dist/server/agent-server.js.map +1 -1
- package/dist/server/bin.cjs +105 -85
- package/dist/server/bin.cjs.map +1 -1
- package/dist/types.d.ts +1 -0
- package/package.json +3 -3
- package/src/adapters/claude/claude-agent.ts +12 -2
- package/src/adapters/claude/conversion/acp-to-sdk.ts +3 -3
- package/src/adapters/claude/conversion/sdk-to-acp.ts +22 -1
- package/src/adapters/claude/mcp/tool-metadata.ts +10 -0
- package/src/index.ts +5 -1
- package/src/types.ts +1 -0
package/dist/server/bin.cjs
CHANGED
|
@@ -805,10 +805,10 @@ var require_src2 = __commonJS({
|
|
|
805
805
|
var fs_1 = require("fs");
|
|
806
806
|
var debug_1 = __importDefault(require_src());
|
|
807
807
|
var log = debug_1.default("@kwsites/file-exists");
|
|
808
|
-
function check(
|
|
809
|
-
log(`checking %s`,
|
|
808
|
+
function check(path12, isFile, isDirectory) {
|
|
809
|
+
log(`checking %s`, path12);
|
|
810
810
|
try {
|
|
811
|
-
const stat = fs_1.statSync(
|
|
811
|
+
const stat = fs_1.statSync(path12);
|
|
812
812
|
if (stat.isFile() && isFile) {
|
|
813
813
|
log(`[OK] path represents a file`);
|
|
814
814
|
return true;
|
|
@@ -828,8 +828,8 @@ var require_src2 = __commonJS({
|
|
|
828
828
|
throw e;
|
|
829
829
|
}
|
|
830
830
|
}
|
|
831
|
-
function exists2(
|
|
832
|
-
return check(
|
|
831
|
+
function exists2(path12, type = exports2.READABLE) {
|
|
832
|
+
return check(path12, (type & exports2.FILE) > 0, (type & exports2.FOLDER) > 0);
|
|
833
833
|
}
|
|
834
834
|
exports2.exists = exists2;
|
|
835
835
|
exports2.FILE = 1;
|
|
@@ -904,7 +904,7 @@ var import_hono = require("hono");
|
|
|
904
904
|
// package.json
|
|
905
905
|
var package_default = {
|
|
906
906
|
name: "@posthog/agent",
|
|
907
|
-
version: "2.3.
|
|
907
|
+
version: "2.3.67",
|
|
908
908
|
repository: "https://github.com/PostHog/code",
|
|
909
909
|
description: "TypeScript agent framework wrapping Claude Agent SDK with Git-based task execution for PostHog",
|
|
910
910
|
exports: {
|
|
@@ -968,13 +968,13 @@ var package_default = {
|
|
|
968
968
|
author: "PostHog",
|
|
969
969
|
license: "SEE LICENSE IN LICENSE",
|
|
970
970
|
scripts: {
|
|
971
|
-
build: "
|
|
971
|
+
build: "node ../../scripts/rimraf.mjs dist && tsup",
|
|
972
972
|
dev: "tsup --watch",
|
|
973
973
|
test: "vitest run",
|
|
974
974
|
"test:watch": "vitest",
|
|
975
975
|
typecheck: "pnpm exec tsc --noEmit",
|
|
976
976
|
prepublishOnly: "pnpm run build",
|
|
977
|
-
clean: "
|
|
977
|
+
clean: "node ../../scripts/rimraf.mjs dist .turbo"
|
|
978
978
|
},
|
|
979
979
|
engines: {
|
|
980
980
|
node: ">=20.0.0"
|
|
@@ -1290,7 +1290,7 @@ function nodeWritableToWebWritable(nodeStream) {
|
|
|
1290
1290
|
var import_node_crypto = require("crypto");
|
|
1291
1291
|
var fs4 = __toESM(require("fs"), 1);
|
|
1292
1292
|
var os4 = __toESM(require("os"), 1);
|
|
1293
|
-
var
|
|
1293
|
+
var path6 = __toESM(require("path"), 1);
|
|
1294
1294
|
var import_sdk2 = require("@agentclientprotocol/sdk");
|
|
1295
1295
|
var import_claude_agent_sdk = require("@anthropic-ai/claude-agent-sdk");
|
|
1296
1296
|
var import_uuid = require("uuid");
|
|
@@ -1455,6 +1455,7 @@ var BaseAcpAgent = class {
|
|
|
1455
1455
|
};
|
|
1456
1456
|
|
|
1457
1457
|
// src/adapters/claude/conversion/acp-to-sdk.ts
|
|
1458
|
+
var path = __toESM(require("path"), 1);
|
|
1458
1459
|
function sdkText(value) {
|
|
1459
1460
|
return { type: "text", text: value };
|
|
1460
1461
|
}
|
|
@@ -1462,12 +1463,11 @@ function formatUriAsLink(uri) {
|
|
|
1462
1463
|
try {
|
|
1463
1464
|
if (uri.startsWith("file://")) {
|
|
1464
1465
|
const filePath = uri.slice(7);
|
|
1465
|
-
const name =
|
|
1466
|
+
const name = path.basename(filePath) || filePath;
|
|
1466
1467
|
return `[@${name}](${uri})`;
|
|
1467
1468
|
}
|
|
1468
1469
|
if (uri.startsWith("zed://")) {
|
|
1469
|
-
const
|
|
1470
|
-
const name = parts[parts.length - 1] || uri;
|
|
1470
|
+
const name = path.basename(uri) || uri;
|
|
1471
1471
|
return `[@${name}](${uri})`;
|
|
1472
1472
|
}
|
|
1473
1473
|
return uri;
|
|
@@ -1572,8 +1572,8 @@ var ToolContentBuilder = class {
|
|
|
1572
1572
|
this.items.push({ type: "content", content: image(data, mimeType, uri) });
|
|
1573
1573
|
return this;
|
|
1574
1574
|
}
|
|
1575
|
-
diff(
|
|
1576
|
-
this.items.push({ type: "diff", path:
|
|
1575
|
+
diff(path12, oldText, newText) {
|
|
1576
|
+
this.items.push({ type: "diff", path: path12, oldText, newText });
|
|
1577
1577
|
return this;
|
|
1578
1578
|
}
|
|
1579
1579
|
build() {
|
|
@@ -1729,6 +1729,14 @@ function isMcpToolReadOnly(toolName) {
|
|
|
1729
1729
|
const metadata = mcpToolMetadataCache.get(toolName);
|
|
1730
1730
|
return metadata?.readOnly === true;
|
|
1731
1731
|
}
|
|
1732
|
+
function getConnectedMcpServerNames() {
|
|
1733
|
+
const names = /* @__PURE__ */ new Set();
|
|
1734
|
+
for (const key of mcpToolMetadataCache.keys()) {
|
|
1735
|
+
const parts = key.split("__");
|
|
1736
|
+
if (parts.length >= 3) names.add(parts[1]);
|
|
1737
|
+
}
|
|
1738
|
+
return [...names];
|
|
1739
|
+
}
|
|
1732
1740
|
|
|
1733
1741
|
// src/adapters/claude/conversion/tool-use-to-acp.ts
|
|
1734
1742
|
var SYSTEM_REMINDER_REGEX = /\s*<system-reminder>[\s\S]*?<\/system-reminder>/g;
|
|
@@ -2485,7 +2493,10 @@ function handleToolResultChunk(chunk, ctx) {
|
|
|
2485
2493
|
toolCallId: chunk.tool_use_id,
|
|
2486
2494
|
sessionUpdate: "tool_call_update",
|
|
2487
2495
|
status: chunk.is_error ? "failed" : "completed",
|
|
2488
|
-
rawOutput: chunk.
|
|
2496
|
+
rawOutput: ctx.mcpToolUseResult ? { ...ctx.mcpToolUseResult, isError: chunk.is_error ?? false } : {
|
|
2497
|
+
content: Array.isArray(chunk.content) ? chunk.content : typeof chunk.content === "string" ? [{ type: "text", text: chunk.content }] : [],
|
|
2498
|
+
isError: chunk.is_error ?? false
|
|
2499
|
+
},
|
|
2489
2500
|
...toolUpdate
|
|
2490
2501
|
});
|
|
2491
2502
|
return updates;
|
|
@@ -2539,7 +2550,7 @@ function processContentChunk(chunk, role, ctx) {
|
|
|
2539
2550
|
return [];
|
|
2540
2551
|
}
|
|
2541
2552
|
}
|
|
2542
|
-
function toAcpNotifications(content, role, sessionId, toolUseCache, fileContentCache, client, logger, parentToolCallId, registerHooks, supportsTerminalOutput, cwd) {
|
|
2553
|
+
function toAcpNotifications(content, role, sessionId, toolUseCache, fileContentCache, client, logger, parentToolCallId, registerHooks, supportsTerminalOutput, cwd, mcpToolUseResult) {
|
|
2543
2554
|
if (typeof content === "string") {
|
|
2544
2555
|
const update = {
|
|
2545
2556
|
sessionUpdate: messageUpdateType(role),
|
|
@@ -2563,7 +2574,8 @@ function toAcpNotifications(content, role, sessionId, toolUseCache, fileContentC
|
|
|
2563
2574
|
parentToolCallId,
|
|
2564
2575
|
registerHooks,
|
|
2565
2576
|
supportsTerminalOutput,
|
|
2566
|
-
cwd
|
|
2577
|
+
cwd,
|
|
2578
|
+
mcpToolUseResult
|
|
2567
2579
|
};
|
|
2568
2580
|
const output = [];
|
|
2569
2581
|
for (const chunk of content) {
|
|
@@ -2822,6 +2834,7 @@ async function handleUserAssistantMessage(message, context) {
|
|
|
2822
2834
|
const content = message.message.content;
|
|
2823
2835
|
const contentToProcess = message.type === "assistant" ? filterMessageContent(content) : content;
|
|
2824
2836
|
const parentToolCallId = "parent_tool_use_id" in message ? message.parent_tool_use_id ?? void 0 : void 0;
|
|
2837
|
+
const mcpToolUseResult = message.type === "user" && message.tool_use_result != null ? message.tool_use_result : void 0;
|
|
2825
2838
|
for (const notification of toAcpNotifications(
|
|
2826
2839
|
contentToProcess,
|
|
2827
2840
|
message.message.role,
|
|
@@ -2833,7 +2846,8 @@ async function handleUserAssistantMessage(message, context) {
|
|
|
2833
2846
|
parentToolCallId,
|
|
2834
2847
|
context.registerHooks,
|
|
2835
2848
|
context.supportsTerminalOutput,
|
|
2836
|
-
session.cwd
|
|
2849
|
+
session.cwd,
|
|
2850
|
+
mcpToolUseResult
|
|
2837
2851
|
)) {
|
|
2838
2852
|
await client.sessionUpdate(notification);
|
|
2839
2853
|
session.notificationHistory.push(notification);
|
|
@@ -2843,18 +2857,18 @@ async function handleUserAssistantMessage(message, context) {
|
|
|
2843
2857
|
|
|
2844
2858
|
// src/adapters/claude/plan/utils.ts
|
|
2845
2859
|
var os = __toESM(require("os"), 1);
|
|
2846
|
-
var
|
|
2860
|
+
var path3 = __toESM(require("path"), 1);
|
|
2847
2861
|
function getClaudeConfigDir() {
|
|
2848
|
-
return process.env.CLAUDE_CONFIG_DIR ||
|
|
2862
|
+
return process.env.CLAUDE_CONFIG_DIR || path3.join(os.homedir(), ".claude");
|
|
2849
2863
|
}
|
|
2850
2864
|
function getClaudePlansDir() {
|
|
2851
|
-
return
|
|
2865
|
+
return path3.join(getClaudeConfigDir(), "plans");
|
|
2852
2866
|
}
|
|
2853
2867
|
function isClaudePlanFilePath(filePath) {
|
|
2854
2868
|
if (!filePath) return false;
|
|
2855
|
-
const resolved =
|
|
2856
|
-
const plansDir =
|
|
2857
|
-
return resolved === plansDir || resolved.startsWith(plansDir +
|
|
2869
|
+
const resolved = path3.resolve(filePath);
|
|
2870
|
+
const plansDir = path3.resolve(getClaudePlansDir());
|
|
2871
|
+
return resolved === plansDir || resolved.startsWith(plansDir + path3.sep);
|
|
2858
2872
|
}
|
|
2859
2873
|
function isPlanReady(plan) {
|
|
2860
2874
|
if (!plan) return false;
|
|
@@ -3494,7 +3508,7 @@ function getEffortOptions(modelId) {
|
|
|
3494
3508
|
var import_node_child_process = require("child_process");
|
|
3495
3509
|
var fs2 = __toESM(require("fs"), 1);
|
|
3496
3510
|
var os2 = __toESM(require("os"), 1);
|
|
3497
|
-
var
|
|
3511
|
+
var path4 = __toESM(require("path"), 1);
|
|
3498
3512
|
|
|
3499
3513
|
// src/adapters/claude/session/instructions.ts
|
|
3500
3514
|
var BRANCH_NAMING = `
|
|
@@ -3640,8 +3654,8 @@ function buildSpawnWrapper(sessionId, onProcessSpawned, onProcessExited, logger)
|
|
|
3640
3654
|
};
|
|
3641
3655
|
}
|
|
3642
3656
|
function ensureLocalSettings(cwd) {
|
|
3643
|
-
const claudeDir =
|
|
3644
|
-
const localSettingsPath =
|
|
3657
|
+
const claudeDir = path4.join(cwd, ".claude");
|
|
3658
|
+
const localSettingsPath = path4.join(claudeDir, "settings.local.json");
|
|
3645
3659
|
try {
|
|
3646
3660
|
if (!fs2.existsSync(localSettingsPath)) {
|
|
3647
3661
|
fs2.mkdirSync(claudeDir, { recursive: true });
|
|
@@ -3712,8 +3726,8 @@ function buildSessionOptions(params) {
|
|
|
3712
3726
|
return options;
|
|
3713
3727
|
}
|
|
3714
3728
|
function clearStatsigCache() {
|
|
3715
|
-
const statsigPath =
|
|
3716
|
-
process.env.CLAUDE_CONFIG_DIR ||
|
|
3729
|
+
const statsigPath = path4.join(
|
|
3730
|
+
process.env.CLAUDE_CONFIG_DIR || path4.join(os2.homedir(), ".claude"),
|
|
3717
3731
|
"statsig"
|
|
3718
3732
|
);
|
|
3719
3733
|
fs2.rm(statsigPath, { recursive: true, force: true }, () => {
|
|
@@ -3723,7 +3737,7 @@ function clearStatsigCache() {
|
|
|
3723
3737
|
// src/adapters/claude/session/settings.ts
|
|
3724
3738
|
var fs3 = __toESM(require("fs"), 1);
|
|
3725
3739
|
var os3 = __toESM(require("os"), 1);
|
|
3726
|
-
var
|
|
3740
|
+
var path5 = __toESM(require("path"), 1);
|
|
3727
3741
|
var import_minimatch = require("minimatch");
|
|
3728
3742
|
var ACP_TOOL_NAME_PREFIX = "mcp__acp__";
|
|
3729
3743
|
var acpToolNames = {
|
|
@@ -3763,13 +3777,13 @@ function parseRule(rule) {
|
|
|
3763
3777
|
function normalizePath(filePath, cwd) {
|
|
3764
3778
|
let resolved = filePath;
|
|
3765
3779
|
if (resolved.startsWith("~/")) {
|
|
3766
|
-
resolved =
|
|
3780
|
+
resolved = path5.join(os3.homedir(), resolved.slice(2));
|
|
3767
3781
|
} else if (resolved.startsWith("./")) {
|
|
3768
|
-
resolved =
|
|
3769
|
-
} else if (!
|
|
3770
|
-
resolved =
|
|
3782
|
+
resolved = path5.join(cwd, resolved.slice(2));
|
|
3783
|
+
} else if (!path5.isAbsolute(resolved)) {
|
|
3784
|
+
resolved = path5.join(cwd, resolved);
|
|
3771
3785
|
}
|
|
3772
|
-
return
|
|
3786
|
+
return path5.normalize(resolved).replace(/\\/g, "/");
|
|
3773
3787
|
}
|
|
3774
3788
|
function matchesGlob(pattern, filePath, cwd) {
|
|
3775
3789
|
const normalizedPattern = normalizePath(pattern, cwd);
|
|
@@ -3853,14 +3867,14 @@ var SettingsManager = class {
|
|
|
3853
3867
|
this.initialized = true;
|
|
3854
3868
|
}
|
|
3855
3869
|
getUserSettingsPath() {
|
|
3856
|
-
const configDir = process.env.CLAUDE_CONFIG_DIR ||
|
|
3857
|
-
return
|
|
3870
|
+
const configDir = process.env.CLAUDE_CONFIG_DIR || path5.join(os3.homedir(), ".claude");
|
|
3871
|
+
return path5.join(configDir, "settings.json");
|
|
3858
3872
|
}
|
|
3859
3873
|
getProjectSettingsPath() {
|
|
3860
|
-
return
|
|
3874
|
+
return path5.join(this.cwd, ".claude", "settings.json");
|
|
3861
3875
|
}
|
|
3862
3876
|
getLocalSettingsPath() {
|
|
3863
|
-
return
|
|
3877
|
+
return path5.join(this.cwd, ".claude", "settings.local.json");
|
|
3864
3878
|
}
|
|
3865
3879
|
async loadAllSettings() {
|
|
3866
3880
|
const [userSettings, projectSettings, localSettings, enterpriseSettings] = await Promise.all([
|
|
@@ -4025,7 +4039,7 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
4025
4039
|
};
|
|
4026
4040
|
}
|
|
4027
4041
|
async newSession(params) {
|
|
4028
|
-
if (fs4.existsSync(
|
|
4042
|
+
if (fs4.existsSync(path6.resolve(os4.homedir(), ".claude.json.backup")) && !fs4.existsSync(path6.resolve(os4.homedir(), ".claude.json"))) {
|
|
4029
4043
|
throw import_sdk2.RequestError.authRequired();
|
|
4030
4044
|
}
|
|
4031
4045
|
const response = await this.createSession(params, {
|
|
@@ -4673,11 +4687,17 @@ var ClaudeAcpAgent = class extends BaseAcpAgent {
|
|
|
4673
4687
|
* Both populate caches used later — neither is needed to return configOptions.
|
|
4674
4688
|
*/
|
|
4675
4689
|
deferBackgroundFetches(q) {
|
|
4690
|
+
this.logger.info("Starting background fetches (commands + MCP metadata)");
|
|
4676
4691
|
Promise.all([
|
|
4677
4692
|
new Promise((resolve4) => setTimeout(resolve4, 10)).then(
|
|
4678
4693
|
() => this.sendAvailableCommandsUpdate()
|
|
4679
4694
|
),
|
|
4680
|
-
fetchMcpToolMetadata(q, this.logger)
|
|
4695
|
+
fetchMcpToolMetadata(q, this.logger).then(() => {
|
|
4696
|
+
const serverNames = getConnectedMcpServerNames();
|
|
4697
|
+
if (serverNames.length > 0) {
|
|
4698
|
+
this.options?.onMcpServersReady?.(serverNames);
|
|
4699
|
+
}
|
|
4700
|
+
})
|
|
4681
4701
|
]).catch(
|
|
4682
4702
|
(err) => this.logger.error("Background fetch failed", { error: err })
|
|
4683
4703
|
);
|
|
@@ -5141,7 +5161,7 @@ function createCodexConnection(config) {
|
|
|
5141
5161
|
var import_node_crypto2 = require("crypto");
|
|
5142
5162
|
var fs5 = __toESM(require("fs/promises"), 1);
|
|
5143
5163
|
var os5 = __toESM(require("os"), 1);
|
|
5144
|
-
var
|
|
5164
|
+
var path7 = __toESM(require("path"), 1);
|
|
5145
5165
|
var CHARS_PER_TOKEN = 4;
|
|
5146
5166
|
var DEFAULT_MAX_TOKENS = 15e4;
|
|
5147
5167
|
function estimateTurnTokens(turn) {
|
|
@@ -5488,7 +5508,7 @@ var Saga = class {
|
|
|
5488
5508
|
|
|
5489
5509
|
// ../git/dist/queries.js
|
|
5490
5510
|
var fs7 = __toESM(require("fs/promises"), 1);
|
|
5491
|
-
var
|
|
5511
|
+
var path9 = __toESM(require("path"), 1);
|
|
5492
5512
|
|
|
5493
5513
|
// ../../node_modules/simple-git/dist/esm/index.js
|
|
5494
5514
|
var import_node_buffer = require("buffer");
|
|
@@ -5527,8 +5547,8 @@ function pathspec(...paths) {
|
|
|
5527
5547
|
cache.set(key, paths);
|
|
5528
5548
|
return key;
|
|
5529
5549
|
}
|
|
5530
|
-
function isPathSpec(
|
|
5531
|
-
return
|
|
5550
|
+
function isPathSpec(path12) {
|
|
5551
|
+
return path12 instanceof String && cache.has(path12);
|
|
5532
5552
|
}
|
|
5533
5553
|
function toPaths(pathSpec) {
|
|
5534
5554
|
return cache.get(pathSpec) || [];
|
|
@@ -5617,8 +5637,8 @@ function toLinesWithContent(input = "", trimmed2 = true, separator = "\n") {
|
|
|
5617
5637
|
function forEachLineWithContent(input, callback) {
|
|
5618
5638
|
return toLinesWithContent(input, true).map((line) => callback(line));
|
|
5619
5639
|
}
|
|
5620
|
-
function folderExists(
|
|
5621
|
-
return (0, import_file_exists.exists)(
|
|
5640
|
+
function folderExists(path12) {
|
|
5641
|
+
return (0, import_file_exists.exists)(path12, import_file_exists.FOLDER);
|
|
5622
5642
|
}
|
|
5623
5643
|
function append(target, item) {
|
|
5624
5644
|
if (Array.isArray(target)) {
|
|
@@ -6022,8 +6042,8 @@ function checkIsRepoRootTask() {
|
|
|
6022
6042
|
commands,
|
|
6023
6043
|
format: "utf-8",
|
|
6024
6044
|
onError,
|
|
6025
|
-
parser(
|
|
6026
|
-
return /^\.(git)?$/.test(
|
|
6045
|
+
parser(path12) {
|
|
6046
|
+
return /^\.(git)?$/.test(path12.trim());
|
|
6027
6047
|
}
|
|
6028
6048
|
};
|
|
6029
6049
|
}
|
|
@@ -6457,11 +6477,11 @@ function parseGrep(grep) {
|
|
|
6457
6477
|
const paths = /* @__PURE__ */ new Set();
|
|
6458
6478
|
const results = {};
|
|
6459
6479
|
forEachLineWithContent(grep, (input) => {
|
|
6460
|
-
const [
|
|
6461
|
-
paths.add(
|
|
6462
|
-
(results[
|
|
6480
|
+
const [path12, line, preview] = input.split(NULL);
|
|
6481
|
+
paths.add(path12);
|
|
6482
|
+
(results[path12] = results[path12] || []).push({
|
|
6463
6483
|
line: asNumber(line),
|
|
6464
|
-
path:
|
|
6484
|
+
path: path12,
|
|
6465
6485
|
preview
|
|
6466
6486
|
});
|
|
6467
6487
|
});
|
|
@@ -7226,14 +7246,14 @@ var init_hash_object = __esm({
|
|
|
7226
7246
|
init_task();
|
|
7227
7247
|
}
|
|
7228
7248
|
});
|
|
7229
|
-
function parseInit(bare,
|
|
7249
|
+
function parseInit(bare, path12, text2) {
|
|
7230
7250
|
const response = String(text2).trim();
|
|
7231
7251
|
let result;
|
|
7232
7252
|
if (result = initResponseRegex.exec(response)) {
|
|
7233
|
-
return new InitSummary(bare,
|
|
7253
|
+
return new InitSummary(bare, path12, false, result[1]);
|
|
7234
7254
|
}
|
|
7235
7255
|
if (result = reInitResponseRegex.exec(response)) {
|
|
7236
|
-
return new InitSummary(bare,
|
|
7256
|
+
return new InitSummary(bare, path12, true, result[1]);
|
|
7237
7257
|
}
|
|
7238
7258
|
let gitDir = "";
|
|
7239
7259
|
const tokens = response.split(" ");
|
|
@@ -7244,7 +7264,7 @@ function parseInit(bare, path11, text2) {
|
|
|
7244
7264
|
break;
|
|
7245
7265
|
}
|
|
7246
7266
|
}
|
|
7247
|
-
return new InitSummary(bare,
|
|
7267
|
+
return new InitSummary(bare, path12, /^re/i.test(response), gitDir);
|
|
7248
7268
|
}
|
|
7249
7269
|
var InitSummary;
|
|
7250
7270
|
var initResponseRegex;
|
|
@@ -7253,9 +7273,9 @@ var init_InitSummary = __esm({
|
|
|
7253
7273
|
"src/lib/responses/InitSummary.ts"() {
|
|
7254
7274
|
"use strict";
|
|
7255
7275
|
InitSummary = class {
|
|
7256
|
-
constructor(bare,
|
|
7276
|
+
constructor(bare, path12, existing, gitDir) {
|
|
7257
7277
|
this.bare = bare;
|
|
7258
|
-
this.path =
|
|
7278
|
+
this.path = path12;
|
|
7259
7279
|
this.existing = existing;
|
|
7260
7280
|
this.gitDir = gitDir;
|
|
7261
7281
|
}
|
|
@@ -7267,7 +7287,7 @@ var init_InitSummary = __esm({
|
|
|
7267
7287
|
function hasBareCommand(command) {
|
|
7268
7288
|
return command.includes(bareCommand);
|
|
7269
7289
|
}
|
|
7270
|
-
function initTask(bare = false,
|
|
7290
|
+
function initTask(bare = false, path12, customArgs) {
|
|
7271
7291
|
const commands = ["init", ...customArgs];
|
|
7272
7292
|
if (bare && !hasBareCommand(commands)) {
|
|
7273
7293
|
commands.splice(1, 0, bareCommand);
|
|
@@ -7276,7 +7296,7 @@ function initTask(bare = false, path11, customArgs) {
|
|
|
7276
7296
|
commands,
|
|
7277
7297
|
format: "utf-8",
|
|
7278
7298
|
parser(text2) {
|
|
7279
|
-
return parseInit(commands.includes("--bare"),
|
|
7299
|
+
return parseInit(commands.includes("--bare"), path12, text2);
|
|
7280
7300
|
}
|
|
7281
7301
|
};
|
|
7282
7302
|
}
|
|
@@ -8092,12 +8112,12 @@ var init_FileStatusSummary = __esm({
|
|
|
8092
8112
|
"use strict";
|
|
8093
8113
|
fromPathRegex = /^(.+)\0(.+)$/;
|
|
8094
8114
|
FileStatusSummary = class {
|
|
8095
|
-
constructor(
|
|
8096
|
-
this.path =
|
|
8115
|
+
constructor(path12, index, working_dir) {
|
|
8116
|
+
this.path = path12;
|
|
8097
8117
|
this.index = index;
|
|
8098
8118
|
this.working_dir = working_dir;
|
|
8099
8119
|
if (index === "R" || working_dir === "R") {
|
|
8100
|
-
const detail = fromPathRegex.exec(
|
|
8120
|
+
const detail = fromPathRegex.exec(path12) || [null, path12, path12];
|
|
8101
8121
|
this.from = detail[2] || "";
|
|
8102
8122
|
this.path = detail[1] || "";
|
|
8103
8123
|
}
|
|
@@ -8128,14 +8148,14 @@ function splitLine(result, lineStr) {
|
|
|
8128
8148
|
default:
|
|
8129
8149
|
return;
|
|
8130
8150
|
}
|
|
8131
|
-
function data(index, workingDir,
|
|
8151
|
+
function data(index, workingDir, path12) {
|
|
8132
8152
|
const raw = `${index}${workingDir}`;
|
|
8133
8153
|
const handler = parsers6.get(raw);
|
|
8134
8154
|
if (handler) {
|
|
8135
|
-
handler(result,
|
|
8155
|
+
handler(result, path12);
|
|
8136
8156
|
}
|
|
8137
8157
|
if (raw !== "##" && raw !== "!!") {
|
|
8138
|
-
result.files.push(new FileStatusSummary(
|
|
8158
|
+
result.files.push(new FileStatusSummary(path12, index, workingDir));
|
|
8139
8159
|
}
|
|
8140
8160
|
}
|
|
8141
8161
|
}
|
|
@@ -8448,9 +8468,9 @@ var init_simple_git_api = __esm({
|
|
|
8448
8468
|
next
|
|
8449
8469
|
);
|
|
8450
8470
|
}
|
|
8451
|
-
hashObject(
|
|
8471
|
+
hashObject(path12, write) {
|
|
8452
8472
|
return this._runTask(
|
|
8453
|
-
hashObjectTask(
|
|
8473
|
+
hashObjectTask(path12, write === true),
|
|
8454
8474
|
trailingFunctionArgument(arguments)
|
|
8455
8475
|
);
|
|
8456
8476
|
}
|
|
@@ -8803,8 +8823,8 @@ var init_branch = __esm({
|
|
|
8803
8823
|
}
|
|
8804
8824
|
});
|
|
8805
8825
|
function toPath(input) {
|
|
8806
|
-
const
|
|
8807
|
-
return
|
|
8826
|
+
const path12 = input.trim().replace(/^["']|["']$/g, "");
|
|
8827
|
+
return path12 && (0, import_node_path3.normalize)(path12);
|
|
8808
8828
|
}
|
|
8809
8829
|
var parseCheckIgnore;
|
|
8810
8830
|
var init_CheckIgnore = __esm({
|
|
@@ -9118,8 +9138,8 @@ __export(sub_module_exports, {
|
|
|
9118
9138
|
subModuleTask: () => subModuleTask,
|
|
9119
9139
|
updateSubModuleTask: () => updateSubModuleTask
|
|
9120
9140
|
});
|
|
9121
|
-
function addSubModuleTask(repo,
|
|
9122
|
-
return subModuleTask(["add", repo,
|
|
9141
|
+
function addSubModuleTask(repo, path12) {
|
|
9142
|
+
return subModuleTask(["add", repo, path12]);
|
|
9123
9143
|
}
|
|
9124
9144
|
function initSubModuleTask(customArgs) {
|
|
9125
9145
|
return subModuleTask(["init", ...customArgs]);
|
|
@@ -9449,8 +9469,8 @@ var require_git = __commonJS2({
|
|
|
9449
9469
|
}
|
|
9450
9470
|
return this._runTask(straightThroughStringTask2(command, this._trimmed), next);
|
|
9451
9471
|
};
|
|
9452
|
-
Git2.prototype.submoduleAdd = function(repo,
|
|
9453
|
-
return this._runTask(addSubModuleTask2(repo,
|
|
9472
|
+
Git2.prototype.submoduleAdd = function(repo, path12, then) {
|
|
9473
|
+
return this._runTask(addSubModuleTask2(repo, path12), trailingFunctionArgument2(arguments));
|
|
9454
9474
|
};
|
|
9455
9475
|
Git2.prototype.submoduleUpdate = function(args, then) {
|
|
9456
9476
|
return this._runTask(
|
|
@@ -10249,7 +10269,7 @@ var import_node_path5 = require("path");
|
|
|
10249
10269
|
// ../git/dist/sagas/tree.js
|
|
10250
10270
|
var import_node_fs3 = require("fs");
|
|
10251
10271
|
var fs8 = __toESM(require("fs/promises"), 1);
|
|
10252
|
-
var
|
|
10272
|
+
var path10 = __toESM(require("path"), 1);
|
|
10253
10273
|
var tar = __toESM(require("tar"), 1);
|
|
10254
10274
|
|
|
10255
10275
|
// ../git/dist/git-saga.js
|
|
@@ -10276,14 +10296,14 @@ var CaptureTreeSaga = class extends GitSaga {
|
|
|
10276
10296
|
tempIndexPath = null;
|
|
10277
10297
|
async executeGitOperations(input) {
|
|
10278
10298
|
const { baseDir, lastTreeHash, archivePath, signal } = input;
|
|
10279
|
-
const tmpDir =
|
|
10299
|
+
const tmpDir = path10.join(baseDir, ".git", "posthog-code-tmp");
|
|
10280
10300
|
await this.step({
|
|
10281
10301
|
name: "create_tmp_dir",
|
|
10282
10302
|
execute: () => fs8.mkdir(tmpDir, { recursive: true }),
|
|
10283
10303
|
rollback: async () => {
|
|
10284
10304
|
}
|
|
10285
10305
|
});
|
|
10286
|
-
this.tempIndexPath =
|
|
10306
|
+
this.tempIndexPath = path10.join(tmpDir, `index-${Date.now()}`);
|
|
10287
10307
|
const tempIndexGit = this.git.env({
|
|
10288
10308
|
...process.env,
|
|
10289
10309
|
GIT_INDEX_FILE: this.tempIndexPath
|
|
@@ -10338,14 +10358,14 @@ var CaptureTreeSaga = class extends GitSaga {
|
|
|
10338
10358
|
if (filesToArchive.length === 0) {
|
|
10339
10359
|
return void 0;
|
|
10340
10360
|
}
|
|
10341
|
-
const existingFiles = filesToArchive.filter((f) => (0, import_node_fs3.existsSync)(
|
|
10361
|
+
const existingFiles = filesToArchive.filter((f) => (0, import_node_fs3.existsSync)(path10.join(baseDir, f)));
|
|
10342
10362
|
if (existingFiles.length === 0) {
|
|
10343
10363
|
return void 0;
|
|
10344
10364
|
}
|
|
10345
10365
|
await this.step({
|
|
10346
10366
|
name: "create_archive",
|
|
10347
10367
|
execute: async () => {
|
|
10348
|
-
const archiveDir =
|
|
10368
|
+
const archiveDir = path10.dirname(archivePath);
|
|
10349
10369
|
await fs8.mkdir(archiveDir, { recursive: true });
|
|
10350
10370
|
await tar.create({
|
|
10351
10371
|
gzip: true,
|
|
@@ -10454,7 +10474,7 @@ var ApplyTreeSaga = class extends GitSaga {
|
|
|
10454
10474
|
const filesToExtract = changes.filter((c) => c.status !== "D").map((c) => c.path);
|
|
10455
10475
|
await this.readOnlyStep("backup_existing_files", async () => {
|
|
10456
10476
|
for (const filePath of filesToExtract) {
|
|
10457
|
-
const fullPath =
|
|
10477
|
+
const fullPath = path10.join(baseDir, filePath);
|
|
10458
10478
|
try {
|
|
10459
10479
|
const content = await fs8.readFile(fullPath);
|
|
10460
10480
|
this.fileBackups.set(filePath, content);
|
|
@@ -10473,10 +10493,10 @@ var ApplyTreeSaga = class extends GitSaga {
|
|
|
10473
10493
|
},
|
|
10474
10494
|
rollback: async () => {
|
|
10475
10495
|
for (const filePath of this.extractedFiles) {
|
|
10476
|
-
const fullPath =
|
|
10496
|
+
const fullPath = path10.join(baseDir, filePath);
|
|
10477
10497
|
const backup = this.fileBackups.get(filePath);
|
|
10478
10498
|
if (backup) {
|
|
10479
|
-
const dir =
|
|
10499
|
+
const dir = path10.dirname(fullPath);
|
|
10480
10500
|
await fs8.mkdir(dir, { recursive: true }).catch(() => {
|
|
10481
10501
|
});
|
|
10482
10502
|
await fs8.writeFile(fullPath, backup).catch(() => {
|
|
@@ -10490,7 +10510,7 @@ var ApplyTreeSaga = class extends GitSaga {
|
|
|
10490
10510
|
});
|
|
10491
10511
|
}
|
|
10492
10512
|
for (const change of changes.filter((c) => c.status === "D")) {
|
|
10493
|
-
const fullPath =
|
|
10513
|
+
const fullPath = path10.join(baseDir, change.path);
|
|
10494
10514
|
const backupContent = await this.readOnlyStep(`backup_${change.path}`, async () => {
|
|
10495
10515
|
try {
|
|
10496
10516
|
return await fs8.readFile(fullPath);
|
|
@@ -10506,7 +10526,7 @@ var ApplyTreeSaga = class extends GitSaga {
|
|
|
10506
10526
|
},
|
|
10507
10527
|
rollback: async () => {
|
|
10508
10528
|
if (backupContent) {
|
|
10509
|
-
const dir =
|
|
10529
|
+
const dir = path10.dirname(fullPath);
|
|
10510
10530
|
await fs8.mkdir(dir, { recursive: true }).catch(() => {
|
|
10511
10531
|
});
|
|
10512
10532
|
await fs8.writeFile(fullPath, backupContent).catch(() => {
|